Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
Joey Armstrong | 89c812c | 2024-01-12 19:00:20 -0500 | [diff] [blame] | 2 | * Copyright 2020-2024 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 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 17 | // Package common provides global definitions |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 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 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 78 | // CallbackPairEntry to be used for OMCI send/receive correlation |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 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 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 85 | // CallbackPair to be used for ReceiveCallback init |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 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 | |
Joey Armstrong | 89c812c | 2024-01-12 19:00:20 -0500 | [diff] [blame] | 110 | // OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 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 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 158 | // NewOmciCC constructor returns a new instance of a OmciCC |
| 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 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 189 | // Stop stops/resets the omciCC |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 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 |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 300 | // |
| 301 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
| 302 | // |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 303 | // nolint: gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 304 | func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 305 | //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] | 306 | |
| 307 | if len(rxMsg) < 10 { |
| 308 | logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort", |
| 309 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 310 | if len(rxMsg) > 0 { |
| 311 | oo.printRxMessage(ctx, rxMsg) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 312 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 313 | return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID) |
| 314 | } |
| 315 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 316 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 317 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 318 | // (an extendedFormat message could be destroyed this way!) |
| 319 | trailerLenData := rxMsg[42:44] |
| 320 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
| 321 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
| 322 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 323 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 324 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 325 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 326 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 327 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 328 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 329 | } |
| 330 | } |
| 331 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 332 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 333 | // (an extendedFormat message could be destroyed this way!) |
| 334 | // extend/overwrite with trailer |
| 335 | trailer := make([]byte, 8) |
| 336 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 337 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 338 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 339 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 340 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 341 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 342 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
| 343 | } |
| 344 | } else { |
| 345 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 346 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 347 | oo.printRxMessage(ctx, rxMsg) |
| 348 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
| 349 | } |
| 350 | } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) { |
| 351 | if len(rxMsg) > 1980 { |
| 352 | logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort", |
| 353 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 354 | oo.printRxMessage(ctx, rxMsg) |
| 355 | return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 356 | } |
| 357 | } else { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 358 | logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort", |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 359 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 360 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 361 | return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 362 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 363 | decodeOptions := gopacket.DecodeOptions{ |
| 364 | Lazy: true, |
| 365 | NoCopy: true, |
| 366 | } |
| 367 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 368 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 369 | 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] | 370 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 371 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 372 | } |
| 373 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 374 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 375 | 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] | 376 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 377 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 378 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 379 | // insert some check on detected OMCI decoding issues and log them |
| 380 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 381 | // even though allowed from omci-lib due to set relaxed decoding |
| 382 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 383 | // (compare mib_sync.go unknownAttrLayer) |
| 384 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 385 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 386 | errMsg := failure.Error() |
| 387 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 388 | "device-id": oo.deviceID, "issue": errMsg}) |
| 389 | } |
| 390 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 391 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 392 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 393 | 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] | 394 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 395 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 396 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 397 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 398 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
| 399 | "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 400 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 401 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 402 | // We expect to find the TID in the oo.rxSchedulerMap |
| 403 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 404 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 405 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 406 | 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] | 407 | if omciMsg.TransactionID == 0 { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 408 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 409 | oo.incrementBaseRxNoAkFrames() |
| 410 | } else { |
| 411 | oo.incrementExtRxNoAkFrames() |
| 412 | } |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 413 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 414 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 415 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 416 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 417 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 418 | 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] | 419 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 420 | //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] | 421 | oo.mutexRxSchedMap.Lock() |
| 422 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 423 | if ok && rxCallbackEntry.CbFunction != nil { |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 424 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 425 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 426 | oo.printRxMessage(ctx, rxMsg) |
| 427 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 428 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 429 | oo.incrementBaseRxAkFrames() |
| 430 | } else { |
| 431 | oo.incrementExtRxAkFrames() |
| 432 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 433 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 434 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 435 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 436 | isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet) |
| 437 | if err != nil { |
| 438 | // qualified error logging already done in function above |
| 439 | if !rxCallbackEntry.FramePrint { |
| 440 | oo.printRxMessage(ctx, rxMsg) |
| 441 | } |
| 442 | return fmt.Errorf("could not decode further layers %s", oo.deviceID) |
| 443 | } |
| 444 | if isSuccessfulResponse { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 445 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 446 | } else { |
| 447 | logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type", |
| 448 | log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID}) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 449 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 450 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 451 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 452 | // so do not clean up the TransactionID in that case. |
| 453 | if omciMsg.MessageType != omci.TestResponseType { |
| 454 | // having posted the response the request is regarded as 'done' |
| 455 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 456 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 457 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 458 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 459 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 460 | oo.mutexRxSchedMap.Unlock() |
| 461 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 462 | oo.printRxMessage(ctx, rxMsg) |
| 463 | 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] | 464 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 465 | /* py code was: |
| 466 | Receive and OMCI message from the proxy channel to the OLT. |
| 467 | |
| 468 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 469 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 470 | """ |
| 471 | if not self.enabled: |
| 472 | return |
| 473 | |
| 474 | try: |
| 475 | now = arrow.utcnow() |
| 476 | d = None |
| 477 | |
| 478 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 479 | # save the current value of the entity_id_to_class_map, then |
| 480 | # replace it with our custom one before decode, and then finally |
| 481 | # restore it later. Tried other ways but really made the code messy. |
| 482 | saved_me_map = omci_entities.entity_id_to_class_map |
| 483 | omci_entities.entity_id_to_class_map = self._me_map |
| 484 | |
| 485 | try: |
| 486 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 487 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 488 | except KeyError as e: |
| 489 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 490 | 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] | 491 | rx_frame = self._decode_unknown_me(msg) |
| 492 | self._rx_unknown_me += 1 |
| 493 | |
| 494 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 495 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 496 | return |
| 497 | |
| 498 | finally: |
| 499 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 500 | |
| 501 | rx_tid = rx_frame.fields['transaction_id'] |
| 502 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 503 | 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] | 504 | # Filter the Test Result frame and route through receive onu |
| 505 | # message method. |
| 506 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 507 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 508 | return self._receive_onu_message(rx_frame) |
| 509 | |
| 510 | # Previously unreachable if this is the very first round-trip Rx or we |
| 511 | # have been running consecutive errors |
| 512 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 513 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 514 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 515 | |
| 516 | self._rx_frames += 1 |
| 517 | self._consecutive_errors = 0 |
| 518 | |
| 519 | try: |
| 520 | high_priority = self._tid_is_high_priority(rx_tid) |
| 521 | index = self._get_priority_index(high_priority) |
| 522 | |
| 523 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 524 | last_tx_tuple = self._tx_request[index] |
| 525 | |
| 526 | if last_tx_tuple is None or \ |
| 527 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 528 | # Possible late Rx on a message that timed-out |
| 529 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 530 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 531 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 532 | self._rx_unknown_tid += 1 |
| 533 | self._rx_late += 1 |
| 534 | return |
| 535 | |
| 536 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 537 | if dc is not None and not dc.cancelled and not dc.called: |
| 538 | dc.cancel() |
| 539 | |
| 540 | _secs = self._update_rx_tx_stats(now, ts) |
| 541 | |
| 542 | # Late arrival already serviced by a timeout? |
| 543 | if d.called: |
| 544 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 545 | 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] | 546 | return |
| 547 | |
| 548 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 549 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 550 | if d is not None: |
| 551 | return d.errback(failure.Failure(e)) |
| 552 | return |
| 553 | |
| 554 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 555 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 556 | tx_tid = tx_frame.fields['transaction_id']) |
| 557 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 558 | |
| 559 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 560 | self._rx_response[index] = rx_frame |
| 561 | d.callback(rx_frame) |
| 562 | |
| 563 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 564 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 565 | */ |
| 566 | } |
| 567 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 568 | /* |
| 569 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 570 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 571 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 572 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 573 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 574 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 575 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 576 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 577 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 578 | delete(oo.rxSchedulerMap, tid) |
| 579 | } |
| 580 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 581 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 582 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 583 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 584 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 585 | if timeout != 0 { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 586 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 587 | oo.mutexRxSchedMap.Lock() |
| 588 | // 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] | 589 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 590 | oo.mutexRxSchedMap.Unlock() |
| 591 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 592 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 593 | 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] | 594 | //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] | 595 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 596 | txFrame, |
| 597 | timeout, |
| 598 | retry, |
| 599 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 600 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 601 | receiveCallbackPair, |
| 602 | nil, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 603 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 604 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 605 | oo.mutexMonReq.Lock() |
| 606 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 607 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 608 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 609 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 610 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 611 | return nil |
| 612 | } |
| 613 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 614 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 615 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 616 | } |
| 617 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 618 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 619 | // Avoid accessing the txQueues from parallel send routines to block |
| 620 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 621 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 622 | // for the corresponding response too (t.b.d.). |
| 623 | oo.mutexSendQueuedRequests.Lock() |
| 624 | defer oo.mutexSendQueuedRequests.Unlock() |
| 625 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 626 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 627 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 628 | return |
| 629 | } |
| 630 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 631 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 632 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 633 | return |
| 634 | } |
| 635 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 636 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 637 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 638 | oo.mutexHighPrioTxQueue.Lock() |
| 639 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 640 | for oo.highPrioTxQueue.Len() > 0 { |
| 641 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 642 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 643 | // Element will be removed from the queue regardless of the send success, to prevent |
| 644 | // an accumulation of send requests for the same message in the event of an error. |
| 645 | // In this case, resend attempts for the message are ensured by our retry |
| 646 | // mechanism after omci-timeout. |
| 647 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 648 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 649 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 650 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 651 | } |
| 652 | return nil |
| 653 | } |
| 654 | |
| 655 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 656 | oo.mutexLowPrioTxQueue.Lock() |
| 657 | for oo.lowPrioTxQueue.Len() > 0 { |
| 658 | queueElement := oo.lowPrioTxQueue.Front() // First element |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 659 | // check if the element is for onu sw section |
| 660 | aOmciTxReq := queueElement.Value.(OmciTransferStructure) |
| 661 | if aOmciTxReq.OnuSwWindow != nil { |
| 662 | if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 663 | // Element will be removed from the queue regardless of the send success, to prevent |
| 664 | // an accumulation of send requests for the same message in the event of an error. |
| 665 | // In this case, resend attempts for the message are ensured by our retry |
| 666 | // mechanism after omci-timeout. |
| 667 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 668 | oo.mutexLowPrioTxQueue.Unlock() |
| 669 | return err |
| 670 | } |
| 671 | } else { |
| 672 | err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)) |
| 673 | if err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 674 | // Element will be removed from the queue regardless of the send success, to prevent |
| 675 | // an accumulation of send requests for the same message in the event of an error. |
| 676 | // In this case, resend attempts for the message are ensured by our retry |
| 677 | // mechanism after omci-timeout. |
| 678 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 679 | oo.mutexLowPrioTxQueue.Unlock() |
| 680 | return err |
| 681 | } |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 682 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 683 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 684 | // Interrupt the sending of low priority requests to process any high priority requests |
| 685 | // that may have arrived in the meantime |
| 686 | oo.mutexLowPrioTxQueue.Unlock() |
| 687 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 688 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 689 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 690 | oo.mutexLowPrioTxQueue.Lock() |
| 691 | } |
| 692 | |
| 693 | oo.mutexLowPrioTxQueue.Unlock() |
| 694 | return nil |
| 695 | } |
| 696 | |
| 697 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 698 | if omciTxRequest.withFramePrint { |
| 699 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 700 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 701 | "device-id": oo.deviceID, |
| 702 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 703 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 704 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 705 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 706 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 707 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 708 | ChildDeviceId: oo.deviceID, |
| 709 | Message: omciTxRequest.txFrame, |
| 710 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 711 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 712 | } |
| 713 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 714 | if sendErr != nil { |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 715 | 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] | 716 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 717 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 718 | if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 719 | oo.incrementBaseTxArFrames() |
| 720 | } else { |
| 721 | oo.incrementExtTxArFrames() |
| 722 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 723 | return nil |
| 724 | } |
| 725 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 726 | // GetNextTid - TODO: add comment |
| 727 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 728 | var next uint16 |
| 729 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 730 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 731 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 732 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 733 | if oo.hpTid < 0x8000 { |
| 734 | oo.hpTid = 0x8000 |
| 735 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 736 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 737 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 738 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 739 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 740 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 741 | if oo.tid >= 0x8000 { |
| 742 | oo.tid = 1 |
| 743 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 744 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 745 | } |
| 746 | return next |
| 747 | } |
| 748 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 749 | // GetOnuSwSecNextTid get the next low prio tid for the onu sw sections |
| 750 | // onu sw sections uses only low priority tids |
| 751 | // The mutexTid lock should be taken prior to using this function |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 752 | func (oo *OmciCC) GetOnuSwSecNextTid() uint16 { |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 753 | if oo.tid >= 0x8000 { |
| 754 | oo.tid = 1 |
| 755 | } |
bseeniva | d32c274 | 2024-12-09 11:46:17 +0530 | [diff] [blame] | 756 | next := oo.tid |
| 757 | oo.tid++ |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 758 | return next |
| 759 | } |
| 760 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 761 | // GetOnuSwSecLastTid gets the last allocated tid |
| 762 | // The mutexTid lock should be taken prior to using this function |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 763 | func (oo *OmciCC) GetOnuSwSecLastTid() uint16 { |
| 764 | next := oo.tid |
| 765 | lastAllocatedTid := next - 1 |
| 766 | return lastAllocatedTid |
| 767 | } |
| 768 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 769 | // LockMutexTID locks mutexTid |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 770 | func (oo *OmciCC) LockMutexTID() { |
| 771 | oo.mutexTid.Lock() |
| 772 | } |
| 773 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 774 | // UnLockMutexTID unlocks mutexTid |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 775 | func (oo *OmciCC) UnLockMutexTID() { |
| 776 | oo.mutexTid.Unlock() |
| 777 | } |
| 778 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 779 | // ################################################################################### |
| 780 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 781 | |
| 782 | // Serialize - TODO: add comment |
| 783 | 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] | 784 | omciLayer := &omci.OMCI{ |
| 785 | TransactionID: tid, |
| 786 | MessageType: msgType, |
| 787 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 788 | return SerializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 791 | // SerializeOmciLayer - TODO: add comment |
| 792 | 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] | 793 | var options gopacket.SerializeOptions |
| 794 | options.FixLengths = true |
| 795 | |
| 796 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 797 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 798 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 799 | 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] | 800 | return nil, err |
| 801 | } |
| 802 | return buffer.Bytes(), nil |
| 803 | } |
| 804 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 805 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 806 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 807 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 808 | hex.Encode(dst, omciPkt) |
| 809 | return dst, nil |
| 810 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 811 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 812 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 813 | // 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] | 814 | 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] | 815 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 816 | 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] | 817 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 818 | |
| 819 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 820 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 821 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 822 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 823 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 824 | oo.mutexMonReq.RLock() |
| 825 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 826 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 827 | select { |
| 828 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 829 | default: |
| 830 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 831 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 832 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 833 | } else { |
| 834 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 835 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 836 | } |
| 837 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 838 | |
| 839 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 840 | // 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] | 841 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 842 | Type: OMCI, |
| 843 | Data: OmciMessage{ |
| 844 | OmciMsg: omciMsg, |
| 845 | OmciPacket: packet, |
| 846 | }, |
| 847 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 848 | //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] | 849 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 850 | |
| 851 | return nil |
| 852 | } |
| 853 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 854 | // SendMibReset sends MibResetRequest |
| 855 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 856 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 857 | logger.Infow(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 858 | request := &omci.MibResetRequest{ |
| 859 | MeBasePacket: omci.MeBasePacket{ |
| 860 | EntityClass: me.OnuDataClassID, |
| 861 | }, |
| 862 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 863 | tid := oo.GetNextTid(highPrio) |
| 864 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 865 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 866 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 867 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 868 | return err |
| 869 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 870 | omciRxCallbackPair := CallbackPair{ |
| 871 | CbKey: tid, |
| 872 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 873 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 874 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 875 | } |
| 876 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 877 | // SendReboot sends RebootRequest |
| 878 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 879 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 880 | request := &omci.RebootRequest{ |
| 881 | MeBasePacket: omci.MeBasePacket{ |
| 882 | EntityClass: me.OnuGClassID, |
| 883 | }, |
| 884 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 885 | tid := oo.GetNextTid(highPrio) |
| 886 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 887 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 888 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 889 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 890 | return err |
| 891 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 892 | omciRxCallbackPair := CallbackPair{ |
| 893 | CbKey: tid, |
| 894 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 895 | } |
| 896 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 897 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 898 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 899 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 900 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 901 | return err |
| 902 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 903 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 904 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 905 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 906 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 907 | return err |
| 908 | } |
| 909 | return nil |
| 910 | } |
| 911 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 912 | // SendMibUpload sends MibUploadRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 913 | 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] | 914 | 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] | 915 | |
| 916 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 917 | |
| 918 | omciLayer := &omci.OMCI{ |
| 919 | TransactionID: tid, |
| 920 | MessageType: omci.MibUploadRequestType, |
| 921 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 922 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 923 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 924 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 925 | request := &omci.MibUploadRequest{ |
| 926 | MeBasePacket: omci.MeBasePacket{ |
| 927 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 928 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 929 | }, |
| 930 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 931 | var options gopacket.SerializeOptions |
| 932 | options.FixLengths = true |
| 933 | |
| 934 | buffer := gopacket.NewSerializeBuffer() |
| 935 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 936 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 937 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 938 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 939 | return err |
| 940 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 941 | oo.UploadSequNo = 0 |
| 942 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 943 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 944 | omciRxCallbackPair := CallbackPair{ |
| 945 | CbKey: tid, |
| 946 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 947 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 948 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 949 | } |
| 950 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 951 | // SendMibUploadNext sends MibUploadNextRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 952 | 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] | 953 | 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] | 954 | |
| 955 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 956 | |
| 957 | omciLayer := &omci.OMCI{ |
| 958 | TransactionID: tid, |
| 959 | MessageType: omci.MibUploadNextRequestType, |
| 960 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 961 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 962 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 963 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 964 | request := &omci.MibUploadNextRequest{ |
| 965 | MeBasePacket: omci.MeBasePacket{ |
| 966 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 967 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 968 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 969 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 970 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 971 | var options gopacket.SerializeOptions |
| 972 | options.FixLengths = true |
| 973 | |
| 974 | buffer := gopacket.NewSerializeBuffer() |
| 975 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 976 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 977 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 978 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 979 | return err |
| 980 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 981 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 982 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 983 | omciRxCallbackPair := CallbackPair{ |
| 984 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 985 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 986 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 987 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 988 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 989 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 990 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 991 | } |
| 992 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 993 | // SendGetAllAlarm gets all alarm ME instances |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 994 | 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] | 995 | 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] | 996 | |
| 997 | tid := oo.GetNextTid(highPrio) |
| 998 | omciLayer := &omci.OMCI{ |
| 999 | TransactionID: tid, |
| 1000 | MessageType: omci.GetAllAlarmsRequestType, |
| 1001 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1002 | } |
| 1003 | if isExtendedOmci { |
| 1004 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1005 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1006 | request := &omci.GetAllAlarmsRequest{ |
| 1007 | MeBasePacket: omci.MeBasePacket{ |
| 1008 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1009 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1010 | }, |
| 1011 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 1012 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1013 | var options gopacket.SerializeOptions |
| 1014 | options.FixLengths = true |
| 1015 | buffer := gopacket.NewSerializeBuffer() |
| 1016 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1017 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1018 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1019 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1020 | return err |
| 1021 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1022 | outgoingPacket := buffer.Bytes() |
| 1023 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1024 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1025 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1026 | omciRxCallbackPair := CallbackPair{ |
| 1027 | CbKey: tid, |
| 1028 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1029 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1030 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1031 | if err != nil { |
| 1032 | logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1033 | "device-id": oo.deviceID}) |
| 1034 | return err |
| 1035 | } |
| 1036 | logger.Debug(ctx, "send GetAllAlarmsRequest done") |
| 1037 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1038 | } |
| 1039 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1040 | // SendGetAllAlarmNext gets next alarm ME instance |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1041 | 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] | 1042 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 1043 | 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] | 1044 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1045 | |
| 1046 | tid := oo.GetNextTid(highPrio) |
| 1047 | omciLayer := &omci.OMCI{ |
| 1048 | TransactionID: tid, |
| 1049 | MessageType: omci.GetAllAlarmsNextRequestType, |
| 1050 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1051 | } |
| 1052 | if isExtendedOmci { |
| 1053 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1054 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1055 | request := &omci.GetAllAlarmsNextRequest{ |
| 1056 | MeBasePacket: omci.MeBasePacket{ |
| 1057 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1058 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1059 | }, |
| 1060 | CommandSequenceNumber: alarmUploadSeqNo, |
| 1061 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1062 | var options gopacket.SerializeOptions |
| 1063 | options.FixLengths = true |
| 1064 | buffer := gopacket.NewSerializeBuffer() |
| 1065 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1066 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1067 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1068 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1069 | return err |
| 1070 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1071 | outgoingPacket := buffer.Bytes() |
| 1072 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1073 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1074 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1075 | omciRxCallbackPair := CallbackPair{ |
| 1076 | CbKey: tid, |
| 1077 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1078 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1079 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1080 | if err != nil { |
| 1081 | logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1082 | "device-id": oo.deviceID}) |
| 1083 | return err |
| 1084 | } |
| 1085 | logger.Debug(ctx, "send GetAllAlarmsNextRequest done") |
| 1086 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1087 | } |
| 1088 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1089 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 1090 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1091 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1092 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1093 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1094 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1095 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1096 | EntityID: GalEthernetEID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1097 | Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1098 | } |
| 1099 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 1100 | if omciErr.GetError() == nil { |
| 1101 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1102 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1103 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1104 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1105 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1106 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1107 | } |
| 1108 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1109 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1110 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1111 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1112 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1113 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1116 | omciRxCallbackPair := CallbackPair{ |
| 1117 | CbKey: tid, |
| 1118 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1119 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1120 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1121 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1122 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1123 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1124 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1125 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1126 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1127 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1128 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1129 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1130 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1131 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1132 | } |
| 1133 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1134 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1135 | // 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] | 1136 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1137 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1138 | 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] | 1139 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1140 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1141 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 1142 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1143 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 1144 | // read ONU-2G from DB ???? //TODO!!! |
| 1145 | meParams := me.ParamData{ |
| 1146 | EntityID: 0, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1147 | Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1148 | } |
| 1149 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 1150 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1151 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1152 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1153 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1154 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1155 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1156 | } |
| 1157 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1158 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1159 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1160 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1161 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1162 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1165 | omciRxCallbackPair := CallbackPair{ |
| 1166 | CbKey: tid, |
| 1167 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1168 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1169 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1170 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1171 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1172 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1173 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1174 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1175 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1176 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1177 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1178 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1179 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1180 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1181 | } |
| 1182 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1183 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 1184 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 1185 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1186 | tid := oo.GetNextTid(highPrio) |
| 1187 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1188 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1189 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1190 | |
| 1191 | meParams := me.ParamData{ |
| 1192 | EntityID: instID, |
| 1193 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1194 | me.MacBridgeServiceProfile_Priority: 0x8000, |
| 1195 | me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s |
| 1196 | me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s |
| 1197 | me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s |
| 1198 | me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1199 | }, |
| 1200 | } |
| 1201 | |
| 1202 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1203 | if omciErr.GetError() == nil { |
| 1204 | //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] | 1205 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1206 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1207 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1208 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1209 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1210 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1211 | } |
| 1212 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1213 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1214 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1215 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1216 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1217 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1218 | } |
| 1219 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1220 | omciRxCallbackPair := CallbackPair{ |
| 1221 | CbKey: tid, |
| 1222 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1223 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1224 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1225 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1226 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1227 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1228 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1229 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1230 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1231 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1232 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1233 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1234 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1235 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1238 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1239 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1240 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1241 | tid := oo.GetNextTid(highPrio) |
| 1242 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1243 | if idErr != nil { |
| 1244 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1245 | "Err": idErr, "device-id": oo.deviceID}) |
| 1246 | return nil, idErr |
| 1247 | } |
| 1248 | 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] | 1249 | "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] | 1250 | |
| 1251 | meParams := me.ParamData{ |
| 1252 | EntityID: instID, |
| 1253 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1254 | me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1255 | me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo, |
| 1256 | me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType), |
| 1257 | me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1258 | }, |
| 1259 | } |
| 1260 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1261 | if omciErr.GetError() == nil { |
| 1262 | //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] | 1263 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1264 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1265 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1266 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1267 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1268 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1269 | } |
| 1270 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1271 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1272 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1273 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1274 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1275 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1276 | } |
| 1277 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1278 | omciRxCallbackPair := CallbackPair{ |
| 1279 | CbKey: tid, |
| 1280 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1281 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1282 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1283 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1284 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1285 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1286 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1287 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1288 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1289 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1290 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1291 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1292 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1293 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1294 | } |
| 1295 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1296 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1297 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1298 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1299 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1300 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1301 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1302 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1303 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1304 | |
| 1305 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1306 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1307 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1308 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1309 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1310 | assType = uint8(10) // for VEIP |
| 1311 | } |
| 1312 | meParams := me.ParamData{ |
| 1313 | EntityID: instID, |
| 1314 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1315 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType, |
| 1316 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1317 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1318 | }, |
| 1319 | } |
| 1320 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1321 | if omciErr.GetError() == nil { |
| 1322 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1323 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1324 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1325 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1326 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1327 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1328 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1329 | } |
| 1330 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1331 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1332 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1333 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1334 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1335 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1336 | } |
| 1337 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1338 | omciRxCallbackPair := CallbackPair{ |
| 1339 | CbKey: tid, |
| 1340 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1341 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1342 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1343 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1344 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1345 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1346 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1347 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1348 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1349 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1350 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1351 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1352 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1353 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1354 | } |
| 1355 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1356 | // SendSetOnuGLS sets OnuG ME instance |
| 1357 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1358 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1359 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1360 | 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] | 1361 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1362 | |
| 1363 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1364 | meParams := me.ParamData{ |
| 1365 | EntityID: 0, |
| 1366 | Attributes: requestedAttributes, |
| 1367 | } |
| 1368 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1369 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1370 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1371 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1372 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1373 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1374 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1375 | } |
| 1376 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1377 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1378 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1379 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1380 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1381 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1382 | } |
| 1383 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1384 | omciRxCallbackPair := CallbackPair{ |
| 1385 | CbKey: tid, |
| 1386 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1387 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1388 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1389 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1390 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1391 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1392 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1393 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1394 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1395 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1396 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1397 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1398 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1399 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1400 | } |
| 1401 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1402 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1403 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1404 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1405 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1406 | 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] | 1407 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1408 | |
| 1409 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1410 | meParams := me.ParamData{ |
| 1411 | EntityID: aInstNo, |
| 1412 | Attributes: requestedAttributes, |
| 1413 | } |
| 1414 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1415 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1416 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1417 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1418 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1419 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1420 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1421 | } |
| 1422 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1423 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1424 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1425 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1426 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1427 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1428 | } |
| 1429 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1430 | omciRxCallbackPair := CallbackPair{ |
| 1431 | CbKey: tid, |
| 1432 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1433 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1434 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1435 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1436 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1437 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1438 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1439 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1440 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1441 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1442 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1443 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1444 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1445 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1449 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1450 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1451 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1452 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1453 | 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] | 1454 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1455 | |
| 1456 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1457 | meParams := me.ParamData{ |
| 1458 | EntityID: aInstNo, |
| 1459 | Attributes: requestedAttributes, |
| 1460 | } |
| 1461 | meInstance, omciErr := me.NewUniG(meParams) |
| 1462 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1463 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1464 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1465 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1466 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1467 | return nil |
| 1468 | } |
| 1469 | |
| 1470 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1471 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1472 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1473 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1474 | return nil |
| 1475 | } |
| 1476 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1477 | omciRxCallbackPair := CallbackPair{ |
| 1478 | CbKey: tid, |
| 1479 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1480 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1481 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1482 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1483 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1484 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1485 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1486 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1487 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1488 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1489 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1490 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1491 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1492 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1493 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1494 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1495 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1496 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1497 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1498 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1499 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1500 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1501 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1502 | |
| 1503 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1504 | meParams := me.ParamData{ |
| 1505 | EntityID: aInstNo, |
| 1506 | Attributes: requestedAttributes, |
| 1507 | } |
| 1508 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1509 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1510 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1511 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1512 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1513 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1514 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1515 | } |
| 1516 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1517 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1518 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1519 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1520 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1521 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1524 | omciRxCallbackPair := CallbackPair{ |
| 1525 | CbKey: tid, |
| 1526 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1527 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1528 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1529 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1530 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1531 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1532 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1533 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1534 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1535 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1536 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1537 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1538 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1539 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1540 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1541 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1542 | // SendGetMe gets ME instance |
| 1543 | 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] | 1544 | timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1545 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1546 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1547 | 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] | 1548 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1549 | |
| 1550 | meParams := me.ParamData{ |
| 1551 | EntityID: entityID, |
| 1552 | Attributes: requestedAttributes, |
| 1553 | } |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1554 | var messageSet omci.DeviceIdent = omci.BaselineIdent |
| 1555 | if isExtendedOmci { |
| 1556 | messageSet = omci.ExtendedIdent |
| 1557 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1558 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1559 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1560 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1561 | 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] | 1562 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1563 | 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] | 1564 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1565 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1566 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1567 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1568 | 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] | 1569 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1570 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1571 | omciRxCallbackPair := CallbackPair{ |
| 1572 | CbKey: tid, |
| 1573 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1574 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1575 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1576 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1577 | 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] | 1578 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1579 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1580 | 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] | 1581 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1582 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1583 | 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] | 1584 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1585 | } |
| 1586 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1587 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1588 | 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] | 1589 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1590 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1591 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1592 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1593 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1594 | |
| 1595 | request := &omci.GetRequest{ |
| 1596 | MeBasePacket: omci.MeBasePacket{ |
| 1597 | EntityInstance: entityID, |
| 1598 | EntityClass: classID, |
| 1599 | }, |
| 1600 | AttributeMask: requestedAttributesMask, |
| 1601 | } |
| 1602 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1603 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1604 | if err != nil { |
| 1605 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1606 | return err |
| 1607 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1608 | omciRxCallbackPair := CallbackPair{ |
| 1609 | CbKey: tid, |
| 1610 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1611 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1612 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1613 | if err != nil { |
| 1614 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1615 | return err |
| 1616 | } |
| 1617 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1618 | return nil |
| 1619 | } |
| 1620 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1621 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1622 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1623 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1624 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1625 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1626 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1627 | |
| 1628 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1629 | EntityID: aInstID, |
| 1630 | Attributes: me.AttributeValueMap{ |
| 1631 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1632 | me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF, |
| 1633 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF, |
| 1634 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF, |
| 1635 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF, |
| 1636 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF, |
| 1637 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF, |
| 1638 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF, |
| 1639 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF, |
| 1640 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF, |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1641 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1642 | } |
| 1643 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1644 | if omciErr.GetError() == nil { |
| 1645 | //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] | 1646 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1647 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1648 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1649 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1650 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1651 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1652 | } |
| 1653 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1654 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1655 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1656 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1657 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1658 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1659 | } |
| 1660 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1661 | omciRxCallbackPair := CallbackPair{ |
| 1662 | CbKey: tid, |
| 1663 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1664 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1665 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1666 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1667 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1668 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1669 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1670 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1671 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1672 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1673 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1674 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1675 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1676 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1677 | } |
| 1678 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1679 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1680 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1681 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1682 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1683 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1684 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1685 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1686 | |
| 1687 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1688 | if omciErr.GetError() == nil { |
| 1689 | //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] | 1690 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1691 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1692 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1693 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1694 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1695 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1696 | } |
| 1697 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1698 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1699 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1700 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1701 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1702 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1703 | } |
| 1704 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1705 | omciRxCallbackPair := CallbackPair{ |
| 1706 | CbKey: tid, |
| 1707 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1708 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1709 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1710 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1711 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1712 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1713 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1714 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1715 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1716 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1717 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1718 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1719 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1720 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1721 | } |
| 1722 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1723 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1724 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1725 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1726 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1727 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1728 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1729 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1730 | |
| 1731 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1732 | if omciErr.GetError() == nil { |
| 1733 | //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] | 1734 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1735 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1736 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1737 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1738 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1739 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1740 | } |
| 1741 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1742 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1743 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1744 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1745 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1746 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1747 | } |
| 1748 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1749 | omciRxCallbackPair := CallbackPair{ |
| 1750 | CbKey: tid, |
| 1751 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1752 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1753 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1754 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1755 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1756 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1757 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1758 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1759 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1760 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1761 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1762 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1763 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1764 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1765 | } |
| 1766 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1767 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1768 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1769 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1770 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1771 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1772 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1773 | |
| 1774 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1775 | if omciErr.GetError() == nil { |
| 1776 | //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] | 1777 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1778 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1779 | if err != nil { |
| 1780 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1781 | "Err": err, "device-id": oo.deviceID}) |
| 1782 | return nil, err |
| 1783 | } |
| 1784 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1785 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1786 | if err != nil { |
| 1787 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1788 | "Err": err, "device-id": oo.deviceID}) |
| 1789 | return nil, err |
| 1790 | } |
| 1791 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1792 | omciRxCallbackPair := CallbackPair{ |
| 1793 | CbKey: tid, |
| 1794 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1795 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1796 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1797 | if err != nil { |
| 1798 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1799 | "Err": err, "device-id": oo.deviceID}) |
| 1800 | return nil, err |
| 1801 | } |
| 1802 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1803 | return meInstance, nil |
| 1804 | } |
| 1805 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1806 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1807 | return nil, omciErr.GetError() |
| 1808 | } |
| 1809 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1810 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1811 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1812 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1813 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1814 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1815 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1816 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1817 | |
| 1818 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1819 | if omciErr.GetError() == nil { |
| 1820 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1821 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1822 | oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1823 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1824 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1825 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1826 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1827 | } |
| 1828 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1829 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1830 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1831 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1832 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1833 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1834 | } |
| 1835 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1836 | omciRxCallbackPair := CallbackPair{ |
| 1837 | CbKey: tid, |
| 1838 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1839 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1840 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1841 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1842 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1843 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1844 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1845 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1846 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1847 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1848 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1849 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1850 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1851 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1852 | } |
| 1853 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1854 | // SendSetTcontVar sets TCont ME instance |
| 1855 | func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1856 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1857 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1858 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1859 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1860 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1861 | |
| 1862 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1863 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1864 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1865 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1866 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1867 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1868 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1869 | } |
| 1870 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1871 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1872 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1873 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1874 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1875 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1876 | } |
| 1877 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1878 | omciRxCallbackPair := CallbackPair{ |
| 1879 | CbKey: tid, |
| 1880 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1881 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1882 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1883 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1884 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1885 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1886 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1887 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1888 | logger.Debug(ctx, "send TCont-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1889 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1890 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1891 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1892 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1893 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1894 | } |
| 1895 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1896 | // SendSetPrioQueueVar sets PriorityQueue ME instance |
| 1897 | func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1898 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1899 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1900 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1901 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1902 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1903 | |
| 1904 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1905 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1906 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1907 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1908 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1909 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1910 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1911 | } |
| 1912 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1913 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1914 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1915 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1916 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1917 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1918 | } |
| 1919 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1920 | omciRxCallbackPair := CallbackPair{ |
| 1921 | CbKey: tid, |
| 1922 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1923 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1924 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1925 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1926 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1927 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1928 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1929 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1930 | logger.Debug(ctx, "send PrioQueue-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1931 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1932 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1933 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1934 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1935 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1936 | } |
| 1937 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1938 | // SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance |
| 1939 | func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1940 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1941 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1942 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1943 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1944 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1945 | |
| 1946 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1947 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1948 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1949 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1950 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1951 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1952 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1953 | } |
| 1954 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1955 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1956 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1957 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1958 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1959 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1960 | } |
| 1961 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1962 | omciRxCallbackPair := CallbackPair{ |
| 1963 | CbKey: tid, |
| 1964 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1965 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1966 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1967 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1968 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1969 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1970 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1971 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1972 | logger.Debug(ctx, "send 1PMapper-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1973 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1974 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1975 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1976 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1977 | return nil, omciErr.GetError() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1978 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1979 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1980 | // SendCreateVtfdVar creates VlanTaggingFilterData ME instance |
| 1981 | func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1982 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1983 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1984 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1985 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1986 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1987 | |
| 1988 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1989 | if omciErr.GetError() == nil { |
| 1990 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1991 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1992 | oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1993 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1994 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1995 | "Err": err, "device-id": oo.deviceID}) |
| 1996 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1997 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1998 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1999 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2000 | } |
| 2001 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2002 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2003 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2004 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2005 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2006 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2007 | } |
| 2008 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2009 | omciRxCallbackPair := CallbackPair{ |
| 2010 | CbKey: tid, |
| 2011 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2012 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2013 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2014 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2015 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2016 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2017 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2018 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2019 | logger.Debug(ctx, "send VTFD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2020 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2021 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2022 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2023 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2024 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2025 | } |
| 2026 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2027 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2028 | func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2029 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2030 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2031 | 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] | 2032 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2033 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2034 | |
| 2035 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 2036 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2037 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 2038 | oframe.TransactionID(tid)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2039 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2040 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2041 | "Err": err, "device-id": oo.deviceID}) |
| 2042 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2043 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2044 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2045 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2046 | } |
| 2047 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2048 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2049 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2050 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2051 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2052 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2053 | } |
| 2054 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2055 | omciRxCallbackPair := CallbackPair{ |
| 2056 | CbKey: tid, |
| 2057 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2058 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2059 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2060 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2061 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2062 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2063 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2064 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2065 | logger.Debug(ctx, "send VTFD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2066 | return meInstance, nil |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2067 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2068 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2069 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2070 | return nil, omciErr.GetError() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2071 | } |
| 2072 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2073 | // SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2074 | func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2075 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2076 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2077 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2078 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2079 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2080 | |
| 2081 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2082 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2083 | //EnhancedMode not yet supported, used with default options |
| 2084 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 2085 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2086 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2087 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2088 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2089 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2090 | } |
| 2091 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2092 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2093 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2094 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2095 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2096 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2097 | } |
| 2098 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2099 | omciRxCallbackPair := CallbackPair{ |
| 2100 | CbKey: tid, |
| 2101 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2102 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2103 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2104 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2105 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2106 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2107 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2108 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2109 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2110 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2111 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2112 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2113 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2114 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2115 | } |
| 2116 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2117 | // SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2118 | func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2119 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2120 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2121 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2122 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2123 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2124 | |
| 2125 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2126 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2127 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2128 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2129 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2130 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2131 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2132 | } |
| 2133 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2134 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2135 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2136 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2137 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2138 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2139 | } |
| 2140 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2141 | omciRxCallbackPair := CallbackPair{ |
| 2142 | CbKey: tid, |
| 2143 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2144 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2145 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2146 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2147 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2148 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2149 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2150 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2151 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2152 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2153 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2154 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2155 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2156 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2157 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2158 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2159 | // SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2160 | func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2161 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2162 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2163 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2164 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2165 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2166 | |
| 2167 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2168 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2169 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2170 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2171 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2172 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2173 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2174 | } |
| 2175 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2176 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2177 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2178 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2179 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2180 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2181 | } |
| 2182 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2183 | omciRxCallbackPair := CallbackPair{ |
| 2184 | CbKey: tid, |
| 2185 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2186 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2187 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2188 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2189 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2190 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2191 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2192 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2193 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2194 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2195 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2196 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2197 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2198 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2199 | } |
| 2200 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2201 | // SendDeleteVtfd deletes VlanTaggingFilterData ME instance |
| 2202 | func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2203 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2204 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2205 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2206 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2207 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2208 | |
| 2209 | meParams := me.ParamData{EntityID: aInstID} |
| 2210 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 2211 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2212 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2213 | oframe.TransactionID(tid)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2214 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2215 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2216 | "Err": err, "device-id": oo.deviceID}) |
| 2217 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2218 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2219 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2220 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2221 | } |
| 2222 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2223 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2224 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2225 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2226 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2227 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2228 | } |
| 2229 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2230 | omciRxCallbackPair := CallbackPair{ |
| 2231 | CbKey: tid, |
| 2232 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2233 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2234 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2235 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2236 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2237 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2238 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2239 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2240 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2241 | return meInstance, nil |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2242 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2243 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2244 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2245 | return nil, omciErr.GetError() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2246 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2247 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2248 | // SendCreateTDVar creates TrafficDescriptor ME instance |
| 2249 | func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2250 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2251 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2252 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2253 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2254 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2255 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2256 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2257 | if err != nil { |
| 2258 | 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] | 2259 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2260 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2261 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2262 | if err != nil { |
| 2263 | 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] | 2264 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2265 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2266 | omciRxCallbackPair := CallbackPair{ |
| 2267 | CbKey: tid, |
| 2268 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2269 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2270 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2271 | if err != nil { |
| 2272 | 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] | 2273 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2274 | } |
| 2275 | logger.Debug(ctx, "send TD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2276 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2277 | } |
| 2278 | 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] | 2279 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2280 | } |
| 2281 | |
| 2282 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2283 | func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2284 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2285 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2286 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2287 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2288 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2289 | |
| 2290 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2291 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2292 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2293 | if err != nil { |
| 2294 | 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] | 2295 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2296 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2297 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2298 | if err != nil { |
| 2299 | 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] | 2300 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2301 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2302 | omciRxCallbackPair := CallbackPair{ |
| 2303 | CbKey: tid, |
| 2304 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2305 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2306 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2307 | if err != nil { |
| 2308 | 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] | 2309 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2310 | } |
| 2311 | logger.Debug(ctx, "send TD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2312 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2313 | } |
| 2314 | 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] | 2315 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2316 | |
| 2317 | } |
| 2318 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2319 | // SendDeleteTD - TODO: add comment |
| 2320 | func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2321 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2322 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2323 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2324 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2325 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2326 | |
| 2327 | meParams := me.ParamData{EntityID: aInstID} |
| 2328 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 2329 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2330 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2331 | if err != nil { |
| 2332 | 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] | 2333 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2334 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2335 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2336 | if err != nil { |
| 2337 | 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] | 2338 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2339 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2340 | omciRxCallbackPair := CallbackPair{ |
| 2341 | CbKey: tid, |
| 2342 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2343 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2344 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2345 | if err != nil { |
| 2346 | 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] | 2347 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2348 | } |
| 2349 | logger.Debug(ctx, "send TD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2350 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2351 | } |
| 2352 | 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] | 2353 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2354 | |
| 2355 | } |
| 2356 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2357 | // SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance |
| 2358 | func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2359 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2360 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2361 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2362 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2363 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2364 | |
| 2365 | meParams := me.ParamData{EntityID: aInstID} |
| 2366 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2367 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2368 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2369 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2370 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2371 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2372 | "Err": err, "device-id": oo.deviceID}) |
| 2373 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2374 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2375 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2376 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2377 | } |
| 2378 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2379 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2380 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2381 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2382 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2383 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2384 | } |
| 2385 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2386 | omciRxCallbackPair := CallbackPair{ |
| 2387 | CbKey: tid, |
| 2388 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2389 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2390 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2391 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2392 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2393 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2394 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2395 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2396 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2397 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2398 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2399 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2400 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2401 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2402 | } |
| 2403 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2404 | // SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance |
| 2405 | func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2406 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2407 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2408 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2409 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2410 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2411 | |
| 2412 | meParams := me.ParamData{EntityID: aInstID} |
| 2413 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2414 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2415 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2416 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2417 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2418 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2419 | "Err": err, "device-id": oo.deviceID}) |
| 2420 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2421 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2422 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2423 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2424 | } |
| 2425 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2426 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2427 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2428 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2429 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2430 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2431 | } |
| 2432 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2433 | omciRxCallbackPair := CallbackPair{ |
| 2434 | CbKey: tid, |
| 2435 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2436 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2437 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2438 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2439 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2440 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2441 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2442 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2443 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2444 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2445 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2446 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2447 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2448 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2449 | } |
| 2450 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2451 | // SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance |
| 2452 | func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2453 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2454 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2455 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2456 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2457 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2458 | |
| 2459 | meParams := me.ParamData{EntityID: aInstID} |
| 2460 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2461 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2462 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2463 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2464 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2465 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2466 | "Err": err, "device-id": oo.deviceID}) |
| 2467 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2468 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2469 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2470 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2471 | } |
| 2472 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2473 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2474 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2475 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2476 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2477 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2478 | } |
| 2479 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2480 | omciRxCallbackPair := CallbackPair{ |
| 2481 | CbKey: tid, |
| 2482 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2483 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2484 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2485 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2486 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2487 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2488 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2489 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2490 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2491 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2492 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2493 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2494 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2495 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2496 | } |
| 2497 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2498 | // SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance |
| 2499 | func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2500 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2501 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2502 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2503 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2504 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2505 | |
| 2506 | meParams := me.ParamData{EntityID: aInstID} |
| 2507 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2508 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2509 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2510 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2511 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2512 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2513 | "Err": err, "device-id": oo.deviceID}) |
| 2514 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2515 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2516 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2517 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2518 | } |
| 2519 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2520 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2521 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2522 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2523 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2524 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2525 | } |
| 2526 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2527 | omciRxCallbackPair := CallbackPair{ |
| 2528 | CbKey: tid, |
| 2529 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2530 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2531 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2532 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2533 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2534 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2535 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2536 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2537 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2538 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2539 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2540 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2541 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2542 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2543 | } |
| 2544 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2545 | // SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance |
| 2546 | func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2547 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2548 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2549 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2550 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2551 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2552 | |
| 2553 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2554 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2555 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2556 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2557 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2558 | 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] | 2559 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2560 | } |
| 2561 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2562 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2563 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2564 | 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] | 2565 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2566 | } |
| 2567 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2568 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2569 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2570 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2571 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2572 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2573 | 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] | 2574 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2575 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2576 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2577 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2578 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2579 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2580 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2581 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2582 | } |
| 2583 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2584 | // SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance |
| 2585 | func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2586 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2587 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2588 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2589 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2590 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2591 | |
| 2592 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2593 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2594 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2595 | oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2596 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2597 | 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] | 2598 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2599 | } |
| 2600 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2601 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2602 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2603 | 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] | 2604 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2605 | } |
| 2606 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2607 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2608 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2609 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2610 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2611 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2612 | 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] | 2613 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2614 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2615 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2616 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2617 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2618 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2619 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2620 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2621 | } |
| 2622 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2623 | // SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance |
| 2624 | func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2625 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2626 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2627 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2628 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2629 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2630 | |
| 2631 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2632 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2633 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2634 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2635 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2636 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2637 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2638 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2639 | } |
| 2640 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2641 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2642 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2643 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2644 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2645 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2646 | } |
| 2647 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2648 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2649 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2650 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2651 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2652 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2653 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2654 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2655 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2656 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2657 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2658 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2659 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2660 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2661 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2662 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2663 | } |
| 2664 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2665 | // SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance |
| 2666 | func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2667 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2668 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2669 | logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2670 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2671 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2672 | |
| 2673 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2674 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2675 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2676 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2677 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2678 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2679 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2680 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2681 | } |
| 2682 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2683 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2684 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2685 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2686 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2687 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2688 | } |
| 2689 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2690 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2691 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2692 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2693 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2694 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2695 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2696 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2697 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2698 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2699 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2700 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2701 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2702 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2703 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2704 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2705 | } |
| 2706 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2707 | // SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance |
| 2708 | func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2709 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2710 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2711 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2712 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2713 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2714 | |
| 2715 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2716 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2717 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2718 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2719 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2720 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2721 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2722 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2723 | } |
| 2724 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2725 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2726 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2727 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2728 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2729 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2730 | } |
| 2731 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2732 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2733 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2734 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2735 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2736 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2737 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2738 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2739 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2740 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2741 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2742 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2743 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2744 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2745 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2746 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2747 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2748 | |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2749 | // SendCreateVoipVoiceCTP nolint: unused |
| 2750 | func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2751 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2752 | tid := oo.GetNextTid(highPrio) |
| 2753 | logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2754 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2755 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2756 | |
| 2757 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2758 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2759 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2760 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2761 | if err != nil { |
| 2762 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err, |
| 2763 | "device-id": oo.deviceID}) |
| 2764 | return nil, err |
| 2765 | } |
| 2766 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2767 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2768 | if err != nil { |
| 2769 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err, |
| 2770 | "device-id": oo.deviceID}) |
| 2771 | return nil, err |
| 2772 | } |
| 2773 | |
| 2774 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2775 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2776 | } |
| 2777 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2778 | if err != nil { |
| 2779 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err, |
| 2780 | "device-id": oo.deviceID}) |
| 2781 | return nil, err |
| 2782 | } |
| 2783 | logger.Debug(ctx, "send VoipVoiceCTP-create-msg done") |
| 2784 | return meInstance, nil |
| 2785 | } |
| 2786 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2787 | "device-id": oo.deviceID}) |
| 2788 | return nil, omciErr.GetError() |
| 2789 | } |
| 2790 | |
| 2791 | // SendSetVoipVoiceCTP nolint: unused |
| 2792 | func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2793 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2794 | tid := oo.GetNextTid(highPrio) |
| 2795 | logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2796 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2797 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2798 | |
| 2799 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2800 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2801 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2802 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2803 | if err != nil { |
| 2804 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err, |
| 2805 | "device-id": oo.deviceID}) |
| 2806 | return nil, err |
| 2807 | } |
| 2808 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2809 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2810 | if err != nil { |
| 2811 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err, |
| 2812 | "device-id": oo.deviceID}) |
| 2813 | return nil, err |
| 2814 | } |
| 2815 | |
| 2816 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2817 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2818 | } |
| 2819 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2820 | if err != nil { |
| 2821 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err, |
| 2822 | "device-id": oo.deviceID}) |
| 2823 | return nil, err |
| 2824 | } |
| 2825 | logger.Debug(ctx, "send VoipVoiceCTP-set-msg done") |
| 2826 | return meInstance, nil |
| 2827 | } |
| 2828 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2829 | "device-id": oo.deviceID}) |
| 2830 | return nil, omciErr.GetError() |
| 2831 | } |
| 2832 | |
| 2833 | // SendDeleteVoipVoiceCTP nolint: unused |
| 2834 | func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2835 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2836 | tid := oo.GetNextTid(highPrio) |
| 2837 | logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2838 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2839 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2840 | |
| 2841 | meParams := me.ParamData{EntityID: aInstID} |
| 2842 | meInstance, omciErr := me.NewVoipVoiceCtp(meParams) |
| 2843 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2844 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2845 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2846 | if err != nil { |
| 2847 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{ |
| 2848 | "Err": err, "device-id": oo.deviceID}) |
| 2849 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2850 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2851 | // (relevant to all used sendXX() methods and their error conditions) |
| 2852 | return nil, err |
| 2853 | } |
| 2854 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2855 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2856 | if err != nil { |
| 2857 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{ |
| 2858 | "Err": err, "device-id": oo.deviceID}) |
| 2859 | return nil, err |
| 2860 | } |
| 2861 | |
| 2862 | omciRxCallbackPair := CallbackPair{ |
| 2863 | CbKey: tid, |
| 2864 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2865 | } |
| 2866 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2867 | if err != nil { |
| 2868 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{ |
| 2869 | "Err": err, "device-id": oo.deviceID}) |
| 2870 | return nil, err |
| 2871 | } |
| 2872 | logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done") |
| 2873 | return meInstance, nil |
| 2874 | } |
| 2875 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{ |
| 2876 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2877 | return nil, omciErr.GetError() |
| 2878 | } |
| 2879 | |
| 2880 | // SendCreateVoipMediaProfile nolint: unused |
| 2881 | func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2882 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2883 | tid := oo.GetNextTid(highPrio) |
| 2884 | logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2885 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2886 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2887 | |
| 2888 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2889 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2890 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2891 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2892 | if err != nil { |
| 2893 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err, |
| 2894 | "device-id": oo.deviceID}) |
| 2895 | return nil, err |
| 2896 | } |
| 2897 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2898 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2899 | if err != nil { |
| 2900 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err, |
| 2901 | "device-id": oo.deviceID}) |
| 2902 | return nil, err |
| 2903 | } |
| 2904 | |
| 2905 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2906 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2907 | } |
| 2908 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2909 | if err != nil { |
| 2910 | logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err, |
| 2911 | "device-id": oo.deviceID}) |
| 2912 | return nil, err |
| 2913 | } |
| 2914 | logger.Debug(ctx, "send VoipMediaProfile-create-msg done") |
| 2915 | return meInstance, nil |
| 2916 | } |
| 2917 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2918 | "device-id": oo.deviceID}) |
| 2919 | return nil, omciErr.GetError() |
| 2920 | } |
| 2921 | |
| 2922 | // SendSetVoipMediaProfile nolint: unused |
| 2923 | func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2924 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2925 | tid := oo.GetNextTid(highPrio) |
| 2926 | logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2927 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2928 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2929 | |
| 2930 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2931 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2932 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2933 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2934 | if err != nil { |
| 2935 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err, |
| 2936 | "device-id": oo.deviceID}) |
| 2937 | return nil, err |
| 2938 | } |
| 2939 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2940 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2941 | if err != nil { |
| 2942 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err, |
| 2943 | "device-id": oo.deviceID}) |
| 2944 | return nil, err |
| 2945 | } |
| 2946 | |
| 2947 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2948 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2949 | } |
| 2950 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2951 | if err != nil { |
| 2952 | logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err, |
| 2953 | "device-id": oo.deviceID}) |
| 2954 | return nil, err |
| 2955 | } |
| 2956 | logger.Debug(ctx, "send VoipMediaProfile-set-msg done") |
| 2957 | return meInstance, nil |
| 2958 | } |
| 2959 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2960 | "device-id": oo.deviceID}) |
| 2961 | return nil, omciErr.GetError() |
| 2962 | } |
| 2963 | |
| 2964 | // SendDeleteVoipMediaProfile nolint: unused |
| 2965 | func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2966 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2967 | tid := oo.GetNextTid(highPrio) |
| 2968 | logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2969 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2970 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2971 | |
| 2972 | meParams := me.ParamData{EntityID: aInstID} |
| 2973 | meInstance, omciErr := me.NewVoipMediaProfile(meParams) |
| 2974 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2975 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2976 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2977 | if err != nil { |
| 2978 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{ |
| 2979 | "Err": err, "device-id": oo.deviceID}) |
| 2980 | return nil, err |
| 2981 | } |
| 2982 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2983 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2984 | if err != nil { |
| 2985 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{ |
| 2986 | "Err": err, "device-id": oo.deviceID}) |
| 2987 | return nil, err |
| 2988 | } |
| 2989 | |
| 2990 | omciRxCallbackPair := CallbackPair{ |
| 2991 | CbKey: tid, |
| 2992 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2993 | } |
| 2994 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2995 | if err != nil { |
| 2996 | logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{ |
| 2997 | "Err": err, "device-id": oo.deviceID}) |
| 2998 | return nil, err |
| 2999 | } |
| 3000 | logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done") |
| 3001 | return meInstance, nil |
| 3002 | } |
| 3003 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{ |
| 3004 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3005 | return nil, omciErr.GetError() |
| 3006 | } |
| 3007 | |
| 3008 | // SendCreateVoiceServiceProfile nolint: unused |
| 3009 | func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3010 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3011 | tid := oo.GetNextTid(highPrio) |
| 3012 | logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3013 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3014 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3015 | |
| 3016 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 3017 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3018 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3019 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3020 | if err != nil { |
| 3021 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err, |
| 3022 | "device-id": oo.deviceID}) |
| 3023 | return nil, err |
| 3024 | } |
| 3025 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3026 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3027 | if err != nil { |
| 3028 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err, |
| 3029 | "device-id": oo.deviceID}) |
| 3030 | return nil, err |
| 3031 | } |
| 3032 | |
| 3033 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3034 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3035 | } |
| 3036 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3037 | if err != nil { |
| 3038 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err, |
| 3039 | "device-id": oo.deviceID}) |
| 3040 | return nil, err |
| 3041 | } |
| 3042 | logger.Debug(ctx, "send VoiceServiceProfile-create-msg done") |
| 3043 | return meInstance, nil |
| 3044 | } |
| 3045 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3046 | "device-id": oo.deviceID}) |
| 3047 | return nil, omciErr.GetError() |
| 3048 | } |
| 3049 | |
| 3050 | // SendSetVoiceServiceProfile nolint: unused |
| 3051 | func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3052 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3053 | tid := oo.GetNextTid(highPrio) |
| 3054 | logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3055 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3056 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3057 | |
| 3058 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 3059 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3060 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3061 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3062 | if err != nil { |
| 3063 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err, |
| 3064 | "device-id": oo.deviceID}) |
| 3065 | return nil, err |
| 3066 | } |
| 3067 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3068 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3069 | if err != nil { |
| 3070 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err, |
| 3071 | "device-id": oo.deviceID}) |
| 3072 | return nil, err |
| 3073 | } |
| 3074 | |
| 3075 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3076 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3077 | } |
| 3078 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3079 | if err != nil { |
| 3080 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err, |
| 3081 | "device-id": oo.deviceID}) |
| 3082 | return nil, err |
| 3083 | } |
| 3084 | logger.Debug(ctx, "send VoiceServiceProfile-set-msg done") |
| 3085 | return meInstance, nil |
| 3086 | } |
| 3087 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3088 | "device-id": oo.deviceID}) |
| 3089 | return nil, omciErr.GetError() |
| 3090 | } |
| 3091 | |
| 3092 | // SendDeleteVoiceServiceProfile nolint: unused |
| 3093 | func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3094 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3095 | tid := oo.GetNextTid(highPrio) |
| 3096 | logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3097 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3098 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3099 | |
| 3100 | meParams := me.ParamData{EntityID: aInstID} |
| 3101 | meInstance, omciErr := me.NewVoiceServiceProfile(meParams) |
| 3102 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3103 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3104 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3105 | if err != nil { |
| 3106 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{ |
| 3107 | "Err": err, "device-id": oo.deviceID}) |
| 3108 | return nil, err |
| 3109 | } |
| 3110 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3111 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3112 | if err != nil { |
| 3113 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{ |
| 3114 | "Err": err, "device-id": oo.deviceID}) |
| 3115 | return nil, err |
| 3116 | } |
| 3117 | |
| 3118 | omciRxCallbackPair := CallbackPair{ |
| 3119 | CbKey: tid, |
| 3120 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3121 | } |
| 3122 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3123 | if err != nil { |
| 3124 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{ |
| 3125 | "Err": err, "device-id": oo.deviceID}) |
| 3126 | return nil, err |
| 3127 | } |
| 3128 | logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done") |
| 3129 | return meInstance, nil |
| 3130 | } |
| 3131 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{ |
| 3132 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3133 | return nil, omciErr.GetError() |
| 3134 | } |
| 3135 | |
| 3136 | // SendCreateSIPUserData nolint: unused |
| 3137 | func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3138 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3139 | tid := oo.GetNextTid(highPrio) |
| 3140 | logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3141 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3142 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3143 | |
| 3144 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3145 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3146 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3147 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3148 | if err != nil { |
| 3149 | logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err, |
| 3150 | "device-id": oo.deviceID}) |
| 3151 | return nil, err |
| 3152 | } |
| 3153 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3154 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3155 | if err != nil { |
| 3156 | logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err, |
| 3157 | "device-id": oo.deviceID}) |
| 3158 | return nil, err |
| 3159 | } |
| 3160 | |
| 3161 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3162 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3163 | } |
| 3164 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3165 | if err != nil { |
| 3166 | logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err, |
| 3167 | "device-id": oo.deviceID}) |
| 3168 | return nil, err |
| 3169 | } |
| 3170 | logger.Debug(ctx, "send SIPUserData-create-msg done") |
| 3171 | return meInstance, nil |
| 3172 | } |
| 3173 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3174 | "device-id": oo.deviceID}) |
| 3175 | return nil, omciErr.GetError() |
| 3176 | } |
| 3177 | |
| 3178 | // SendSetSIPUserData nolint: unused |
| 3179 | func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3180 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3181 | tid := oo.GetNextTid(highPrio) |
| 3182 | logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3183 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3184 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3185 | |
| 3186 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3187 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3188 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3189 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3190 | if err != nil { |
| 3191 | logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err, |
| 3192 | "device-id": oo.deviceID}) |
| 3193 | return nil, err |
| 3194 | } |
| 3195 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3196 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3197 | if err != nil { |
| 3198 | logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err, |
| 3199 | "device-id": oo.deviceID}) |
| 3200 | return nil, err |
| 3201 | } |
| 3202 | |
| 3203 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3204 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3205 | } |
| 3206 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3207 | if err != nil { |
| 3208 | logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err, |
| 3209 | "device-id": oo.deviceID}) |
| 3210 | return nil, err |
| 3211 | } |
| 3212 | logger.Debug(ctx, "send SIPUserData-set-msg done") |
| 3213 | return meInstance, nil |
| 3214 | } |
| 3215 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3216 | "device-id": oo.deviceID}) |
| 3217 | return nil, omciErr.GetError() |
| 3218 | } |
| 3219 | |
| 3220 | // SendDeleteSIPUserData nolint: unused |
| 3221 | func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3222 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3223 | tid := oo.GetNextTid(highPrio) |
| 3224 | logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3225 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3226 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3227 | |
| 3228 | meParams := me.ParamData{EntityID: aInstID} |
| 3229 | meInstance, omciErr := me.NewSipUserData(meParams) |
| 3230 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3231 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3232 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3233 | if err != nil { |
| 3234 | logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{ |
| 3235 | "Err": err, "device-id": oo.deviceID}) |
| 3236 | return nil, err |
| 3237 | } |
| 3238 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3239 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3240 | if err != nil { |
| 3241 | logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{ |
| 3242 | "Err": err, "device-id": oo.deviceID}) |
| 3243 | return nil, err |
| 3244 | } |
| 3245 | |
| 3246 | omciRxCallbackPair := CallbackPair{ |
| 3247 | CbKey: tid, |
| 3248 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3249 | } |
| 3250 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3251 | if err != nil { |
| 3252 | logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{ |
| 3253 | "Err": err, "device-id": oo.deviceID}) |
| 3254 | return nil, err |
| 3255 | } |
| 3256 | logger.Debug(ctx, "send SIPUserData-Delete-msg done") |
| 3257 | return meInstance, nil |
| 3258 | } |
| 3259 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{ |
| 3260 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3261 | return nil, omciErr.GetError() |
| 3262 | } |
| 3263 | |
| 3264 | // SendCreateVoipApplicationServiceProfile nolint: unused |
| 3265 | func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3266 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3267 | tid := oo.GetNextTid(highPrio) |
| 3268 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3269 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3270 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3271 | |
| 3272 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3273 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3274 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3275 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3276 | if err != nil { |
| 3277 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err, |
| 3278 | "device-id": oo.deviceID}) |
| 3279 | return nil, err |
| 3280 | } |
| 3281 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3282 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3283 | if err != nil { |
| 3284 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3285 | "device-id": oo.deviceID}) |
| 3286 | return nil, err |
| 3287 | } |
| 3288 | |
| 3289 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3290 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3291 | } |
| 3292 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3293 | if err != nil { |
| 3294 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3295 | "device-id": oo.deviceID}) |
| 3296 | return nil, err |
| 3297 | } |
| 3298 | logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done") |
| 3299 | return meInstance, nil |
| 3300 | } |
| 3301 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3302 | "device-id": oo.deviceID}) |
| 3303 | return nil, omciErr.GetError() |
| 3304 | } |
| 3305 | |
| 3306 | // SendSetVoipApplicationServiceProfile nolint: unused |
| 3307 | func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3308 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3309 | tid := oo.GetNextTid(highPrio) |
| 3310 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3311 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3312 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3313 | |
| 3314 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3315 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3316 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3317 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3318 | if err != nil { |
| 3319 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err, |
| 3320 | "device-id": oo.deviceID}) |
| 3321 | return nil, err |
| 3322 | } |
| 3323 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3324 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3325 | if err != nil { |
| 3326 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3327 | "device-id": oo.deviceID}) |
| 3328 | return nil, err |
| 3329 | } |
| 3330 | |
| 3331 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3332 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3333 | } |
| 3334 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3335 | if err != nil { |
| 3336 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3337 | "device-id": oo.deviceID}) |
| 3338 | return nil, err |
| 3339 | } |
| 3340 | logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done") |
| 3341 | return meInstance, nil |
| 3342 | } |
| 3343 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3344 | "device-id": oo.deviceID}) |
| 3345 | return nil, omciErr.GetError() |
| 3346 | } |
| 3347 | |
| 3348 | // SendDeleteVoipApplicationServiceProfile nolint: unused |
| 3349 | func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3350 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3351 | tid := oo.GetNextTid(highPrio) |
| 3352 | logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3353 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3354 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3355 | |
| 3356 | meParams := me.ParamData{EntityID: aInstID} |
| 3357 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams) |
| 3358 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3359 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3360 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3361 | if err != nil { |
| 3362 | logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{ |
| 3363 | "Err": err, "device-id": oo.deviceID}) |
| 3364 | return nil, err |
| 3365 | } |
| 3366 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3367 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3368 | if err != nil { |
| 3369 | logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3370 | "Err": err, "device-id": oo.deviceID}) |
| 3371 | return nil, err |
| 3372 | } |
| 3373 | |
| 3374 | omciRxCallbackPair := CallbackPair{ |
| 3375 | CbKey: tid, |
| 3376 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3377 | } |
| 3378 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3379 | if err != nil { |
| 3380 | logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3381 | "Err": err, "device-id": oo.deviceID}) |
| 3382 | return nil, err |
| 3383 | } |
| 3384 | logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done") |
| 3385 | return meInstance, nil |
| 3386 | } |
| 3387 | logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{ |
| 3388 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3389 | return nil, omciErr.GetError() |
| 3390 | } |
| 3391 | |
| 3392 | // SendCreateSIPAgentConfigData nolint: unused |
| 3393 | func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3394 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3395 | tid := oo.GetNextTid(highPrio) |
| 3396 | logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3397 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3398 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3399 | |
| 3400 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3401 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3402 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3403 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3404 | if err != nil { |
| 3405 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err, |
| 3406 | "device-id": oo.deviceID}) |
| 3407 | return nil, err |
| 3408 | } |
| 3409 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3410 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3411 | if err != nil { |
| 3412 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err, |
| 3413 | "device-id": oo.deviceID}) |
| 3414 | return nil, err |
| 3415 | } |
| 3416 | |
| 3417 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3418 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3419 | } |
| 3420 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3421 | if err != nil { |
| 3422 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err, |
| 3423 | "device-id": oo.deviceID}) |
| 3424 | return nil, err |
| 3425 | } |
| 3426 | logger.Debug(ctx, "send SIPAgentConfigData-create-msg done") |
| 3427 | return meInstance, nil |
| 3428 | } |
| 3429 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3430 | "device-id": oo.deviceID}) |
| 3431 | return nil, omciErr.GetError() |
| 3432 | } |
| 3433 | |
| 3434 | // SendSetSIPAgentConfigData nolint: unused |
| 3435 | func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3436 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3437 | tid := oo.GetNextTid(highPrio) |
| 3438 | logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3439 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3440 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3441 | |
| 3442 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3443 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3444 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3445 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3446 | if err != nil { |
| 3447 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err, |
| 3448 | "device-id": oo.deviceID}) |
| 3449 | return nil, err |
| 3450 | } |
| 3451 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3452 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3453 | if err != nil { |
| 3454 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err, |
| 3455 | "device-id": oo.deviceID}) |
| 3456 | return nil, err |
| 3457 | } |
| 3458 | |
| 3459 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3460 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3461 | } |
| 3462 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3463 | if err != nil { |
| 3464 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err, |
| 3465 | "device-id": oo.deviceID}) |
| 3466 | return nil, err |
| 3467 | } |
| 3468 | logger.Debug(ctx, "send SIPAgentConfigData-set-msg done") |
| 3469 | return meInstance, nil |
| 3470 | } |
| 3471 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3472 | "device-id": oo.deviceID}) |
| 3473 | return nil, omciErr.GetError() |
| 3474 | } |
| 3475 | |
| 3476 | // SendDeleteSIPAgentConfigData nolint: unused |
| 3477 | func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3478 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3479 | tid := oo.GetNextTid(highPrio) |
| 3480 | logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3481 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3482 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3483 | |
| 3484 | meParams := me.ParamData{EntityID: aInstID} |
| 3485 | meInstance, omciErr := me.NewSipAgentConfigData(meParams) |
| 3486 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3487 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3488 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3489 | if err != nil { |
| 3490 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{ |
| 3491 | "Err": err, "device-id": oo.deviceID}) |
| 3492 | return nil, err |
| 3493 | } |
| 3494 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3495 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3496 | if err != nil { |
| 3497 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{ |
| 3498 | "Err": err, "device-id": oo.deviceID}) |
| 3499 | return nil, err |
| 3500 | } |
| 3501 | |
| 3502 | omciRxCallbackPair := CallbackPair{ |
| 3503 | CbKey: tid, |
| 3504 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3505 | } |
| 3506 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3507 | if err != nil { |
| 3508 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{ |
| 3509 | "Err": err, "device-id": oo.deviceID}) |
| 3510 | return nil, err |
| 3511 | } |
| 3512 | logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done") |
| 3513 | return meInstance, nil |
| 3514 | } |
| 3515 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3516 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3517 | return nil, omciErr.GetError() |
| 3518 | } |
| 3519 | |
| 3520 | // SendCreateTCPUDPConfigData nolint: unused |
| 3521 | func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3522 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3523 | tid := oo.GetNextTid(highPrio) |
| 3524 | logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3525 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3526 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3527 | |
| 3528 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3529 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3530 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3531 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3532 | if err != nil { |
| 3533 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err, |
| 3534 | "device-id": oo.deviceID}) |
| 3535 | return nil, err |
| 3536 | } |
| 3537 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3538 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3539 | if err != nil { |
| 3540 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err, |
| 3541 | "device-id": oo.deviceID}) |
| 3542 | return nil, err |
| 3543 | } |
| 3544 | |
| 3545 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3546 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3547 | } |
| 3548 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3549 | if err != nil { |
| 3550 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err, |
| 3551 | "device-id": oo.deviceID}) |
| 3552 | return nil, err |
| 3553 | } |
| 3554 | logger.Debug(ctx, "send TCPUDPConfigData-create-msg done") |
| 3555 | return meInstance, nil |
| 3556 | } |
| 3557 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3558 | "device-id": oo.deviceID}) |
| 3559 | return nil, omciErr.GetError() |
| 3560 | } |
| 3561 | |
| 3562 | // SendSetTCPUDPConfigData nolint: unused |
| 3563 | func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3564 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3565 | tid := oo.GetNextTid(highPrio) |
| 3566 | logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3567 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3568 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3569 | |
| 3570 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3571 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3572 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3573 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3574 | if err != nil { |
| 3575 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err, |
| 3576 | "device-id": oo.deviceID}) |
| 3577 | return nil, err |
| 3578 | } |
| 3579 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3580 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3581 | if err != nil { |
| 3582 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err, |
| 3583 | "device-id": oo.deviceID}) |
| 3584 | return nil, err |
| 3585 | } |
| 3586 | |
| 3587 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3588 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3589 | } |
| 3590 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3591 | if err != nil { |
| 3592 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err, |
| 3593 | "device-id": oo.deviceID}) |
| 3594 | return nil, err |
| 3595 | } |
| 3596 | logger.Debug(ctx, "send TCPUDPConfigData-set-msg done") |
| 3597 | return meInstance, nil |
| 3598 | } |
| 3599 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3600 | "device-id": oo.deviceID}) |
| 3601 | return nil, omciErr.GetError() |
| 3602 | } |
| 3603 | |
| 3604 | // SendDeleteTCPUDPConfigData nolint: unused |
| 3605 | func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3606 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3607 | tid := oo.GetNextTid(highPrio) |
| 3608 | logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3609 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3610 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3611 | |
| 3612 | meParams := me.ParamData{EntityID: aInstID} |
| 3613 | meInstance, omciErr := me.NewTcpUdpConfigData(meParams) |
| 3614 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3615 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3616 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3617 | if err != nil { |
| 3618 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{ |
| 3619 | "Err": err, "device-id": oo.deviceID}) |
| 3620 | return nil, err |
| 3621 | } |
| 3622 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3623 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3624 | if err != nil { |
| 3625 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{ |
| 3626 | "Err": err, "device-id": oo.deviceID}) |
| 3627 | return nil, err |
| 3628 | } |
| 3629 | |
| 3630 | omciRxCallbackPair := CallbackPair{ |
| 3631 | CbKey: tid, |
| 3632 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3633 | } |
| 3634 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3635 | if err != nil { |
| 3636 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{ |
| 3637 | "Err": err, "device-id": oo.deviceID}) |
| 3638 | return nil, err |
| 3639 | } |
| 3640 | logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done") |
| 3641 | return meInstance, nil |
| 3642 | } |
| 3643 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3644 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3645 | return nil, omciErr.GetError() |
| 3646 | } |
| 3647 | |
| 3648 | // SendCreateIPHostConfigData nolint: unused |
| 3649 | func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3650 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3651 | tid := oo.GetNextTid(highPrio) |
| 3652 | logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3653 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3654 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3655 | |
| 3656 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3657 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3658 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3659 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3660 | if err != nil { |
| 3661 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err, |
| 3662 | "device-id": oo.deviceID}) |
| 3663 | return nil, err |
| 3664 | } |
| 3665 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3666 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3667 | if err != nil { |
| 3668 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err, |
| 3669 | "device-id": oo.deviceID}) |
| 3670 | return nil, err |
| 3671 | } |
| 3672 | |
| 3673 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3674 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3675 | } |
| 3676 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3677 | if err != nil { |
| 3678 | logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err, |
| 3679 | "device-id": oo.deviceID}) |
| 3680 | return nil, err |
| 3681 | } |
| 3682 | logger.Debug(ctx, "send IPHostConfigData-create-msg done") |
| 3683 | return meInstance, nil |
| 3684 | } |
| 3685 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3686 | "device-id": oo.deviceID}) |
| 3687 | return nil, omciErr.GetError() |
| 3688 | } |
| 3689 | |
| 3690 | // SendSetIPHostConfigData nolint: unused |
| 3691 | func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3692 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3693 | tid := oo.GetNextTid(highPrio) |
| 3694 | logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3695 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3696 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3697 | |
| 3698 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3699 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3700 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3701 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3702 | if err != nil { |
| 3703 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err, |
| 3704 | "device-id": oo.deviceID}) |
| 3705 | return nil, err |
| 3706 | } |
| 3707 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3708 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3709 | if err != nil { |
| 3710 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err, |
| 3711 | "device-id": oo.deviceID}) |
| 3712 | return nil, err |
| 3713 | } |
| 3714 | |
| 3715 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3716 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3717 | } |
| 3718 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3719 | if err != nil { |
| 3720 | logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err, |
| 3721 | "device-id": oo.deviceID}) |
| 3722 | return nil, err |
| 3723 | } |
| 3724 | logger.Debug(ctx, "send IPHostConfigData-set-msg done") |
| 3725 | return meInstance, nil |
| 3726 | } |
| 3727 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3728 | "device-id": oo.deviceID}) |
| 3729 | return nil, omciErr.GetError() |
| 3730 | } |
| 3731 | |
| 3732 | // SendDeleteIPHostConfigData nolint: unused |
| 3733 | func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3734 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3735 | tid := oo.GetNextTid(highPrio) |
| 3736 | logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3737 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3738 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3739 | |
| 3740 | meParams := me.ParamData{EntityID: aInstID} |
| 3741 | meInstance, omciErr := me.NewIpHostConfigData(meParams) |
| 3742 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3743 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3744 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3745 | if err != nil { |
| 3746 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{ |
| 3747 | "Err": err, "device-id": oo.deviceID}) |
| 3748 | return nil, err |
| 3749 | } |
| 3750 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3751 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3752 | if err != nil { |
| 3753 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{ |
| 3754 | "Err": err, "device-id": oo.deviceID}) |
| 3755 | return nil, err |
| 3756 | } |
| 3757 | |
| 3758 | omciRxCallbackPair := CallbackPair{ |
| 3759 | CbKey: tid, |
| 3760 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3761 | } |
| 3762 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3763 | if err != nil { |
| 3764 | logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{ |
| 3765 | "Err": err, "device-id": oo.deviceID}) |
| 3766 | return nil, err |
| 3767 | } |
| 3768 | logger.Debug(ctx, "send IPHostConfigData-Delete-msg done") |
| 3769 | return meInstance, nil |
| 3770 | } |
| 3771 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{ |
| 3772 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3773 | return nil, omciErr.GetError() |
| 3774 | } |
| 3775 | |
| 3776 | // SendCreateRTPProfileData nolint: unused |
| 3777 | func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3778 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3779 | tid := oo.GetNextTid(highPrio) |
| 3780 | logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3781 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3782 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3783 | |
| 3784 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3785 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3786 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3787 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3788 | if err != nil { |
| 3789 | logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err, |
| 3790 | "device-id": oo.deviceID}) |
| 3791 | return nil, err |
| 3792 | } |
| 3793 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3794 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3795 | if err != nil { |
| 3796 | logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err, |
| 3797 | "device-id": oo.deviceID}) |
| 3798 | return nil, err |
| 3799 | } |
| 3800 | |
| 3801 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3802 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3803 | } |
| 3804 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3805 | if err != nil { |
| 3806 | logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err, |
| 3807 | "device-id": oo.deviceID}) |
| 3808 | return nil, err |
| 3809 | } |
| 3810 | logger.Debug(ctx, "send RTPProfileData-create-msg done") |
| 3811 | return meInstance, nil |
| 3812 | } |
| 3813 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3814 | "device-id": oo.deviceID}) |
| 3815 | return nil, omciErr.GetError() |
| 3816 | } |
| 3817 | |
| 3818 | // SendSetRTPProfileData nolint: unused |
| 3819 | func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3820 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3821 | tid := oo.GetNextTid(highPrio) |
| 3822 | logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3823 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3824 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3825 | |
| 3826 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3827 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3828 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3829 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3830 | if err != nil { |
| 3831 | logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err, |
| 3832 | "device-id": oo.deviceID}) |
| 3833 | return nil, err |
| 3834 | } |
| 3835 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3836 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3837 | if err != nil { |
| 3838 | logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err, |
| 3839 | "device-id": oo.deviceID}) |
| 3840 | return nil, err |
| 3841 | } |
| 3842 | |
| 3843 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3844 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3845 | } |
| 3846 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3847 | if err != nil { |
| 3848 | logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err, |
| 3849 | "device-id": oo.deviceID}) |
| 3850 | return nil, err |
| 3851 | } |
| 3852 | logger.Debug(ctx, "send RTPProfileData-set-msg done") |
| 3853 | return meInstance, nil |
| 3854 | } |
| 3855 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3856 | "device-id": oo.deviceID}) |
| 3857 | return nil, omciErr.GetError() |
| 3858 | } |
| 3859 | |
| 3860 | // SendDeleteRTPProfileData nolint: unused |
| 3861 | func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3862 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3863 | tid := oo.GetNextTid(highPrio) |
| 3864 | logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3865 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3866 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3867 | |
| 3868 | meParams := me.ParamData{EntityID: aInstID} |
| 3869 | meInstance, omciErr := me.NewRtpProfileData(meParams) |
| 3870 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3871 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3872 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3873 | if err != nil { |
| 3874 | logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{ |
| 3875 | "Err": err, "device-id": oo.deviceID}) |
| 3876 | return nil, err |
| 3877 | } |
| 3878 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3879 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3880 | if err != nil { |
| 3881 | logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{ |
| 3882 | "Err": err, "device-id": oo.deviceID}) |
| 3883 | return nil, err |
| 3884 | } |
| 3885 | |
| 3886 | omciRxCallbackPair := CallbackPair{ |
| 3887 | CbKey: tid, |
| 3888 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3889 | } |
| 3890 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3891 | if err != nil { |
| 3892 | logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{ |
| 3893 | "Err": err, "device-id": oo.deviceID}) |
| 3894 | return nil, err |
| 3895 | } |
| 3896 | logger.Debug(ctx, "send RTPProfileData-Delete-msg done") |
| 3897 | return meInstance, nil |
| 3898 | } |
| 3899 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{ |
| 3900 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3901 | return nil, omciErr.GetError() |
| 3902 | } |
| 3903 | |
| 3904 | // SendCreateNetworkDialPlanTable nolint: unused |
| 3905 | func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3906 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3907 | tid := oo.GetNextTid(highPrio) |
| 3908 | logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3909 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3910 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3911 | |
| 3912 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3913 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3914 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3915 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3916 | if err != nil { |
| 3917 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err, |
| 3918 | "device-id": oo.deviceID}) |
| 3919 | return nil, err |
| 3920 | } |
| 3921 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3922 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3923 | if err != nil { |
| 3924 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3925 | "device-id": oo.deviceID}) |
| 3926 | return nil, err |
| 3927 | } |
| 3928 | |
| 3929 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3930 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3931 | } |
| 3932 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3933 | if err != nil { |
| 3934 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3935 | "device-id": oo.deviceID}) |
| 3936 | return nil, err |
| 3937 | } |
| 3938 | logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done") |
| 3939 | return meInstance, nil |
| 3940 | } |
| 3941 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3942 | "device-id": oo.deviceID}) |
| 3943 | return nil, omciErr.GetError() |
| 3944 | } |
| 3945 | |
| 3946 | // SendSetNetworkDialPlanTable nolint: unused |
| 3947 | func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3948 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3949 | tid := oo.GetNextTid(highPrio) |
| 3950 | logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3951 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3952 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3953 | |
| 3954 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3955 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3956 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3957 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3958 | if err != nil { |
| 3959 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err, |
| 3960 | "device-id": oo.deviceID}) |
| 3961 | return nil, err |
| 3962 | } |
| 3963 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3964 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3965 | if err != nil { |
| 3966 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3967 | "device-id": oo.deviceID}) |
| 3968 | return nil, err |
| 3969 | } |
| 3970 | |
| 3971 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3972 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3973 | } |
| 3974 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3975 | if err != nil { |
| 3976 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3977 | "device-id": oo.deviceID}) |
| 3978 | return nil, err |
| 3979 | } |
| 3980 | logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done") |
| 3981 | return meInstance, nil |
| 3982 | } |
| 3983 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3984 | "device-id": oo.deviceID}) |
| 3985 | return nil, omciErr.GetError() |
| 3986 | } |
| 3987 | |
| 3988 | // SendDeleteNetworkDialPlanTable nolint: unused |
| 3989 | func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3990 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3991 | tid := oo.GetNextTid(highPrio) |
| 3992 | logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3993 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3994 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3995 | |
| 3996 | meParams := me.ParamData{EntityID: aInstID} |
| 3997 | meInstance, omciErr := me.NewNetworkDialPlanTable(meParams) |
| 3998 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3999 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 4000 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 4001 | if err != nil { |
| 4002 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{ |
| 4003 | "Err": err, "device-id": oo.deviceID}) |
| 4004 | return nil, err |
| 4005 | } |
| 4006 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4007 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 4008 | if err != nil { |
| 4009 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{ |
| 4010 | "Err": err, "device-id": oo.deviceID}) |
| 4011 | return nil, err |
| 4012 | } |
| 4013 | |
| 4014 | omciRxCallbackPair := CallbackPair{ |
| 4015 | CbKey: tid, |
| 4016 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4017 | } |
| 4018 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 4019 | if err != nil { |
| 4020 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{ |
| 4021 | "Err": err, "device-id": oo.deviceID}) |
| 4022 | return nil, err |
| 4023 | } |
| 4024 | logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done") |
| 4025 | return meInstance, nil |
| 4026 | } |
| 4027 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{ |
| 4028 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 4029 | return nil, omciErr.GetError() |
| 4030 | } |
| 4031 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4032 | // SendSyncTime sends SynchronizeTimeRequest |
| 4033 | func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 4034 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4035 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 4036 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 4037 | |
| 4038 | omciLayer := &omci.OMCI{ |
| 4039 | TransactionID: tid, |
| 4040 | MessageType: omci.SynchronizeTimeRequestType, |
| 4041 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4042 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4043 | } |
| 4044 | utcTime := time.Now().UTC() |
| 4045 | request := &omci.SynchronizeTimeRequest{ |
| 4046 | MeBasePacket: omci.MeBasePacket{ |
| 4047 | EntityClass: me.OnuGClassID, |
| 4048 | // Default Instance ID is 0 |
| 4049 | }, |
| 4050 | Year: uint16(utcTime.Year()), |
| 4051 | Month: uint8(utcTime.Month()), |
| 4052 | Day: uint8(utcTime.Day()), |
| 4053 | Hour: uint8(utcTime.Hour()), |
| 4054 | Minute: uint8(utcTime.Minute()), |
| 4055 | Second: uint8(utcTime.Second()), |
| 4056 | } |
| 4057 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4058 | pkt, err := SerializeOmciLayer(ctx, omciLayer, request) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4059 | if err != nil { |
| 4060 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 4061 | "device-id": oo.deviceID}) |
| 4062 | return err |
| 4063 | } |
| 4064 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4065 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4066 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4067 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4068 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4069 | if err != nil { |
| 4070 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 4071 | "device-id": oo.deviceID}) |
| 4072 | return err |
| 4073 | } |
| 4074 | logger.Debug(ctx, "send synchronize time request done") |
| 4075 | return nil |
| 4076 | } |
| 4077 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4078 | // SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance |
| 4079 | func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4080 | upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4081 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4082 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4083 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 4084 | meParam := me.ParamData{EntityID: entityID} |
| 4085 | var meInstance *me.ManagedEntity |
| 4086 | var omciErr me.OmciErrors |
| 4087 | if upstream { |
| 4088 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 4089 | } else { |
| 4090 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 4091 | } |
| 4092 | if omciErr.GetError() == nil { |
| 4093 | var omciLayer *omci.OMCI |
| 4094 | var msgLayer gopacket.SerializableLayer |
| 4095 | var err error |
| 4096 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4097 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4098 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4099 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4100 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4101 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4102 | } |
| 4103 | if err != nil { |
| 4104 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 4105 | 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] | 4106 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4107 | } |
| 4108 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4109 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4110 | if err != nil { |
| 4111 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 4112 | 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] | 4113 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4114 | } |
| 4115 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4116 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4117 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4118 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4119 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4120 | if err != nil { |
| 4121 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 4122 | 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] | 4123 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4124 | } |
| 4125 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 4126 | 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] | 4127 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4128 | } |
| 4129 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 4130 | 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] | 4131 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4132 | } |
| 4133 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4134 | // SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance |
| 4135 | func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4136 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4137 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4138 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4139 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4140 | meParam := me.ParamData{EntityID: entityID} |
| 4141 | var meInstance *me.ManagedEntity |
| 4142 | var omciErr me.OmciErrors |
| 4143 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 4144 | |
| 4145 | if omciErr.GetError() == nil { |
| 4146 | var omciLayer *omci.OMCI |
| 4147 | var msgLayer gopacket.SerializableLayer |
| 4148 | var err error |
| 4149 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4150 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4151 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4152 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4153 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4154 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4155 | } |
| 4156 | if err != nil { |
| 4157 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 4158 | 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] | 4159 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4160 | } |
| 4161 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4162 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4163 | if err != nil { |
| 4164 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 4165 | 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] | 4166 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4167 | } |
| 4168 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4169 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4170 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4171 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4172 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4173 | if err != nil { |
| 4174 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 4175 | 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] | 4176 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4177 | } |
| 4178 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 4179 | 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] | 4180 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4181 | } |
| 4182 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 4183 | 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] | 4184 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4185 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4186 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4187 | // SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance |
| 4188 | func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4189 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4190 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4191 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4192 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4193 | meParam := me.ParamData{EntityID: entityID} |
| 4194 | var meInstance *me.ManagedEntity |
| 4195 | var omciErr me.OmciErrors |
| 4196 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 4197 | |
| 4198 | if omciErr.GetError() == nil { |
| 4199 | var omciLayer *omci.OMCI |
| 4200 | var msgLayer gopacket.SerializableLayer |
| 4201 | var err error |
| 4202 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4203 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4204 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4205 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4206 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4207 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4208 | } |
| 4209 | if err != nil { |
| 4210 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 4211 | 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] | 4212 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4213 | } |
| 4214 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4215 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4216 | if err != nil { |
| 4217 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 4218 | 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] | 4219 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4220 | } |
| 4221 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4222 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4223 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4224 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4225 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4226 | if err != nil { |
| 4227 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 4228 | 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] | 4229 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4230 | } |
| 4231 | logger.Debugw(ctx, "send fec history data ME done", |
| 4232 | 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] | 4233 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4234 | } |
| 4235 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 4236 | 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] | 4237 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4238 | } |
| 4239 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4240 | // SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance |
| 4241 | func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4242 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4243 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4244 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4245 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4246 | meParam := me.ParamData{EntityID: entityID} |
| 4247 | var meInstance *me.ManagedEntity |
| 4248 | var omciErr me.OmciErrors |
| 4249 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 4250 | |
| 4251 | if omciErr.GetError() == nil { |
| 4252 | var omciLayer *omci.OMCI |
| 4253 | var msgLayer gopacket.SerializableLayer |
| 4254 | var err error |
| 4255 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4256 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4257 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4258 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4259 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4260 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4261 | } |
| 4262 | if err != nil { |
| 4263 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 4264 | 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] | 4265 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4266 | } |
| 4267 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4268 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4269 | if err != nil { |
| 4270 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 4271 | 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] | 4272 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4273 | } |
| 4274 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4275 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4276 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4277 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4278 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4279 | if err != nil { |
| 4280 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 4281 | 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] | 4282 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4283 | } |
| 4284 | logger.Debugw(ctx, "send gemport history data ME done", |
| 4285 | 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] | 4286 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4287 | } |
| 4288 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 4289 | 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] | 4290 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4291 | } |
| 4292 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4293 | // SendStartSoftwareDownload sends StartSoftwareDownloadRequest |
| 4294 | func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4295 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4296 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4297 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4298 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4299 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4300 | |
| 4301 | omciLayer := &omci.OMCI{ |
| 4302 | TransactionID: tid, |
| 4303 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 4304 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4305 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4306 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4307 | if aIsExtendedOmci { |
| 4308 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4309 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4310 | request := &omci.StartSoftwareDownloadRequest{ |
| 4311 | MeBasePacket: omci.MeBasePacket{ |
| 4312 | EntityClass: me.SoftwareImageClassID, |
| 4313 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4314 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4315 | }, |
| 4316 | WindowSize: aDownloadWindowSize, |
| 4317 | ImageSize: aFileLen, |
| 4318 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 4319 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 4320 | } |
| 4321 | |
| 4322 | var options gopacket.SerializeOptions |
| 4323 | options.FixLengths = true |
| 4324 | buffer := gopacket.NewSerializeBuffer() |
| 4325 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4326 | if err != nil { |
| 4327 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 4328 | "device-id": oo.deviceID}) |
| 4329 | return err |
| 4330 | } |
| 4331 | outgoingPacket := buffer.Bytes() |
| 4332 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4333 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4334 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4335 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4336 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4337 | if err != nil { |
| 4338 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 4339 | "device-id": oo.deviceID}) |
| 4340 | return err |
| 4341 | } |
| 4342 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4343 | return nil |
| 4344 | } |
| 4345 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4346 | // PrepareOnuSectionsOfWindow prepares a list of sections for each window |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 4347 | // Before invoking this function the oo.mutexTid needs to be be locked so that |
| 4348 | // GetOnuSwSecNextTid can be invoked without further locking |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4349 | func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context, |
| 4350 | aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4351 | omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) { |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4352 | //onuswsections uses only low prioirity tids |
| 4353 | tid := oo.GetOnuSwSecNextTid() |
| 4354 | logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4355 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4356 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection}) |
| 4357 | |
| 4358 | var omciTxReq OmciTransferStructure |
| 4359 | msgType := omci.DownloadSectionRequestType |
| 4360 | |
| 4361 | if aAckRequest > 0 { |
| 4362 | msgType = omci.DownloadSectionRequestWithResponseType |
| 4363 | |
| 4364 | } |
| 4365 | omciLayer := &omci.OMCI{ |
| 4366 | TransactionID: tid, |
| 4367 | MessageType: msgType, |
| 4368 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4369 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4370 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4371 | if aIsExtendedOmci { |
| 4372 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4373 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4374 | localSectionData := make([]byte, len(aSection)) |
| 4375 | |
| 4376 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
| 4377 | request := &omci.DownloadSectionRequest{ |
| 4378 | MeBasePacket: omci.MeBasePacket{ |
| 4379 | EntityClass: me.SoftwareImageClassID, |
| 4380 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4381 | Extended: aIsExtendedOmci, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4382 | }, |
| 4383 | SectionNumber: aDownloadSectionNo, |
| 4384 | SectionData: localSectionData, |
| 4385 | } |
| 4386 | |
| 4387 | var options gopacket.SerializeOptions |
| 4388 | options.FixLengths = true |
| 4389 | buffer := gopacket.NewSerializeBuffer() |
| 4390 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4391 | if err != nil { |
| 4392 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4393 | "device-id": oo.deviceID}) |
| 4394 | return omciTxReq, err |
| 4395 | } |
| 4396 | outgoingPacket := buffer.Bytes() |
| 4397 | |
| 4398 | omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket) |
| 4399 | |
| 4400 | if aAckRequest > 0 { |
| 4401 | // only the last section should have a timeout as an ack is required only for the last section of the window |
| 4402 | omciTxReq = OmciTransferStructure{ |
| 4403 | withFramePrint: true, |
| 4404 | OnuSwWindow: omciMsgsPerWindow, |
| 4405 | } |
| 4406 | return omciTxReq, nil |
| 4407 | } |
| 4408 | |
| 4409 | return omciTxReq, nil |
| 4410 | } |
| 4411 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 4412 | // SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4413 | func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context, |
| 4414 | aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) { |
| 4415 | if aOmciTxRequest.OnuSwWindow == nil { |
| 4416 | logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil", |
| 4417 | log.Fields{"device-id": oo.deviceID}) |
| 4418 | return |
| 4419 | |
| 4420 | } |
| 4421 | |
| 4422 | tid := oo.GetOnuSwSecLastTid() |
| 4423 | logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid}) |
| 4424 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4425 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4426 | } |
| 4427 | |
| 4428 | aOmciTxRequest.cbPair = omciRxCallbackPair |
| 4429 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey}) |
| 4430 | oo.mutexRxSchedMap.Lock() |
| 4431 | // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ... |
| 4432 | oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry |
| 4433 | oo.mutexRxSchedMap.Unlock() |
| 4434 | |
| 4435 | chSuccess := make(chan bool) |
| 4436 | aOmciTxRequest.chSuccess = chSuccess |
| 4437 | aOmciTxRequest.timeout = aTimeout |
| 4438 | aOmciTxRequest.retries = CDefaultRetries |
| 4439 | |
| 4440 | //tid := aOmciTxRequest.cbPair.CbKey |
| 4441 | oo.mutexMonReq.Lock() |
| 4442 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4443 | oo.mutexMonReq.Unlock() |
| 4444 | |
| 4445 | retries := aOmciTxRequest.retries |
| 4446 | retryCounter := 0 |
| 4447 | if aTimeout == 0 { |
| 4448 | logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID}) |
| 4449 | return |
| 4450 | } |
| 4451 | loop: |
| 4452 | for retryCounter <= retries { |
| 4453 | // the onu sw sections are enqueued only to the low priority queue |
| 4454 | oo.mutexLowPrioTxQueue.Lock() |
| 4455 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4456 | oo.mutexLowPrioTxQueue.Unlock() |
| 4457 | |
| 4458 | go oo.sendQueuedRequests(ctx) |
| 4459 | |
| 4460 | select { |
| 4461 | case success := <-chSuccess: |
| 4462 | if success { |
| 4463 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4464 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4465 | } else { |
| 4466 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4467 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4468 | } |
| 4469 | break loop |
| 4470 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4471 | if retryCounter == retries { |
Holger Hildebrandt | 2b10764 | 2022-12-09 07:56:23 +0000 | [diff] [blame] | 4472 | if oo.pBaseDeviceHandler.IsOltAvailable() { |
| 4473 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
| 4474 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4475 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc) |
| 4476 | } else { |
| 4477 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!", |
| 4478 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4479 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4480 | oo.incrementTxTimesouts() |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4481 | break loop |
| 4482 | } else { |
| 4483 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4484 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4485 | oo.incrementTxRetries() |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4486 | } |
| 4487 | } |
| 4488 | retryCounter++ |
| 4489 | } |
| 4490 | oo.mutexMonReq.Lock() |
| 4491 | delete(oo.monitoredRequests, tid) |
| 4492 | oo.mutexMonReq.Unlock() |
| 4493 | } |
| 4494 | |
| 4495 | func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4496 | var lastSection []byte |
| 4497 | if omciTxRequest.OnuSwWindow != nil { |
| 4498 | lastSection = omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1] |
| 4499 | } else { |
| 4500 | logger.Errorw(ctx, "invalid sw window received", log.Fields{"device-id": oo.deviceID}) |
| 4501 | return fmt.Errorf("invalid sw window received") |
| 4502 | } |
| 4503 | if omciTxRequest.withFramePrint { |
| 4504 | logger.Debugw(ctx, "sw-section-omci-message-to-send:", log.Fields{ |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4505 | "TxOmciMessage": hex.EncodeToString(lastSection), |
| 4506 | "device-id": oo.deviceID, |
| 4507 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 4508 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 4509 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 4510 | } |
| 4511 | sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow) |
| 4512 | if sendErr != nil { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4513 | 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] | 4514 | return sendErr |
| 4515 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4516 | numberOfNoArSections := len(omciTxRequest.OnuSwWindow.Messages) - 1 // last section of window is sent with AR expected |
| 4517 | if lastSection[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 4518 | oo.increaseBaseTxNoArFramesBy(ctx, uint32(numberOfNoArSections)) |
| 4519 | oo.incrementBaseTxArFrames() |
| 4520 | } else { |
| 4521 | oo.increaseExtTxNoArFramesBy(ctx, uint32(numberOfNoArSections)) |
| 4522 | oo.incrementExtTxArFrames() |
| 4523 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4524 | return nil |
| 4525 | } |
| 4526 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4527 | // SendDownloadSection sends DownloadSectionRequestWithResponse |
| 4528 | func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4529 | 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] | 4530 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4531 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4532 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4533 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4534 | |
| 4535 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 4536 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4537 | msgType := omci.DownloadSectionRequestType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4538 | var timeout int = 0 //default value for no response expected |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4539 | if aAckRequest > 0 { |
| 4540 | msgType = omci.DownloadSectionRequestWithResponseType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4541 | timeout = aTimeout |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4542 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4543 | omciLayer := &omci.OMCI{ |
| 4544 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4545 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4546 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4547 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4548 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4549 | if aIsExtendedOmci { |
| 4550 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4551 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4552 | localSectionData := make([]byte, len(aSection)) |
| 4553 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4554 | 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] | 4555 | request := &omci.DownloadSectionRequest{ |
| 4556 | MeBasePacket: omci.MeBasePacket{ |
| 4557 | EntityClass: me.SoftwareImageClassID, |
| 4558 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4559 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4560 | }, |
| 4561 | SectionNumber: aDownloadSectionNo, |
| 4562 | SectionData: localSectionData, |
| 4563 | } |
| 4564 | |
| 4565 | var options gopacket.SerializeOptions |
| 4566 | options.FixLengths = true |
| 4567 | buffer := gopacket.NewSerializeBuffer() |
| 4568 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4569 | if err != nil { |
| 4570 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4571 | "device-id": oo.deviceID}) |
| 4572 | return err |
| 4573 | } |
| 4574 | outgoingPacket := buffer.Bytes() |
| 4575 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4576 | //for initial debug purpose overrule the requested print state for some frames |
| 4577 | printFrame := aPrint |
| 4578 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 4579 | printFrame = true |
| 4580 | } |
| 4581 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4582 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4583 | // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway |
| 4584 | // (used to avoid retransmission of frames with the same TID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4585 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4586 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4587 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4588 | if err != nil { |
| 4589 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 4590 | "device-id": oo.deviceID}) |
| 4591 | return err |
| 4592 | } |
| 4593 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4594 | return nil |
| 4595 | } |
| 4596 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 4597 | // SendEndSoftwareDownload sends EndSoftwareDownloadRequest |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4598 | func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4599 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4600 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4601 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4602 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4603 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4604 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4605 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4606 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4607 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4608 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4609 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4610 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4611 | if aIsExtendedOmci { |
| 4612 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4613 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4614 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4615 | MeBasePacket: omci.MeBasePacket{ |
| 4616 | EntityClass: me.SoftwareImageClassID, |
| 4617 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4618 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4619 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4620 | CRC32: aImageCrc, |
| 4621 | ImageSize: aFileLen, |
| 4622 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 4623 | 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] | 4624 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4625 | |
| 4626 | var options gopacket.SerializeOptions |
| 4627 | options.FixLengths = true |
| 4628 | buffer := gopacket.NewSerializeBuffer() |
| 4629 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4630 | if err != nil { |
| 4631 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4632 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4633 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4634 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4635 | outgoingPacket := buffer.Bytes() |
| 4636 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4637 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4638 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4639 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4640 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4641 | if err != nil { |
| 4642 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 4643 | "device-id": oo.deviceID}) |
| 4644 | return err |
| 4645 | } |
| 4646 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4647 | return nil |
| 4648 | } |
| 4649 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4650 | // SendActivateSoftware sends ActivateSoftwareRequest |
| 4651 | func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4652 | rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4653 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4654 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4655 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4656 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4657 | |
| 4658 | omciLayer := &omci.OMCI{ |
| 4659 | TransactionID: tid, |
| 4660 | MessageType: omci.ActivateSoftwareRequestType, |
| 4661 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4662 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4663 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4664 | if aIsExtendedOmci { |
| 4665 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4666 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4667 | request := &omci.ActivateSoftwareRequest{ |
| 4668 | MeBasePacket: omci.MeBasePacket{ |
| 4669 | EntityClass: me.SoftwareImageClassID, |
| 4670 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4671 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4672 | }, |
| 4673 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 4674 | } |
| 4675 | |
| 4676 | var options gopacket.SerializeOptions |
| 4677 | options.FixLengths = true |
| 4678 | buffer := gopacket.NewSerializeBuffer() |
| 4679 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4680 | if err != nil { |
| 4681 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 4682 | "device-id": oo.deviceID}) |
| 4683 | return err |
| 4684 | } |
| 4685 | outgoingPacket := buffer.Bytes() |
| 4686 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4687 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4688 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4689 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4690 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4691 | if err != nil { |
| 4692 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 4693 | "device-id": oo.deviceID}) |
| 4694 | return err |
| 4695 | } |
| 4696 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4697 | return nil |
| 4698 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4699 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4700 | // SendCommitSoftware sends CommitSoftwareRequest |
| 4701 | func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4702 | rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4703 | tid := oo.GetNextTid(highPrio) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4704 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4705 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4706 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4707 | |
| 4708 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4709 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4710 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4711 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4712 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4713 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4714 | if aIsExtendedOmci { |
| 4715 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4716 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4717 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4718 | MeBasePacket: omci.MeBasePacket{ |
| 4719 | EntityClass: me.SoftwareImageClassID, |
| 4720 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4721 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4722 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4723 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4724 | |
| 4725 | var options gopacket.SerializeOptions |
| 4726 | options.FixLengths = true |
| 4727 | buffer := gopacket.NewSerializeBuffer() |
| 4728 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4729 | if err != nil { |
| 4730 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4731 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4732 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4733 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4734 | outgoingPacket := buffer.Bytes() |
| 4735 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4736 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4737 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4738 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4739 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4740 | if err != nil { |
| 4741 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 4742 | "device-id": oo.deviceID}) |
| 4743 | return err |
| 4744 | } |
| 4745 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4746 | return nil |
| 4747 | } |
| 4748 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 4749 | // SendSelfTestReq sends TestRequest |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4750 | func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error { |
| 4751 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4752 | logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID, |
| 4753 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4754 | "InstId": strconv.FormatInt(int64(instdID), 16)}) |
| 4755 | omciLayer := &omci.OMCI{ |
| 4756 | TransactionID: tid, |
| 4757 | MessageType: omci.TestRequestType, |
| 4758 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4759 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4760 | } |
| 4761 | |
| 4762 | var request *omci.OpticalLineSupervisionTestRequest |
| 4763 | switch classID { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4764 | case me.AniGClassID: |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4765 | request = &omci.OpticalLineSupervisionTestRequest{ |
| 4766 | MeBasePacket: omci.MeBasePacket{ |
| 4767 | EntityClass: classID, |
| 4768 | EntityInstance: instdID, |
| 4769 | }, |
| 4770 | SelectTest: uint8(7), // self test |
| 4771 | GeneralPurposeBuffer: uint16(0), |
| 4772 | VendorSpecificParameters: uint16(0), |
| 4773 | } |
| 4774 | default: |
| 4775 | logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID}) |
| 4776 | return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID) |
| 4777 | } |
| 4778 | // Test serialization back to former string |
| 4779 | var options gopacket.SerializeOptions |
| 4780 | options.FixLengths = true |
| 4781 | |
| 4782 | buffer := gopacket.NewSerializeBuffer() |
| 4783 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4784 | if err != nil { |
| 4785 | logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err, |
| 4786 | "device-id": oo.deviceID}) |
| 4787 | return err |
| 4788 | } |
| 4789 | outgoingPacket := buffer.Bytes() |
| 4790 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4791 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4792 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4793 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4794 | err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4795 | if err != nil { |
| 4796 | logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err, |
| 4797 | "device-id": oo.deviceID}) |
| 4798 | return err |
| 4799 | } |
| 4800 | logger.Debug(ctx, "send self test request done") |
| 4801 | return nil |
| 4802 | } |
| 4803 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 4804 | // nolint: gocyclo |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4805 | func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) { |
| 4806 | |
| 4807 | nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false) |
| 4808 | if err != nil { |
| 4809 | logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID}) |
| 4810 | return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID) |
| 4811 | } |
| 4812 | msgLayer := (*packet).Layer(nextLayer) |
| 4813 | if msgLayer != nil { |
| 4814 | // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers |
| 4815 | if failure := (*packet).ErrorLayer(); failure != nil { |
| 4816 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4817 | // In the case of MibUploadNextResponse, we let the packet pass so that later processing |
| 4818 | // can examine for UnkonwnMEs and UnknownAttributes |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 4819 | logger.Debug(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass", |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4820 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4821 | return false, nil |
| 4822 | } else if nextLayer == omci.LayerTypeGetResponse { |
| 4823 | if resp := msgLayer.(*omci.GetResponse); resp != nil { |
| 4824 | if resp.NextLayerType() == omci.LayerTypeUnknownAttributes { |
| 4825 | unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes) |
| 4826 | if unknownAttrLayer != nil { |
| 4827 | logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!", |
| 4828 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer}) |
| 4829 | return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID) |
| 4830 | } |
| 4831 | } |
| 4832 | } |
| 4833 | } |
| 4834 | // Try to decode any further error information |
| 4835 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
| 4836 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!", |
| 4837 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()}) |
| 4838 | return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID) |
| 4839 | } |
| 4840 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!", |
| 4841 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4842 | return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID) |
| 4843 | } |
| 4844 | } else if failure := (*packet).ErrorLayer(); failure != nil { |
| 4845 | // message layer could not be decoded, but at least check if additional failure information is available |
| 4846 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
Holger Hildebrandt | 93d183f | 2022-04-22 15:50:26 +0000 | [diff] [blame] | 4847 | errMsg := decodeFailure.String() |
| 4848 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4849 | if strings.Contains(strings.ToLower(errMsg), "table decode") { |
| 4850 | // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass |
| 4851 | // so that later processing can deal with it |
| 4852 | logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass", |
| 4853 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4854 | return false, nil |
| 4855 | } |
| 4856 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4857 | 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] | 4858 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg}) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4859 | return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID) |
| 4860 | } |
| 4861 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available", |
| 4862 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4863 | return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID) |
| 4864 | } else { |
| 4865 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID}) |
| 4866 | return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID) |
| 4867 | } |
| 4868 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4869 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4870 | if v == omciMsg.MessageType { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4871 | switch nextLayer { |
| 4872 | case omci.LayerTypeCreateResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4873 | if resp := msgLayer.(*omci.CreateResponse); resp != nil { |
| 4874 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4875 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4876 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4877 | } |
| 4878 | case omci.LayerTypeDeleteResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4879 | if resp := msgLayer.(*omci.DeleteResponse); resp != nil { |
| 4880 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4881 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4882 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4883 | } |
| 4884 | case omci.LayerTypeSetResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4885 | if resp := msgLayer.(*omci.SetResponse); resp != nil { |
| 4886 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4887 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4888 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4889 | } |
| 4890 | case omci.LayerTypeStartSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4891 | if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil { |
| 4892 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4893 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4894 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4895 | } |
| 4896 | case omci.LayerTypeEndSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4897 | if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil { |
| 4898 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4899 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4900 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4901 | } |
| 4902 | case omci.LayerTypeActivateSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4903 | if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil { |
| 4904 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4905 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4906 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4907 | } |
| 4908 | case omci.LayerTypeCommitSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4909 | if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil { |
| 4910 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4911 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4912 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4913 | } |
| 4914 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4915 | } |
| 4916 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4917 | return false, nil |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4918 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4919 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4920 | func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4921 | timeout := aOmciTxRequest.timeout |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4922 | if timeout == 0 { |
| 4923 | //timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4924 | // enqueue |
| 4925 | if aOmciTxRequest.highPrio { |
| 4926 | oo.mutexHighPrioTxQueue.Lock() |
| 4927 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4928 | oo.mutexHighPrioTxQueue.Unlock() |
| 4929 | } else { |
| 4930 | oo.mutexLowPrioTxQueue.Lock() |
| 4931 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4932 | oo.mutexLowPrioTxQueue.Unlock() |
| 4933 | } |
| 4934 | go oo.sendQueuedRequests(ctx) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4935 | } else { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4936 | //the supervised sending with waiting on the response (based on TID) is called in background |
| 4937 | // to avoid blocking of the sender for the complete OMCI handshake procedure |
| 4938 | // to stay consistent with the processing tested so far, sending of next messages of the same control procedure |
| 4939 | // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there) |
| 4940 | go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4941 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4942 | } |
| 4943 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4944 | func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4945 | chSuccess := make(chan bool) |
| 4946 | aOmciTxRequest.chSuccess = chSuccess |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4947 | tid := aOmciTxRequest.cbPair.CbKey |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4948 | oo.mutexMonReq.Lock() |
| 4949 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4950 | oo.mutexMonReq.Unlock() |
| 4951 | |
| 4952 | retries := aOmciTxRequest.retries |
| 4953 | retryCounter := 0 |
| 4954 | loop: |
| 4955 | for retryCounter <= retries { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4956 | // enqueue |
| 4957 | if aOmciTxRequest.highPrio { |
| 4958 | oo.mutexHighPrioTxQueue.Lock() |
| 4959 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4960 | oo.mutexHighPrioTxQueue.Unlock() |
| 4961 | } else { |
| 4962 | oo.mutexLowPrioTxQueue.Lock() |
| 4963 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4964 | oo.mutexLowPrioTxQueue.Unlock() |
| 4965 | } |
| 4966 | go oo.sendQueuedRequests(ctx) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4967 | |
| 4968 | select { |
| 4969 | case success := <-chSuccess: |
| 4970 | if success { |
| 4971 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4972 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4973 | } else { |
| 4974 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4975 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4976 | } |
| 4977 | break loop |
| 4978 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4979 | if retryCounter == retries { |
Holger Hildebrandt | 2b10764 | 2022-12-09 07:56:23 +0000 | [diff] [blame] | 4980 | if oo.pBaseDeviceHandler.IsOltAvailable() { |
| 4981 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
| 4982 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4983 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc) |
| 4984 | } else { |
| 4985 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!", |
| 4986 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4987 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4988 | oo.incrementTxTimesouts() |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4989 | break loop |
| 4990 | } else { |
| 4991 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4992 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4993 | oo.incrementTxRetries() |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4994 | } |
| 4995 | } |
| 4996 | retryCounter++ |
| 4997 | } |
| 4998 | oo.mutexMonReq.Lock() |
| 4999 | delete(oo.monitoredRequests, tid) |
| 5000 | oo.mutexMonReq.Unlock() |
| 5001 | } |
| 5002 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 5003 | // CancelRequestMonitoring terminates monitoring of outstanding omci requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5004 | func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) { |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5005 | logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5006 | oo.mutexMonReq.RLock() |
| 5007 | for k := range oo.monitoredRequests { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5008 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 5009 | select { |
| 5010 | case oo.monitoredRequests[k].chSuccess <- false: |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5011 | logger.Debugw(ctx, "send cancellation on omciRespChannel", |
| 5012 | log.Fields{"index": k, "device-id": oo.deviceID}) |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5013 | default: |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5014 | logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)", |
| 5015 | log.Fields{"index": k, "device-id": oo.deviceID}) |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5016 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5017 | } |
| 5018 | oo.mutexMonReq.RUnlock() |
| 5019 | } |
| 5020 | |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 5021 | // GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum |
| 5022 | // time consumed for retry processing of a particular OMCI-request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5023 | func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration { |
| 5024 | return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5025 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5026 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5027 | // SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance |
| 5028 | func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5029 | 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] | 5030 | tid := oo.GetNextTid(highPrio) |
nikesh.krishnan | 1ffb813 | 2023-05-23 03:44:13 +0530 | [diff] [blame] | 5031 | logger.Info(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5032 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 5033 | |
| 5034 | meParam := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 5035 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5036 | } |
| 5037 | var meInstance *me.ManagedEntity |
| 5038 | var omciErr me.OmciErrors |
| 5039 | if classID == me.EthernetFrameExtendedPmClassID { |
| 5040 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam) |
| 5041 | } else { |
| 5042 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam) |
| 5043 | } |
| 5044 | |
| 5045 | if omciErr.GetError() == nil { |
| 5046 | var omciLayer *omci.OMCI |
| 5047 | var msgLayer gopacket.SerializableLayer |
| 5048 | var err error |
| 5049 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5050 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 5051 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5052 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5053 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 5054 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5055 | } |
| 5056 | if err != nil { |
| 5057 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 5058 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5059 | return nil, err |
| 5060 | } |
| 5061 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 5062 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5063 | if err != nil { |
| 5064 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me", |
| 5065 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5066 | return nil, err |
| 5067 | } |
| 5068 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5069 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 5070 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5071 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5072 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5073 | if err != nil { |
| 5074 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 5075 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5076 | return nil, err |
| 5077 | } |
| 5078 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done", |
| 5079 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5080 | return meInstance, nil |
| 5081 | } |
| 5082 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 5083 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5084 | return nil, omciErr.GetError() |
| 5085 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5086 | |
| 5087 | // RLockMutexMonReq lock read access to monitoredRequests |
| 5088 | func (oo *OmciCC) RLockMutexMonReq() { |
| 5089 | oo.mutexMonReq.RLock() |
| 5090 | } |
| 5091 | |
| 5092 | // RUnlockMutexMonReq unlock read access to monitoredRequests |
| 5093 | func (oo *OmciCC) RUnlockMutexMonReq() { |
| 5094 | oo.mutexMonReq.RUnlock() |
| 5095 | } |
| 5096 | |
| 5097 | // GetMonitoredRequest get OmciTransferStructure for an omciTransID |
| 5098 | func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) { |
| 5099 | value, exist = oo.monitoredRequests[omciTransID] |
| 5100 | return value, exist |
| 5101 | } |
| 5102 | |
| 5103 | // SetChMonitoredRequest sets chSuccess to indicate whether response was received or not |
| 5104 | func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) { |
| 5105 | oo.monitoredRequests[omciTransID].chSuccess <- chVal |
| 5106 | } |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5107 | |
| 5108 | // SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me |
| 5109 | func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
| 5110 | rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
| 5111 | tid := oo.GetNextTid(highPrio) |
| 5112 | logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID, |
| 5113 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 5114 | |
| 5115 | meParams := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 5116 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5117 | } |
| 5118 | var meInstance *me.ManagedEntity |
| 5119 | var omciErr me.OmciErrors |
| 5120 | if classID == me.EthernetFrameExtendedPmClassID { |
| 5121 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams) |
| 5122 | } else { |
| 5123 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams) |
| 5124 | } |
| 5125 | |
| 5126 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5127 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5128 | if err != nil { |
| 5129 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 5130 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5131 | return nil, err |
| 5132 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 5133 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5134 | if err != nil { |
| 5135 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg", |
| 5136 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5137 | return nil, err |
| 5138 | } |
| 5139 | omciRxCallbackPair := CallbackPair{ |
| 5140 | CbKey: tid, |
| 5141 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 5142 | } |
| 5143 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 5144 | if err != nil { |
| 5145 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 5146 | log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5147 | return nil, err |
| 5148 | } |
| 5149 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done", |
| 5150 | log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5151 | return meInstance, nil |
| 5152 | } |
| 5153 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 5154 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5155 | return nil, omciErr.GetError() |
| 5156 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 5157 | |
| 5158 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 5159 | func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 5160 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 5161 | oo.pBaseDeviceHandler = nil |
| 5162 | oo.pOnuDeviceEntry = nil |
| 5163 | oo.pOnuAlarmManager = nil |
| 5164 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 5165 | |
| 5166 | // GetOmciCounters - TODO: add comment |
| 5167 | func (oo *OmciCC) GetOmciCounters() *extension.SingleGetValueResponse { |
| 5168 | oo.mutexCounters.RLock() |
| 5169 | defer oo.mutexCounters.RUnlock() |
| 5170 | resp := extension.SingleGetValueResponse{ |
| 5171 | Response: &extension.GetValueResponse{ |
| 5172 | Status: extension.GetValueResponse_OK, |
| 5173 | Response: &extension.GetValueResponse_OnuOmciStats{ |
| 5174 | OnuOmciStats: &extension.GetOnuOmciTxRxStatsResponse{}, |
| 5175 | }, |
| 5176 | }, |
| 5177 | } |
| 5178 | resp.Response.GetOnuOmciStats().BaseTxArFrames = oo.countersBase.txArFrames |
| 5179 | resp.Response.GetOnuOmciStats().BaseTxNoArFrames = oo.countersBase.txNoArFrames |
| 5180 | resp.Response.GetOnuOmciStats().BaseRxAkFrames = oo.countersBase.rxAkFrames |
| 5181 | resp.Response.GetOnuOmciStats().BaseRxNoAkFrames = oo.countersBase.rxNoAkFrames |
| 5182 | resp.Response.GetOnuOmciStats().ExtTxArFrames = oo.countersExt.txArFrames |
| 5183 | resp.Response.GetOnuOmciStats().ExtTxNoArFrames = oo.countersExt.txNoArFrames |
| 5184 | resp.Response.GetOnuOmciStats().ExtRxAkFrames = oo.countersExt.rxAkFrames |
| 5185 | resp.Response.GetOnuOmciStats().ExtRxNoAkFrames = oo.countersExt.rxNoAkFrames |
| 5186 | resp.Response.GetOnuOmciStats().TxOmciCounterRetries = oo.txRetries |
| 5187 | resp.Response.GetOnuOmciStats().TxOmciCounterTimeouts = oo.txTimeouts |
| 5188 | return &resp |
| 5189 | } |
| 5190 | |
| 5191 | // For more speed, separate functions for each counter |
| 5192 | |
| 5193 | func (oo *OmciCC) incrementBaseTxArFrames() { |
| 5194 | oo.mutexCounters.Lock() |
| 5195 | defer oo.mutexCounters.Unlock() |
| 5196 | oo.countersBase.txArFrames++ |
| 5197 | } |
| 5198 | |
| 5199 | func (oo *OmciCC) incrementExtTxArFrames() { |
| 5200 | oo.mutexCounters.Lock() |
| 5201 | defer oo.mutexCounters.Unlock() |
| 5202 | oo.countersExt.txArFrames++ |
| 5203 | } |
| 5204 | |
| 5205 | func (oo *OmciCC) incrementBaseRxAkFrames() { |
| 5206 | oo.mutexCounters.Lock() |
| 5207 | defer oo.mutexCounters.Unlock() |
| 5208 | oo.countersBase.rxAkFrames++ |
| 5209 | } |
| 5210 | |
| 5211 | func (oo *OmciCC) incrementExtRxAkFrames() { |
| 5212 | oo.mutexCounters.Lock() |
| 5213 | defer oo.mutexCounters.Unlock() |
| 5214 | oo.countersExt.rxAkFrames++ |
| 5215 | } |
| 5216 | |
| 5217 | func (oo *OmciCC) increaseBaseTxNoArFramesBy(ctx context.Context, value uint32) { |
| 5218 | oo.mutexCounters.Lock() |
| 5219 | defer oo.mutexCounters.Unlock() |
| 5220 | oo.countersBase.txNoArFrames += value |
| 5221 | } |
| 5222 | |
| 5223 | func (oo *OmciCC) increaseExtTxNoArFramesBy(ctx context.Context, value uint32) { |
| 5224 | oo.mutexCounters.Lock() |
| 5225 | defer oo.mutexCounters.Unlock() |
| 5226 | oo.countersExt.txNoArFrames += value |
| 5227 | } |
| 5228 | |
| 5229 | func (oo *OmciCC) incrementBaseRxNoAkFrames() { |
| 5230 | oo.mutexCounters.Lock() |
| 5231 | defer oo.mutexCounters.Unlock() |
| 5232 | oo.countersBase.rxNoAkFrames++ |
| 5233 | } |
| 5234 | |
| 5235 | func (oo *OmciCC) incrementExtRxNoAkFrames() { |
| 5236 | oo.mutexCounters.Lock() |
| 5237 | defer oo.mutexCounters.Unlock() |
| 5238 | oo.countersExt.rxNoAkFrames++ |
| 5239 | } |
| 5240 | |
| 5241 | func (oo *OmciCC) incrementTxRetries() { |
| 5242 | oo.mutexCounters.Lock() |
| 5243 | defer oo.mutexCounters.Unlock() |
| 5244 | oo.txRetries++ |
| 5245 | } |
| 5246 | |
| 5247 | func (oo *OmciCC) incrementTxTimesouts() { |
| 5248 | oo.mutexCounters.Lock() |
| 5249 | defer oo.mutexCounters.Unlock() |
| 5250 | oo.txTimeouts++ |
| 5251 | } |
Holger Hildebrandt | 7e13846 | 2023-03-29 12:12:14 +0000 | [diff] [blame] | 5252 | |
| 5253 | // NotifyAboutOnuConfigFailure - trigger ONU DeviceEvent to notify about ONU config failure |
| 5254 | func (oo *OmciCC) NotifyAboutOnuConfigFailure(ctx context.Context, errID string, meClassID me.ClassID, meEntityID uint16, |
| 5255 | meName string, meResult me.Results) { |
| 5256 | var description string |
| 5257 | if !oo.confFailMeAlreadyHandled(meClassID) { |
| 5258 | switch errID { |
| 5259 | case OnuConfigFailureResponseErr: |
| 5260 | description = OnuConfigFailureResponseErrDesc + meResult.String() + |
| 5261 | ", OMCI ME: " + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) + " (only first instance reported)" |
| 5262 | case OnuConfigFailureTimeout: |
| 5263 | description = OnuConfigFailureTimeoutDesc + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) + |
| 5264 | " (only first instance reported)" |
| 5265 | default: |
| 5266 | logger.Warnw(ctx, "method called with undefined errID", log.Fields{"errID": errID, "device-id": oo.deviceID}) |
| 5267 | return |
| 5268 | } |
| 5269 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, errID, description) |
| 5270 | oo.appendConfFailMe(meClassID) |
| 5271 | } |
| 5272 | } |
| 5273 | |
| 5274 | func (oo *OmciCC) confFailMeAlreadyHandled(meClassID me.ClassID) bool { |
| 5275 | oo.mutexConfFailMEs.RLock() |
| 5276 | defer oo.mutexConfFailMEs.RUnlock() |
| 5277 | for _, v := range oo.confFailMEs { |
| 5278 | if v == meClassID { |
| 5279 | return true |
| 5280 | } |
| 5281 | } |
| 5282 | return false |
| 5283 | } |
| 5284 | |
| 5285 | func (oo *OmciCC) appendConfFailMe(meClassID me.ClassID) { |
| 5286 | oo.mutexConfFailMEs.Lock() |
| 5287 | defer oo.mutexConfFailMEs.Unlock() |
| 5288 | oo.confFailMEs = append(oo.confFailMEs, meClassID) |
| 5289 | } |
| 5290 | |
| 5291 | // ResetConfFailMEs - reset list of stored config failure MEs |
| 5292 | func (oo *OmciCC) ResetConfFailMEs() { |
| 5293 | oo.mutexConfFailMEs.Lock() |
| 5294 | defer oo.mutexConfFailMEs.Unlock() |
| 5295 | oo.confFailMEs = nil |
| 5296 | } |