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 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 321 | decodeOptions := gopacket.DecodeOptions{ |
| 322 | Lazy: true, |
| 323 | NoCopy: true, |
| 324 | } |
| 325 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 326 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 327 | 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] | 328 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 329 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 330 | } |
| 331 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 332 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 333 | 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] | 334 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 335 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 336 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 337 | // insert some check on detected OMCI decoding issues and log them |
| 338 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 339 | // even though allowed from omci-lib due to set relaxed decoding |
| 340 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 341 | // (compare mib_sync.go unknownAttrLayer) |
| 342 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 343 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 344 | errMsg := failure.Error() |
| 345 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 346 | "device-id": oo.deviceID, "issue": errMsg}) |
| 347 | } |
| 348 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 349 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 350 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 351 | 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] | 352 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 353 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 354 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 355 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 356 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
| 357 | "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 358 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 359 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 360 | // We expect to find the TID in the oo.rxSchedulerMap |
| 361 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 362 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 363 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 364 | logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 365 | if omciMsg.TransactionID == 0 { |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 366 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 367 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 368 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 369 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 370 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 371 | 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] | 372 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 373 | //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] | 374 | oo.mutexRxSchedMap.Lock() |
| 375 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 376 | if ok && rxCallbackEntry.CbFunction != nil { |
| 377 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 378 | oo.printRxMessage(ctx, rxMsg) |
| 379 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 380 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 381 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 382 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 383 | isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet) |
| 384 | if err != nil { |
| 385 | // qualified error logging already done in function above |
| 386 | if !rxCallbackEntry.FramePrint { |
| 387 | oo.printRxMessage(ctx, rxMsg) |
| 388 | } |
| 389 | return fmt.Errorf("could not decode further layers %s", oo.deviceID) |
| 390 | } |
| 391 | if isSuccessfulResponse { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 392 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 393 | } else { |
| 394 | logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type", |
| 395 | log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID}) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 396 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 397 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 398 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 399 | // so do not clean up the TransactionID in that case. |
| 400 | if omciMsg.MessageType != omci.TestResponseType { |
| 401 | // having posted the response the request is regarded as 'done' |
| 402 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 403 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 404 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 405 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 406 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 407 | oo.mutexRxSchedMap.Unlock() |
| 408 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 409 | oo.printRxMessage(ctx, rxMsg) |
| 410 | 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] | 411 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 412 | /* py code was: |
| 413 | Receive and OMCI message from the proxy channel to the OLT. |
| 414 | |
| 415 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 416 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 417 | """ |
| 418 | if not self.enabled: |
| 419 | return |
| 420 | |
| 421 | try: |
| 422 | now = arrow.utcnow() |
| 423 | d = None |
| 424 | |
| 425 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 426 | # save the current value of the entity_id_to_class_map, then |
| 427 | # replace it with our custom one before decode, and then finally |
| 428 | # restore it later. Tried other ways but really made the code messy. |
| 429 | saved_me_map = omci_entities.entity_id_to_class_map |
| 430 | omci_entities.entity_id_to_class_map = self._me_map |
| 431 | |
| 432 | try: |
| 433 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 434 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 435 | except KeyError as e: |
| 436 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 437 | 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] | 438 | rx_frame = self._decode_unknown_me(msg) |
| 439 | self._rx_unknown_me += 1 |
| 440 | |
| 441 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 442 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 443 | return |
| 444 | |
| 445 | finally: |
| 446 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 447 | |
| 448 | rx_tid = rx_frame.fields['transaction_id'] |
| 449 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 450 | 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] | 451 | # Filter the Test Result frame and route through receive onu |
| 452 | # message method. |
| 453 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 454 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 455 | return self._receive_onu_message(rx_frame) |
| 456 | |
| 457 | # Previously unreachable if this is the very first round-trip Rx or we |
| 458 | # have been running consecutive errors |
| 459 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 460 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 461 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 462 | |
| 463 | self._rx_frames += 1 |
| 464 | self._consecutive_errors = 0 |
| 465 | |
| 466 | try: |
| 467 | high_priority = self._tid_is_high_priority(rx_tid) |
| 468 | index = self._get_priority_index(high_priority) |
| 469 | |
| 470 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 471 | last_tx_tuple = self._tx_request[index] |
| 472 | |
| 473 | if last_tx_tuple is None or \ |
| 474 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 475 | # Possible late Rx on a message that timed-out |
| 476 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 477 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 478 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 479 | self._rx_unknown_tid += 1 |
| 480 | self._rx_late += 1 |
| 481 | return |
| 482 | |
| 483 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 484 | if dc is not None and not dc.cancelled and not dc.called: |
| 485 | dc.cancel() |
| 486 | |
| 487 | _secs = self._update_rx_tx_stats(now, ts) |
| 488 | |
| 489 | # Late arrival already serviced by a timeout? |
| 490 | if d.called: |
| 491 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 492 | 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] | 493 | return |
| 494 | |
| 495 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 496 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 497 | if d is not None: |
| 498 | return d.errback(failure.Failure(e)) |
| 499 | return |
| 500 | |
| 501 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 502 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 503 | tx_tid = tx_frame.fields['transaction_id']) |
| 504 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 505 | |
| 506 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 507 | self._rx_response[index] = rx_frame |
| 508 | d.callback(rx_frame) |
| 509 | |
| 510 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 511 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 512 | */ |
| 513 | } |
| 514 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 515 | /* |
| 516 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 517 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 518 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 519 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 520 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 521 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 522 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 523 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 524 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 525 | delete(oo.rxSchedulerMap, tid) |
| 526 | } |
| 527 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 528 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 529 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 530 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 531 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 532 | if timeout != 0 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 533 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 534 | oo.mutexRxSchedMap.Lock() |
| 535 | // 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] | 536 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 537 | oo.mutexRxSchedMap.Unlock() |
| 538 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 539 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 540 | 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] | 541 | //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] | 542 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 543 | txFrame, |
| 544 | timeout, |
| 545 | retry, |
| 546 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 547 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 548 | receiveCallbackPair, |
| 549 | nil, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 550 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 551 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 552 | oo.mutexMonReq.Lock() |
| 553 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 554 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 555 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 556 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 557 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 558 | return nil |
| 559 | } |
| 560 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 561 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 562 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 563 | } |
| 564 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 565 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 566 | // Avoid accessing the txQueues from parallel send routines to block |
| 567 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 568 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 569 | // for the corresponding response too (t.b.d.). |
| 570 | oo.mutexSendQueuedRequests.Lock() |
| 571 | defer oo.mutexSendQueuedRequests.Unlock() |
| 572 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 573 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 574 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 575 | return |
| 576 | } |
| 577 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 578 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 579 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 580 | return |
| 581 | } |
| 582 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 583 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 584 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 585 | oo.mutexHighPrioTxQueue.Lock() |
| 586 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 587 | for oo.highPrioTxQueue.Len() > 0 { |
| 588 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 589 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
| 590 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 591 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 592 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 593 | } |
| 594 | return nil |
| 595 | } |
| 596 | |
| 597 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 598 | oo.mutexLowPrioTxQueue.Lock() |
| 599 | for oo.lowPrioTxQueue.Len() > 0 { |
| 600 | queueElement := oo.lowPrioTxQueue.Front() // First element |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 601 | // check if the element is for onu sw section |
| 602 | aOmciTxReq := queueElement.Value.(OmciTransferStructure) |
| 603 | if aOmciTxReq.OnuSwWindow != nil { |
| 604 | if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil { |
| 605 | oo.mutexLowPrioTxQueue.Unlock() |
| 606 | return err |
| 607 | } |
| 608 | } else { |
| 609 | err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)) |
| 610 | if err != nil { |
| 611 | oo.mutexLowPrioTxQueue.Unlock() |
| 612 | return err |
| 613 | } |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 614 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 615 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 616 | // Interrupt the sending of low priority requests to process any high priority requests |
| 617 | // that may have arrived in the meantime |
| 618 | oo.mutexLowPrioTxQueue.Unlock() |
| 619 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 620 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 621 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 622 | oo.mutexLowPrioTxQueue.Lock() |
| 623 | } |
| 624 | |
| 625 | oo.mutexLowPrioTxQueue.Unlock() |
| 626 | return nil |
| 627 | } |
| 628 | |
| 629 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 630 | if omciTxRequest.withFramePrint { |
| 631 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 632 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 633 | "device-id": oo.deviceID, |
| 634 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 635 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 636 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 637 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 638 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 639 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 640 | ChildDeviceId: oo.deviceID, |
| 641 | Message: omciTxRequest.txFrame, |
| 642 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 643 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 644 | } |
| 645 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 646 | if sendErr != nil { |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 647 | logger.Errorw(ctx, "send omci request error", log.Fields{"device-id": oo.deviceID, "ChildId": oo.deviceID, "error": sendErr}) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 648 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 649 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 650 | return nil |
| 651 | } |
| 652 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 653 | // GetNextTid - TODO: add comment |
| 654 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 655 | var next uint16 |
| 656 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 657 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 658 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 659 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 660 | if oo.hpTid < 0x8000 { |
| 661 | oo.hpTid = 0x8000 |
| 662 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 663 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 664 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 665 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 666 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 667 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 668 | if oo.tid >= 0x8000 { |
| 669 | oo.tid = 1 |
| 670 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 671 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 672 | } |
| 673 | return next |
| 674 | } |
| 675 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 676 | //GetOnuSwSecNextTid get the next low prio tid for the onu sw sections |
| 677 | //onu sw sections uses only low priority tids |
| 678 | //The mutexTid lock should be taken prior to using this function |
| 679 | func (oo *OmciCC) GetOnuSwSecNextTid() uint16 { |
| 680 | next := oo.tid |
| 681 | oo.tid++ |
| 682 | if oo.tid >= 0x8000 { |
| 683 | oo.tid = 1 |
| 684 | } |
| 685 | return next |
| 686 | } |
| 687 | |
| 688 | //GetOnuSwSecLastTid gets the last allocated tid |
| 689 | //The mutexTid lock should be taken prior to using this function |
| 690 | func (oo *OmciCC) GetOnuSwSecLastTid() uint16 { |
| 691 | next := oo.tid |
| 692 | lastAllocatedTid := next - 1 |
| 693 | return lastAllocatedTid |
| 694 | } |
| 695 | |
| 696 | //LockMutexTID locks mutexTid |
| 697 | func (oo *OmciCC) LockMutexTID() { |
| 698 | oo.mutexTid.Lock() |
| 699 | } |
| 700 | |
| 701 | //UnLockMutexTID unlocks mutexTid |
| 702 | func (oo *OmciCC) UnLockMutexTID() { |
| 703 | oo.mutexTid.Unlock() |
| 704 | } |
| 705 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 706 | // ################################################################################### |
| 707 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 708 | |
| 709 | // Serialize - TODO: add comment |
| 710 | 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] | 711 | omciLayer := &omci.OMCI{ |
| 712 | TransactionID: tid, |
| 713 | MessageType: msgType, |
| 714 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 715 | return serializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 716 | } |
| 717 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 718 | 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] | 719 | var options gopacket.SerializeOptions |
| 720 | options.FixLengths = true |
| 721 | |
| 722 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 723 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 724 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 725 | 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] | 726 | return nil, err |
| 727 | } |
| 728 | return buffer.Bytes(), nil |
| 729 | } |
| 730 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 731 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 732 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 733 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 734 | hex.Encode(dst, omciPkt) |
| 735 | return dst, nil |
| 736 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 737 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 738 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 739 | //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] | 740 | 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] | 741 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 742 | 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] | 743 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 744 | |
| 745 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 746 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 747 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 748 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 749 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 750 | oo.mutexMonReq.RLock() |
| 751 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 752 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 753 | select { |
| 754 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 755 | default: |
| 756 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 757 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 758 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 759 | } else { |
| 760 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 761 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 762 | } |
| 763 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 764 | |
| 765 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 766 | // 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] | 767 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 768 | Type: OMCI, |
| 769 | Data: OmciMessage{ |
| 770 | OmciMsg: omciMsg, |
| 771 | OmciPacket: packet, |
| 772 | }, |
| 773 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 774 | //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] | 775 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 776 | |
| 777 | return nil |
| 778 | } |
| 779 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 780 | // SendMibReset sends MibResetRequest |
| 781 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 782 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 783 | 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] | 784 | request := &omci.MibResetRequest{ |
| 785 | MeBasePacket: omci.MeBasePacket{ |
| 786 | EntityClass: me.OnuDataClassID, |
| 787 | }, |
| 788 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 789 | tid := oo.GetNextTid(highPrio) |
| 790 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 791 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 792 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 793 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 794 | return err |
| 795 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 796 | omciRxCallbackPair := CallbackPair{ |
| 797 | CbKey: tid, |
| 798 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 799 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 800 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 803 | // SendReboot sends RebootRequest |
| 804 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 805 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 806 | request := &omci.RebootRequest{ |
| 807 | MeBasePacket: omci.MeBasePacket{ |
| 808 | EntityClass: me.OnuGClassID, |
| 809 | }, |
| 810 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 811 | tid := oo.GetNextTid(highPrio) |
| 812 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 813 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 814 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 815 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 816 | return err |
| 817 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 818 | omciRxCallbackPair := CallbackPair{ |
| 819 | CbKey: tid, |
| 820 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 821 | } |
| 822 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 823 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 824 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 825 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 826 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 827 | return err |
| 828 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 829 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 830 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 831 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 832 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 833 | return err |
| 834 | } |
| 835 | return nil |
| 836 | } |
| 837 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 838 | // SendMibUpload sends MibUploadRequest |
| 839 | func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 840 | 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] | 841 | request := &omci.MibUploadRequest{ |
| 842 | MeBasePacket: omci.MeBasePacket{ |
| 843 | EntityClass: me.OnuDataClassID, |
| 844 | }, |
| 845 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 846 | tid := oo.GetNextTid(highPrio) |
| 847 | pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 848 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 849 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 850 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 851 | return err |
| 852 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 853 | oo.UploadSequNo = 0 |
| 854 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 855 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 856 | omciRxCallbackPair := CallbackPair{ |
| 857 | CbKey: tid, |
| 858 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 859 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 860 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 861 | } |
| 862 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 863 | // SendMibUploadNext sends MibUploadNextRequest |
| 864 | func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
| 865 | 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] | 866 | request := &omci.MibUploadNextRequest{ |
| 867 | MeBasePacket: omci.MeBasePacket{ |
| 868 | EntityClass: me.OnuDataClassID, |
| 869 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 870 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 871 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 872 | tid := oo.GetNextTid(highPrio) |
| 873 | pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 874 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 875 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 876 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 877 | return err |
| 878 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 879 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 880 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 881 | omciRxCallbackPair := CallbackPair{ |
| 882 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 883 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 884 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 885 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 886 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 887 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 888 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 889 | } |
| 890 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 891 | // SendGetAllAlarm gets all alarm ME instances |
| 892 | 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] | 893 | logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID}) |
| 894 | request := &omci.GetAllAlarmsRequest{ |
| 895 | MeBasePacket: omci.MeBasePacket{ |
| 896 | EntityClass: me.OnuDataClassID, |
| 897 | }, |
| 898 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 899 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 900 | tid := oo.GetNextTid(highPrio) |
| 901 | pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 902 | if err != nil { |
| 903 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{ |
| 904 | "Err": err, "device-id": oo.deviceID}) |
| 905 | return err |
| 906 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 907 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 908 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 909 | omciRxCallbackPair := CallbackPair{ |
| 910 | CbKey: tid, |
| 911 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 912 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 913 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 914 | } |
| 915 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 916 | // SendGetAllAlarmNext gets next alarm ME instance |
| 917 | func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error { |
| 918 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 919 | 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] | 920 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
| 921 | request := &omci.GetAllAlarmsNextRequest{ |
| 922 | MeBasePacket: omci.MeBasePacket{ |
| 923 | EntityClass: me.OnuDataClassID, |
| 924 | }, |
| 925 | CommandSequenceNumber: alarmUploadSeqNo, |
| 926 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 927 | tid := oo.GetNextTid(highPrio) |
| 928 | pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 929 | if err != nil { |
| 930 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{ |
| 931 | "Err": err, "device-id": oo.deviceID}) |
| 932 | return err |
| 933 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 934 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 935 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 936 | omciRxCallbackPair := CallbackPair{ |
| 937 | CbKey: tid, |
| 938 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 939 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 940 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 941 | } |
| 942 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 943 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 944 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 945 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 946 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 947 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 948 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 949 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 950 | EntityID: GalEthernetEID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 951 | Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 952 | } |
| 953 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 954 | if omciErr.GetError() == nil { |
| 955 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 956 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 957 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 958 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 959 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 960 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 961 | } |
| 962 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 963 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 964 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 965 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 966 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 967 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 968 | } |
| 969 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 970 | omciRxCallbackPair := CallbackPair{ |
| 971 | CbKey: tid, |
| 972 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 973 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 974 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 975 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 976 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 977 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 978 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 979 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 980 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 981 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 982 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 983 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 984 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 985 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 986 | } |
| 987 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 988 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 989 | // 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] | 990 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 991 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 992 | 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] | 993 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 994 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 995 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 996 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 997 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 998 | // read ONU-2G from DB ???? //TODO!!! |
| 999 | meParams := me.ParamData{ |
| 1000 | EntityID: 0, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1001 | Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1002 | } |
| 1003 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 1004 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1005 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1006 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1007 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1008 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1009 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1012 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1013 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1014 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1015 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1016 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1017 | } |
| 1018 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1019 | omciRxCallbackPair := CallbackPair{ |
| 1020 | CbKey: tid, |
| 1021 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1022 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1023 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1024 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1025 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1026 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1027 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1028 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1029 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1030 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1031 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1032 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1033 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1034 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1037 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 1038 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 1039 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1040 | tid := oo.GetNextTid(highPrio) |
| 1041 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1042 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1043 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1044 | |
| 1045 | meParams := me.ParamData{ |
| 1046 | EntityID: instID, |
| 1047 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1048 | me.MacBridgeServiceProfile_Priority: 0x8000, |
| 1049 | me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s |
| 1050 | me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s |
| 1051 | me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s |
| 1052 | me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1053 | }, |
| 1054 | } |
| 1055 | |
| 1056 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1057 | if omciErr.GetError() == nil { |
| 1058 | //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] | 1059 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1060 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1061 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1062 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1063 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1064 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1065 | } |
| 1066 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1067 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1068 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1069 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1070 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1071 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1072 | } |
| 1073 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1074 | omciRxCallbackPair := CallbackPair{ |
| 1075 | CbKey: tid, |
| 1076 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1077 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1078 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1079 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1080 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1081 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1082 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1083 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1084 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1085 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1086 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1087 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1088 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1089 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1090 | } |
| 1091 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1092 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1093 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1094 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1095 | tid := oo.GetNextTid(highPrio) |
| 1096 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1097 | if idErr != nil { |
| 1098 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1099 | "Err": idErr, "device-id": oo.deviceID}) |
| 1100 | return nil, idErr |
| 1101 | } |
| 1102 | 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] | 1103 | "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] | 1104 | |
| 1105 | meParams := me.ParamData{ |
| 1106 | EntityID: instID, |
| 1107 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1108 | me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1109 | me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo, |
| 1110 | me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType), |
| 1111 | me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1112 | }, |
| 1113 | } |
| 1114 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1115 | if omciErr.GetError() == nil { |
| 1116 | //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] | 1117 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1118 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1119 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1120 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1121 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1122 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1123 | } |
| 1124 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1125 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1126 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1127 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1128 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1129 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1132 | omciRxCallbackPair := CallbackPair{ |
| 1133 | CbKey: tid, |
| 1134 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1135 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1136 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1137 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1138 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1139 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1140 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1141 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1142 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1143 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1144 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1145 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1146 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1147 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1150 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1151 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1152 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1153 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1154 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1155 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1156 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1157 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1158 | |
| 1159 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1160 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1161 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1162 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1163 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1164 | assType = uint8(10) // for VEIP |
| 1165 | } |
| 1166 | meParams := me.ParamData{ |
| 1167 | EntityID: instID, |
| 1168 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1169 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType, |
| 1170 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1171 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1172 | }, |
| 1173 | } |
| 1174 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1175 | if omciErr.GetError() == nil { |
| 1176 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1177 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1178 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1179 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1180 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1181 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1182 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1185 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1186 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1187 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1188 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1189 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1192 | omciRxCallbackPair := CallbackPair{ |
| 1193 | CbKey: tid, |
| 1194 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1195 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1196 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1197 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1198 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1199 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1200 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1201 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1202 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1203 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1204 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1205 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1206 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1207 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1208 | } |
| 1209 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1210 | // SendSetOnuGLS sets OnuG ME instance |
| 1211 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1212 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1213 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1214 | 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] | 1215 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1216 | |
| 1217 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1218 | meParams := me.ParamData{ |
| 1219 | EntityID: 0, |
| 1220 | Attributes: requestedAttributes, |
| 1221 | } |
| 1222 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1223 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1224 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1225 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1226 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1227 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1228 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1229 | } |
| 1230 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1231 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1232 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1233 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1234 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1235 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1238 | omciRxCallbackPair := CallbackPair{ |
| 1239 | CbKey: tid, |
| 1240 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1241 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1242 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1243 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1244 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1245 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1246 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1247 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1248 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1249 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1250 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1251 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1252 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1253 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1254 | } |
| 1255 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1256 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1257 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1258 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1259 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1260 | 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] | 1261 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1262 | |
| 1263 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1264 | meParams := me.ParamData{ |
| 1265 | EntityID: aInstNo, |
| 1266 | Attributes: requestedAttributes, |
| 1267 | } |
| 1268 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1269 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1270 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1271 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1272 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1273 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1274 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1277 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1278 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1279 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1280 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1281 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1282 | } |
| 1283 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1284 | omciRxCallbackPair := CallbackPair{ |
| 1285 | CbKey: tid, |
| 1286 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1287 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1288 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1289 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1290 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1291 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1292 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1293 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1294 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1295 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1296 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1297 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1298 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1299 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1300 | } |
| 1301 | |
| 1302 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1303 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1304 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1305 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1306 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1307 | 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] | 1308 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1309 | |
| 1310 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1311 | meParams := me.ParamData{ |
| 1312 | EntityID: aInstNo, |
| 1313 | Attributes: requestedAttributes, |
| 1314 | } |
| 1315 | meInstance, omciErr := me.NewUniG(meParams) |
| 1316 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1317 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1318 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1319 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1320 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1321 | return nil |
| 1322 | } |
| 1323 | |
| 1324 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1325 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1326 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1327 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1328 | return nil |
| 1329 | } |
| 1330 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1331 | omciRxCallbackPair := CallbackPair{ |
| 1332 | CbKey: tid, |
| 1333 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
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 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1336 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1337 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1338 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1339 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1340 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1341 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1342 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1343 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1344 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1345 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1346 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1347 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1348 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1349 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1350 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1351 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1352 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1353 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1354 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1355 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1356 | |
| 1357 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1358 | meParams := me.ParamData{ |
| 1359 | EntityID: aInstNo, |
| 1360 | Attributes: requestedAttributes, |
| 1361 | } |
| 1362 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1363 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1364 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1365 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1366 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1367 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1368 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1371 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1372 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1373 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1374 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1375 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1378 | omciRxCallbackPair := CallbackPair{ |
| 1379 | CbKey: tid, |
| 1380 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1381 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1382 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1383 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1384 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1385 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1386 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1387 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1388 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1389 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1390 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1391 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1392 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1393 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1394 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1395 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1396 | // SendGetMe gets ME instance |
| 1397 | 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] | 1398 | timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1399 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1400 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1401 | 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] | 1402 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1403 | |
| 1404 | meParams := me.ParamData{ |
| 1405 | EntityID: entityID, |
| 1406 | Attributes: requestedAttributes, |
| 1407 | } |
| 1408 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1409 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1410 | meClassIDName := meInstance.GetName() |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1411 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1412 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1413 | 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] | 1414 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1415 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1416 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1417 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1418 | 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] | 1419 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1420 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1421 | omciRxCallbackPair := CallbackPair{ |
| 1422 | CbKey: tid, |
| 1423 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1424 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1425 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1426 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1427 | 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] | 1428 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1429 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1430 | 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] | 1431 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1432 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1433 | 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] | 1434 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1437 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1438 | 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] | 1439 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1440 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1441 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1442 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1443 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1444 | |
| 1445 | request := &omci.GetRequest{ |
| 1446 | MeBasePacket: omci.MeBasePacket{ |
| 1447 | EntityInstance: entityID, |
| 1448 | EntityClass: classID, |
| 1449 | }, |
| 1450 | AttributeMask: requestedAttributesMask, |
| 1451 | } |
| 1452 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1453 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1454 | if err != nil { |
| 1455 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1456 | return err |
| 1457 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1458 | omciRxCallbackPair := CallbackPair{ |
| 1459 | CbKey: tid, |
| 1460 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1461 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1462 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1463 | if err != nil { |
| 1464 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1465 | return err |
| 1466 | } |
| 1467 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1468 | return nil |
| 1469 | } |
| 1470 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1471 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1472 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1473 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1474 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1475 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1476 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1477 | |
| 1478 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1479 | EntityID: aInstID, |
| 1480 | Attributes: me.AttributeValueMap{ |
| 1481 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1482 | me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF, |
| 1483 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF, |
| 1484 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF, |
| 1485 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF, |
| 1486 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF, |
| 1487 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF, |
| 1488 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF, |
| 1489 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF, |
| 1490 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF, |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1491 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1492 | } |
| 1493 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1494 | if omciErr.GetError() == nil { |
| 1495 | //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] | 1496 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1497 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1498 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1499 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1500 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1501 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1502 | } |
| 1503 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1504 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1505 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1506 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1507 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1508 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1509 | } |
| 1510 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1511 | omciRxCallbackPair := CallbackPair{ |
| 1512 | CbKey: tid, |
| 1513 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1514 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1515 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1516 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1517 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1518 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1519 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1520 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1521 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1522 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1523 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1524 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1525 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1526 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1527 | } |
| 1528 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1529 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1530 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1531 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1532 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1533 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1534 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1535 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1536 | |
| 1537 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1538 | if omciErr.GetError() == nil { |
| 1539 | //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] | 1540 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1541 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1542 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1543 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1544 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1545 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1546 | } |
| 1547 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1548 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1549 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1550 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1551 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1552 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1553 | } |
| 1554 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1555 | omciRxCallbackPair := CallbackPair{ |
| 1556 | CbKey: tid, |
| 1557 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1558 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1559 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1560 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1561 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1562 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1563 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1564 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1565 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1566 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1567 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1568 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1569 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1570 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1571 | } |
| 1572 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1573 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1574 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1575 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1576 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1577 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1578 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1579 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1580 | |
| 1581 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1582 | if omciErr.GetError() == nil { |
| 1583 | //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] | 1584 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1585 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1586 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1587 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1588 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1589 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1590 | } |
| 1591 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1592 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1593 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1594 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1595 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1596 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1597 | } |
| 1598 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1599 | omciRxCallbackPair := CallbackPair{ |
| 1600 | CbKey: tid, |
| 1601 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1602 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1603 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1604 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1605 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1606 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1607 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1608 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1609 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1610 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1611 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1612 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1613 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1614 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1615 | } |
| 1616 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1617 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1618 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1619 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1620 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1621 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1622 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1623 | |
| 1624 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1625 | if omciErr.GetError() == nil { |
| 1626 | //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] | 1627 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1628 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1629 | if err != nil { |
| 1630 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1631 | "Err": err, "device-id": oo.deviceID}) |
| 1632 | return nil, err |
| 1633 | } |
| 1634 | |
| 1635 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1636 | if err != nil { |
| 1637 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1638 | "Err": err, "device-id": oo.deviceID}) |
| 1639 | return nil, err |
| 1640 | } |
| 1641 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1642 | omciRxCallbackPair := CallbackPair{ |
| 1643 | CbKey: tid, |
| 1644 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1645 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1646 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1647 | if err != nil { |
| 1648 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1649 | "Err": err, "device-id": oo.deviceID}) |
| 1650 | return nil, err |
| 1651 | } |
| 1652 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1653 | return meInstance, nil |
| 1654 | } |
| 1655 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1656 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1657 | return nil, omciErr.GetError() |
| 1658 | } |
| 1659 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1660 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1661 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1662 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1663 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1664 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1665 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1666 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1667 | |
| 1668 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1669 | if omciErr.GetError() == nil { |
| 1670 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1671 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1672 | oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1673 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1674 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1675 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1676 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1677 | } |
| 1678 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1679 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1680 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1681 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1682 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1683 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1684 | } |
| 1685 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1686 | omciRxCallbackPair := CallbackPair{ |
| 1687 | CbKey: tid, |
| 1688 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1689 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1690 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1691 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1692 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1693 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1694 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1695 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1696 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1697 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1698 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1699 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1700 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1701 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1702 | } |
| 1703 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1704 | // SendSetTcontVar sets TCont ME instance |
| 1705 | func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1706 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1707 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1708 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1709 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1710 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1711 | |
| 1712 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1713 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1714 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1715 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1716 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1717 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1718 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1719 | } |
| 1720 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1721 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1722 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1723 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1724 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1725 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1726 | } |
| 1727 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1728 | omciRxCallbackPair := CallbackPair{ |
| 1729 | CbKey: tid, |
| 1730 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1731 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1732 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1733 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1734 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1735 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1736 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1737 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1738 | logger.Debug(ctx, "send TCont-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1739 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1740 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1741 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1742 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1743 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1744 | } |
| 1745 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1746 | // SendSetPrioQueueVar sets PriorityQueue ME instance |
| 1747 | func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1748 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1749 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1750 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1751 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1752 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1753 | |
| 1754 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1755 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1756 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1757 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1758 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1759 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1760 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1761 | } |
| 1762 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1763 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1764 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1765 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1766 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1767 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1768 | } |
| 1769 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1770 | omciRxCallbackPair := CallbackPair{ |
| 1771 | CbKey: tid, |
| 1772 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1773 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1774 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1775 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1776 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1777 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1778 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1779 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1780 | logger.Debug(ctx, "send PrioQueue-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1781 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1782 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1783 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1784 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1785 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1786 | } |
| 1787 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1788 | // SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance |
| 1789 | func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1790 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1791 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1792 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1793 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1794 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1795 | |
| 1796 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1797 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1798 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1799 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1800 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1801 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1802 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1803 | } |
| 1804 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1805 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1806 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1807 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1808 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1809 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1810 | } |
| 1811 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1812 | omciRxCallbackPair := CallbackPair{ |
| 1813 | CbKey: tid, |
| 1814 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1815 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1816 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1817 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1818 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1819 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1820 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1821 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1822 | logger.Debug(ctx, "send 1PMapper-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1823 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1824 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1825 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1826 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1827 | return nil, omciErr.GetError() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1828 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1829 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1830 | // SendCreateVtfdVar creates VlanTaggingFilterData ME instance |
| 1831 | func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1832 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1833 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1834 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1835 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1836 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1837 | |
| 1838 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1839 | if omciErr.GetError() == nil { |
| 1840 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1841 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1842 | oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1843 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1844 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1845 | "Err": err, "device-id": oo.deviceID}) |
| 1846 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1847 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1848 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1849 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1850 | } |
| 1851 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1852 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1853 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1854 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1855 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1856 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1857 | } |
| 1858 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1859 | omciRxCallbackPair := CallbackPair{ |
| 1860 | CbKey: tid, |
| 1861 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1862 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1863 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1864 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1865 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1866 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1867 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1868 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1869 | logger.Debug(ctx, "send VTFD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1870 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1871 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1872 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1873 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1874 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1875 | } |
| 1876 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1877 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1878 | func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1879 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1880 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1881 | 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] | 1882 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1883 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1884 | |
| 1885 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1886 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1887 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1888 | oframe.TransactionID(tid)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1889 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1890 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1891 | "Err": err, "device-id": oo.deviceID}) |
| 1892 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1893 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1894 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1895 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1896 | } |
| 1897 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1898 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1899 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1900 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1901 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1902 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1903 | } |
| 1904 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1905 | omciRxCallbackPair := CallbackPair{ |
| 1906 | CbKey: tid, |
| 1907 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1908 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1909 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1910 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1911 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1912 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1913 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1914 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1915 | logger.Debug(ctx, "send VTFD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1916 | return meInstance, nil |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1917 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1918 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1919 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1920 | return nil, omciErr.GetError() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1921 | } |
| 1922 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1923 | // SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1924 | func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1925 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1926 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1927 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1928 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1929 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1930 | |
| 1931 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1932 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1933 | //EnhancedMode not yet supported, used with default options |
| 1934 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1935 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1936 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1937 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1938 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1939 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1940 | } |
| 1941 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1942 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1943 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1944 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1945 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1946 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1947 | } |
| 1948 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1949 | omciRxCallbackPair := CallbackPair{ |
| 1950 | CbKey: tid, |
| 1951 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1952 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1953 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1954 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1955 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1956 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1957 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1958 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1959 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1960 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1961 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1962 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1963 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1964 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1965 | } |
| 1966 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1967 | // SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1968 | func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1969 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1970 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1971 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1972 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1973 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1974 | |
| 1975 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1976 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1977 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1978 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1979 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1980 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1981 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1982 | } |
| 1983 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1984 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1985 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1986 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1987 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1988 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1989 | } |
| 1990 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1991 | omciRxCallbackPair := CallbackPair{ |
| 1992 | CbKey: tid, |
| 1993 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1994 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1995 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1996 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1997 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1998 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1999 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2000 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2001 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2002 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2003 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2004 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2005 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2006 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2007 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2008 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2009 | // SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2010 | func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2011 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2012 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2013 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2014 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2015 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2016 | |
| 2017 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2018 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2019 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2020 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2021 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2022 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2023 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2024 | } |
| 2025 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2026 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2027 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2028 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2029 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2030 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2031 | } |
| 2032 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2033 | omciRxCallbackPair := CallbackPair{ |
| 2034 | CbKey: tid, |
| 2035 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2036 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2037 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2038 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2039 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2040 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2041 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2042 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2043 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2044 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2045 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2046 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2047 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2048 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2049 | } |
| 2050 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2051 | // SendDeleteVtfd deletes VlanTaggingFilterData ME instance |
| 2052 | func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2053 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2054 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2055 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2056 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2057 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2058 | |
| 2059 | meParams := me.ParamData{EntityID: aInstID} |
| 2060 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 2061 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2062 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2063 | oframe.TransactionID(tid)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2064 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2065 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2066 | "Err": err, "device-id": oo.deviceID}) |
| 2067 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2068 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2069 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2070 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2071 | } |
| 2072 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2073 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2074 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2075 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2076 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2077 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2078 | } |
| 2079 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2080 | omciRxCallbackPair := CallbackPair{ |
| 2081 | CbKey: tid, |
| 2082 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2083 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2084 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2085 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2086 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2087 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2088 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2089 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2090 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2091 | return meInstance, nil |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2092 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2093 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2094 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2095 | return nil, omciErr.GetError() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2096 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2097 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2098 | // SendCreateTDVar creates TrafficDescriptor ME instance |
| 2099 | func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2100 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2101 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2102 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2103 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2104 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2105 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2106 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2107 | if err != nil { |
| 2108 | 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] | 2109 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2110 | } |
| 2111 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2112 | if err != nil { |
| 2113 | 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] | 2114 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2115 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2116 | omciRxCallbackPair := CallbackPair{ |
| 2117 | CbKey: tid, |
| 2118 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2119 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2120 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2121 | if err != nil { |
| 2122 | 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] | 2123 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2124 | } |
| 2125 | logger.Debug(ctx, "send TD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2126 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2127 | } |
| 2128 | 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] | 2129 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2130 | } |
| 2131 | |
| 2132 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2133 | func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2134 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2135 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2136 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2137 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2138 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2139 | |
| 2140 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2141 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2142 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2143 | if err != nil { |
| 2144 | 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] | 2145 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2146 | } |
| 2147 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2148 | if err != nil { |
| 2149 | 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] | 2150 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2151 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2152 | omciRxCallbackPair := CallbackPair{ |
| 2153 | CbKey: tid, |
| 2154 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2155 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2156 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2157 | if err != nil { |
| 2158 | 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] | 2159 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2160 | } |
| 2161 | logger.Debug(ctx, "send TD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2162 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2163 | } |
| 2164 | 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] | 2165 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2166 | |
| 2167 | } |
| 2168 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2169 | // SendDeleteTD - TODO: add comment |
| 2170 | func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2171 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2172 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2173 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2174 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2175 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2176 | |
| 2177 | meParams := me.ParamData{EntityID: aInstID} |
| 2178 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 2179 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2180 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2181 | if err != nil { |
| 2182 | 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] | 2183 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2184 | } |
| 2185 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2186 | if err != nil { |
| 2187 | 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] | 2188 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2189 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2190 | omciRxCallbackPair := CallbackPair{ |
| 2191 | CbKey: tid, |
| 2192 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2193 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2194 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2195 | if err != nil { |
| 2196 | 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] | 2197 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2198 | } |
| 2199 | logger.Debug(ctx, "send TD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2200 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2201 | } |
| 2202 | 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] | 2203 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2204 | |
| 2205 | } |
| 2206 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2207 | // SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance |
| 2208 | func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2209 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2210 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2211 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2212 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2213 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2214 | |
| 2215 | meParams := me.ParamData{EntityID: aInstID} |
| 2216 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2217 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2218 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2219 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2220 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2221 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2222 | "Err": err, "device-id": oo.deviceID}) |
| 2223 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2224 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2225 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2226 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2227 | } |
| 2228 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2229 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2230 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2231 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2232 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2233 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2234 | } |
| 2235 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2236 | omciRxCallbackPair := CallbackPair{ |
| 2237 | CbKey: tid, |
| 2238 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2239 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2240 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2241 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2242 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2243 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2244 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2245 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2246 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2247 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2248 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2249 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2250 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2251 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2252 | } |
| 2253 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2254 | // SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance |
| 2255 | func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2256 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2257 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2258 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2259 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2260 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2261 | |
| 2262 | meParams := me.ParamData{EntityID: aInstID} |
| 2263 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2264 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2265 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2266 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2267 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2268 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2269 | "Err": err, "device-id": oo.deviceID}) |
| 2270 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2271 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2272 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2273 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2274 | } |
| 2275 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2276 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2277 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2278 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2279 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2280 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2281 | } |
| 2282 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2283 | omciRxCallbackPair := CallbackPair{ |
| 2284 | CbKey: tid, |
| 2285 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2286 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2287 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2288 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2289 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2290 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2291 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2292 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2293 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2294 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2295 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2296 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2297 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2298 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2299 | } |
| 2300 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2301 | // SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance |
| 2302 | func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2303 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2304 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2305 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2306 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2307 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2308 | |
| 2309 | meParams := me.ParamData{EntityID: aInstID} |
| 2310 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2311 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2312 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2313 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2314 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2315 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2316 | "Err": err, "device-id": oo.deviceID}) |
| 2317 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2318 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2319 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2320 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2321 | } |
| 2322 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2323 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2324 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2325 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2326 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2327 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2328 | } |
| 2329 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2330 | omciRxCallbackPair := CallbackPair{ |
| 2331 | CbKey: tid, |
| 2332 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2333 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2334 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2335 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2336 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2337 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2338 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2339 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2340 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2341 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2342 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2343 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2344 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2345 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2346 | } |
| 2347 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2348 | // SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance |
| 2349 | func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2350 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2351 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2352 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2353 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2354 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2355 | |
| 2356 | meParams := me.ParamData{EntityID: aInstID} |
| 2357 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2358 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2359 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2360 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2361 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2362 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2363 | "Err": err, "device-id": oo.deviceID}) |
| 2364 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2365 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2366 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2367 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2368 | } |
| 2369 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2370 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2371 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2372 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2373 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2374 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2375 | } |
| 2376 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2377 | omciRxCallbackPair := CallbackPair{ |
| 2378 | CbKey: tid, |
| 2379 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2380 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2381 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2382 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2383 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2384 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2385 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2386 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2387 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2388 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2389 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2390 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2391 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2392 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2393 | } |
| 2394 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2395 | // SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance |
| 2396 | func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2397 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2398 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2399 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2400 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2401 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2402 | |
| 2403 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2404 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2405 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2406 | oframe.AddDefaults(true)) |
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 encode MulticastGEMIWTP for 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 | } |
| 2411 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2412 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2413 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2414 | 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] | 2415 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2416 | } |
| 2417 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2418 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2419 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2420 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2421 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2422 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2423 | 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] | 2424 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2425 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2426 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2427 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2428 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2429 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2430 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2431 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2432 | } |
| 2433 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2434 | // SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance |
| 2435 | func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2436 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2437 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2438 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2439 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2440 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2441 | |
| 2442 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2443 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2444 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2445 | oframe.AddDefaults(true)) |
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 encode MulticastGEMIWTP for 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 | } |
| 2450 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2451 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2452 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2453 | 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] | 2454 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2455 | } |
| 2456 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2457 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2458 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2459 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2460 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2461 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2462 | 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] | 2463 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2464 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2465 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2466 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2467 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2468 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2469 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2470 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2471 | } |
| 2472 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2473 | // SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance |
| 2474 | func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2475 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2476 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2477 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2478 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2479 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2480 | |
| 2481 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2482 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2483 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2484 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2485 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2486 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2487 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2488 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2489 | } |
| 2490 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2491 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2492 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2493 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2494 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2495 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2496 | } |
| 2497 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2498 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2499 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2500 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2501 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2502 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2503 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2504 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2505 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2506 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2507 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2508 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2509 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2510 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2511 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2512 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2513 | } |
| 2514 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2515 | // SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance |
| 2516 | func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2517 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2518 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2519 | logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2520 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2521 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2522 | |
| 2523 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2524 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2525 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2526 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2527 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2528 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2529 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2530 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2531 | } |
| 2532 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2533 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2534 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2535 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2536 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2537 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2538 | } |
| 2539 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2540 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2541 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2542 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2543 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2544 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2545 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2546 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2547 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2548 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2549 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2550 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2551 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2552 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2553 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2554 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2555 | } |
| 2556 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2557 | // SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance |
| 2558 | func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2559 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2560 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2561 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2562 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2563 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2564 | |
| 2565 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2566 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2567 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2568 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2569 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2570 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2571 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2572 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2573 | } |
| 2574 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2575 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2576 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2577 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2578 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2579 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2580 | } |
| 2581 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2582 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2583 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2584 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2585 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2586 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2587 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2588 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2589 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2590 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2591 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2592 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2593 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2594 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2595 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2596 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2597 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2598 | |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2599 | // SendCreateVoipVoiceCTP nolint: unused |
| 2600 | func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2601 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2602 | tid := oo.GetNextTid(highPrio) |
| 2603 | logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2604 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2605 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2606 | |
| 2607 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2608 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2609 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2610 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2611 | if err != nil { |
| 2612 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err, |
| 2613 | "device-id": oo.deviceID}) |
| 2614 | return nil, err |
| 2615 | } |
| 2616 | |
| 2617 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2618 | if err != nil { |
| 2619 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err, |
| 2620 | "device-id": oo.deviceID}) |
| 2621 | return nil, err |
| 2622 | } |
| 2623 | |
| 2624 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2625 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2626 | } |
| 2627 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2628 | if err != nil { |
| 2629 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err, |
| 2630 | "device-id": oo.deviceID}) |
| 2631 | return nil, err |
| 2632 | } |
| 2633 | logger.Debug(ctx, "send VoipVoiceCTP-create-msg done") |
| 2634 | return meInstance, nil |
| 2635 | } |
| 2636 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2637 | "device-id": oo.deviceID}) |
| 2638 | return nil, omciErr.GetError() |
| 2639 | } |
| 2640 | |
| 2641 | // SendSetVoipVoiceCTP nolint: unused |
| 2642 | func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2643 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2644 | tid := oo.GetNextTid(highPrio) |
| 2645 | logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2646 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2647 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2648 | |
| 2649 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2650 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2651 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2652 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2653 | if err != nil { |
| 2654 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err, |
| 2655 | "device-id": oo.deviceID}) |
| 2656 | return nil, err |
| 2657 | } |
| 2658 | |
| 2659 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2660 | if err != nil { |
| 2661 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err, |
| 2662 | "device-id": oo.deviceID}) |
| 2663 | return nil, err |
| 2664 | } |
| 2665 | |
| 2666 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2667 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2668 | } |
| 2669 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2670 | if err != nil { |
| 2671 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err, |
| 2672 | "device-id": oo.deviceID}) |
| 2673 | return nil, err |
| 2674 | } |
| 2675 | logger.Debug(ctx, "send VoipVoiceCTP-set-msg done") |
| 2676 | return meInstance, nil |
| 2677 | } |
| 2678 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2679 | "device-id": oo.deviceID}) |
| 2680 | return nil, omciErr.GetError() |
| 2681 | } |
| 2682 | |
| 2683 | // SendDeleteVoipVoiceCTP nolint: unused |
| 2684 | func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2685 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2686 | tid := oo.GetNextTid(highPrio) |
| 2687 | logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2688 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2689 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2690 | |
| 2691 | meParams := me.ParamData{EntityID: aInstID} |
| 2692 | meInstance, omciErr := me.NewVoipVoiceCtp(meParams) |
| 2693 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2694 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2695 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2696 | if err != nil { |
| 2697 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{ |
| 2698 | "Err": err, "device-id": oo.deviceID}) |
| 2699 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2700 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2701 | // (relevant to all used sendXX() methods and their error conditions) |
| 2702 | return nil, err |
| 2703 | } |
| 2704 | |
| 2705 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2706 | if err != nil { |
| 2707 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{ |
| 2708 | "Err": err, "device-id": oo.deviceID}) |
| 2709 | return nil, err |
| 2710 | } |
| 2711 | |
| 2712 | omciRxCallbackPair := CallbackPair{ |
| 2713 | CbKey: tid, |
| 2714 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2715 | } |
| 2716 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2717 | if err != nil { |
| 2718 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{ |
| 2719 | "Err": err, "device-id": oo.deviceID}) |
| 2720 | return nil, err |
| 2721 | } |
| 2722 | logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done") |
| 2723 | return meInstance, nil |
| 2724 | } |
| 2725 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{ |
| 2726 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2727 | return nil, omciErr.GetError() |
| 2728 | } |
| 2729 | |
| 2730 | // SendCreateVoipMediaProfile nolint: unused |
| 2731 | func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2732 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2733 | tid := oo.GetNextTid(highPrio) |
| 2734 | logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2735 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2736 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2737 | |
| 2738 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2739 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2740 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2741 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2742 | if err != nil { |
| 2743 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err, |
| 2744 | "device-id": oo.deviceID}) |
| 2745 | return nil, err |
| 2746 | } |
| 2747 | |
| 2748 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2749 | if err != nil { |
| 2750 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err, |
| 2751 | "device-id": oo.deviceID}) |
| 2752 | return nil, err |
| 2753 | } |
| 2754 | |
| 2755 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2756 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2757 | } |
| 2758 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2759 | if err != nil { |
| 2760 | logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err, |
| 2761 | "device-id": oo.deviceID}) |
| 2762 | return nil, err |
| 2763 | } |
| 2764 | logger.Debug(ctx, "send VoipMediaProfile-create-msg done") |
| 2765 | return meInstance, nil |
| 2766 | } |
| 2767 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2768 | "device-id": oo.deviceID}) |
| 2769 | return nil, omciErr.GetError() |
| 2770 | } |
| 2771 | |
| 2772 | // SendSetVoipMediaProfile nolint: unused |
| 2773 | func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2774 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2775 | tid := oo.GetNextTid(highPrio) |
| 2776 | logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2777 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2778 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2779 | |
| 2780 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2781 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2782 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2783 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2784 | if err != nil { |
| 2785 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err, |
| 2786 | "device-id": oo.deviceID}) |
| 2787 | return nil, err |
| 2788 | } |
| 2789 | |
| 2790 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2791 | if err != nil { |
| 2792 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err, |
| 2793 | "device-id": oo.deviceID}) |
| 2794 | return nil, err |
| 2795 | } |
| 2796 | |
| 2797 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2798 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2799 | } |
| 2800 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2801 | if err != nil { |
| 2802 | logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err, |
| 2803 | "device-id": oo.deviceID}) |
| 2804 | return nil, err |
| 2805 | } |
| 2806 | logger.Debug(ctx, "send VoipMediaProfile-set-msg done") |
| 2807 | return meInstance, nil |
| 2808 | } |
| 2809 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2810 | "device-id": oo.deviceID}) |
| 2811 | return nil, omciErr.GetError() |
| 2812 | } |
| 2813 | |
| 2814 | // SendDeleteVoipMediaProfile nolint: unused |
| 2815 | func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2816 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2817 | tid := oo.GetNextTid(highPrio) |
| 2818 | logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2819 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2820 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2821 | |
| 2822 | meParams := me.ParamData{EntityID: aInstID} |
| 2823 | meInstance, omciErr := me.NewVoipMediaProfile(meParams) |
| 2824 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2825 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2826 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2827 | if err != nil { |
| 2828 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{ |
| 2829 | "Err": err, "device-id": oo.deviceID}) |
| 2830 | return nil, err |
| 2831 | } |
| 2832 | |
| 2833 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2834 | if err != nil { |
| 2835 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{ |
| 2836 | "Err": err, "device-id": oo.deviceID}) |
| 2837 | return nil, err |
| 2838 | } |
| 2839 | |
| 2840 | omciRxCallbackPair := CallbackPair{ |
| 2841 | CbKey: tid, |
| 2842 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2843 | } |
| 2844 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2845 | if err != nil { |
| 2846 | logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{ |
| 2847 | "Err": err, "device-id": oo.deviceID}) |
| 2848 | return nil, err |
| 2849 | } |
| 2850 | logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done") |
| 2851 | return meInstance, nil |
| 2852 | } |
| 2853 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{ |
| 2854 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2855 | return nil, omciErr.GetError() |
| 2856 | } |
| 2857 | |
| 2858 | // SendCreateVoiceServiceProfile nolint: unused |
| 2859 | func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2860 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2861 | tid := oo.GetNextTid(highPrio) |
| 2862 | logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2863 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2864 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2865 | |
| 2866 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 2867 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2868 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2869 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2870 | if err != nil { |
| 2871 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err, |
| 2872 | "device-id": oo.deviceID}) |
| 2873 | return nil, err |
| 2874 | } |
| 2875 | |
| 2876 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2877 | if err != nil { |
| 2878 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err, |
| 2879 | "device-id": oo.deviceID}) |
| 2880 | return nil, err |
| 2881 | } |
| 2882 | |
| 2883 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2884 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2885 | } |
| 2886 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2887 | if err != nil { |
| 2888 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err, |
| 2889 | "device-id": oo.deviceID}) |
| 2890 | return nil, err |
| 2891 | } |
| 2892 | logger.Debug(ctx, "send VoiceServiceProfile-create-msg done") |
| 2893 | return meInstance, nil |
| 2894 | } |
| 2895 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2896 | "device-id": oo.deviceID}) |
| 2897 | return nil, omciErr.GetError() |
| 2898 | } |
| 2899 | |
| 2900 | // SendSetVoiceServiceProfile nolint: unused |
| 2901 | func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2902 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2903 | tid := oo.GetNextTid(highPrio) |
| 2904 | logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2905 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2906 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2907 | |
| 2908 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 2909 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2910 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2911 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2912 | if err != nil { |
| 2913 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err, |
| 2914 | "device-id": oo.deviceID}) |
| 2915 | return nil, err |
| 2916 | } |
| 2917 | |
| 2918 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2919 | if err != nil { |
| 2920 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err, |
| 2921 | "device-id": oo.deviceID}) |
| 2922 | return nil, err |
| 2923 | } |
| 2924 | |
| 2925 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2926 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2927 | } |
| 2928 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2929 | if err != nil { |
| 2930 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err, |
| 2931 | "device-id": oo.deviceID}) |
| 2932 | return nil, err |
| 2933 | } |
| 2934 | logger.Debug(ctx, "send VoiceServiceProfile-set-msg done") |
| 2935 | return meInstance, nil |
| 2936 | } |
| 2937 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2938 | "device-id": oo.deviceID}) |
| 2939 | return nil, omciErr.GetError() |
| 2940 | } |
| 2941 | |
| 2942 | // SendDeleteVoiceServiceProfile nolint: unused |
| 2943 | func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2944 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2945 | tid := oo.GetNextTid(highPrio) |
| 2946 | logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2947 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2948 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2949 | |
| 2950 | meParams := me.ParamData{EntityID: aInstID} |
| 2951 | meInstance, omciErr := me.NewVoiceServiceProfile(meParams) |
| 2952 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2953 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2954 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2955 | if err != nil { |
| 2956 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{ |
| 2957 | "Err": err, "device-id": oo.deviceID}) |
| 2958 | return nil, err |
| 2959 | } |
| 2960 | |
| 2961 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2962 | if err != nil { |
| 2963 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{ |
| 2964 | "Err": err, "device-id": oo.deviceID}) |
| 2965 | return nil, err |
| 2966 | } |
| 2967 | |
| 2968 | omciRxCallbackPair := CallbackPair{ |
| 2969 | CbKey: tid, |
| 2970 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2971 | } |
| 2972 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2973 | if err != nil { |
| 2974 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{ |
| 2975 | "Err": err, "device-id": oo.deviceID}) |
| 2976 | return nil, err |
| 2977 | } |
| 2978 | logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done") |
| 2979 | return meInstance, nil |
| 2980 | } |
| 2981 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{ |
| 2982 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2983 | return nil, omciErr.GetError() |
| 2984 | } |
| 2985 | |
| 2986 | // SendCreateSIPUserData nolint: unused |
| 2987 | func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 2988 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2989 | tid := oo.GetNextTid(highPrio) |
| 2990 | logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2991 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2992 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2993 | |
| 2994 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 2995 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2996 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2997 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2998 | if err != nil { |
| 2999 | logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err, |
| 3000 | "device-id": oo.deviceID}) |
| 3001 | return nil, err |
| 3002 | } |
| 3003 | |
| 3004 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3005 | if err != nil { |
| 3006 | logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err, |
| 3007 | "device-id": oo.deviceID}) |
| 3008 | return nil, err |
| 3009 | } |
| 3010 | |
| 3011 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3012 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3013 | } |
| 3014 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3015 | if err != nil { |
| 3016 | logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err, |
| 3017 | "device-id": oo.deviceID}) |
| 3018 | return nil, err |
| 3019 | } |
| 3020 | logger.Debug(ctx, "send SIPUserData-create-msg done") |
| 3021 | return meInstance, nil |
| 3022 | } |
| 3023 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3024 | "device-id": oo.deviceID}) |
| 3025 | return nil, omciErr.GetError() |
| 3026 | } |
| 3027 | |
| 3028 | // SendSetSIPUserData nolint: unused |
| 3029 | func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3030 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3031 | tid := oo.GetNextTid(highPrio) |
| 3032 | logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3033 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3034 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3035 | |
| 3036 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3037 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3038 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3039 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3040 | if err != nil { |
| 3041 | logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err, |
| 3042 | "device-id": oo.deviceID}) |
| 3043 | return nil, err |
| 3044 | } |
| 3045 | |
| 3046 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3047 | if err != nil { |
| 3048 | logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err, |
| 3049 | "device-id": oo.deviceID}) |
| 3050 | return nil, err |
| 3051 | } |
| 3052 | |
| 3053 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3054 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3055 | } |
| 3056 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3057 | if err != nil { |
| 3058 | logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err, |
| 3059 | "device-id": oo.deviceID}) |
| 3060 | return nil, err |
| 3061 | } |
| 3062 | logger.Debug(ctx, "send SIPUserData-set-msg done") |
| 3063 | return meInstance, nil |
| 3064 | } |
| 3065 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3066 | "device-id": oo.deviceID}) |
| 3067 | return nil, omciErr.GetError() |
| 3068 | } |
| 3069 | |
| 3070 | // SendDeleteSIPUserData nolint: unused |
| 3071 | func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3072 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3073 | tid := oo.GetNextTid(highPrio) |
| 3074 | logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3075 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3076 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3077 | |
| 3078 | meParams := me.ParamData{EntityID: aInstID} |
| 3079 | meInstance, omciErr := me.NewSipUserData(meParams) |
| 3080 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3081 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3082 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3083 | if err != nil { |
| 3084 | logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{ |
| 3085 | "Err": err, "device-id": oo.deviceID}) |
| 3086 | return nil, err |
| 3087 | } |
| 3088 | |
| 3089 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3090 | if err != nil { |
| 3091 | logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{ |
| 3092 | "Err": err, "device-id": oo.deviceID}) |
| 3093 | return nil, err |
| 3094 | } |
| 3095 | |
| 3096 | omciRxCallbackPair := CallbackPair{ |
| 3097 | CbKey: tid, |
| 3098 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3099 | } |
| 3100 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3101 | if err != nil { |
| 3102 | logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{ |
| 3103 | "Err": err, "device-id": oo.deviceID}) |
| 3104 | return nil, err |
| 3105 | } |
| 3106 | logger.Debug(ctx, "send SIPUserData-Delete-msg done") |
| 3107 | return meInstance, nil |
| 3108 | } |
| 3109 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{ |
| 3110 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3111 | return nil, omciErr.GetError() |
| 3112 | } |
| 3113 | |
| 3114 | // SendCreateVoipApplicationServiceProfile nolint: unused |
| 3115 | func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3116 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3117 | tid := oo.GetNextTid(highPrio) |
| 3118 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3119 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3120 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3121 | |
| 3122 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3123 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3124 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3125 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3126 | if err != nil { |
| 3127 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err, |
| 3128 | "device-id": oo.deviceID}) |
| 3129 | return nil, err |
| 3130 | } |
| 3131 | |
| 3132 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3133 | if err != nil { |
| 3134 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3135 | "device-id": oo.deviceID}) |
| 3136 | return nil, err |
| 3137 | } |
| 3138 | |
| 3139 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3140 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3141 | } |
| 3142 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3143 | if err != nil { |
| 3144 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3145 | "device-id": oo.deviceID}) |
| 3146 | return nil, err |
| 3147 | } |
| 3148 | logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done") |
| 3149 | return meInstance, nil |
| 3150 | } |
| 3151 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3152 | "device-id": oo.deviceID}) |
| 3153 | return nil, omciErr.GetError() |
| 3154 | } |
| 3155 | |
| 3156 | // SendSetVoipApplicationServiceProfile nolint: unused |
| 3157 | func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3158 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3159 | tid := oo.GetNextTid(highPrio) |
| 3160 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3161 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3162 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3163 | |
| 3164 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3165 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3166 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3167 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3168 | if err != nil { |
| 3169 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err, |
| 3170 | "device-id": oo.deviceID}) |
| 3171 | return nil, err |
| 3172 | } |
| 3173 | |
| 3174 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3175 | if err != nil { |
| 3176 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3177 | "device-id": oo.deviceID}) |
| 3178 | return nil, err |
| 3179 | } |
| 3180 | |
| 3181 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3182 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3183 | } |
| 3184 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3185 | if err != nil { |
| 3186 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3187 | "device-id": oo.deviceID}) |
| 3188 | return nil, err |
| 3189 | } |
| 3190 | logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done") |
| 3191 | return meInstance, nil |
| 3192 | } |
| 3193 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3194 | "device-id": oo.deviceID}) |
| 3195 | return nil, omciErr.GetError() |
| 3196 | } |
| 3197 | |
| 3198 | // SendDeleteVoipApplicationServiceProfile nolint: unused |
| 3199 | func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3200 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3201 | tid := oo.GetNextTid(highPrio) |
| 3202 | logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3203 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3204 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3205 | |
| 3206 | meParams := me.ParamData{EntityID: aInstID} |
| 3207 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams) |
| 3208 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3209 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3210 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3211 | if err != nil { |
| 3212 | logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{ |
| 3213 | "Err": err, "device-id": oo.deviceID}) |
| 3214 | return nil, err |
| 3215 | } |
| 3216 | |
| 3217 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3218 | if err != nil { |
| 3219 | logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3220 | "Err": err, "device-id": oo.deviceID}) |
| 3221 | return nil, err |
| 3222 | } |
| 3223 | |
| 3224 | omciRxCallbackPair := CallbackPair{ |
| 3225 | CbKey: tid, |
| 3226 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3227 | } |
| 3228 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3229 | if err != nil { |
| 3230 | logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3231 | "Err": err, "device-id": oo.deviceID}) |
| 3232 | return nil, err |
| 3233 | } |
| 3234 | logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done") |
| 3235 | return meInstance, nil |
| 3236 | } |
| 3237 | logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{ |
| 3238 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3239 | return nil, omciErr.GetError() |
| 3240 | } |
| 3241 | |
| 3242 | // SendCreateSIPAgentConfigData nolint: unused |
| 3243 | func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3244 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3245 | tid := oo.GetNextTid(highPrio) |
| 3246 | logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3247 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3248 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3249 | |
| 3250 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3251 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3252 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3253 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3254 | if err != nil { |
| 3255 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err, |
| 3256 | "device-id": oo.deviceID}) |
| 3257 | return nil, err |
| 3258 | } |
| 3259 | |
| 3260 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3261 | if err != nil { |
| 3262 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err, |
| 3263 | "device-id": oo.deviceID}) |
| 3264 | return nil, err |
| 3265 | } |
| 3266 | |
| 3267 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3268 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3269 | } |
| 3270 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3271 | if err != nil { |
| 3272 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err, |
| 3273 | "device-id": oo.deviceID}) |
| 3274 | return nil, err |
| 3275 | } |
| 3276 | logger.Debug(ctx, "send SIPAgentConfigData-create-msg done") |
| 3277 | return meInstance, nil |
| 3278 | } |
| 3279 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3280 | "device-id": oo.deviceID}) |
| 3281 | return nil, omciErr.GetError() |
| 3282 | } |
| 3283 | |
| 3284 | // SendSetSIPAgentConfigData nolint: unused |
| 3285 | func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3286 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3287 | tid := oo.GetNextTid(highPrio) |
| 3288 | logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3289 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3290 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3291 | |
| 3292 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3293 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3294 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3295 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3296 | if err != nil { |
| 3297 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err, |
| 3298 | "device-id": oo.deviceID}) |
| 3299 | return nil, err |
| 3300 | } |
| 3301 | |
| 3302 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3303 | if err != nil { |
| 3304 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err, |
| 3305 | "device-id": oo.deviceID}) |
| 3306 | return nil, err |
| 3307 | } |
| 3308 | |
| 3309 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3310 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3311 | } |
| 3312 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3313 | if err != nil { |
| 3314 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err, |
| 3315 | "device-id": oo.deviceID}) |
| 3316 | return nil, err |
| 3317 | } |
| 3318 | logger.Debug(ctx, "send SIPAgentConfigData-set-msg done") |
| 3319 | return meInstance, nil |
| 3320 | } |
| 3321 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3322 | "device-id": oo.deviceID}) |
| 3323 | return nil, omciErr.GetError() |
| 3324 | } |
| 3325 | |
| 3326 | // SendDeleteSIPAgentConfigData nolint: unused |
| 3327 | func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3328 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3329 | tid := oo.GetNextTid(highPrio) |
| 3330 | logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3331 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3332 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3333 | |
| 3334 | meParams := me.ParamData{EntityID: aInstID} |
| 3335 | meInstance, omciErr := me.NewSipAgentConfigData(meParams) |
| 3336 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3337 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3338 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3339 | if err != nil { |
| 3340 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{ |
| 3341 | "Err": err, "device-id": oo.deviceID}) |
| 3342 | return nil, err |
| 3343 | } |
| 3344 | |
| 3345 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3346 | if err != nil { |
| 3347 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{ |
| 3348 | "Err": err, "device-id": oo.deviceID}) |
| 3349 | return nil, err |
| 3350 | } |
| 3351 | |
| 3352 | omciRxCallbackPair := CallbackPair{ |
| 3353 | CbKey: tid, |
| 3354 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3355 | } |
| 3356 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3357 | if err != nil { |
| 3358 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{ |
| 3359 | "Err": err, "device-id": oo.deviceID}) |
| 3360 | return nil, err |
| 3361 | } |
| 3362 | logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done") |
| 3363 | return meInstance, nil |
| 3364 | } |
| 3365 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3366 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3367 | return nil, omciErr.GetError() |
| 3368 | } |
| 3369 | |
| 3370 | // SendCreateTCPUDPConfigData nolint: unused |
| 3371 | func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3372 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3373 | tid := oo.GetNextTid(highPrio) |
| 3374 | logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3375 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3376 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3377 | |
| 3378 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3379 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3380 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3381 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3382 | if err != nil { |
| 3383 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err, |
| 3384 | "device-id": oo.deviceID}) |
| 3385 | return nil, err |
| 3386 | } |
| 3387 | |
| 3388 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3389 | if err != nil { |
| 3390 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err, |
| 3391 | "device-id": oo.deviceID}) |
| 3392 | return nil, err |
| 3393 | } |
| 3394 | |
| 3395 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3396 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3397 | } |
| 3398 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3399 | if err != nil { |
| 3400 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err, |
| 3401 | "device-id": oo.deviceID}) |
| 3402 | return nil, err |
| 3403 | } |
| 3404 | logger.Debug(ctx, "send TCPUDPConfigData-create-msg done") |
| 3405 | return meInstance, nil |
| 3406 | } |
| 3407 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3408 | "device-id": oo.deviceID}) |
| 3409 | return nil, omciErr.GetError() |
| 3410 | } |
| 3411 | |
| 3412 | // SendSetTCPUDPConfigData nolint: unused |
| 3413 | func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3414 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3415 | tid := oo.GetNextTid(highPrio) |
| 3416 | logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3417 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3418 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3419 | |
| 3420 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3421 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3422 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3423 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3424 | if err != nil { |
| 3425 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err, |
| 3426 | "device-id": oo.deviceID}) |
| 3427 | return nil, err |
| 3428 | } |
| 3429 | |
| 3430 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3431 | if err != nil { |
| 3432 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err, |
| 3433 | "device-id": oo.deviceID}) |
| 3434 | return nil, err |
| 3435 | } |
| 3436 | |
| 3437 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3438 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3439 | } |
| 3440 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3441 | if err != nil { |
| 3442 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err, |
| 3443 | "device-id": oo.deviceID}) |
| 3444 | return nil, err |
| 3445 | } |
| 3446 | logger.Debug(ctx, "send TCPUDPConfigData-set-msg done") |
| 3447 | return meInstance, nil |
| 3448 | } |
| 3449 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3450 | "device-id": oo.deviceID}) |
| 3451 | return nil, omciErr.GetError() |
| 3452 | } |
| 3453 | |
| 3454 | // SendDeleteTCPUDPConfigData nolint: unused |
| 3455 | func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3456 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3457 | tid := oo.GetNextTid(highPrio) |
| 3458 | logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3459 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3460 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3461 | |
| 3462 | meParams := me.ParamData{EntityID: aInstID} |
| 3463 | meInstance, omciErr := me.NewTcpUdpConfigData(meParams) |
| 3464 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3465 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3466 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3467 | if err != nil { |
| 3468 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{ |
| 3469 | "Err": err, "device-id": oo.deviceID}) |
| 3470 | return nil, err |
| 3471 | } |
| 3472 | |
| 3473 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3474 | if err != nil { |
| 3475 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{ |
| 3476 | "Err": err, "device-id": oo.deviceID}) |
| 3477 | return nil, err |
| 3478 | } |
| 3479 | |
| 3480 | omciRxCallbackPair := CallbackPair{ |
| 3481 | CbKey: tid, |
| 3482 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3483 | } |
| 3484 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3485 | if err != nil { |
| 3486 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{ |
| 3487 | "Err": err, "device-id": oo.deviceID}) |
| 3488 | return nil, err |
| 3489 | } |
| 3490 | logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done") |
| 3491 | return meInstance, nil |
| 3492 | } |
| 3493 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3494 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3495 | return nil, omciErr.GetError() |
| 3496 | } |
| 3497 | |
| 3498 | // SendCreateIPHostConfigData nolint: unused |
| 3499 | func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3500 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3501 | tid := oo.GetNextTid(highPrio) |
| 3502 | logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3503 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3504 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3505 | |
| 3506 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3507 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3508 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3509 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3510 | if err != nil { |
| 3511 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err, |
| 3512 | "device-id": oo.deviceID}) |
| 3513 | return nil, err |
| 3514 | } |
| 3515 | |
| 3516 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3517 | if err != nil { |
| 3518 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err, |
| 3519 | "device-id": oo.deviceID}) |
| 3520 | return nil, err |
| 3521 | } |
| 3522 | |
| 3523 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3524 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3525 | } |
| 3526 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3527 | if err != nil { |
| 3528 | logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err, |
| 3529 | "device-id": oo.deviceID}) |
| 3530 | return nil, err |
| 3531 | } |
| 3532 | logger.Debug(ctx, "send IPHostConfigData-create-msg done") |
| 3533 | return meInstance, nil |
| 3534 | } |
| 3535 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3536 | "device-id": oo.deviceID}) |
| 3537 | return nil, omciErr.GetError() |
| 3538 | } |
| 3539 | |
| 3540 | // SendSetIPHostConfigData nolint: unused |
| 3541 | func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3542 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3543 | tid := oo.GetNextTid(highPrio) |
| 3544 | logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3545 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3546 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3547 | |
| 3548 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3549 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3550 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3551 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3552 | if err != nil { |
| 3553 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err, |
| 3554 | "device-id": oo.deviceID}) |
| 3555 | return nil, err |
| 3556 | } |
| 3557 | |
| 3558 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3559 | if err != nil { |
| 3560 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err, |
| 3561 | "device-id": oo.deviceID}) |
| 3562 | return nil, err |
| 3563 | } |
| 3564 | |
| 3565 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3566 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3567 | } |
| 3568 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3569 | if err != nil { |
| 3570 | logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err, |
| 3571 | "device-id": oo.deviceID}) |
| 3572 | return nil, err |
| 3573 | } |
| 3574 | logger.Debug(ctx, "send IPHostConfigData-set-msg done") |
| 3575 | return meInstance, nil |
| 3576 | } |
| 3577 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3578 | "device-id": oo.deviceID}) |
| 3579 | return nil, omciErr.GetError() |
| 3580 | } |
| 3581 | |
| 3582 | // SendDeleteIPHostConfigData nolint: unused |
| 3583 | func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3584 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3585 | tid := oo.GetNextTid(highPrio) |
| 3586 | logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3587 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3588 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3589 | |
| 3590 | meParams := me.ParamData{EntityID: aInstID} |
| 3591 | meInstance, omciErr := me.NewIpHostConfigData(meParams) |
| 3592 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3593 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3594 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3595 | if err != nil { |
| 3596 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{ |
| 3597 | "Err": err, "device-id": oo.deviceID}) |
| 3598 | return nil, err |
| 3599 | } |
| 3600 | |
| 3601 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3602 | if err != nil { |
| 3603 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{ |
| 3604 | "Err": err, "device-id": oo.deviceID}) |
| 3605 | return nil, err |
| 3606 | } |
| 3607 | |
| 3608 | omciRxCallbackPair := CallbackPair{ |
| 3609 | CbKey: tid, |
| 3610 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3611 | } |
| 3612 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3613 | if err != nil { |
| 3614 | logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{ |
| 3615 | "Err": err, "device-id": oo.deviceID}) |
| 3616 | return nil, err |
| 3617 | } |
| 3618 | logger.Debug(ctx, "send IPHostConfigData-Delete-msg done") |
| 3619 | return meInstance, nil |
| 3620 | } |
| 3621 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{ |
| 3622 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3623 | return nil, omciErr.GetError() |
| 3624 | } |
| 3625 | |
| 3626 | // SendCreateRTPProfileData nolint: unused |
| 3627 | func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3628 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3629 | tid := oo.GetNextTid(highPrio) |
| 3630 | logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3631 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3632 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3633 | |
| 3634 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3635 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3636 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3637 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3638 | if err != nil { |
| 3639 | logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err, |
| 3640 | "device-id": oo.deviceID}) |
| 3641 | return nil, err |
| 3642 | } |
| 3643 | |
| 3644 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3645 | if err != nil { |
| 3646 | logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err, |
| 3647 | "device-id": oo.deviceID}) |
| 3648 | return nil, err |
| 3649 | } |
| 3650 | |
| 3651 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3652 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3653 | } |
| 3654 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3655 | if err != nil { |
| 3656 | logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err, |
| 3657 | "device-id": oo.deviceID}) |
| 3658 | return nil, err |
| 3659 | } |
| 3660 | logger.Debug(ctx, "send RTPProfileData-create-msg done") |
| 3661 | return meInstance, nil |
| 3662 | } |
| 3663 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3664 | "device-id": oo.deviceID}) |
| 3665 | return nil, omciErr.GetError() |
| 3666 | } |
| 3667 | |
| 3668 | // SendSetRTPProfileData nolint: unused |
| 3669 | func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3670 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3671 | tid := oo.GetNextTid(highPrio) |
| 3672 | logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3673 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3674 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3675 | |
| 3676 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3677 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3678 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3679 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3680 | if err != nil { |
| 3681 | logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err, |
| 3682 | "device-id": oo.deviceID}) |
| 3683 | return nil, err |
| 3684 | } |
| 3685 | |
| 3686 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3687 | if err != nil { |
| 3688 | logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err, |
| 3689 | "device-id": oo.deviceID}) |
| 3690 | return nil, err |
| 3691 | } |
| 3692 | |
| 3693 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3694 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3695 | } |
| 3696 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3697 | if err != nil { |
| 3698 | logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err, |
| 3699 | "device-id": oo.deviceID}) |
| 3700 | return nil, err |
| 3701 | } |
| 3702 | logger.Debug(ctx, "send RTPProfileData-set-msg done") |
| 3703 | return meInstance, nil |
| 3704 | } |
| 3705 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3706 | "device-id": oo.deviceID}) |
| 3707 | return nil, omciErr.GetError() |
| 3708 | } |
| 3709 | |
| 3710 | // SendDeleteRTPProfileData nolint: unused |
| 3711 | func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3712 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3713 | tid := oo.GetNextTid(highPrio) |
| 3714 | logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3715 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3716 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3717 | |
| 3718 | meParams := me.ParamData{EntityID: aInstID} |
| 3719 | meInstance, omciErr := me.NewRtpProfileData(meParams) |
| 3720 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3721 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3722 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3723 | if err != nil { |
| 3724 | logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{ |
| 3725 | "Err": err, "device-id": oo.deviceID}) |
| 3726 | return nil, err |
| 3727 | } |
| 3728 | |
| 3729 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3730 | if err != nil { |
| 3731 | logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{ |
| 3732 | "Err": err, "device-id": oo.deviceID}) |
| 3733 | return nil, err |
| 3734 | } |
| 3735 | |
| 3736 | omciRxCallbackPair := CallbackPair{ |
| 3737 | CbKey: tid, |
| 3738 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3739 | } |
| 3740 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3741 | if err != nil { |
| 3742 | logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{ |
| 3743 | "Err": err, "device-id": oo.deviceID}) |
| 3744 | return nil, err |
| 3745 | } |
| 3746 | logger.Debug(ctx, "send RTPProfileData-Delete-msg done") |
| 3747 | return meInstance, nil |
| 3748 | } |
| 3749 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{ |
| 3750 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3751 | return nil, omciErr.GetError() |
| 3752 | } |
| 3753 | |
| 3754 | // SendCreateNetworkDialPlanTable nolint: unused |
| 3755 | func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3756 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3757 | tid := oo.GetNextTid(highPrio) |
| 3758 | logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3759 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3760 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3761 | |
| 3762 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3763 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3764 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3765 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3766 | if err != nil { |
| 3767 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err, |
| 3768 | "device-id": oo.deviceID}) |
| 3769 | return nil, err |
| 3770 | } |
| 3771 | |
| 3772 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3773 | if err != nil { |
| 3774 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3775 | "device-id": oo.deviceID}) |
| 3776 | return nil, err |
| 3777 | } |
| 3778 | |
| 3779 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3780 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3781 | } |
| 3782 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3783 | if err != nil { |
| 3784 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3785 | "device-id": oo.deviceID}) |
| 3786 | return nil, err |
| 3787 | } |
| 3788 | logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done") |
| 3789 | return meInstance, nil |
| 3790 | } |
| 3791 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3792 | "device-id": oo.deviceID}) |
| 3793 | return nil, omciErr.GetError() |
| 3794 | } |
| 3795 | |
| 3796 | // SendSetNetworkDialPlanTable nolint: unused |
| 3797 | func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3798 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3799 | tid := oo.GetNextTid(highPrio) |
| 3800 | logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3801 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3802 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3803 | |
| 3804 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3805 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3806 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3807 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3808 | if err != nil { |
| 3809 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err, |
| 3810 | "device-id": oo.deviceID}) |
| 3811 | return nil, err |
| 3812 | } |
| 3813 | |
| 3814 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3815 | if err != nil { |
| 3816 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3817 | "device-id": oo.deviceID}) |
| 3818 | return nil, err |
| 3819 | } |
| 3820 | |
| 3821 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3822 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3823 | } |
| 3824 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3825 | if err != nil { |
| 3826 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3827 | "device-id": oo.deviceID}) |
| 3828 | return nil, err |
| 3829 | } |
| 3830 | logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done") |
| 3831 | return meInstance, nil |
| 3832 | } |
| 3833 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3834 | "device-id": oo.deviceID}) |
| 3835 | return nil, omciErr.GetError() |
| 3836 | } |
| 3837 | |
| 3838 | // SendDeleteNetworkDialPlanTable nolint: unused |
| 3839 | func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3840 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3841 | tid := oo.GetNextTid(highPrio) |
| 3842 | logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3843 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3844 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3845 | |
| 3846 | meParams := me.ParamData{EntityID: aInstID} |
| 3847 | meInstance, omciErr := me.NewNetworkDialPlanTable(meParams) |
| 3848 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3849 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3850 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3851 | if err != nil { |
| 3852 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{ |
| 3853 | "Err": err, "device-id": oo.deviceID}) |
| 3854 | return nil, err |
| 3855 | } |
| 3856 | |
| 3857 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3858 | if err != nil { |
| 3859 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{ |
| 3860 | "Err": err, "device-id": oo.deviceID}) |
| 3861 | return nil, err |
| 3862 | } |
| 3863 | |
| 3864 | omciRxCallbackPair := CallbackPair{ |
| 3865 | CbKey: tid, |
| 3866 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3867 | } |
| 3868 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3869 | if err != nil { |
| 3870 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{ |
| 3871 | "Err": err, "device-id": oo.deviceID}) |
| 3872 | return nil, err |
| 3873 | } |
| 3874 | logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done") |
| 3875 | return meInstance, nil |
| 3876 | } |
| 3877 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{ |
| 3878 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3879 | return nil, omciErr.GetError() |
| 3880 | } |
| 3881 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3882 | // SendSyncTime sends SynchronizeTimeRequest |
| 3883 | func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 3884 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3885 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 3886 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 3887 | |
| 3888 | omciLayer := &omci.OMCI{ |
| 3889 | TransactionID: tid, |
| 3890 | MessageType: omci.SynchronizeTimeRequestType, |
| 3891 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 3892 | // Length: 0x28, // Optional, defaults to 40 octets |
| 3893 | } |
| 3894 | utcTime := time.Now().UTC() |
| 3895 | request := &omci.SynchronizeTimeRequest{ |
| 3896 | MeBasePacket: omci.MeBasePacket{ |
| 3897 | EntityClass: me.OnuGClassID, |
| 3898 | // Default Instance ID is 0 |
| 3899 | }, |
| 3900 | Year: uint16(utcTime.Year()), |
| 3901 | Month: uint8(utcTime.Month()), |
| 3902 | Day: uint8(utcTime.Day()), |
| 3903 | Hour: uint8(utcTime.Hour()), |
| 3904 | Minute: uint8(utcTime.Minute()), |
| 3905 | Second: uint8(utcTime.Second()), |
| 3906 | } |
| 3907 | |
| 3908 | pkt, err := serializeOmciLayer(ctx, omciLayer, request) |
| 3909 | if err != nil { |
| 3910 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 3911 | "device-id": oo.deviceID}) |
| 3912 | return err |
| 3913 | } |
| 3914 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3915 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3916 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3917 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3918 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3919 | if err != nil { |
| 3920 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 3921 | "device-id": oo.deviceID}) |
| 3922 | return err |
| 3923 | } |
| 3924 | logger.Debug(ctx, "send synchronize time request done") |
| 3925 | return nil |
| 3926 | } |
| 3927 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3928 | // SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance |
| 3929 | func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3930 | upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3931 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3932 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3933 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 3934 | meParam := me.ParamData{EntityID: entityID} |
| 3935 | var meInstance *me.ManagedEntity |
| 3936 | var omciErr me.OmciErrors |
| 3937 | if upstream { |
| 3938 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 3939 | } else { |
| 3940 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 3941 | } |
| 3942 | if omciErr.GetError() == nil { |
| 3943 | var omciLayer *omci.OMCI |
| 3944 | var msgLayer gopacket.SerializableLayer |
| 3945 | var err error |
| 3946 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3947 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3948 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3949 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3950 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 3951 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3952 | } |
| 3953 | if err != nil { |
| 3954 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 3955 | 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] | 3956 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3960 | if err != nil { |
| 3961 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 3962 | 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] | 3963 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3964 | } |
| 3965 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3966 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3967 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3968 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3969 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3970 | if err != nil { |
| 3971 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 3972 | 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] | 3973 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3974 | } |
| 3975 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 3976 | 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] | 3977 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3978 | } |
| 3979 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 3980 | 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] | 3981 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3982 | } |
| 3983 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3984 | // SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance |
| 3985 | func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3986 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3987 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3988 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3989 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 3990 | meParam := me.ParamData{EntityID: entityID} |
| 3991 | var meInstance *me.ManagedEntity |
| 3992 | var omciErr me.OmciErrors |
| 3993 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 3994 | |
| 3995 | if omciErr.GetError() == nil { |
| 3996 | var omciLayer *omci.OMCI |
| 3997 | var msgLayer gopacket.SerializableLayer |
| 3998 | var err error |
| 3999 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4000 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4001 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4002 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4003 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4004 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4005 | } |
| 4006 | if err != nil { |
| 4007 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 4008 | 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] | 4009 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4010 | } |
| 4011 | |
| 4012 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4013 | if err != nil { |
| 4014 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 4015 | 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] | 4016 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4017 | } |
| 4018 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4019 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4020 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4021 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4022 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4023 | if err != nil { |
| 4024 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 4025 | 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] | 4026 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4027 | } |
| 4028 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 4029 | 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] | 4030 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4031 | } |
| 4032 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 4033 | 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] | 4034 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4035 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4036 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4037 | // SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance |
| 4038 | func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4039 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4040 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4041 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4042 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4043 | meParam := me.ParamData{EntityID: entityID} |
| 4044 | var meInstance *me.ManagedEntity |
| 4045 | var omciErr me.OmciErrors |
| 4046 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 4047 | |
| 4048 | if omciErr.GetError() == nil { |
| 4049 | var omciLayer *omci.OMCI |
| 4050 | var msgLayer gopacket.SerializableLayer |
| 4051 | var err error |
| 4052 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4053 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4054 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4055 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4056 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4057 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4058 | } |
| 4059 | if err != nil { |
| 4060 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 4061 | 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] | 4062 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4063 | } |
| 4064 | |
| 4065 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4066 | if err != nil { |
| 4067 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 4068 | 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] | 4069 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4070 | } |
| 4071 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4072 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4073 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4074 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4075 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4076 | if err != nil { |
| 4077 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 4078 | 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] | 4079 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4080 | } |
| 4081 | logger.Debugw(ctx, "send fec history data ME done", |
| 4082 | 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] | 4083 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4084 | } |
| 4085 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 4086 | 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] | 4087 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4088 | } |
| 4089 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4090 | // SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance |
| 4091 | func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4092 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4093 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4094 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4095 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4096 | meParam := me.ParamData{EntityID: entityID} |
| 4097 | var meInstance *me.ManagedEntity |
| 4098 | var omciErr me.OmciErrors |
| 4099 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 4100 | |
| 4101 | if omciErr.GetError() == nil { |
| 4102 | var omciLayer *omci.OMCI |
| 4103 | var msgLayer gopacket.SerializableLayer |
| 4104 | var err error |
| 4105 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4106 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4107 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4108 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4109 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4110 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4111 | } |
| 4112 | if err != nil { |
| 4113 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 4114 | 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] | 4115 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4116 | } |
| 4117 | |
| 4118 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4119 | if err != nil { |
| 4120 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 4121 | 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] | 4122 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4123 | } |
| 4124 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4125 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4126 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4127 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4128 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4129 | if err != nil { |
| 4130 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 4131 | 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] | 4132 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4133 | } |
| 4134 | logger.Debugw(ctx, "send gemport history data ME done", |
| 4135 | 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] | 4136 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4137 | } |
| 4138 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 4139 | 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] | 4140 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4141 | } |
| 4142 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4143 | // SendStartSoftwareDownload sends StartSoftwareDownloadRequest |
| 4144 | func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4145 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4146 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4147 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4148 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4149 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4150 | |
| 4151 | omciLayer := &omci.OMCI{ |
| 4152 | TransactionID: tid, |
| 4153 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 4154 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4155 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4156 | } |
| 4157 | request := &omci.StartSoftwareDownloadRequest{ |
| 4158 | MeBasePacket: omci.MeBasePacket{ |
| 4159 | EntityClass: me.SoftwareImageClassID, |
| 4160 | EntityInstance: aImageMeID, //inactive image |
| 4161 | }, |
| 4162 | WindowSize: aDownloadWindowSize, |
| 4163 | ImageSize: aFileLen, |
| 4164 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 4165 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 4166 | } |
| 4167 | |
| 4168 | var options gopacket.SerializeOptions |
| 4169 | options.FixLengths = true |
| 4170 | buffer := gopacket.NewSerializeBuffer() |
| 4171 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4172 | if err != nil { |
| 4173 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 4174 | "device-id": oo.deviceID}) |
| 4175 | return err |
| 4176 | } |
| 4177 | outgoingPacket := buffer.Bytes() |
| 4178 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4179 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4180 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4181 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4182 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4183 | if err != nil { |
| 4184 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 4185 | "device-id": oo.deviceID}) |
| 4186 | return err |
| 4187 | } |
| 4188 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4189 | return nil |
| 4190 | } |
| 4191 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4192 | // PrepareOnuSectionsOfWindow prepares a list of sections for each window |
| 4193 | //Before invoking this function the oo.mutexTid needs to be be locked so that |
| 4194 | //GetOnuSwSecNextTid can be invoked without further locking |
| 4195 | func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context, |
| 4196 | aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, |
| 4197 | omciMsgsPerWindow *ia.OmciMessages) (OmciTransferStructure, error) { |
| 4198 | //onuswsections uses only low prioirity tids |
| 4199 | tid := oo.GetOnuSwSecNextTid() |
| 4200 | logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4201 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4202 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection}) |
| 4203 | |
| 4204 | var omciTxReq OmciTransferStructure |
| 4205 | msgType := omci.DownloadSectionRequestType |
| 4206 | |
| 4207 | if aAckRequest > 0 { |
| 4208 | msgType = omci.DownloadSectionRequestWithResponseType |
| 4209 | |
| 4210 | } |
| 4211 | omciLayer := &omci.OMCI{ |
| 4212 | TransactionID: tid, |
| 4213 | MessageType: msgType, |
| 4214 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4215 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4216 | } |
| 4217 | localSectionData := make([]byte, len(aSection)) |
| 4218 | |
| 4219 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
| 4220 | request := &omci.DownloadSectionRequest{ |
| 4221 | MeBasePacket: omci.MeBasePacket{ |
| 4222 | EntityClass: me.SoftwareImageClassID, |
| 4223 | EntityInstance: aImageMeID, //inactive image |
| 4224 | }, |
| 4225 | SectionNumber: aDownloadSectionNo, |
| 4226 | SectionData: localSectionData, |
| 4227 | } |
| 4228 | |
| 4229 | var options gopacket.SerializeOptions |
| 4230 | options.FixLengths = true |
| 4231 | buffer := gopacket.NewSerializeBuffer() |
| 4232 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4233 | if err != nil { |
| 4234 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4235 | "device-id": oo.deviceID}) |
| 4236 | return omciTxReq, err |
| 4237 | } |
| 4238 | outgoingPacket := buffer.Bytes() |
| 4239 | |
| 4240 | omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket) |
| 4241 | |
| 4242 | if aAckRequest > 0 { |
| 4243 | // only the last section should have a timeout as an ack is required only for the last section of the window |
| 4244 | omciTxReq = OmciTransferStructure{ |
| 4245 | withFramePrint: true, |
| 4246 | OnuSwWindow: omciMsgsPerWindow, |
| 4247 | } |
| 4248 | return omciTxReq, nil |
| 4249 | } |
| 4250 | |
| 4251 | return omciTxReq, nil |
| 4252 | } |
| 4253 | |
| 4254 | //SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections |
| 4255 | func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context, |
| 4256 | aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) { |
| 4257 | if aOmciTxRequest.OnuSwWindow == nil { |
| 4258 | logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil", |
| 4259 | log.Fields{"device-id": oo.deviceID}) |
| 4260 | return |
| 4261 | |
| 4262 | } |
| 4263 | |
| 4264 | tid := oo.GetOnuSwSecLastTid() |
| 4265 | logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid}) |
| 4266 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4267 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4268 | } |
| 4269 | |
| 4270 | aOmciTxRequest.cbPair = omciRxCallbackPair |
| 4271 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey}) |
| 4272 | oo.mutexRxSchedMap.Lock() |
| 4273 | // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ... |
| 4274 | oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry |
| 4275 | oo.mutexRxSchedMap.Unlock() |
| 4276 | |
| 4277 | chSuccess := make(chan bool) |
| 4278 | aOmciTxRequest.chSuccess = chSuccess |
| 4279 | aOmciTxRequest.timeout = aTimeout |
| 4280 | aOmciTxRequest.retries = CDefaultRetries |
| 4281 | |
| 4282 | //tid := aOmciTxRequest.cbPair.CbKey |
| 4283 | oo.mutexMonReq.Lock() |
| 4284 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4285 | oo.mutexMonReq.Unlock() |
| 4286 | |
| 4287 | retries := aOmciTxRequest.retries |
| 4288 | retryCounter := 0 |
| 4289 | if aTimeout == 0 { |
| 4290 | logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID}) |
| 4291 | return |
| 4292 | } |
| 4293 | loop: |
| 4294 | for retryCounter <= retries { |
| 4295 | // the onu sw sections are enqueued only to the low priority queue |
| 4296 | oo.mutexLowPrioTxQueue.Lock() |
| 4297 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4298 | oo.mutexLowPrioTxQueue.Unlock() |
| 4299 | |
| 4300 | go oo.sendQueuedRequests(ctx) |
| 4301 | |
| 4302 | select { |
| 4303 | case success := <-chSuccess: |
| 4304 | if success { |
| 4305 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4306 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4307 | } else { |
| 4308 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4309 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4310 | } |
| 4311 | break loop |
| 4312 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4313 | if retryCounter == retries { |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4314 | 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] | 4315 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4316 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc) |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4317 | break loop |
| 4318 | } else { |
| 4319 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4320 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4321 | } |
| 4322 | } |
| 4323 | retryCounter++ |
| 4324 | } |
| 4325 | oo.mutexMonReq.Lock() |
| 4326 | delete(oo.monitoredRequests, tid) |
| 4327 | oo.mutexMonReq.Unlock() |
| 4328 | } |
| 4329 | |
| 4330 | func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 4331 | if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil { |
| 4332 | lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1] |
| 4333 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 4334 | "TxOmciMessage": hex.EncodeToString(lastSection), |
| 4335 | "device-id": oo.deviceID, |
| 4336 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 4337 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 4338 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 4339 | } |
| 4340 | sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow) |
| 4341 | if sendErr != nil { |
| 4342 | logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
| 4343 | return sendErr |
| 4344 | } |
| 4345 | return nil |
| 4346 | } |
| 4347 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4348 | // SendDownloadSection sends DownloadSectionRequestWithResponse |
| 4349 | func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4350 | 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] | 4351 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4352 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4353 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4354 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4355 | |
| 4356 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 4357 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4358 | msgType := omci.DownloadSectionRequestType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4359 | var timeout int = 0 //default value for no response expected |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4360 | if aAckRequest > 0 { |
| 4361 | msgType = omci.DownloadSectionRequestWithResponseType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4362 | timeout = aTimeout |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4363 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4364 | omciLayer := &omci.OMCI{ |
| 4365 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4366 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4367 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4368 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4369 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4370 | localSectionData := make([]byte, len(aSection)) |
| 4371 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4372 | 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] | 4373 | request := &omci.DownloadSectionRequest{ |
| 4374 | MeBasePacket: omci.MeBasePacket{ |
| 4375 | EntityClass: me.SoftwareImageClassID, |
| 4376 | EntityInstance: aImageMeID, //inactive image |
| 4377 | }, |
| 4378 | SectionNumber: aDownloadSectionNo, |
| 4379 | SectionData: localSectionData, |
| 4380 | } |
| 4381 | |
| 4382 | var options gopacket.SerializeOptions |
| 4383 | options.FixLengths = true |
| 4384 | buffer := gopacket.NewSerializeBuffer() |
| 4385 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4386 | if err != nil { |
| 4387 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4388 | "device-id": oo.deviceID}) |
| 4389 | return err |
| 4390 | } |
| 4391 | outgoingPacket := buffer.Bytes() |
| 4392 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4393 | //for initial debug purpose overrule the requested print state for some frames |
| 4394 | printFrame := aPrint |
| 4395 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 4396 | printFrame = true |
| 4397 | } |
| 4398 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4399 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4400 | // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway |
| 4401 | // (used to avoid retransmission of frames with the same TID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4402 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4403 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4404 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4405 | if err != nil { |
| 4406 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 4407 | "device-id": oo.deviceID}) |
| 4408 | return err |
| 4409 | } |
| 4410 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4411 | return nil |
| 4412 | } |
| 4413 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4414 | //SendEndSoftwareDownload sends EndSoftwareDownloadRequest |
| 4415 | func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4416 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4417 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4418 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4419 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4420 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4421 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4422 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4423 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4424 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4425 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4426 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4427 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4428 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4429 | MeBasePacket: omci.MeBasePacket{ |
| 4430 | EntityClass: me.SoftwareImageClassID, |
| 4431 | EntityInstance: aImageMeID, //inactive image |
| 4432 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4433 | CRC32: aImageCrc, |
| 4434 | ImageSize: aFileLen, |
| 4435 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 4436 | 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] | 4437 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4438 | |
| 4439 | var options gopacket.SerializeOptions |
| 4440 | options.FixLengths = true |
| 4441 | buffer := gopacket.NewSerializeBuffer() |
| 4442 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4443 | if err != nil { |
| 4444 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4445 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4446 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4447 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4448 | outgoingPacket := buffer.Bytes() |
| 4449 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4450 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4451 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4452 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4453 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4454 | if err != nil { |
| 4455 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 4456 | "device-id": oo.deviceID}) |
| 4457 | return err |
| 4458 | } |
| 4459 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4460 | return nil |
| 4461 | } |
| 4462 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4463 | // SendActivateSoftware sends ActivateSoftwareRequest |
| 4464 | func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4465 | rxChan chan Message, aImageMeID uint16) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4466 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4467 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4468 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4469 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4470 | |
| 4471 | omciLayer := &omci.OMCI{ |
| 4472 | TransactionID: tid, |
| 4473 | MessageType: omci.ActivateSoftwareRequestType, |
| 4474 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4475 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4476 | } |
| 4477 | request := &omci.ActivateSoftwareRequest{ |
| 4478 | MeBasePacket: omci.MeBasePacket{ |
| 4479 | EntityClass: me.SoftwareImageClassID, |
| 4480 | EntityInstance: aImageMeID, //inactive image |
| 4481 | }, |
| 4482 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 4483 | } |
| 4484 | |
| 4485 | var options gopacket.SerializeOptions |
| 4486 | options.FixLengths = true |
| 4487 | buffer := gopacket.NewSerializeBuffer() |
| 4488 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4489 | if err != nil { |
| 4490 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 4491 | "device-id": oo.deviceID}) |
| 4492 | return err |
| 4493 | } |
| 4494 | outgoingPacket := buffer.Bytes() |
| 4495 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4496 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4497 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4498 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4499 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4500 | if err != nil { |
| 4501 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 4502 | "device-id": oo.deviceID}) |
| 4503 | return err |
| 4504 | } |
| 4505 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4506 | return nil |
| 4507 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4508 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4509 | // SendCommitSoftware sends CommitSoftwareRequest |
| 4510 | func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4511 | rxChan chan Message, aImageMeID uint16) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4512 | tid := oo.GetNextTid(highPrio) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4513 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4514 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4515 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4516 | |
| 4517 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4518 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4519 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4520 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4521 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4522 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4523 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4524 | MeBasePacket: omci.MeBasePacket{ |
| 4525 | EntityClass: me.SoftwareImageClassID, |
| 4526 | EntityInstance: aImageMeID, //inactive image |
| 4527 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4528 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4529 | |
| 4530 | var options gopacket.SerializeOptions |
| 4531 | options.FixLengths = true |
| 4532 | buffer := gopacket.NewSerializeBuffer() |
| 4533 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4534 | if err != nil { |
| 4535 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4536 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4537 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4538 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4539 | outgoingPacket := buffer.Bytes() |
| 4540 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4541 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4542 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4543 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4544 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4545 | if err != nil { |
| 4546 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 4547 | "device-id": oo.deviceID}) |
| 4548 | return err |
| 4549 | } |
| 4550 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4551 | return nil |
| 4552 | } |
| 4553 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4554 | //SendSelfTestReq sends TestRequest |
| 4555 | func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error { |
| 4556 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4557 | logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID, |
| 4558 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4559 | "InstId": strconv.FormatInt(int64(instdID), 16)}) |
| 4560 | omciLayer := &omci.OMCI{ |
| 4561 | TransactionID: tid, |
| 4562 | MessageType: omci.TestRequestType, |
| 4563 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4564 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4565 | } |
| 4566 | |
| 4567 | var request *omci.OpticalLineSupervisionTestRequest |
| 4568 | switch classID { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4569 | case me.AniGClassID: |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4570 | request = &omci.OpticalLineSupervisionTestRequest{ |
| 4571 | MeBasePacket: omci.MeBasePacket{ |
| 4572 | EntityClass: classID, |
| 4573 | EntityInstance: instdID, |
| 4574 | }, |
| 4575 | SelectTest: uint8(7), // self test |
| 4576 | GeneralPurposeBuffer: uint16(0), |
| 4577 | VendorSpecificParameters: uint16(0), |
| 4578 | } |
| 4579 | default: |
| 4580 | logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID}) |
| 4581 | return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID) |
| 4582 | } |
| 4583 | // Test serialization back to former string |
| 4584 | var options gopacket.SerializeOptions |
| 4585 | options.FixLengths = true |
| 4586 | |
| 4587 | buffer := gopacket.NewSerializeBuffer() |
| 4588 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4589 | if err != nil { |
| 4590 | logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err, |
| 4591 | "device-id": oo.deviceID}) |
| 4592 | return err |
| 4593 | } |
| 4594 | outgoingPacket := buffer.Bytes() |
| 4595 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4596 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4597 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4598 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4599 | err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4600 | if err != nil { |
| 4601 | logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err, |
| 4602 | "device-id": oo.deviceID}) |
| 4603 | return err |
| 4604 | } |
| 4605 | logger.Debug(ctx, "send self test request done") |
| 4606 | return nil |
| 4607 | } |
| 4608 | |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4609 | //nolint: gocyclo |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4610 | func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) { |
| 4611 | |
| 4612 | nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false) |
| 4613 | if err != nil { |
| 4614 | logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID}) |
| 4615 | return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID) |
| 4616 | } |
| 4617 | msgLayer := (*packet).Layer(nextLayer) |
| 4618 | if msgLayer != nil { |
| 4619 | // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers |
| 4620 | if failure := (*packet).ErrorLayer(); failure != nil { |
| 4621 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4622 | // In the case of MibUploadNextResponse, we let the packet pass so that later processing |
| 4623 | // can examine for UnkonwnMEs and UnknownAttributes |
| 4624 | logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass", |
| 4625 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4626 | return false, nil |
| 4627 | } else if nextLayer == omci.LayerTypeGetResponse { |
| 4628 | if resp := msgLayer.(*omci.GetResponse); resp != nil { |
| 4629 | if resp.NextLayerType() == omci.LayerTypeUnknownAttributes { |
| 4630 | unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes) |
| 4631 | if unknownAttrLayer != nil { |
| 4632 | logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!", |
| 4633 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer}) |
| 4634 | return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID) |
| 4635 | } |
| 4636 | } |
| 4637 | } |
| 4638 | } |
| 4639 | // Try to decode any further error information |
| 4640 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
| 4641 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!", |
| 4642 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()}) |
| 4643 | return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID) |
| 4644 | } |
| 4645 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!", |
| 4646 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4647 | return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID) |
| 4648 | } |
| 4649 | } else if failure := (*packet).ErrorLayer(); failure != nil { |
| 4650 | // message layer could not be decoded, but at least check if additional failure information is available |
| 4651 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
| 4652 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!", |
| 4653 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()}) |
| 4654 | return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID) |
| 4655 | } |
| 4656 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available", |
| 4657 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4658 | return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID) |
| 4659 | } else { |
| 4660 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID}) |
| 4661 | return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID) |
| 4662 | } |
| 4663 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4664 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4665 | if v == omciMsg.MessageType { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4666 | switch nextLayer { |
| 4667 | case omci.LayerTypeCreateResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4668 | if resp := msgLayer.(*omci.CreateResponse); resp != nil { |
| 4669 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4670 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4671 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4672 | } |
| 4673 | case omci.LayerTypeDeleteResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4674 | if resp := msgLayer.(*omci.DeleteResponse); resp != nil { |
| 4675 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4676 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4677 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4678 | } |
| 4679 | case omci.LayerTypeSetResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4680 | if resp := msgLayer.(*omci.SetResponse); resp != nil { |
| 4681 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4682 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4683 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4684 | } |
| 4685 | case omci.LayerTypeStartSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4686 | if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil { |
| 4687 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4688 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4689 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4690 | } |
| 4691 | case omci.LayerTypeEndSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4692 | if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil { |
| 4693 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4694 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4695 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4696 | } |
| 4697 | case omci.LayerTypeActivateSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4698 | if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil { |
| 4699 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4700 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4701 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4702 | } |
| 4703 | case omci.LayerTypeCommitSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4704 | if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil { |
| 4705 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4706 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4707 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4708 | } |
| 4709 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4710 | } |
| 4711 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4712 | return false, nil |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4713 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4714 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4715 | func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4716 | timeout := aOmciTxRequest.timeout |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4717 | if timeout == 0 { |
| 4718 | //timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4719 | // enqueue |
| 4720 | if aOmciTxRequest.highPrio { |
| 4721 | oo.mutexHighPrioTxQueue.Lock() |
| 4722 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4723 | oo.mutexHighPrioTxQueue.Unlock() |
| 4724 | } else { |
| 4725 | oo.mutexLowPrioTxQueue.Lock() |
| 4726 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4727 | oo.mutexLowPrioTxQueue.Unlock() |
| 4728 | } |
| 4729 | go oo.sendQueuedRequests(ctx) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4730 | } else { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4731 | //the supervised sending with waiting on the response (based on TID) is called in background |
| 4732 | // to avoid blocking of the sender for the complete OMCI handshake procedure |
| 4733 | // to stay consistent with the processing tested so far, sending of next messages of the same control procedure |
| 4734 | // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there) |
| 4735 | go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4736 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4737 | } |
| 4738 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4739 | func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4740 | chSuccess := make(chan bool) |
| 4741 | aOmciTxRequest.chSuccess = chSuccess |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4742 | tid := aOmciTxRequest.cbPair.CbKey |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4743 | oo.mutexMonReq.Lock() |
| 4744 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4745 | oo.mutexMonReq.Unlock() |
| 4746 | |
| 4747 | retries := aOmciTxRequest.retries |
| 4748 | retryCounter := 0 |
| 4749 | loop: |
| 4750 | for retryCounter <= retries { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4751 | // enqueue |
| 4752 | if aOmciTxRequest.highPrio { |
| 4753 | oo.mutexHighPrioTxQueue.Lock() |
| 4754 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4755 | oo.mutexHighPrioTxQueue.Unlock() |
| 4756 | } else { |
| 4757 | oo.mutexLowPrioTxQueue.Lock() |
| 4758 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4759 | oo.mutexLowPrioTxQueue.Unlock() |
| 4760 | } |
| 4761 | go oo.sendQueuedRequests(ctx) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4762 | |
| 4763 | select { |
| 4764 | case success := <-chSuccess: |
| 4765 | if success { |
| 4766 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4767 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4768 | } else { |
| 4769 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4770 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4771 | } |
| 4772 | break loop |
| 4773 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4774 | if retryCounter == retries { |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4775 | 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] | 4776 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4777 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4778 | break loop |
| 4779 | } else { |
| 4780 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4781 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4782 | } |
| 4783 | } |
| 4784 | retryCounter++ |
| 4785 | } |
| 4786 | oo.mutexMonReq.Lock() |
| 4787 | delete(oo.monitoredRequests, tid) |
| 4788 | oo.mutexMonReq.Unlock() |
| 4789 | } |
| 4790 | |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4791 | //CancelRequestMonitoring terminates monitoring of outstanding omci requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4792 | func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4793 | oo.mutexMonReq.RLock() |
| 4794 | for k := range oo.monitoredRequests { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 4795 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 4796 | select { |
| 4797 | case oo.monitoredRequests[k].chSuccess <- false: |
| 4798 | default: |
| 4799 | logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{ |
| 4800 | "index": k, "device-id": oo.deviceID}) |
| 4801 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4802 | } |
| 4803 | oo.mutexMonReq.RUnlock() |
| 4804 | } |
| 4805 | |
| 4806 | //GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum |
| 4807 | //time consumed for retry processing of a particular OMCI-request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4808 | func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration { |
| 4809 | return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4810 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4811 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4812 | // SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance |
| 4813 | func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4814 | 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] | 4815 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4816 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4817 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 4818 | |
| 4819 | meParam := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 4820 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4821 | } |
| 4822 | var meInstance *me.ManagedEntity |
| 4823 | var omciErr me.OmciErrors |
| 4824 | if classID == me.EthernetFrameExtendedPmClassID { |
| 4825 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam) |
| 4826 | } else { |
| 4827 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam) |
| 4828 | } |
| 4829 | |
| 4830 | if omciErr.GetError() == nil { |
| 4831 | var omciLayer *omci.OMCI |
| 4832 | var msgLayer gopacket.SerializableLayer |
| 4833 | var err error |
| 4834 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4835 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4836 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4837 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4838 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4839 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4840 | } |
| 4841 | if err != nil { |
| 4842 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 4843 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4844 | return nil, err |
| 4845 | } |
| 4846 | |
| 4847 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4848 | if err != nil { |
| 4849 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me", |
| 4850 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4851 | return nil, err |
| 4852 | } |
| 4853 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4854 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4855 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4856 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4857 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4858 | if err != nil { |
| 4859 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 4860 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4861 | return nil, err |
| 4862 | } |
| 4863 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done", |
| 4864 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4865 | return meInstance, nil |
| 4866 | } |
| 4867 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 4868 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4869 | return nil, omciErr.GetError() |
| 4870 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4871 | |
| 4872 | // RLockMutexMonReq lock read access to monitoredRequests |
| 4873 | func (oo *OmciCC) RLockMutexMonReq() { |
| 4874 | oo.mutexMonReq.RLock() |
| 4875 | } |
| 4876 | |
| 4877 | // RUnlockMutexMonReq unlock read access to monitoredRequests |
| 4878 | func (oo *OmciCC) RUnlockMutexMonReq() { |
| 4879 | oo.mutexMonReq.RUnlock() |
| 4880 | } |
| 4881 | |
| 4882 | // GetMonitoredRequest get OmciTransferStructure for an omciTransID |
| 4883 | func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) { |
| 4884 | value, exist = oo.monitoredRequests[omciTransID] |
| 4885 | return value, exist |
| 4886 | } |
| 4887 | |
| 4888 | // SetChMonitoredRequest sets chSuccess to indicate whether response was received or not |
| 4889 | func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) { |
| 4890 | oo.monitoredRequests[omciTransID].chSuccess <- chVal |
| 4891 | } |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4892 | |
| 4893 | // SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me |
| 4894 | func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
| 4895 | rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
| 4896 | tid := oo.GetNextTid(highPrio) |
| 4897 | logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID, |
| 4898 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 4899 | |
| 4900 | meParams := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 4901 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4902 | } |
| 4903 | var meInstance *me.ManagedEntity |
| 4904 | var omciErr me.OmciErrors |
| 4905 | if classID == me.EthernetFrameExtendedPmClassID { |
| 4906 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams) |
| 4907 | } else { |
| 4908 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams) |
| 4909 | } |
| 4910 | |
| 4911 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4912 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4913 | if err != nil { |
| 4914 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 4915 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4916 | return nil, err |
| 4917 | } |
| 4918 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4919 | if err != nil { |
| 4920 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg", |
| 4921 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4922 | return nil, err |
| 4923 | } |
| 4924 | omciRxCallbackPair := CallbackPair{ |
| 4925 | CbKey: tid, |
| 4926 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4927 | } |
| 4928 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 4929 | if err != nil { |
| 4930 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 4931 | log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4932 | return nil, err |
| 4933 | } |
| 4934 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done", |
| 4935 | log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4936 | return meInstance, nil |
| 4937 | } |
| 4938 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 4939 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4940 | return nil, omciErr.GetError() |
| 4941 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 4942 | |
| 4943 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 4944 | func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 4945 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 4946 | oo.pBaseDeviceHandler = nil |
| 4947 | oo.pOnuDeviceEntry = nil |
| 4948 | oo.pOnuAlarmManager = nil |
| 4949 | } |