Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
Joey Armstrong | e8c091f | 2023-01-17 16:56:26 -0500 | [diff] [blame] | 2 | * Copyright 2020-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 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 | 93d183f | 2022-04-22 15:50:26 +0000 | [diff] [blame] | 27 | "strings" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 28 | "sync" |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 29 | "time" //by now for testing |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 30 | |
| 31 | "github.com/google/gopacket" |
| 32 | // TODO!!! Some references could be resolved auto, but some need specific context .... |
| 33 | gp "github.com/google/gopacket" |
| 34 | |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 35 | "github.com/opencord/omci-lib-go/v2" |
| 36 | me "github.com/opencord/omci-lib-go/v2/generated" |
| 37 | oframe "github.com/opencord/omci-lib-go/v2/meframe" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 38 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 39 | vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc" |
| 40 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 41 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 42 | "github.com/opencord/voltha-protos/v5/go/common" |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 43 | "github.com/opencord/voltha-protos/v5/go/extension" |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 44 | ia "github.com/opencord/voltha-protos/v5/go/inter_adapter" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 45 | ) |
| 46 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 47 | // ### OMCI related definitions - retrieved from Python adapter code/trace #### |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 48 | |
Holger Hildebrandt | 9b64e0b | 2022-04-21 08:02:00 +0000 | [diff] [blame] | 49 | const maxGemPayloadSize = uint16(2048) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 50 | const connectivityModeValue = uint8(5) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 51 | |
| 52 | //const defaultTPID = uint16(0x8100) |
| 53 | //const broadComDefaultVID = uint16(4091) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 54 | |
| 55 | // UnusedTcontAllocID - TODO: add comment |
| 56 | 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] | 57 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 58 | const cOmciDeviceIdentifierPos = 3 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 59 | const cOmciBaseMessageTrailerLen = 40 |
| 60 | |
| 61 | // tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format) |
| 62 | type tOmciReceiveError uint8 |
| 63 | |
| 64 | const ( |
| 65 | // cOmciMessageReceiveNoError - default start state |
| 66 | cOmciMessageReceiveNoError tOmciReceiveError = iota |
| 67 | // Error indication wrong trailer length within the message |
| 68 | cOmciMessageReceiveErrorTrailerLen |
| 69 | // Error indication missing trailer within the message |
| 70 | cOmciMessageReceiveErrorMissTrailer |
| 71 | ) |
| 72 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 73 | // CDefaultRetries - TODO: add comment |
| 74 | const CDefaultRetries = 2 |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 75 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 76 | // ### OMCI related definitions - end |
| 77 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 78 | //CallbackPairEntry to be used for OMCI send/receive correlation |
| 79 | type CallbackPairEntry struct { |
| 80 | CbRespChannel chan Message |
| 81 | CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error |
| 82 | FramePrint bool //true for printing |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 85 | //CallbackPair to be used for ReceiveCallback init |
| 86 | type CallbackPair struct { |
| 87 | CbKey uint16 |
| 88 | CbEntry CallbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 91 | // OmciTransferStructure - TODO: add comment |
| 92 | type OmciTransferStructure struct { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 93 | txFrame []byte |
| 94 | timeout int |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 95 | retries int |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 96 | highPrio bool |
| 97 | withFramePrint bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 98 | cbPair CallbackPair |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 99 | chSuccess chan bool |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 100 | OnuSwWindow *ia.OmciMessages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 103 | type txRxCounters struct { |
| 104 | txArFrames uint32 |
| 105 | txNoArFrames uint32 |
| 106 | rxAkFrames uint32 |
| 107 | rxNoAkFrames uint32 |
| 108 | } |
| 109 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 110 | //OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 111 | type OmciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 112 | enabled bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 113 | pBaseDeviceHandler IdeviceHandler |
| 114 | pOnuDeviceEntry IonuDeviceEntry |
| 115 | pOnuAlarmManager IonuAlarmManager |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 116 | deviceID string |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 117 | coreClient *vgrpc.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 118 | supportExtMsg bool |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 119 | rxOmciFrameError tOmciReceiveError |
Holger Hildebrandt | 7e13846 | 2023-03-29 12:12:14 +0000 | [diff] [blame] | 120 | confFailMEs []me.ClassID |
| 121 | mutexConfFailMEs sync.RWMutex |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 122 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 123 | mutexCounters sync.RWMutex |
| 124 | countersBase txRxCounters |
| 125 | countersExt txRxCounters |
| 126 | txRetries uint32 |
| 127 | txTimeouts uint32 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 128 | |
| 129 | // OMCI params |
| 130 | mutexTid sync.Mutex |
| 131 | tid uint16 |
| 132 | mutexHpTid sync.Mutex |
| 133 | hpTid uint16 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 134 | UploadSequNo uint16 |
| 135 | UploadNoOfCmds uint16 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 136 | |
Holger Hildebrandt | 556d56c | 2022-12-07 09:23:49 +0000 | [diff] [blame] | 137 | mutexSendQueuedRequests sync.Mutex |
| 138 | mutexLowPrioTxQueue sync.Mutex |
| 139 | lowPrioTxQueue *list.List |
| 140 | mutexHighPrioTxQueue sync.Mutex |
| 141 | highPrioTxQueue *list.List |
| 142 | mutexRxSchedMap sync.Mutex |
| 143 | rxSchedulerMap map[uint16]CallbackPairEntry |
| 144 | mutexMonReq sync.RWMutex |
| 145 | monitoredRequests map[uint16]OmciTransferStructure |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 148 | var responsesWithMibDataSync = []omci.MessageType{ |
| 149 | omci.CreateResponseType, |
| 150 | omci.DeleteResponseType, |
| 151 | omci.SetResponseType, |
| 152 | omci.StartSoftwareDownloadResponseType, |
| 153 | omci.EndSoftwareDownloadResponseType, |
| 154 | omci.ActivateSoftwareResponseType, |
| 155 | omci.CommitSoftwareResponseType, |
| 156 | } |
| 157 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 158 | //NewOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 159 | //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] | 160 | func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler, |
| 161 | onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager, |
| 162 | coreClient *vgrpc.Client) *OmciCC { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 163 | logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 164 | var omciCC OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 165 | omciCC.enabled = false |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 166 | omciCC.pBaseDeviceHandler = deviceHandler |
| 167 | omciCC.pOnuAlarmManager = onuAlarmManager |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 168 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 169 | omciCC.deviceID = deviceID |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 170 | omciCC.coreClient = coreClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 171 | omciCC.supportExtMsg = false |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 172 | omciCC.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | 7e13846 | 2023-03-29 12:12:14 +0000 | [diff] [blame] | 173 | omciCC.confFailMEs = nil |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 174 | omciCC.countersBase = txRxCounters{0, 0, 0, 0} |
| 175 | omciCC.countersExt = txRxCounters{0, 0, 0, 0} |
| 176 | omciCC.txRetries = 0 |
| 177 | omciCC.txTimeouts = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 178 | omciCC.tid = 0x1 |
| 179 | omciCC.hpTid = 0x8000 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 180 | omciCC.UploadSequNo = 0 |
| 181 | omciCC.UploadNoOfCmds = 0 |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 182 | omciCC.lowPrioTxQueue = list.New() |
| 183 | omciCC.highPrioTxQueue = list.New() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 184 | omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry) |
| 185 | omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 186 | return &omciCC |
| 187 | } |
| 188 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 189 | //Stop stops/resets the omciCC |
| 190 | func (oo *OmciCC) Stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 191 | logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 192 | //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] | 193 | oo.CancelRequestMonitoring(ctx) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 194 | // clear the tx queues |
| 195 | oo.mutexHighPrioTxQueue.Lock() |
| 196 | oo.highPrioTxQueue.Init() |
| 197 | oo.mutexHighPrioTxQueue.Unlock() |
| 198 | oo.mutexLowPrioTxQueue.Lock() |
| 199 | oo.lowPrioTxQueue.Init() |
| 200 | oo.mutexLowPrioTxQueue.Unlock() |
| 201 | //clear the scheduler map |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 202 | oo.mutexRxSchedMap.Lock() |
| 203 | for k := range oo.rxSchedulerMap { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 204 | delete(oo.rxSchedulerMap, k) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 205 | } |
| 206 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 207 | //reset the high prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 208 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 209 | oo.hpTid = 0x8000 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 210 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 211 | //reset the low prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 212 | oo.mutexTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 213 | oo.tid = 1 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 214 | oo.mutexTid.Unlock() |
| 215 | //reset control values |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 216 | oo.UploadSequNo = 0 |
| 217 | oo.UploadNoOfCmds = 0 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 218 | oo.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | 7e13846 | 2023-03-29 12:12:14 +0000 | [diff] [blame] | 219 | oo.ResetConfFailMEs() |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 220 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 221 | //reset the stats counter |
| 222 | oo.mutexCounters.Lock() |
| 223 | oo.countersBase = txRxCounters{0, 0, 0, 0} |
| 224 | oo.countersExt = txRxCounters{0, 0, 0, 0} |
| 225 | oo.txRetries = 0 |
| 226 | oo.txTimeouts = 0 |
| 227 | oo.mutexCounters.Unlock() |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 228 | return nil |
| 229 | } |
| 230 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 231 | // Rx handler for omci messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 232 | 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] | 233 | logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 234 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 235 | switch omciMsg.MessageType { |
| 236 | case omci.AlarmNotificationType: |
| 237 | data := OmciMessage{ |
| 238 | OmciMsg: omciMsg, |
| 239 | OmciPacket: packet, |
| 240 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 241 | go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 242 | return nil |
| 243 | default: |
| 244 | return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String()) |
| 245 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 246 | /* |
| 247 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 248 | rxOnuFrames++ |
| 249 | |
| 250 | switch msgType { |
| 251 | case AlarmNotification: |
| 252 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 253 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 254 | // python code was: |
| 255 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 256 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 257 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 258 | // |
| 259 | return errors.New("RxAlarmNotification unimplemented") |
| 260 | } |
| 261 | case AttributeValueChange: |
| 262 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 263 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 264 | // python code was: |
| 265 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 266 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 267 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 268 | // |
| 269 | return errors.New("RxAttributeValueChange unimplemented") |
| 270 | } |
| 271 | case TestResult: |
| 272 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 273 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 274 | // python code was: |
| 275 | //elif msg_type == EntityOperations.TestResult.value: |
| 276 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 277 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 278 | // |
| 279 | return errors.New("RxTestResult unimplemented") |
| 280 | } |
| 281 | default: |
| 282 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 283 | logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 284 | rxOnuDiscards++ |
| 285 | return errors.New("RxOnuMsgType unimplemented") |
| 286 | } |
| 287 | } |
| 288 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 289 | } |
| 290 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 291 | func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 292 | //assuming omci message content is hex coded! |
| 293 | // with restricted output of 16bytes would be ...rxMsg[:16] |
| 294 | logger.Debugw(ctx, "omci-message-received:", log.Fields{ |
| 295 | "RxOmciMessage": hex.EncodeToString(rxMsg), |
| 296 | "device-id": oo.deviceID}) |
| 297 | } |
| 298 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 299 | // ReceiveMessage - Rx handler for onu messages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 300 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 301 | // nolint: gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 302 | func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 303 | //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)}) |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 304 | |
| 305 | if len(rxMsg) < 10 { |
| 306 | logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort", |
| 307 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 308 | if len(rxMsg) > 0 { |
| 309 | oo.printRxMessage(ctx, rxMsg) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 310 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 311 | return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID) |
| 312 | } |
| 313 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 314 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 315 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 316 | // (an extendedFormat message could be destroyed this way!) |
| 317 | trailerLenData := rxMsg[42:44] |
| 318 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
| 319 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
| 320 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 321 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 322 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 323 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 324 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 325 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 326 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 327 | } |
| 328 | } |
| 329 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 330 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 331 | // (an extendedFormat message could be destroyed this way!) |
| 332 | // extend/overwrite with trailer |
| 333 | trailer := make([]byte, 8) |
| 334 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 335 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 336 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 337 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 338 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 339 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 340 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
| 341 | } |
| 342 | } else { |
| 343 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 344 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 345 | oo.printRxMessage(ctx, rxMsg) |
| 346 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
| 347 | } |
| 348 | } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) { |
| 349 | if len(rxMsg) > 1980 { |
| 350 | logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort", |
| 351 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 352 | oo.printRxMessage(ctx, rxMsg) |
| 353 | return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 354 | } |
| 355 | } else { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 356 | logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort", |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 357 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 358 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 359 | return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 360 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 361 | decodeOptions := gopacket.DecodeOptions{ |
| 362 | Lazy: true, |
| 363 | NoCopy: true, |
| 364 | } |
| 365 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 366 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 367 | 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] | 368 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 369 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 370 | } |
| 371 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 372 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 373 | 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] | 374 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 375 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 376 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 377 | // insert some check on detected OMCI decoding issues and log them |
| 378 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 379 | // even though allowed from omci-lib due to set relaxed decoding |
| 380 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 381 | // (compare mib_sync.go unknownAttrLayer) |
| 382 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 383 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 384 | errMsg := failure.Error() |
| 385 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 386 | "device-id": oo.deviceID, "issue": errMsg}) |
| 387 | } |
| 388 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 389 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 390 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 391 | 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] | 392 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 393 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 394 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 395 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 396 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
| 397 | "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 398 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 399 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 400 | // We expect to find the TID in the oo.rxSchedulerMap |
| 401 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 402 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 403 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 404 | logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 405 | if omciMsg.TransactionID == 0 { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 406 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 407 | oo.incrementBaseRxNoAkFrames() |
| 408 | } else { |
| 409 | oo.incrementExtRxNoAkFrames() |
| 410 | } |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 411 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 412 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 413 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 414 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 415 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 416 | 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] | 417 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 418 | //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] | 419 | oo.mutexRxSchedMap.Lock() |
| 420 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 421 | if ok && rxCallbackEntry.CbFunction != nil { |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 422 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 423 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 424 | oo.printRxMessage(ctx, rxMsg) |
| 425 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 426 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 427 | oo.incrementBaseRxAkFrames() |
| 428 | } else { |
| 429 | oo.incrementExtRxAkFrames() |
| 430 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 431 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 432 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 433 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 434 | isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet) |
| 435 | if err != nil { |
| 436 | // qualified error logging already done in function above |
| 437 | if !rxCallbackEntry.FramePrint { |
| 438 | oo.printRxMessage(ctx, rxMsg) |
| 439 | } |
| 440 | return fmt.Errorf("could not decode further layers %s", oo.deviceID) |
| 441 | } |
| 442 | if isSuccessfulResponse { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 443 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 444 | } else { |
| 445 | logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type", |
| 446 | log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID}) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 447 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 448 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 449 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 450 | // so do not clean up the TransactionID in that case. |
| 451 | if omciMsg.MessageType != omci.TestResponseType { |
| 452 | // having posted the response the request is regarded as 'done' |
| 453 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 454 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 455 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 456 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 457 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 458 | oo.mutexRxSchedMap.Unlock() |
| 459 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 460 | oo.printRxMessage(ctx, rxMsg) |
| 461 | 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] | 462 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 463 | /* py code was: |
| 464 | Receive and OMCI message from the proxy channel to the OLT. |
| 465 | |
| 466 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 467 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 468 | """ |
| 469 | if not self.enabled: |
| 470 | return |
| 471 | |
| 472 | try: |
| 473 | now = arrow.utcnow() |
| 474 | d = None |
| 475 | |
| 476 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 477 | # save the current value of the entity_id_to_class_map, then |
| 478 | # replace it with our custom one before decode, and then finally |
| 479 | # restore it later. Tried other ways but really made the code messy. |
| 480 | saved_me_map = omci_entities.entity_id_to_class_map |
| 481 | omci_entities.entity_id_to_class_map = self._me_map |
| 482 | |
| 483 | try: |
| 484 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 485 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 486 | except KeyError as e: |
| 487 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 488 | 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] | 489 | rx_frame = self._decode_unknown_me(msg) |
| 490 | self._rx_unknown_me += 1 |
| 491 | |
| 492 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 493 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 494 | return |
| 495 | |
| 496 | finally: |
| 497 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 498 | |
| 499 | rx_tid = rx_frame.fields['transaction_id'] |
| 500 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 501 | 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] | 502 | # Filter the Test Result frame and route through receive onu |
| 503 | # message method. |
| 504 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 505 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 506 | return self._receive_onu_message(rx_frame) |
| 507 | |
| 508 | # Previously unreachable if this is the very first round-trip Rx or we |
| 509 | # have been running consecutive errors |
| 510 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 511 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 512 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 513 | |
| 514 | self._rx_frames += 1 |
| 515 | self._consecutive_errors = 0 |
| 516 | |
| 517 | try: |
| 518 | high_priority = self._tid_is_high_priority(rx_tid) |
| 519 | index = self._get_priority_index(high_priority) |
| 520 | |
| 521 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 522 | last_tx_tuple = self._tx_request[index] |
| 523 | |
| 524 | if last_tx_tuple is None or \ |
| 525 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 526 | # Possible late Rx on a message that timed-out |
| 527 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 528 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 529 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 530 | self._rx_unknown_tid += 1 |
| 531 | self._rx_late += 1 |
| 532 | return |
| 533 | |
| 534 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 535 | if dc is not None and not dc.cancelled and not dc.called: |
| 536 | dc.cancel() |
| 537 | |
| 538 | _secs = self._update_rx_tx_stats(now, ts) |
| 539 | |
| 540 | # Late arrival already serviced by a timeout? |
| 541 | if d.called: |
| 542 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 543 | 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] | 544 | return |
| 545 | |
| 546 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 547 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 548 | if d is not None: |
| 549 | return d.errback(failure.Failure(e)) |
| 550 | return |
| 551 | |
| 552 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 553 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 554 | tx_tid = tx_frame.fields['transaction_id']) |
| 555 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 556 | |
| 557 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 558 | self._rx_response[index] = rx_frame |
| 559 | d.callback(rx_frame) |
| 560 | |
| 561 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 562 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 563 | */ |
| 564 | } |
| 565 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 566 | /* |
| 567 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 568 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 569 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 570 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 571 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 572 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 573 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 574 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 575 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 576 | delete(oo.rxSchedulerMap, tid) |
| 577 | } |
| 578 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 579 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 580 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 581 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 582 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 583 | if timeout != 0 { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 584 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 585 | oo.mutexRxSchedMap.Lock() |
| 586 | // 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] | 587 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 588 | oo.mutexRxSchedMap.Unlock() |
| 589 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 590 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 591 | 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] | 592 | //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] | 593 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 594 | txFrame, |
| 595 | timeout, |
| 596 | retry, |
| 597 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 598 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 599 | receiveCallbackPair, |
| 600 | nil, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 601 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 602 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 603 | oo.mutexMonReq.Lock() |
| 604 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 605 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 606 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 607 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 608 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 609 | return nil |
| 610 | } |
| 611 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 612 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 613 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 614 | } |
| 615 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 616 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 617 | // Avoid accessing the txQueues from parallel send routines to block |
| 618 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 619 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 620 | // for the corresponding response too (t.b.d.). |
| 621 | oo.mutexSendQueuedRequests.Lock() |
| 622 | defer oo.mutexSendQueuedRequests.Unlock() |
| 623 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 624 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 625 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 626 | return |
| 627 | } |
| 628 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 629 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 630 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 631 | return |
| 632 | } |
| 633 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 634 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 635 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 636 | oo.mutexHighPrioTxQueue.Lock() |
| 637 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 638 | for oo.highPrioTxQueue.Len() > 0 { |
| 639 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 640 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 641 | // Element will be removed from the queue regardless of the send success, to prevent |
| 642 | // an accumulation of send requests for the same message in the event of an error. |
| 643 | // In this case, resend attempts for the message are ensured by our retry |
| 644 | // mechanism after omci-timeout. |
| 645 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 646 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 647 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 648 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 649 | } |
| 650 | return nil |
| 651 | } |
| 652 | |
| 653 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 654 | oo.mutexLowPrioTxQueue.Lock() |
| 655 | for oo.lowPrioTxQueue.Len() > 0 { |
| 656 | queueElement := oo.lowPrioTxQueue.Front() // First element |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 657 | // check if the element is for onu sw section |
| 658 | aOmciTxReq := queueElement.Value.(OmciTransferStructure) |
| 659 | if aOmciTxReq.OnuSwWindow != nil { |
| 660 | if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 661 | // Element will be removed from the queue regardless of the send success, to prevent |
| 662 | // an accumulation of send requests for the same message in the event of an error. |
| 663 | // In this case, resend attempts for the message are ensured by our retry |
| 664 | // mechanism after omci-timeout. |
| 665 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 666 | oo.mutexLowPrioTxQueue.Unlock() |
| 667 | return err |
| 668 | } |
| 669 | } else { |
| 670 | err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)) |
| 671 | if err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 672 | // Element will be removed from the queue regardless of the send success, to prevent |
| 673 | // an accumulation of send requests for the same message in the event of an error. |
| 674 | // In this case, resend attempts for the message are ensured by our retry |
| 675 | // mechanism after omci-timeout. |
| 676 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 677 | oo.mutexLowPrioTxQueue.Unlock() |
| 678 | return err |
| 679 | } |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 680 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 681 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 682 | // Interrupt the sending of low priority requests to process any high priority requests |
| 683 | // that may have arrived in the meantime |
| 684 | oo.mutexLowPrioTxQueue.Unlock() |
| 685 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 686 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 687 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 688 | oo.mutexLowPrioTxQueue.Lock() |
| 689 | } |
| 690 | |
| 691 | oo.mutexLowPrioTxQueue.Unlock() |
| 692 | return nil |
| 693 | } |
| 694 | |
| 695 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 696 | if omciTxRequest.withFramePrint { |
| 697 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 698 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 699 | "device-id": oo.deviceID, |
| 700 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 701 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 702 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 703 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 704 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 705 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 706 | ChildDeviceId: oo.deviceID, |
| 707 | Message: omciTxRequest.txFrame, |
| 708 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 709 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 710 | } |
| 711 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 712 | if sendErr != nil { |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 713 | logger.Errorw(ctx, "send omci request error", log.Fields{"device-id": oo.deviceID, "ChildId": oo.deviceID, "error": sendErr}) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 714 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 715 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 716 | if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 717 | oo.incrementBaseTxArFrames() |
| 718 | } else { |
| 719 | oo.incrementExtTxArFrames() |
| 720 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 721 | return nil |
| 722 | } |
| 723 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 724 | // GetNextTid - TODO: add comment |
| 725 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 726 | var next uint16 |
| 727 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 728 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 729 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 730 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 731 | if oo.hpTid < 0x8000 { |
| 732 | oo.hpTid = 0x8000 |
| 733 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 734 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 735 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 736 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 737 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 738 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 739 | if oo.tid >= 0x8000 { |
| 740 | oo.tid = 1 |
| 741 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 742 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 743 | } |
| 744 | return next |
| 745 | } |
| 746 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 747 | //GetOnuSwSecNextTid get the next low prio tid for the onu sw sections |
| 748 | //onu sw sections uses only low priority tids |
| 749 | //The mutexTid lock should be taken prior to using this function |
| 750 | func (oo *OmciCC) GetOnuSwSecNextTid() uint16 { |
| 751 | next := oo.tid |
| 752 | oo.tid++ |
| 753 | if oo.tid >= 0x8000 { |
| 754 | oo.tid = 1 |
| 755 | } |
| 756 | return next |
| 757 | } |
| 758 | |
| 759 | //GetOnuSwSecLastTid gets the last allocated tid |
| 760 | //The mutexTid lock should be taken prior to using this function |
| 761 | func (oo *OmciCC) GetOnuSwSecLastTid() uint16 { |
| 762 | next := oo.tid |
| 763 | lastAllocatedTid := next - 1 |
| 764 | return lastAllocatedTid |
| 765 | } |
| 766 | |
| 767 | //LockMutexTID locks mutexTid |
| 768 | func (oo *OmciCC) LockMutexTID() { |
| 769 | oo.mutexTid.Lock() |
| 770 | } |
| 771 | |
| 772 | //UnLockMutexTID unlocks mutexTid |
| 773 | func (oo *OmciCC) UnLockMutexTID() { |
| 774 | oo.mutexTid.Unlock() |
| 775 | } |
| 776 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 777 | // ################################################################################### |
| 778 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 779 | |
| 780 | // Serialize - TODO: add comment |
| 781 | 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] | 782 | omciLayer := &omci.OMCI{ |
| 783 | TransactionID: tid, |
| 784 | MessageType: msgType, |
| 785 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 786 | return SerializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 787 | } |
| 788 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 789 | // SerializeOmciLayer - TODO: add comment |
| 790 | 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] | 791 | var options gopacket.SerializeOptions |
| 792 | options.FixLengths = true |
| 793 | |
| 794 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 795 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 796 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 797 | 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] | 798 | return nil, err |
| 799 | } |
| 800 | return buffer.Bytes(), nil |
| 801 | } |
| 802 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 803 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 804 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 805 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 806 | hex.Encode(dst, omciPkt) |
| 807 | return dst, nil |
| 808 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 809 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 810 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 811 | //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] | 812 | 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] | 813 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 814 | 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] | 815 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 816 | |
| 817 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 818 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 819 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 820 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 821 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 822 | oo.mutexMonReq.RLock() |
| 823 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 824 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 825 | select { |
| 826 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 827 | default: |
| 828 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 829 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 830 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 831 | } else { |
| 832 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 833 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 834 | } |
| 835 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 836 | |
| 837 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 838 | // 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] | 839 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 840 | Type: OMCI, |
| 841 | Data: OmciMessage{ |
| 842 | OmciMsg: omciMsg, |
| 843 | OmciPacket: packet, |
| 844 | }, |
| 845 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 846 | //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] | 847 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 848 | |
| 849 | return nil |
| 850 | } |
| 851 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 852 | // SendMibReset sends MibResetRequest |
| 853 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 854 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 855 | 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] | 856 | request := &omci.MibResetRequest{ |
| 857 | MeBasePacket: omci.MeBasePacket{ |
| 858 | EntityClass: me.OnuDataClassID, |
| 859 | }, |
| 860 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 861 | tid := oo.GetNextTid(highPrio) |
| 862 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 863 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 864 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 865 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 866 | return err |
| 867 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 868 | omciRxCallbackPair := CallbackPair{ |
| 869 | CbKey: tid, |
| 870 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 871 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 872 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 875 | // SendReboot sends RebootRequest |
| 876 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 877 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 878 | request := &omci.RebootRequest{ |
| 879 | MeBasePacket: omci.MeBasePacket{ |
| 880 | EntityClass: me.OnuGClassID, |
| 881 | }, |
| 882 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 883 | tid := oo.GetNextTid(highPrio) |
| 884 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 885 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 886 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 887 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 888 | return err |
| 889 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 890 | omciRxCallbackPair := CallbackPair{ |
| 891 | CbKey: tid, |
| 892 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 893 | } |
| 894 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 895 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 896 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 897 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 898 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 899 | return err |
| 900 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 901 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 902 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 903 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 904 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 905 | return err |
| 906 | } |
| 907 | return nil |
| 908 | } |
| 909 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 910 | // SendMibUpload sends MibUploadRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 911 | func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 912 | logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 913 | |
| 914 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 915 | |
| 916 | omciLayer := &omci.OMCI{ |
| 917 | TransactionID: tid, |
| 918 | MessageType: omci.MibUploadRequestType, |
| 919 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 920 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 921 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 922 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 923 | request := &omci.MibUploadRequest{ |
| 924 | MeBasePacket: omci.MeBasePacket{ |
| 925 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 926 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 927 | }, |
| 928 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 929 | var options gopacket.SerializeOptions |
| 930 | options.FixLengths = true |
| 931 | |
| 932 | buffer := gopacket.NewSerializeBuffer() |
| 933 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 934 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 935 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 936 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 937 | return err |
| 938 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 939 | oo.UploadSequNo = 0 |
| 940 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 941 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 942 | omciRxCallbackPair := CallbackPair{ |
| 943 | CbKey: tid, |
| 944 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 945 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 946 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 947 | } |
| 948 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 949 | // SendMibUploadNext sends MibUploadNextRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 950 | func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 951 | logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo}) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 952 | |
| 953 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 954 | |
| 955 | omciLayer := &omci.OMCI{ |
| 956 | TransactionID: tid, |
| 957 | MessageType: omci.MibUploadNextRequestType, |
| 958 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 959 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 960 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 961 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 962 | request := &omci.MibUploadNextRequest{ |
| 963 | MeBasePacket: omci.MeBasePacket{ |
| 964 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 965 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 966 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 967 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 968 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 969 | var options gopacket.SerializeOptions |
| 970 | options.FixLengths = true |
| 971 | |
| 972 | buffer := gopacket.NewSerializeBuffer() |
| 973 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 974 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 975 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 976 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 977 | return err |
| 978 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 979 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 980 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 981 | omciRxCallbackPair := CallbackPair{ |
| 982 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 983 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 984 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 985 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 986 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 987 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 988 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 989 | } |
| 990 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 991 | // SendGetAllAlarm gets all alarm ME instances |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 992 | func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool, isExtendedOmci bool) error { |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 993 | logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 994 | |
| 995 | tid := oo.GetNextTid(highPrio) |
| 996 | omciLayer := &omci.OMCI{ |
| 997 | TransactionID: tid, |
| 998 | MessageType: omci.GetAllAlarmsRequestType, |
| 999 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1000 | } |
| 1001 | if isExtendedOmci { |
| 1002 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1003 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1004 | request := &omci.GetAllAlarmsRequest{ |
| 1005 | MeBasePacket: omci.MeBasePacket{ |
| 1006 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1007 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1008 | }, |
| 1009 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 1010 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1011 | var options gopacket.SerializeOptions |
| 1012 | options.FixLengths = true |
| 1013 | buffer := gopacket.NewSerializeBuffer() |
| 1014 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1015 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1016 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1017 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1018 | return err |
| 1019 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1020 | outgoingPacket := buffer.Bytes() |
| 1021 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1022 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1023 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1024 | omciRxCallbackPair := CallbackPair{ |
| 1025 | CbKey: tid, |
| 1026 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1027 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1028 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1029 | if err != nil { |
| 1030 | logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1031 | "device-id": oo.deviceID}) |
| 1032 | return err |
| 1033 | } |
| 1034 | logger.Debug(ctx, "send GetAllAlarmsRequest done") |
| 1035 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1036 | } |
| 1037 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1038 | // SendGetAllAlarmNext gets next alarm ME instance |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1039 | func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool, isExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1040 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 1041 | 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] | 1042 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1043 | |
| 1044 | tid := oo.GetNextTid(highPrio) |
| 1045 | omciLayer := &omci.OMCI{ |
| 1046 | TransactionID: tid, |
| 1047 | MessageType: omci.GetAllAlarmsNextRequestType, |
| 1048 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1049 | } |
| 1050 | if isExtendedOmci { |
| 1051 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1052 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1053 | request := &omci.GetAllAlarmsNextRequest{ |
| 1054 | MeBasePacket: omci.MeBasePacket{ |
| 1055 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1056 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1057 | }, |
| 1058 | CommandSequenceNumber: alarmUploadSeqNo, |
| 1059 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1060 | var options gopacket.SerializeOptions |
| 1061 | options.FixLengths = true |
| 1062 | buffer := gopacket.NewSerializeBuffer() |
| 1063 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1064 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1065 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1066 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1067 | return err |
| 1068 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1069 | outgoingPacket := buffer.Bytes() |
| 1070 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1071 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1072 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1073 | omciRxCallbackPair := CallbackPair{ |
| 1074 | CbKey: tid, |
| 1075 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1076 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1077 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1078 | if err != nil { |
| 1079 | logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1080 | "device-id": oo.deviceID}) |
| 1081 | return err |
| 1082 | } |
| 1083 | logger.Debug(ctx, "send GetAllAlarmsNextRequest done") |
| 1084 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1085 | } |
| 1086 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1087 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 1088 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1089 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1090 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1091 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1092 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1093 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1094 | EntityID: GalEthernetEID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1095 | Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1096 | } |
| 1097 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 1098 | if omciErr.GetError() == nil { |
| 1099 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1100 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1101 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1102 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1103 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1104 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1107 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1108 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1109 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1110 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1111 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1112 | } |
| 1113 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1114 | omciRxCallbackPair := CallbackPair{ |
| 1115 | CbKey: tid, |
| 1116 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1117 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1118 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1119 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1120 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1121 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1122 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1123 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1124 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1125 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1126 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1127 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1128 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1129 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1132 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1133 | // 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] | 1134 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1135 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1136 | 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] | 1137 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1138 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1139 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 1140 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1141 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 1142 | // read ONU-2G from DB ???? //TODO!!! |
| 1143 | meParams := me.ParamData{ |
| 1144 | EntityID: 0, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1145 | Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1146 | } |
| 1147 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 1148 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1149 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1150 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1151 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1152 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1153 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1154 | } |
| 1155 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1156 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1157 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1158 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1159 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1160 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1161 | } |
| 1162 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1163 | omciRxCallbackPair := CallbackPair{ |
| 1164 | CbKey: tid, |
| 1165 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1166 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1167 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1168 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1169 | logger.Errorw(ctx, "Cannot send ONU2-G 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 | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1172 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1173 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1174 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1175 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1176 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1177 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1178 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1181 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 1182 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 1183 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1184 | tid := oo.GetNextTid(highPrio) |
| 1185 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1186 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1187 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1188 | |
| 1189 | meParams := me.ParamData{ |
| 1190 | EntityID: instID, |
| 1191 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1192 | me.MacBridgeServiceProfile_Priority: 0x8000, |
| 1193 | me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s |
| 1194 | me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s |
| 1195 | me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s |
| 1196 | me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1197 | }, |
| 1198 | } |
| 1199 | |
| 1200 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1201 | if omciErr.GetError() == nil { |
| 1202 | //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] | 1203 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1204 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1205 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1206 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1207 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1208 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1209 | } |
| 1210 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1211 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1212 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1213 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1214 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1215 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1218 | omciRxCallbackPair := CallbackPair{ |
| 1219 | CbKey: tid, |
| 1220 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1221 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1222 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1223 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1224 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1225 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1226 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1227 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1228 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1229 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1230 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1231 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1232 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1233 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1234 | } |
| 1235 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1236 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1237 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1238 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1239 | tid := oo.GetNextTid(highPrio) |
| 1240 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1241 | if idErr != nil { |
| 1242 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1243 | "Err": idErr, "device-id": oo.deviceID}) |
| 1244 | return nil, idErr |
| 1245 | } |
| 1246 | 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] | 1247 | "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] | 1248 | |
| 1249 | meParams := me.ParamData{ |
| 1250 | EntityID: instID, |
| 1251 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1252 | me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1253 | me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo, |
| 1254 | me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType), |
| 1255 | me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1256 | }, |
| 1257 | } |
| 1258 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1259 | if omciErr.GetError() == nil { |
| 1260 | //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] | 1261 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1262 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1263 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1264 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1265 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1266 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1267 | } |
| 1268 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1269 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1270 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1271 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1272 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1273 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1274 | } |
| 1275 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1276 | omciRxCallbackPair := CallbackPair{ |
| 1277 | CbKey: tid, |
| 1278 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1279 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1280 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1281 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1282 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1283 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1284 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1285 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1286 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1287 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1288 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1289 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1290 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1291 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1292 | } |
| 1293 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1294 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1295 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1296 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1297 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1298 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1299 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1300 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1301 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1302 | |
| 1303 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1304 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1305 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1306 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1307 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1308 | assType = uint8(10) // for VEIP |
| 1309 | } |
| 1310 | meParams := me.ParamData{ |
| 1311 | EntityID: instID, |
| 1312 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1313 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType, |
| 1314 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1315 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1316 | }, |
| 1317 | } |
| 1318 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1319 | if omciErr.GetError() == nil { |
| 1320 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1321 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1322 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1323 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1324 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1325 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1326 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1327 | } |
| 1328 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1329 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1330 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1331 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1332 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1333 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1334 | } |
| 1335 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1336 | omciRxCallbackPair := CallbackPair{ |
| 1337 | CbKey: tid, |
| 1338 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1339 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1340 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1341 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1342 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1343 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1344 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1345 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1346 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1347 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1348 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1349 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1350 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1351 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1352 | } |
| 1353 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1354 | // SendSetOnuGLS sets OnuG ME instance |
| 1355 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1356 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1357 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1358 | 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] | 1359 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1360 | |
| 1361 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1362 | meParams := me.ParamData{ |
| 1363 | EntityID: 0, |
| 1364 | Attributes: requestedAttributes, |
| 1365 | } |
| 1366 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1367 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1368 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1369 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1370 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1371 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1372 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1373 | } |
| 1374 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1375 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1376 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1377 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1378 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1379 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1380 | } |
| 1381 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1382 | omciRxCallbackPair := CallbackPair{ |
| 1383 | CbKey: tid, |
| 1384 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1385 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1386 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1387 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1388 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1389 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1390 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1391 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1392 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1393 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1394 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1395 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1396 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1397 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1398 | } |
| 1399 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1400 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1401 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1402 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1403 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1404 | 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] | 1405 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1406 | |
| 1407 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1408 | meParams := me.ParamData{ |
| 1409 | EntityID: aInstNo, |
| 1410 | Attributes: requestedAttributes, |
| 1411 | } |
| 1412 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1413 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1414 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1415 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1416 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1417 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1418 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1419 | } |
| 1420 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1421 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1422 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1423 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1424 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1425 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1426 | } |
| 1427 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1428 | omciRxCallbackPair := CallbackPair{ |
| 1429 | CbKey: tid, |
| 1430 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1431 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1432 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1433 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1434 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1435 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1436 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1437 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1438 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1439 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1440 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1441 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1442 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1443 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1444 | } |
| 1445 | |
| 1446 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1447 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1448 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1449 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1450 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1451 | 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] | 1452 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1453 | |
| 1454 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1455 | meParams := me.ParamData{ |
| 1456 | EntityID: aInstNo, |
| 1457 | Attributes: requestedAttributes, |
| 1458 | } |
| 1459 | meInstance, omciErr := me.NewUniG(meParams) |
| 1460 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1461 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1462 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1463 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1464 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1465 | return nil |
| 1466 | } |
| 1467 | |
| 1468 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1469 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1470 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1471 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1472 | return nil |
| 1473 | } |
| 1474 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1475 | omciRxCallbackPair := CallbackPair{ |
| 1476 | CbKey: tid, |
| 1477 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1478 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1479 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1480 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1481 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1482 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1483 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1484 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1485 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1486 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1487 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1488 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1489 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1490 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1491 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1492 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1493 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1494 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1495 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1496 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1497 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1498 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1499 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1500 | |
| 1501 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1502 | meParams := me.ParamData{ |
| 1503 | EntityID: aInstNo, |
| 1504 | Attributes: requestedAttributes, |
| 1505 | } |
| 1506 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1507 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1508 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1509 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1510 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1511 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1512 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1513 | } |
| 1514 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1515 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1516 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1517 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1518 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1519 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1520 | } |
| 1521 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1522 | omciRxCallbackPair := CallbackPair{ |
| 1523 | CbKey: tid, |
| 1524 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1525 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1526 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1527 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1528 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1529 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1530 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1531 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1532 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1533 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1534 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1535 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1536 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1537 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1538 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1539 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1540 | // SendGetMe gets ME instance |
| 1541 | func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1542 | timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1543 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1544 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1545 | 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] | 1546 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1547 | |
| 1548 | meParams := me.ParamData{ |
| 1549 | EntityID: entityID, |
| 1550 | Attributes: requestedAttributes, |
| 1551 | } |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1552 | var messageSet omci.DeviceIdent = omci.BaselineIdent |
| 1553 | if isExtendedOmci { |
| 1554 | messageSet = omci.ExtendedIdent |
| 1555 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1556 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1557 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1558 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1559 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid), oframe.FrameFormat(messageSet)) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1560 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1561 | 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] | 1562 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1563 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1564 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1565 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1566 | 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] | 1567 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1568 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1569 | omciRxCallbackPair := CallbackPair{ |
| 1570 | CbKey: tid, |
| 1571 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1572 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1573 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1574 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1575 | 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] | 1576 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1577 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1578 | 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] | 1579 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1580 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1581 | 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] | 1582 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1583 | } |
| 1584 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1585 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1586 | 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] | 1587 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1588 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1589 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1590 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1591 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1592 | |
| 1593 | request := &omci.GetRequest{ |
| 1594 | MeBasePacket: omci.MeBasePacket{ |
| 1595 | EntityInstance: entityID, |
| 1596 | EntityClass: classID, |
| 1597 | }, |
| 1598 | AttributeMask: requestedAttributesMask, |
| 1599 | } |
| 1600 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1601 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1602 | if err != nil { |
| 1603 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1604 | return err |
| 1605 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1606 | omciRxCallbackPair := CallbackPair{ |
| 1607 | CbKey: tid, |
| 1608 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1609 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1610 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1611 | if err != nil { |
| 1612 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1613 | return err |
| 1614 | } |
| 1615 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1616 | return nil |
| 1617 | } |
| 1618 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1619 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1620 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1621 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1622 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1623 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1624 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1625 | |
| 1626 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1627 | EntityID: aInstID, |
| 1628 | Attributes: me.AttributeValueMap{ |
| 1629 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1630 | me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF, |
| 1631 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF, |
| 1632 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF, |
| 1633 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF, |
| 1634 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF, |
| 1635 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF, |
| 1636 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF, |
| 1637 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF, |
| 1638 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF, |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1639 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1640 | } |
| 1641 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1642 | if omciErr.GetError() == nil { |
| 1643 | //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] | 1644 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1645 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1646 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1647 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1648 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1649 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1650 | } |
| 1651 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1652 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1653 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1654 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1655 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1656 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1657 | } |
| 1658 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1659 | omciRxCallbackPair := CallbackPair{ |
| 1660 | CbKey: tid, |
| 1661 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1662 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1663 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1664 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1665 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1666 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1667 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1668 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1669 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1670 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1671 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1672 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1673 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1674 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1675 | } |
| 1676 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1677 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1678 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1679 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1680 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1681 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1682 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1683 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1684 | |
| 1685 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1686 | if omciErr.GetError() == nil { |
| 1687 | //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] | 1688 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1689 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1690 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1691 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1692 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1693 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1694 | } |
| 1695 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1696 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1697 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1698 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1699 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1700 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1701 | } |
| 1702 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1703 | omciRxCallbackPair := CallbackPair{ |
| 1704 | CbKey: tid, |
| 1705 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1706 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1707 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1708 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1709 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1710 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1711 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1712 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1713 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1714 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1715 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1716 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1717 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1718 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1719 | } |
| 1720 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1721 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1722 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1723 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1724 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1725 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1726 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1727 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1728 | |
| 1729 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1730 | if omciErr.GetError() == nil { |
| 1731 | //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] | 1732 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1733 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1734 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1735 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1736 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1737 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1738 | } |
| 1739 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1740 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1741 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1742 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1743 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1744 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1745 | } |
| 1746 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1747 | omciRxCallbackPair := CallbackPair{ |
| 1748 | CbKey: tid, |
| 1749 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1750 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1751 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1752 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1753 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1754 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1755 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1756 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1757 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1758 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1759 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1760 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1761 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1762 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1763 | } |
| 1764 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1765 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1766 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1767 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1768 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1769 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1770 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1771 | |
| 1772 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1773 | if omciErr.GetError() == nil { |
| 1774 | //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] | 1775 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1776 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1777 | if err != nil { |
| 1778 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1779 | "Err": err, "device-id": oo.deviceID}) |
| 1780 | return nil, err |
| 1781 | } |
| 1782 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1783 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1784 | if err != nil { |
| 1785 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1786 | "Err": err, "device-id": oo.deviceID}) |
| 1787 | return nil, err |
| 1788 | } |
| 1789 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1790 | omciRxCallbackPair := CallbackPair{ |
| 1791 | CbKey: tid, |
| 1792 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1793 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1794 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1795 | if err != nil { |
| 1796 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1797 | "Err": err, "device-id": oo.deviceID}) |
| 1798 | return nil, err |
| 1799 | } |
| 1800 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1801 | return meInstance, nil |
| 1802 | } |
| 1803 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1804 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1805 | return nil, omciErr.GetError() |
| 1806 | } |
| 1807 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1808 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1809 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1810 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1811 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1812 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1813 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1814 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1815 | |
| 1816 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1817 | if omciErr.GetError() == nil { |
| 1818 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1819 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1820 | oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1821 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1822 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1823 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1824 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1825 | } |
| 1826 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1827 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1828 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1829 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1830 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1831 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1832 | } |
| 1833 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1834 | omciRxCallbackPair := CallbackPair{ |
| 1835 | CbKey: tid, |
| 1836 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1837 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1838 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1839 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1840 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1841 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1842 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1843 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1844 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1845 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1846 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1847 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1848 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1849 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1850 | } |
| 1851 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1852 | // SendSetTcontVar sets TCont ME instance |
| 1853 | func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1854 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1855 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1856 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1857 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1858 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1859 | |
| 1860 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1861 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1862 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1863 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1864 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1865 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1866 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1867 | } |
| 1868 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1869 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1870 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1871 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1872 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1873 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1874 | } |
| 1875 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1876 | omciRxCallbackPair := CallbackPair{ |
| 1877 | CbKey: tid, |
| 1878 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1879 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1880 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1881 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1882 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1883 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1884 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1885 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1886 | logger.Debug(ctx, "send TCont-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1887 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1888 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1889 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1890 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1891 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1892 | } |
| 1893 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1894 | // SendSetPrioQueueVar sets PriorityQueue ME instance |
| 1895 | func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1896 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1897 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1898 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1899 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1900 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1901 | |
| 1902 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1903 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1904 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1905 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1906 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1907 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1908 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1909 | } |
| 1910 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1911 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1912 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1913 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1914 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1915 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1916 | } |
| 1917 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1918 | omciRxCallbackPair := CallbackPair{ |
| 1919 | CbKey: tid, |
| 1920 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1921 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1922 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1923 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1924 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1925 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1926 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1927 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1928 | logger.Debug(ctx, "send PrioQueue-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1929 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1930 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1931 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1932 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1933 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1934 | } |
| 1935 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1936 | // SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance |
| 1937 | func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1938 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1939 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1940 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1941 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1942 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1943 | |
| 1944 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1945 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1946 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1947 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1948 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1949 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1950 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1951 | } |
| 1952 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1953 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1954 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1955 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1956 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1957 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1958 | } |
| 1959 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1960 | omciRxCallbackPair := CallbackPair{ |
| 1961 | CbKey: tid, |
| 1962 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1963 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1964 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1965 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1966 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1967 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1968 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1969 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1970 | logger.Debug(ctx, "send 1PMapper-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1971 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1972 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1973 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1974 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1975 | return nil, omciErr.GetError() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1976 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1977 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1978 | // SendCreateVtfdVar creates VlanTaggingFilterData ME instance |
| 1979 | func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1980 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1981 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1982 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1983 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1984 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1985 | |
| 1986 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1987 | if omciErr.GetError() == nil { |
| 1988 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1989 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1990 | oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1991 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1992 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1993 | "Err": err, "device-id": oo.deviceID}) |
| 1994 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1995 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1996 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1997 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1998 | } |
| 1999 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2000 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2001 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2002 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2003 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2004 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2005 | } |
| 2006 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2007 | omciRxCallbackPair := CallbackPair{ |
| 2008 | CbKey: tid, |
| 2009 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2010 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2011 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2012 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2013 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2014 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2015 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2016 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2017 | logger.Debug(ctx, "send VTFD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2018 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2019 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2020 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2021 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2022 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2023 | } |
| 2024 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2025 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2026 | func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2027 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2028 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2029 | 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] | 2030 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2031 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2032 | |
| 2033 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 2034 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2035 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 2036 | oframe.TransactionID(tid)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2037 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2038 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2039 | "Err": err, "device-id": oo.deviceID}) |
| 2040 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2041 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2042 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2043 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2044 | } |
| 2045 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2046 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2047 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2048 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2049 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2050 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2051 | } |
| 2052 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2053 | omciRxCallbackPair := CallbackPair{ |
| 2054 | CbKey: tid, |
| 2055 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2056 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2057 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2058 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2059 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2060 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2061 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2062 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2063 | logger.Debug(ctx, "send VTFD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2064 | return meInstance, nil |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2065 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2066 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2067 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2068 | return nil, omciErr.GetError() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2069 | } |
| 2070 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2071 | // SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2072 | func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2073 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2074 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2075 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2076 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2077 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2078 | |
| 2079 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2080 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2081 | //EnhancedMode not yet supported, used with default options |
| 2082 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 2083 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2084 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2085 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2086 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2087 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2088 | } |
| 2089 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2090 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2091 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2092 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2093 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2094 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2095 | } |
| 2096 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2097 | omciRxCallbackPair := CallbackPair{ |
| 2098 | CbKey: tid, |
| 2099 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2100 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2101 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2102 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2103 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2104 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2105 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2106 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2107 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2108 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2109 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2110 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2111 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2112 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2113 | } |
| 2114 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2115 | // SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2116 | func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2117 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2118 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2119 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2120 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2121 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2122 | |
| 2123 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2124 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2125 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2126 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2127 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2128 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2129 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2130 | } |
| 2131 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2132 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2133 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2134 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2135 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2136 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2137 | } |
| 2138 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2139 | omciRxCallbackPair := CallbackPair{ |
| 2140 | CbKey: tid, |
| 2141 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2142 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2143 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2144 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2145 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2146 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2147 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2148 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2149 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2150 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2151 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2152 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2153 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2154 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2155 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2156 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2157 | // SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2158 | func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2159 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2160 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2161 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2162 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2163 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2164 | |
| 2165 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2166 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2167 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2168 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2169 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2170 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2171 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2172 | } |
| 2173 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2174 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2175 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2176 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2177 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2178 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2179 | } |
| 2180 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2181 | omciRxCallbackPair := CallbackPair{ |
| 2182 | CbKey: tid, |
| 2183 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2184 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2185 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2186 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2187 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2188 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2189 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2190 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2191 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2192 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2193 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2194 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2195 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2196 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2197 | } |
| 2198 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2199 | // SendDeleteVtfd deletes VlanTaggingFilterData ME instance |
| 2200 | func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2201 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2202 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2203 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2204 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2205 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2206 | |
| 2207 | meParams := me.ParamData{EntityID: aInstID} |
| 2208 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 2209 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2210 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2211 | oframe.TransactionID(tid)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2212 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2213 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2214 | "Err": err, "device-id": oo.deviceID}) |
| 2215 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2216 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2217 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2218 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2219 | } |
| 2220 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2221 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2222 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2223 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2224 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2225 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2226 | } |
| 2227 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2228 | omciRxCallbackPair := CallbackPair{ |
| 2229 | CbKey: tid, |
| 2230 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2231 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2232 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2233 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2234 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2235 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2236 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2237 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2238 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2239 | return meInstance, nil |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2240 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2241 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2242 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2243 | return nil, omciErr.GetError() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2244 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2245 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2246 | // SendCreateTDVar creates TrafficDescriptor ME instance |
| 2247 | func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2248 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2249 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2250 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2251 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2252 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2253 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2254 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2255 | if err != nil { |
| 2256 | 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] | 2257 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2258 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2259 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2260 | if err != nil { |
| 2261 | 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] | 2262 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2263 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2264 | omciRxCallbackPair := CallbackPair{ |
| 2265 | CbKey: tid, |
| 2266 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2267 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2268 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2269 | if err != nil { |
| 2270 | 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] | 2271 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2272 | } |
| 2273 | logger.Debug(ctx, "send TD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2274 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2275 | } |
| 2276 | 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] | 2277 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2278 | } |
| 2279 | |
| 2280 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2281 | func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2282 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2283 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2284 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2285 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2286 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2287 | |
| 2288 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2289 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2290 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2291 | if err != nil { |
| 2292 | 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] | 2293 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2294 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2295 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2296 | if err != nil { |
| 2297 | 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] | 2298 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2299 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2300 | omciRxCallbackPair := CallbackPair{ |
| 2301 | CbKey: tid, |
| 2302 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2303 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2304 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2305 | if err != nil { |
| 2306 | 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] | 2307 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2308 | } |
| 2309 | logger.Debug(ctx, "send TD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2310 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2311 | } |
| 2312 | 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] | 2313 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2314 | |
| 2315 | } |
| 2316 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2317 | // SendDeleteTD - TODO: add comment |
| 2318 | func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2319 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2320 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2321 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2322 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2323 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2324 | |
| 2325 | meParams := me.ParamData{EntityID: aInstID} |
| 2326 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 2327 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2328 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2329 | if err != nil { |
| 2330 | 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] | 2331 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2332 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2333 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2334 | if err != nil { |
| 2335 | 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] | 2336 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2337 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2338 | omciRxCallbackPair := CallbackPair{ |
| 2339 | CbKey: tid, |
| 2340 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2341 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2342 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2343 | if err != nil { |
| 2344 | 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] | 2345 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2346 | } |
| 2347 | logger.Debug(ctx, "send TD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2348 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2349 | } |
| 2350 | 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] | 2351 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2352 | |
| 2353 | } |
| 2354 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2355 | // SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance |
| 2356 | func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2357 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2358 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2359 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2360 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2361 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2362 | |
| 2363 | meParams := me.ParamData{EntityID: aInstID} |
| 2364 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2365 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2366 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2367 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2368 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2369 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2370 | "Err": err, "device-id": oo.deviceID}) |
| 2371 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2372 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2373 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2374 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2375 | } |
| 2376 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2377 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2378 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2379 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2380 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2381 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2382 | } |
| 2383 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2384 | omciRxCallbackPair := CallbackPair{ |
| 2385 | CbKey: tid, |
| 2386 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2387 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2388 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2389 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2390 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2391 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2392 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2393 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2394 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2395 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2396 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2397 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2398 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2399 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2400 | } |
| 2401 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2402 | // SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance |
| 2403 | func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2404 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2405 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2406 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2407 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2408 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2409 | |
| 2410 | meParams := me.ParamData{EntityID: aInstID} |
| 2411 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2412 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2413 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2414 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2415 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2416 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2417 | "Err": err, "device-id": oo.deviceID}) |
| 2418 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2419 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2420 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2421 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2422 | } |
| 2423 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2424 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2425 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2426 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2427 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2428 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2429 | } |
| 2430 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2431 | omciRxCallbackPair := CallbackPair{ |
| 2432 | CbKey: tid, |
| 2433 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2434 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2435 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2436 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2437 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2438 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2439 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2440 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2441 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2442 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2443 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2444 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2445 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2446 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2447 | } |
| 2448 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2449 | // SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance |
| 2450 | func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2451 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2452 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2453 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2454 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2455 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2456 | |
| 2457 | meParams := me.ParamData{EntityID: aInstID} |
| 2458 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2459 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2460 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2461 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2462 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2463 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2464 | "Err": err, "device-id": oo.deviceID}) |
| 2465 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2466 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2467 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2468 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2469 | } |
| 2470 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2471 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2472 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2473 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2474 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2475 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2476 | } |
| 2477 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2478 | omciRxCallbackPair := CallbackPair{ |
| 2479 | CbKey: tid, |
| 2480 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2481 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2482 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2483 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2484 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2485 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2486 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2487 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2488 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2489 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2490 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2491 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2492 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2493 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2494 | } |
| 2495 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2496 | // SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance |
| 2497 | func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2498 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2499 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2500 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2501 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2502 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2503 | |
| 2504 | meParams := me.ParamData{EntityID: aInstID} |
| 2505 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2506 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2507 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2508 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2509 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2510 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2511 | "Err": err, "device-id": oo.deviceID}) |
| 2512 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2513 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2514 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2515 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2516 | } |
| 2517 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2518 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2519 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2520 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2521 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2522 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2523 | } |
| 2524 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2525 | omciRxCallbackPair := CallbackPair{ |
| 2526 | CbKey: tid, |
| 2527 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2528 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2529 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2530 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2531 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2532 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2533 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2534 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2535 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2536 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2537 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2538 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2539 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2540 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2541 | } |
| 2542 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2543 | // SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance |
| 2544 | func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2545 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2546 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2547 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2548 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2549 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2550 | |
| 2551 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2552 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2553 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2554 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2555 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2556 | 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] | 2557 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2558 | } |
| 2559 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2560 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2561 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2562 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2563 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2564 | } |
| 2565 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2566 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2567 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2568 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2569 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2570 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2571 | 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] | 2572 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2573 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2574 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2575 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2576 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2577 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2578 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2579 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2580 | } |
| 2581 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2582 | // SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance |
| 2583 | func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2584 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2585 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2586 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2587 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2588 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2589 | |
| 2590 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2591 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2592 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2593 | oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2594 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2595 | 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] | 2596 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2597 | } |
| 2598 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2599 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2600 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2601 | 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] | 2602 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2603 | } |
| 2604 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2605 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2606 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2607 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2608 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2609 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2610 | 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] | 2611 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2612 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2613 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2614 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2615 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2616 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2617 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2618 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2619 | } |
| 2620 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2621 | // SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance |
| 2622 | func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2623 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2624 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2625 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2626 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2627 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2628 | |
| 2629 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2630 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2631 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2632 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2633 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2634 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2635 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2636 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2637 | } |
| 2638 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2639 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2640 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2641 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2642 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2643 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2644 | } |
| 2645 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2646 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2647 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2648 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2649 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2650 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2651 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2652 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2653 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2654 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2655 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2656 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2657 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2658 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2659 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2660 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2661 | } |
| 2662 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2663 | // SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance |
| 2664 | func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2665 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2666 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2667 | logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2668 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2669 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2670 | |
| 2671 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2672 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2673 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2674 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2675 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2676 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2677 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2678 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2679 | } |
| 2680 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2681 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2682 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2683 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2684 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2685 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2686 | } |
| 2687 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2688 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2689 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2690 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2691 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2692 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2693 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2694 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2695 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2696 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2697 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2698 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2699 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2700 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2701 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2702 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2703 | } |
| 2704 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2705 | // SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance |
| 2706 | func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2707 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2708 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2709 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2710 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2711 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2712 | |
| 2713 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2714 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2715 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2716 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2717 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2718 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2719 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2720 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2721 | } |
| 2722 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2723 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2724 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2725 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2726 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2727 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2728 | } |
| 2729 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2730 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2731 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2732 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2733 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2734 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2735 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2736 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2737 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2738 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2739 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2740 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2741 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2742 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2743 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2744 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2745 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2746 | |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2747 | // SendCreateVoipVoiceCTP nolint: unused |
| 2748 | func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2749 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2750 | tid := oo.GetNextTid(highPrio) |
| 2751 | logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2752 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2753 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2754 | |
| 2755 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2756 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2757 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2758 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2759 | if err != nil { |
| 2760 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err, |
| 2761 | "device-id": oo.deviceID}) |
| 2762 | return nil, err |
| 2763 | } |
| 2764 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2765 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2766 | if err != nil { |
| 2767 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err, |
| 2768 | "device-id": oo.deviceID}) |
| 2769 | return nil, err |
| 2770 | } |
| 2771 | |
| 2772 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2773 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2774 | } |
| 2775 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2776 | if err != nil { |
| 2777 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err, |
| 2778 | "device-id": oo.deviceID}) |
| 2779 | return nil, err |
| 2780 | } |
| 2781 | logger.Debug(ctx, "send VoipVoiceCTP-create-msg done") |
| 2782 | return meInstance, nil |
| 2783 | } |
| 2784 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2785 | "device-id": oo.deviceID}) |
| 2786 | return nil, omciErr.GetError() |
| 2787 | } |
| 2788 | |
| 2789 | // SendSetVoipVoiceCTP nolint: unused |
| 2790 | func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2791 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2792 | tid := oo.GetNextTid(highPrio) |
| 2793 | logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2794 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2795 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2796 | |
| 2797 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2798 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2799 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2800 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2801 | if err != nil { |
| 2802 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err, |
| 2803 | "device-id": oo.deviceID}) |
| 2804 | return nil, err |
| 2805 | } |
| 2806 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2807 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2808 | if err != nil { |
| 2809 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err, |
| 2810 | "device-id": oo.deviceID}) |
| 2811 | return nil, err |
| 2812 | } |
| 2813 | |
| 2814 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2815 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2816 | } |
| 2817 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2818 | if err != nil { |
| 2819 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err, |
| 2820 | "device-id": oo.deviceID}) |
| 2821 | return nil, err |
| 2822 | } |
| 2823 | logger.Debug(ctx, "send VoipVoiceCTP-set-msg done") |
| 2824 | return meInstance, nil |
| 2825 | } |
| 2826 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2827 | "device-id": oo.deviceID}) |
| 2828 | return nil, omciErr.GetError() |
| 2829 | } |
| 2830 | |
| 2831 | // SendDeleteVoipVoiceCTP nolint: unused |
| 2832 | func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2833 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2834 | tid := oo.GetNextTid(highPrio) |
| 2835 | logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2836 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2837 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2838 | |
| 2839 | meParams := me.ParamData{EntityID: aInstID} |
| 2840 | meInstance, omciErr := me.NewVoipVoiceCtp(meParams) |
| 2841 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2842 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2843 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2844 | if err != nil { |
| 2845 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{ |
| 2846 | "Err": err, "device-id": oo.deviceID}) |
| 2847 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2848 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2849 | // (relevant to all used sendXX() methods and their error conditions) |
| 2850 | return nil, err |
| 2851 | } |
| 2852 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2853 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2854 | if err != nil { |
| 2855 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{ |
| 2856 | "Err": err, "device-id": oo.deviceID}) |
| 2857 | return nil, err |
| 2858 | } |
| 2859 | |
| 2860 | omciRxCallbackPair := CallbackPair{ |
| 2861 | CbKey: tid, |
| 2862 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2863 | } |
| 2864 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2865 | if err != nil { |
| 2866 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{ |
| 2867 | "Err": err, "device-id": oo.deviceID}) |
| 2868 | return nil, err |
| 2869 | } |
| 2870 | logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done") |
| 2871 | return meInstance, nil |
| 2872 | } |
| 2873 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{ |
| 2874 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2875 | return nil, omciErr.GetError() |
| 2876 | } |
| 2877 | |
| 2878 | // SendCreateVoipMediaProfile nolint: unused |
| 2879 | func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2880 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2881 | tid := oo.GetNextTid(highPrio) |
| 2882 | logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2883 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2884 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2885 | |
| 2886 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2887 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2888 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2889 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2890 | if err != nil { |
| 2891 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err, |
| 2892 | "device-id": oo.deviceID}) |
| 2893 | return nil, err |
| 2894 | } |
| 2895 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2896 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2897 | if err != nil { |
| 2898 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err, |
| 2899 | "device-id": oo.deviceID}) |
| 2900 | return nil, err |
| 2901 | } |
| 2902 | |
| 2903 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2904 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2905 | } |
| 2906 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2907 | if err != nil { |
| 2908 | logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err, |
| 2909 | "device-id": oo.deviceID}) |
| 2910 | return nil, err |
| 2911 | } |
| 2912 | logger.Debug(ctx, "send VoipMediaProfile-create-msg done") |
| 2913 | return meInstance, nil |
| 2914 | } |
| 2915 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2916 | "device-id": oo.deviceID}) |
| 2917 | return nil, omciErr.GetError() |
| 2918 | } |
| 2919 | |
| 2920 | // SendSetVoipMediaProfile nolint: unused |
| 2921 | func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2922 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2923 | tid := oo.GetNextTid(highPrio) |
| 2924 | logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2925 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2926 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2927 | |
| 2928 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2929 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2930 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2931 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2932 | if err != nil { |
| 2933 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err, |
| 2934 | "device-id": oo.deviceID}) |
| 2935 | return nil, err |
| 2936 | } |
| 2937 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2938 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2939 | if err != nil { |
| 2940 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err, |
| 2941 | "device-id": oo.deviceID}) |
| 2942 | return nil, err |
| 2943 | } |
| 2944 | |
| 2945 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2946 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2947 | } |
| 2948 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2949 | if err != nil { |
| 2950 | logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err, |
| 2951 | "device-id": oo.deviceID}) |
| 2952 | return nil, err |
| 2953 | } |
| 2954 | logger.Debug(ctx, "send VoipMediaProfile-set-msg done") |
| 2955 | return meInstance, nil |
| 2956 | } |
| 2957 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2958 | "device-id": oo.deviceID}) |
| 2959 | return nil, omciErr.GetError() |
| 2960 | } |
| 2961 | |
| 2962 | // SendDeleteVoipMediaProfile nolint: unused |
| 2963 | func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2964 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2965 | tid := oo.GetNextTid(highPrio) |
| 2966 | logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2967 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2968 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2969 | |
| 2970 | meParams := me.ParamData{EntityID: aInstID} |
| 2971 | meInstance, omciErr := me.NewVoipMediaProfile(meParams) |
| 2972 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2973 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2974 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2975 | if err != nil { |
| 2976 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{ |
| 2977 | "Err": err, "device-id": oo.deviceID}) |
| 2978 | return nil, err |
| 2979 | } |
| 2980 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2981 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2982 | if err != nil { |
| 2983 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{ |
| 2984 | "Err": err, "device-id": oo.deviceID}) |
| 2985 | return nil, err |
| 2986 | } |
| 2987 | |
| 2988 | omciRxCallbackPair := CallbackPair{ |
| 2989 | CbKey: tid, |
| 2990 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2991 | } |
| 2992 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2993 | if err != nil { |
| 2994 | logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{ |
| 2995 | "Err": err, "device-id": oo.deviceID}) |
| 2996 | return nil, err |
| 2997 | } |
| 2998 | logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done") |
| 2999 | return meInstance, nil |
| 3000 | } |
| 3001 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{ |
| 3002 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3003 | return nil, omciErr.GetError() |
| 3004 | } |
| 3005 | |
| 3006 | // SendCreateVoiceServiceProfile nolint: unused |
| 3007 | func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3008 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3009 | tid := oo.GetNextTid(highPrio) |
| 3010 | logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3011 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3012 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3013 | |
| 3014 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 3015 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3016 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3017 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3018 | if err != nil { |
| 3019 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err, |
| 3020 | "device-id": oo.deviceID}) |
| 3021 | return nil, err |
| 3022 | } |
| 3023 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3024 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3025 | if err != nil { |
| 3026 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err, |
| 3027 | "device-id": oo.deviceID}) |
| 3028 | return nil, err |
| 3029 | } |
| 3030 | |
| 3031 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3032 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3033 | } |
| 3034 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3035 | if err != nil { |
| 3036 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err, |
| 3037 | "device-id": oo.deviceID}) |
| 3038 | return nil, err |
| 3039 | } |
| 3040 | logger.Debug(ctx, "send VoiceServiceProfile-create-msg done") |
| 3041 | return meInstance, nil |
| 3042 | } |
| 3043 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3044 | "device-id": oo.deviceID}) |
| 3045 | return nil, omciErr.GetError() |
| 3046 | } |
| 3047 | |
| 3048 | // SendSetVoiceServiceProfile nolint: unused |
| 3049 | func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3050 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3051 | tid := oo.GetNextTid(highPrio) |
| 3052 | logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3053 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3054 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3055 | |
| 3056 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 3057 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3058 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3059 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3060 | if err != nil { |
| 3061 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err, |
| 3062 | "device-id": oo.deviceID}) |
| 3063 | return nil, err |
| 3064 | } |
| 3065 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3066 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3067 | if err != nil { |
| 3068 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err, |
| 3069 | "device-id": oo.deviceID}) |
| 3070 | return nil, err |
| 3071 | } |
| 3072 | |
| 3073 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3074 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3075 | } |
| 3076 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3077 | if err != nil { |
| 3078 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err, |
| 3079 | "device-id": oo.deviceID}) |
| 3080 | return nil, err |
| 3081 | } |
| 3082 | logger.Debug(ctx, "send VoiceServiceProfile-set-msg done") |
| 3083 | return meInstance, nil |
| 3084 | } |
| 3085 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3086 | "device-id": oo.deviceID}) |
| 3087 | return nil, omciErr.GetError() |
| 3088 | } |
| 3089 | |
| 3090 | // SendDeleteVoiceServiceProfile nolint: unused |
| 3091 | func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3092 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3093 | tid := oo.GetNextTid(highPrio) |
| 3094 | logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3095 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3096 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3097 | |
| 3098 | meParams := me.ParamData{EntityID: aInstID} |
| 3099 | meInstance, omciErr := me.NewVoiceServiceProfile(meParams) |
| 3100 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3101 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3102 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3103 | if err != nil { |
| 3104 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{ |
| 3105 | "Err": err, "device-id": oo.deviceID}) |
| 3106 | return nil, err |
| 3107 | } |
| 3108 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3109 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3110 | if err != nil { |
| 3111 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{ |
| 3112 | "Err": err, "device-id": oo.deviceID}) |
| 3113 | return nil, err |
| 3114 | } |
| 3115 | |
| 3116 | omciRxCallbackPair := CallbackPair{ |
| 3117 | CbKey: tid, |
| 3118 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3119 | } |
| 3120 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3121 | if err != nil { |
| 3122 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{ |
| 3123 | "Err": err, "device-id": oo.deviceID}) |
| 3124 | return nil, err |
| 3125 | } |
| 3126 | logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done") |
| 3127 | return meInstance, nil |
| 3128 | } |
| 3129 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{ |
| 3130 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3131 | return nil, omciErr.GetError() |
| 3132 | } |
| 3133 | |
| 3134 | // SendCreateSIPUserData nolint: unused |
| 3135 | func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3136 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3137 | tid := oo.GetNextTid(highPrio) |
| 3138 | logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3139 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3140 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3141 | |
| 3142 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3143 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3144 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3145 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3146 | if err != nil { |
| 3147 | logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err, |
| 3148 | "device-id": oo.deviceID}) |
| 3149 | return nil, err |
| 3150 | } |
| 3151 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3152 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3153 | if err != nil { |
| 3154 | logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err, |
| 3155 | "device-id": oo.deviceID}) |
| 3156 | return nil, err |
| 3157 | } |
| 3158 | |
| 3159 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3160 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3161 | } |
| 3162 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3163 | if err != nil { |
| 3164 | logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err, |
| 3165 | "device-id": oo.deviceID}) |
| 3166 | return nil, err |
| 3167 | } |
| 3168 | logger.Debug(ctx, "send SIPUserData-create-msg done") |
| 3169 | return meInstance, nil |
| 3170 | } |
| 3171 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3172 | "device-id": oo.deviceID}) |
| 3173 | return nil, omciErr.GetError() |
| 3174 | } |
| 3175 | |
| 3176 | // SendSetSIPUserData nolint: unused |
| 3177 | func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3178 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3179 | tid := oo.GetNextTid(highPrio) |
| 3180 | logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3181 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3182 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3183 | |
| 3184 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3185 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3186 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3187 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3188 | if err != nil { |
| 3189 | logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err, |
| 3190 | "device-id": oo.deviceID}) |
| 3191 | return nil, err |
| 3192 | } |
| 3193 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3194 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3195 | if err != nil { |
| 3196 | logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err, |
| 3197 | "device-id": oo.deviceID}) |
| 3198 | return nil, err |
| 3199 | } |
| 3200 | |
| 3201 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3202 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3203 | } |
| 3204 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3205 | if err != nil { |
| 3206 | logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err, |
| 3207 | "device-id": oo.deviceID}) |
| 3208 | return nil, err |
| 3209 | } |
| 3210 | logger.Debug(ctx, "send SIPUserData-set-msg done") |
| 3211 | return meInstance, nil |
| 3212 | } |
| 3213 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3214 | "device-id": oo.deviceID}) |
| 3215 | return nil, omciErr.GetError() |
| 3216 | } |
| 3217 | |
| 3218 | // SendDeleteSIPUserData nolint: unused |
| 3219 | func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3220 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3221 | tid := oo.GetNextTid(highPrio) |
| 3222 | logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3223 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3224 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3225 | |
| 3226 | meParams := me.ParamData{EntityID: aInstID} |
| 3227 | meInstance, omciErr := me.NewSipUserData(meParams) |
| 3228 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3229 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3230 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3231 | if err != nil { |
| 3232 | logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{ |
| 3233 | "Err": err, "device-id": oo.deviceID}) |
| 3234 | return nil, err |
| 3235 | } |
| 3236 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3237 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3238 | if err != nil { |
| 3239 | logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{ |
| 3240 | "Err": err, "device-id": oo.deviceID}) |
| 3241 | return nil, err |
| 3242 | } |
| 3243 | |
| 3244 | omciRxCallbackPair := CallbackPair{ |
| 3245 | CbKey: tid, |
| 3246 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3247 | } |
| 3248 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3249 | if err != nil { |
| 3250 | logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{ |
| 3251 | "Err": err, "device-id": oo.deviceID}) |
| 3252 | return nil, err |
| 3253 | } |
| 3254 | logger.Debug(ctx, "send SIPUserData-Delete-msg done") |
| 3255 | return meInstance, nil |
| 3256 | } |
| 3257 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{ |
| 3258 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3259 | return nil, omciErr.GetError() |
| 3260 | } |
| 3261 | |
| 3262 | // SendCreateVoipApplicationServiceProfile nolint: unused |
| 3263 | func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3264 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3265 | tid := oo.GetNextTid(highPrio) |
| 3266 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3267 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3268 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3269 | |
| 3270 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3271 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3272 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3273 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3274 | if err != nil { |
| 3275 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err, |
| 3276 | "device-id": oo.deviceID}) |
| 3277 | return nil, err |
| 3278 | } |
| 3279 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3280 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3281 | if err != nil { |
| 3282 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3283 | "device-id": oo.deviceID}) |
| 3284 | return nil, err |
| 3285 | } |
| 3286 | |
| 3287 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3288 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3289 | } |
| 3290 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3291 | if err != nil { |
| 3292 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3293 | "device-id": oo.deviceID}) |
| 3294 | return nil, err |
| 3295 | } |
| 3296 | logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done") |
| 3297 | return meInstance, nil |
| 3298 | } |
| 3299 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3300 | "device-id": oo.deviceID}) |
| 3301 | return nil, omciErr.GetError() |
| 3302 | } |
| 3303 | |
| 3304 | // SendSetVoipApplicationServiceProfile nolint: unused |
| 3305 | func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3306 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3307 | tid := oo.GetNextTid(highPrio) |
| 3308 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3309 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3310 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3311 | |
| 3312 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3313 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3314 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3315 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3316 | if err != nil { |
| 3317 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err, |
| 3318 | "device-id": oo.deviceID}) |
| 3319 | return nil, err |
| 3320 | } |
| 3321 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3322 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3323 | if err != nil { |
| 3324 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3325 | "device-id": oo.deviceID}) |
| 3326 | return nil, err |
| 3327 | } |
| 3328 | |
| 3329 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3330 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3331 | } |
| 3332 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3333 | if err != nil { |
| 3334 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3335 | "device-id": oo.deviceID}) |
| 3336 | return nil, err |
| 3337 | } |
| 3338 | logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done") |
| 3339 | return meInstance, nil |
| 3340 | } |
| 3341 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3342 | "device-id": oo.deviceID}) |
| 3343 | return nil, omciErr.GetError() |
| 3344 | } |
| 3345 | |
| 3346 | // SendDeleteVoipApplicationServiceProfile nolint: unused |
| 3347 | func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3348 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3349 | tid := oo.GetNextTid(highPrio) |
| 3350 | logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3351 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3352 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3353 | |
| 3354 | meParams := me.ParamData{EntityID: aInstID} |
| 3355 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams) |
| 3356 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3357 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3358 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3359 | if err != nil { |
| 3360 | logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{ |
| 3361 | "Err": err, "device-id": oo.deviceID}) |
| 3362 | return nil, err |
| 3363 | } |
| 3364 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3365 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3366 | if err != nil { |
| 3367 | logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3368 | "Err": err, "device-id": oo.deviceID}) |
| 3369 | return nil, err |
| 3370 | } |
| 3371 | |
| 3372 | omciRxCallbackPair := CallbackPair{ |
| 3373 | CbKey: tid, |
| 3374 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3375 | } |
| 3376 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3377 | if err != nil { |
| 3378 | logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3379 | "Err": err, "device-id": oo.deviceID}) |
| 3380 | return nil, err |
| 3381 | } |
| 3382 | logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done") |
| 3383 | return meInstance, nil |
| 3384 | } |
| 3385 | logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{ |
| 3386 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3387 | return nil, omciErr.GetError() |
| 3388 | } |
| 3389 | |
| 3390 | // SendCreateSIPAgentConfigData nolint: unused |
| 3391 | func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3392 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3393 | tid := oo.GetNextTid(highPrio) |
| 3394 | logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3395 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3396 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3397 | |
| 3398 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3399 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3400 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3401 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3402 | if err != nil { |
| 3403 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err, |
| 3404 | "device-id": oo.deviceID}) |
| 3405 | return nil, err |
| 3406 | } |
| 3407 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3408 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3409 | if err != nil { |
| 3410 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err, |
| 3411 | "device-id": oo.deviceID}) |
| 3412 | return nil, err |
| 3413 | } |
| 3414 | |
| 3415 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3416 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3417 | } |
| 3418 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3419 | if err != nil { |
| 3420 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err, |
| 3421 | "device-id": oo.deviceID}) |
| 3422 | return nil, err |
| 3423 | } |
| 3424 | logger.Debug(ctx, "send SIPAgentConfigData-create-msg done") |
| 3425 | return meInstance, nil |
| 3426 | } |
| 3427 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3428 | "device-id": oo.deviceID}) |
| 3429 | return nil, omciErr.GetError() |
| 3430 | } |
| 3431 | |
| 3432 | // SendSetSIPAgentConfigData nolint: unused |
| 3433 | func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3434 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3435 | tid := oo.GetNextTid(highPrio) |
| 3436 | logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3437 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3438 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3439 | |
| 3440 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3441 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3442 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3443 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3444 | if err != nil { |
| 3445 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err, |
| 3446 | "device-id": oo.deviceID}) |
| 3447 | return nil, err |
| 3448 | } |
| 3449 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3450 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3451 | if err != nil { |
| 3452 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err, |
| 3453 | "device-id": oo.deviceID}) |
| 3454 | return nil, err |
| 3455 | } |
| 3456 | |
| 3457 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3458 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3459 | } |
| 3460 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3461 | if err != nil { |
| 3462 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err, |
| 3463 | "device-id": oo.deviceID}) |
| 3464 | return nil, err |
| 3465 | } |
| 3466 | logger.Debug(ctx, "send SIPAgentConfigData-set-msg done") |
| 3467 | return meInstance, nil |
| 3468 | } |
| 3469 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3470 | "device-id": oo.deviceID}) |
| 3471 | return nil, omciErr.GetError() |
| 3472 | } |
| 3473 | |
| 3474 | // SendDeleteSIPAgentConfigData nolint: unused |
| 3475 | func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3476 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3477 | tid := oo.GetNextTid(highPrio) |
| 3478 | logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3479 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3480 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3481 | |
| 3482 | meParams := me.ParamData{EntityID: aInstID} |
| 3483 | meInstance, omciErr := me.NewSipAgentConfigData(meParams) |
| 3484 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3485 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3486 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3487 | if err != nil { |
| 3488 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{ |
| 3489 | "Err": err, "device-id": oo.deviceID}) |
| 3490 | return nil, err |
| 3491 | } |
| 3492 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3493 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3494 | if err != nil { |
| 3495 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{ |
| 3496 | "Err": err, "device-id": oo.deviceID}) |
| 3497 | return nil, err |
| 3498 | } |
| 3499 | |
| 3500 | omciRxCallbackPair := CallbackPair{ |
| 3501 | CbKey: tid, |
| 3502 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3503 | } |
| 3504 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3505 | if err != nil { |
| 3506 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{ |
| 3507 | "Err": err, "device-id": oo.deviceID}) |
| 3508 | return nil, err |
| 3509 | } |
| 3510 | logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done") |
| 3511 | return meInstance, nil |
| 3512 | } |
| 3513 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3514 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3515 | return nil, omciErr.GetError() |
| 3516 | } |
| 3517 | |
| 3518 | // SendCreateTCPUDPConfigData nolint: unused |
| 3519 | func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3520 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3521 | tid := oo.GetNextTid(highPrio) |
| 3522 | logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3523 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3524 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3525 | |
| 3526 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3527 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3528 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3529 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3530 | if err != nil { |
| 3531 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err, |
| 3532 | "device-id": oo.deviceID}) |
| 3533 | return nil, err |
| 3534 | } |
| 3535 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3536 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3537 | if err != nil { |
| 3538 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err, |
| 3539 | "device-id": oo.deviceID}) |
| 3540 | return nil, err |
| 3541 | } |
| 3542 | |
| 3543 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3544 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3545 | } |
| 3546 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3547 | if err != nil { |
| 3548 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err, |
| 3549 | "device-id": oo.deviceID}) |
| 3550 | return nil, err |
| 3551 | } |
| 3552 | logger.Debug(ctx, "send TCPUDPConfigData-create-msg done") |
| 3553 | return meInstance, nil |
| 3554 | } |
| 3555 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3556 | "device-id": oo.deviceID}) |
| 3557 | return nil, omciErr.GetError() |
| 3558 | } |
| 3559 | |
| 3560 | // SendSetTCPUDPConfigData nolint: unused |
| 3561 | func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3562 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3563 | tid := oo.GetNextTid(highPrio) |
| 3564 | logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3565 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3566 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3567 | |
| 3568 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3569 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3570 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3571 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3572 | if err != nil { |
| 3573 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err, |
| 3574 | "device-id": oo.deviceID}) |
| 3575 | return nil, err |
| 3576 | } |
| 3577 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3578 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3579 | if err != nil { |
| 3580 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err, |
| 3581 | "device-id": oo.deviceID}) |
| 3582 | return nil, err |
| 3583 | } |
| 3584 | |
| 3585 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3586 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3587 | } |
| 3588 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3589 | if err != nil { |
| 3590 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err, |
| 3591 | "device-id": oo.deviceID}) |
| 3592 | return nil, err |
| 3593 | } |
| 3594 | logger.Debug(ctx, "send TCPUDPConfigData-set-msg done") |
| 3595 | return meInstance, nil |
| 3596 | } |
| 3597 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3598 | "device-id": oo.deviceID}) |
| 3599 | return nil, omciErr.GetError() |
| 3600 | } |
| 3601 | |
| 3602 | // SendDeleteTCPUDPConfigData nolint: unused |
| 3603 | func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3604 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3605 | tid := oo.GetNextTid(highPrio) |
| 3606 | logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3607 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3608 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3609 | |
| 3610 | meParams := me.ParamData{EntityID: aInstID} |
| 3611 | meInstance, omciErr := me.NewTcpUdpConfigData(meParams) |
| 3612 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3613 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3614 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3615 | if err != nil { |
| 3616 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{ |
| 3617 | "Err": err, "device-id": oo.deviceID}) |
| 3618 | return nil, err |
| 3619 | } |
| 3620 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3621 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3622 | if err != nil { |
| 3623 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{ |
| 3624 | "Err": err, "device-id": oo.deviceID}) |
| 3625 | return nil, err |
| 3626 | } |
| 3627 | |
| 3628 | omciRxCallbackPair := CallbackPair{ |
| 3629 | CbKey: tid, |
| 3630 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3631 | } |
| 3632 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3633 | if err != nil { |
| 3634 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{ |
| 3635 | "Err": err, "device-id": oo.deviceID}) |
| 3636 | return nil, err |
| 3637 | } |
| 3638 | logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done") |
| 3639 | return meInstance, nil |
| 3640 | } |
| 3641 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3642 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3643 | return nil, omciErr.GetError() |
| 3644 | } |
| 3645 | |
| 3646 | // SendCreateIPHostConfigData nolint: unused |
| 3647 | func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3648 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3649 | tid := oo.GetNextTid(highPrio) |
| 3650 | logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3651 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3652 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3653 | |
| 3654 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3655 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3656 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3657 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3658 | if err != nil { |
| 3659 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err, |
| 3660 | "device-id": oo.deviceID}) |
| 3661 | return nil, err |
| 3662 | } |
| 3663 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3664 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3665 | if err != nil { |
| 3666 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err, |
| 3667 | "device-id": oo.deviceID}) |
| 3668 | return nil, err |
| 3669 | } |
| 3670 | |
| 3671 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3672 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3673 | } |
| 3674 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3675 | if err != nil { |
| 3676 | logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err, |
| 3677 | "device-id": oo.deviceID}) |
| 3678 | return nil, err |
| 3679 | } |
| 3680 | logger.Debug(ctx, "send IPHostConfigData-create-msg done") |
| 3681 | return meInstance, nil |
| 3682 | } |
| 3683 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3684 | "device-id": oo.deviceID}) |
| 3685 | return nil, omciErr.GetError() |
| 3686 | } |
| 3687 | |
| 3688 | // SendSetIPHostConfigData nolint: unused |
| 3689 | func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3690 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3691 | tid := oo.GetNextTid(highPrio) |
| 3692 | logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3693 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3694 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3695 | |
| 3696 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3697 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3698 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3699 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3700 | if err != nil { |
| 3701 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err, |
| 3702 | "device-id": oo.deviceID}) |
| 3703 | return nil, err |
| 3704 | } |
| 3705 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3706 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3707 | if err != nil { |
| 3708 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err, |
| 3709 | "device-id": oo.deviceID}) |
| 3710 | return nil, err |
| 3711 | } |
| 3712 | |
| 3713 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3714 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3715 | } |
| 3716 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3717 | if err != nil { |
| 3718 | logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err, |
| 3719 | "device-id": oo.deviceID}) |
| 3720 | return nil, err |
| 3721 | } |
| 3722 | logger.Debug(ctx, "send IPHostConfigData-set-msg done") |
| 3723 | return meInstance, nil |
| 3724 | } |
| 3725 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3726 | "device-id": oo.deviceID}) |
| 3727 | return nil, omciErr.GetError() |
| 3728 | } |
| 3729 | |
| 3730 | // SendDeleteIPHostConfigData nolint: unused |
| 3731 | func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3732 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3733 | tid := oo.GetNextTid(highPrio) |
| 3734 | logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3735 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3736 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3737 | |
| 3738 | meParams := me.ParamData{EntityID: aInstID} |
| 3739 | meInstance, omciErr := me.NewIpHostConfigData(meParams) |
| 3740 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3741 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3742 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3743 | if err != nil { |
| 3744 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{ |
| 3745 | "Err": err, "device-id": oo.deviceID}) |
| 3746 | return nil, err |
| 3747 | } |
| 3748 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3749 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3750 | if err != nil { |
| 3751 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{ |
| 3752 | "Err": err, "device-id": oo.deviceID}) |
| 3753 | return nil, err |
| 3754 | } |
| 3755 | |
| 3756 | omciRxCallbackPair := CallbackPair{ |
| 3757 | CbKey: tid, |
| 3758 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3759 | } |
| 3760 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3761 | if err != nil { |
| 3762 | logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{ |
| 3763 | "Err": err, "device-id": oo.deviceID}) |
| 3764 | return nil, err |
| 3765 | } |
| 3766 | logger.Debug(ctx, "send IPHostConfigData-Delete-msg done") |
| 3767 | return meInstance, nil |
| 3768 | } |
| 3769 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{ |
| 3770 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3771 | return nil, omciErr.GetError() |
| 3772 | } |
| 3773 | |
| 3774 | // SendCreateRTPProfileData nolint: unused |
| 3775 | func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3776 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3777 | tid := oo.GetNextTid(highPrio) |
| 3778 | logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3779 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3780 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3781 | |
| 3782 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3783 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3784 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3785 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3786 | if err != nil { |
| 3787 | logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err, |
| 3788 | "device-id": oo.deviceID}) |
| 3789 | return nil, err |
| 3790 | } |
| 3791 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3792 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3793 | if err != nil { |
| 3794 | logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err, |
| 3795 | "device-id": oo.deviceID}) |
| 3796 | return nil, err |
| 3797 | } |
| 3798 | |
| 3799 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3800 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3801 | } |
| 3802 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3803 | if err != nil { |
| 3804 | logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err, |
| 3805 | "device-id": oo.deviceID}) |
| 3806 | return nil, err |
| 3807 | } |
| 3808 | logger.Debug(ctx, "send RTPProfileData-create-msg done") |
| 3809 | return meInstance, nil |
| 3810 | } |
| 3811 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3812 | "device-id": oo.deviceID}) |
| 3813 | return nil, omciErr.GetError() |
| 3814 | } |
| 3815 | |
| 3816 | // SendSetRTPProfileData nolint: unused |
| 3817 | func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3818 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3819 | tid := oo.GetNextTid(highPrio) |
| 3820 | logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3821 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3822 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3823 | |
| 3824 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3825 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3826 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3827 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3828 | if err != nil { |
| 3829 | logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err, |
| 3830 | "device-id": oo.deviceID}) |
| 3831 | return nil, err |
| 3832 | } |
| 3833 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3834 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3835 | if err != nil { |
| 3836 | logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err, |
| 3837 | "device-id": oo.deviceID}) |
| 3838 | return nil, err |
| 3839 | } |
| 3840 | |
| 3841 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3842 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3843 | } |
| 3844 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3845 | if err != nil { |
| 3846 | logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err, |
| 3847 | "device-id": oo.deviceID}) |
| 3848 | return nil, err |
| 3849 | } |
| 3850 | logger.Debug(ctx, "send RTPProfileData-set-msg done") |
| 3851 | return meInstance, nil |
| 3852 | } |
| 3853 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3854 | "device-id": oo.deviceID}) |
| 3855 | return nil, omciErr.GetError() |
| 3856 | } |
| 3857 | |
| 3858 | // SendDeleteRTPProfileData nolint: unused |
| 3859 | func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3860 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3861 | tid := oo.GetNextTid(highPrio) |
| 3862 | logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3863 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3864 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3865 | |
| 3866 | meParams := me.ParamData{EntityID: aInstID} |
| 3867 | meInstance, omciErr := me.NewRtpProfileData(meParams) |
| 3868 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3869 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3870 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3871 | if err != nil { |
| 3872 | logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{ |
| 3873 | "Err": err, "device-id": oo.deviceID}) |
| 3874 | return nil, err |
| 3875 | } |
| 3876 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3877 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3878 | if err != nil { |
| 3879 | logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{ |
| 3880 | "Err": err, "device-id": oo.deviceID}) |
| 3881 | return nil, err |
| 3882 | } |
| 3883 | |
| 3884 | omciRxCallbackPair := CallbackPair{ |
| 3885 | CbKey: tid, |
| 3886 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3887 | } |
| 3888 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3889 | if err != nil { |
| 3890 | logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{ |
| 3891 | "Err": err, "device-id": oo.deviceID}) |
| 3892 | return nil, err |
| 3893 | } |
| 3894 | logger.Debug(ctx, "send RTPProfileData-Delete-msg done") |
| 3895 | return meInstance, nil |
| 3896 | } |
| 3897 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{ |
| 3898 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3899 | return nil, omciErr.GetError() |
| 3900 | } |
| 3901 | |
| 3902 | // SendCreateNetworkDialPlanTable nolint: unused |
| 3903 | func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3904 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3905 | tid := oo.GetNextTid(highPrio) |
| 3906 | logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3907 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3908 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3909 | |
| 3910 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3911 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3912 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3913 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3914 | if err != nil { |
| 3915 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err, |
| 3916 | "device-id": oo.deviceID}) |
| 3917 | return nil, err |
| 3918 | } |
| 3919 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3920 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3921 | if err != nil { |
| 3922 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3923 | "device-id": oo.deviceID}) |
| 3924 | return nil, err |
| 3925 | } |
| 3926 | |
| 3927 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3928 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3929 | } |
| 3930 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3931 | if err != nil { |
| 3932 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3933 | "device-id": oo.deviceID}) |
| 3934 | return nil, err |
| 3935 | } |
| 3936 | logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done") |
| 3937 | return meInstance, nil |
| 3938 | } |
| 3939 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3940 | "device-id": oo.deviceID}) |
| 3941 | return nil, omciErr.GetError() |
| 3942 | } |
| 3943 | |
| 3944 | // SendSetNetworkDialPlanTable nolint: unused |
| 3945 | func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3946 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3947 | tid := oo.GetNextTid(highPrio) |
| 3948 | logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3949 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3950 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3951 | |
| 3952 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3953 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3954 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3955 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3956 | if err != nil { |
| 3957 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err, |
| 3958 | "device-id": oo.deviceID}) |
| 3959 | return nil, err |
| 3960 | } |
| 3961 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3962 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3963 | if err != nil { |
| 3964 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3965 | "device-id": oo.deviceID}) |
| 3966 | return nil, err |
| 3967 | } |
| 3968 | |
| 3969 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3970 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3971 | } |
| 3972 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3973 | if err != nil { |
| 3974 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3975 | "device-id": oo.deviceID}) |
| 3976 | return nil, err |
| 3977 | } |
| 3978 | logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done") |
| 3979 | return meInstance, nil |
| 3980 | } |
| 3981 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3982 | "device-id": oo.deviceID}) |
| 3983 | return nil, omciErr.GetError() |
| 3984 | } |
| 3985 | |
| 3986 | // SendDeleteNetworkDialPlanTable nolint: unused |
| 3987 | func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3988 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3989 | tid := oo.GetNextTid(highPrio) |
| 3990 | logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3991 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3992 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3993 | |
| 3994 | meParams := me.ParamData{EntityID: aInstID} |
| 3995 | meInstance, omciErr := me.NewNetworkDialPlanTable(meParams) |
| 3996 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3997 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3998 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3999 | if err != nil { |
| 4000 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{ |
| 4001 | "Err": err, "device-id": oo.deviceID}) |
| 4002 | return nil, err |
| 4003 | } |
| 4004 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4005 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 4006 | if err != nil { |
| 4007 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{ |
| 4008 | "Err": err, "device-id": oo.deviceID}) |
| 4009 | return nil, err |
| 4010 | } |
| 4011 | |
| 4012 | omciRxCallbackPair := CallbackPair{ |
| 4013 | CbKey: tid, |
| 4014 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4015 | } |
| 4016 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 4017 | if err != nil { |
| 4018 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{ |
| 4019 | "Err": err, "device-id": oo.deviceID}) |
| 4020 | return nil, err |
| 4021 | } |
| 4022 | logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done") |
| 4023 | return meInstance, nil |
| 4024 | } |
| 4025 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{ |
| 4026 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 4027 | return nil, omciErr.GetError() |
| 4028 | } |
| 4029 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4030 | // SendSyncTime sends SynchronizeTimeRequest |
| 4031 | func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 4032 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4033 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 4034 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 4035 | |
| 4036 | omciLayer := &omci.OMCI{ |
| 4037 | TransactionID: tid, |
| 4038 | MessageType: omci.SynchronizeTimeRequestType, |
| 4039 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4040 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4041 | } |
| 4042 | utcTime := time.Now().UTC() |
| 4043 | request := &omci.SynchronizeTimeRequest{ |
| 4044 | MeBasePacket: omci.MeBasePacket{ |
| 4045 | EntityClass: me.OnuGClassID, |
| 4046 | // Default Instance ID is 0 |
| 4047 | }, |
| 4048 | Year: uint16(utcTime.Year()), |
| 4049 | Month: uint8(utcTime.Month()), |
| 4050 | Day: uint8(utcTime.Day()), |
| 4051 | Hour: uint8(utcTime.Hour()), |
| 4052 | Minute: uint8(utcTime.Minute()), |
| 4053 | Second: uint8(utcTime.Second()), |
| 4054 | } |
| 4055 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4056 | pkt, err := SerializeOmciLayer(ctx, omciLayer, request) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4057 | if err != nil { |
| 4058 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 4059 | "device-id": oo.deviceID}) |
| 4060 | return err |
| 4061 | } |
| 4062 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4063 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4064 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4065 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4066 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4067 | if err != nil { |
| 4068 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 4069 | "device-id": oo.deviceID}) |
| 4070 | return err |
| 4071 | } |
| 4072 | logger.Debug(ctx, "send synchronize time request done") |
| 4073 | return nil |
| 4074 | } |
| 4075 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4076 | // SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance |
| 4077 | func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4078 | upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4079 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4080 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4081 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 4082 | meParam := me.ParamData{EntityID: entityID} |
| 4083 | var meInstance *me.ManagedEntity |
| 4084 | var omciErr me.OmciErrors |
| 4085 | if upstream { |
| 4086 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 4087 | } else { |
| 4088 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 4089 | } |
| 4090 | if omciErr.GetError() == nil { |
| 4091 | var omciLayer *omci.OMCI |
| 4092 | var msgLayer gopacket.SerializableLayer |
| 4093 | var err error |
| 4094 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4095 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4096 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4097 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4098 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4099 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4100 | } |
| 4101 | if err != nil { |
| 4102 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 4103 | 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] | 4104 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4105 | } |
| 4106 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4107 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4108 | if err != nil { |
| 4109 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 4110 | 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] | 4111 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4112 | } |
| 4113 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4114 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4115 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4116 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4117 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4118 | if err != nil { |
| 4119 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 4120 | 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] | 4121 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4122 | } |
| 4123 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 4124 | 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] | 4125 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4126 | } |
| 4127 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 4128 | 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] | 4129 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4130 | } |
| 4131 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4132 | // SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance |
| 4133 | func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4134 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4135 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4136 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4137 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4138 | meParam := me.ParamData{EntityID: entityID} |
| 4139 | var meInstance *me.ManagedEntity |
| 4140 | var omciErr me.OmciErrors |
| 4141 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 4142 | |
| 4143 | if omciErr.GetError() == nil { |
| 4144 | var omciLayer *omci.OMCI |
| 4145 | var msgLayer gopacket.SerializableLayer |
| 4146 | var err error |
| 4147 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4148 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4149 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4150 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4151 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4152 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4153 | } |
| 4154 | if err != nil { |
| 4155 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 4156 | 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] | 4157 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4158 | } |
| 4159 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4160 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4161 | if err != nil { |
| 4162 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 4163 | 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] | 4164 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4165 | } |
| 4166 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4167 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4168 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4169 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4170 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4171 | if err != nil { |
| 4172 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 4173 | 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] | 4174 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4175 | } |
| 4176 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 4177 | 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] | 4178 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4179 | } |
| 4180 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 4181 | 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] | 4182 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4183 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4184 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4185 | // SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance |
| 4186 | func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4187 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4188 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4189 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4190 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4191 | meParam := me.ParamData{EntityID: entityID} |
| 4192 | var meInstance *me.ManagedEntity |
| 4193 | var omciErr me.OmciErrors |
| 4194 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 4195 | |
| 4196 | if omciErr.GetError() == nil { |
| 4197 | var omciLayer *omci.OMCI |
| 4198 | var msgLayer gopacket.SerializableLayer |
| 4199 | var err error |
| 4200 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4201 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4202 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4203 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4204 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4205 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4206 | } |
| 4207 | if err != nil { |
| 4208 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 4209 | 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] | 4210 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4211 | } |
| 4212 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4213 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4214 | if err != nil { |
| 4215 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 4216 | 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] | 4217 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4218 | } |
| 4219 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4220 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4221 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4222 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4223 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4224 | if err != nil { |
| 4225 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 4226 | 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] | 4227 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4228 | } |
| 4229 | logger.Debugw(ctx, "send fec history data ME done", |
| 4230 | 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] | 4231 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4232 | } |
| 4233 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 4234 | 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] | 4235 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4236 | } |
| 4237 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4238 | // SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance |
| 4239 | func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4240 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4241 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4242 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4243 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4244 | meParam := me.ParamData{EntityID: entityID} |
| 4245 | var meInstance *me.ManagedEntity |
| 4246 | var omciErr me.OmciErrors |
| 4247 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 4248 | |
| 4249 | if omciErr.GetError() == nil { |
| 4250 | var omciLayer *omci.OMCI |
| 4251 | var msgLayer gopacket.SerializableLayer |
| 4252 | var err error |
| 4253 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4254 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4255 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4256 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4257 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4258 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4259 | } |
| 4260 | if err != nil { |
| 4261 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 4262 | 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] | 4263 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4264 | } |
| 4265 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4266 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4267 | if err != nil { |
| 4268 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 4269 | 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] | 4270 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4271 | } |
| 4272 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4273 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4274 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4275 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4276 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4277 | if err != nil { |
| 4278 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 4279 | 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] | 4280 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4281 | } |
| 4282 | logger.Debugw(ctx, "send gemport history data ME done", |
| 4283 | 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] | 4284 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4285 | } |
| 4286 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 4287 | 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] | 4288 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4289 | } |
| 4290 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4291 | // SendStartSoftwareDownload sends StartSoftwareDownloadRequest |
| 4292 | func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4293 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4294 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4295 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4296 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4297 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4298 | |
| 4299 | omciLayer := &omci.OMCI{ |
| 4300 | TransactionID: tid, |
| 4301 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 4302 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4303 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4304 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4305 | if aIsExtendedOmci { |
| 4306 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4307 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4308 | request := &omci.StartSoftwareDownloadRequest{ |
| 4309 | MeBasePacket: omci.MeBasePacket{ |
| 4310 | EntityClass: me.SoftwareImageClassID, |
| 4311 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4312 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4313 | }, |
| 4314 | WindowSize: aDownloadWindowSize, |
| 4315 | ImageSize: aFileLen, |
| 4316 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 4317 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 4318 | } |
| 4319 | |
| 4320 | var options gopacket.SerializeOptions |
| 4321 | options.FixLengths = true |
| 4322 | buffer := gopacket.NewSerializeBuffer() |
| 4323 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4324 | if err != nil { |
| 4325 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 4326 | "device-id": oo.deviceID}) |
| 4327 | return err |
| 4328 | } |
| 4329 | outgoingPacket := buffer.Bytes() |
| 4330 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4331 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4332 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4333 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4334 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4335 | if err != nil { |
| 4336 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 4337 | "device-id": oo.deviceID}) |
| 4338 | return err |
| 4339 | } |
| 4340 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4341 | return nil |
| 4342 | } |
| 4343 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4344 | // PrepareOnuSectionsOfWindow prepares a list of sections for each window |
| 4345 | //Before invoking this function the oo.mutexTid needs to be be locked so that |
| 4346 | //GetOnuSwSecNextTid can be invoked without further locking |
| 4347 | func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context, |
| 4348 | aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4349 | omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) { |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4350 | //onuswsections uses only low prioirity tids |
| 4351 | tid := oo.GetOnuSwSecNextTid() |
| 4352 | logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4353 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4354 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection}) |
| 4355 | |
| 4356 | var omciTxReq OmciTransferStructure |
| 4357 | msgType := omci.DownloadSectionRequestType |
| 4358 | |
| 4359 | if aAckRequest > 0 { |
| 4360 | msgType = omci.DownloadSectionRequestWithResponseType |
| 4361 | |
| 4362 | } |
| 4363 | omciLayer := &omci.OMCI{ |
| 4364 | TransactionID: tid, |
| 4365 | MessageType: msgType, |
| 4366 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4367 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4368 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4369 | if aIsExtendedOmci { |
| 4370 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4371 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4372 | localSectionData := make([]byte, len(aSection)) |
| 4373 | |
| 4374 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
| 4375 | request := &omci.DownloadSectionRequest{ |
| 4376 | MeBasePacket: omci.MeBasePacket{ |
| 4377 | EntityClass: me.SoftwareImageClassID, |
| 4378 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4379 | Extended: aIsExtendedOmci, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4380 | }, |
| 4381 | SectionNumber: aDownloadSectionNo, |
| 4382 | SectionData: localSectionData, |
| 4383 | } |
| 4384 | |
| 4385 | var options gopacket.SerializeOptions |
| 4386 | options.FixLengths = true |
| 4387 | buffer := gopacket.NewSerializeBuffer() |
| 4388 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4389 | if err != nil { |
| 4390 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4391 | "device-id": oo.deviceID}) |
| 4392 | return omciTxReq, err |
| 4393 | } |
| 4394 | outgoingPacket := buffer.Bytes() |
| 4395 | |
| 4396 | omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket) |
| 4397 | |
| 4398 | if aAckRequest > 0 { |
| 4399 | // only the last section should have a timeout as an ack is required only for the last section of the window |
| 4400 | omciTxReq = OmciTransferStructure{ |
| 4401 | withFramePrint: true, |
| 4402 | OnuSwWindow: omciMsgsPerWindow, |
| 4403 | } |
| 4404 | return omciTxReq, nil |
| 4405 | } |
| 4406 | |
| 4407 | return omciTxReq, nil |
| 4408 | } |
| 4409 | |
| 4410 | //SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections |
| 4411 | func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context, |
| 4412 | aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) { |
| 4413 | if aOmciTxRequest.OnuSwWindow == nil { |
| 4414 | logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil", |
| 4415 | log.Fields{"device-id": oo.deviceID}) |
| 4416 | return |
| 4417 | |
| 4418 | } |
| 4419 | |
| 4420 | tid := oo.GetOnuSwSecLastTid() |
| 4421 | logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid}) |
| 4422 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4423 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4424 | } |
| 4425 | |
| 4426 | aOmciTxRequest.cbPair = omciRxCallbackPair |
| 4427 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey}) |
| 4428 | oo.mutexRxSchedMap.Lock() |
| 4429 | // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ... |
| 4430 | oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry |
| 4431 | oo.mutexRxSchedMap.Unlock() |
| 4432 | |
| 4433 | chSuccess := make(chan bool) |
| 4434 | aOmciTxRequest.chSuccess = chSuccess |
| 4435 | aOmciTxRequest.timeout = aTimeout |
| 4436 | aOmciTxRequest.retries = CDefaultRetries |
| 4437 | |
| 4438 | //tid := aOmciTxRequest.cbPair.CbKey |
| 4439 | oo.mutexMonReq.Lock() |
| 4440 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4441 | oo.mutexMonReq.Unlock() |
| 4442 | |
| 4443 | retries := aOmciTxRequest.retries |
| 4444 | retryCounter := 0 |
| 4445 | if aTimeout == 0 { |
| 4446 | logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID}) |
| 4447 | return |
| 4448 | } |
| 4449 | loop: |
| 4450 | for retryCounter <= retries { |
| 4451 | // the onu sw sections are enqueued only to the low priority queue |
| 4452 | oo.mutexLowPrioTxQueue.Lock() |
| 4453 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4454 | oo.mutexLowPrioTxQueue.Unlock() |
| 4455 | |
| 4456 | go oo.sendQueuedRequests(ctx) |
| 4457 | |
| 4458 | select { |
| 4459 | case success := <-chSuccess: |
| 4460 | if success { |
| 4461 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4462 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4463 | } else { |
| 4464 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4465 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4466 | } |
| 4467 | break loop |
| 4468 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4469 | if retryCounter == retries { |
Holger Hildebrandt | 2b10764 | 2022-12-09 07:56:23 +0000 | [diff] [blame] | 4470 | if oo.pBaseDeviceHandler.IsOltAvailable() { |
| 4471 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
| 4472 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4473 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc) |
| 4474 | } else { |
| 4475 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!", |
| 4476 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4477 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4478 | oo.incrementTxTimesouts() |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4479 | break loop |
| 4480 | } else { |
| 4481 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4482 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4483 | oo.incrementTxRetries() |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4484 | } |
| 4485 | } |
| 4486 | retryCounter++ |
| 4487 | } |
| 4488 | oo.mutexMonReq.Lock() |
| 4489 | delete(oo.monitoredRequests, tid) |
| 4490 | oo.mutexMonReq.Unlock() |
| 4491 | } |
| 4492 | |
| 4493 | func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4494 | var lastSection []byte |
| 4495 | if omciTxRequest.OnuSwWindow != nil { |
| 4496 | lastSection = omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1] |
| 4497 | } else { |
| 4498 | logger.Errorw(ctx, "invalid sw window received", log.Fields{"device-id": oo.deviceID}) |
| 4499 | return fmt.Errorf("invalid sw window received") |
| 4500 | } |
| 4501 | if omciTxRequest.withFramePrint { |
| 4502 | logger.Debugw(ctx, "sw-section-omci-message-to-send:", log.Fields{ |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4503 | "TxOmciMessage": hex.EncodeToString(lastSection), |
| 4504 | "device-id": oo.deviceID, |
| 4505 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 4506 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 4507 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 4508 | } |
| 4509 | sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow) |
| 4510 | if sendErr != nil { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4511 | logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"device-id": oo.deviceID, "error": sendErr}) |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4512 | return sendErr |
| 4513 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4514 | numberOfNoArSections := len(omciTxRequest.OnuSwWindow.Messages) - 1 // last section of window is sent with AR expected |
| 4515 | if lastSection[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 4516 | oo.increaseBaseTxNoArFramesBy(ctx, uint32(numberOfNoArSections)) |
| 4517 | oo.incrementBaseTxArFrames() |
| 4518 | } else { |
| 4519 | oo.increaseExtTxNoArFramesBy(ctx, uint32(numberOfNoArSections)) |
| 4520 | oo.incrementExtTxArFrames() |
| 4521 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4522 | return nil |
| 4523 | } |
| 4524 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4525 | // SendDownloadSection sends DownloadSectionRequestWithResponse |
| 4526 | func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4527 | rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4528 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4529 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4530 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4531 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4532 | |
| 4533 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 4534 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4535 | msgType := omci.DownloadSectionRequestType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4536 | var timeout int = 0 //default value for no response expected |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4537 | if aAckRequest > 0 { |
| 4538 | msgType = omci.DownloadSectionRequestWithResponseType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4539 | timeout = aTimeout |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4540 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4541 | omciLayer := &omci.OMCI{ |
| 4542 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4543 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4544 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4545 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4546 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4547 | if aIsExtendedOmci { |
| 4548 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4549 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4550 | localSectionData := make([]byte, len(aSection)) |
| 4551 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4552 | 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] | 4553 | request := &omci.DownloadSectionRequest{ |
| 4554 | MeBasePacket: omci.MeBasePacket{ |
| 4555 | EntityClass: me.SoftwareImageClassID, |
| 4556 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4557 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4558 | }, |
| 4559 | SectionNumber: aDownloadSectionNo, |
| 4560 | SectionData: localSectionData, |
| 4561 | } |
| 4562 | |
| 4563 | var options gopacket.SerializeOptions |
| 4564 | options.FixLengths = true |
| 4565 | buffer := gopacket.NewSerializeBuffer() |
| 4566 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4567 | if err != nil { |
| 4568 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4569 | "device-id": oo.deviceID}) |
| 4570 | return err |
| 4571 | } |
| 4572 | outgoingPacket := buffer.Bytes() |
| 4573 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4574 | //for initial debug purpose overrule the requested print state for some frames |
| 4575 | printFrame := aPrint |
| 4576 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 4577 | printFrame = true |
| 4578 | } |
| 4579 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4580 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4581 | // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway |
| 4582 | // (used to avoid retransmission of frames with the same TID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4583 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4584 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4585 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4586 | if err != nil { |
| 4587 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 4588 | "device-id": oo.deviceID}) |
| 4589 | return err |
| 4590 | } |
| 4591 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4592 | return nil |
| 4593 | } |
| 4594 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4595 | //SendEndSoftwareDownload sends EndSoftwareDownloadRequest |
| 4596 | func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4597 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4598 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4599 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4600 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4601 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4602 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4603 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4604 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4605 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4606 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4607 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4608 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4609 | if aIsExtendedOmci { |
| 4610 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4611 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4612 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4613 | MeBasePacket: omci.MeBasePacket{ |
| 4614 | EntityClass: me.SoftwareImageClassID, |
| 4615 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4616 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4617 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4618 | CRC32: aImageCrc, |
| 4619 | ImageSize: aFileLen, |
| 4620 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 4621 | 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] | 4622 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4623 | |
| 4624 | var options gopacket.SerializeOptions |
| 4625 | options.FixLengths = true |
| 4626 | buffer := gopacket.NewSerializeBuffer() |
| 4627 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4628 | if err != nil { |
| 4629 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4630 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4631 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4632 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4633 | outgoingPacket := buffer.Bytes() |
| 4634 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4635 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4636 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4637 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4638 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4639 | if err != nil { |
| 4640 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 4641 | "device-id": oo.deviceID}) |
| 4642 | return err |
| 4643 | } |
| 4644 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4645 | return nil |
| 4646 | } |
| 4647 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4648 | // SendActivateSoftware sends ActivateSoftwareRequest |
| 4649 | func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4650 | rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4651 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4652 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4653 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4654 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4655 | |
| 4656 | omciLayer := &omci.OMCI{ |
| 4657 | TransactionID: tid, |
| 4658 | MessageType: omci.ActivateSoftwareRequestType, |
| 4659 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4660 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4661 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4662 | if aIsExtendedOmci { |
| 4663 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4664 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4665 | request := &omci.ActivateSoftwareRequest{ |
| 4666 | MeBasePacket: omci.MeBasePacket{ |
| 4667 | EntityClass: me.SoftwareImageClassID, |
| 4668 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4669 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4670 | }, |
| 4671 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 4672 | } |
| 4673 | |
| 4674 | var options gopacket.SerializeOptions |
| 4675 | options.FixLengths = true |
| 4676 | buffer := gopacket.NewSerializeBuffer() |
| 4677 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4678 | if err != nil { |
| 4679 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 4680 | "device-id": oo.deviceID}) |
| 4681 | return err |
| 4682 | } |
| 4683 | outgoingPacket := buffer.Bytes() |
| 4684 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4685 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4686 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4687 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4688 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4689 | if err != nil { |
| 4690 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 4691 | "device-id": oo.deviceID}) |
| 4692 | return err |
| 4693 | } |
| 4694 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4695 | return nil |
| 4696 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4697 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4698 | // SendCommitSoftware sends CommitSoftwareRequest |
| 4699 | func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4700 | rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4701 | tid := oo.GetNextTid(highPrio) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4702 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4703 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4704 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4705 | |
| 4706 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4707 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4708 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4709 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4710 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4711 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4712 | if aIsExtendedOmci { |
| 4713 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4714 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4715 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4716 | MeBasePacket: omci.MeBasePacket{ |
| 4717 | EntityClass: me.SoftwareImageClassID, |
| 4718 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4719 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4720 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4721 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4722 | |
| 4723 | var options gopacket.SerializeOptions |
| 4724 | options.FixLengths = true |
| 4725 | buffer := gopacket.NewSerializeBuffer() |
| 4726 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4727 | if err != nil { |
| 4728 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4729 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4730 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4731 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4732 | outgoingPacket := buffer.Bytes() |
| 4733 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4734 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4735 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4736 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4737 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4738 | if err != nil { |
| 4739 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 4740 | "device-id": oo.deviceID}) |
| 4741 | return err |
| 4742 | } |
| 4743 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4744 | return nil |
| 4745 | } |
| 4746 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4747 | //SendSelfTestReq sends TestRequest |
| 4748 | func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error { |
| 4749 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4750 | logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID, |
| 4751 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4752 | "InstId": strconv.FormatInt(int64(instdID), 16)}) |
| 4753 | omciLayer := &omci.OMCI{ |
| 4754 | TransactionID: tid, |
| 4755 | MessageType: omci.TestRequestType, |
| 4756 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4757 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4758 | } |
| 4759 | |
| 4760 | var request *omci.OpticalLineSupervisionTestRequest |
| 4761 | switch classID { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4762 | case me.AniGClassID: |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4763 | request = &omci.OpticalLineSupervisionTestRequest{ |
| 4764 | MeBasePacket: omci.MeBasePacket{ |
| 4765 | EntityClass: classID, |
| 4766 | EntityInstance: instdID, |
| 4767 | }, |
| 4768 | SelectTest: uint8(7), // self test |
| 4769 | GeneralPurposeBuffer: uint16(0), |
| 4770 | VendorSpecificParameters: uint16(0), |
| 4771 | } |
| 4772 | default: |
| 4773 | logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID}) |
| 4774 | return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID) |
| 4775 | } |
| 4776 | // Test serialization back to former string |
| 4777 | var options gopacket.SerializeOptions |
| 4778 | options.FixLengths = true |
| 4779 | |
| 4780 | buffer := gopacket.NewSerializeBuffer() |
| 4781 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4782 | if err != nil { |
| 4783 | logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err, |
| 4784 | "device-id": oo.deviceID}) |
| 4785 | return err |
| 4786 | } |
| 4787 | outgoingPacket := buffer.Bytes() |
| 4788 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4789 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4790 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4791 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4792 | err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4793 | if err != nil { |
| 4794 | logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err, |
| 4795 | "device-id": oo.deviceID}) |
| 4796 | return err |
| 4797 | } |
| 4798 | logger.Debug(ctx, "send self test request done") |
| 4799 | return nil |
| 4800 | } |
| 4801 | |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4802 | //nolint: gocyclo |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4803 | func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) { |
| 4804 | |
| 4805 | nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false) |
| 4806 | if err != nil { |
| 4807 | logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID}) |
| 4808 | return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID) |
| 4809 | } |
| 4810 | msgLayer := (*packet).Layer(nextLayer) |
| 4811 | if msgLayer != nil { |
| 4812 | // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers |
| 4813 | if failure := (*packet).ErrorLayer(); failure != nil { |
| 4814 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4815 | // In the case of MibUploadNextResponse, we let the packet pass so that later processing |
| 4816 | // can examine for UnkonwnMEs and UnknownAttributes |
| 4817 | logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass", |
| 4818 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4819 | return false, nil |
| 4820 | } else if nextLayer == omci.LayerTypeGetResponse { |
| 4821 | if resp := msgLayer.(*omci.GetResponse); resp != nil { |
| 4822 | if resp.NextLayerType() == omci.LayerTypeUnknownAttributes { |
| 4823 | unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes) |
| 4824 | if unknownAttrLayer != nil { |
| 4825 | logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!", |
| 4826 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer}) |
| 4827 | return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID) |
| 4828 | } |
| 4829 | } |
| 4830 | } |
| 4831 | } |
| 4832 | // Try to decode any further error information |
| 4833 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
| 4834 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!", |
| 4835 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()}) |
| 4836 | return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID) |
| 4837 | } |
| 4838 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!", |
| 4839 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4840 | return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID) |
| 4841 | } |
| 4842 | } else if failure := (*packet).ErrorLayer(); failure != nil { |
| 4843 | // message layer could not be decoded, but at least check if additional failure information is available |
| 4844 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
Holger Hildebrandt | 93d183f | 2022-04-22 15:50:26 +0000 | [diff] [blame] | 4845 | errMsg := decodeFailure.String() |
| 4846 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4847 | if strings.Contains(strings.ToLower(errMsg), "table decode") { |
| 4848 | // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass |
| 4849 | // so that later processing can deal with it |
| 4850 | logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass", |
| 4851 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4852 | return false, nil |
| 4853 | } |
| 4854 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4855 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!", |
Holger Hildebrandt | 93d183f | 2022-04-22 15:50:26 +0000 | [diff] [blame] | 4856 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg}) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4857 | return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID) |
| 4858 | } |
| 4859 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available", |
| 4860 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4861 | return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID) |
| 4862 | } else { |
| 4863 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID}) |
| 4864 | return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID) |
| 4865 | } |
| 4866 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4867 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4868 | if v == omciMsg.MessageType { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4869 | switch nextLayer { |
| 4870 | case omci.LayerTypeCreateResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4871 | if resp := msgLayer.(*omci.CreateResponse); resp != nil { |
| 4872 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4873 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4874 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4875 | } |
| 4876 | case omci.LayerTypeDeleteResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4877 | if resp := msgLayer.(*omci.DeleteResponse); resp != nil { |
| 4878 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4879 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4880 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4881 | } |
| 4882 | case omci.LayerTypeSetResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4883 | if resp := msgLayer.(*omci.SetResponse); resp != nil { |
| 4884 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4885 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4886 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4887 | } |
| 4888 | case omci.LayerTypeStartSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4889 | if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil { |
| 4890 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4891 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4892 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4893 | } |
| 4894 | case omci.LayerTypeEndSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4895 | if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil { |
| 4896 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4897 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4898 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4899 | } |
| 4900 | case omci.LayerTypeActivateSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4901 | if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil { |
| 4902 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4903 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4904 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4905 | } |
| 4906 | case omci.LayerTypeCommitSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4907 | if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil { |
| 4908 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4909 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4910 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4911 | } |
| 4912 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4913 | } |
| 4914 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4915 | return false, nil |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4916 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4917 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4918 | func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4919 | timeout := aOmciTxRequest.timeout |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4920 | if timeout == 0 { |
| 4921 | //timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4922 | // enqueue |
| 4923 | if aOmciTxRequest.highPrio { |
| 4924 | oo.mutexHighPrioTxQueue.Lock() |
| 4925 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4926 | oo.mutexHighPrioTxQueue.Unlock() |
| 4927 | } else { |
| 4928 | oo.mutexLowPrioTxQueue.Lock() |
| 4929 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4930 | oo.mutexLowPrioTxQueue.Unlock() |
| 4931 | } |
| 4932 | go oo.sendQueuedRequests(ctx) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4933 | } else { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4934 | //the supervised sending with waiting on the response (based on TID) is called in background |
| 4935 | // to avoid blocking of the sender for the complete OMCI handshake procedure |
| 4936 | // to stay consistent with the processing tested so far, sending of next messages of the same control procedure |
| 4937 | // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there) |
| 4938 | go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4939 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4940 | } |
| 4941 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4942 | func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4943 | chSuccess := make(chan bool) |
| 4944 | aOmciTxRequest.chSuccess = chSuccess |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4945 | tid := aOmciTxRequest.cbPair.CbKey |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4946 | oo.mutexMonReq.Lock() |
| 4947 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4948 | oo.mutexMonReq.Unlock() |
| 4949 | |
| 4950 | retries := aOmciTxRequest.retries |
| 4951 | retryCounter := 0 |
| 4952 | loop: |
| 4953 | for retryCounter <= retries { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4954 | // enqueue |
| 4955 | if aOmciTxRequest.highPrio { |
| 4956 | oo.mutexHighPrioTxQueue.Lock() |
| 4957 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4958 | oo.mutexHighPrioTxQueue.Unlock() |
| 4959 | } else { |
| 4960 | oo.mutexLowPrioTxQueue.Lock() |
| 4961 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4962 | oo.mutexLowPrioTxQueue.Unlock() |
| 4963 | } |
| 4964 | go oo.sendQueuedRequests(ctx) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4965 | |
| 4966 | select { |
| 4967 | case success := <-chSuccess: |
| 4968 | if success { |
| 4969 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4970 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4971 | } else { |
| 4972 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4973 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4974 | } |
| 4975 | break loop |
| 4976 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4977 | if retryCounter == retries { |
Holger Hildebrandt | 2b10764 | 2022-12-09 07:56:23 +0000 | [diff] [blame] | 4978 | if oo.pBaseDeviceHandler.IsOltAvailable() { |
| 4979 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
| 4980 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4981 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc) |
| 4982 | } else { |
| 4983 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!", |
| 4984 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4985 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4986 | oo.incrementTxTimesouts() |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4987 | break loop |
| 4988 | } else { |
| 4989 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4990 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4991 | oo.incrementTxRetries() |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4992 | } |
| 4993 | } |
| 4994 | retryCounter++ |
| 4995 | } |
| 4996 | oo.mutexMonReq.Lock() |
| 4997 | delete(oo.monitoredRequests, tid) |
| 4998 | oo.mutexMonReq.Unlock() |
| 4999 | } |
| 5000 | |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5001 | //CancelRequestMonitoring terminates monitoring of outstanding omci requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5002 | func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) { |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5003 | logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5004 | oo.mutexMonReq.RLock() |
| 5005 | for k := range oo.monitoredRequests { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5006 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 5007 | select { |
| 5008 | case oo.monitoredRequests[k].chSuccess <- false: |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5009 | logger.Debugw(ctx, "send cancellation on omciRespChannel", |
| 5010 | log.Fields{"index": k, "device-id": oo.deviceID}) |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5011 | default: |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5012 | logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)", |
| 5013 | log.Fields{"index": k, "device-id": oo.deviceID}) |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5014 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5015 | } |
| 5016 | oo.mutexMonReq.RUnlock() |
| 5017 | } |
| 5018 | |
| 5019 | //GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum |
| 5020 | //time consumed for retry processing of a particular OMCI-request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5021 | func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration { |
| 5022 | return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5023 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5024 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5025 | // SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance |
| 5026 | func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5027 | 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] | 5028 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5029 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 5030 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 5031 | |
| 5032 | meParam := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 5033 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5034 | } |
| 5035 | var meInstance *me.ManagedEntity |
| 5036 | var omciErr me.OmciErrors |
| 5037 | if classID == me.EthernetFrameExtendedPmClassID { |
| 5038 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam) |
| 5039 | } else { |
| 5040 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam) |
| 5041 | } |
| 5042 | |
| 5043 | if omciErr.GetError() == nil { |
| 5044 | var omciLayer *omci.OMCI |
| 5045 | var msgLayer gopacket.SerializableLayer |
| 5046 | var err error |
| 5047 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5048 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 5049 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5050 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5051 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 5052 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5053 | } |
| 5054 | if err != nil { |
| 5055 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 5056 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5057 | return nil, err |
| 5058 | } |
| 5059 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 5060 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5061 | if err != nil { |
| 5062 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me", |
| 5063 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5064 | return nil, err |
| 5065 | } |
| 5066 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5067 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 5068 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5069 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5070 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5071 | if err != nil { |
| 5072 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 5073 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5074 | return nil, err |
| 5075 | } |
| 5076 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done", |
| 5077 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5078 | return meInstance, nil |
| 5079 | } |
| 5080 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 5081 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5082 | return nil, omciErr.GetError() |
| 5083 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5084 | |
| 5085 | // RLockMutexMonReq lock read access to monitoredRequests |
| 5086 | func (oo *OmciCC) RLockMutexMonReq() { |
| 5087 | oo.mutexMonReq.RLock() |
| 5088 | } |
| 5089 | |
| 5090 | // RUnlockMutexMonReq unlock read access to monitoredRequests |
| 5091 | func (oo *OmciCC) RUnlockMutexMonReq() { |
| 5092 | oo.mutexMonReq.RUnlock() |
| 5093 | } |
| 5094 | |
| 5095 | // GetMonitoredRequest get OmciTransferStructure for an omciTransID |
| 5096 | func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) { |
| 5097 | value, exist = oo.monitoredRequests[omciTransID] |
| 5098 | return value, exist |
| 5099 | } |
| 5100 | |
| 5101 | // SetChMonitoredRequest sets chSuccess to indicate whether response was received or not |
| 5102 | func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) { |
| 5103 | oo.monitoredRequests[omciTransID].chSuccess <- chVal |
| 5104 | } |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5105 | |
| 5106 | // SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me |
| 5107 | func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
| 5108 | rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
| 5109 | tid := oo.GetNextTid(highPrio) |
| 5110 | logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID, |
| 5111 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 5112 | |
| 5113 | meParams := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 5114 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5115 | } |
| 5116 | var meInstance *me.ManagedEntity |
| 5117 | var omciErr me.OmciErrors |
| 5118 | if classID == me.EthernetFrameExtendedPmClassID { |
| 5119 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams) |
| 5120 | } else { |
| 5121 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams) |
| 5122 | } |
| 5123 | |
| 5124 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5125 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5126 | if err != nil { |
| 5127 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 5128 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5129 | return nil, err |
| 5130 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 5131 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5132 | if err != nil { |
| 5133 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg", |
| 5134 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5135 | return nil, err |
| 5136 | } |
| 5137 | omciRxCallbackPair := CallbackPair{ |
| 5138 | CbKey: tid, |
| 5139 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 5140 | } |
| 5141 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 5142 | if err != nil { |
| 5143 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 5144 | log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5145 | return nil, err |
| 5146 | } |
| 5147 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done", |
| 5148 | log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5149 | return meInstance, nil |
| 5150 | } |
| 5151 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 5152 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5153 | return nil, omciErr.GetError() |
| 5154 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 5155 | |
| 5156 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 5157 | func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 5158 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 5159 | oo.pBaseDeviceHandler = nil |
| 5160 | oo.pOnuDeviceEntry = nil |
| 5161 | oo.pOnuAlarmManager = nil |
| 5162 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 5163 | |
| 5164 | // GetOmciCounters - TODO: add comment |
| 5165 | func (oo *OmciCC) GetOmciCounters() *extension.SingleGetValueResponse { |
| 5166 | oo.mutexCounters.RLock() |
| 5167 | defer oo.mutexCounters.RUnlock() |
| 5168 | resp := extension.SingleGetValueResponse{ |
| 5169 | Response: &extension.GetValueResponse{ |
| 5170 | Status: extension.GetValueResponse_OK, |
| 5171 | Response: &extension.GetValueResponse_OnuOmciStats{ |
| 5172 | OnuOmciStats: &extension.GetOnuOmciTxRxStatsResponse{}, |
| 5173 | }, |
| 5174 | }, |
| 5175 | } |
| 5176 | resp.Response.GetOnuOmciStats().BaseTxArFrames = oo.countersBase.txArFrames |
| 5177 | resp.Response.GetOnuOmciStats().BaseTxNoArFrames = oo.countersBase.txNoArFrames |
| 5178 | resp.Response.GetOnuOmciStats().BaseRxAkFrames = oo.countersBase.rxAkFrames |
| 5179 | resp.Response.GetOnuOmciStats().BaseRxNoAkFrames = oo.countersBase.rxNoAkFrames |
| 5180 | resp.Response.GetOnuOmciStats().ExtTxArFrames = oo.countersExt.txArFrames |
| 5181 | resp.Response.GetOnuOmciStats().ExtTxNoArFrames = oo.countersExt.txNoArFrames |
| 5182 | resp.Response.GetOnuOmciStats().ExtRxAkFrames = oo.countersExt.rxAkFrames |
| 5183 | resp.Response.GetOnuOmciStats().ExtRxNoAkFrames = oo.countersExt.rxNoAkFrames |
| 5184 | resp.Response.GetOnuOmciStats().TxOmciCounterRetries = oo.txRetries |
| 5185 | resp.Response.GetOnuOmciStats().TxOmciCounterTimeouts = oo.txTimeouts |
| 5186 | return &resp |
| 5187 | } |
| 5188 | |
| 5189 | // For more speed, separate functions for each counter |
| 5190 | |
| 5191 | func (oo *OmciCC) incrementBaseTxArFrames() { |
| 5192 | oo.mutexCounters.Lock() |
| 5193 | defer oo.mutexCounters.Unlock() |
| 5194 | oo.countersBase.txArFrames++ |
| 5195 | } |
| 5196 | |
| 5197 | func (oo *OmciCC) incrementExtTxArFrames() { |
| 5198 | oo.mutexCounters.Lock() |
| 5199 | defer oo.mutexCounters.Unlock() |
| 5200 | oo.countersExt.txArFrames++ |
| 5201 | } |
| 5202 | |
| 5203 | func (oo *OmciCC) incrementBaseRxAkFrames() { |
| 5204 | oo.mutexCounters.Lock() |
| 5205 | defer oo.mutexCounters.Unlock() |
| 5206 | oo.countersBase.rxAkFrames++ |
| 5207 | } |
| 5208 | |
| 5209 | func (oo *OmciCC) incrementExtRxAkFrames() { |
| 5210 | oo.mutexCounters.Lock() |
| 5211 | defer oo.mutexCounters.Unlock() |
| 5212 | oo.countersExt.rxAkFrames++ |
| 5213 | } |
| 5214 | |
| 5215 | func (oo *OmciCC) increaseBaseTxNoArFramesBy(ctx context.Context, value uint32) { |
| 5216 | oo.mutexCounters.Lock() |
| 5217 | defer oo.mutexCounters.Unlock() |
| 5218 | oo.countersBase.txNoArFrames += value |
| 5219 | } |
| 5220 | |
| 5221 | func (oo *OmciCC) increaseExtTxNoArFramesBy(ctx context.Context, value uint32) { |
| 5222 | oo.mutexCounters.Lock() |
| 5223 | defer oo.mutexCounters.Unlock() |
| 5224 | oo.countersExt.txNoArFrames += value |
| 5225 | } |
| 5226 | |
| 5227 | func (oo *OmciCC) incrementBaseRxNoAkFrames() { |
| 5228 | oo.mutexCounters.Lock() |
| 5229 | defer oo.mutexCounters.Unlock() |
| 5230 | oo.countersBase.rxNoAkFrames++ |
| 5231 | } |
| 5232 | |
| 5233 | func (oo *OmciCC) incrementExtRxNoAkFrames() { |
| 5234 | oo.mutexCounters.Lock() |
| 5235 | defer oo.mutexCounters.Unlock() |
| 5236 | oo.countersExt.rxNoAkFrames++ |
| 5237 | } |
| 5238 | |
| 5239 | func (oo *OmciCC) incrementTxRetries() { |
| 5240 | oo.mutexCounters.Lock() |
| 5241 | defer oo.mutexCounters.Unlock() |
| 5242 | oo.txRetries++ |
| 5243 | } |
| 5244 | |
| 5245 | func (oo *OmciCC) incrementTxTimesouts() { |
| 5246 | oo.mutexCounters.Lock() |
| 5247 | defer oo.mutexCounters.Unlock() |
| 5248 | oo.txTimeouts++ |
| 5249 | } |
Holger Hildebrandt | 7e13846 | 2023-03-29 12:12:14 +0000 | [diff] [blame] | 5250 | |
| 5251 | // NotifyAboutOnuConfigFailure - trigger ONU DeviceEvent to notify about ONU config failure |
| 5252 | func (oo *OmciCC) NotifyAboutOnuConfigFailure(ctx context.Context, errID string, meClassID me.ClassID, meEntityID uint16, |
| 5253 | meName string, meResult me.Results) { |
| 5254 | var description string |
| 5255 | if !oo.confFailMeAlreadyHandled(meClassID) { |
| 5256 | switch errID { |
| 5257 | case OnuConfigFailureResponseErr: |
| 5258 | description = OnuConfigFailureResponseErrDesc + meResult.String() + |
| 5259 | ", OMCI ME: " + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) + " (only first instance reported)" |
| 5260 | case OnuConfigFailureTimeout: |
| 5261 | description = OnuConfigFailureTimeoutDesc + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) + |
| 5262 | " (only first instance reported)" |
| 5263 | default: |
| 5264 | logger.Warnw(ctx, "method called with undefined errID", log.Fields{"errID": errID, "device-id": oo.deviceID}) |
| 5265 | return |
| 5266 | } |
| 5267 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, errID, description) |
| 5268 | oo.appendConfFailMe(meClassID) |
| 5269 | } |
| 5270 | } |
| 5271 | |
| 5272 | func (oo *OmciCC) confFailMeAlreadyHandled(meClassID me.ClassID) bool { |
| 5273 | oo.mutexConfFailMEs.RLock() |
| 5274 | defer oo.mutexConfFailMEs.RUnlock() |
| 5275 | for _, v := range oo.confFailMEs { |
| 5276 | if v == meClassID { |
| 5277 | return true |
| 5278 | } |
| 5279 | } |
| 5280 | return false |
| 5281 | } |
| 5282 | |
| 5283 | func (oo *OmciCC) appendConfFailMe(meClassID me.ClassID) { |
| 5284 | oo.mutexConfFailMEs.Lock() |
| 5285 | defer oo.mutexConfFailMEs.Unlock() |
| 5286 | oo.confFailMEs = append(oo.confFailMEs, meClassID) |
| 5287 | } |
| 5288 | |
| 5289 | // ResetConfFailMEs - reset list of stored config failure MEs |
| 5290 | func (oo *OmciCC) ResetConfFailMEs() { |
| 5291 | oo.mutexConfFailMEs.Lock() |
| 5292 | defer oo.mutexConfFailMEs.Unlock() |
| 5293 | oo.confFailMEs = nil |
| 5294 | } |