Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 17 | //Package common provides global definitions |
| 18 | package common |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "container/list" |
| 22 | "context" |
| 23 | "encoding/binary" |
| 24 | "encoding/hex" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 25 | "fmt" |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 26 | "strconv" |
Holger Hildebrandt | 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 | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 76 | const cMaxConsecutiveOmciTimeouts = 3 |
| 77 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 78 | // ### OMCI related definitions - end |
| 79 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 80 | //CallbackPairEntry to be used for OMCI send/receive correlation |
| 81 | type CallbackPairEntry struct { |
| 82 | CbRespChannel chan Message |
| 83 | CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error |
| 84 | FramePrint bool //true for printing |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 87 | //CallbackPair to be used for ReceiveCallback init |
| 88 | type CallbackPair struct { |
| 89 | CbKey uint16 |
| 90 | CbEntry CallbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 93 | // OmciTransferStructure - TODO: add comment |
| 94 | type OmciTransferStructure struct { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 95 | txFrame []byte |
| 96 | timeout int |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 97 | retries int |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 98 | highPrio bool |
| 99 | withFramePrint bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 100 | cbPair CallbackPair |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 101 | chSuccess chan bool |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 102 | OnuSwWindow *ia.OmciMessages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 105 | type txRxCounters struct { |
| 106 | txArFrames uint32 |
| 107 | txNoArFrames uint32 |
| 108 | rxAkFrames uint32 |
| 109 | rxNoAkFrames uint32 |
| 110 | } |
| 111 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 112 | //OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 113 | type OmciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 114 | enabled bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 115 | pBaseDeviceHandler IdeviceHandler |
| 116 | pOnuDeviceEntry IonuDeviceEntry |
| 117 | pOnuAlarmManager IonuAlarmManager |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 118 | deviceID string |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 119 | coreClient *vgrpc.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 120 | supportExtMsg bool |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 121 | rxOmciFrameError tOmciReceiveError |
| 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 | 68854a8 | 2022-09-05 07:00:21 +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 |
| 146 | mutexConsecutiveOmciTimeouts sync.RWMutex |
| 147 | consecutiveOmciTimeouts uint8 |
| 148 | mutexOmciAbortInProgress sync.RWMutex |
| 149 | omciAbortInProgress bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 152 | var responsesWithMibDataSync = []omci.MessageType{ |
| 153 | omci.CreateResponseType, |
| 154 | omci.DeleteResponseType, |
| 155 | omci.SetResponseType, |
| 156 | omci.StartSoftwareDownloadResponseType, |
| 157 | omci.EndSoftwareDownloadResponseType, |
| 158 | omci.ActivateSoftwareResponseType, |
| 159 | omci.CommitSoftwareResponseType, |
| 160 | } |
| 161 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 162 | //NewOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 163 | //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] | 164 | func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler, |
| 165 | onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager, |
| 166 | coreClient *vgrpc.Client) *OmciCC { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 167 | logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 168 | var omciCC OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 169 | omciCC.enabled = false |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 170 | omciCC.pBaseDeviceHandler = deviceHandler |
| 171 | omciCC.pOnuAlarmManager = onuAlarmManager |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 172 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 173 | omciCC.deviceID = deviceID |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 174 | omciCC.coreClient = coreClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 175 | omciCC.supportExtMsg = false |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 176 | omciCC.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 177 | omciCC.countersBase = txRxCounters{0, 0, 0, 0} |
| 178 | omciCC.countersExt = txRxCounters{0, 0, 0, 0} |
| 179 | omciCC.txRetries = 0 |
| 180 | omciCC.txTimeouts = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 181 | omciCC.tid = 0x1 |
| 182 | omciCC.hpTid = 0x8000 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 183 | omciCC.UploadSequNo = 0 |
| 184 | omciCC.UploadNoOfCmds = 0 |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 185 | omciCC.lowPrioTxQueue = list.New() |
| 186 | omciCC.highPrioTxQueue = list.New() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 187 | omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry) |
| 188 | omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure) |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 189 | omciCC.consecutiveOmciTimeouts = 0 |
| 190 | omciCC.omciAbortInProgress = false |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 191 | return &omciCC |
| 192 | } |
| 193 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 194 | //Stop stops/resets the omciCC |
| 195 | func (oo *OmciCC) Stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 196 | logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 197 | //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] | 198 | oo.CancelRequestMonitoring(ctx) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 199 | // clear the tx queues |
| 200 | oo.mutexHighPrioTxQueue.Lock() |
| 201 | oo.highPrioTxQueue.Init() |
| 202 | oo.mutexHighPrioTxQueue.Unlock() |
| 203 | oo.mutexLowPrioTxQueue.Lock() |
| 204 | oo.lowPrioTxQueue.Init() |
| 205 | oo.mutexLowPrioTxQueue.Unlock() |
| 206 | //clear the scheduler map |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 207 | oo.mutexRxSchedMap.Lock() |
| 208 | for k := range oo.rxSchedulerMap { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 209 | delete(oo.rxSchedulerMap, k) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 210 | } |
| 211 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 212 | //reset the high prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 213 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 214 | oo.hpTid = 0x8000 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 215 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 216 | //reset the low prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 217 | oo.mutexTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 218 | oo.tid = 1 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 219 | oo.mutexTid.Unlock() |
| 220 | //reset control values |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 221 | oo.UploadSequNo = 0 |
| 222 | oo.UploadNoOfCmds = 0 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 223 | oo.rxOmciFrameError = cOmciMessageReceiveNoError |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 224 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 225 | //reset the stats counter |
| 226 | oo.mutexCounters.Lock() |
| 227 | oo.countersBase = txRxCounters{0, 0, 0, 0} |
| 228 | oo.countersExt = txRxCounters{0, 0, 0, 0} |
| 229 | oo.txRetries = 0 |
| 230 | oo.txTimeouts = 0 |
| 231 | oo.mutexCounters.Unlock() |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 232 | return nil |
| 233 | } |
| 234 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 235 | // Rx handler for omci messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 236 | 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] | 237 | logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 238 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 239 | switch omciMsg.MessageType { |
| 240 | case omci.AlarmNotificationType: |
| 241 | data := OmciMessage{ |
| 242 | OmciMsg: omciMsg, |
| 243 | OmciPacket: packet, |
| 244 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 245 | go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 246 | return nil |
| 247 | default: |
| 248 | return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String()) |
| 249 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 250 | /* |
| 251 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 252 | rxOnuFrames++ |
| 253 | |
| 254 | switch msgType { |
| 255 | case AlarmNotification: |
| 256 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 257 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 258 | // python code was: |
| 259 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 260 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 261 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 262 | // |
| 263 | return errors.New("RxAlarmNotification unimplemented") |
| 264 | } |
| 265 | case AttributeValueChange: |
| 266 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 267 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 268 | // python code was: |
| 269 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 270 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 271 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 272 | // |
| 273 | return errors.New("RxAttributeValueChange unimplemented") |
| 274 | } |
| 275 | case TestResult: |
| 276 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 277 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 278 | // python code was: |
| 279 | //elif msg_type == EntityOperations.TestResult.value: |
| 280 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 281 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 282 | // |
| 283 | return errors.New("RxTestResult unimplemented") |
| 284 | } |
| 285 | default: |
| 286 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 287 | logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 288 | rxOnuDiscards++ |
| 289 | return errors.New("RxOnuMsgType unimplemented") |
| 290 | } |
| 291 | } |
| 292 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 295 | func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 296 | //assuming omci message content is hex coded! |
| 297 | // with restricted output of 16bytes would be ...rxMsg[:16] |
| 298 | logger.Debugw(ctx, "omci-message-received:", log.Fields{ |
| 299 | "RxOmciMessage": hex.EncodeToString(rxMsg), |
| 300 | "device-id": oo.deviceID}) |
| 301 | } |
| 302 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 303 | // ReceiveMessage - Rx handler for onu messages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 304 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 305 | // nolint: gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 306 | func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 307 | //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] | 308 | |
| 309 | if len(rxMsg) < 10 { |
| 310 | logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort", |
| 311 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 312 | if len(rxMsg) > 0 { |
| 313 | oo.printRxMessage(ctx, rxMsg) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 314 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 315 | return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID) |
| 316 | } |
| 317 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 318 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 319 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 320 | // (an extendedFormat message could be destroyed this way!) |
| 321 | trailerLenData := rxMsg[42:44] |
| 322 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
| 323 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
| 324 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 325 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 326 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 327 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 328 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 329 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 330 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 331 | } |
| 332 | } |
| 333 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 334 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 335 | // (an extendedFormat message could be destroyed this way!) |
| 336 | // extend/overwrite with trailer |
| 337 | trailer := make([]byte, 8) |
| 338 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 339 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 340 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 341 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 342 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 343 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 344 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
| 345 | } |
| 346 | } else { |
| 347 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 348 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 349 | oo.printRxMessage(ctx, rxMsg) |
| 350 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
| 351 | } |
| 352 | } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) { |
| 353 | if len(rxMsg) > 1980 { |
| 354 | logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort", |
| 355 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 356 | oo.printRxMessage(ctx, rxMsg) |
| 357 | return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 358 | } |
| 359 | } else { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 360 | logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort", |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 361 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 362 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 363 | return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 364 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 365 | decodeOptions := gopacket.DecodeOptions{ |
| 366 | Lazy: true, |
| 367 | NoCopy: true, |
| 368 | } |
| 369 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 370 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 371 | 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] | 372 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 373 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 374 | } |
| 375 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 376 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 377 | 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] | 378 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 379 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 380 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 381 | // insert some check on detected OMCI decoding issues and log them |
| 382 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 383 | // even though allowed from omci-lib due to set relaxed decoding |
| 384 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 385 | // (compare mib_sync.go unknownAttrLayer) |
| 386 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 387 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 388 | errMsg := failure.Error() |
| 389 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 390 | "device-id": oo.deviceID, "issue": errMsg}) |
| 391 | } |
| 392 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 393 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 394 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 395 | 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] | 396 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 397 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 398 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 399 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 400 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
| 401 | "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 402 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 403 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 404 | // We expect to find the TID in the oo.rxSchedulerMap |
| 405 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 406 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 407 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 408 | 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] | 409 | if omciMsg.TransactionID == 0 { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 410 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 411 | oo.incrementBaseRxNoAkFrames() |
| 412 | } else { |
| 413 | oo.incrementExtRxNoAkFrames() |
| 414 | } |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 415 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 416 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 417 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 418 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 419 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 420 | 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] | 421 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 422 | //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] | 423 | oo.mutexRxSchedMap.Lock() |
| 424 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 425 | if ok && rxCallbackEntry.CbFunction != nil { |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 426 | |
| 427 | // valid OMCI Response Message received - reset counter of consecutive OMCI timeouts |
| 428 | oo.mutexConsecutiveOmciTimeouts.Lock() |
| 429 | oo.consecutiveOmciTimeouts = 0 |
| 430 | oo.mutexConsecutiveOmciTimeouts.Unlock() |
| 431 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 432 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 433 | oo.printRxMessage(ctx, rxMsg) |
| 434 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 435 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 436 | oo.incrementBaseRxAkFrames() |
| 437 | } else { |
| 438 | oo.incrementExtRxAkFrames() |
| 439 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 440 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 441 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 442 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 443 | isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet) |
| 444 | if err != nil { |
| 445 | // qualified error logging already done in function above |
| 446 | if !rxCallbackEntry.FramePrint { |
| 447 | oo.printRxMessage(ctx, rxMsg) |
| 448 | } |
| 449 | return fmt.Errorf("could not decode further layers %s", oo.deviceID) |
| 450 | } |
| 451 | if isSuccessfulResponse { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 452 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 453 | } else { |
| 454 | logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type", |
| 455 | log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID}) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 456 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 457 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 458 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 459 | // so do not clean up the TransactionID in that case. |
| 460 | if omciMsg.MessageType != omci.TestResponseType { |
| 461 | // having posted the response the request is regarded as 'done' |
| 462 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 463 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 464 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 465 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 466 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 467 | oo.mutexRxSchedMap.Unlock() |
| 468 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 469 | oo.printRxMessage(ctx, rxMsg) |
| 470 | 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] | 471 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 472 | /* py code was: |
| 473 | Receive and OMCI message from the proxy channel to the OLT. |
| 474 | |
| 475 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 476 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 477 | """ |
| 478 | if not self.enabled: |
| 479 | return |
| 480 | |
| 481 | try: |
| 482 | now = arrow.utcnow() |
| 483 | d = None |
| 484 | |
| 485 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 486 | # save the current value of the entity_id_to_class_map, then |
| 487 | # replace it with our custom one before decode, and then finally |
| 488 | # restore it later. Tried other ways but really made the code messy. |
| 489 | saved_me_map = omci_entities.entity_id_to_class_map |
| 490 | omci_entities.entity_id_to_class_map = self._me_map |
| 491 | |
| 492 | try: |
| 493 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 494 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 495 | except KeyError as e: |
| 496 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 497 | 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] | 498 | rx_frame = self._decode_unknown_me(msg) |
| 499 | self._rx_unknown_me += 1 |
| 500 | |
| 501 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 502 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 503 | return |
| 504 | |
| 505 | finally: |
| 506 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 507 | |
| 508 | rx_tid = rx_frame.fields['transaction_id'] |
| 509 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 510 | 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] | 511 | # Filter the Test Result frame and route through receive onu |
| 512 | # message method. |
| 513 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 514 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 515 | return self._receive_onu_message(rx_frame) |
| 516 | |
| 517 | # Previously unreachable if this is the very first round-trip Rx or we |
| 518 | # have been running consecutive errors |
| 519 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 520 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 521 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 522 | |
| 523 | self._rx_frames += 1 |
| 524 | self._consecutive_errors = 0 |
| 525 | |
| 526 | try: |
| 527 | high_priority = self._tid_is_high_priority(rx_tid) |
| 528 | index = self._get_priority_index(high_priority) |
| 529 | |
| 530 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 531 | last_tx_tuple = self._tx_request[index] |
| 532 | |
| 533 | if last_tx_tuple is None or \ |
| 534 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 535 | # Possible late Rx on a message that timed-out |
| 536 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 537 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 538 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 539 | self._rx_unknown_tid += 1 |
| 540 | self._rx_late += 1 |
| 541 | return |
| 542 | |
| 543 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 544 | if dc is not None and not dc.cancelled and not dc.called: |
| 545 | dc.cancel() |
| 546 | |
| 547 | _secs = self._update_rx_tx_stats(now, ts) |
| 548 | |
| 549 | # Late arrival already serviced by a timeout? |
| 550 | if d.called: |
| 551 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 552 | 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] | 553 | return |
| 554 | |
| 555 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 556 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 557 | if d is not None: |
| 558 | return d.errback(failure.Failure(e)) |
| 559 | return |
| 560 | |
| 561 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 562 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 563 | tx_tid = tx_frame.fields['transaction_id']) |
| 564 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 565 | |
| 566 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 567 | self._rx_response[index] = rx_frame |
| 568 | d.callback(rx_frame) |
| 569 | |
| 570 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 571 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 572 | */ |
| 573 | } |
| 574 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 575 | /* |
| 576 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 577 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 578 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 579 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 580 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 581 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 582 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 583 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 584 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 585 | delete(oo.rxSchedulerMap, tid) |
| 586 | } |
| 587 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 588 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 589 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 590 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 591 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 592 | if timeout != 0 { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 593 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 594 | oo.mutexRxSchedMap.Lock() |
| 595 | // 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] | 596 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 597 | oo.mutexRxSchedMap.Unlock() |
| 598 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 599 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 600 | 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] | 601 | //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] | 602 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 603 | txFrame, |
| 604 | timeout, |
| 605 | retry, |
| 606 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 607 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 608 | receiveCallbackPair, |
| 609 | nil, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 610 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 611 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 612 | oo.mutexMonReq.Lock() |
| 613 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 614 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 615 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 616 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 617 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 618 | return nil |
| 619 | } |
| 620 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 621 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 622 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 623 | } |
| 624 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 625 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 626 | // Avoid accessing the txQueues from parallel send routines to block |
| 627 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 628 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 629 | // for the corresponding response too (t.b.d.). |
| 630 | oo.mutexSendQueuedRequests.Lock() |
| 631 | defer oo.mutexSendQueuedRequests.Unlock() |
| 632 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 633 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 634 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 635 | return |
| 636 | } |
| 637 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 638 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 639 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 640 | return |
| 641 | } |
| 642 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 643 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 644 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 645 | oo.mutexHighPrioTxQueue.Lock() |
| 646 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 647 | for oo.highPrioTxQueue.Len() > 0 { |
| 648 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 649 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 650 | // Element will be removed from the queue regardless of the send success, to prevent |
| 651 | // an accumulation of send requests for the same message in the event of an error. |
| 652 | // In this case, resend attempts for the message are ensured by our retry |
| 653 | // mechanism after omci-timeout. |
| 654 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 655 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 656 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 657 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 658 | } |
| 659 | return nil |
| 660 | } |
| 661 | |
| 662 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 663 | oo.mutexLowPrioTxQueue.Lock() |
| 664 | for oo.lowPrioTxQueue.Len() > 0 { |
| 665 | queueElement := oo.lowPrioTxQueue.Front() // First element |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 666 | // check if the element is for onu sw section |
| 667 | aOmciTxReq := queueElement.Value.(OmciTransferStructure) |
| 668 | if aOmciTxReq.OnuSwWindow != nil { |
| 669 | if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 670 | // Element will be removed from the queue regardless of the send success, to prevent |
| 671 | // an accumulation of send requests for the same message in the event of an error. |
| 672 | // In this case, resend attempts for the message are ensured by our retry |
| 673 | // mechanism after omci-timeout. |
| 674 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 675 | oo.mutexLowPrioTxQueue.Unlock() |
| 676 | return err |
| 677 | } |
| 678 | } else { |
| 679 | err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)) |
| 680 | if err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 681 | // Element will be removed from the queue regardless of the send success, to prevent |
| 682 | // an accumulation of send requests for the same message in the event of an error. |
| 683 | // In this case, resend attempts for the message are ensured by our retry |
| 684 | // mechanism after omci-timeout. |
| 685 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 686 | oo.mutexLowPrioTxQueue.Unlock() |
| 687 | return err |
| 688 | } |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 689 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 690 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 691 | // Interrupt the sending of low priority requests to process any high priority requests |
| 692 | // that may have arrived in the meantime |
| 693 | oo.mutexLowPrioTxQueue.Unlock() |
| 694 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 695 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 696 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 697 | oo.mutexLowPrioTxQueue.Lock() |
| 698 | } |
| 699 | |
| 700 | oo.mutexLowPrioTxQueue.Unlock() |
| 701 | return nil |
| 702 | } |
| 703 | |
| 704 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 705 | if omciTxRequest.withFramePrint { |
| 706 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 707 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 708 | "device-id": oo.deviceID, |
| 709 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 710 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 711 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 712 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 713 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 714 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 715 | ChildDeviceId: oo.deviceID, |
| 716 | Message: omciTxRequest.txFrame, |
| 717 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 718 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 719 | } |
| 720 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 721 | if sendErr != nil { |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 722 | 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] | 723 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 724 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 725 | if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 726 | oo.incrementBaseTxArFrames() |
| 727 | } else { |
| 728 | oo.incrementExtTxArFrames() |
| 729 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 730 | return nil |
| 731 | } |
| 732 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 733 | // GetNextTid - TODO: add comment |
| 734 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 735 | var next uint16 |
| 736 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 737 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 738 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 739 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 740 | if oo.hpTid < 0x8000 { |
| 741 | oo.hpTid = 0x8000 |
| 742 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 743 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 744 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 745 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 746 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 747 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 748 | if oo.tid >= 0x8000 { |
| 749 | oo.tid = 1 |
| 750 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 751 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 752 | } |
| 753 | return next |
| 754 | } |
| 755 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 756 | //GetOnuSwSecNextTid get the next low prio tid for the onu sw sections |
| 757 | //onu sw sections uses only low priority tids |
| 758 | //The mutexTid lock should be taken prior to using this function |
| 759 | func (oo *OmciCC) GetOnuSwSecNextTid() uint16 { |
| 760 | next := oo.tid |
| 761 | oo.tid++ |
| 762 | if oo.tid >= 0x8000 { |
| 763 | oo.tid = 1 |
| 764 | } |
| 765 | return next |
| 766 | } |
| 767 | |
| 768 | //GetOnuSwSecLastTid gets the last allocated tid |
| 769 | //The mutexTid lock should be taken prior to using this function |
| 770 | func (oo *OmciCC) GetOnuSwSecLastTid() uint16 { |
| 771 | next := oo.tid |
| 772 | lastAllocatedTid := next - 1 |
| 773 | return lastAllocatedTid |
| 774 | } |
| 775 | |
| 776 | //LockMutexTID locks mutexTid |
| 777 | func (oo *OmciCC) LockMutexTID() { |
| 778 | oo.mutexTid.Lock() |
| 779 | } |
| 780 | |
| 781 | //UnLockMutexTID unlocks mutexTid |
| 782 | func (oo *OmciCC) UnLockMutexTID() { |
| 783 | oo.mutexTid.Unlock() |
| 784 | } |
| 785 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 786 | // ################################################################################### |
| 787 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 788 | |
| 789 | // Serialize - TODO: add comment |
| 790 | 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] | 791 | omciLayer := &omci.OMCI{ |
| 792 | TransactionID: tid, |
| 793 | MessageType: msgType, |
| 794 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 795 | return SerializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 796 | } |
| 797 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 798 | // SerializeOmciLayer - TODO: add comment |
| 799 | 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] | 800 | var options gopacket.SerializeOptions |
| 801 | options.FixLengths = true |
| 802 | |
| 803 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 804 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 805 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 806 | 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] | 807 | return nil, err |
| 808 | } |
| 809 | return buffer.Bytes(), nil |
| 810 | } |
| 811 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 812 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 813 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 814 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 815 | hex.Encode(dst, omciPkt) |
| 816 | return dst, nil |
| 817 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 818 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 819 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 820 | //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] | 821 | 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] | 822 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 823 | 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] | 824 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 825 | |
| 826 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 827 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 828 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 829 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 830 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 831 | oo.mutexMonReq.RLock() |
| 832 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 833 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 834 | select { |
| 835 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 836 | default: |
| 837 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 838 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 839 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 840 | } else { |
| 841 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 842 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 843 | } |
| 844 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 845 | |
| 846 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 847 | // 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] | 848 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 849 | Type: OMCI, |
| 850 | Data: OmciMessage{ |
| 851 | OmciMsg: omciMsg, |
| 852 | OmciPacket: packet, |
| 853 | }, |
| 854 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 855 | //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] | 856 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 857 | |
| 858 | return nil |
| 859 | } |
| 860 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 861 | // SendMibReset sends MibResetRequest |
| 862 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 863 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 864 | logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 865 | request := &omci.MibResetRequest{ |
| 866 | MeBasePacket: omci.MeBasePacket{ |
| 867 | EntityClass: me.OnuDataClassID, |
| 868 | }, |
| 869 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 870 | tid := oo.GetNextTid(highPrio) |
| 871 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 872 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 873 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 874 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 875 | return err |
| 876 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 877 | omciRxCallbackPair := CallbackPair{ |
| 878 | CbKey: tid, |
| 879 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 880 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 881 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 882 | } |
| 883 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 884 | // SendReboot sends RebootRequest |
| 885 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 886 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 887 | request := &omci.RebootRequest{ |
| 888 | MeBasePacket: omci.MeBasePacket{ |
| 889 | EntityClass: me.OnuGClassID, |
| 890 | }, |
| 891 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 892 | tid := oo.GetNextTid(highPrio) |
| 893 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 894 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 895 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 896 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 897 | return err |
| 898 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 899 | omciRxCallbackPair := CallbackPair{ |
| 900 | CbKey: tid, |
| 901 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 902 | } |
| 903 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 904 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 905 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 906 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 907 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 908 | return err |
| 909 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 910 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 911 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 912 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 913 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 914 | return err |
| 915 | } |
| 916 | return nil |
| 917 | } |
| 918 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 919 | // SendMibUpload sends MibUploadRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 920 | 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] | 921 | 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] | 922 | |
| 923 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 924 | |
| 925 | omciLayer := &omci.OMCI{ |
| 926 | TransactionID: tid, |
| 927 | MessageType: omci.MibUploadRequestType, |
| 928 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 929 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 930 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 931 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 932 | request := &omci.MibUploadRequest{ |
| 933 | MeBasePacket: omci.MeBasePacket{ |
| 934 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 935 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 936 | }, |
| 937 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 938 | var options gopacket.SerializeOptions |
| 939 | options.FixLengths = true |
| 940 | |
| 941 | buffer := gopacket.NewSerializeBuffer() |
| 942 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 943 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 944 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 945 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 946 | return err |
| 947 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 948 | oo.UploadSequNo = 0 |
| 949 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 950 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 951 | omciRxCallbackPair := CallbackPair{ |
| 952 | CbKey: tid, |
| 953 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 954 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 955 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 956 | } |
| 957 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 958 | // SendMibUploadNext sends MibUploadNextRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 959 | 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] | 960 | 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] | 961 | |
| 962 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 963 | |
| 964 | omciLayer := &omci.OMCI{ |
| 965 | TransactionID: tid, |
| 966 | MessageType: omci.MibUploadNextRequestType, |
| 967 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 968 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 969 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 970 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 971 | request := &omci.MibUploadNextRequest{ |
| 972 | MeBasePacket: omci.MeBasePacket{ |
| 973 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 974 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 975 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 976 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 977 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 978 | var options gopacket.SerializeOptions |
| 979 | options.FixLengths = true |
| 980 | |
| 981 | buffer := gopacket.NewSerializeBuffer() |
| 982 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 983 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 984 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 985 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 986 | return err |
| 987 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 988 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 989 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 990 | omciRxCallbackPair := CallbackPair{ |
| 991 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 992 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 993 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 994 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 995 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 996 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 997 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 998 | } |
| 999 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1000 | // SendGetAllAlarm gets all alarm ME instances |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1001 | 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] | 1002 | 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] | 1003 | |
| 1004 | tid := oo.GetNextTid(highPrio) |
| 1005 | omciLayer := &omci.OMCI{ |
| 1006 | TransactionID: tid, |
| 1007 | MessageType: omci.GetAllAlarmsRequestType, |
| 1008 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1009 | } |
| 1010 | if isExtendedOmci { |
| 1011 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1012 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1013 | request := &omci.GetAllAlarmsRequest{ |
| 1014 | MeBasePacket: omci.MeBasePacket{ |
| 1015 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1016 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1017 | }, |
| 1018 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 1019 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1020 | var options gopacket.SerializeOptions |
| 1021 | options.FixLengths = true |
| 1022 | buffer := gopacket.NewSerializeBuffer() |
| 1023 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1024 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1025 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1026 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1027 | return err |
| 1028 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1029 | outgoingPacket := buffer.Bytes() |
| 1030 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1031 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1032 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1033 | omciRxCallbackPair := CallbackPair{ |
| 1034 | CbKey: tid, |
| 1035 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1036 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1037 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1038 | if err != nil { |
| 1039 | logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1040 | "device-id": oo.deviceID}) |
| 1041 | return err |
| 1042 | } |
| 1043 | logger.Debug(ctx, "send GetAllAlarmsRequest done") |
| 1044 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1045 | } |
| 1046 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1047 | // SendGetAllAlarmNext gets next alarm ME instance |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1048 | 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] | 1049 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 1050 | 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] | 1051 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1052 | |
| 1053 | tid := oo.GetNextTid(highPrio) |
| 1054 | omciLayer := &omci.OMCI{ |
| 1055 | TransactionID: tid, |
| 1056 | MessageType: omci.GetAllAlarmsNextRequestType, |
| 1057 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1058 | } |
| 1059 | if isExtendedOmci { |
| 1060 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1061 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1062 | request := &omci.GetAllAlarmsNextRequest{ |
| 1063 | MeBasePacket: omci.MeBasePacket{ |
| 1064 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1065 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1066 | }, |
| 1067 | CommandSequenceNumber: alarmUploadSeqNo, |
| 1068 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1069 | var options gopacket.SerializeOptions |
| 1070 | options.FixLengths = true |
| 1071 | buffer := gopacket.NewSerializeBuffer() |
| 1072 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1073 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1074 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1075 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1076 | return err |
| 1077 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1078 | outgoingPacket := buffer.Bytes() |
| 1079 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1080 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1081 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1082 | omciRxCallbackPair := CallbackPair{ |
| 1083 | CbKey: tid, |
| 1084 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1085 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1086 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1087 | if err != nil { |
| 1088 | logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1089 | "device-id": oo.deviceID}) |
| 1090 | return err |
| 1091 | } |
| 1092 | logger.Debug(ctx, "send GetAllAlarmsNextRequest done") |
| 1093 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1094 | } |
| 1095 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1096 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 1097 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1098 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1099 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1100 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1101 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1102 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1103 | EntityID: GalEthernetEID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1104 | Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1105 | } |
| 1106 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 1107 | if omciErr.GetError() == nil { |
| 1108 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1109 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
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 encode GalEnetProfileInstance for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1116 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1117 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1118 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1119 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1120 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1121 | } |
| 1122 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1123 | omciRxCallbackPair := CallbackPair{ |
| 1124 | CbKey: tid, |
| 1125 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1126 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1127 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1128 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1129 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1130 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1131 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1132 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1133 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1134 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1135 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1136 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1137 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1138 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1141 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1142 | // 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] | 1143 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1144 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1145 | 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] | 1146 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1147 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1148 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 1149 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1150 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 1151 | // read ONU-2G from DB ???? //TODO!!! |
| 1152 | meParams := me.ParamData{ |
| 1153 | EntityID: 0, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1154 | Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1155 | } |
| 1156 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 1157 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1158 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode ONU2-G instance for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1165 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1166 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1167 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1168 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1169 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1170 | } |
| 1171 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1172 | omciRxCallbackPair := CallbackPair{ |
| 1173 | CbKey: tid, |
| 1174 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1175 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1176 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1177 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1178 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1179 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1180 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1181 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1182 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1183 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1184 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1185 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1186 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1187 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1188 | } |
| 1189 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1190 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 1191 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 1192 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1193 | tid := oo.GetNextTid(highPrio) |
| 1194 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1195 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1196 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1197 | |
| 1198 | meParams := me.ParamData{ |
| 1199 | EntityID: instID, |
| 1200 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1201 | me.MacBridgeServiceProfile_Priority: 0x8000, |
| 1202 | me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s |
| 1203 | me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s |
| 1204 | me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s |
| 1205 | me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1206 | }, |
| 1207 | } |
| 1208 | |
| 1209 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1210 | if omciErr.GetError() == nil { |
| 1211 | //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] | 1212 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1213 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode MBSP for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1220 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1221 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1222 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1223 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1224 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1227 | omciRxCallbackPair := CallbackPair{ |
| 1228 | CbKey: tid, |
| 1229 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1230 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1231 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1232 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1233 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1234 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1235 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1236 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1237 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1238 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1239 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1240 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1241 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1242 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1245 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1246 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1247 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1248 | tid := oo.GetNextTid(highPrio) |
| 1249 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1250 | if idErr != nil { |
| 1251 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1252 | "Err": idErr, "device-id": oo.deviceID}) |
| 1253 | return nil, idErr |
| 1254 | } |
| 1255 | 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] | 1256 | "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] | 1257 | |
| 1258 | meParams := me.ParamData{ |
| 1259 | EntityID: instID, |
| 1260 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1261 | me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1262 | me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo, |
| 1263 | me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType), |
| 1264 | me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1265 | }, |
| 1266 | } |
| 1267 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1268 | if omciErr.GetError() == nil { |
| 1269 | //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] | 1270 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1271 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode MBPCD for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1278 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1279 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1280 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1281 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1282 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1285 | omciRxCallbackPair := CallbackPair{ |
| 1286 | CbKey: tid, |
| 1287 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1288 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1289 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1290 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1291 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1292 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1293 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1294 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1295 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1296 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1297 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1298 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1299 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1300 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1301 | } |
| 1302 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1303 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1304 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1305 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1306 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1307 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1308 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1309 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1310 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1311 | |
| 1312 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1313 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1314 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1315 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1316 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1317 | assType = uint8(10) // for VEIP |
| 1318 | } |
| 1319 | meParams := me.ParamData{ |
| 1320 | EntityID: instID, |
| 1321 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1322 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType, |
| 1323 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1324 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1325 | }, |
| 1326 | } |
| 1327 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1328 | if omciErr.GetError() == nil { |
| 1329 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1330 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1331 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode EVTOCD for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1338 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1339 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1340 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1341 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1342 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1343 | } |
| 1344 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1345 | omciRxCallbackPair := CallbackPair{ |
| 1346 | CbKey: tid, |
| 1347 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1348 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1349 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1350 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1351 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1352 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1353 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1354 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1355 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1356 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1357 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1358 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1359 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1360 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1361 | } |
| 1362 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1363 | // SendSetOnuGLS sets OnuG ME instance |
| 1364 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1365 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1366 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1367 | 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] | 1368 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1369 | |
| 1370 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1371 | meParams := me.ParamData{ |
| 1372 | EntityID: 0, |
| 1373 | Attributes: requestedAttributes, |
| 1374 | } |
| 1375 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1376 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1377 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode ONU-G instance for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1384 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1385 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1386 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1387 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1388 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1389 | } |
| 1390 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1391 | omciRxCallbackPair := CallbackPair{ |
| 1392 | CbKey: tid, |
| 1393 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1394 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1395 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1396 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1397 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1398 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1399 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1400 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1401 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1402 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1403 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1404 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1405 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1406 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1409 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1410 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1411 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1412 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1413 | 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] | 1414 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1415 | |
| 1416 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1417 | meParams := me.ParamData{ |
| 1418 | EntityID: aInstNo, |
| 1419 | Attributes: requestedAttributes, |
| 1420 | } |
| 1421 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1422 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1423 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode PPTPEthUni instance for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1430 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1431 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1432 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1433 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1434 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1437 | omciRxCallbackPair := CallbackPair{ |
| 1438 | CbKey: tid, |
| 1439 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1440 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1441 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1442 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1443 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1444 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1445 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1446 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1447 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1448 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1449 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1450 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1451 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1452 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1453 | } |
| 1454 | |
| 1455 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1456 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1457 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1458 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1459 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1460 | logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1461 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1462 | |
| 1463 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1464 | meParams := me.ParamData{ |
| 1465 | EntityID: aInstNo, |
| 1466 | Attributes: requestedAttributes, |
| 1467 | } |
| 1468 | meInstance, omciErr := me.NewUniG(meParams) |
| 1469 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1470 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1471 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1472 | logger.Errorw(ctx,"Cannot encode UNI-G instance for 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 | |
| 1477 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1478 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1479 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1480 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1481 | return nil |
| 1482 | } |
| 1483 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1484 | omciRxCallbackPair := CallbackPair{ |
| 1485 | CbKey: tid, |
| 1486 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1487 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1488 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1489 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1490 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1491 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1492 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1493 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1494 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1495 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1496 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1497 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1498 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1499 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1500 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1501 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1502 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1503 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1504 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1505 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1506 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1507 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1508 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1509 | |
| 1510 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1511 | meParams := me.ParamData{ |
| 1512 | EntityID: aInstNo, |
| 1513 | Attributes: requestedAttributes, |
| 1514 | } |
| 1515 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1516 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1517 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode VEIP instance for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1524 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1525 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1526 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1527 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1528 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1529 | } |
| 1530 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1531 | omciRxCallbackPair := CallbackPair{ |
| 1532 | CbKey: tid, |
| 1533 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1534 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1535 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1536 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1537 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1538 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1539 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1540 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1541 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1542 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1543 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1544 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1545 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1546 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1547 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1548 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1549 | // SendGetMe gets ME instance |
| 1550 | 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] | 1551 | timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1552 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1553 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1554 | 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] | 1555 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1556 | |
| 1557 | meParams := me.ParamData{ |
| 1558 | EntityID: entityID, |
| 1559 | Attributes: requestedAttributes, |
| 1560 | } |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1561 | var messageSet omci.DeviceIdent = omci.BaselineIdent |
| 1562 | if isExtendedOmci { |
| 1563 | messageSet = omci.ExtendedIdent |
| 1564 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1565 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1566 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1567 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1568 | 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] | 1569 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1570 | 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] | 1571 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1572 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1573 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1574 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1575 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1576 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1577 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1578 | omciRxCallbackPair := CallbackPair{ |
| 1579 | CbKey: tid, |
| 1580 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1581 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1582 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1583 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1584 | 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] | 1585 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1586 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1587 | 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] | 1588 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1589 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1590 | 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] | 1591 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1592 | } |
| 1593 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1594 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1595 | 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] | 1596 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1597 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1598 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1599 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1600 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1601 | |
| 1602 | request := &omci.GetRequest{ |
| 1603 | MeBasePacket: omci.MeBasePacket{ |
| 1604 | EntityInstance: entityID, |
| 1605 | EntityClass: classID, |
| 1606 | }, |
| 1607 | AttributeMask: requestedAttributesMask, |
| 1608 | } |
| 1609 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1610 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1611 | if err != nil { |
| 1612 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1613 | return err |
| 1614 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1615 | omciRxCallbackPair := CallbackPair{ |
| 1616 | CbKey: tid, |
| 1617 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1618 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1619 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1620 | if err != nil { |
| 1621 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1622 | return err |
| 1623 | } |
| 1624 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1625 | return nil |
| 1626 | } |
| 1627 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1628 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1629 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1630 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1631 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1632 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1633 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1634 | |
| 1635 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1636 | EntityID: aInstID, |
| 1637 | Attributes: me.AttributeValueMap{ |
| 1638 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1639 | me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF, |
| 1640 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF, |
| 1641 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF, |
| 1642 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF, |
| 1643 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF, |
| 1644 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF, |
| 1645 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF, |
| 1646 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF, |
| 1647 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF, |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1648 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1649 | } |
| 1650 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1651 | if omciErr.GetError() == nil { |
| 1652 | //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] | 1653 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1654 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode .1pMapper for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1661 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1662 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1663 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1664 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1665 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1666 | } |
| 1667 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1668 | omciRxCallbackPair := CallbackPair{ |
| 1669 | CbKey: tid, |
| 1670 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1671 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1672 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1673 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1674 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1675 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1676 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1677 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1678 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1679 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1680 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1681 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1682 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1683 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1684 | } |
| 1685 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1686 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1687 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1688 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1689 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1690 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1691 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1692 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1693 | |
| 1694 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1695 | if omciErr.GetError() == nil { |
| 1696 | //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] | 1697 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1698 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode MBPCD for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1705 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1706 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1707 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1708 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1709 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1710 | } |
| 1711 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1712 | omciRxCallbackPair := CallbackPair{ |
| 1713 | CbKey: tid, |
| 1714 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1715 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1716 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1717 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1718 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1719 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1720 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1721 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1722 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1723 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1724 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1725 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1726 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1727 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1728 | } |
| 1729 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1730 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1731 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1732 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1733 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1734 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1735 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1736 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1737 | |
| 1738 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1739 | if omciErr.GetError() == nil { |
| 1740 | //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] | 1741 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1742 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode GemNCTP for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1749 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1750 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1751 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1752 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1753 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1754 | } |
| 1755 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1756 | omciRxCallbackPair := CallbackPair{ |
| 1757 | CbKey: tid, |
| 1758 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1759 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1760 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1761 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1762 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1763 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1764 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1765 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1766 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1767 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1768 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1769 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1770 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1771 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1772 | } |
| 1773 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1774 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1775 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1776 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1777 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1778 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1779 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1780 | |
| 1781 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1782 | if omciErr.GetError() == nil { |
| 1783 | //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] | 1784 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1785 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1786 | if err != nil { |
| 1787 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1788 | "Err": err, "device-id": oo.deviceID}) |
| 1789 | return nil, err |
| 1790 | } |
| 1791 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1792 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1793 | if err != nil { |
| 1794 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1795 | "Err": err, "device-id": oo.deviceID}) |
| 1796 | return nil, err |
| 1797 | } |
| 1798 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1799 | omciRxCallbackPair := CallbackPair{ |
| 1800 | CbKey: tid, |
| 1801 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1802 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1803 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1804 | if err != nil { |
| 1805 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1806 | "Err": err, "device-id": oo.deviceID}) |
| 1807 | return nil, err |
| 1808 | } |
| 1809 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1810 | return meInstance, nil |
| 1811 | } |
| 1812 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1813 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1814 | return nil, omciErr.GetError() |
| 1815 | } |
| 1816 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1817 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1818 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1819 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1820 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1821 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1822 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1823 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1824 | |
| 1825 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1826 | if omciErr.GetError() == nil { |
| 1827 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1828 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1829 | oframe.TransactionID(tid)) |
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 encode GemIwTp for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1836 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1837 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1838 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1839 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1840 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1841 | } |
| 1842 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1843 | omciRxCallbackPair := CallbackPair{ |
| 1844 | CbKey: tid, |
| 1845 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1846 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1847 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1848 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1849 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1850 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1851 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1852 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1853 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1854 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1855 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1856 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1857 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1858 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1859 | } |
| 1860 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1861 | // SendSetTcontVar sets TCont ME instance |
| 1862 | func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1863 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1864 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1865 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1866 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1867 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1868 | |
| 1869 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1870 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1871 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode TCont for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1878 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1879 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1880 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1881 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1882 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1883 | } |
| 1884 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1885 | omciRxCallbackPair := CallbackPair{ |
| 1886 | CbKey: tid, |
| 1887 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1888 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1889 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1890 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1891 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1892 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1893 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1894 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1895 | logger.Debug(ctx, "send TCont-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1896 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1897 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1898 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1899 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1900 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1901 | } |
| 1902 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1903 | // SendSetPrioQueueVar sets PriorityQueue ME instance |
| 1904 | func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1905 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1906 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1907 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1908 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1909 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1910 | |
| 1911 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1912 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1913 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode PrioQueue for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1920 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1921 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1922 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1923 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1924 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1925 | } |
| 1926 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1927 | omciRxCallbackPair := CallbackPair{ |
| 1928 | CbKey: tid, |
| 1929 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1930 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1931 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1932 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1933 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1934 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1935 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1936 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1937 | logger.Debug(ctx, "send PrioQueue-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1938 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1939 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1940 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1941 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1942 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1943 | } |
| 1944 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1945 | // SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance |
| 1946 | func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1947 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1948 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1949 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1950 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1951 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1952 | |
| 1953 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1954 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1955 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode 1PMapper for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1962 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1963 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1964 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1965 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1966 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1967 | } |
| 1968 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1969 | omciRxCallbackPair := CallbackPair{ |
| 1970 | CbKey: tid, |
| 1971 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1972 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1973 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1974 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1975 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1976 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1977 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1978 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1979 | logger.Debug(ctx, "send 1PMapper-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1980 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1981 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1982 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1983 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1984 | return nil, omciErr.GetError() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1985 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1986 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1987 | // SendCreateVtfdVar creates VlanTaggingFilterData ME instance |
| 1988 | func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1989 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1990 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1991 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1992 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1993 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1994 | |
| 1995 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1996 | if omciErr.GetError() == nil { |
| 1997 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1998 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1999 | oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2000 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2001 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2002 | "Err": err, "device-id": oo.deviceID}) |
| 2003 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2004 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2005 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2009 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2010 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2011 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2012 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2013 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2014 | } |
| 2015 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2016 | omciRxCallbackPair := CallbackPair{ |
| 2017 | CbKey: tid, |
| 2018 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2019 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2020 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2021 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2022 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2023 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2024 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2025 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2026 | logger.Debug(ctx, "send VTFD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2027 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2028 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2029 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2030 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2031 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2032 | } |
| 2033 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2034 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2035 | func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2036 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2037 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2038 | 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] | 2039 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2040 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2041 | |
| 2042 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 2043 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2044 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 2045 | oframe.TransactionID(tid)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2046 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2047 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2048 | "Err": err, "device-id": oo.deviceID}) |
| 2049 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2050 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2051 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2055 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2056 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2057 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2058 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2059 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2060 | } |
| 2061 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2062 | omciRxCallbackPair := CallbackPair{ |
| 2063 | CbKey: tid, |
| 2064 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2065 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2066 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2067 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2068 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2069 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2070 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2071 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2072 | logger.Debug(ctx, "send VTFD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2073 | return meInstance, nil |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2074 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2075 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2076 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2077 | return nil, omciErr.GetError() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2078 | } |
| 2079 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2080 | // SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2081 | func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2082 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2083 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2084 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2085 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2086 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2087 | |
| 2088 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2089 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2090 | //EnhancedMode not yet supported, used with default options |
| 2091 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 2092 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
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 encode EVTOCD for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2099 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2100 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2101 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2102 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2103 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2104 | } |
| 2105 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2106 | omciRxCallbackPair := CallbackPair{ |
| 2107 | CbKey: tid, |
| 2108 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2109 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2110 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2111 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2112 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2113 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2114 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2115 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2116 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2117 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2118 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2119 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2120 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2121 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2122 | } |
| 2123 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2124 | // SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2125 | func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2126 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2127 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2128 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2129 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2130 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2131 | |
| 2132 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2133 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2134 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
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 encode EVTOCD for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2141 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2142 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2143 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2144 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2145 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2146 | } |
| 2147 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2148 | omciRxCallbackPair := CallbackPair{ |
| 2149 | CbKey: tid, |
| 2150 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2151 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2152 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2153 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2154 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2155 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2156 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2157 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2158 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2159 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2160 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2161 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2162 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2163 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2164 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2165 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2166 | // SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance |
| 2167 | func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2168 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2169 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2170 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2171 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2172 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2173 | |
| 2174 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2175 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2176 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
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 encode EVTOCD for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2183 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2184 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2185 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2186 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2187 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2188 | } |
| 2189 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2190 | omciRxCallbackPair := CallbackPair{ |
| 2191 | CbKey: tid, |
| 2192 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2193 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2194 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2195 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2196 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2197 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2198 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2199 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2200 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2201 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2202 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2203 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2204 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2205 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2206 | } |
| 2207 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2208 | // SendDeleteVtfd deletes VlanTaggingFilterData ME instance |
| 2209 | func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2210 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2211 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2212 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2213 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2214 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2215 | |
| 2216 | meParams := me.ParamData{EntityID: aInstID} |
| 2217 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 2218 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2219 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2220 | oframe.TransactionID(tid)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2221 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2222 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2223 | "Err": err, "device-id": oo.deviceID}) |
| 2224 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2225 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2226 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2230 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2231 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2232 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2233 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2234 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2235 | } |
| 2236 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2237 | omciRxCallbackPair := CallbackPair{ |
| 2238 | CbKey: tid, |
| 2239 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2240 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2241 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2242 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2243 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2244 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2245 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2246 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2247 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2248 | return meInstance, nil |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2249 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2250 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2251 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2252 | return nil, omciErr.GetError() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2253 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2254 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2255 | // SendCreateTDVar creates TrafficDescriptor ME instance |
| 2256 | func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2257 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2258 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2259 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2260 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2261 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2262 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2263 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2264 | if err != nil { |
| 2265 | 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] | 2266 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2267 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2268 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2269 | if err != nil { |
| 2270 | 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] | 2271 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2272 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2273 | omciRxCallbackPair := CallbackPair{ |
| 2274 | CbKey: tid, |
| 2275 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2276 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2277 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2278 | if err != nil { |
| 2279 | 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] | 2280 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2281 | } |
| 2282 | logger.Debug(ctx, "send TD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2283 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2284 | } |
| 2285 | 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] | 2286 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2290 | func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2291 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2292 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2293 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2294 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2295 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2296 | |
| 2297 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2298 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2299 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2300 | if err != nil { |
| 2301 | 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] | 2302 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2303 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2304 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2305 | if err != nil { |
| 2306 | 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] | 2307 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2308 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2309 | omciRxCallbackPair := CallbackPair{ |
| 2310 | CbKey: tid, |
| 2311 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2312 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2313 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2314 | if err != nil { |
| 2315 | 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] | 2316 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2317 | } |
| 2318 | logger.Debug(ctx, "send TD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2319 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2320 | } |
| 2321 | 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] | 2322 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2323 | |
| 2324 | } |
| 2325 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2326 | // SendDeleteTD - TODO: add comment |
| 2327 | func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2328 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2329 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2330 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2331 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2332 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2333 | |
| 2334 | meParams := me.ParamData{EntityID: aInstID} |
| 2335 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 2336 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2337 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2338 | if err != nil { |
| 2339 | 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] | 2340 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2341 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2342 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2343 | if err != nil { |
| 2344 | 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] | 2345 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2346 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2347 | omciRxCallbackPair := CallbackPair{ |
| 2348 | CbKey: tid, |
| 2349 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2350 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2351 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2352 | if err != nil { |
| 2353 | 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] | 2354 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2355 | } |
| 2356 | logger.Debug(ctx, "send TD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2357 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2358 | } |
| 2359 | 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] | 2360 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2361 | |
| 2362 | } |
| 2363 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2364 | // SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance |
| 2365 | func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2366 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2367 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2368 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2369 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2370 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2371 | |
| 2372 | meParams := me.ParamData{EntityID: aInstID} |
| 2373 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2374 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2375 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2376 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2377 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2378 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2379 | "Err": err, "device-id": oo.deviceID}) |
| 2380 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2381 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2382 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2386 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2387 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2388 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2389 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2390 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2391 | } |
| 2392 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2393 | omciRxCallbackPair := CallbackPair{ |
| 2394 | CbKey: tid, |
| 2395 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2396 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2397 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2398 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2399 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2400 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2401 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2402 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2403 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2404 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2405 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2406 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2407 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2408 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2409 | } |
| 2410 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2411 | // SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance |
| 2412 | func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2413 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2414 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2415 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2416 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2417 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2418 | |
| 2419 | meParams := me.ParamData{EntityID: aInstID} |
| 2420 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2421 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2422 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2423 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2424 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2425 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2426 | "Err": err, "device-id": oo.deviceID}) |
| 2427 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2428 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2429 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2433 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2434 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2435 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2436 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2437 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2438 | } |
| 2439 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2440 | omciRxCallbackPair := CallbackPair{ |
| 2441 | CbKey: tid, |
| 2442 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2443 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2444 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2445 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2446 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2447 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2448 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2449 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2450 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2451 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2452 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2453 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2454 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2455 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2456 | } |
| 2457 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2458 | // SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance |
| 2459 | func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2460 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2461 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2462 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2463 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2464 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2465 | |
| 2466 | meParams := me.ParamData{EntityID: aInstID} |
| 2467 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2468 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2469 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2470 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2471 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2472 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2473 | "Err": err, "device-id": oo.deviceID}) |
| 2474 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2475 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2476 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2480 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2481 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2482 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2483 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2484 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2485 | } |
| 2486 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2487 | omciRxCallbackPair := CallbackPair{ |
| 2488 | CbKey: tid, |
| 2489 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2490 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2491 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2492 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2493 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2494 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2495 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2496 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2497 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2498 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2499 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2500 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2501 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2502 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2503 | } |
| 2504 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2505 | // SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance |
| 2506 | func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2507 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2508 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2509 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2510 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2511 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2512 | |
| 2513 | meParams := me.ParamData{EntityID: aInstID} |
| 2514 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2515 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2516 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2517 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2518 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2519 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2520 | "Err": err, "device-id": oo.deviceID}) |
| 2521 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2522 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2523 | // (relevant to all used sendXX() methods and their error conditions) |
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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2527 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2528 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2529 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2530 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2531 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2532 | } |
| 2533 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2534 | omciRxCallbackPair := CallbackPair{ |
| 2535 | CbKey: tid, |
| 2536 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2537 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2538 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2539 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2540 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2541 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2542 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2543 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2544 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2545 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2546 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2547 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2548 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2549 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2550 | } |
| 2551 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2552 | // SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance |
| 2553 | func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2554 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2555 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2556 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2557 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2558 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2559 | |
| 2560 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2561 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2562 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2563 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2564 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2565 | 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] | 2566 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2567 | } |
| 2568 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2569 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2570 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2571 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2572 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2573 | } |
| 2574 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2575 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2576 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2577 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2578 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2579 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2580 | 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] | 2581 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2582 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2583 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2584 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2585 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2586 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2587 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2588 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2589 | } |
| 2590 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2591 | // SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance |
| 2592 | func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2593 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2594 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2595 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2596 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2597 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2598 | |
| 2599 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2600 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2601 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2602 | oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2603 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2604 | 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] | 2605 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2606 | } |
| 2607 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2608 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2609 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2610 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2611 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2612 | } |
| 2613 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2614 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2615 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2616 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2617 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2618 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2619 | 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] | 2620 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2621 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2622 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2623 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2624 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2625 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2626 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2627 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2628 | } |
| 2629 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2630 | // SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance |
| 2631 | func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2632 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2633 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2634 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2635 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2636 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2637 | |
| 2638 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2639 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2640 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2641 | oframe.AddDefaults(true)) |
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 encode MulticastOperationProfile for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2648 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2649 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2650 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2651 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2652 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2653 | } |
| 2654 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2655 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2656 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2657 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2658 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2659 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2660 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
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, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2663 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2664 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2665 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2666 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2667 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2668 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2669 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2670 | } |
| 2671 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2672 | // SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance |
| 2673 | func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2674 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2675 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2676 | logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2677 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2678 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2679 | |
| 2680 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2681 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2682 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2683 | oframe.AddDefaults(true)) |
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 encode MulticastOperationProfile for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2690 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2691 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2692 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2693 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2694 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2695 | } |
| 2696 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2697 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2698 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2699 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2700 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2701 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2702 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
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, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2705 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2706 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2707 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2708 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2709 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2710 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2711 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2712 | } |
| 2713 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2714 | // SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance |
| 2715 | func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2716 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2717 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2718 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2719 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2720 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2721 | |
| 2722 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2723 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2724 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2725 | oframe.AddDefaults(true)) |
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 encode MulticastSubConfigInfo for 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2732 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2733 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2734 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2735 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2736 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2737 | } |
| 2738 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2739 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2740 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2741 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2742 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2743 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2744 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
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, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2747 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2748 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2749 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2750 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2751 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2752 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2753 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2754 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2755 | |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2756 | // SendCreateVoipVoiceCTP nolint: unused |
| 2757 | func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2758 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2759 | tid := oo.GetNextTid(highPrio) |
| 2760 | logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2761 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2762 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2763 | |
| 2764 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2765 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2766 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2767 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2768 | if err != nil { |
| 2769 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err, |
| 2770 | "device-id": oo.deviceID}) |
| 2771 | return nil, err |
| 2772 | } |
| 2773 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2774 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2775 | if err != nil { |
| 2776 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err, |
| 2777 | "device-id": oo.deviceID}) |
| 2778 | return nil, err |
| 2779 | } |
| 2780 | |
| 2781 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2782 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2783 | } |
| 2784 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2785 | if err != nil { |
| 2786 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err, |
| 2787 | "device-id": oo.deviceID}) |
| 2788 | return nil, err |
| 2789 | } |
| 2790 | logger.Debug(ctx, "send VoipVoiceCTP-create-msg done") |
| 2791 | return meInstance, nil |
| 2792 | } |
| 2793 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2794 | "device-id": oo.deviceID}) |
| 2795 | return nil, omciErr.GetError() |
| 2796 | } |
| 2797 | |
| 2798 | // SendSetVoipVoiceCTP nolint: unused |
| 2799 | func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2800 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2801 | tid := oo.GetNextTid(highPrio) |
| 2802 | logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2803 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2804 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2805 | |
| 2806 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2807 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2808 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2809 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2810 | if err != nil { |
| 2811 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err, |
| 2812 | "device-id": oo.deviceID}) |
| 2813 | return nil, err |
| 2814 | } |
| 2815 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2816 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2817 | if err != nil { |
| 2818 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err, |
| 2819 | "device-id": oo.deviceID}) |
| 2820 | return nil, err |
| 2821 | } |
| 2822 | |
| 2823 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2824 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2825 | } |
| 2826 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2827 | if err != nil { |
| 2828 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err, |
| 2829 | "device-id": oo.deviceID}) |
| 2830 | return nil, err |
| 2831 | } |
| 2832 | logger.Debug(ctx, "send VoipVoiceCTP-set-msg done") |
| 2833 | return meInstance, nil |
| 2834 | } |
| 2835 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2836 | "device-id": oo.deviceID}) |
| 2837 | return nil, omciErr.GetError() |
| 2838 | } |
| 2839 | |
| 2840 | // SendDeleteVoipVoiceCTP nolint: unused |
| 2841 | func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2842 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2843 | tid := oo.GetNextTid(highPrio) |
| 2844 | logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2845 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2846 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2847 | |
| 2848 | meParams := me.ParamData{EntityID: aInstID} |
| 2849 | meInstance, omciErr := me.NewVoipVoiceCtp(meParams) |
| 2850 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2851 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2852 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2853 | if err != nil { |
| 2854 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{ |
| 2855 | "Err": err, "device-id": oo.deviceID}) |
| 2856 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2857 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2858 | // (relevant to all used sendXX() methods and their error conditions) |
| 2859 | return nil, err |
| 2860 | } |
| 2861 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2862 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2863 | if err != nil { |
| 2864 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{ |
| 2865 | "Err": err, "device-id": oo.deviceID}) |
| 2866 | return nil, err |
| 2867 | } |
| 2868 | |
| 2869 | omciRxCallbackPair := CallbackPair{ |
| 2870 | CbKey: tid, |
| 2871 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2872 | } |
| 2873 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2874 | if err != nil { |
| 2875 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{ |
| 2876 | "Err": err, "device-id": oo.deviceID}) |
| 2877 | return nil, err |
| 2878 | } |
| 2879 | logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done") |
| 2880 | return meInstance, nil |
| 2881 | } |
| 2882 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{ |
| 2883 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2884 | return nil, omciErr.GetError() |
| 2885 | } |
| 2886 | |
| 2887 | // SendCreateVoipMediaProfile nolint: unused |
| 2888 | func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2889 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2890 | tid := oo.GetNextTid(highPrio) |
| 2891 | logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2892 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2893 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2894 | |
| 2895 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2896 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2897 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2898 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2899 | if err != nil { |
| 2900 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err, |
| 2901 | "device-id": oo.deviceID}) |
| 2902 | return nil, err |
| 2903 | } |
| 2904 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2905 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2906 | if err != nil { |
| 2907 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err, |
| 2908 | "device-id": oo.deviceID}) |
| 2909 | return nil, err |
| 2910 | } |
| 2911 | |
| 2912 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2913 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2914 | } |
| 2915 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2916 | if err != nil { |
| 2917 | logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err, |
| 2918 | "device-id": oo.deviceID}) |
| 2919 | return nil, err |
| 2920 | } |
| 2921 | logger.Debug(ctx, "send VoipMediaProfile-create-msg done") |
| 2922 | return meInstance, nil |
| 2923 | } |
| 2924 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2925 | "device-id": oo.deviceID}) |
| 2926 | return nil, omciErr.GetError() |
| 2927 | } |
| 2928 | |
| 2929 | // SendSetVoipMediaProfile nolint: unused |
| 2930 | func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2931 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2932 | tid := oo.GetNextTid(highPrio) |
| 2933 | logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2934 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2935 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2936 | |
| 2937 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2938 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2939 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2940 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2941 | if err != nil { |
| 2942 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err, |
| 2943 | "device-id": oo.deviceID}) |
| 2944 | return nil, err |
| 2945 | } |
| 2946 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2947 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2948 | if err != nil { |
| 2949 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err, |
| 2950 | "device-id": oo.deviceID}) |
| 2951 | return nil, err |
| 2952 | } |
| 2953 | |
| 2954 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2955 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2956 | } |
| 2957 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2958 | if err != nil { |
| 2959 | logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err, |
| 2960 | "device-id": oo.deviceID}) |
| 2961 | return nil, err |
| 2962 | } |
| 2963 | logger.Debug(ctx, "send VoipMediaProfile-set-msg done") |
| 2964 | return meInstance, nil |
| 2965 | } |
| 2966 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2967 | "device-id": oo.deviceID}) |
| 2968 | return nil, omciErr.GetError() |
| 2969 | } |
| 2970 | |
| 2971 | // SendDeleteVoipMediaProfile nolint: unused |
| 2972 | func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2973 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2974 | tid := oo.GetNextTid(highPrio) |
| 2975 | logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2976 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2977 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2978 | |
| 2979 | meParams := me.ParamData{EntityID: aInstID} |
| 2980 | meInstance, omciErr := me.NewVoipMediaProfile(meParams) |
| 2981 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2982 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2983 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2984 | if err != nil { |
| 2985 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{ |
| 2986 | "Err": err, "device-id": oo.deviceID}) |
| 2987 | return nil, err |
| 2988 | } |
| 2989 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 2990 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2991 | if err != nil { |
| 2992 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{ |
| 2993 | "Err": err, "device-id": oo.deviceID}) |
| 2994 | return nil, err |
| 2995 | } |
| 2996 | |
| 2997 | omciRxCallbackPair := CallbackPair{ |
| 2998 | CbKey: tid, |
| 2999 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3000 | } |
| 3001 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3002 | if err != nil { |
| 3003 | logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{ |
| 3004 | "Err": err, "device-id": oo.deviceID}) |
| 3005 | return nil, err |
| 3006 | } |
| 3007 | logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done") |
| 3008 | return meInstance, nil |
| 3009 | } |
| 3010 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{ |
| 3011 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3012 | return nil, omciErr.GetError() |
| 3013 | } |
| 3014 | |
| 3015 | // SendCreateVoiceServiceProfile nolint: unused |
| 3016 | func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3017 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3018 | tid := oo.GetNextTid(highPrio) |
| 3019 | logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3020 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3021 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3022 | |
| 3023 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 3024 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3025 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3026 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3027 | if err != nil { |
| 3028 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err, |
| 3029 | "device-id": oo.deviceID}) |
| 3030 | return nil, err |
| 3031 | } |
| 3032 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3033 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3034 | if err != nil { |
| 3035 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err, |
| 3036 | "device-id": oo.deviceID}) |
| 3037 | return nil, err |
| 3038 | } |
| 3039 | |
| 3040 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3041 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3042 | } |
| 3043 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3044 | if err != nil { |
| 3045 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err, |
| 3046 | "device-id": oo.deviceID}) |
| 3047 | return nil, err |
| 3048 | } |
| 3049 | logger.Debug(ctx, "send VoiceServiceProfile-create-msg done") |
| 3050 | return meInstance, nil |
| 3051 | } |
| 3052 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3053 | "device-id": oo.deviceID}) |
| 3054 | return nil, omciErr.GetError() |
| 3055 | } |
| 3056 | |
| 3057 | // SendSetVoiceServiceProfile nolint: unused |
| 3058 | func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3059 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3060 | tid := oo.GetNextTid(highPrio) |
| 3061 | logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3062 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3063 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3064 | |
| 3065 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 3066 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3067 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3068 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3069 | if err != nil { |
| 3070 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err, |
| 3071 | "device-id": oo.deviceID}) |
| 3072 | return nil, err |
| 3073 | } |
| 3074 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3075 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3076 | if err != nil { |
| 3077 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err, |
| 3078 | "device-id": oo.deviceID}) |
| 3079 | return nil, err |
| 3080 | } |
| 3081 | |
| 3082 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3083 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3084 | } |
| 3085 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3086 | if err != nil { |
| 3087 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err, |
| 3088 | "device-id": oo.deviceID}) |
| 3089 | return nil, err |
| 3090 | } |
| 3091 | logger.Debug(ctx, "send VoiceServiceProfile-set-msg done") |
| 3092 | return meInstance, nil |
| 3093 | } |
| 3094 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3095 | "device-id": oo.deviceID}) |
| 3096 | return nil, omciErr.GetError() |
| 3097 | } |
| 3098 | |
| 3099 | // SendDeleteVoiceServiceProfile nolint: unused |
| 3100 | func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3101 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3102 | tid := oo.GetNextTid(highPrio) |
| 3103 | logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3104 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3105 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3106 | |
| 3107 | meParams := me.ParamData{EntityID: aInstID} |
| 3108 | meInstance, omciErr := me.NewVoiceServiceProfile(meParams) |
| 3109 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3110 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3111 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3112 | if err != nil { |
| 3113 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{ |
| 3114 | "Err": err, "device-id": oo.deviceID}) |
| 3115 | return nil, err |
| 3116 | } |
| 3117 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3118 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3119 | if err != nil { |
| 3120 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{ |
| 3121 | "Err": err, "device-id": oo.deviceID}) |
| 3122 | return nil, err |
| 3123 | } |
| 3124 | |
| 3125 | omciRxCallbackPair := CallbackPair{ |
| 3126 | CbKey: tid, |
| 3127 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3128 | } |
| 3129 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3130 | if err != nil { |
| 3131 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{ |
| 3132 | "Err": err, "device-id": oo.deviceID}) |
| 3133 | return nil, err |
| 3134 | } |
| 3135 | logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done") |
| 3136 | return meInstance, nil |
| 3137 | } |
| 3138 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{ |
| 3139 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3140 | return nil, omciErr.GetError() |
| 3141 | } |
| 3142 | |
| 3143 | // SendCreateSIPUserData nolint: unused |
| 3144 | func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3145 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3146 | tid := oo.GetNextTid(highPrio) |
| 3147 | logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3148 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3149 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3150 | |
| 3151 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3152 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3153 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3154 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3155 | if err != nil { |
| 3156 | logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err, |
| 3157 | "device-id": oo.deviceID}) |
| 3158 | return nil, err |
| 3159 | } |
| 3160 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3161 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3162 | if err != nil { |
| 3163 | logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err, |
| 3164 | "device-id": oo.deviceID}) |
| 3165 | return nil, err |
| 3166 | } |
| 3167 | |
| 3168 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3169 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3170 | } |
| 3171 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3172 | if err != nil { |
| 3173 | logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err, |
| 3174 | "device-id": oo.deviceID}) |
| 3175 | return nil, err |
| 3176 | } |
| 3177 | logger.Debug(ctx, "send SIPUserData-create-msg done") |
| 3178 | return meInstance, nil |
| 3179 | } |
| 3180 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3181 | "device-id": oo.deviceID}) |
| 3182 | return nil, omciErr.GetError() |
| 3183 | } |
| 3184 | |
| 3185 | // SendSetSIPUserData nolint: unused |
| 3186 | func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3187 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3188 | tid := oo.GetNextTid(highPrio) |
| 3189 | logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3190 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3191 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3192 | |
| 3193 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3194 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3195 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3196 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3197 | if err != nil { |
| 3198 | logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err, |
| 3199 | "device-id": oo.deviceID}) |
| 3200 | return nil, err |
| 3201 | } |
| 3202 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3203 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3204 | if err != nil { |
| 3205 | logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err, |
| 3206 | "device-id": oo.deviceID}) |
| 3207 | return nil, err |
| 3208 | } |
| 3209 | |
| 3210 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3211 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3212 | } |
| 3213 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3214 | if err != nil { |
| 3215 | logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err, |
| 3216 | "device-id": oo.deviceID}) |
| 3217 | return nil, err |
| 3218 | } |
| 3219 | logger.Debug(ctx, "send SIPUserData-set-msg done") |
| 3220 | return meInstance, nil |
| 3221 | } |
| 3222 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3223 | "device-id": oo.deviceID}) |
| 3224 | return nil, omciErr.GetError() |
| 3225 | } |
| 3226 | |
| 3227 | // SendDeleteSIPUserData nolint: unused |
| 3228 | func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3229 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3230 | tid := oo.GetNextTid(highPrio) |
| 3231 | logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3232 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3233 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3234 | |
| 3235 | meParams := me.ParamData{EntityID: aInstID} |
| 3236 | meInstance, omciErr := me.NewSipUserData(meParams) |
| 3237 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3238 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3239 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3240 | if err != nil { |
| 3241 | logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{ |
| 3242 | "Err": err, "device-id": oo.deviceID}) |
| 3243 | return nil, err |
| 3244 | } |
| 3245 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3246 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3247 | if err != nil { |
| 3248 | logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{ |
| 3249 | "Err": err, "device-id": oo.deviceID}) |
| 3250 | return nil, err |
| 3251 | } |
| 3252 | |
| 3253 | omciRxCallbackPair := CallbackPair{ |
| 3254 | CbKey: tid, |
| 3255 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3256 | } |
| 3257 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3258 | if err != nil { |
| 3259 | logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{ |
| 3260 | "Err": err, "device-id": oo.deviceID}) |
| 3261 | return nil, err |
| 3262 | } |
| 3263 | logger.Debug(ctx, "send SIPUserData-Delete-msg done") |
| 3264 | return meInstance, nil |
| 3265 | } |
| 3266 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{ |
| 3267 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3268 | return nil, omciErr.GetError() |
| 3269 | } |
| 3270 | |
| 3271 | // SendCreateVoipApplicationServiceProfile nolint: unused |
| 3272 | func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3273 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3274 | tid := oo.GetNextTid(highPrio) |
| 3275 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3276 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3277 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3278 | |
| 3279 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3280 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3281 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3282 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3283 | if err != nil { |
| 3284 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err, |
| 3285 | "device-id": oo.deviceID}) |
| 3286 | return nil, err |
| 3287 | } |
| 3288 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3289 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3290 | if err != nil { |
| 3291 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3292 | "device-id": oo.deviceID}) |
| 3293 | return nil, err |
| 3294 | } |
| 3295 | |
| 3296 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3297 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3298 | } |
| 3299 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3300 | if err != nil { |
| 3301 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3302 | "device-id": oo.deviceID}) |
| 3303 | return nil, err |
| 3304 | } |
| 3305 | logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done") |
| 3306 | return meInstance, nil |
| 3307 | } |
| 3308 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3309 | "device-id": oo.deviceID}) |
| 3310 | return nil, omciErr.GetError() |
| 3311 | } |
| 3312 | |
| 3313 | // SendSetVoipApplicationServiceProfile nolint: unused |
| 3314 | func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3315 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3316 | tid := oo.GetNextTid(highPrio) |
| 3317 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3318 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3319 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3320 | |
| 3321 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3322 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3323 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3324 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3325 | if err != nil { |
| 3326 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err, |
| 3327 | "device-id": oo.deviceID}) |
| 3328 | return nil, err |
| 3329 | } |
| 3330 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3331 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3332 | if err != nil { |
| 3333 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3334 | "device-id": oo.deviceID}) |
| 3335 | return nil, err |
| 3336 | } |
| 3337 | |
| 3338 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3339 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3340 | } |
| 3341 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3342 | if err != nil { |
| 3343 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3344 | "device-id": oo.deviceID}) |
| 3345 | return nil, err |
| 3346 | } |
| 3347 | logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done") |
| 3348 | return meInstance, nil |
| 3349 | } |
| 3350 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3351 | "device-id": oo.deviceID}) |
| 3352 | return nil, omciErr.GetError() |
| 3353 | } |
| 3354 | |
| 3355 | // SendDeleteVoipApplicationServiceProfile nolint: unused |
| 3356 | func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3357 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3358 | tid := oo.GetNextTid(highPrio) |
| 3359 | logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3360 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3361 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3362 | |
| 3363 | meParams := me.ParamData{EntityID: aInstID} |
| 3364 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams) |
| 3365 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3366 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3367 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3368 | if err != nil { |
| 3369 | logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{ |
| 3370 | "Err": err, "device-id": oo.deviceID}) |
| 3371 | return nil, err |
| 3372 | } |
| 3373 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3374 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3375 | if err != nil { |
| 3376 | logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3377 | "Err": err, "device-id": oo.deviceID}) |
| 3378 | return nil, err |
| 3379 | } |
| 3380 | |
| 3381 | omciRxCallbackPair := CallbackPair{ |
| 3382 | CbKey: tid, |
| 3383 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3384 | } |
| 3385 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3386 | if err != nil { |
| 3387 | logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3388 | "Err": err, "device-id": oo.deviceID}) |
| 3389 | return nil, err |
| 3390 | } |
| 3391 | logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done") |
| 3392 | return meInstance, nil |
| 3393 | } |
| 3394 | logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{ |
| 3395 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3396 | return nil, omciErr.GetError() |
| 3397 | } |
| 3398 | |
| 3399 | // SendCreateSIPAgentConfigData nolint: unused |
| 3400 | func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3401 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3402 | tid := oo.GetNextTid(highPrio) |
| 3403 | logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3404 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3405 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3406 | |
| 3407 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3408 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3409 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3410 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3411 | if err != nil { |
| 3412 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err, |
| 3413 | "device-id": oo.deviceID}) |
| 3414 | return nil, err |
| 3415 | } |
| 3416 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3417 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3418 | if err != nil { |
| 3419 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err, |
| 3420 | "device-id": oo.deviceID}) |
| 3421 | return nil, err |
| 3422 | } |
| 3423 | |
| 3424 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3425 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3426 | } |
| 3427 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3428 | if err != nil { |
| 3429 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err, |
| 3430 | "device-id": oo.deviceID}) |
| 3431 | return nil, err |
| 3432 | } |
| 3433 | logger.Debug(ctx, "send SIPAgentConfigData-create-msg done") |
| 3434 | return meInstance, nil |
| 3435 | } |
| 3436 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3437 | "device-id": oo.deviceID}) |
| 3438 | return nil, omciErr.GetError() |
| 3439 | } |
| 3440 | |
| 3441 | // SendSetSIPAgentConfigData nolint: unused |
| 3442 | func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3443 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3444 | tid := oo.GetNextTid(highPrio) |
| 3445 | logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3446 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3447 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3448 | |
| 3449 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3450 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3451 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3452 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3453 | if err != nil { |
| 3454 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err, |
| 3455 | "device-id": oo.deviceID}) |
| 3456 | return nil, err |
| 3457 | } |
| 3458 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3459 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3460 | if err != nil { |
| 3461 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err, |
| 3462 | "device-id": oo.deviceID}) |
| 3463 | return nil, err |
| 3464 | } |
| 3465 | |
| 3466 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3467 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3468 | } |
| 3469 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3470 | if err != nil { |
| 3471 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err, |
| 3472 | "device-id": oo.deviceID}) |
| 3473 | return nil, err |
| 3474 | } |
| 3475 | logger.Debug(ctx, "send SIPAgentConfigData-set-msg done") |
| 3476 | return meInstance, nil |
| 3477 | } |
| 3478 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3479 | "device-id": oo.deviceID}) |
| 3480 | return nil, omciErr.GetError() |
| 3481 | } |
| 3482 | |
| 3483 | // SendDeleteSIPAgentConfigData nolint: unused |
| 3484 | func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3485 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3486 | tid := oo.GetNextTid(highPrio) |
| 3487 | logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3488 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3489 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3490 | |
| 3491 | meParams := me.ParamData{EntityID: aInstID} |
| 3492 | meInstance, omciErr := me.NewSipAgentConfigData(meParams) |
| 3493 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3494 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3495 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3496 | if err != nil { |
| 3497 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{ |
| 3498 | "Err": err, "device-id": oo.deviceID}) |
| 3499 | return nil, err |
| 3500 | } |
| 3501 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3502 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3503 | if err != nil { |
| 3504 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{ |
| 3505 | "Err": err, "device-id": oo.deviceID}) |
| 3506 | return nil, err |
| 3507 | } |
| 3508 | |
| 3509 | omciRxCallbackPair := CallbackPair{ |
| 3510 | CbKey: tid, |
| 3511 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3512 | } |
| 3513 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3514 | if err != nil { |
| 3515 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{ |
| 3516 | "Err": err, "device-id": oo.deviceID}) |
| 3517 | return nil, err |
| 3518 | } |
| 3519 | logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done") |
| 3520 | return meInstance, nil |
| 3521 | } |
| 3522 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3523 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3524 | return nil, omciErr.GetError() |
| 3525 | } |
| 3526 | |
| 3527 | // SendCreateTCPUDPConfigData nolint: unused |
| 3528 | func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3529 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3530 | tid := oo.GetNextTid(highPrio) |
| 3531 | logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3532 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3533 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3534 | |
| 3535 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3536 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3537 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3538 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3539 | if err != nil { |
| 3540 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err, |
| 3541 | "device-id": oo.deviceID}) |
| 3542 | return nil, err |
| 3543 | } |
| 3544 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3545 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3546 | if err != nil { |
| 3547 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err, |
| 3548 | "device-id": oo.deviceID}) |
| 3549 | return nil, err |
| 3550 | } |
| 3551 | |
| 3552 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3553 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3554 | } |
| 3555 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3556 | if err != nil { |
| 3557 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err, |
| 3558 | "device-id": oo.deviceID}) |
| 3559 | return nil, err |
| 3560 | } |
| 3561 | logger.Debug(ctx, "send TCPUDPConfigData-create-msg done") |
| 3562 | return meInstance, nil |
| 3563 | } |
| 3564 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3565 | "device-id": oo.deviceID}) |
| 3566 | return nil, omciErr.GetError() |
| 3567 | } |
| 3568 | |
| 3569 | // SendSetTCPUDPConfigData nolint: unused |
| 3570 | func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3571 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3572 | tid := oo.GetNextTid(highPrio) |
| 3573 | logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3574 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3575 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3576 | |
| 3577 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3578 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3579 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3580 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3581 | if err != nil { |
| 3582 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err, |
| 3583 | "device-id": oo.deviceID}) |
| 3584 | return nil, err |
| 3585 | } |
| 3586 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3587 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3588 | if err != nil { |
| 3589 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err, |
| 3590 | "device-id": oo.deviceID}) |
| 3591 | return nil, err |
| 3592 | } |
| 3593 | |
| 3594 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3595 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3596 | } |
| 3597 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3598 | if err != nil { |
| 3599 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err, |
| 3600 | "device-id": oo.deviceID}) |
| 3601 | return nil, err |
| 3602 | } |
| 3603 | logger.Debug(ctx, "send TCPUDPConfigData-set-msg done") |
| 3604 | return meInstance, nil |
| 3605 | } |
| 3606 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3607 | "device-id": oo.deviceID}) |
| 3608 | return nil, omciErr.GetError() |
| 3609 | } |
| 3610 | |
| 3611 | // SendDeleteTCPUDPConfigData nolint: unused |
| 3612 | func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3613 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3614 | tid := oo.GetNextTid(highPrio) |
| 3615 | logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3616 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3617 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3618 | |
| 3619 | meParams := me.ParamData{EntityID: aInstID} |
| 3620 | meInstance, omciErr := me.NewTcpUdpConfigData(meParams) |
| 3621 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3622 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3623 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3624 | if err != nil { |
| 3625 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{ |
| 3626 | "Err": err, "device-id": oo.deviceID}) |
| 3627 | return nil, err |
| 3628 | } |
| 3629 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3630 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3631 | if err != nil { |
| 3632 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{ |
| 3633 | "Err": err, "device-id": oo.deviceID}) |
| 3634 | return nil, err |
| 3635 | } |
| 3636 | |
| 3637 | omciRxCallbackPair := CallbackPair{ |
| 3638 | CbKey: tid, |
| 3639 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3640 | } |
| 3641 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3642 | if err != nil { |
| 3643 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{ |
| 3644 | "Err": err, "device-id": oo.deviceID}) |
| 3645 | return nil, err |
| 3646 | } |
| 3647 | logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done") |
| 3648 | return meInstance, nil |
| 3649 | } |
| 3650 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3651 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3652 | return nil, omciErr.GetError() |
| 3653 | } |
| 3654 | |
| 3655 | // SendCreateIPHostConfigData nolint: unused |
| 3656 | func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3657 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3658 | tid := oo.GetNextTid(highPrio) |
| 3659 | logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3660 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3661 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3662 | |
| 3663 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3664 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3665 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3666 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3667 | if err != nil { |
| 3668 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err, |
| 3669 | "device-id": oo.deviceID}) |
| 3670 | return nil, err |
| 3671 | } |
| 3672 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3673 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3674 | if err != nil { |
| 3675 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err, |
| 3676 | "device-id": oo.deviceID}) |
| 3677 | return nil, err |
| 3678 | } |
| 3679 | |
| 3680 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3681 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3682 | } |
| 3683 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3684 | if err != nil { |
| 3685 | logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err, |
| 3686 | "device-id": oo.deviceID}) |
| 3687 | return nil, err |
| 3688 | } |
| 3689 | logger.Debug(ctx, "send IPHostConfigData-create-msg done") |
| 3690 | return meInstance, nil |
| 3691 | } |
| 3692 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3693 | "device-id": oo.deviceID}) |
| 3694 | return nil, omciErr.GetError() |
| 3695 | } |
| 3696 | |
| 3697 | // SendSetIPHostConfigData nolint: unused |
| 3698 | func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3699 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3700 | tid := oo.GetNextTid(highPrio) |
| 3701 | logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3702 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3703 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3704 | |
| 3705 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3706 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3707 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3708 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3709 | if err != nil { |
| 3710 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err, |
| 3711 | "device-id": oo.deviceID}) |
| 3712 | return nil, err |
| 3713 | } |
| 3714 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3715 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3716 | if err != nil { |
| 3717 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err, |
| 3718 | "device-id": oo.deviceID}) |
| 3719 | return nil, err |
| 3720 | } |
| 3721 | |
| 3722 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3723 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3724 | } |
| 3725 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3726 | if err != nil { |
| 3727 | logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err, |
| 3728 | "device-id": oo.deviceID}) |
| 3729 | return nil, err |
| 3730 | } |
| 3731 | logger.Debug(ctx, "send IPHostConfigData-set-msg done") |
| 3732 | return meInstance, nil |
| 3733 | } |
| 3734 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3735 | "device-id": oo.deviceID}) |
| 3736 | return nil, omciErr.GetError() |
| 3737 | } |
| 3738 | |
| 3739 | // SendDeleteIPHostConfigData nolint: unused |
| 3740 | func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3741 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3742 | tid := oo.GetNextTid(highPrio) |
| 3743 | logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3744 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3745 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3746 | |
| 3747 | meParams := me.ParamData{EntityID: aInstID} |
| 3748 | meInstance, omciErr := me.NewIpHostConfigData(meParams) |
| 3749 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3750 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3751 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3752 | if err != nil { |
| 3753 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{ |
| 3754 | "Err": err, "device-id": oo.deviceID}) |
| 3755 | return nil, err |
| 3756 | } |
| 3757 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3758 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3759 | if err != nil { |
| 3760 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{ |
| 3761 | "Err": err, "device-id": oo.deviceID}) |
| 3762 | return nil, err |
| 3763 | } |
| 3764 | |
| 3765 | omciRxCallbackPair := CallbackPair{ |
| 3766 | CbKey: tid, |
| 3767 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3768 | } |
| 3769 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3770 | if err != nil { |
| 3771 | logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{ |
| 3772 | "Err": err, "device-id": oo.deviceID}) |
| 3773 | return nil, err |
| 3774 | } |
| 3775 | logger.Debug(ctx, "send IPHostConfigData-Delete-msg done") |
| 3776 | return meInstance, nil |
| 3777 | } |
| 3778 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{ |
| 3779 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3780 | return nil, omciErr.GetError() |
| 3781 | } |
| 3782 | |
| 3783 | // SendCreateRTPProfileData nolint: unused |
| 3784 | func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3785 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3786 | tid := oo.GetNextTid(highPrio) |
| 3787 | logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3788 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3789 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3790 | |
| 3791 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3792 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3793 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3794 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3795 | if err != nil { |
| 3796 | logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err, |
| 3797 | "device-id": oo.deviceID}) |
| 3798 | return nil, err |
| 3799 | } |
| 3800 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3801 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3802 | if err != nil { |
| 3803 | logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err, |
| 3804 | "device-id": oo.deviceID}) |
| 3805 | return nil, err |
| 3806 | } |
| 3807 | |
| 3808 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3809 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3810 | } |
| 3811 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3812 | if err != nil { |
| 3813 | logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err, |
| 3814 | "device-id": oo.deviceID}) |
| 3815 | return nil, err |
| 3816 | } |
| 3817 | logger.Debug(ctx, "send RTPProfileData-create-msg done") |
| 3818 | return meInstance, nil |
| 3819 | } |
| 3820 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3821 | "device-id": oo.deviceID}) |
| 3822 | return nil, omciErr.GetError() |
| 3823 | } |
| 3824 | |
| 3825 | // SendSetRTPProfileData nolint: unused |
| 3826 | func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3827 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3828 | tid := oo.GetNextTid(highPrio) |
| 3829 | logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3830 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3831 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3832 | |
| 3833 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3834 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3835 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3836 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3837 | if err != nil { |
| 3838 | logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err, |
| 3839 | "device-id": oo.deviceID}) |
| 3840 | return nil, err |
| 3841 | } |
| 3842 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3843 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3844 | if err != nil { |
| 3845 | logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err, |
| 3846 | "device-id": oo.deviceID}) |
| 3847 | return nil, err |
| 3848 | } |
| 3849 | |
| 3850 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3851 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3852 | } |
| 3853 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3854 | if err != nil { |
| 3855 | logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err, |
| 3856 | "device-id": oo.deviceID}) |
| 3857 | return nil, err |
| 3858 | } |
| 3859 | logger.Debug(ctx, "send RTPProfileData-set-msg done") |
| 3860 | return meInstance, nil |
| 3861 | } |
| 3862 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3863 | "device-id": oo.deviceID}) |
| 3864 | return nil, omciErr.GetError() |
| 3865 | } |
| 3866 | |
| 3867 | // SendDeleteRTPProfileData nolint: unused |
| 3868 | func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3869 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3870 | tid := oo.GetNextTid(highPrio) |
| 3871 | logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3872 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3873 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3874 | |
| 3875 | meParams := me.ParamData{EntityID: aInstID} |
| 3876 | meInstance, omciErr := me.NewRtpProfileData(meParams) |
| 3877 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3878 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3879 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3880 | if err != nil { |
| 3881 | logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{ |
| 3882 | "Err": err, "device-id": oo.deviceID}) |
| 3883 | return nil, err |
| 3884 | } |
| 3885 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3886 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3887 | if err != nil { |
| 3888 | logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{ |
| 3889 | "Err": err, "device-id": oo.deviceID}) |
| 3890 | return nil, err |
| 3891 | } |
| 3892 | |
| 3893 | omciRxCallbackPair := CallbackPair{ |
| 3894 | CbKey: tid, |
| 3895 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3896 | } |
| 3897 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3898 | if err != nil { |
| 3899 | logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{ |
| 3900 | "Err": err, "device-id": oo.deviceID}) |
| 3901 | return nil, err |
| 3902 | } |
| 3903 | logger.Debug(ctx, "send RTPProfileData-Delete-msg done") |
| 3904 | return meInstance, nil |
| 3905 | } |
| 3906 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{ |
| 3907 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3908 | return nil, omciErr.GetError() |
| 3909 | } |
| 3910 | |
| 3911 | // SendCreateNetworkDialPlanTable nolint: unused |
| 3912 | func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3913 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3914 | tid := oo.GetNextTid(highPrio) |
| 3915 | logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3916 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3917 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3918 | |
| 3919 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3920 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3921 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3922 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3923 | if err != nil { |
| 3924 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err, |
| 3925 | "device-id": oo.deviceID}) |
| 3926 | return nil, err |
| 3927 | } |
| 3928 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3929 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3930 | if err != nil { |
| 3931 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3932 | "device-id": oo.deviceID}) |
| 3933 | return nil, err |
| 3934 | } |
| 3935 | |
| 3936 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3937 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3938 | } |
| 3939 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3940 | if err != nil { |
| 3941 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3942 | "device-id": oo.deviceID}) |
| 3943 | return nil, err |
| 3944 | } |
| 3945 | logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done") |
| 3946 | return meInstance, nil |
| 3947 | } |
| 3948 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3949 | "device-id": oo.deviceID}) |
| 3950 | return nil, omciErr.GetError() |
| 3951 | } |
| 3952 | |
| 3953 | // SendSetNetworkDialPlanTable nolint: unused |
| 3954 | func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3955 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3956 | tid := oo.GetNextTid(highPrio) |
| 3957 | logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3958 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3959 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3960 | |
| 3961 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3962 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3963 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3964 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3965 | if err != nil { |
| 3966 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err, |
| 3967 | "device-id": oo.deviceID}) |
| 3968 | return nil, err |
| 3969 | } |
| 3970 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 3971 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3972 | if err != nil { |
| 3973 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3974 | "device-id": oo.deviceID}) |
| 3975 | return nil, err |
| 3976 | } |
| 3977 | |
| 3978 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3979 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3980 | } |
| 3981 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3982 | if err != nil { |
| 3983 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3984 | "device-id": oo.deviceID}) |
| 3985 | return nil, err |
| 3986 | } |
| 3987 | logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done") |
| 3988 | return meInstance, nil |
| 3989 | } |
| 3990 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3991 | "device-id": oo.deviceID}) |
| 3992 | return nil, omciErr.GetError() |
| 3993 | } |
| 3994 | |
| 3995 | // SendDeleteNetworkDialPlanTable nolint: unused |
| 3996 | func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3997 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3998 | tid := oo.GetNextTid(highPrio) |
| 3999 | logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 4000 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4001 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 4002 | |
| 4003 | meParams := me.ParamData{EntityID: aInstID} |
| 4004 | meInstance, omciErr := me.NewNetworkDialPlanTable(meParams) |
| 4005 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4006 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 4007 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 4008 | if err != nil { |
| 4009 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{ |
| 4010 | "Err": err, "device-id": oo.deviceID}) |
| 4011 | return nil, err |
| 4012 | } |
| 4013 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4014 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 4015 | if err != nil { |
| 4016 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{ |
| 4017 | "Err": err, "device-id": oo.deviceID}) |
| 4018 | return nil, err |
| 4019 | } |
| 4020 | |
| 4021 | omciRxCallbackPair := CallbackPair{ |
| 4022 | CbKey: tid, |
| 4023 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4024 | } |
| 4025 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 4026 | if err != nil { |
| 4027 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{ |
| 4028 | "Err": err, "device-id": oo.deviceID}) |
| 4029 | return nil, err |
| 4030 | } |
| 4031 | logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done") |
| 4032 | return meInstance, nil |
| 4033 | } |
| 4034 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{ |
| 4035 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 4036 | return nil, omciErr.GetError() |
| 4037 | } |
| 4038 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4039 | // SendSyncTime sends SynchronizeTimeRequest |
| 4040 | func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 4041 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4042 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 4043 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 4044 | |
| 4045 | omciLayer := &omci.OMCI{ |
| 4046 | TransactionID: tid, |
| 4047 | MessageType: omci.SynchronizeTimeRequestType, |
| 4048 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4049 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4050 | } |
| 4051 | utcTime := time.Now().UTC() |
| 4052 | request := &omci.SynchronizeTimeRequest{ |
| 4053 | MeBasePacket: omci.MeBasePacket{ |
| 4054 | EntityClass: me.OnuGClassID, |
| 4055 | // Default Instance ID is 0 |
| 4056 | }, |
| 4057 | Year: uint16(utcTime.Year()), |
| 4058 | Month: uint8(utcTime.Month()), |
| 4059 | Day: uint8(utcTime.Day()), |
| 4060 | Hour: uint8(utcTime.Hour()), |
| 4061 | Minute: uint8(utcTime.Minute()), |
| 4062 | Second: uint8(utcTime.Second()), |
| 4063 | } |
| 4064 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4065 | pkt, err := SerializeOmciLayer(ctx, omciLayer, request) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4066 | if err != nil { |
| 4067 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 4068 | "device-id": oo.deviceID}) |
| 4069 | return err |
| 4070 | } |
| 4071 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4072 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4073 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4074 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4075 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4076 | if err != nil { |
| 4077 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 4078 | "device-id": oo.deviceID}) |
| 4079 | return err |
| 4080 | } |
| 4081 | logger.Debug(ctx, "send synchronize time request done") |
| 4082 | return nil |
| 4083 | } |
| 4084 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4085 | // SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance |
| 4086 | func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4087 | upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4088 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4089 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4090 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 4091 | meParam := me.ParamData{EntityID: entityID} |
| 4092 | var meInstance *me.ManagedEntity |
| 4093 | var omciErr me.OmciErrors |
| 4094 | if upstream { |
| 4095 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 4096 | } else { |
| 4097 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 4098 | } |
| 4099 | if omciErr.GetError() == nil { |
| 4100 | var omciLayer *omci.OMCI |
| 4101 | var msgLayer gopacket.SerializableLayer |
| 4102 | var err error |
| 4103 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4104 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4105 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4106 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4107 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4108 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4109 | } |
| 4110 | if err != nil { |
| 4111 | logger.Errorw(ctx, "Cannot encode 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4116 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4117 | if err != nil { |
| 4118 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 4119 | 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] | 4120 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4121 | } |
| 4122 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4123 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4124 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4125 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4126 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4127 | if err != nil { |
| 4128 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 4129 | 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] | 4130 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4131 | } |
| 4132 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 4133 | 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] | 4134 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4135 | } |
| 4136 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 4137 | 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] | 4138 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4139 | } |
| 4140 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4141 | // SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance |
| 4142 | func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4143 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4144 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4145 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4146 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4147 | meParam := me.ParamData{EntityID: entityID} |
| 4148 | var meInstance *me.ManagedEntity |
| 4149 | var omciErr me.OmciErrors |
| 4150 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 4151 | |
| 4152 | if omciErr.GetError() == nil { |
| 4153 | var omciLayer *omci.OMCI |
| 4154 | var msgLayer gopacket.SerializableLayer |
| 4155 | var err error |
| 4156 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4157 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4158 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4159 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4160 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4161 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4162 | } |
| 4163 | if err != nil { |
| 4164 | logger.Errorw(ctx, "Cannot encode 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4169 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4170 | if err != nil { |
| 4171 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 4172 | 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] | 4173 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4174 | } |
| 4175 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4176 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4177 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4178 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4179 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4180 | if err != nil { |
| 4181 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 4182 | 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] | 4183 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4184 | } |
| 4185 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 4186 | 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] | 4187 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4188 | } |
| 4189 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 4190 | 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] | 4191 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4192 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4193 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4194 | // SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance |
| 4195 | func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4196 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4197 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4198 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4199 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4200 | meParam := me.ParamData{EntityID: entityID} |
| 4201 | var meInstance *me.ManagedEntity |
| 4202 | var omciErr me.OmciErrors |
| 4203 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 4204 | |
| 4205 | if omciErr.GetError() == nil { |
| 4206 | var omciLayer *omci.OMCI |
| 4207 | var msgLayer gopacket.SerializableLayer |
| 4208 | var err error |
| 4209 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4210 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4211 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4212 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4213 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4214 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4215 | } |
| 4216 | if err != nil { |
| 4217 | logger.Errorw(ctx, "Cannot encode 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4222 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4223 | if err != nil { |
| 4224 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 4225 | 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] | 4226 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4227 | } |
| 4228 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4229 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4230 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4231 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4232 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4233 | if err != nil { |
| 4234 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 4235 | 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] | 4236 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4237 | } |
| 4238 | logger.Debugw(ctx, "send fec history data ME done", |
| 4239 | 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] | 4240 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4241 | } |
| 4242 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 4243 | 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] | 4244 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4245 | } |
| 4246 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4247 | // SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance |
| 4248 | func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4249 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4250 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4251 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4252 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4253 | meParam := me.ParamData{EntityID: entityID} |
| 4254 | var meInstance *me.ManagedEntity |
| 4255 | var omciErr me.OmciErrors |
| 4256 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 4257 | |
| 4258 | if omciErr.GetError() == nil { |
| 4259 | var omciLayer *omci.OMCI |
| 4260 | var msgLayer gopacket.SerializableLayer |
| 4261 | var err error |
| 4262 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4263 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4264 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4265 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4266 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4267 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4268 | } |
| 4269 | if err != nil { |
| 4270 | logger.Errorw(ctx, "Cannot encode 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 | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 4275 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4276 | if err != nil { |
| 4277 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 4278 | 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] | 4279 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4280 | } |
| 4281 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4282 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4283 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4284 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4285 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4286 | if err != nil { |
| 4287 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 4288 | 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] | 4289 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4290 | } |
| 4291 | logger.Debugw(ctx, "send gemport history data ME done", |
| 4292 | 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] | 4293 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4294 | } |
| 4295 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 4296 | 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] | 4297 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4298 | } |
| 4299 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4300 | // SendStartSoftwareDownload sends StartSoftwareDownloadRequest |
| 4301 | func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4302 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4303 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4304 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4305 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4306 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4307 | |
| 4308 | omciLayer := &omci.OMCI{ |
| 4309 | TransactionID: tid, |
| 4310 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 4311 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4312 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4313 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4314 | if aIsExtendedOmci { |
| 4315 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4316 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4317 | request := &omci.StartSoftwareDownloadRequest{ |
| 4318 | MeBasePacket: omci.MeBasePacket{ |
| 4319 | EntityClass: me.SoftwareImageClassID, |
| 4320 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4321 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4322 | }, |
| 4323 | WindowSize: aDownloadWindowSize, |
| 4324 | ImageSize: aFileLen, |
| 4325 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 4326 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 4327 | } |
| 4328 | |
| 4329 | var options gopacket.SerializeOptions |
| 4330 | options.FixLengths = true |
| 4331 | buffer := gopacket.NewSerializeBuffer() |
| 4332 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4333 | if err != nil { |
| 4334 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 4335 | "device-id": oo.deviceID}) |
| 4336 | return err |
| 4337 | } |
| 4338 | outgoingPacket := buffer.Bytes() |
| 4339 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4340 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4341 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4342 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4343 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4344 | if err != nil { |
| 4345 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 4346 | "device-id": oo.deviceID}) |
| 4347 | return err |
| 4348 | } |
| 4349 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4350 | return nil |
| 4351 | } |
| 4352 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4353 | // PrepareOnuSectionsOfWindow prepares a list of sections for each window |
| 4354 | //Before invoking this function the oo.mutexTid needs to be be locked so that |
| 4355 | //GetOnuSwSecNextTid can be invoked without further locking |
| 4356 | func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context, |
| 4357 | aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4358 | omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) { |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4359 | //onuswsections uses only low prioirity tids |
| 4360 | tid := oo.GetOnuSwSecNextTid() |
| 4361 | logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4362 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4363 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection}) |
| 4364 | |
| 4365 | var omciTxReq OmciTransferStructure |
| 4366 | msgType := omci.DownloadSectionRequestType |
| 4367 | |
| 4368 | if aAckRequest > 0 { |
| 4369 | msgType = omci.DownloadSectionRequestWithResponseType |
| 4370 | |
| 4371 | } |
| 4372 | omciLayer := &omci.OMCI{ |
| 4373 | TransactionID: tid, |
| 4374 | MessageType: msgType, |
| 4375 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4376 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4377 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4378 | if aIsExtendedOmci { |
| 4379 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4380 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4381 | localSectionData := make([]byte, len(aSection)) |
| 4382 | |
| 4383 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
| 4384 | request := &omci.DownloadSectionRequest{ |
| 4385 | MeBasePacket: omci.MeBasePacket{ |
| 4386 | EntityClass: me.SoftwareImageClassID, |
| 4387 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4388 | Extended: aIsExtendedOmci, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4389 | }, |
| 4390 | SectionNumber: aDownloadSectionNo, |
| 4391 | SectionData: localSectionData, |
| 4392 | } |
| 4393 | |
| 4394 | var options gopacket.SerializeOptions |
| 4395 | options.FixLengths = true |
| 4396 | buffer := gopacket.NewSerializeBuffer() |
| 4397 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4398 | if err != nil { |
| 4399 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4400 | "device-id": oo.deviceID}) |
| 4401 | return omciTxReq, err |
| 4402 | } |
| 4403 | outgoingPacket := buffer.Bytes() |
| 4404 | |
| 4405 | omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket) |
| 4406 | |
| 4407 | if aAckRequest > 0 { |
| 4408 | // only the last section should have a timeout as an ack is required only for the last section of the window |
| 4409 | omciTxReq = OmciTransferStructure{ |
| 4410 | withFramePrint: true, |
| 4411 | OnuSwWindow: omciMsgsPerWindow, |
| 4412 | } |
| 4413 | return omciTxReq, nil |
| 4414 | } |
| 4415 | |
| 4416 | return omciTxReq, nil |
| 4417 | } |
| 4418 | |
| 4419 | //SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections |
| 4420 | func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context, |
| 4421 | aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) { |
| 4422 | if aOmciTxRequest.OnuSwWindow == nil { |
| 4423 | logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil", |
| 4424 | log.Fields{"device-id": oo.deviceID}) |
| 4425 | return |
| 4426 | |
| 4427 | } |
| 4428 | |
| 4429 | tid := oo.GetOnuSwSecLastTid() |
| 4430 | logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid}) |
| 4431 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4432 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4433 | } |
| 4434 | |
| 4435 | aOmciTxRequest.cbPair = omciRxCallbackPair |
| 4436 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey}) |
| 4437 | oo.mutexRxSchedMap.Lock() |
| 4438 | // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ... |
| 4439 | oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry |
| 4440 | oo.mutexRxSchedMap.Unlock() |
| 4441 | |
| 4442 | chSuccess := make(chan bool) |
| 4443 | aOmciTxRequest.chSuccess = chSuccess |
| 4444 | aOmciTxRequest.timeout = aTimeout |
| 4445 | aOmciTxRequest.retries = CDefaultRetries |
| 4446 | |
| 4447 | //tid := aOmciTxRequest.cbPair.CbKey |
| 4448 | oo.mutexMonReq.Lock() |
| 4449 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4450 | oo.mutexMonReq.Unlock() |
| 4451 | |
| 4452 | retries := aOmciTxRequest.retries |
| 4453 | retryCounter := 0 |
| 4454 | if aTimeout == 0 { |
| 4455 | logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID}) |
| 4456 | return |
| 4457 | } |
| 4458 | loop: |
| 4459 | for retryCounter <= retries { |
| 4460 | // the onu sw sections are enqueued only to the low priority queue |
| 4461 | oo.mutexLowPrioTxQueue.Lock() |
| 4462 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4463 | oo.mutexLowPrioTxQueue.Unlock() |
| 4464 | |
| 4465 | go oo.sendQueuedRequests(ctx) |
| 4466 | |
| 4467 | select { |
| 4468 | case success := <-chSuccess: |
| 4469 | if success { |
| 4470 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4471 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4472 | } else { |
| 4473 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4474 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4475 | } |
| 4476 | break loop |
| 4477 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4478 | if retryCounter == retries { |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4479 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4480 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4481 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4482 | oo.incrementTxTimesouts() |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 4483 | oo.mutexConsecutiveOmciTimeouts.Lock() |
| 4484 | if oo.consecutiveOmciTimeouts < cMaxConsecutiveOmciTimeouts { |
| 4485 | oo.consecutiveOmciTimeouts++ |
| 4486 | oo.mutexConsecutiveOmciTimeouts.Unlock() |
| 4487 | } else { |
| 4488 | oo.consecutiveOmciTimeouts = 0 |
| 4489 | oo.mutexConsecutiveOmciTimeouts.Unlock() |
| 4490 | oo.mutexOmciAbortInProgress.Lock() |
| 4491 | if !oo.omciAbortInProgress { |
| 4492 | oo.omciAbortInProgress = true |
| 4493 | oo.mutexOmciAbortInProgress.Unlock() |
| 4494 | logger.Errorw(ctx, "reqMon: communication aborted - no of max consecutive timeouts reached - stopping device and send ONU device event!", |
| 4495 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4496 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationAbortSwUpgrade, OnuOmciCommunicationAbortSwUpgradeDesc) |
| 4497 | // stop all running FSM processing |
| 4498 | _ = oo.pBaseDeviceHandler.UpdateInterface(ctx) |
| 4499 | oo.mutexOmciAbortInProgress.Lock() |
| 4500 | oo.omciAbortInProgress = false |
| 4501 | oo.mutexOmciAbortInProgress.Unlock() |
| 4502 | } else { |
| 4503 | oo.mutexOmciAbortInProgress.Unlock() |
| 4504 | logger.Infow(ctx, "reqMon: communication aborted - corresponding processing already running", |
| 4505 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4506 | } |
| 4507 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4508 | break loop |
| 4509 | } else { |
| 4510 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4511 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4512 | oo.incrementTxRetries() |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4513 | } |
| 4514 | } |
| 4515 | retryCounter++ |
| 4516 | } |
| 4517 | oo.mutexMonReq.Lock() |
| 4518 | delete(oo.monitoredRequests, tid) |
| 4519 | oo.mutexMonReq.Unlock() |
| 4520 | } |
| 4521 | |
| 4522 | func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4523 | var lastSection []byte |
| 4524 | if omciTxRequest.OnuSwWindow != nil { |
| 4525 | lastSection = omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1] |
| 4526 | } else { |
| 4527 | logger.Errorw(ctx, "invalid sw window received", log.Fields{"device-id": oo.deviceID}) |
| 4528 | return fmt.Errorf("invalid sw window received") |
| 4529 | } |
| 4530 | if omciTxRequest.withFramePrint { |
| 4531 | logger.Debugw(ctx, "sw-section-omci-message-to-send:", log.Fields{ |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4532 | "TxOmciMessage": hex.EncodeToString(lastSection), |
| 4533 | "device-id": oo.deviceID, |
| 4534 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 4535 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 4536 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 4537 | } |
| 4538 | sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow) |
| 4539 | if sendErr != nil { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4540 | 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] | 4541 | return sendErr |
| 4542 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 4543 | numberOfNoArSections := len(omciTxRequest.OnuSwWindow.Messages) - 1 // last section of window is sent with AR expected |
| 4544 | if lastSection[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 4545 | oo.increaseBaseTxNoArFramesBy(ctx, uint32(numberOfNoArSections)) |
| 4546 | oo.incrementBaseTxArFrames() |
| 4547 | } else { |
| 4548 | oo.increaseExtTxNoArFramesBy(ctx, uint32(numberOfNoArSections)) |
| 4549 | oo.incrementExtTxArFrames() |
| 4550 | } |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4551 | return nil |
| 4552 | } |
| 4553 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4554 | // SendDownloadSection sends DownloadSectionRequestWithResponse |
| 4555 | func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4556 | 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] | 4557 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4558 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4559 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4560 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4561 | |
| 4562 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 4563 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4564 | msgType := omci.DownloadSectionRequestType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4565 | var timeout int = 0 //default value for no response expected |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4566 | if aAckRequest > 0 { |
| 4567 | msgType = omci.DownloadSectionRequestWithResponseType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4568 | timeout = aTimeout |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4569 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4570 | omciLayer := &omci.OMCI{ |
| 4571 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4572 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4573 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4574 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4575 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4576 | if aIsExtendedOmci { |
| 4577 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4578 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4579 | localSectionData := make([]byte, len(aSection)) |
| 4580 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4581 | 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] | 4582 | request := &omci.DownloadSectionRequest{ |
| 4583 | MeBasePacket: omci.MeBasePacket{ |
| 4584 | EntityClass: me.SoftwareImageClassID, |
| 4585 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4586 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4587 | }, |
| 4588 | SectionNumber: aDownloadSectionNo, |
| 4589 | SectionData: localSectionData, |
| 4590 | } |
| 4591 | |
| 4592 | var options gopacket.SerializeOptions |
| 4593 | options.FixLengths = true |
| 4594 | buffer := gopacket.NewSerializeBuffer() |
| 4595 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4596 | if err != nil { |
| 4597 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4598 | "device-id": oo.deviceID}) |
| 4599 | return err |
| 4600 | } |
| 4601 | outgoingPacket := buffer.Bytes() |
| 4602 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4603 | //for initial debug purpose overrule the requested print state for some frames |
| 4604 | printFrame := aPrint |
| 4605 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 4606 | printFrame = true |
| 4607 | } |
| 4608 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4609 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4610 | // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway |
| 4611 | // (used to avoid retransmission of frames with the same TID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4612 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4613 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4614 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4615 | if err != nil { |
| 4616 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 4617 | "device-id": oo.deviceID}) |
| 4618 | return err |
| 4619 | } |
| 4620 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4621 | return nil |
| 4622 | } |
| 4623 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4624 | //SendEndSoftwareDownload sends EndSoftwareDownloadRequest |
| 4625 | func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4626 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4627 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4628 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4629 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4630 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4631 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4632 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4633 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4634 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4635 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4636 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4637 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4638 | if aIsExtendedOmci { |
| 4639 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4640 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4641 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4642 | MeBasePacket: omci.MeBasePacket{ |
| 4643 | EntityClass: me.SoftwareImageClassID, |
| 4644 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4645 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4646 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4647 | CRC32: aImageCrc, |
| 4648 | ImageSize: aFileLen, |
| 4649 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 4650 | 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] | 4651 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4652 | |
| 4653 | var options gopacket.SerializeOptions |
| 4654 | options.FixLengths = true |
| 4655 | buffer := gopacket.NewSerializeBuffer() |
| 4656 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4657 | if err != nil { |
| 4658 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4659 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4660 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4661 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4662 | outgoingPacket := buffer.Bytes() |
| 4663 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4664 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4665 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4666 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4667 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4668 | if err != nil { |
| 4669 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 4670 | "device-id": oo.deviceID}) |
| 4671 | return err |
| 4672 | } |
| 4673 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4674 | return nil |
| 4675 | } |
| 4676 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4677 | // SendActivateSoftware sends ActivateSoftwareRequest |
| 4678 | func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4679 | rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4680 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4681 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4682 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4683 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4684 | |
| 4685 | omciLayer := &omci.OMCI{ |
| 4686 | TransactionID: tid, |
| 4687 | MessageType: omci.ActivateSoftwareRequestType, |
| 4688 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4689 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4690 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4691 | if aIsExtendedOmci { |
| 4692 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4693 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4694 | request := &omci.ActivateSoftwareRequest{ |
| 4695 | MeBasePacket: omci.MeBasePacket{ |
| 4696 | EntityClass: me.SoftwareImageClassID, |
| 4697 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4698 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4699 | }, |
| 4700 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 4701 | } |
| 4702 | |
| 4703 | var options gopacket.SerializeOptions |
| 4704 | options.FixLengths = true |
| 4705 | buffer := gopacket.NewSerializeBuffer() |
| 4706 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4707 | if err != nil { |
| 4708 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 4709 | "device-id": oo.deviceID}) |
| 4710 | return err |
| 4711 | } |
| 4712 | outgoingPacket := buffer.Bytes() |
| 4713 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4714 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4715 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4716 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4717 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4718 | if err != nil { |
| 4719 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 4720 | "device-id": oo.deviceID}) |
| 4721 | return err |
| 4722 | } |
| 4723 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4724 | return nil |
| 4725 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4726 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4727 | // SendCommitSoftware sends CommitSoftwareRequest |
| 4728 | func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4729 | rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4730 | tid := oo.GetNextTid(highPrio) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4731 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4732 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4733 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4734 | |
| 4735 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4736 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4737 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4738 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4739 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4740 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4741 | if aIsExtendedOmci { |
| 4742 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 4743 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4744 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4745 | MeBasePacket: omci.MeBasePacket{ |
| 4746 | EntityClass: me.SoftwareImageClassID, |
| 4747 | EntityInstance: aImageMeID, //inactive image |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 4748 | Extended: aIsExtendedOmci, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4749 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4750 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4751 | |
| 4752 | var options gopacket.SerializeOptions |
| 4753 | options.FixLengths = true |
| 4754 | buffer := gopacket.NewSerializeBuffer() |
| 4755 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4756 | if err != nil { |
| 4757 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4758 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4759 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4760 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4761 | outgoingPacket := buffer.Bytes() |
| 4762 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4763 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4764 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4765 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4766 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4767 | if err != nil { |
| 4768 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 4769 | "device-id": oo.deviceID}) |
| 4770 | return err |
| 4771 | } |
| 4772 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4773 | return nil |
| 4774 | } |
| 4775 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4776 | //SendSelfTestReq sends TestRequest |
| 4777 | func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error { |
| 4778 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4779 | logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID, |
| 4780 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4781 | "InstId": strconv.FormatInt(int64(instdID), 16)}) |
| 4782 | omciLayer := &omci.OMCI{ |
| 4783 | TransactionID: tid, |
| 4784 | MessageType: omci.TestRequestType, |
| 4785 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4786 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4787 | } |
| 4788 | |
| 4789 | var request *omci.OpticalLineSupervisionTestRequest |
| 4790 | switch classID { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4791 | case me.AniGClassID: |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4792 | request = &omci.OpticalLineSupervisionTestRequest{ |
| 4793 | MeBasePacket: omci.MeBasePacket{ |
| 4794 | EntityClass: classID, |
| 4795 | EntityInstance: instdID, |
| 4796 | }, |
| 4797 | SelectTest: uint8(7), // self test |
| 4798 | GeneralPurposeBuffer: uint16(0), |
| 4799 | VendorSpecificParameters: uint16(0), |
| 4800 | } |
| 4801 | default: |
| 4802 | logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID}) |
| 4803 | return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID) |
| 4804 | } |
| 4805 | // Test serialization back to former string |
| 4806 | var options gopacket.SerializeOptions |
| 4807 | options.FixLengths = true |
| 4808 | |
| 4809 | buffer := gopacket.NewSerializeBuffer() |
| 4810 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4811 | if err != nil { |
| 4812 | logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err, |
| 4813 | "device-id": oo.deviceID}) |
| 4814 | return err |
| 4815 | } |
| 4816 | outgoingPacket := buffer.Bytes() |
| 4817 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4818 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4819 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4820 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4821 | err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4822 | if err != nil { |
| 4823 | logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err, |
| 4824 | "device-id": oo.deviceID}) |
| 4825 | return err |
| 4826 | } |
| 4827 | logger.Debug(ctx, "send self test request done") |
| 4828 | return nil |
| 4829 | } |
| 4830 | |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4831 | //nolint: gocyclo |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4832 | func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) { |
| 4833 | |
| 4834 | nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false) |
| 4835 | if err != nil { |
| 4836 | logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID}) |
| 4837 | return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID) |
| 4838 | } |
| 4839 | msgLayer := (*packet).Layer(nextLayer) |
| 4840 | if msgLayer != nil { |
| 4841 | // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers |
| 4842 | if failure := (*packet).ErrorLayer(); failure != nil { |
| 4843 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4844 | // In the case of MibUploadNextResponse, we let the packet pass so that later processing |
| 4845 | // can examine for UnkonwnMEs and UnknownAttributes |
| 4846 | logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass", |
| 4847 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4848 | return false, nil |
| 4849 | } else if nextLayer == omci.LayerTypeGetResponse { |
| 4850 | if resp := msgLayer.(*omci.GetResponse); resp != nil { |
| 4851 | if resp.NextLayerType() == omci.LayerTypeUnknownAttributes { |
| 4852 | unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes) |
| 4853 | if unknownAttrLayer != nil { |
| 4854 | logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!", |
| 4855 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer}) |
| 4856 | return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID) |
| 4857 | } |
| 4858 | } |
| 4859 | } |
| 4860 | } |
| 4861 | // Try to decode any further error information |
| 4862 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
| 4863 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!", |
| 4864 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()}) |
| 4865 | return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID) |
| 4866 | } |
| 4867 | logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!", |
| 4868 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4869 | return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID) |
| 4870 | } |
| 4871 | } else if failure := (*packet).ErrorLayer(); failure != nil { |
| 4872 | // message layer could not be decoded, but at least check if additional failure information is available |
| 4873 | if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil { |
Holger Hildebrandt | 93d183f | 2022-04-22 15:50:26 +0000 | [diff] [blame] | 4874 | errMsg := decodeFailure.String() |
| 4875 | if nextLayer == omci.LayerTypeMibUploadNextResponse { |
| 4876 | if strings.Contains(strings.ToLower(errMsg), "table decode") { |
| 4877 | // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass |
| 4878 | // so that later processing can deal with it |
| 4879 | logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass", |
| 4880 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4881 | return false, nil |
| 4882 | } |
| 4883 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4884 | 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] | 4885 | log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg}) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4886 | return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID) |
| 4887 | } |
| 4888 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available", |
| 4889 | log.Fields{"device-id": oo.deviceID, "error": failure.Error()}) |
| 4890 | return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID) |
| 4891 | } else { |
| 4892 | logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID}) |
| 4893 | return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID) |
| 4894 | } |
| 4895 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4896 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4897 | if v == omciMsg.MessageType { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4898 | switch nextLayer { |
| 4899 | case omci.LayerTypeCreateResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4900 | if resp := msgLayer.(*omci.CreateResponse); resp != nil { |
| 4901 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4902 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4903 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4904 | } |
| 4905 | case omci.LayerTypeDeleteResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4906 | if resp := msgLayer.(*omci.DeleteResponse); resp != nil { |
| 4907 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4908 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4909 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4910 | } |
| 4911 | case omci.LayerTypeSetResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4912 | if resp := msgLayer.(*omci.SetResponse); resp != nil { |
| 4913 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4914 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4915 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4916 | } |
| 4917 | case omci.LayerTypeStartSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4918 | if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil { |
| 4919 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4920 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4921 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4922 | } |
| 4923 | case omci.LayerTypeEndSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4924 | if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil { |
| 4925 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4926 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4927 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4928 | } |
| 4929 | case omci.LayerTypeActivateSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4930 | if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil { |
| 4931 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4932 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4933 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4934 | } |
| 4935 | case omci.LayerTypeCommitSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4936 | if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil { |
| 4937 | if resp.Result == me.Success { |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4938 | return true, nil |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4939 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4940 | } |
| 4941 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4942 | } |
| 4943 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 4944 | return false, nil |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4945 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4946 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4947 | func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4948 | timeout := aOmciTxRequest.timeout |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4949 | if timeout == 0 { |
| 4950 | //timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4951 | // enqueue |
| 4952 | if aOmciTxRequest.highPrio { |
| 4953 | oo.mutexHighPrioTxQueue.Lock() |
| 4954 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4955 | oo.mutexHighPrioTxQueue.Unlock() |
| 4956 | } else { |
| 4957 | oo.mutexLowPrioTxQueue.Lock() |
| 4958 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4959 | oo.mutexLowPrioTxQueue.Unlock() |
| 4960 | } |
| 4961 | go oo.sendQueuedRequests(ctx) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4962 | } else { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4963 | //the supervised sending with waiting on the response (based on TID) is called in background |
| 4964 | // to avoid blocking of the sender for the complete OMCI handshake procedure |
| 4965 | // to stay consistent with the processing tested so far, sending of next messages of the same control procedure |
| 4966 | // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there) |
| 4967 | go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4968 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4969 | } |
| 4970 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4971 | func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4972 | chSuccess := make(chan bool) |
| 4973 | aOmciTxRequest.chSuccess = chSuccess |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4974 | tid := aOmciTxRequest.cbPair.CbKey |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4975 | oo.mutexMonReq.Lock() |
| 4976 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4977 | oo.mutexMonReq.Unlock() |
| 4978 | |
| 4979 | retries := aOmciTxRequest.retries |
| 4980 | retryCounter := 0 |
| 4981 | loop: |
| 4982 | for retryCounter <= retries { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4983 | // enqueue |
| 4984 | if aOmciTxRequest.highPrio { |
| 4985 | oo.mutexHighPrioTxQueue.Lock() |
| 4986 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4987 | oo.mutexHighPrioTxQueue.Unlock() |
| 4988 | } else { |
| 4989 | oo.mutexLowPrioTxQueue.Lock() |
| 4990 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4991 | oo.mutexLowPrioTxQueue.Unlock() |
| 4992 | } |
| 4993 | go oo.sendQueuedRequests(ctx) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4994 | |
| 4995 | select { |
| 4996 | case success := <-chSuccess: |
| 4997 | if success { |
| 4998 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4999 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 5000 | } else { |
| 5001 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 5002 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 5003 | } |
| 5004 | break loop |
| 5005 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 5006 | if retryCounter == retries { |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 5007 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 5008 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 5009 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 5010 | oo.incrementTxTimesouts() |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 5011 | oo.mutexConsecutiveOmciTimeouts.Lock() |
| 5012 | if oo.consecutiveOmciTimeouts < cMaxConsecutiveOmciTimeouts { |
| 5013 | oo.consecutiveOmciTimeouts++ |
| 5014 | oo.mutexConsecutiveOmciTimeouts.Unlock() |
| 5015 | } else { |
| 5016 | oo.consecutiveOmciTimeouts = 0 |
| 5017 | oo.mutexConsecutiveOmciTimeouts.Unlock() |
| 5018 | oo.mutexOmciAbortInProgress.Lock() |
| 5019 | if !oo.omciAbortInProgress { |
| 5020 | oo.omciAbortInProgress = true |
| 5021 | oo.mutexOmciAbortInProgress.Unlock() |
| 5022 | logger.Errorw(ctx, "reqMon: communication aborted - no of max consecutive timeouts reached - stopping device and send ONU device event!", |
| 5023 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 5024 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationAbortConfig, OnuOmciCommunicationAbortConfigDesc) |
| 5025 | // stop all running FSM processing |
| 5026 | _ = oo.pBaseDeviceHandler.UpdateInterface(ctx) |
| 5027 | oo.mutexOmciAbortInProgress.Lock() |
| 5028 | oo.omciAbortInProgress = false |
| 5029 | oo.mutexOmciAbortInProgress.Unlock() |
| 5030 | } else { |
| 5031 | oo.mutexOmciAbortInProgress.Unlock() |
| 5032 | logger.Infow(ctx, "reqMon: communication aborted - corresponding processing already running", |
| 5033 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 5034 | } |
| 5035 | } |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 5036 | break loop |
| 5037 | } else { |
| 5038 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 5039 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 5040 | oo.incrementTxRetries() |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 5041 | } |
| 5042 | } |
| 5043 | retryCounter++ |
| 5044 | } |
| 5045 | oo.mutexMonReq.Lock() |
| 5046 | delete(oo.monitoredRequests, tid) |
| 5047 | oo.mutexMonReq.Unlock() |
| 5048 | } |
| 5049 | |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5050 | //CancelRequestMonitoring terminates monitoring of outstanding omci requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5051 | func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) { |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5052 | logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5053 | oo.mutexMonReq.RLock() |
| 5054 | for k := range oo.monitoredRequests { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5055 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 5056 | select { |
| 5057 | case oo.monitoredRequests[k].chSuccess <- false: |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5058 | logger.Debugw(ctx, "send cancellation on omciRespChannel", |
| 5059 | log.Fields{"index": k, "device-id": oo.deviceID}) |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5060 | default: |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 5061 | logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)", |
| 5062 | log.Fields{"index": k, "device-id": oo.deviceID}) |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 5063 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5064 | } |
| 5065 | oo.mutexMonReq.RUnlock() |
| 5066 | } |
| 5067 | |
| 5068 | //GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum |
| 5069 | //time consumed for retry processing of a particular OMCI-request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5070 | func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration { |
| 5071 | return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 5072 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5073 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5074 | // SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance |
| 5075 | func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5076 | 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] | 5077 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5078 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 5079 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 5080 | |
| 5081 | meParam := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 5082 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5083 | } |
| 5084 | var meInstance *me.ManagedEntity |
| 5085 | var omciErr me.OmciErrors |
| 5086 | if classID == me.EthernetFrameExtendedPmClassID { |
| 5087 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam) |
| 5088 | } else { |
| 5089 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam) |
| 5090 | } |
| 5091 | |
| 5092 | if omciErr.GetError() == nil { |
| 5093 | var omciLayer *omci.OMCI |
| 5094 | var msgLayer gopacket.SerializableLayer |
| 5095 | var err error |
| 5096 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5097 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 5098 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5099 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5100 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 5101 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5102 | } |
| 5103 | if err != nil { |
| 5104 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 5105 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5106 | return nil, err |
| 5107 | } |
| 5108 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 5109 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5110 | if err != nil { |
| 5111 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me", |
| 5112 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5113 | return nil, err |
| 5114 | } |
| 5115 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5116 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 5117 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5118 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5119 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 5120 | if err != nil { |
| 5121 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 5122 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5123 | return nil, err |
| 5124 | } |
| 5125 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done", |
| 5126 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5127 | return meInstance, nil |
| 5128 | } |
| 5129 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 5130 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5131 | return nil, omciErr.GetError() |
| 5132 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 5133 | |
| 5134 | // RLockMutexMonReq lock read access to monitoredRequests |
| 5135 | func (oo *OmciCC) RLockMutexMonReq() { |
| 5136 | oo.mutexMonReq.RLock() |
| 5137 | } |
| 5138 | |
| 5139 | // RUnlockMutexMonReq unlock read access to monitoredRequests |
| 5140 | func (oo *OmciCC) RUnlockMutexMonReq() { |
| 5141 | oo.mutexMonReq.RUnlock() |
| 5142 | } |
| 5143 | |
| 5144 | // GetMonitoredRequest get OmciTransferStructure for an omciTransID |
| 5145 | func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) { |
| 5146 | value, exist = oo.monitoredRequests[omciTransID] |
| 5147 | return value, exist |
| 5148 | } |
| 5149 | |
| 5150 | // SetChMonitoredRequest sets chSuccess to indicate whether response was received or not |
| 5151 | func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) { |
| 5152 | oo.monitoredRequests[omciTransID].chSuccess <- chVal |
| 5153 | } |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5154 | |
| 5155 | // SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me |
| 5156 | func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
| 5157 | rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
| 5158 | tid := oo.GetNextTid(highPrio) |
| 5159 | logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID, |
| 5160 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 5161 | |
| 5162 | meParams := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 5163 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5164 | } |
| 5165 | var meInstance *me.ManagedEntity |
| 5166 | var omciErr me.OmciErrors |
| 5167 | if classID == me.EthernetFrameExtendedPmClassID { |
| 5168 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams) |
| 5169 | } else { |
| 5170 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams) |
| 5171 | } |
| 5172 | |
| 5173 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 5174 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5175 | if err != nil { |
| 5176 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 5177 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5178 | return nil, err |
| 5179 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 5180 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 5181 | if err != nil { |
| 5182 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg", |
| 5183 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5184 | return nil, err |
| 5185 | } |
| 5186 | omciRxCallbackPair := CallbackPair{ |
| 5187 | CbKey: tid, |
| 5188 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 5189 | } |
| 5190 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 5191 | if err != nil { |
| 5192 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 5193 | log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5194 | return nil, err |
| 5195 | } |
| 5196 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done", |
| 5197 | log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5198 | return meInstance, nil |
| 5199 | } |
| 5200 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 5201 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 5202 | return nil, omciErr.GetError() |
| 5203 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 5204 | |
| 5205 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 5206 | func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 5207 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 5208 | oo.pBaseDeviceHandler = nil |
| 5209 | oo.pOnuDeviceEntry = nil |
| 5210 | oo.pOnuAlarmManager = nil |
| 5211 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 5212 | |
| 5213 | // GetOmciCounters - TODO: add comment |
| 5214 | func (oo *OmciCC) GetOmciCounters() *extension.SingleGetValueResponse { |
| 5215 | oo.mutexCounters.RLock() |
| 5216 | defer oo.mutexCounters.RUnlock() |
| 5217 | resp := extension.SingleGetValueResponse{ |
| 5218 | Response: &extension.GetValueResponse{ |
| 5219 | Status: extension.GetValueResponse_OK, |
| 5220 | Response: &extension.GetValueResponse_OnuOmciStats{ |
| 5221 | OnuOmciStats: &extension.GetOnuOmciTxRxStatsResponse{}, |
| 5222 | }, |
| 5223 | }, |
| 5224 | } |
| 5225 | resp.Response.GetOnuOmciStats().BaseTxArFrames = oo.countersBase.txArFrames |
| 5226 | resp.Response.GetOnuOmciStats().BaseTxNoArFrames = oo.countersBase.txNoArFrames |
| 5227 | resp.Response.GetOnuOmciStats().BaseRxAkFrames = oo.countersBase.rxAkFrames |
| 5228 | resp.Response.GetOnuOmciStats().BaseRxNoAkFrames = oo.countersBase.rxNoAkFrames |
| 5229 | resp.Response.GetOnuOmciStats().ExtTxArFrames = oo.countersExt.txArFrames |
| 5230 | resp.Response.GetOnuOmciStats().ExtTxNoArFrames = oo.countersExt.txNoArFrames |
| 5231 | resp.Response.GetOnuOmciStats().ExtRxAkFrames = oo.countersExt.rxAkFrames |
| 5232 | resp.Response.GetOnuOmciStats().ExtRxNoAkFrames = oo.countersExt.rxNoAkFrames |
| 5233 | resp.Response.GetOnuOmciStats().TxOmciCounterRetries = oo.txRetries |
| 5234 | resp.Response.GetOnuOmciStats().TxOmciCounterTimeouts = oo.txTimeouts |
| 5235 | return &resp |
| 5236 | } |
| 5237 | |
| 5238 | // For more speed, separate functions for each counter |
| 5239 | |
| 5240 | func (oo *OmciCC) incrementBaseTxArFrames() { |
| 5241 | oo.mutexCounters.Lock() |
| 5242 | defer oo.mutexCounters.Unlock() |
| 5243 | oo.countersBase.txArFrames++ |
| 5244 | } |
| 5245 | |
| 5246 | func (oo *OmciCC) incrementExtTxArFrames() { |
| 5247 | oo.mutexCounters.Lock() |
| 5248 | defer oo.mutexCounters.Unlock() |
| 5249 | oo.countersExt.txArFrames++ |
| 5250 | } |
| 5251 | |
| 5252 | func (oo *OmciCC) incrementBaseRxAkFrames() { |
| 5253 | oo.mutexCounters.Lock() |
| 5254 | defer oo.mutexCounters.Unlock() |
| 5255 | oo.countersBase.rxAkFrames++ |
| 5256 | } |
| 5257 | |
| 5258 | func (oo *OmciCC) incrementExtRxAkFrames() { |
| 5259 | oo.mutexCounters.Lock() |
| 5260 | defer oo.mutexCounters.Unlock() |
| 5261 | oo.countersExt.rxAkFrames++ |
| 5262 | } |
| 5263 | |
| 5264 | func (oo *OmciCC) increaseBaseTxNoArFramesBy(ctx context.Context, value uint32) { |
| 5265 | oo.mutexCounters.Lock() |
| 5266 | defer oo.mutexCounters.Unlock() |
| 5267 | oo.countersBase.txNoArFrames += value |
| 5268 | } |
| 5269 | |
| 5270 | func (oo *OmciCC) increaseExtTxNoArFramesBy(ctx context.Context, value uint32) { |
| 5271 | oo.mutexCounters.Lock() |
| 5272 | defer oo.mutexCounters.Unlock() |
| 5273 | oo.countersExt.txNoArFrames += value |
| 5274 | } |
| 5275 | |
| 5276 | func (oo *OmciCC) incrementBaseRxNoAkFrames() { |
| 5277 | oo.mutexCounters.Lock() |
| 5278 | defer oo.mutexCounters.Unlock() |
| 5279 | oo.countersBase.rxNoAkFrames++ |
| 5280 | } |
| 5281 | |
| 5282 | func (oo *OmciCC) incrementExtRxNoAkFrames() { |
| 5283 | oo.mutexCounters.Lock() |
| 5284 | defer oo.mutexCounters.Unlock() |
| 5285 | oo.countersExt.rxNoAkFrames++ |
| 5286 | } |
| 5287 | |
| 5288 | func (oo *OmciCC) incrementTxRetries() { |
| 5289 | oo.mutexCounters.Lock() |
| 5290 | defer oo.mutexCounters.Unlock() |
| 5291 | oo.txRetries++ |
| 5292 | } |
| 5293 | |
| 5294 | func (oo *OmciCC) incrementTxTimesouts() { |
| 5295 | oo.mutexCounters.Lock() |
| 5296 | defer oo.mutexCounters.Unlock() |
| 5297 | oo.txTimeouts++ |
| 5298 | } |