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 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 99 | //OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 100 | type OmciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 101 | enabled bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 102 | pBaseDeviceHandler IdeviceHandler |
| 103 | pOnuDeviceEntry IonuDeviceEntry |
| 104 | pOnuAlarmManager IonuAlarmManager |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 105 | deviceID string |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 106 | coreClient *vgrpc.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 107 | supportExtMsg bool |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 108 | rxOmciFrameError tOmciReceiveError |
| 109 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 110 | txFrames, txOnuFrames uint32 |
| 111 | rxFrames, rxOnuFrames, rxOnuDiscards uint32 |
| 112 | |
| 113 | // OMCI params |
| 114 | mutexTid sync.Mutex |
| 115 | tid uint16 |
| 116 | mutexHpTid sync.Mutex |
| 117 | hpTid uint16 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 118 | UploadSequNo uint16 |
| 119 | UploadNoOfCmds uint16 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 120 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 121 | mutexSendQueuedRequests sync.Mutex |
| 122 | mutexLowPrioTxQueue sync.Mutex |
| 123 | lowPrioTxQueue *list.List |
| 124 | mutexHighPrioTxQueue sync.Mutex |
| 125 | highPrioTxQueue *list.List |
| 126 | mutexRxSchedMap sync.Mutex |
| 127 | rxSchedulerMap map[uint16]CallbackPairEntry |
| 128 | mutexMonReq sync.RWMutex |
| 129 | monitoredRequests map[uint16]OmciTransferStructure |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 132 | var responsesWithMibDataSync = []omci.MessageType{ |
| 133 | omci.CreateResponseType, |
| 134 | omci.DeleteResponseType, |
| 135 | omci.SetResponseType, |
| 136 | omci.StartSoftwareDownloadResponseType, |
| 137 | omci.EndSoftwareDownloadResponseType, |
| 138 | omci.ActivateSoftwareResponseType, |
| 139 | omci.CommitSoftwareResponseType, |
| 140 | } |
| 141 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 142 | //NewOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 143 | //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] | 144 | func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler, |
| 145 | onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager, |
| 146 | coreClient *vgrpc.Client) *OmciCC { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 147 | logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 148 | var omciCC OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 149 | omciCC.enabled = false |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 150 | omciCC.pBaseDeviceHandler = deviceHandler |
| 151 | omciCC.pOnuAlarmManager = onuAlarmManager |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 152 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 153 | omciCC.deviceID = deviceID |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 154 | omciCC.coreClient = coreClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 155 | omciCC.supportExtMsg = false |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 156 | omciCC.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 157 | omciCC.txFrames = 0 |
| 158 | omciCC.txOnuFrames = 0 |
| 159 | omciCC.rxFrames = 0 |
| 160 | omciCC.rxOnuFrames = 0 |
| 161 | omciCC.rxOnuDiscards = 0 |
| 162 | omciCC.tid = 0x1 |
| 163 | omciCC.hpTid = 0x8000 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 164 | omciCC.UploadSequNo = 0 |
| 165 | omciCC.UploadNoOfCmds = 0 |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 166 | omciCC.lowPrioTxQueue = list.New() |
| 167 | omciCC.highPrioTxQueue = list.New() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 168 | omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry) |
| 169 | omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 170 | |
| 171 | return &omciCC |
| 172 | } |
| 173 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 174 | //Stop stops/resets the omciCC |
| 175 | func (oo *OmciCC) Stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 176 | logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 177 | //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] | 178 | oo.CancelRequestMonitoring(ctx) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 179 | // clear the tx queues |
| 180 | oo.mutexHighPrioTxQueue.Lock() |
| 181 | oo.highPrioTxQueue.Init() |
| 182 | oo.mutexHighPrioTxQueue.Unlock() |
| 183 | oo.mutexLowPrioTxQueue.Lock() |
| 184 | oo.lowPrioTxQueue.Init() |
| 185 | oo.mutexLowPrioTxQueue.Unlock() |
| 186 | //clear the scheduler map |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 187 | oo.mutexRxSchedMap.Lock() |
| 188 | for k := range oo.rxSchedulerMap { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 189 | delete(oo.rxSchedulerMap, k) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 190 | } |
| 191 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 192 | //reset the high prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 193 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 194 | oo.hpTid = 0x8000 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 195 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 196 | //reset the low prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 197 | oo.mutexTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 198 | oo.tid = 1 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 199 | oo.mutexTid.Unlock() |
| 200 | //reset control values |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 201 | oo.UploadSequNo = 0 |
| 202 | oo.UploadNoOfCmds = 0 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 203 | oo.rxOmciFrameError = cOmciMessageReceiveNoError |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 204 | //reset the stats counter - which might be topic of discussion ... |
| 205 | oo.txFrames = 0 |
| 206 | oo.txOnuFrames = 0 |
| 207 | oo.rxFrames = 0 |
| 208 | oo.rxOnuFrames = 0 |
| 209 | oo.rxOnuDiscards = 0 |
| 210 | |
| 211 | return nil |
| 212 | } |
| 213 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 214 | // Rx handler for omci messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 215 | 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] | 216 | logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 217 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 218 | switch omciMsg.MessageType { |
| 219 | case omci.AlarmNotificationType: |
| 220 | data := OmciMessage{ |
| 221 | OmciMsg: omciMsg, |
| 222 | OmciPacket: packet, |
| 223 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 224 | go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 225 | return nil |
| 226 | default: |
| 227 | return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String()) |
| 228 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 229 | /* |
| 230 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 231 | rxOnuFrames++ |
| 232 | |
| 233 | switch msgType { |
| 234 | case AlarmNotification: |
| 235 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 236 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 237 | // python code was: |
| 238 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 239 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 240 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 241 | // |
| 242 | return errors.New("RxAlarmNotification unimplemented") |
| 243 | } |
| 244 | case AttributeValueChange: |
| 245 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 246 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 247 | // python code was: |
| 248 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 249 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 250 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 251 | // |
| 252 | return errors.New("RxAttributeValueChange unimplemented") |
| 253 | } |
| 254 | case TestResult: |
| 255 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 256 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 257 | // python code was: |
| 258 | //elif msg_type == EntityOperations.TestResult.value: |
| 259 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 260 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 261 | // |
| 262 | return errors.New("RxTestResult unimplemented") |
| 263 | } |
| 264 | default: |
| 265 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 266 | logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 267 | rxOnuDiscards++ |
| 268 | return errors.New("RxOnuMsgType unimplemented") |
| 269 | } |
| 270 | } |
| 271 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 274 | func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 275 | //assuming omci message content is hex coded! |
| 276 | // with restricted output of 16bytes would be ...rxMsg[:16] |
| 277 | logger.Debugw(ctx, "omci-message-received:", log.Fields{ |
| 278 | "RxOmciMessage": hex.EncodeToString(rxMsg), |
| 279 | "device-id": oo.deviceID}) |
| 280 | } |
| 281 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 282 | // ReceiveMessage - Rx handler for onu messages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 283 | // 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] | 284 | func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 285 | //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] | 286 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 287 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 288 | // (an extendedFormat message could be destroyed this way!) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 289 | trailerLenData := rxMsg[42:44] |
| 290 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 291 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 292 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 293 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 294 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 295 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 296 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 297 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 298 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 299 | } |
| 300 | } |
| 301 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 302 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 303 | // (an extendedFormat message could be destroyed this way!) |
| 304 | // extend/overwrite with trailer |
| 305 | trailer := make([]byte, 8) |
| 306 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 307 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 308 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 309 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 310 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 311 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 312 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 313 | } |
| 314 | } else { |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 315 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 316 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 317 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 318 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy) |
| 322 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 323 | 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] | 324 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 325 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 326 | } |
| 327 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 328 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 329 | 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] | 330 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 331 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 332 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 333 | // insert some check on detected OMCI decoding issues and log them |
| 334 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 335 | // even though allowed from omci-lib due to set relaxed decoding |
| 336 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 337 | // (compare mib_sync.go unknownAttrLayer) |
| 338 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 339 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 340 | errMsg := failure.Error() |
| 341 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 342 | "device-id": oo.deviceID, "issue": errMsg}) |
| 343 | } |
| 344 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 345 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 346 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 347 | 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] | 348 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 349 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 350 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 351 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 352 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 353 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 354 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 355 | // We expect to find the TID in the oo.rxSchedulerMap |
| 356 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 357 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 358 | oo.printRxMessage(ctx, rxMsg) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 359 | logger.Debug(ctx, "RxMsg is no Omci Response Message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 360 | if omciMsg.TransactionID == 0 { |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 361 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 362 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 363 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 364 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 365 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 366 | 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] | 367 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 368 | //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] | 369 | oo.mutexRxSchedMap.Lock() |
| 370 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 371 | if ok && rxCallbackEntry.CbFunction != nil { |
| 372 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 373 | oo.printRxMessage(ctx, rxMsg) |
| 374 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 375 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 376 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 377 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 378 | if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 379 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 380 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 381 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 382 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 383 | // so do not clean up the TransactionID in that case. |
| 384 | if omciMsg.MessageType != omci.TestResponseType { |
| 385 | // having posted the response the request is regarded as 'done' |
| 386 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 387 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 388 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 389 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 390 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 391 | oo.mutexRxSchedMap.Unlock() |
| 392 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 393 | oo.printRxMessage(ctx, rxMsg) |
| 394 | 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] | 395 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 396 | /* py code was: |
| 397 | Receive and OMCI message from the proxy channel to the OLT. |
| 398 | |
| 399 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 400 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 401 | """ |
| 402 | if not self.enabled: |
| 403 | return |
| 404 | |
| 405 | try: |
| 406 | now = arrow.utcnow() |
| 407 | d = None |
| 408 | |
| 409 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 410 | # save the current value of the entity_id_to_class_map, then |
| 411 | # replace it with our custom one before decode, and then finally |
| 412 | # restore it later. Tried other ways but really made the code messy. |
| 413 | saved_me_map = omci_entities.entity_id_to_class_map |
| 414 | omci_entities.entity_id_to_class_map = self._me_map |
| 415 | |
| 416 | try: |
| 417 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 418 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 419 | except KeyError as e: |
| 420 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 421 | 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] | 422 | rx_frame = self._decode_unknown_me(msg) |
| 423 | self._rx_unknown_me += 1 |
| 424 | |
| 425 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 426 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 427 | return |
| 428 | |
| 429 | finally: |
| 430 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 431 | |
| 432 | rx_tid = rx_frame.fields['transaction_id'] |
| 433 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 434 | 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] | 435 | # Filter the Test Result frame and route through receive onu |
| 436 | # message method. |
| 437 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 438 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 439 | return self._receive_onu_message(rx_frame) |
| 440 | |
| 441 | # Previously unreachable if this is the very first round-trip Rx or we |
| 442 | # have been running consecutive errors |
| 443 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 444 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 445 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 446 | |
| 447 | self._rx_frames += 1 |
| 448 | self._consecutive_errors = 0 |
| 449 | |
| 450 | try: |
| 451 | high_priority = self._tid_is_high_priority(rx_tid) |
| 452 | index = self._get_priority_index(high_priority) |
| 453 | |
| 454 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 455 | last_tx_tuple = self._tx_request[index] |
| 456 | |
| 457 | if last_tx_tuple is None or \ |
| 458 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 459 | # Possible late Rx on a message that timed-out |
| 460 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 461 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 462 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 463 | self._rx_unknown_tid += 1 |
| 464 | self._rx_late += 1 |
| 465 | return |
| 466 | |
| 467 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 468 | if dc is not None and not dc.cancelled and not dc.called: |
| 469 | dc.cancel() |
| 470 | |
| 471 | _secs = self._update_rx_tx_stats(now, ts) |
| 472 | |
| 473 | # Late arrival already serviced by a timeout? |
| 474 | if d.called: |
| 475 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 476 | 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] | 477 | return |
| 478 | |
| 479 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 480 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 481 | if d is not None: |
| 482 | return d.errback(failure.Failure(e)) |
| 483 | return |
| 484 | |
| 485 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 486 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 487 | tx_tid = tx_frame.fields['transaction_id']) |
| 488 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 489 | |
| 490 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 491 | self._rx_response[index] = rx_frame |
| 492 | d.callback(rx_frame) |
| 493 | |
| 494 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 495 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 496 | */ |
| 497 | } |
| 498 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 499 | /* |
| 500 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 501 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 502 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 503 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 504 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 505 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 506 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 507 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 508 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 509 | delete(oo.rxSchedulerMap, tid) |
| 510 | } |
| 511 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 512 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 513 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 514 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 515 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 516 | if timeout != 0 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 517 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 518 | oo.mutexRxSchedMap.Lock() |
| 519 | // 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] | 520 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 521 | oo.mutexRxSchedMap.Unlock() |
| 522 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 523 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 524 | 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] | 525 | //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] | 526 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 527 | txFrame, |
| 528 | timeout, |
| 529 | retry, |
| 530 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 531 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 532 | receiveCallbackPair, |
| 533 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 534 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 535 | oo.mutexMonReq.Lock() |
| 536 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 537 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 538 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 539 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 540 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 541 | return nil |
| 542 | } |
| 543 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 544 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 545 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 546 | } |
| 547 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 548 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 549 | // Avoid accessing the txQueues from parallel send routines to block |
| 550 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 551 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 552 | // for the corresponding response too (t.b.d.). |
| 553 | oo.mutexSendQueuedRequests.Lock() |
| 554 | defer oo.mutexSendQueuedRequests.Unlock() |
| 555 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 556 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 557 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 558 | return |
| 559 | } |
| 560 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 561 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 562 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 563 | return |
| 564 | } |
| 565 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 566 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 567 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 568 | oo.mutexHighPrioTxQueue.Lock() |
| 569 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 570 | for oo.highPrioTxQueue.Len() > 0 { |
| 571 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 572 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
| 573 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 574 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 575 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 576 | } |
| 577 | return nil |
| 578 | } |
| 579 | |
| 580 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 581 | oo.mutexLowPrioTxQueue.Lock() |
| 582 | for oo.lowPrioTxQueue.Len() > 0 { |
| 583 | queueElement := oo.lowPrioTxQueue.Front() // First element |
| 584 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
| 585 | oo.mutexLowPrioTxQueue.Unlock() |
| 586 | return err |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 587 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 588 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 589 | // Interrupt the sending of low priority requests to process any high priority requests |
| 590 | // that may have arrived in the meantime |
| 591 | oo.mutexLowPrioTxQueue.Unlock() |
| 592 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 593 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 594 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 595 | oo.mutexLowPrioTxQueue.Lock() |
| 596 | } |
| 597 | |
| 598 | oo.mutexLowPrioTxQueue.Unlock() |
| 599 | return nil |
| 600 | } |
| 601 | |
| 602 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 603 | if omciTxRequest.withFramePrint { |
| 604 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 605 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 606 | "device-id": oo.deviceID, |
| 607 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 608 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 609 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 610 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 611 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 612 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 613 | ChildDeviceId: oo.deviceID, |
| 614 | Message: omciTxRequest.txFrame, |
| 615 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 616 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 617 | } |
| 618 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 619 | if sendErr != nil { |
| 620 | logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
| 621 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 622 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 623 | return nil |
| 624 | } |
| 625 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 626 | // GetNextTid - TODO: add comment |
| 627 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 628 | var next uint16 |
| 629 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 630 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 631 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 632 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 633 | if oo.hpTid < 0x8000 { |
| 634 | oo.hpTid = 0x8000 |
| 635 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 636 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 637 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 638 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 639 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 640 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 641 | if oo.tid >= 0x8000 { |
| 642 | oo.tid = 1 |
| 643 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 644 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 645 | } |
| 646 | return next |
| 647 | } |
| 648 | |
| 649 | // ################################################################################### |
| 650 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 651 | |
| 652 | // Serialize - TODO: add comment |
| 653 | 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] | 654 | omciLayer := &omci.OMCI{ |
| 655 | TransactionID: tid, |
| 656 | MessageType: msgType, |
| 657 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 658 | return serializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 659 | } |
| 660 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 661 | 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] | 662 | var options gopacket.SerializeOptions |
| 663 | options.FixLengths = true |
| 664 | |
| 665 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 666 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 667 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 668 | 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] | 669 | return nil, err |
| 670 | } |
| 671 | return buffer.Bytes(), nil |
| 672 | } |
| 673 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 674 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 675 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 676 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 677 | hex.Encode(dst, omciPkt) |
| 678 | return dst, nil |
| 679 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 680 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 681 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 682 | //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] | 683 | 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] | 684 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 685 | 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] | 686 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 687 | |
| 688 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 689 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 690 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 691 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 692 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 693 | oo.mutexMonReq.RLock() |
| 694 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 695 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 696 | select { |
| 697 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 698 | default: |
| 699 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 700 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 701 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 702 | } else { |
| 703 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 704 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 705 | } |
| 706 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 707 | |
| 708 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 709 | // 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] | 710 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 711 | Type: OMCI, |
| 712 | Data: OmciMessage{ |
| 713 | OmciMsg: omciMsg, |
| 714 | OmciPacket: packet, |
| 715 | }, |
| 716 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 717 | //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] | 718 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 719 | |
| 720 | return nil |
| 721 | } |
| 722 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 723 | // SendMibReset sends MibResetRequest |
| 724 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 725 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 726 | 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] | 727 | request := &omci.MibResetRequest{ |
| 728 | MeBasePacket: omci.MeBasePacket{ |
| 729 | EntityClass: me.OnuDataClassID, |
| 730 | }, |
| 731 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 732 | tid := oo.GetNextTid(highPrio) |
| 733 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 734 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 735 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 736 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 737 | return err |
| 738 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 739 | omciRxCallbackPair := CallbackPair{ |
| 740 | CbKey: tid, |
| 741 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 742 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 743 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 746 | // SendReboot sends RebootRequest |
| 747 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 748 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 749 | request := &omci.RebootRequest{ |
| 750 | MeBasePacket: omci.MeBasePacket{ |
| 751 | EntityClass: me.OnuGClassID, |
| 752 | }, |
| 753 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 754 | tid := oo.GetNextTid(highPrio) |
| 755 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 756 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 757 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 758 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 759 | return err |
| 760 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 761 | omciRxCallbackPair := CallbackPair{ |
| 762 | CbKey: tid, |
| 763 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 764 | } |
| 765 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 766 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 767 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 768 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 769 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 770 | return err |
| 771 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 772 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 773 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 774 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 775 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 776 | return err |
| 777 | } |
| 778 | return nil |
| 779 | } |
| 780 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 781 | // SendMibUpload sends MibUploadRequest |
| 782 | func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 783 | 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] | 784 | request := &omci.MibUploadRequest{ |
| 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.MibUploadRequestType, 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 MibUploadRequest", 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 | oo.UploadSequNo = 0 |
| 797 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 798 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 799 | omciRxCallbackPair := CallbackPair{ |
| 800 | CbKey: tid, |
| 801 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 802 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 803 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 804 | } |
| 805 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 806 | // SendMibUploadNext sends MibUploadNextRequest |
| 807 | func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
| 808 | 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] | 809 | request := &omci.MibUploadNextRequest{ |
| 810 | MeBasePacket: omci.MeBasePacket{ |
| 811 | EntityClass: me.OnuDataClassID, |
| 812 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 813 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 814 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 815 | tid := oo.GetNextTid(highPrio) |
| 816 | pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 817 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 818 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 819 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 820 | return err |
| 821 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 822 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 823 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 824 | omciRxCallbackPair := CallbackPair{ |
| 825 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 826 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 827 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 828 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 829 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 830 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 831 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 832 | } |
| 833 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 834 | // SendGetAllAlarm gets all alarm ME instances |
| 835 | 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] | 836 | logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID}) |
| 837 | request := &omci.GetAllAlarmsRequest{ |
| 838 | MeBasePacket: omci.MeBasePacket{ |
| 839 | EntityClass: me.OnuDataClassID, |
| 840 | }, |
| 841 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 842 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 843 | tid := oo.GetNextTid(highPrio) |
| 844 | pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 845 | if err != nil { |
| 846 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{ |
| 847 | "Err": err, "device-id": oo.deviceID}) |
| 848 | return err |
| 849 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 850 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 851 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 852 | omciRxCallbackPair := CallbackPair{ |
| 853 | CbKey: tid, |
| 854 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 855 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 856 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 857 | } |
| 858 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 859 | // SendGetAllAlarmNext gets next alarm ME instance |
| 860 | func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error { |
| 861 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 862 | 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] | 863 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
| 864 | request := &omci.GetAllAlarmsNextRequest{ |
| 865 | MeBasePacket: omci.MeBasePacket{ |
| 866 | EntityClass: me.OnuDataClassID, |
| 867 | }, |
| 868 | CommandSequenceNumber: alarmUploadSeqNo, |
| 869 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 870 | tid := oo.GetNextTid(highPrio) |
| 871 | pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 872 | if err != nil { |
| 873 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{ |
| 874 | "Err": err, "device-id": oo.deviceID}) |
| 875 | return err |
| 876 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 877 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 878 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 879 | omciRxCallbackPair := CallbackPair{ |
| 880 | CbKey: tid, |
| 881 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 882 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 883 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 884 | } |
| 885 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 886 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 887 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 888 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 889 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 890 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 891 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 892 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 893 | EntityID: GalEthernetEID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 894 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 895 | } |
| 896 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 897 | if omciErr.GetError() == nil { |
| 898 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 899 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 900 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 901 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 902 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 903 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 904 | } |
| 905 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 906 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 907 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 908 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 909 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 910 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 913 | omciRxCallbackPair := CallbackPair{ |
| 914 | CbKey: tid, |
| 915 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 916 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 917 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 918 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 919 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 920 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 921 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 922 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 923 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 924 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 925 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 926 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 927 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 928 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 931 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 932 | // 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] | 933 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 934 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 935 | 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] | 936 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 937 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 938 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 939 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 940 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 941 | // read ONU-2G from DB ???? //TODO!!! |
| 942 | meParams := me.ParamData{ |
| 943 | EntityID: 0, |
| 944 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 945 | } |
| 946 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 947 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 948 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 949 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 950 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 951 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 952 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 953 | } |
| 954 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 955 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 956 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 957 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 958 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 959 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 960 | } |
| 961 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 962 | omciRxCallbackPair := CallbackPair{ |
| 963 | CbKey: tid, |
| 964 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 965 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 966 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 967 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 968 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 969 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 970 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 971 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 972 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 973 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 974 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 975 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 976 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 977 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 978 | } |
| 979 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 980 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 981 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 982 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 983 | tid := oo.GetNextTid(highPrio) |
| 984 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 985 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 986 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 987 | |
| 988 | meParams := me.ParamData{ |
| 989 | EntityID: instID, |
| 990 | Attributes: me.AttributeValueMap{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 991 | "Priority": 0x8000, |
| 992 | "MaxAge": 20 * 256, //20s |
| 993 | "HelloTime": 2 * 256, //2s |
| 994 | "ForwardDelay": 15 * 256, //15s |
| 995 | "DynamicFilteringAgeingTime": 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 996 | }, |
| 997 | } |
| 998 | |
| 999 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1000 | if omciErr.GetError() == nil { |
| 1001 | //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] | 1002 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1003 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1004 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1005 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1006 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1007 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1008 | } |
| 1009 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1010 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1011 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1012 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1013 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1014 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1017 | omciRxCallbackPair := CallbackPair{ |
| 1018 | CbKey: tid, |
| 1019 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1020 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1021 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1022 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1023 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1024 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1025 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1026 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1027 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1028 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1029 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1030 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1031 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1032 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1035 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1036 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1037 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1038 | tid := oo.GetNextTid(highPrio) |
| 1039 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1040 | if idErr != nil { |
| 1041 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1042 | "Err": idErr, "device-id": oo.deviceID}) |
| 1043 | return nil, idErr |
| 1044 | } |
| 1045 | 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] | 1046 | "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] | 1047 | |
| 1048 | meParams := me.ParamData{ |
| 1049 | EntityID: instID, |
| 1050 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1051 | "BridgeIdPointer": MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1052 | "PortNum": aPUniPort.MacBpNo, |
| 1053 | "TpType": uint8(aPUniPort.PortType), |
| 1054 | "TpPointer": aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1055 | }, |
| 1056 | } |
| 1057 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1058 | if omciErr.GetError() == nil { |
| 1059 | //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] | 1060 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1061 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1062 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1063 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1064 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1065 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1068 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1069 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1070 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1071 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1072 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1073 | } |
| 1074 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1075 | omciRxCallbackPair := CallbackPair{ |
| 1076 | CbKey: tid, |
| 1077 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1078 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1079 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1080 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1081 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1082 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1083 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1084 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1085 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1086 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1087 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1088 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1089 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1090 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1091 | } |
| 1092 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1093 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1094 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1095 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1096 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1097 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1098 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1099 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1100 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1101 | |
| 1102 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1103 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1104 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1105 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1106 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1107 | assType = uint8(10) // for VEIP |
| 1108 | } |
| 1109 | meParams := me.ParamData{ |
| 1110 | EntityID: instID, |
| 1111 | Attributes: me.AttributeValueMap{ |
| 1112 | "AssociationType": assType, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1113 | "AssociatedMePointer": aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1114 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1115 | }, |
| 1116 | } |
| 1117 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1118 | if omciErr.GetError() == nil { |
| 1119 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1120 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1121 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1122 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1123 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1124 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1125 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1128 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1129 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1130 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1131 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1132 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1135 | omciRxCallbackPair := CallbackPair{ |
| 1136 | CbKey: tid, |
| 1137 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1138 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1139 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1140 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1141 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1142 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1143 | return nil, err |
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.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1146 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1147 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1148 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1149 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1150 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1151 | } |
| 1152 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1153 | // SendSetOnuGLS sets OnuG ME instance |
| 1154 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1155 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1156 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1157 | 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] | 1158 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1159 | |
| 1160 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1161 | meParams := me.ParamData{ |
| 1162 | EntityID: 0, |
| 1163 | Attributes: requestedAttributes, |
| 1164 | } |
| 1165 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1166 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1167 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1168 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1169 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1170 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1171 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1172 | } |
| 1173 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1174 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1175 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1176 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1177 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1178 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1181 | omciRxCallbackPair := CallbackPair{ |
| 1182 | CbKey: tid, |
| 1183 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1184 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1185 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1186 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1187 | logger.Errorw(ctx, "Cannot send ONU-G set", 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 | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1190 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1191 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1192 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1193 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1194 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1195 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1196 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1197 | } |
| 1198 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1199 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1200 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1201 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1202 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1203 | 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] | 1204 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1205 | |
| 1206 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1207 | meParams := me.ParamData{ |
| 1208 | EntityID: aInstNo, |
| 1209 | Attributes: requestedAttributes, |
| 1210 | } |
| 1211 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1212 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1213 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1214 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1215 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1216 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1217 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1218 | } |
| 1219 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1220 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1221 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1222 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1223 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1224 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1227 | omciRxCallbackPair := CallbackPair{ |
| 1228 | CbKey: tid, |
| 1229 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1230 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1231 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1232 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1233 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +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 | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1236 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1237 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1238 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1239 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1240 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1241 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1242 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1246 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1247 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1248 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1249 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1250 | 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] | 1251 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1252 | |
| 1253 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1254 | meParams := me.ParamData{ |
| 1255 | EntityID: aInstNo, |
| 1256 | Attributes: requestedAttributes, |
| 1257 | } |
| 1258 | meInstance, omciErr := me.NewUniG(meParams) |
| 1259 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1260 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1261 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1262 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1263 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1264 | return nil |
| 1265 | } |
| 1266 | |
| 1267 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1268 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1269 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1270 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1271 | return nil |
| 1272 | } |
| 1273 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1274 | omciRxCallbackPair := CallbackPair{ |
| 1275 | CbKey: tid, |
| 1276 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1277 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1278 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1279 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1280 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1281 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1282 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1283 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1284 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1285 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1286 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1287 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1288 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1289 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1290 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1291 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1292 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1293 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1294 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1295 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1296 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1297 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1298 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1299 | |
| 1300 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1301 | meParams := me.ParamData{ |
| 1302 | EntityID: aInstNo, |
| 1303 | Attributes: requestedAttributes, |
| 1304 | } |
| 1305 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1306 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1307 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1308 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1309 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1310 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1311 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1312 | } |
| 1313 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1314 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1315 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1316 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1317 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1318 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1319 | } |
| 1320 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1321 | omciRxCallbackPair := CallbackPair{ |
| 1322 | CbKey: tid, |
| 1323 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1324 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1325 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1326 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1327 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1328 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1329 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1330 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1331 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1332 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1333 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1334 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1335 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1336 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1337 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1338 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1339 | // SendGetMe gets ME instance |
| 1340 | 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] | 1341 | timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1342 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1343 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1344 | 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] | 1345 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1346 | |
| 1347 | meParams := me.ParamData{ |
| 1348 | EntityID: entityID, |
| 1349 | Attributes: requestedAttributes, |
| 1350 | } |
| 1351 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1352 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1353 | meClassIDName := meInstance.GetName() |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1354 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1355 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1356 | 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] | 1357 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1358 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1359 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1360 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1361 | 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] | 1362 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1363 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1364 | omciRxCallbackPair := CallbackPair{ |
| 1365 | CbKey: tid, |
| 1366 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1367 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1368 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1369 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1370 | 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] | 1371 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1372 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1373 | 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] | 1374 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1375 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1376 | 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] | 1377 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1378 | } |
| 1379 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1380 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1381 | 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] | 1382 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1383 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1384 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1385 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1386 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1387 | |
| 1388 | request := &omci.GetRequest{ |
| 1389 | MeBasePacket: omci.MeBasePacket{ |
| 1390 | EntityInstance: entityID, |
| 1391 | EntityClass: classID, |
| 1392 | }, |
| 1393 | AttributeMask: requestedAttributesMask, |
| 1394 | } |
| 1395 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1396 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1397 | if err != nil { |
| 1398 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1399 | return err |
| 1400 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1401 | omciRxCallbackPair := CallbackPair{ |
| 1402 | CbKey: tid, |
| 1403 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1404 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1405 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1406 | if err != nil { |
| 1407 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1408 | return err |
| 1409 | } |
| 1410 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1411 | return nil |
| 1412 | } |
| 1413 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1414 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1415 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1416 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1417 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1418 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1419 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1420 | |
| 1421 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1422 | EntityID: aInstID, |
| 1423 | Attributes: me.AttributeValueMap{ |
| 1424 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
| 1425 | "TpPointer": 0xFFFF, |
| 1426 | "InterworkTpPointerForPBitPriority0": 0xFFFF, |
| 1427 | "InterworkTpPointerForPBitPriority1": 0xFFFF, |
| 1428 | "InterworkTpPointerForPBitPriority2": 0xFFFF, |
| 1429 | "InterworkTpPointerForPBitPriority3": 0xFFFF, |
| 1430 | "InterworkTpPointerForPBitPriority4": 0xFFFF, |
| 1431 | "InterworkTpPointerForPBitPriority5": 0xFFFF, |
| 1432 | "InterworkTpPointerForPBitPriority6": 0xFFFF, |
| 1433 | "InterworkTpPointerForPBitPriority7": 0xFFFF, |
| 1434 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1435 | } |
| 1436 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1437 | if omciErr.GetError() == nil { |
| 1438 | //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] | 1439 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1440 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1441 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1442 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1443 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1444 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1445 | } |
| 1446 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1447 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1448 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1449 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1450 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1451 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1452 | } |
| 1453 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1454 | omciRxCallbackPair := CallbackPair{ |
| 1455 | CbKey: tid, |
| 1456 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1457 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1458 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1459 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1460 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1461 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1462 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1463 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1464 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1465 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1466 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1467 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1468 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1469 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1472 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1473 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1474 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1475 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1476 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1477 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1478 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1479 | |
| 1480 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1481 | if omciErr.GetError() == nil { |
| 1482 | //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] | 1483 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1484 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1485 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1486 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1487 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1488 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1489 | } |
| 1490 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1491 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1492 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1493 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1494 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1495 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1496 | } |
| 1497 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1498 | omciRxCallbackPair := CallbackPair{ |
| 1499 | CbKey: tid, |
| 1500 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1501 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1502 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1503 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1504 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1505 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1506 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1507 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1508 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1509 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1510 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1511 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1512 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1513 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1514 | } |
| 1515 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1516 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1517 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1518 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1519 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1520 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1521 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1522 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1523 | |
| 1524 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1525 | if omciErr.GetError() == nil { |
| 1526 | //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] | 1527 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1528 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1529 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1530 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1531 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1532 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1533 | } |
| 1534 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1535 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1536 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1537 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1538 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1539 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1540 | } |
| 1541 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1542 | omciRxCallbackPair := CallbackPair{ |
| 1543 | CbKey: tid, |
| 1544 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1545 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1546 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1547 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1548 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1549 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1550 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1551 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1552 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1553 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1554 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1555 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1556 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1557 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1558 | } |
| 1559 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1560 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1561 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1562 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1563 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1564 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1565 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1566 | |
| 1567 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1568 | if omciErr.GetError() == nil { |
| 1569 | //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] | 1570 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1571 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1572 | if err != nil { |
| 1573 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1574 | "Err": err, "device-id": oo.deviceID}) |
| 1575 | return nil, err |
| 1576 | } |
| 1577 | |
| 1578 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1579 | if err != nil { |
| 1580 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1581 | "Err": err, "device-id": oo.deviceID}) |
| 1582 | return nil, err |
| 1583 | } |
| 1584 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1585 | omciRxCallbackPair := CallbackPair{ |
| 1586 | CbKey: tid, |
| 1587 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1588 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1589 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1590 | if err != nil { |
| 1591 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1592 | "Err": err, "device-id": oo.deviceID}) |
| 1593 | return nil, err |
| 1594 | } |
| 1595 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1596 | return meInstance, nil |
| 1597 | } |
| 1598 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1599 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1600 | return nil, omciErr.GetError() |
| 1601 | } |
| 1602 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1603 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1604 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1605 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1606 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1607 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1608 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1609 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1610 | |
| 1611 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1612 | if omciErr.GetError() == nil { |
| 1613 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1614 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1615 | oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1616 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1617 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1618 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1619 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1620 | } |
| 1621 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1622 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1623 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1624 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1625 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1626 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1627 | } |
| 1628 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1629 | omciRxCallbackPair := CallbackPair{ |
| 1630 | CbKey: tid, |
| 1631 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1632 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1633 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1634 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1635 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1636 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1637 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1638 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1639 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1640 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1641 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1642 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1643 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1644 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1645 | } |
| 1646 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1647 | // SendSetTcontVar sets TCont ME instance |
| 1648 | func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1649 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1650 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1651 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1652 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1653 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1654 | |
| 1655 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1656 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1657 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1658 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1659 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1660 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1661 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1662 | } |
| 1663 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1664 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1665 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1666 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1667 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1668 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1669 | } |
| 1670 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1671 | omciRxCallbackPair := CallbackPair{ |
| 1672 | CbKey: tid, |
| 1673 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1674 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1675 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1676 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1677 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1678 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1679 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1680 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1681 | logger.Debug(ctx, "send TCont-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1682 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1683 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1684 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1685 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1686 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1687 | } |
| 1688 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1689 | // SendSetPrioQueueVar sets PriorityQueue ME instance |
| 1690 | func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1691 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1692 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1693 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1694 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1695 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1696 | |
| 1697 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1698 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1699 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1700 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1701 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1702 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1703 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1704 | } |
| 1705 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1706 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1707 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1708 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1709 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1710 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1711 | } |
| 1712 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1713 | omciRxCallbackPair := CallbackPair{ |
| 1714 | CbKey: tid, |
| 1715 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1716 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1717 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1718 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1719 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1720 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1721 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1722 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1723 | logger.Debug(ctx, "send PrioQueue-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1724 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1725 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1726 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1727 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1728 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1729 | } |
| 1730 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1731 | // SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance |
| 1732 | func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1733 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1734 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1735 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1736 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1737 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1738 | |
| 1739 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1740 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1741 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1742 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1743 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1744 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1745 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1746 | } |
| 1747 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1748 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1749 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1750 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1751 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1752 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1753 | } |
| 1754 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1755 | omciRxCallbackPair := CallbackPair{ |
| 1756 | CbKey: tid, |
| 1757 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1758 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1759 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1760 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1761 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1762 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1763 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1764 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1765 | logger.Debug(ctx, "send 1PMapper-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1766 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1767 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1768 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1769 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1770 | return nil, omciErr.GetError() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1771 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1772 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1773 | // SendCreateVtfdVar creates VlanTaggingFilterData ME instance |
| 1774 | func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1775 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1776 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1777 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1778 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1779 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1780 | |
| 1781 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1782 | if omciErr.GetError() == nil { |
| 1783 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1784 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1785 | oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1786 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1787 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1788 | "Err": err, "device-id": oo.deviceID}) |
| 1789 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1790 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1791 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1792 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1793 | } |
| 1794 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1795 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1796 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1797 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1798 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1799 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1802 | omciRxCallbackPair := CallbackPair{ |
| 1803 | CbKey: tid, |
| 1804 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1805 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1806 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1807 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1808 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1809 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1810 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1811 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1812 | logger.Debug(ctx, "send VTFD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1813 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1814 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1815 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1816 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1817 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1818 | } |
| 1819 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1820 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1821 | func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1822 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1823 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1824 | 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] | 1825 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1826 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1827 | |
| 1828 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1829 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1830 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1831 | oframe.TransactionID(tid)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1832 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1833 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1834 | "Err": err, "device-id": oo.deviceID}) |
| 1835 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1836 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1837 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1838 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1839 | } |
| 1840 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1841 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1842 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1843 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1844 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1845 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1846 | } |
| 1847 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1848 | omciRxCallbackPair := CallbackPair{ |
| 1849 | CbKey: tid, |
| 1850 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1851 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1852 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1853 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1854 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23: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 |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1857 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1858 | logger.Debug(ctx, "send VTFD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1859 | return meInstance, nil |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1860 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1861 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1862 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1863 | return nil, omciErr.GetError() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1864 | } |
| 1865 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1866 | // SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1867 | func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1868 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1869 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1870 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1871 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1872 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1873 | |
| 1874 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1875 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1876 | //EnhancedMode not yet supported, used with default options |
| 1877 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1878 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1879 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1880 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1881 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1882 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1883 | } |
| 1884 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1885 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1886 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1887 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1888 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1889 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1890 | } |
| 1891 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1892 | omciRxCallbackPair := CallbackPair{ |
| 1893 | CbKey: tid, |
| 1894 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1895 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1896 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1897 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1898 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1899 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1900 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1901 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1902 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1903 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1904 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1905 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1906 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1907 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1908 | } |
| 1909 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1910 | // SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1911 | func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1912 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1913 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1914 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1915 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1916 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1917 | |
| 1918 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1919 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1920 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1921 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1922 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1923 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1924 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1925 | } |
| 1926 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1927 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1928 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1929 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1930 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1931 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1932 | } |
| 1933 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1934 | omciRxCallbackPair := CallbackPair{ |
| 1935 | CbKey: tid, |
| 1936 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1937 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1938 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1939 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1940 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1941 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1942 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1943 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1944 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1945 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1946 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1947 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1948 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1949 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1950 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1951 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1952 | // SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1953 | func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1954 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1955 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1956 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1957 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1958 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1959 | |
| 1960 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1961 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1962 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1963 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1964 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1965 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1966 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1967 | } |
| 1968 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1969 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1970 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1971 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1972 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1973 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1974 | } |
| 1975 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1976 | omciRxCallbackPair := CallbackPair{ |
| 1977 | CbKey: tid, |
| 1978 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1979 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1980 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1981 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1982 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1983 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1984 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1985 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1986 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1987 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1988 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1989 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1990 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1991 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1992 | } |
| 1993 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1994 | // SendDeleteVtfd deletes VlanTaggingFilterData ME instance |
| 1995 | func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1996 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1997 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1998 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1999 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2000 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2001 | |
| 2002 | meParams := me.ParamData{EntityID: aInstID} |
| 2003 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 2004 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2005 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2006 | oframe.TransactionID(tid)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2007 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2008 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2009 | "Err": err, "device-id": oo.deviceID}) |
| 2010 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2011 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2012 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2013 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2014 | } |
| 2015 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2016 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2017 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2018 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2019 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2020 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2021 | } |
| 2022 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2023 | omciRxCallbackPair := CallbackPair{ |
| 2024 | CbKey: tid, |
| 2025 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2026 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2027 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2028 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2029 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2030 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2031 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2032 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2033 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2034 | return meInstance, nil |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2035 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2036 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2037 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2038 | return nil, omciErr.GetError() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2039 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2040 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2041 | // SendCreateTDVar creates TrafficDescriptor ME instance |
| 2042 | func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2043 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2044 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2045 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2046 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2047 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2048 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2049 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2050 | if err != nil { |
| 2051 | 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] | 2052 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2053 | } |
| 2054 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2055 | if err != nil { |
| 2056 | 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] | 2057 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2058 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2059 | omciRxCallbackPair := CallbackPair{ |
| 2060 | CbKey: tid, |
| 2061 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2062 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2063 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2064 | if err != nil { |
| 2065 | 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] | 2066 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2067 | } |
| 2068 | logger.Debug(ctx, "send TD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2069 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2070 | } |
| 2071 | 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] | 2072 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2073 | } |
| 2074 | |
| 2075 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2076 | func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2077 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2078 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2079 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2080 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2081 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2082 | |
| 2083 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2084 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2085 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2086 | if err != nil { |
| 2087 | 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] | 2088 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2089 | } |
| 2090 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2091 | if err != nil { |
| 2092 | 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] | 2093 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2094 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2095 | omciRxCallbackPair := CallbackPair{ |
| 2096 | CbKey: tid, |
| 2097 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2098 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2099 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2100 | if err != nil { |
| 2101 | 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] | 2102 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2103 | } |
| 2104 | logger.Debug(ctx, "send TD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2105 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2106 | } |
| 2107 | 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] | 2108 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2109 | |
| 2110 | } |
| 2111 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2112 | // SendDeleteTD - TODO: add comment |
| 2113 | func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2114 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2115 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2116 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2117 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2118 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2119 | |
| 2120 | meParams := me.ParamData{EntityID: aInstID} |
| 2121 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 2122 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2123 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2124 | if err != nil { |
| 2125 | 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] | 2126 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2127 | } |
| 2128 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2129 | if err != nil { |
| 2130 | 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] | 2131 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2132 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2133 | omciRxCallbackPair := CallbackPair{ |
| 2134 | CbKey: tid, |
| 2135 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2136 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2137 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2138 | if err != nil { |
| 2139 | 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] | 2140 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2141 | } |
| 2142 | logger.Debug(ctx, "send TD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2143 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2144 | } |
| 2145 | 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] | 2146 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2147 | |
| 2148 | } |
| 2149 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2150 | // SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance |
| 2151 | func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2152 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2153 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2154 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2155 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2156 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2157 | |
| 2158 | meParams := me.ParamData{EntityID: aInstID} |
| 2159 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2160 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2161 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2162 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2163 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2164 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2165 | "Err": err, "device-id": oo.deviceID}) |
| 2166 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2167 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2168 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2169 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2170 | } |
| 2171 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2172 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2173 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2174 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2175 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2176 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2177 | } |
| 2178 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2179 | omciRxCallbackPair := CallbackPair{ |
| 2180 | CbKey: tid, |
| 2181 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2182 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2183 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2184 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2185 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2186 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2187 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2188 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2189 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2190 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2191 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2192 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2193 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2194 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2195 | } |
| 2196 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2197 | // SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance |
| 2198 | func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2199 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2200 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2201 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2202 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2203 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2204 | |
| 2205 | meParams := me.ParamData{EntityID: aInstID} |
| 2206 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2207 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2208 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2209 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2210 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2211 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2212 | "Err": err, "device-id": oo.deviceID}) |
| 2213 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2214 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2215 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2216 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2217 | } |
| 2218 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2219 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
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 serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2222 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2223 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2226 | omciRxCallbackPair := CallbackPair{ |
| 2227 | CbKey: tid, |
| 2228 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2229 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2230 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2231 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2232 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2233 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2234 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2235 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2236 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2237 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2238 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2239 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2240 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2241 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2242 | } |
| 2243 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2244 | // SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance |
| 2245 | func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2246 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2247 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2248 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2249 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2250 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2251 | |
| 2252 | meParams := me.ParamData{EntityID: aInstID} |
| 2253 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2254 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2255 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2256 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2257 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2258 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2259 | "Err": err, "device-id": oo.deviceID}) |
| 2260 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2261 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2262 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2263 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2264 | } |
| 2265 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2266 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
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 serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2269 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2270 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2271 | } |
| 2272 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2273 | omciRxCallbackPair := CallbackPair{ |
| 2274 | CbKey: tid, |
| 2275 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2276 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2277 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2278 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2279 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2280 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2281 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2282 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2283 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2284 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2285 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2286 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2287 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2288 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2289 | } |
| 2290 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2291 | // SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance |
| 2292 | func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2293 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2294 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2295 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2296 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2297 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2298 | |
| 2299 | meParams := me.ParamData{EntityID: aInstID} |
| 2300 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2301 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2302 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2303 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2304 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2305 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2306 | "Err": err, "device-id": oo.deviceID}) |
| 2307 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2308 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2309 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2310 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2313 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
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 serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2316 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2317 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2318 | } |
| 2319 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2320 | omciRxCallbackPair := CallbackPair{ |
| 2321 | CbKey: tid, |
| 2322 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2323 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2324 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2325 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2326 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2327 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2328 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2329 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2330 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2331 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2332 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2333 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2334 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2335 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2336 | } |
| 2337 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2338 | // SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance |
| 2339 | func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2340 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2341 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2342 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2343 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2344 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2345 | |
| 2346 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2347 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2348 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2349 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2350 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2351 | 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] | 2352 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2353 | } |
| 2354 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2355 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2356 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2357 | 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] | 2358 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2359 | } |
| 2360 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2361 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2362 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2363 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2364 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2365 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2366 | 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] | 2367 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2368 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2369 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2370 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2371 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2372 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2373 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2374 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2375 | } |
| 2376 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2377 | // SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance |
| 2378 | func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2379 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2380 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2381 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2382 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2383 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2384 | |
| 2385 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2386 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2387 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2388 | oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2389 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2390 | 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] | 2391 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2392 | } |
| 2393 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2394 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2395 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2396 | 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] | 2397 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2398 | } |
| 2399 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2400 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2401 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2402 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2403 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2404 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2405 | 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] | 2406 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2407 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2408 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2409 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2410 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2411 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2412 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2413 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2414 | } |
| 2415 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2416 | // SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance |
| 2417 | func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2418 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2419 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2420 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2421 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2422 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2423 | |
| 2424 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2425 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2426 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2427 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2428 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2429 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
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, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2432 | } |
| 2433 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2434 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2435 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2436 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2437 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2438 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2439 | } |
| 2440 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2441 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2442 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2443 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2444 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2445 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2446 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2447 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2448 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2449 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2450 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2451 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2452 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2453 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2454 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2455 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2456 | } |
| 2457 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2458 | // SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance |
| 2459 | func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2460 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2461 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2462 | logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2463 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2464 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2465 | |
| 2466 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2467 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2468 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2469 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2470 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2471 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2472 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2473 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2474 | } |
| 2475 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2476 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2477 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2478 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2479 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2480 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2481 | } |
| 2482 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2483 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2484 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2485 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2486 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2487 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2488 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2489 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2490 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2491 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2492 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2493 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2494 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2495 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2496 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2497 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2498 | } |
| 2499 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2500 | // SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance |
| 2501 | func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2502 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2503 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2504 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2505 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2506 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2507 | |
| 2508 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2509 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2510 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2511 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2512 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2513 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2514 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2515 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2516 | } |
| 2517 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2518 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2519 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2520 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2521 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2522 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2523 | } |
| 2524 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2525 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2526 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2527 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2528 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2529 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2530 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2531 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2532 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2533 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2534 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2535 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2536 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2537 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2538 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2539 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2540 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2541 | |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2542 | // SendCreateVoipVoiceCTP nolint: unused |
| 2543 | func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2544 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2545 | tid := oo.GetNextTid(highPrio) |
| 2546 | logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2547 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2548 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2549 | |
| 2550 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2551 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2552 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2553 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2554 | if err != nil { |
| 2555 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err, |
| 2556 | "device-id": oo.deviceID}) |
| 2557 | return nil, err |
| 2558 | } |
| 2559 | |
| 2560 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2561 | if err != nil { |
| 2562 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err, |
| 2563 | "device-id": oo.deviceID}) |
| 2564 | return nil, err |
| 2565 | } |
| 2566 | |
| 2567 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2568 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2569 | } |
| 2570 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2571 | if err != nil { |
| 2572 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err, |
| 2573 | "device-id": oo.deviceID}) |
| 2574 | return nil, err |
| 2575 | } |
| 2576 | logger.Debug(ctx, "send VoipVoiceCTP-create-msg done") |
| 2577 | return meInstance, nil |
| 2578 | } |
| 2579 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2580 | "device-id": oo.deviceID}) |
| 2581 | return nil, omciErr.GetError() |
| 2582 | } |
| 2583 | |
| 2584 | // SendSetVoipVoiceCTP nolint: unused |
| 2585 | func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2586 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2587 | tid := oo.GetNextTid(highPrio) |
| 2588 | logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2589 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2590 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2591 | |
| 2592 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2593 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2594 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2595 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2596 | if err != nil { |
| 2597 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err, |
| 2598 | "device-id": oo.deviceID}) |
| 2599 | return nil, err |
| 2600 | } |
| 2601 | |
| 2602 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2603 | if err != nil { |
| 2604 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err, |
| 2605 | "device-id": oo.deviceID}) |
| 2606 | return nil, err |
| 2607 | } |
| 2608 | |
| 2609 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2610 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2611 | } |
| 2612 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2613 | if err != nil { |
| 2614 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err, |
| 2615 | "device-id": oo.deviceID}) |
| 2616 | return nil, err |
| 2617 | } |
| 2618 | logger.Debug(ctx, "send VoipVoiceCTP-set-msg done") |
| 2619 | return meInstance, nil |
| 2620 | } |
| 2621 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2622 | "device-id": oo.deviceID}) |
| 2623 | return nil, omciErr.GetError() |
| 2624 | } |
| 2625 | |
| 2626 | // SendDeleteVoipVoiceCTP nolint: unused |
| 2627 | func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2628 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2629 | tid := oo.GetNextTid(highPrio) |
| 2630 | logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2631 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2632 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2633 | |
| 2634 | meParams := me.ParamData{EntityID: aInstID} |
| 2635 | meInstance, omciErr := me.NewVoipVoiceCtp(meParams) |
| 2636 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2637 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2638 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2639 | if err != nil { |
| 2640 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{ |
| 2641 | "Err": err, "device-id": oo.deviceID}) |
| 2642 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2643 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2644 | // (relevant to all used sendXX() methods and their error conditions) |
| 2645 | return nil, err |
| 2646 | } |
| 2647 | |
| 2648 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2649 | if err != nil { |
| 2650 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{ |
| 2651 | "Err": err, "device-id": oo.deviceID}) |
| 2652 | return nil, err |
| 2653 | } |
| 2654 | |
| 2655 | omciRxCallbackPair := CallbackPair{ |
| 2656 | CbKey: tid, |
| 2657 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2658 | } |
| 2659 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2660 | if err != nil { |
| 2661 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{ |
| 2662 | "Err": err, "device-id": oo.deviceID}) |
| 2663 | return nil, err |
| 2664 | } |
| 2665 | logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done") |
| 2666 | return meInstance, nil |
| 2667 | } |
| 2668 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{ |
| 2669 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2670 | return nil, omciErr.GetError() |
| 2671 | } |
| 2672 | |
| 2673 | // SendCreateVoipMediaProfile nolint: unused |
| 2674 | func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2675 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2676 | tid := oo.GetNextTid(highPrio) |
| 2677 | logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2678 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2679 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2680 | |
| 2681 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2682 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2683 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2684 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2685 | if err != nil { |
| 2686 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err, |
| 2687 | "device-id": oo.deviceID}) |
| 2688 | return nil, err |
| 2689 | } |
| 2690 | |
| 2691 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2692 | if err != nil { |
| 2693 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err, |
| 2694 | "device-id": oo.deviceID}) |
| 2695 | return nil, err |
| 2696 | } |
| 2697 | |
| 2698 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2699 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2700 | } |
| 2701 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2702 | if err != nil { |
| 2703 | logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err, |
| 2704 | "device-id": oo.deviceID}) |
| 2705 | return nil, err |
| 2706 | } |
| 2707 | logger.Debug(ctx, "send VoipMediaProfile-create-msg done") |
| 2708 | return meInstance, nil |
| 2709 | } |
| 2710 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2711 | "device-id": oo.deviceID}) |
| 2712 | return nil, omciErr.GetError() |
| 2713 | } |
| 2714 | |
| 2715 | // SendSetVoipMediaProfile nolint: unused |
| 2716 | func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2717 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2718 | tid := oo.GetNextTid(highPrio) |
| 2719 | logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2720 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2721 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2722 | |
| 2723 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2724 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2725 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2726 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2727 | if err != nil { |
| 2728 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err, |
| 2729 | "device-id": oo.deviceID}) |
| 2730 | return nil, err |
| 2731 | } |
| 2732 | |
| 2733 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2734 | if err != nil { |
| 2735 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err, |
| 2736 | "device-id": oo.deviceID}) |
| 2737 | return nil, err |
| 2738 | } |
| 2739 | |
| 2740 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2741 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2742 | } |
| 2743 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2744 | if err != nil { |
| 2745 | logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err, |
| 2746 | "device-id": oo.deviceID}) |
| 2747 | return nil, err |
| 2748 | } |
| 2749 | logger.Debug(ctx, "send VoipMediaProfile-set-msg done") |
| 2750 | return meInstance, nil |
| 2751 | } |
| 2752 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2753 | "device-id": oo.deviceID}) |
| 2754 | return nil, omciErr.GetError() |
| 2755 | } |
| 2756 | |
| 2757 | // SendDeleteVoipMediaProfile nolint: unused |
| 2758 | func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2759 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2760 | tid := oo.GetNextTid(highPrio) |
| 2761 | logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2762 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2763 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2764 | |
| 2765 | meParams := me.ParamData{EntityID: aInstID} |
| 2766 | meInstance, omciErr := me.NewVoipMediaProfile(meParams) |
| 2767 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2768 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2769 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2770 | if err != nil { |
| 2771 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{ |
| 2772 | "Err": err, "device-id": oo.deviceID}) |
| 2773 | return nil, err |
| 2774 | } |
| 2775 | |
| 2776 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2777 | if err != nil { |
| 2778 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{ |
| 2779 | "Err": err, "device-id": oo.deviceID}) |
| 2780 | return nil, err |
| 2781 | } |
| 2782 | |
| 2783 | omciRxCallbackPair := CallbackPair{ |
| 2784 | CbKey: tid, |
| 2785 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2786 | } |
| 2787 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2788 | if err != nil { |
| 2789 | logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{ |
| 2790 | "Err": err, "device-id": oo.deviceID}) |
| 2791 | return nil, err |
| 2792 | } |
| 2793 | logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done") |
| 2794 | return meInstance, nil |
| 2795 | } |
| 2796 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{ |
| 2797 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2798 | return nil, omciErr.GetError() |
| 2799 | } |
| 2800 | |
| 2801 | // SendCreateVoiceServiceProfile nolint: unused |
| 2802 | func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2803 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2804 | tid := oo.GetNextTid(highPrio) |
| 2805 | logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2806 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2807 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2808 | |
| 2809 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 2810 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2811 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2812 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2813 | if err != nil { |
| 2814 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err, |
| 2815 | "device-id": oo.deviceID}) |
| 2816 | return nil, err |
| 2817 | } |
| 2818 | |
| 2819 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2820 | if err != nil { |
| 2821 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err, |
| 2822 | "device-id": oo.deviceID}) |
| 2823 | return nil, err |
| 2824 | } |
| 2825 | |
| 2826 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2827 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2828 | } |
| 2829 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2830 | if err != nil { |
| 2831 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err, |
| 2832 | "device-id": oo.deviceID}) |
| 2833 | return nil, err |
| 2834 | } |
| 2835 | logger.Debug(ctx, "send VoiceServiceProfile-create-msg done") |
| 2836 | return meInstance, nil |
| 2837 | } |
| 2838 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2839 | "device-id": oo.deviceID}) |
| 2840 | return nil, omciErr.GetError() |
| 2841 | } |
| 2842 | |
| 2843 | // SendSetVoiceServiceProfile nolint: unused |
| 2844 | func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2845 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2846 | tid := oo.GetNextTid(highPrio) |
| 2847 | logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2848 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2849 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2850 | |
| 2851 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 2852 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2853 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2854 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2855 | if err != nil { |
| 2856 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err, |
| 2857 | "device-id": oo.deviceID}) |
| 2858 | return nil, err |
| 2859 | } |
| 2860 | |
| 2861 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2862 | if err != nil { |
| 2863 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err, |
| 2864 | "device-id": oo.deviceID}) |
| 2865 | return nil, err |
| 2866 | } |
| 2867 | |
| 2868 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2869 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2870 | } |
| 2871 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2872 | if err != nil { |
| 2873 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err, |
| 2874 | "device-id": oo.deviceID}) |
| 2875 | return nil, err |
| 2876 | } |
| 2877 | logger.Debug(ctx, "send VoiceServiceProfile-set-msg done") |
| 2878 | return meInstance, nil |
| 2879 | } |
| 2880 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2881 | "device-id": oo.deviceID}) |
| 2882 | return nil, omciErr.GetError() |
| 2883 | } |
| 2884 | |
| 2885 | // SendDeleteVoiceServiceProfile nolint: unused |
| 2886 | func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2887 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2888 | tid := oo.GetNextTid(highPrio) |
| 2889 | logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2890 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2891 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2892 | |
| 2893 | meParams := me.ParamData{EntityID: aInstID} |
| 2894 | meInstance, omciErr := me.NewVoiceServiceProfile(meParams) |
| 2895 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2896 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2897 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2898 | if err != nil { |
| 2899 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{ |
| 2900 | "Err": err, "device-id": oo.deviceID}) |
| 2901 | return nil, err |
| 2902 | } |
| 2903 | |
| 2904 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2905 | if err != nil { |
| 2906 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{ |
| 2907 | "Err": err, "device-id": oo.deviceID}) |
| 2908 | return nil, err |
| 2909 | } |
| 2910 | |
| 2911 | omciRxCallbackPair := CallbackPair{ |
| 2912 | CbKey: tid, |
| 2913 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2914 | } |
| 2915 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2916 | if err != nil { |
| 2917 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{ |
| 2918 | "Err": err, "device-id": oo.deviceID}) |
| 2919 | return nil, err |
| 2920 | } |
| 2921 | logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done") |
| 2922 | return meInstance, nil |
| 2923 | } |
| 2924 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{ |
| 2925 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2926 | return nil, omciErr.GetError() |
| 2927 | } |
| 2928 | |
| 2929 | // SendCreateSIPUserData nolint: unused |
| 2930 | func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 2931 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2932 | tid := oo.GetNextTid(highPrio) |
| 2933 | logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2934 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2935 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2936 | |
| 2937 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 2938 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2939 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2940 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2941 | if err != nil { |
| 2942 | logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err, |
| 2943 | "device-id": oo.deviceID}) |
| 2944 | return nil, err |
| 2945 | } |
| 2946 | |
| 2947 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2948 | if err != nil { |
| 2949 | logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err, |
| 2950 | "device-id": oo.deviceID}) |
| 2951 | return nil, err |
| 2952 | } |
| 2953 | |
| 2954 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2955 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2956 | } |
| 2957 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2958 | if err != nil { |
| 2959 | logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err, |
| 2960 | "device-id": oo.deviceID}) |
| 2961 | return nil, err |
| 2962 | } |
| 2963 | logger.Debug(ctx, "send SIPUserData-create-msg done") |
| 2964 | return meInstance, nil |
| 2965 | } |
| 2966 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 2967 | "device-id": oo.deviceID}) |
| 2968 | return nil, omciErr.GetError() |
| 2969 | } |
| 2970 | |
| 2971 | // SendSetSIPUserData nolint: unused |
| 2972 | func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 2973 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2974 | tid := oo.GetNextTid(highPrio) |
| 2975 | logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2976 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2977 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2978 | |
| 2979 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 2980 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2981 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2982 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2983 | if err != nil { |
| 2984 | logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err, |
| 2985 | "device-id": oo.deviceID}) |
| 2986 | return nil, err |
| 2987 | } |
| 2988 | |
| 2989 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2990 | if err != nil { |
| 2991 | logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err, |
| 2992 | "device-id": oo.deviceID}) |
| 2993 | return nil, err |
| 2994 | } |
| 2995 | |
| 2996 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2997 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2998 | } |
| 2999 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3000 | if err != nil { |
| 3001 | logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err, |
| 3002 | "device-id": oo.deviceID}) |
| 3003 | return nil, err |
| 3004 | } |
| 3005 | logger.Debug(ctx, "send SIPUserData-set-msg done") |
| 3006 | return meInstance, nil |
| 3007 | } |
| 3008 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3009 | "device-id": oo.deviceID}) |
| 3010 | return nil, omciErr.GetError() |
| 3011 | } |
| 3012 | |
| 3013 | // SendDeleteSIPUserData nolint: unused |
| 3014 | func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3015 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3016 | tid := oo.GetNextTid(highPrio) |
| 3017 | logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3018 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3019 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3020 | |
| 3021 | meParams := me.ParamData{EntityID: aInstID} |
| 3022 | meInstance, omciErr := me.NewSipUserData(meParams) |
| 3023 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3024 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3025 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3026 | if err != nil { |
| 3027 | logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{ |
| 3028 | "Err": err, "device-id": oo.deviceID}) |
| 3029 | return nil, err |
| 3030 | } |
| 3031 | |
| 3032 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3033 | if err != nil { |
| 3034 | logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{ |
| 3035 | "Err": err, "device-id": oo.deviceID}) |
| 3036 | return nil, err |
| 3037 | } |
| 3038 | |
| 3039 | omciRxCallbackPair := CallbackPair{ |
| 3040 | CbKey: tid, |
| 3041 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3042 | } |
| 3043 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3044 | if err != nil { |
| 3045 | logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{ |
| 3046 | "Err": err, "device-id": oo.deviceID}) |
| 3047 | return nil, err |
| 3048 | } |
| 3049 | logger.Debug(ctx, "send SIPUserData-Delete-msg done") |
| 3050 | return meInstance, nil |
| 3051 | } |
| 3052 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{ |
| 3053 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3054 | return nil, omciErr.GetError() |
| 3055 | } |
| 3056 | |
| 3057 | // SendCreateVoipApplicationServiceProfile nolint: unused |
| 3058 | func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3059 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3060 | tid := oo.GetNextTid(highPrio) |
| 3061 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3062 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3063 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3064 | |
| 3065 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3066 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3067 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3068 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3069 | if err != nil { |
| 3070 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err, |
| 3071 | "device-id": oo.deviceID}) |
| 3072 | return nil, err |
| 3073 | } |
| 3074 | |
| 3075 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3076 | if err != nil { |
| 3077 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3078 | "device-id": oo.deviceID}) |
| 3079 | return nil, err |
| 3080 | } |
| 3081 | |
| 3082 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3083 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3084 | } |
| 3085 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3086 | if err != nil { |
| 3087 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3088 | "device-id": oo.deviceID}) |
| 3089 | return nil, err |
| 3090 | } |
| 3091 | logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done") |
| 3092 | return meInstance, nil |
| 3093 | } |
| 3094 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3095 | "device-id": oo.deviceID}) |
| 3096 | return nil, omciErr.GetError() |
| 3097 | } |
| 3098 | |
| 3099 | // SendSetVoipApplicationServiceProfile nolint: unused |
| 3100 | func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3101 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3102 | tid := oo.GetNextTid(highPrio) |
| 3103 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3104 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3105 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3106 | |
| 3107 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3108 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3109 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3110 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3111 | if err != nil { |
| 3112 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err, |
| 3113 | "device-id": oo.deviceID}) |
| 3114 | return nil, err |
| 3115 | } |
| 3116 | |
| 3117 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3118 | if err != nil { |
| 3119 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3120 | "device-id": oo.deviceID}) |
| 3121 | return nil, err |
| 3122 | } |
| 3123 | |
| 3124 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3125 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3126 | } |
| 3127 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3128 | if err != nil { |
| 3129 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3130 | "device-id": oo.deviceID}) |
| 3131 | return nil, err |
| 3132 | } |
| 3133 | logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done") |
| 3134 | return meInstance, nil |
| 3135 | } |
| 3136 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3137 | "device-id": oo.deviceID}) |
| 3138 | return nil, omciErr.GetError() |
| 3139 | } |
| 3140 | |
| 3141 | // SendDeleteVoipApplicationServiceProfile nolint: unused |
| 3142 | func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3143 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3144 | tid := oo.GetNextTid(highPrio) |
| 3145 | logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3146 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3147 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3148 | |
| 3149 | meParams := me.ParamData{EntityID: aInstID} |
| 3150 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams) |
| 3151 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3152 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3153 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3154 | if err != nil { |
| 3155 | logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{ |
| 3156 | "Err": err, "device-id": oo.deviceID}) |
| 3157 | return nil, err |
| 3158 | } |
| 3159 | |
| 3160 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3161 | if err != nil { |
| 3162 | logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3163 | "Err": err, "device-id": oo.deviceID}) |
| 3164 | return nil, err |
| 3165 | } |
| 3166 | |
| 3167 | omciRxCallbackPair := CallbackPair{ |
| 3168 | CbKey: tid, |
| 3169 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3170 | } |
| 3171 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3172 | if err != nil { |
| 3173 | logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3174 | "Err": err, "device-id": oo.deviceID}) |
| 3175 | return nil, err |
| 3176 | } |
| 3177 | logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done") |
| 3178 | return meInstance, nil |
| 3179 | } |
| 3180 | logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{ |
| 3181 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3182 | return nil, omciErr.GetError() |
| 3183 | } |
| 3184 | |
| 3185 | // SendCreateSIPAgentConfigData nolint: unused |
| 3186 | func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3187 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3188 | tid := oo.GetNextTid(highPrio) |
| 3189 | logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3190 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3191 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3192 | |
| 3193 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3194 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3195 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3196 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3197 | if err != nil { |
| 3198 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err, |
| 3199 | "device-id": oo.deviceID}) |
| 3200 | return nil, err |
| 3201 | } |
| 3202 | |
| 3203 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3204 | if err != nil { |
| 3205 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err, |
| 3206 | "device-id": oo.deviceID}) |
| 3207 | return nil, err |
| 3208 | } |
| 3209 | |
| 3210 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3211 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3212 | } |
| 3213 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3214 | if err != nil { |
| 3215 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err, |
| 3216 | "device-id": oo.deviceID}) |
| 3217 | return nil, err |
| 3218 | } |
| 3219 | logger.Debug(ctx, "send SIPAgentConfigData-create-msg done") |
| 3220 | return meInstance, nil |
| 3221 | } |
| 3222 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3223 | "device-id": oo.deviceID}) |
| 3224 | return nil, omciErr.GetError() |
| 3225 | } |
| 3226 | |
| 3227 | // SendSetSIPAgentConfigData nolint: unused |
| 3228 | func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3229 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3230 | tid := oo.GetNextTid(highPrio) |
| 3231 | logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3232 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3233 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3234 | |
| 3235 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3236 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3237 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3238 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3239 | if err != nil { |
| 3240 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err, |
| 3241 | "device-id": oo.deviceID}) |
| 3242 | return nil, err |
| 3243 | } |
| 3244 | |
| 3245 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3246 | if err != nil { |
| 3247 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err, |
| 3248 | "device-id": oo.deviceID}) |
| 3249 | return nil, err |
| 3250 | } |
| 3251 | |
| 3252 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3253 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3254 | } |
| 3255 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3256 | if err != nil { |
| 3257 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err, |
| 3258 | "device-id": oo.deviceID}) |
| 3259 | return nil, err |
| 3260 | } |
| 3261 | logger.Debug(ctx, "send SIPAgentConfigData-set-msg done") |
| 3262 | return meInstance, nil |
| 3263 | } |
| 3264 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3265 | "device-id": oo.deviceID}) |
| 3266 | return nil, omciErr.GetError() |
| 3267 | } |
| 3268 | |
| 3269 | // SendDeleteSIPAgentConfigData nolint: unused |
| 3270 | func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3271 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3272 | tid := oo.GetNextTid(highPrio) |
| 3273 | logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3274 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3275 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3276 | |
| 3277 | meParams := me.ParamData{EntityID: aInstID} |
| 3278 | meInstance, omciErr := me.NewSipAgentConfigData(meParams) |
| 3279 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3280 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3281 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3282 | if err != nil { |
| 3283 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{ |
| 3284 | "Err": err, "device-id": oo.deviceID}) |
| 3285 | return nil, err |
| 3286 | } |
| 3287 | |
| 3288 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3289 | if err != nil { |
| 3290 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{ |
| 3291 | "Err": err, "device-id": oo.deviceID}) |
| 3292 | return nil, err |
| 3293 | } |
| 3294 | |
| 3295 | omciRxCallbackPair := CallbackPair{ |
| 3296 | CbKey: tid, |
| 3297 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3298 | } |
| 3299 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3300 | if err != nil { |
| 3301 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{ |
| 3302 | "Err": err, "device-id": oo.deviceID}) |
| 3303 | return nil, err |
| 3304 | } |
| 3305 | logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done") |
| 3306 | return meInstance, nil |
| 3307 | } |
| 3308 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3309 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3310 | return nil, omciErr.GetError() |
| 3311 | } |
| 3312 | |
| 3313 | // SendCreateTCPUDPConfigData nolint: unused |
| 3314 | func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3315 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3316 | tid := oo.GetNextTid(highPrio) |
| 3317 | logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3318 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3319 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3320 | |
| 3321 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3322 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3323 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3324 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3325 | if err != nil { |
| 3326 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err, |
| 3327 | "device-id": oo.deviceID}) |
| 3328 | return nil, err |
| 3329 | } |
| 3330 | |
| 3331 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3332 | if err != nil { |
| 3333 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err, |
| 3334 | "device-id": oo.deviceID}) |
| 3335 | return nil, err |
| 3336 | } |
| 3337 | |
| 3338 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3339 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3340 | } |
| 3341 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3342 | if err != nil { |
| 3343 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err, |
| 3344 | "device-id": oo.deviceID}) |
| 3345 | return nil, err |
| 3346 | } |
| 3347 | logger.Debug(ctx, "send TCPUDPConfigData-create-msg done") |
| 3348 | return meInstance, nil |
| 3349 | } |
| 3350 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3351 | "device-id": oo.deviceID}) |
| 3352 | return nil, omciErr.GetError() |
| 3353 | } |
| 3354 | |
| 3355 | // SendSetTCPUDPConfigData nolint: unused |
| 3356 | func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3357 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3358 | tid := oo.GetNextTid(highPrio) |
| 3359 | logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3360 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3361 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3362 | |
| 3363 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3364 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3365 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3366 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3367 | if err != nil { |
| 3368 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err, |
| 3369 | "device-id": oo.deviceID}) |
| 3370 | return nil, err |
| 3371 | } |
| 3372 | |
| 3373 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3374 | if err != nil { |
| 3375 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err, |
| 3376 | "device-id": oo.deviceID}) |
| 3377 | return nil, err |
| 3378 | } |
| 3379 | |
| 3380 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3381 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3382 | } |
| 3383 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3384 | if err != nil { |
| 3385 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err, |
| 3386 | "device-id": oo.deviceID}) |
| 3387 | return nil, err |
| 3388 | } |
| 3389 | logger.Debug(ctx, "send TCPUDPConfigData-set-msg done") |
| 3390 | return meInstance, nil |
| 3391 | } |
| 3392 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3393 | "device-id": oo.deviceID}) |
| 3394 | return nil, omciErr.GetError() |
| 3395 | } |
| 3396 | |
| 3397 | // SendDeleteTCPUDPConfigData nolint: unused |
| 3398 | func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3399 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3400 | tid := oo.GetNextTid(highPrio) |
| 3401 | logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3402 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3403 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3404 | |
| 3405 | meParams := me.ParamData{EntityID: aInstID} |
| 3406 | meInstance, omciErr := me.NewTcpUdpConfigData(meParams) |
| 3407 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3408 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3409 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3410 | if err != nil { |
| 3411 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{ |
| 3412 | "Err": err, "device-id": oo.deviceID}) |
| 3413 | return nil, err |
| 3414 | } |
| 3415 | |
| 3416 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3417 | if err != nil { |
| 3418 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{ |
| 3419 | "Err": err, "device-id": oo.deviceID}) |
| 3420 | return nil, err |
| 3421 | } |
| 3422 | |
| 3423 | omciRxCallbackPair := CallbackPair{ |
| 3424 | CbKey: tid, |
| 3425 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3426 | } |
| 3427 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3428 | if err != nil { |
| 3429 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{ |
| 3430 | "Err": err, "device-id": oo.deviceID}) |
| 3431 | return nil, err |
| 3432 | } |
| 3433 | logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done") |
| 3434 | return meInstance, nil |
| 3435 | } |
| 3436 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3437 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3438 | return nil, omciErr.GetError() |
| 3439 | } |
| 3440 | |
| 3441 | // SendCreateIPHostConfigData nolint: unused |
| 3442 | func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3443 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3444 | tid := oo.GetNextTid(highPrio) |
| 3445 | logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3446 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3447 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3448 | |
| 3449 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3450 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3451 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3452 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3453 | if err != nil { |
| 3454 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err, |
| 3455 | "device-id": oo.deviceID}) |
| 3456 | return nil, err |
| 3457 | } |
| 3458 | |
| 3459 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3460 | if err != nil { |
| 3461 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err, |
| 3462 | "device-id": oo.deviceID}) |
| 3463 | return nil, err |
| 3464 | } |
| 3465 | |
| 3466 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3467 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3468 | } |
| 3469 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3470 | if err != nil { |
| 3471 | logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err, |
| 3472 | "device-id": oo.deviceID}) |
| 3473 | return nil, err |
| 3474 | } |
| 3475 | logger.Debug(ctx, "send IPHostConfigData-create-msg done") |
| 3476 | return meInstance, nil |
| 3477 | } |
| 3478 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3479 | "device-id": oo.deviceID}) |
| 3480 | return nil, omciErr.GetError() |
| 3481 | } |
| 3482 | |
| 3483 | // SendSetIPHostConfigData nolint: unused |
| 3484 | func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3485 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3486 | tid := oo.GetNextTid(highPrio) |
| 3487 | logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3488 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3489 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3490 | |
| 3491 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3492 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3493 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3494 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3495 | if err != nil { |
| 3496 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err, |
| 3497 | "device-id": oo.deviceID}) |
| 3498 | return nil, err |
| 3499 | } |
| 3500 | |
| 3501 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3502 | if err != nil { |
| 3503 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err, |
| 3504 | "device-id": oo.deviceID}) |
| 3505 | return nil, err |
| 3506 | } |
| 3507 | |
| 3508 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3509 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3510 | } |
| 3511 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3512 | if err != nil { |
| 3513 | logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err, |
| 3514 | "device-id": oo.deviceID}) |
| 3515 | return nil, err |
| 3516 | } |
| 3517 | logger.Debug(ctx, "send IPHostConfigData-set-msg done") |
| 3518 | return meInstance, nil |
| 3519 | } |
| 3520 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3521 | "device-id": oo.deviceID}) |
| 3522 | return nil, omciErr.GetError() |
| 3523 | } |
| 3524 | |
| 3525 | // SendDeleteIPHostConfigData nolint: unused |
| 3526 | func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3527 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3528 | tid := oo.GetNextTid(highPrio) |
| 3529 | logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3530 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3531 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3532 | |
| 3533 | meParams := me.ParamData{EntityID: aInstID} |
| 3534 | meInstance, omciErr := me.NewIpHostConfigData(meParams) |
| 3535 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3536 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3537 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3538 | if err != nil { |
| 3539 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{ |
| 3540 | "Err": err, "device-id": oo.deviceID}) |
| 3541 | return nil, err |
| 3542 | } |
| 3543 | |
| 3544 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3545 | if err != nil { |
| 3546 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{ |
| 3547 | "Err": err, "device-id": oo.deviceID}) |
| 3548 | return nil, err |
| 3549 | } |
| 3550 | |
| 3551 | omciRxCallbackPair := CallbackPair{ |
| 3552 | CbKey: tid, |
| 3553 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3554 | } |
| 3555 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3556 | if err != nil { |
| 3557 | logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{ |
| 3558 | "Err": err, "device-id": oo.deviceID}) |
| 3559 | return nil, err |
| 3560 | } |
| 3561 | logger.Debug(ctx, "send IPHostConfigData-Delete-msg done") |
| 3562 | return meInstance, nil |
| 3563 | } |
| 3564 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{ |
| 3565 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3566 | return nil, omciErr.GetError() |
| 3567 | } |
| 3568 | |
| 3569 | // SendCreateRTPProfileData nolint: unused |
| 3570 | func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3571 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3572 | tid := oo.GetNextTid(highPrio) |
| 3573 | logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3574 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3575 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3576 | |
| 3577 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3578 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3579 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3580 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3581 | if err != nil { |
| 3582 | logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err, |
| 3583 | "device-id": oo.deviceID}) |
| 3584 | return nil, err |
| 3585 | } |
| 3586 | |
| 3587 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3588 | if err != nil { |
| 3589 | logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err, |
| 3590 | "device-id": oo.deviceID}) |
| 3591 | return nil, err |
| 3592 | } |
| 3593 | |
| 3594 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3595 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3596 | } |
| 3597 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3598 | if err != nil { |
| 3599 | logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err, |
| 3600 | "device-id": oo.deviceID}) |
| 3601 | return nil, err |
| 3602 | } |
| 3603 | logger.Debug(ctx, "send RTPProfileData-create-msg done") |
| 3604 | return meInstance, nil |
| 3605 | } |
| 3606 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3607 | "device-id": oo.deviceID}) |
| 3608 | return nil, omciErr.GetError() |
| 3609 | } |
| 3610 | |
| 3611 | // SendSetRTPProfileData nolint: unused |
| 3612 | func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3613 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3614 | tid := oo.GetNextTid(highPrio) |
| 3615 | logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3616 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3617 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3618 | |
| 3619 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3620 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3621 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3622 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3623 | if err != nil { |
| 3624 | logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err, |
| 3625 | "device-id": oo.deviceID}) |
| 3626 | return nil, err |
| 3627 | } |
| 3628 | |
| 3629 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3630 | if err != nil { |
| 3631 | logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err, |
| 3632 | "device-id": oo.deviceID}) |
| 3633 | return nil, err |
| 3634 | } |
| 3635 | |
| 3636 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3637 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3638 | } |
| 3639 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3640 | if err != nil { |
| 3641 | logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err, |
| 3642 | "device-id": oo.deviceID}) |
| 3643 | return nil, err |
| 3644 | } |
| 3645 | logger.Debug(ctx, "send RTPProfileData-set-msg done") |
| 3646 | return meInstance, nil |
| 3647 | } |
| 3648 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3649 | "device-id": oo.deviceID}) |
| 3650 | return nil, omciErr.GetError() |
| 3651 | } |
| 3652 | |
| 3653 | // SendDeleteRTPProfileData nolint: unused |
| 3654 | func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3655 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3656 | tid := oo.GetNextTid(highPrio) |
| 3657 | logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3658 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3659 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3660 | |
| 3661 | meParams := me.ParamData{EntityID: aInstID} |
| 3662 | meInstance, omciErr := me.NewRtpProfileData(meParams) |
| 3663 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3664 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3665 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3666 | if err != nil { |
| 3667 | logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{ |
| 3668 | "Err": err, "device-id": oo.deviceID}) |
| 3669 | return nil, err |
| 3670 | } |
| 3671 | |
| 3672 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3673 | if err != nil { |
| 3674 | logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{ |
| 3675 | "Err": err, "device-id": oo.deviceID}) |
| 3676 | return nil, err |
| 3677 | } |
| 3678 | |
| 3679 | omciRxCallbackPair := CallbackPair{ |
| 3680 | CbKey: tid, |
| 3681 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3682 | } |
| 3683 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3684 | if err != nil { |
| 3685 | logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{ |
| 3686 | "Err": err, "device-id": oo.deviceID}) |
| 3687 | return nil, err |
| 3688 | } |
| 3689 | logger.Debug(ctx, "send RTPProfileData-Delete-msg done") |
| 3690 | return meInstance, nil |
| 3691 | } |
| 3692 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{ |
| 3693 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3694 | return nil, omciErr.GetError() |
| 3695 | } |
| 3696 | |
| 3697 | // SendCreateNetworkDialPlanTable nolint: unused |
| 3698 | func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3699 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3700 | tid := oo.GetNextTid(highPrio) |
| 3701 | logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3702 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3703 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3704 | |
| 3705 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3706 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3707 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3708 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3709 | if err != nil { |
| 3710 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err, |
| 3711 | "device-id": oo.deviceID}) |
| 3712 | return nil, err |
| 3713 | } |
| 3714 | |
| 3715 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3716 | if err != nil { |
| 3717 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3718 | "device-id": oo.deviceID}) |
| 3719 | return nil, err |
| 3720 | } |
| 3721 | |
| 3722 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3723 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3724 | } |
| 3725 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3726 | if err != nil { |
| 3727 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3728 | "device-id": oo.deviceID}) |
| 3729 | return nil, err |
| 3730 | } |
| 3731 | logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done") |
| 3732 | return meInstance, nil |
| 3733 | } |
| 3734 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3735 | "device-id": oo.deviceID}) |
| 3736 | return nil, omciErr.GetError() |
| 3737 | } |
| 3738 | |
| 3739 | // SendSetNetworkDialPlanTable nolint: unused |
| 3740 | func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3741 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3742 | tid := oo.GetNextTid(highPrio) |
| 3743 | logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3744 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3745 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3746 | |
| 3747 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3748 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3749 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3750 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3751 | if err != nil { |
| 3752 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err, |
| 3753 | "device-id": oo.deviceID}) |
| 3754 | return nil, err |
| 3755 | } |
| 3756 | |
| 3757 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3758 | if err != nil { |
| 3759 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3760 | "device-id": oo.deviceID}) |
| 3761 | return nil, err |
| 3762 | } |
| 3763 | |
| 3764 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3765 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3766 | } |
| 3767 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3768 | if err != nil { |
| 3769 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3770 | "device-id": oo.deviceID}) |
| 3771 | return nil, err |
| 3772 | } |
| 3773 | logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done") |
| 3774 | return meInstance, nil |
| 3775 | } |
| 3776 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3777 | "device-id": oo.deviceID}) |
| 3778 | return nil, omciErr.GetError() |
| 3779 | } |
| 3780 | |
| 3781 | // SendDeleteNetworkDialPlanTable nolint: unused |
| 3782 | func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3783 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3784 | tid := oo.GetNextTid(highPrio) |
| 3785 | logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3786 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3787 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3788 | |
| 3789 | meParams := me.ParamData{EntityID: aInstID} |
| 3790 | meInstance, omciErr := me.NewNetworkDialPlanTable(meParams) |
| 3791 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3792 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3793 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3794 | if err != nil { |
| 3795 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{ |
| 3796 | "Err": err, "device-id": oo.deviceID}) |
| 3797 | return nil, err |
| 3798 | } |
| 3799 | |
| 3800 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3801 | if err != nil { |
| 3802 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{ |
| 3803 | "Err": err, "device-id": oo.deviceID}) |
| 3804 | return nil, err |
| 3805 | } |
| 3806 | |
| 3807 | omciRxCallbackPair := CallbackPair{ |
| 3808 | CbKey: tid, |
| 3809 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3810 | } |
| 3811 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3812 | if err != nil { |
| 3813 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{ |
| 3814 | "Err": err, "device-id": oo.deviceID}) |
| 3815 | return nil, err |
| 3816 | } |
| 3817 | logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done") |
| 3818 | return meInstance, nil |
| 3819 | } |
| 3820 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{ |
| 3821 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3822 | return nil, omciErr.GetError() |
| 3823 | } |
| 3824 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3825 | // SendSyncTime sends SynchronizeTimeRequest |
| 3826 | func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 3827 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3828 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 3829 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 3830 | |
| 3831 | omciLayer := &omci.OMCI{ |
| 3832 | TransactionID: tid, |
| 3833 | MessageType: omci.SynchronizeTimeRequestType, |
| 3834 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 3835 | // Length: 0x28, // Optional, defaults to 40 octets |
| 3836 | } |
| 3837 | utcTime := time.Now().UTC() |
| 3838 | request := &omci.SynchronizeTimeRequest{ |
| 3839 | MeBasePacket: omci.MeBasePacket{ |
| 3840 | EntityClass: me.OnuGClassID, |
| 3841 | // Default Instance ID is 0 |
| 3842 | }, |
| 3843 | Year: uint16(utcTime.Year()), |
| 3844 | Month: uint8(utcTime.Month()), |
| 3845 | Day: uint8(utcTime.Day()), |
| 3846 | Hour: uint8(utcTime.Hour()), |
| 3847 | Minute: uint8(utcTime.Minute()), |
| 3848 | Second: uint8(utcTime.Second()), |
| 3849 | } |
| 3850 | |
| 3851 | pkt, err := serializeOmciLayer(ctx, omciLayer, request) |
| 3852 | if err != nil { |
| 3853 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 3854 | "device-id": oo.deviceID}) |
| 3855 | return err |
| 3856 | } |
| 3857 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3858 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3859 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3860 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3861 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3862 | if err != nil { |
| 3863 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 3864 | "device-id": oo.deviceID}) |
| 3865 | return err |
| 3866 | } |
| 3867 | logger.Debug(ctx, "send synchronize time request done") |
| 3868 | return nil |
| 3869 | } |
| 3870 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3871 | // SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance |
| 3872 | func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3873 | upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3874 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3875 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3876 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 3877 | meParam := me.ParamData{EntityID: entityID} |
| 3878 | var meInstance *me.ManagedEntity |
| 3879 | var omciErr me.OmciErrors |
| 3880 | if upstream { |
| 3881 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 3882 | } else { |
| 3883 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 3884 | } |
| 3885 | if omciErr.GetError() == nil { |
| 3886 | var omciLayer *omci.OMCI |
| 3887 | var msgLayer gopacket.SerializableLayer |
| 3888 | var err error |
| 3889 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3890 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3891 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3892 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3893 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 3894 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3895 | } |
| 3896 | if err != nil { |
| 3897 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 3898 | 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] | 3899 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3900 | } |
| 3901 | |
| 3902 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3903 | if err != nil { |
| 3904 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 3905 | 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] | 3906 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3907 | } |
| 3908 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3909 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3910 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3911 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3912 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3913 | if err != nil { |
| 3914 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 3915 | 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] | 3916 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3917 | } |
| 3918 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 3919 | 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] | 3920 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3921 | } |
| 3922 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 3923 | 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] | 3924 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3925 | } |
| 3926 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3927 | // SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance |
| 3928 | func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3929 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3930 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3931 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3932 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 3933 | meParam := me.ParamData{EntityID: entityID} |
| 3934 | var meInstance *me.ManagedEntity |
| 3935 | var omciErr me.OmciErrors |
| 3936 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 3937 | |
| 3938 | if omciErr.GetError() == nil { |
| 3939 | var omciLayer *omci.OMCI |
| 3940 | var msgLayer gopacket.SerializableLayer |
| 3941 | var err error |
| 3942 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3943 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3944 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3945 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3946 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 3947 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3948 | } |
| 3949 | if err != nil { |
| 3950 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 3951 | 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] | 3952 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3953 | } |
| 3954 | |
| 3955 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3956 | if err != nil { |
| 3957 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 3958 | 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] | 3959 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3960 | } |
| 3961 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3962 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3963 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3964 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3965 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3966 | if err != nil { |
| 3967 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 3968 | 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] | 3969 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3970 | } |
| 3971 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 3972 | 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] | 3973 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3974 | } |
| 3975 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 3976 | 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] | 3977 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3978 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 3979 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3980 | // SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance |
| 3981 | func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3982 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3983 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 3984 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3985 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 3986 | meParam := me.ParamData{EntityID: entityID} |
| 3987 | var meInstance *me.ManagedEntity |
| 3988 | var omciErr me.OmciErrors |
| 3989 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 3990 | |
| 3991 | if omciErr.GetError() == nil { |
| 3992 | var omciLayer *omci.OMCI |
| 3993 | var msgLayer gopacket.SerializableLayer |
| 3994 | var err error |
| 3995 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3996 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3997 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 3998 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3999 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4000 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4001 | } |
| 4002 | if err != nil { |
| 4003 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 4004 | 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] | 4005 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4006 | } |
| 4007 | |
| 4008 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4009 | if err != nil { |
| 4010 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 4011 | 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] | 4012 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4013 | } |
| 4014 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4015 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4016 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4017 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4018 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4019 | if err != nil { |
| 4020 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 4021 | 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] | 4022 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4023 | } |
| 4024 | logger.Debugw(ctx, "send fec history data ME done", |
| 4025 | 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] | 4026 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4027 | } |
| 4028 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 4029 | 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] | 4030 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4031 | } |
| 4032 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4033 | // SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance |
| 4034 | func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4035 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4036 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4037 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4038 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4039 | meParam := me.ParamData{EntityID: entityID} |
| 4040 | var meInstance *me.ManagedEntity |
| 4041 | var omciErr me.OmciErrors |
| 4042 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 4043 | |
| 4044 | if omciErr.GetError() == nil { |
| 4045 | var omciLayer *omci.OMCI |
| 4046 | var msgLayer gopacket.SerializableLayer |
| 4047 | var err error |
| 4048 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4049 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4050 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4051 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4052 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4053 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4054 | } |
| 4055 | if err != nil { |
| 4056 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 4057 | 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] | 4058 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4059 | } |
| 4060 | |
| 4061 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4062 | if err != nil { |
| 4063 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 4064 | 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] | 4065 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4066 | } |
| 4067 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4068 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4069 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4070 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4071 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4072 | if err != nil { |
| 4073 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 4074 | 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] | 4075 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4076 | } |
| 4077 | logger.Debugw(ctx, "send gemport history data ME done", |
| 4078 | 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] | 4079 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4080 | } |
| 4081 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 4082 | 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] | 4083 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4084 | } |
| 4085 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4086 | // SendStartSoftwareDownload sends StartSoftwareDownloadRequest |
| 4087 | func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4088 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4089 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4090 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4091 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4092 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4093 | |
| 4094 | omciLayer := &omci.OMCI{ |
| 4095 | TransactionID: tid, |
| 4096 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 4097 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4098 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4099 | } |
| 4100 | request := &omci.StartSoftwareDownloadRequest{ |
| 4101 | MeBasePacket: omci.MeBasePacket{ |
| 4102 | EntityClass: me.SoftwareImageClassID, |
| 4103 | EntityInstance: aImageMeID, //inactive image |
| 4104 | }, |
| 4105 | WindowSize: aDownloadWindowSize, |
| 4106 | ImageSize: aFileLen, |
| 4107 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 4108 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 4109 | } |
| 4110 | |
| 4111 | var options gopacket.SerializeOptions |
| 4112 | options.FixLengths = true |
| 4113 | buffer := gopacket.NewSerializeBuffer() |
| 4114 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4115 | if err != nil { |
| 4116 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 4117 | "device-id": oo.deviceID}) |
| 4118 | return err |
| 4119 | } |
| 4120 | outgoingPacket := buffer.Bytes() |
| 4121 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4122 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4123 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4124 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4125 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4126 | if err != nil { |
| 4127 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 4128 | "device-id": oo.deviceID}) |
| 4129 | return err |
| 4130 | } |
| 4131 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4132 | return nil |
| 4133 | } |
| 4134 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4135 | // SendDownloadSection sends DownloadSectionRequestWithResponse |
| 4136 | func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4137 | 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] | 4138 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4139 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4140 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4141 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4142 | |
| 4143 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 4144 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4145 | msgType := omci.DownloadSectionRequestType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4146 | var timeout int = 0 //default value for no response expected |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4147 | if aAckRequest > 0 { |
| 4148 | msgType = omci.DownloadSectionRequestWithResponseType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4149 | timeout = aTimeout |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4150 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4151 | omciLayer := &omci.OMCI{ |
| 4152 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4153 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4154 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4155 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4156 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4157 | localSectionData := make([]byte, len(aSection)) |
| 4158 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4159 | 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] | 4160 | request := &omci.DownloadSectionRequest{ |
| 4161 | MeBasePacket: omci.MeBasePacket{ |
| 4162 | EntityClass: me.SoftwareImageClassID, |
| 4163 | EntityInstance: aImageMeID, //inactive image |
| 4164 | }, |
| 4165 | SectionNumber: aDownloadSectionNo, |
| 4166 | SectionData: localSectionData, |
| 4167 | } |
| 4168 | |
| 4169 | var options gopacket.SerializeOptions |
| 4170 | options.FixLengths = true |
| 4171 | buffer := gopacket.NewSerializeBuffer() |
| 4172 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4173 | if err != nil { |
| 4174 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4175 | "device-id": oo.deviceID}) |
| 4176 | return err |
| 4177 | } |
| 4178 | outgoingPacket := buffer.Bytes() |
| 4179 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4180 | //for initial debug purpose overrule the requested print state for some frames |
| 4181 | printFrame := aPrint |
| 4182 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 4183 | printFrame = true |
| 4184 | } |
| 4185 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4186 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4187 | // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway |
| 4188 | // (used to avoid retransmission of frames with the same TID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4189 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4190 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4191 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4192 | if err != nil { |
| 4193 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 4194 | "device-id": oo.deviceID}) |
| 4195 | return err |
| 4196 | } |
| 4197 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4198 | return nil |
| 4199 | } |
| 4200 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4201 | //SendEndSoftwareDownload sends EndSoftwareDownloadRequest |
| 4202 | func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4203 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4204 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4205 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4206 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4207 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4208 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4209 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4210 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4211 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4212 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4213 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4214 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4215 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4216 | MeBasePacket: omci.MeBasePacket{ |
| 4217 | EntityClass: me.SoftwareImageClassID, |
| 4218 | EntityInstance: aImageMeID, //inactive image |
| 4219 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4220 | CRC32: aImageCrc, |
| 4221 | ImageSize: aFileLen, |
| 4222 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 4223 | 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] | 4224 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4225 | |
| 4226 | var options gopacket.SerializeOptions |
| 4227 | options.FixLengths = true |
| 4228 | buffer := gopacket.NewSerializeBuffer() |
| 4229 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4230 | if err != nil { |
| 4231 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4232 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4233 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4234 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4235 | outgoingPacket := buffer.Bytes() |
| 4236 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4237 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4238 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4239 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4240 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4241 | if err != nil { |
| 4242 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 4243 | "device-id": oo.deviceID}) |
| 4244 | return err |
| 4245 | } |
| 4246 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4247 | return nil |
| 4248 | } |
| 4249 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4250 | // SendActivateSoftware sends ActivateSoftwareRequest |
| 4251 | func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4252 | rxChan chan Message, aImageMeID uint16) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4253 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4254 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4255 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4256 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4257 | |
| 4258 | omciLayer := &omci.OMCI{ |
| 4259 | TransactionID: tid, |
| 4260 | MessageType: omci.ActivateSoftwareRequestType, |
| 4261 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4262 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4263 | } |
| 4264 | request := &omci.ActivateSoftwareRequest{ |
| 4265 | MeBasePacket: omci.MeBasePacket{ |
| 4266 | EntityClass: me.SoftwareImageClassID, |
| 4267 | EntityInstance: aImageMeID, //inactive image |
| 4268 | }, |
| 4269 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 4270 | } |
| 4271 | |
| 4272 | var options gopacket.SerializeOptions |
| 4273 | options.FixLengths = true |
| 4274 | buffer := gopacket.NewSerializeBuffer() |
| 4275 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4276 | if err != nil { |
| 4277 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 4278 | "device-id": oo.deviceID}) |
| 4279 | return err |
| 4280 | } |
| 4281 | outgoingPacket := buffer.Bytes() |
| 4282 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4283 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4284 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4285 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4286 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4287 | if err != nil { |
| 4288 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 4289 | "device-id": oo.deviceID}) |
| 4290 | return err |
| 4291 | } |
| 4292 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4293 | return nil |
| 4294 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4295 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4296 | // SendCommitSoftware sends CommitSoftwareRequest |
| 4297 | func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4298 | rxChan chan Message, aImageMeID uint16) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4299 | tid := oo.GetNextTid(highPrio) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4300 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4301 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4302 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4303 | |
| 4304 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4305 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4306 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4307 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4308 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4309 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4310 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4311 | MeBasePacket: omci.MeBasePacket{ |
| 4312 | EntityClass: me.SoftwareImageClassID, |
| 4313 | EntityInstance: aImageMeID, //inactive image |
| 4314 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4315 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4316 | |
| 4317 | var options gopacket.SerializeOptions |
| 4318 | options.FixLengths = true |
| 4319 | buffer := gopacket.NewSerializeBuffer() |
| 4320 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4321 | if err != nil { |
| 4322 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4323 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4324 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4325 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4326 | outgoingPacket := buffer.Bytes() |
| 4327 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4328 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4329 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4330 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4331 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4332 | if err != nil { |
| 4333 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 4334 | "device-id": oo.deviceID}) |
| 4335 | return err |
| 4336 | } |
| 4337 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4338 | return nil |
| 4339 | } |
| 4340 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4341 | //SendSelfTestReq sends TestRequest |
| 4342 | func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error { |
| 4343 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4344 | logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID, |
| 4345 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4346 | "InstId": strconv.FormatInt(int64(instdID), 16)}) |
| 4347 | omciLayer := &omci.OMCI{ |
| 4348 | TransactionID: tid, |
| 4349 | MessageType: omci.TestRequestType, |
| 4350 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4351 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4352 | } |
| 4353 | |
| 4354 | var request *omci.OpticalLineSupervisionTestRequest |
| 4355 | switch classID { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4356 | case me.AniGClassID: |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4357 | request = &omci.OpticalLineSupervisionTestRequest{ |
| 4358 | MeBasePacket: omci.MeBasePacket{ |
| 4359 | EntityClass: classID, |
| 4360 | EntityInstance: instdID, |
| 4361 | }, |
| 4362 | SelectTest: uint8(7), // self test |
| 4363 | GeneralPurposeBuffer: uint16(0), |
| 4364 | VendorSpecificParameters: uint16(0), |
| 4365 | } |
| 4366 | default: |
| 4367 | logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID}) |
| 4368 | return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID) |
| 4369 | } |
| 4370 | // Test serialization back to former string |
| 4371 | var options gopacket.SerializeOptions |
| 4372 | options.FixLengths = true |
| 4373 | |
| 4374 | buffer := gopacket.NewSerializeBuffer() |
| 4375 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4376 | if err != nil { |
| 4377 | logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err, |
| 4378 | "device-id": oo.deviceID}) |
| 4379 | return err |
| 4380 | } |
| 4381 | outgoingPacket := buffer.Bytes() |
| 4382 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4383 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4384 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4385 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4386 | err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4387 | if err != nil { |
| 4388 | logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err, |
| 4389 | "device-id": oo.deviceID}) |
| 4390 | return err |
| 4391 | } |
| 4392 | logger.Debug(ctx, "send self test request done") |
| 4393 | return nil |
| 4394 | } |
| 4395 | |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4396 | //nolint: gocyclo |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4397 | func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool { |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4398 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4399 | if v == omciMsg.MessageType { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4400 | nextLayer, _ := omci.MsgTypeToNextLayer(v, false) |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4401 | msgLayer := (*packet).Layer(nextLayer) |
| 4402 | switch nextLayer { |
| 4403 | case omci.LayerTypeCreateResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4404 | if resp := msgLayer.(*omci.CreateResponse); resp != nil { |
| 4405 | if resp.Result == me.Success { |
| 4406 | return true |
| 4407 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4408 | } |
| 4409 | case omci.LayerTypeDeleteResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4410 | if resp := msgLayer.(*omci.DeleteResponse); resp != nil { |
| 4411 | if resp.Result == me.Success { |
| 4412 | return true |
| 4413 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4414 | } |
| 4415 | case omci.LayerTypeSetResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4416 | if resp := msgLayer.(*omci.SetResponse); resp != nil { |
| 4417 | if resp.Result == me.Success { |
| 4418 | return true |
| 4419 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4420 | } |
| 4421 | case omci.LayerTypeStartSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4422 | if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil { |
| 4423 | if resp.Result == me.Success { |
| 4424 | return true |
| 4425 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4426 | } |
| 4427 | case omci.LayerTypeEndSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4428 | if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil { |
| 4429 | if resp.Result == me.Success { |
| 4430 | return true |
| 4431 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4432 | } |
| 4433 | case omci.LayerTypeActivateSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4434 | if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil { |
| 4435 | if resp.Result == me.Success { |
| 4436 | return true |
| 4437 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4438 | } |
| 4439 | case omci.LayerTypeCommitSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4440 | if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil { |
| 4441 | if resp.Result == me.Success { |
| 4442 | return true |
| 4443 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4444 | } |
| 4445 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4446 | } |
| 4447 | } |
| 4448 | return false |
| 4449 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4450 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4451 | func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4452 | timeout := aOmciTxRequest.timeout |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4453 | if timeout == 0 { |
| 4454 | //timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4455 | // enqueue |
| 4456 | if aOmciTxRequest.highPrio { |
| 4457 | oo.mutexHighPrioTxQueue.Lock() |
| 4458 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4459 | oo.mutexHighPrioTxQueue.Unlock() |
| 4460 | } else { |
| 4461 | oo.mutexLowPrioTxQueue.Lock() |
| 4462 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4463 | oo.mutexLowPrioTxQueue.Unlock() |
| 4464 | } |
| 4465 | go oo.sendQueuedRequests(ctx) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4466 | } else { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4467 | //the supervised sending with waiting on the response (based on TID) is called in background |
| 4468 | // to avoid blocking of the sender for the complete OMCI handshake procedure |
| 4469 | // to stay consistent with the processing tested so far, sending of next messages of the same control procedure |
| 4470 | // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there) |
| 4471 | go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4472 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4473 | } |
| 4474 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4475 | func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4476 | chSuccess := make(chan bool) |
| 4477 | aOmciTxRequest.chSuccess = chSuccess |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4478 | tid := aOmciTxRequest.cbPair.CbKey |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4479 | oo.mutexMonReq.Lock() |
| 4480 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4481 | oo.mutexMonReq.Unlock() |
| 4482 | |
| 4483 | retries := aOmciTxRequest.retries |
| 4484 | retryCounter := 0 |
| 4485 | loop: |
| 4486 | for retryCounter <= retries { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4487 | // enqueue |
| 4488 | if aOmciTxRequest.highPrio { |
| 4489 | oo.mutexHighPrioTxQueue.Lock() |
| 4490 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4491 | oo.mutexHighPrioTxQueue.Unlock() |
| 4492 | } else { |
| 4493 | oo.mutexLowPrioTxQueue.Lock() |
| 4494 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4495 | oo.mutexLowPrioTxQueue.Unlock() |
| 4496 | } |
| 4497 | go oo.sendQueuedRequests(ctx) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4498 | |
| 4499 | select { |
| 4500 | case success := <-chSuccess: |
| 4501 | if success { |
| 4502 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4503 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4504 | } else { |
| 4505 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4506 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4507 | } |
| 4508 | break loop |
| 4509 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4510 | if retryCounter == retries { |
| 4511 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!", |
| 4512 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4513 | break loop |
| 4514 | } else { |
| 4515 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4516 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4517 | } |
| 4518 | } |
| 4519 | retryCounter++ |
| 4520 | } |
| 4521 | oo.mutexMonReq.Lock() |
| 4522 | delete(oo.monitoredRequests, tid) |
| 4523 | oo.mutexMonReq.Unlock() |
| 4524 | } |
| 4525 | |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4526 | //CancelRequestMonitoring terminates monitoring of outstanding omci requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4527 | func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4528 | oo.mutexMonReq.RLock() |
| 4529 | for k := range oo.monitoredRequests { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 4530 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 4531 | select { |
| 4532 | case oo.monitoredRequests[k].chSuccess <- false: |
| 4533 | default: |
| 4534 | logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{ |
| 4535 | "index": k, "device-id": oo.deviceID}) |
| 4536 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4537 | } |
| 4538 | oo.mutexMonReq.RUnlock() |
| 4539 | } |
| 4540 | |
| 4541 | //GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum |
| 4542 | //time consumed for retry processing of a particular OMCI-request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4543 | func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration { |
| 4544 | return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4545 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4546 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4547 | // SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance |
| 4548 | func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4549 | 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] | 4550 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4551 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4552 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 4553 | |
| 4554 | meParam := me.ParamData{EntityID: entityID, |
| 4555 | Attributes: me.AttributeValueMap{"ControlBlock": controlBlock}, |
| 4556 | } |
| 4557 | var meInstance *me.ManagedEntity |
| 4558 | var omciErr me.OmciErrors |
| 4559 | if classID == me.EthernetFrameExtendedPmClassID { |
| 4560 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam) |
| 4561 | } else { |
| 4562 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam) |
| 4563 | } |
| 4564 | |
| 4565 | if omciErr.GetError() == nil { |
| 4566 | var omciLayer *omci.OMCI |
| 4567 | var msgLayer gopacket.SerializableLayer |
| 4568 | var err error |
| 4569 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4570 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4571 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4572 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4573 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4574 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4575 | } |
| 4576 | if err != nil { |
| 4577 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 4578 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4579 | return nil, err |
| 4580 | } |
| 4581 | |
| 4582 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4583 | if err != nil { |
| 4584 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me", |
| 4585 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4586 | return nil, err |
| 4587 | } |
| 4588 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4589 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4590 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4591 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4592 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4593 | if err != nil { |
| 4594 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 4595 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4596 | return nil, err |
| 4597 | } |
| 4598 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done", |
| 4599 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4600 | return meInstance, nil |
| 4601 | } |
| 4602 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 4603 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4604 | return nil, omciErr.GetError() |
| 4605 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4606 | |
| 4607 | // RLockMutexMonReq lock read access to monitoredRequests |
| 4608 | func (oo *OmciCC) RLockMutexMonReq() { |
| 4609 | oo.mutexMonReq.RLock() |
| 4610 | } |
| 4611 | |
| 4612 | // RUnlockMutexMonReq unlock read access to monitoredRequests |
| 4613 | func (oo *OmciCC) RUnlockMutexMonReq() { |
| 4614 | oo.mutexMonReq.RUnlock() |
| 4615 | } |
| 4616 | |
| 4617 | // GetMonitoredRequest get OmciTransferStructure for an omciTransID |
| 4618 | func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) { |
| 4619 | value, exist = oo.monitoredRequests[omciTransID] |
| 4620 | return value, exist |
| 4621 | } |
| 4622 | |
| 4623 | // SetChMonitoredRequest sets chSuccess to indicate whether response was received or not |
| 4624 | func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) { |
| 4625 | oo.monitoredRequests[omciTransID].chSuccess <- chVal |
| 4626 | } |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4627 | |
| 4628 | // SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me |
| 4629 | func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
| 4630 | rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
| 4631 | tid := oo.GetNextTid(highPrio) |
| 4632 | logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID, |
| 4633 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 4634 | |
| 4635 | meParams := me.ParamData{EntityID: entityID, |
| 4636 | Attributes: me.AttributeValueMap{"ControlBlock": controlBlock}, |
| 4637 | } |
| 4638 | var meInstance *me.ManagedEntity |
| 4639 | var omciErr me.OmciErrors |
| 4640 | if classID == me.EthernetFrameExtendedPmClassID { |
| 4641 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams) |
| 4642 | } else { |
| 4643 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams) |
| 4644 | } |
| 4645 | |
| 4646 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4647 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4648 | if err != nil { |
| 4649 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 4650 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4651 | return nil, err |
| 4652 | } |
| 4653 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4654 | if err != nil { |
| 4655 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg", |
| 4656 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4657 | return nil, err |
| 4658 | } |
| 4659 | omciRxCallbackPair := CallbackPair{ |
| 4660 | CbKey: tid, |
| 4661 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4662 | } |
| 4663 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 4664 | if err != nil { |
| 4665 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 4666 | log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4667 | return nil, err |
| 4668 | } |
| 4669 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done", |
| 4670 | log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4671 | return meInstance, nil |
| 4672 | } |
| 4673 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 4674 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4675 | return nil, omciErr.GetError() |
| 4676 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 4677 | |
| 4678 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 4679 | func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 4680 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 4681 | oo.pBaseDeviceHandler = nil |
| 4682 | oo.pOnuDeviceEntry = nil |
| 4683 | oo.pOnuAlarmManager = nil |
| 4684 | } |