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 | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 76 | // ### OMCI related definitions - end |
| 77 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 78 | //CallbackPairEntry to be used for OMCI send/receive correlation |
| 79 | type CallbackPairEntry struct { |
| 80 | CbRespChannel chan Message |
| 81 | CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error |
| 82 | FramePrint bool //true for printing |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 85 | //CallbackPair to be used for ReceiveCallback init |
| 86 | type CallbackPair struct { |
| 87 | CbKey uint16 |
| 88 | CbEntry CallbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 91 | // OmciTransferStructure - TODO: add comment |
| 92 | type OmciTransferStructure struct { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 93 | txFrame []byte |
| 94 | timeout int |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 95 | retries int |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 96 | highPrio bool |
| 97 | withFramePrint bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 98 | cbPair CallbackPair |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 99 | chSuccess chan bool |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 100 | OnuSwWindow *ia.OmciMessages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 103 | type txRxCounters struct { |
| 104 | txArFrames uint32 |
| 105 | txNoArFrames uint32 |
| 106 | rxAkFrames uint32 |
| 107 | rxNoAkFrames uint32 |
| 108 | } |
| 109 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 110 | //OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 111 | type OmciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 112 | enabled bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 113 | pBaseDeviceHandler IdeviceHandler |
| 114 | pOnuDeviceEntry IonuDeviceEntry |
| 115 | pOnuAlarmManager IonuAlarmManager |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 116 | deviceID string |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 117 | coreClient *vgrpc.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 118 | supportExtMsg bool |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 119 | rxOmciFrameError tOmciReceiveError |
| 120 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 121 | mutexCounters sync.RWMutex |
| 122 | countersBase txRxCounters |
| 123 | countersExt txRxCounters |
| 124 | txRetries uint32 |
| 125 | txTimeouts uint32 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 126 | |
| 127 | // OMCI params |
| 128 | mutexTid sync.Mutex |
| 129 | tid uint16 |
| 130 | mutexHpTid sync.Mutex |
| 131 | hpTid uint16 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 132 | UploadSequNo uint16 |
| 133 | UploadNoOfCmds uint16 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 134 | |
Holger Hildebrandt | 556d56c | 2022-12-07 09:23:49 +0000 | [diff] [blame] | 135 | mutexSendQueuedRequests sync.Mutex |
| 136 | mutexLowPrioTxQueue sync.Mutex |
| 137 | lowPrioTxQueue *list.List |
| 138 | mutexHighPrioTxQueue sync.Mutex |
| 139 | highPrioTxQueue *list.List |
| 140 | mutexRxSchedMap sync.Mutex |
| 141 | rxSchedulerMap map[uint16]CallbackPairEntry |
| 142 | mutexMonReq sync.RWMutex |
| 143 | monitoredRequests map[uint16]OmciTransferStructure |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 146 | var responsesWithMibDataSync = []omci.MessageType{ |
| 147 | omci.CreateResponseType, |
| 148 | omci.DeleteResponseType, |
| 149 | omci.SetResponseType, |
| 150 | omci.StartSoftwareDownloadResponseType, |
| 151 | omci.EndSoftwareDownloadResponseType, |
| 152 | omci.ActivateSoftwareResponseType, |
| 153 | omci.CommitSoftwareResponseType, |
| 154 | } |
| 155 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 156 | //NewOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 157 | //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] | 158 | func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler, |
| 159 | onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager, |
| 160 | coreClient *vgrpc.Client) *OmciCC { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 161 | logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 162 | var omciCC OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 163 | omciCC.enabled = false |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 164 | omciCC.pBaseDeviceHandler = deviceHandler |
| 165 | omciCC.pOnuAlarmManager = onuAlarmManager |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 166 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 167 | omciCC.deviceID = deviceID |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 168 | omciCC.coreClient = coreClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 169 | omciCC.supportExtMsg = false |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 170 | omciCC.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 171 | omciCC.countersBase = txRxCounters{0, 0, 0, 0} |
| 172 | omciCC.countersExt = txRxCounters{0, 0, 0, 0} |
| 173 | omciCC.txRetries = 0 |
| 174 | omciCC.txTimeouts = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 175 | omciCC.tid = 0x1 |
| 176 | omciCC.hpTid = 0x8000 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 177 | omciCC.UploadSequNo = 0 |
| 178 | omciCC.UploadNoOfCmds = 0 |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 179 | omciCC.lowPrioTxQueue = list.New() |
| 180 | omciCC.highPrioTxQueue = list.New() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 181 | omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry) |
| 182 | omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 183 | return &omciCC |
| 184 | } |
| 185 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 186 | //Stop stops/resets the omciCC |
| 187 | func (oo *OmciCC) Stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 188 | logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 189 | //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] | 190 | oo.CancelRequestMonitoring(ctx) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 191 | // clear the tx queues |
| 192 | oo.mutexHighPrioTxQueue.Lock() |
| 193 | oo.highPrioTxQueue.Init() |
| 194 | oo.mutexHighPrioTxQueue.Unlock() |
| 195 | oo.mutexLowPrioTxQueue.Lock() |
| 196 | oo.lowPrioTxQueue.Init() |
| 197 | oo.mutexLowPrioTxQueue.Unlock() |
| 198 | //clear the scheduler map |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 199 | oo.mutexRxSchedMap.Lock() |
| 200 | for k := range oo.rxSchedulerMap { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 201 | delete(oo.rxSchedulerMap, k) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 202 | } |
| 203 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 204 | //reset the high prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 205 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 206 | oo.hpTid = 0x8000 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 207 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 208 | //reset the low prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 209 | oo.mutexTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 210 | oo.tid = 1 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 211 | oo.mutexTid.Unlock() |
| 212 | //reset control values |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 213 | oo.UploadSequNo = 0 |
| 214 | oo.UploadNoOfCmds = 0 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 215 | oo.rxOmciFrameError = cOmciMessageReceiveNoError |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 216 | |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 217 | //reset the stats counter |
| 218 | oo.mutexCounters.Lock() |
| 219 | oo.countersBase = txRxCounters{0, 0, 0, 0} |
| 220 | oo.countersExt = txRxCounters{0, 0, 0, 0} |
| 221 | oo.txRetries = 0 |
| 222 | oo.txTimeouts = 0 |
| 223 | oo.mutexCounters.Unlock() |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 224 | return nil |
| 225 | } |
| 226 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 227 | // Rx handler for omci messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 228 | 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] | 229 | logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 230 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 231 | switch omciMsg.MessageType { |
| 232 | case omci.AlarmNotificationType: |
| 233 | data := OmciMessage{ |
| 234 | OmciMsg: omciMsg, |
| 235 | OmciPacket: packet, |
| 236 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 237 | go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 238 | return nil |
| 239 | default: |
| 240 | return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String()) |
| 241 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 242 | /* |
| 243 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 244 | rxOnuFrames++ |
| 245 | |
| 246 | switch msgType { |
| 247 | case AlarmNotification: |
| 248 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 249 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 250 | // python code was: |
| 251 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 252 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 253 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 254 | // |
| 255 | return errors.New("RxAlarmNotification unimplemented") |
| 256 | } |
| 257 | case AttributeValueChange: |
| 258 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 259 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 260 | // python code was: |
| 261 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 262 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 263 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 264 | // |
| 265 | return errors.New("RxAttributeValueChange unimplemented") |
| 266 | } |
| 267 | case TestResult: |
| 268 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 269 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 270 | // python code was: |
| 271 | //elif msg_type == EntityOperations.TestResult.value: |
| 272 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 273 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 274 | // |
| 275 | return errors.New("RxTestResult unimplemented") |
| 276 | } |
| 277 | default: |
| 278 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 279 | logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 280 | rxOnuDiscards++ |
| 281 | return errors.New("RxOnuMsgType unimplemented") |
| 282 | } |
| 283 | } |
| 284 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 287 | func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 288 | //assuming omci message content is hex coded! |
| 289 | // with restricted output of 16bytes would be ...rxMsg[:16] |
| 290 | logger.Debugw(ctx, "omci-message-received:", log.Fields{ |
| 291 | "RxOmciMessage": hex.EncodeToString(rxMsg), |
| 292 | "device-id": oo.deviceID}) |
| 293 | } |
| 294 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 295 | // ReceiveMessage - Rx handler for onu messages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 296 | // 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] | 297 | // nolint: gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 298 | func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 299 | //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] | 300 | |
| 301 | if len(rxMsg) < 10 { |
| 302 | logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort", |
| 303 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 304 | if len(rxMsg) > 0 { |
| 305 | oo.printRxMessage(ctx, rxMsg) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 306 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 307 | return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID) |
| 308 | } |
| 309 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 310 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 311 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 312 | // (an extendedFormat message could be destroyed this way!) |
| 313 | trailerLenData := rxMsg[42:44] |
| 314 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
| 315 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
| 316 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 317 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 318 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 319 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 320 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 321 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 322 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 323 | } |
| 324 | } |
| 325 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 326 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 327 | // (an extendedFormat message could be destroyed this way!) |
| 328 | // extend/overwrite with trailer |
| 329 | trailer := make([]byte, 8) |
| 330 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 331 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 332 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 333 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 334 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 335 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 336 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
| 337 | } |
| 338 | } else { |
| 339 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 340 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 341 | oo.printRxMessage(ctx, rxMsg) |
| 342 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
| 343 | } |
| 344 | } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) { |
| 345 | if len(rxMsg) > 1980 { |
| 346 | logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort", |
| 347 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
| 348 | oo.printRxMessage(ctx, rxMsg) |
| 349 | return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 350 | } |
| 351 | } else { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 352 | logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort", |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 353 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 354 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 355 | return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 356 | } |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 357 | decodeOptions := gopacket.DecodeOptions{ |
| 358 | Lazy: true, |
| 359 | NoCopy: true, |
| 360 | } |
| 361 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 362 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 363 | 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] | 364 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 365 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 366 | } |
| 367 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 368 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 369 | 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] | 370 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 371 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 372 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 373 | // insert some check on detected OMCI decoding issues and log them |
| 374 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 375 | // even though allowed from omci-lib due to set relaxed decoding |
| 376 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 377 | // (compare mib_sync.go unknownAttrLayer) |
| 378 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 379 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 380 | errMsg := failure.Error() |
| 381 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 382 | "device-id": oo.deviceID, "issue": errMsg}) |
| 383 | } |
| 384 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 385 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 386 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 387 | 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] | 388 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 389 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 390 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 391 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 392 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
| 393 | "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 394 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 395 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 396 | // We expect to find the TID in the oo.rxSchedulerMap |
| 397 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 398 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 399 | oo.printRxMessage(ctx, rxMsg) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 400 | 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] | 401 | if omciMsg.TransactionID == 0 { |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 402 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 403 | oo.incrementBaseRxNoAkFrames() |
| 404 | } else { |
| 405 | oo.incrementExtRxNoAkFrames() |
| 406 | } |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 407 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 408 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 409 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 410 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 411 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 412 | 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] | 413 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 414 | //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] | 415 | oo.mutexRxSchedMap.Lock() |
| 416 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 417 | if ok && rxCallbackEntry.CbFunction != nil { |
Holger Hildebrandt | 68854a8 | 2022-09-05 07:00:21 +0000 | [diff] [blame] | 418 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 419 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 420 | oo.printRxMessage(ctx, rxMsg) |
| 421 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 422 | if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 423 | oo.incrementBaseRxAkFrames() |
| 424 | } else { |
| 425 | oo.incrementExtRxAkFrames() |
| 426 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 427 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 428 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 429 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 430 | isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet) |
| 431 | if err != nil { |
| 432 | // qualified error logging already done in function above |
| 433 | if !rxCallbackEntry.FramePrint { |
| 434 | oo.printRxMessage(ctx, rxMsg) |
| 435 | } |
| 436 | return fmt.Errorf("could not decode further layers %s", oo.deviceID) |
| 437 | } |
| 438 | if isSuccessfulResponse { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 439 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 36747fd | 2022-03-14 09:47:17 +0000 | [diff] [blame] | 440 | } else { |
| 441 | logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type", |
| 442 | log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID}) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 443 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 444 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 445 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 446 | // so do not clean up the TransactionID in that case. |
| 447 | if omciMsg.MessageType != omci.TestResponseType { |
| 448 | // having posted the response the request is regarded as 'done' |
| 449 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 450 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 451 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 452 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 453 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 454 | oo.mutexRxSchedMap.Unlock() |
| 455 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 456 | oo.printRxMessage(ctx, rxMsg) |
| 457 | 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] | 458 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 459 | /* py code was: |
| 460 | Receive and OMCI message from the proxy channel to the OLT. |
| 461 | |
| 462 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 463 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 464 | """ |
| 465 | if not self.enabled: |
| 466 | return |
| 467 | |
| 468 | try: |
| 469 | now = arrow.utcnow() |
| 470 | d = None |
| 471 | |
| 472 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 473 | # save the current value of the entity_id_to_class_map, then |
| 474 | # replace it with our custom one before decode, and then finally |
| 475 | # restore it later. Tried other ways but really made the code messy. |
| 476 | saved_me_map = omci_entities.entity_id_to_class_map |
| 477 | omci_entities.entity_id_to_class_map = self._me_map |
| 478 | |
| 479 | try: |
| 480 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 481 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 482 | except KeyError as e: |
| 483 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 484 | 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] | 485 | rx_frame = self._decode_unknown_me(msg) |
| 486 | self._rx_unknown_me += 1 |
| 487 | |
| 488 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 489 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 490 | return |
| 491 | |
| 492 | finally: |
| 493 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 494 | |
| 495 | rx_tid = rx_frame.fields['transaction_id'] |
| 496 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 497 | 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] | 498 | # Filter the Test Result frame and route through receive onu |
| 499 | # message method. |
| 500 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 501 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 502 | return self._receive_onu_message(rx_frame) |
| 503 | |
| 504 | # Previously unreachable if this is the very first round-trip Rx or we |
| 505 | # have been running consecutive errors |
| 506 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 507 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 508 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 509 | |
| 510 | self._rx_frames += 1 |
| 511 | self._consecutive_errors = 0 |
| 512 | |
| 513 | try: |
| 514 | high_priority = self._tid_is_high_priority(rx_tid) |
| 515 | index = self._get_priority_index(high_priority) |
| 516 | |
| 517 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 518 | last_tx_tuple = self._tx_request[index] |
| 519 | |
| 520 | if last_tx_tuple is None or \ |
| 521 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 522 | # Possible late Rx on a message that timed-out |
| 523 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 524 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 525 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 526 | self._rx_unknown_tid += 1 |
| 527 | self._rx_late += 1 |
| 528 | return |
| 529 | |
| 530 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 531 | if dc is not None and not dc.cancelled and not dc.called: |
| 532 | dc.cancel() |
| 533 | |
| 534 | _secs = self._update_rx_tx_stats(now, ts) |
| 535 | |
| 536 | # Late arrival already serviced by a timeout? |
| 537 | if d.called: |
| 538 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 539 | 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] | 540 | return |
| 541 | |
| 542 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 543 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 544 | if d is not None: |
| 545 | return d.errback(failure.Failure(e)) |
| 546 | return |
| 547 | |
| 548 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 549 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 550 | tx_tid = tx_frame.fields['transaction_id']) |
| 551 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 552 | |
| 553 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 554 | self._rx_response[index] = rx_frame |
| 555 | d.callback(rx_frame) |
| 556 | |
| 557 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 558 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 559 | */ |
| 560 | } |
| 561 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 562 | /* |
| 563 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 564 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 565 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 566 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 567 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 568 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 569 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 570 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 571 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 572 | delete(oo.rxSchedulerMap, tid) |
| 573 | } |
| 574 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 575 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 576 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 577 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 578 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 579 | if timeout != 0 { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 580 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 581 | oo.mutexRxSchedMap.Lock() |
| 582 | // 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] | 583 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 584 | oo.mutexRxSchedMap.Unlock() |
| 585 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 586 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 587 | 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] | 588 | //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] | 589 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 590 | txFrame, |
| 591 | timeout, |
| 592 | retry, |
| 593 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 594 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 595 | receiveCallbackPair, |
| 596 | nil, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 597 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 598 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 599 | oo.mutexMonReq.Lock() |
| 600 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 601 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 602 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 603 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 604 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 605 | return nil |
| 606 | } |
| 607 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 608 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 609 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 610 | } |
| 611 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 612 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 613 | // Avoid accessing the txQueues from parallel send routines to block |
| 614 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 615 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 616 | // for the corresponding response too (t.b.d.). |
| 617 | oo.mutexSendQueuedRequests.Lock() |
| 618 | defer oo.mutexSendQueuedRequests.Unlock() |
| 619 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 620 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 621 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 622 | return |
| 623 | } |
| 624 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 625 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 626 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 627 | return |
| 628 | } |
| 629 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 630 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 631 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 632 | oo.mutexHighPrioTxQueue.Lock() |
| 633 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 634 | for oo.highPrioTxQueue.Len() > 0 { |
| 635 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 636 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 637 | // Element will be removed from the queue regardless of the send success, to prevent |
| 638 | // an accumulation of send requests for the same message in the event of an error. |
| 639 | // In this case, resend attempts for the message are ensured by our retry |
| 640 | // mechanism after omci-timeout. |
| 641 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 642 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 643 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 644 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 645 | } |
| 646 | return nil |
| 647 | } |
| 648 | |
| 649 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 650 | oo.mutexLowPrioTxQueue.Lock() |
| 651 | for oo.lowPrioTxQueue.Len() > 0 { |
| 652 | queueElement := oo.lowPrioTxQueue.Front() // First element |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 653 | // check if the element is for onu sw section |
| 654 | aOmciTxReq := queueElement.Value.(OmciTransferStructure) |
| 655 | if aOmciTxReq.OnuSwWindow != nil { |
| 656 | if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 657 | // Element will be removed from the queue regardless of the send success, to prevent |
| 658 | // an accumulation of send requests for the same message in the event of an error. |
| 659 | // In this case, resend attempts for the message are ensured by our retry |
| 660 | // mechanism after omci-timeout. |
| 661 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 662 | oo.mutexLowPrioTxQueue.Unlock() |
| 663 | return err |
| 664 | } |
| 665 | } else { |
| 666 | err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)) |
| 667 | if err != nil { |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 668 | // Element will be removed from the queue regardless of the send success, to prevent |
| 669 | // an accumulation of send requests for the same message in the event of an error. |
| 670 | // In this case, resend attempts for the message are ensured by our retry |
| 671 | // mechanism after omci-timeout. |
| 672 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 673 | oo.mutexLowPrioTxQueue.Unlock() |
| 674 | return err |
| 675 | } |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 676 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 677 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 678 | // Interrupt the sending of low priority requests to process any high priority requests |
| 679 | // that may have arrived in the meantime |
| 680 | oo.mutexLowPrioTxQueue.Unlock() |
| 681 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 682 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 683 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 684 | oo.mutexLowPrioTxQueue.Lock() |
| 685 | } |
| 686 | |
| 687 | oo.mutexLowPrioTxQueue.Unlock() |
| 688 | return nil |
| 689 | } |
| 690 | |
| 691 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 692 | if omciTxRequest.withFramePrint { |
| 693 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 694 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 695 | "device-id": oo.deviceID, |
| 696 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 697 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 698 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 699 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 700 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 701 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 702 | ChildDeviceId: oo.deviceID, |
| 703 | Message: omciTxRequest.txFrame, |
| 704 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 705 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 706 | } |
| 707 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 708 | if sendErr != nil { |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 709 | 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] | 710 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 711 | } |
Holger Hildebrandt | 66af5ce | 2022-09-07 13:38:02 +0000 | [diff] [blame] | 712 | if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) { |
| 713 | oo.incrementBaseTxArFrames() |
| 714 | } else { |
| 715 | oo.incrementExtTxArFrames() |
| 716 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 717 | return nil |
| 718 | } |
| 719 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 720 | // GetNextTid - TODO: add comment |
| 721 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 722 | var next uint16 |
| 723 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 724 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 725 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 726 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 727 | if oo.hpTid < 0x8000 { |
| 728 | oo.hpTid = 0x8000 |
| 729 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 730 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 731 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 732 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 733 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 734 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 735 | if oo.tid >= 0x8000 { |
| 736 | oo.tid = 1 |
| 737 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 738 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 739 | } |
| 740 | return next |
| 741 | } |
| 742 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 743 | //GetOnuSwSecNextTid get the next low prio tid for the onu sw sections |
| 744 | //onu sw sections uses only low priority tids |
| 745 | //The mutexTid lock should be taken prior to using this function |
| 746 | func (oo *OmciCC) GetOnuSwSecNextTid() uint16 { |
| 747 | next := oo.tid |
| 748 | oo.tid++ |
| 749 | if oo.tid >= 0x8000 { |
| 750 | oo.tid = 1 |
| 751 | } |
| 752 | return next |
| 753 | } |
| 754 | |
| 755 | //GetOnuSwSecLastTid gets the last allocated tid |
| 756 | //The mutexTid lock should be taken prior to using this function |
| 757 | func (oo *OmciCC) GetOnuSwSecLastTid() uint16 { |
| 758 | next := oo.tid |
| 759 | lastAllocatedTid := next - 1 |
| 760 | return lastAllocatedTid |
| 761 | } |
| 762 | |
| 763 | //LockMutexTID locks mutexTid |
| 764 | func (oo *OmciCC) LockMutexTID() { |
| 765 | oo.mutexTid.Lock() |
| 766 | } |
| 767 | |
| 768 | //UnLockMutexTID unlocks mutexTid |
| 769 | func (oo *OmciCC) UnLockMutexTID() { |
| 770 | oo.mutexTid.Unlock() |
| 771 | } |
| 772 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 773 | // ################################################################################### |
| 774 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 775 | |
| 776 | // Serialize - TODO: add comment |
| 777 | 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] | 778 | omciLayer := &omci.OMCI{ |
| 779 | TransactionID: tid, |
| 780 | MessageType: msgType, |
| 781 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 782 | return SerializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 783 | } |
| 784 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 785 | // SerializeOmciLayer - TODO: add comment |
| 786 | 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] | 787 | var options gopacket.SerializeOptions |
| 788 | options.FixLengths = true |
| 789 | |
| 790 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 791 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 792 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 793 | 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] | 794 | return nil, err |
| 795 | } |
| 796 | return buffer.Bytes(), nil |
| 797 | } |
| 798 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 799 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 800 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 801 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 802 | hex.Encode(dst, omciPkt) |
| 803 | return dst, nil |
| 804 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 805 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 806 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 807 | //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] | 808 | 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] | 809 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 810 | 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] | 811 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 812 | |
| 813 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 814 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 815 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 816 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 817 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 818 | oo.mutexMonReq.RLock() |
| 819 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 820 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 821 | select { |
| 822 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 823 | default: |
| 824 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 825 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 826 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 827 | } else { |
| 828 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 829 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 830 | } |
| 831 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 832 | |
| 833 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 834 | // 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] | 835 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 836 | Type: OMCI, |
| 837 | Data: OmciMessage{ |
| 838 | OmciMsg: omciMsg, |
| 839 | OmciPacket: packet, |
| 840 | }, |
| 841 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 842 | //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] | 843 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 844 | |
| 845 | return nil |
| 846 | } |
| 847 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 848 | // SendMibReset sends MibResetRequest |
| 849 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 850 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 851 | 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] | 852 | request := &omci.MibResetRequest{ |
| 853 | MeBasePacket: omci.MeBasePacket{ |
| 854 | EntityClass: me.OnuDataClassID, |
| 855 | }, |
| 856 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 857 | tid := oo.GetNextTid(highPrio) |
| 858 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 859 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 860 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 861 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 862 | return err |
| 863 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 864 | omciRxCallbackPair := CallbackPair{ |
| 865 | CbKey: tid, |
| 866 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 867 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 868 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 869 | } |
| 870 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 871 | // SendReboot sends RebootRequest |
| 872 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 873 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 874 | request := &omci.RebootRequest{ |
| 875 | MeBasePacket: omci.MeBasePacket{ |
| 876 | EntityClass: me.OnuGClassID, |
| 877 | }, |
| 878 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 879 | tid := oo.GetNextTid(highPrio) |
| 880 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 881 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 882 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 883 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 884 | return err |
| 885 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 886 | omciRxCallbackPair := CallbackPair{ |
| 887 | CbKey: tid, |
| 888 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 889 | } |
| 890 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 891 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 892 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 893 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 894 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 895 | return err |
| 896 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 897 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 898 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 899 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 900 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 901 | return err |
| 902 | } |
| 903 | return nil |
| 904 | } |
| 905 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 906 | // SendMibUpload sends MibUploadRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 907 | 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] | 908 | 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] | 909 | |
| 910 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 911 | |
| 912 | omciLayer := &omci.OMCI{ |
| 913 | TransactionID: tid, |
| 914 | MessageType: omci.MibUploadRequestType, |
| 915 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 916 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 917 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 918 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 919 | request := &omci.MibUploadRequest{ |
| 920 | MeBasePacket: omci.MeBasePacket{ |
| 921 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 922 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 923 | }, |
| 924 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 925 | var options gopacket.SerializeOptions |
| 926 | options.FixLengths = true |
| 927 | |
| 928 | buffer := gopacket.NewSerializeBuffer() |
| 929 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 930 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 931 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 932 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 933 | return err |
| 934 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 935 | oo.UploadSequNo = 0 |
| 936 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 937 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 938 | omciRxCallbackPair := CallbackPair{ |
| 939 | CbKey: tid, |
| 940 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 941 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 942 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 943 | } |
| 944 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 945 | // SendMibUploadNext sends MibUploadNextRequest |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 946 | 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] | 947 | 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] | 948 | |
| 949 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 950 | |
| 951 | omciLayer := &omci.OMCI{ |
| 952 | TransactionID: tid, |
| 953 | MessageType: omci.MibUploadNextRequestType, |
| 954 | } |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 955 | if isExtOmciSupported { |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 956 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 957 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 958 | request := &omci.MibUploadNextRequest{ |
| 959 | MeBasePacket: omci.MeBasePacket{ |
| 960 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 5458d89 | 2022-05-31 09:52:06 +0000 | [diff] [blame] | 961 | Extended: isExtOmciSupported, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 962 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 963 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 964 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 965 | var options gopacket.SerializeOptions |
| 966 | options.FixLengths = true |
| 967 | |
| 968 | buffer := gopacket.NewSerializeBuffer() |
| 969 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 970 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 971 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 972 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 973 | return err |
| 974 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 975 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 976 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 977 | omciRxCallbackPair := CallbackPair{ |
| 978 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 979 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 980 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 981 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 982 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 983 | } |
Holger Hildebrandt | 0edf5b0 | 2022-05-04 14:19:43 +0000 | [diff] [blame] | 984 | return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 985 | } |
| 986 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 987 | // SendGetAllAlarm gets all alarm ME instances |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 988 | 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] | 989 | 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] | 990 | |
| 991 | tid := oo.GetNextTid(highPrio) |
| 992 | omciLayer := &omci.OMCI{ |
| 993 | TransactionID: tid, |
| 994 | MessageType: omci.GetAllAlarmsRequestType, |
| 995 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 996 | } |
| 997 | if isExtendedOmci { |
| 998 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 999 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1000 | request := &omci.GetAllAlarmsRequest{ |
| 1001 | MeBasePacket: omci.MeBasePacket{ |
| 1002 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1003 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1004 | }, |
| 1005 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 1006 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1007 | var options gopacket.SerializeOptions |
| 1008 | options.FixLengths = true |
| 1009 | buffer := gopacket.NewSerializeBuffer() |
| 1010 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1011 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1012 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1013 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1014 | return err |
| 1015 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1016 | outgoingPacket := buffer.Bytes() |
| 1017 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1018 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1019 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1020 | omciRxCallbackPair := CallbackPair{ |
| 1021 | CbKey: tid, |
| 1022 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1023 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1024 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1025 | if err != nil { |
| 1026 | logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err, |
| 1027 | "device-id": oo.deviceID}) |
| 1028 | return err |
| 1029 | } |
| 1030 | logger.Debug(ctx, "send GetAllAlarmsRequest done") |
| 1031 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1032 | } |
| 1033 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1034 | // SendGetAllAlarmNext gets next alarm ME instance |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1035 | 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] | 1036 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 1037 | 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] | 1038 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1039 | |
| 1040 | tid := oo.GetNextTid(highPrio) |
| 1041 | omciLayer := &omci.OMCI{ |
| 1042 | TransactionID: tid, |
| 1043 | MessageType: omci.GetAllAlarmsNextRequestType, |
| 1044 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 1045 | } |
| 1046 | if isExtendedOmci { |
| 1047 | omciLayer.DeviceIdentifier = omci.ExtendedIdent |
| 1048 | } |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1049 | request := &omci.GetAllAlarmsNextRequest{ |
| 1050 | MeBasePacket: omci.MeBasePacket{ |
| 1051 | EntityClass: me.OnuDataClassID, |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1052 | Extended: isExtendedOmci, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1053 | }, |
| 1054 | CommandSequenceNumber: alarmUploadSeqNo, |
| 1055 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1056 | var options gopacket.SerializeOptions |
| 1057 | options.FixLengths = true |
| 1058 | buffer := gopacket.NewSerializeBuffer() |
| 1059 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1060 | if err != nil { |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1061 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1062 | "device-id": oo.deviceID}) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1063 | return err |
| 1064 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1065 | outgoingPacket := buffer.Bytes() |
| 1066 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1067 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1068 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1069 | omciRxCallbackPair := CallbackPair{ |
| 1070 | CbKey: tid, |
| 1071 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1072 | } |
Holger Hildebrandt | 3b29a8a | 2022-07-11 05:55:13 +0000 | [diff] [blame] | 1073 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 1074 | if err != nil { |
| 1075 | logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err, |
| 1076 | "device-id": oo.deviceID}) |
| 1077 | return err |
| 1078 | } |
| 1079 | logger.Debug(ctx, "send GetAllAlarmsNextRequest done") |
| 1080 | return nil |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 1081 | } |
| 1082 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1083 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 1084 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1085 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1086 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1087 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1088 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1089 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1090 | EntityID: GalEthernetEID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1091 | Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1092 | } |
| 1093 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 1094 | if omciErr.GetError() == nil { |
| 1095 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1096 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1097 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1098 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1099 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1100 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1101 | } |
| 1102 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1103 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1104 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1105 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1106 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1107 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1108 | } |
| 1109 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1110 | omciRxCallbackPair := CallbackPair{ |
| 1111 | CbKey: tid, |
| 1112 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1113 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1114 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1115 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1116 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1117 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1118 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1119 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1120 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1121 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1122 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1123 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1124 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1125 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1128 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1129 | // 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] | 1130 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1131 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1132 | 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] | 1133 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1134 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1135 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 1136 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1137 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 1138 | // read ONU-2G from DB ???? //TODO!!! |
| 1139 | meParams := me.ParamData{ |
| 1140 | EntityID: 0, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1141 | Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1142 | } |
| 1143 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 1144 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1145 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1146 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1147 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1148 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1149 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1150 | } |
| 1151 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1152 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1153 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1154 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1155 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1156 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1159 | omciRxCallbackPair := CallbackPair{ |
| 1160 | CbKey: tid, |
| 1161 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1162 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1163 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1164 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1165 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1166 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1167 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1168 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1169 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1170 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1171 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1172 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1173 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1174 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1175 | } |
| 1176 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1177 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 1178 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 1179 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1180 | tid := oo.GetNextTid(highPrio) |
| 1181 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1182 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1183 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1184 | |
| 1185 | meParams := me.ParamData{ |
| 1186 | EntityID: instID, |
| 1187 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1188 | me.MacBridgeServiceProfile_Priority: 0x8000, |
| 1189 | me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s |
| 1190 | me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s |
| 1191 | me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s |
| 1192 | me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1193 | }, |
| 1194 | } |
| 1195 | |
| 1196 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1197 | if omciErr.GetError() == nil { |
| 1198 | //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] | 1199 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1200 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1201 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1202 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1203 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1204 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1205 | } |
| 1206 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1207 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1208 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1209 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1210 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1211 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1212 | } |
| 1213 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1214 | omciRxCallbackPair := CallbackPair{ |
| 1215 | CbKey: tid, |
| 1216 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1217 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1218 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1219 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1220 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1221 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1222 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1223 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1224 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1225 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1226 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1227 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1228 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1229 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1232 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1233 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1234 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1235 | tid := oo.GetNextTid(highPrio) |
| 1236 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1237 | if idErr != nil { |
| 1238 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1239 | "Err": idErr, "device-id": oo.deviceID}) |
| 1240 | return nil, idErr |
| 1241 | } |
| 1242 | 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] | 1243 | "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] | 1244 | |
| 1245 | meParams := me.ParamData{ |
| 1246 | EntityID: instID, |
| 1247 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1248 | me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1249 | me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo, |
| 1250 | me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType), |
| 1251 | me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1252 | }, |
| 1253 | } |
| 1254 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1255 | if omciErr.GetError() == nil { |
| 1256 | //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] | 1257 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1258 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1259 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1260 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1261 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1262 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1263 | } |
| 1264 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1265 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1266 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1267 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1268 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1269 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1272 | omciRxCallbackPair := CallbackPair{ |
| 1273 | CbKey: tid, |
| 1274 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1275 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1276 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1277 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1278 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1279 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1280 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1281 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1282 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1283 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1284 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1285 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1286 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1287 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1288 | } |
| 1289 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1290 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1291 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1292 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1293 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1294 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1295 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1296 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1297 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1298 | |
| 1299 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1300 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1301 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1302 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1303 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1304 | assType = uint8(10) // for VEIP |
| 1305 | } |
| 1306 | meParams := me.ParamData{ |
| 1307 | EntityID: instID, |
| 1308 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1309 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType, |
| 1310 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1311 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1312 | }, |
| 1313 | } |
| 1314 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1315 | if omciErr.GetError() == nil { |
| 1316 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1317 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1318 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1319 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1320 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1321 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1322 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1323 | } |
| 1324 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1325 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1326 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1327 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1328 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1329 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1330 | } |
| 1331 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1332 | omciRxCallbackPair := CallbackPair{ |
| 1333 | CbKey: tid, |
| 1334 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1335 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1336 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1337 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1338 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1339 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1340 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1341 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1342 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1343 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1344 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1345 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1346 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1347 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1348 | } |
| 1349 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1350 | // SendSetOnuGLS sets OnuG ME instance |
| 1351 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1352 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1353 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1354 | logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1355 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1356 | |
| 1357 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1358 | meParams := me.ParamData{ |
| 1359 | EntityID: 0, |
| 1360 | Attributes: requestedAttributes, |
| 1361 | } |
| 1362 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1363 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1364 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1365 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1366 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1367 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1368 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1371 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1372 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1373 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1374 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1375 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1378 | omciRxCallbackPair := CallbackPair{ |
| 1379 | CbKey: tid, |
| 1380 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1381 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1382 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1383 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1384 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1385 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1386 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1387 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1388 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1389 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1390 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1391 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1392 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1393 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1394 | } |
| 1395 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1396 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1397 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1398 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1399 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1400 | 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] | 1401 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1402 | |
| 1403 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1404 | meParams := me.ParamData{ |
| 1405 | EntityID: aInstNo, |
| 1406 | Attributes: requestedAttributes, |
| 1407 | } |
| 1408 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1409 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1410 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1411 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1412 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1413 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1414 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1415 | } |
| 1416 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1417 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1418 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1419 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1420 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1421 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1422 | } |
| 1423 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1424 | omciRxCallbackPair := CallbackPair{ |
| 1425 | CbKey: tid, |
| 1426 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1427 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1428 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1429 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1430 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1431 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1432 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1433 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1434 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1435 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1436 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1437 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1438 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1439 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1443 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1444 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1445 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1446 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1447 | 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] | 1448 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1449 | |
| 1450 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1451 | meParams := me.ParamData{ |
| 1452 | EntityID: aInstNo, |
| 1453 | Attributes: requestedAttributes, |
| 1454 | } |
| 1455 | meInstance, omciErr := me.NewUniG(meParams) |
| 1456 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1457 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1458 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1459 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1460 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1461 | return nil |
| 1462 | } |
| 1463 | |
| 1464 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1465 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1466 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1467 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1468 | return nil |
| 1469 | } |
| 1470 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1471 | omciRxCallbackPair := CallbackPair{ |
| 1472 | CbKey: tid, |
| 1473 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1474 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1475 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1476 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1477 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1478 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1479 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1480 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1481 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1482 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1483 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1484 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1485 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1486 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1487 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1488 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1489 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1490 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1491 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1492 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1493 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1494 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1495 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1496 | |
| 1497 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1498 | meParams := me.ParamData{ |
| 1499 | EntityID: aInstNo, |
| 1500 | Attributes: requestedAttributes, |
| 1501 | } |
| 1502 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1503 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1504 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1505 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1506 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1507 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1508 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1509 | } |
| 1510 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1511 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1512 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1513 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1514 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1515 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1516 | } |
| 1517 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1518 | omciRxCallbackPair := CallbackPair{ |
| 1519 | CbKey: tid, |
| 1520 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1521 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1522 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1523 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1524 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1525 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1526 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1527 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1528 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1529 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1530 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1531 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1532 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1533 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1534 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1535 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1536 | // SendGetMe gets ME instance |
| 1537 | 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] | 1538 | timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1539 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1540 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1541 | 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] | 1542 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1543 | |
| 1544 | meParams := me.ParamData{ |
| 1545 | EntityID: entityID, |
| 1546 | Attributes: requestedAttributes, |
| 1547 | } |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1548 | var messageSet omci.DeviceIdent = omci.BaselineIdent |
| 1549 | if isExtendedOmci { |
| 1550 | messageSet = omci.ExtendedIdent |
| 1551 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1552 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1553 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1554 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | d930cb2 | 2022-06-17 09:24:50 +0000 | [diff] [blame] | 1555 | 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] | 1556 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1557 | 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] | 1558 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1559 | } |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1560 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1561 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1562 | 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] | 1563 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1564 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1565 | omciRxCallbackPair := CallbackPair{ |
| 1566 | CbKey: tid, |
| 1567 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1568 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1569 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1570 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1571 | 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] | 1572 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1573 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1574 | 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] | 1575 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1576 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1577 | 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] | 1578 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1579 | } |
| 1580 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1581 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1582 | 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] | 1583 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1584 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1585 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1586 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1587 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1588 | |
| 1589 | request := &omci.GetRequest{ |
| 1590 | MeBasePacket: omci.MeBasePacket{ |
| 1591 | EntityInstance: entityID, |
| 1592 | EntityClass: classID, |
| 1593 | }, |
| 1594 | AttributeMask: requestedAttributesMask, |
| 1595 | } |
| 1596 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1597 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1598 | if err != nil { |
| 1599 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1600 | return err |
| 1601 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1602 | omciRxCallbackPair := CallbackPair{ |
| 1603 | CbKey: tid, |
| 1604 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1605 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1606 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1607 | if err != nil { |
| 1608 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1609 | return err |
| 1610 | } |
| 1611 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1612 | return nil |
| 1613 | } |
| 1614 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1615 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1616 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1617 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1618 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1619 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1620 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1621 | |
| 1622 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1623 | EntityID: aInstID, |
| 1624 | Attributes: me.AttributeValueMap{ |
| 1625 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1626 | me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF, |
| 1627 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF, |
| 1628 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF, |
| 1629 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF, |
| 1630 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF, |
| 1631 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF, |
| 1632 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF, |
| 1633 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF, |
| 1634 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF, |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1635 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1636 | } |
| 1637 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1638 | if omciErr.GetError() == nil { |
| 1639 | //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] | 1640 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1641 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1642 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1643 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1644 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1645 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1646 | } |
| 1647 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1648 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1649 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1650 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1651 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1652 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1653 | } |
| 1654 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1655 | omciRxCallbackPair := CallbackPair{ |
| 1656 | CbKey: tid, |
| 1657 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1658 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1659 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1660 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1661 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1662 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1663 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1664 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1665 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1666 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1667 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1668 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1669 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1670 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1671 | } |
| 1672 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1673 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1674 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1675 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1676 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1677 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1678 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1679 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1680 | |
| 1681 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1682 | if omciErr.GetError() == nil { |
| 1683 | //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] | 1684 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1685 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1686 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1687 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1688 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1689 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1690 | } |
| 1691 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1692 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1693 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1694 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1695 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1696 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1697 | } |
| 1698 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1699 | omciRxCallbackPair := CallbackPair{ |
| 1700 | CbKey: tid, |
| 1701 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1702 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1703 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1704 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1705 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1706 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1707 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1708 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1709 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1710 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1711 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1712 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1713 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1714 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1715 | } |
| 1716 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1717 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1718 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1719 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1720 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1721 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1722 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1723 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1724 | |
| 1725 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1726 | if omciErr.GetError() == nil { |
| 1727 | //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] | 1728 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1729 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1730 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1731 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1732 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1733 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1734 | } |
| 1735 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1736 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1737 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1738 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1739 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1740 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1741 | } |
| 1742 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1743 | omciRxCallbackPair := CallbackPair{ |
| 1744 | CbKey: tid, |
| 1745 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1746 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1747 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1748 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1749 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1750 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1751 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1752 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1753 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1754 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1755 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1756 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1757 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1758 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1759 | } |
| 1760 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1761 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1762 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1763 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1764 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1765 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1766 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1767 | |
| 1768 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1769 | if omciErr.GetError() == nil { |
| 1770 | //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] | 1771 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1772 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1773 | if err != nil { |
| 1774 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1775 | "Err": err, "device-id": oo.deviceID}) |
| 1776 | return nil, err |
| 1777 | } |
| 1778 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1779 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1780 | if err != nil { |
| 1781 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1782 | "Err": err, "device-id": oo.deviceID}) |
| 1783 | return nil, err |
| 1784 | } |
| 1785 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1786 | omciRxCallbackPair := CallbackPair{ |
| 1787 | CbKey: tid, |
| 1788 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1789 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1790 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1791 | if err != nil { |
| 1792 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1793 | "Err": err, "device-id": oo.deviceID}) |
| 1794 | return nil, err |
| 1795 | } |
| 1796 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1797 | return meInstance, nil |
| 1798 | } |
| 1799 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1800 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1801 | return nil, omciErr.GetError() |
| 1802 | } |
| 1803 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1804 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1805 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1806 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1807 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1808 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1809 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1810 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1811 | |
| 1812 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1813 | if omciErr.GetError() == nil { |
| 1814 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1815 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1816 | oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1817 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1818 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1819 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1820 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1821 | } |
| 1822 | |
Holger Hildebrandt | a6ef0e8 | 2022-04-06 13:11:32 +0000 | [diff] [blame] | 1823 | pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1824 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1825 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1826 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1827 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1828 | } |
| 1829 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1830 | omciRxCallbackPair := CallbackPair{ |
| 1831 | CbKey: tid, |
| 1832 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1833 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1834 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1835 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1836 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1837 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1838 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1839 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1840 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1841 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1842 | } |
|