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 | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
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" |
| 25 | "errors" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 26 | "fmt" |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 27 | "strconv" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 28 | "sync" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 29 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 30 | //"time" |
| 31 | |
| 32 | "github.com/google/gopacket" |
| 33 | // TODO!!! Some references could be resolved auto, but some need specific context .... |
| 34 | gp "github.com/google/gopacket" |
| 35 | |
| 36 | "github.com/opencord/omci-lib-go" |
| 37 | me "github.com/opencord/omci-lib-go/generated" |
| 38 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
| 39 | |
| 40 | //"github.com/opencord/voltha-lib-go/v3/pkg/kafka" |
| 41 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 42 | ic "github.com/opencord/voltha-protos/v3/go/inter_container" |
| 43 | //"github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 44 | //"github.com/opencord/voltha-protos/v3/go/voltha" |
| 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 | |
| 49 | //ConstDefaultOmciTimeout - Default OMCI Timeout |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 50 | const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds |
| 51 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 52 | const galEthernetEID = uint16(1) |
| 53 | const maxGemPayloadSize = uint16(48) |
| 54 | const connectivityModeValue = uint8(5) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 55 | |
| 56 | //const defaultTPID = uint16(0x8100) |
| 57 | //const broadComDefaultVID = uint16(4091) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 58 | const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning |
| 59 | const ieeeMapperServiceProfileEID = uint16(0x8001) |
| 60 | const macBridgePortAniEID = uint16(0x2102) |
| 61 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 62 | const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems |
| 63 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 64 | // ### OMCI related definitions - end |
| 65 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 66 | //callbackPairEntry to be used for OMCI send/receive correlation |
| 67 | type callbackPairEntry struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 68 | cbRespChannel chan Message |
| 69 | cbFunction func(*omci.OMCI, *gp.Packet, chan Message) error |
| 70 | } |
| 71 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 72 | //callbackPair to be used for ReceiveCallback init |
| 73 | type callbackPair struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 74 | cbKey uint16 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 75 | cbEntry callbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | type omciTransferStructure struct { |
| 79 | txFrame []byte |
| 80 | timeout int |
| 81 | retry int |
| 82 | highPrio bool |
| 83 | } |
| 84 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 85 | //omciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 86 | type omciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 87 | enabled bool |
| 88 | pOnuDeviceEntry *OnuDeviceEntry |
| 89 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 90 | pBaseDeviceHandler *deviceHandler |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 91 | coreProxy adapterif.CoreProxy |
| 92 | adapterProxy adapterif.AdapterProxy |
| 93 | supportExtMsg bool |
| 94 | //txRequest |
| 95 | //rxResponse |
| 96 | //pendingRequest |
| 97 | txFrames, txOnuFrames uint32 |
| 98 | rxFrames, rxOnuFrames, rxOnuDiscards uint32 |
| 99 | |
| 100 | // OMCI params |
| 101 | mutexTid sync.Mutex |
| 102 | tid uint16 |
| 103 | mutexHpTid sync.Mutex |
| 104 | hpTid uint16 |
| 105 | uploadSequNo uint16 |
| 106 | uploadNoOfCmds uint16 |
| 107 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 108 | mutexTxQueue sync.Mutex |
| 109 | txQueue *list.List |
| 110 | mutexRxSchedMap sync.Mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 111 | rxSchedulerMap map[uint16]callbackPairEntry |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 112 | pLastTxMeInstance *me.ManagedEntity |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 115 | //newOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 116 | //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 117 | func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry, |
| 118 | deviceID string, deviceHandler *deviceHandler, |
| 119 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC { |
Holger Hildebrandt | 80129db | 2020-11-23 10:49:32 +0000 | [diff] [blame] | 120 | logger.Debugw("init-omciCC", log.Fields{"device-id": deviceID}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 121 | var omciCC omciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 122 | omciCC.enabled = false |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 123 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 124 | omciCC.deviceID = deviceID |
| 125 | omciCC.pBaseDeviceHandler = deviceHandler |
| 126 | omciCC.coreProxy = coreProxy |
| 127 | omciCC.adapterProxy = adapterProxy |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 128 | omciCC.supportExtMsg = false |
| 129 | omciCC.txFrames = 0 |
| 130 | omciCC.txOnuFrames = 0 |
| 131 | omciCC.rxFrames = 0 |
| 132 | omciCC.rxOnuFrames = 0 |
| 133 | omciCC.rxOnuDiscards = 0 |
| 134 | omciCC.tid = 0x1 |
| 135 | omciCC.hpTid = 0x8000 |
| 136 | omciCC.uploadSequNo = 0 |
| 137 | omciCC.uploadNoOfCmds = 0 |
| 138 | |
| 139 | omciCC.txQueue = list.New() |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 140 | omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 141 | |
| 142 | return &omciCC |
| 143 | } |
| 144 | |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 145 | //stop stops/resets the omciCC |
| 146 | func (oo *omciCC) stop(ctx context.Context) error { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 147 | logger.Debugw("omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 148 | //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests |
| 149 | oo.mutexTxQueue.Lock() |
| 150 | oo.txQueue.Init() // clear the tx queue |
| 151 | oo.mutexTxQueue.Unlock() |
| 152 | oo.mutexRxSchedMap.Lock() |
| 153 | for k := range oo.rxSchedulerMap { |
| 154 | delete(oo.rxSchedulerMap, k) //clear the scheduler map |
| 155 | } |
| 156 | oo.mutexRxSchedMap.Unlock() |
| 157 | oo.mutexHpTid.Lock() |
| 158 | oo.hpTid = 0x8000 //reset the high prio transactionId |
| 159 | oo.mutexHpTid.Unlock() |
| 160 | oo.mutexTid.Lock() |
| 161 | oo.tid = 1 //reset the low prio transactionId |
| 162 | oo.mutexTid.Unlock() |
| 163 | //reset control values |
| 164 | oo.uploadSequNo = 0 |
| 165 | oo.uploadNoOfCmds = 0 |
| 166 | //reset the stats counter - which might be topic of discussion ... |
| 167 | oo.txFrames = 0 |
| 168 | oo.txOnuFrames = 0 |
| 169 | oo.rxFrames = 0 |
| 170 | oo.rxOnuFrames = 0 |
| 171 | oo.rxOnuDiscards = 0 |
| 172 | |
| 173 | return nil |
| 174 | } |
| 175 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 176 | // Rx handler for omci messages |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 177 | func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 178 | logger.Debugw("rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 179 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
| 180 | /* |
| 181 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 182 | rxOnuFrames++ |
| 183 | |
| 184 | switch msgType { |
| 185 | case AlarmNotification: |
| 186 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 187 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 188 | // python code was: |
| 189 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 190 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 191 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 192 | // |
| 193 | return errors.New("RxAlarmNotification unimplemented") |
| 194 | } |
| 195 | case AttributeValueChange: |
| 196 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 197 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 198 | // python code was: |
| 199 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 200 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 201 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 202 | // |
| 203 | return errors.New("RxAttributeValueChange unimplemented") |
| 204 | } |
| 205 | case TestResult: |
| 206 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 207 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 208 | // python code was: |
| 209 | //elif msg_type == EntityOperations.TestResult.value: |
| 210 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 211 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 212 | // |
| 213 | return errors.New("RxTestResult unimplemented") |
| 214 | } |
| 215 | default: |
| 216 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 217 | logger.Errorw("rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 218 | rxOnuDiscards++ |
| 219 | return errors.New("RxOnuMsgType unimplemented") |
| 220 | } |
| 221 | } |
| 222 | */ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 223 | return errors.New("receiveOnuMessage unimplemented") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // Rx handler for onu messages |
| 227 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 228 | func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 229 | //logger.Debugw("cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 230 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 231 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 232 | // (am extendedFormat message could be destroyed this way!) |
| 233 | trailerLenData := rxMsg[42:44] |
| 234 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 235 | //logger.Debugw("omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 236 | if trailerLen != 40 { // invalid base Format entry -> autocorrect |
| 237 | binary.BigEndian.PutUint16(rxMsg[42:44], 40) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 238 | logger.Debug("cc-corrected-omci-message: trailer len inserted") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 239 | } |
| 240 | } else { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 241 | logger.Errorw("received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 242 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy) |
| 246 | if packet == nil { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 247 | logger.Errorw("omci-message could not be decoded", log.Fields{"device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 248 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 249 | } |
| 250 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 251 | if omciLayer == nil { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 252 | logger.Errorw("omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 253 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 254 | } |
| 255 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 256 | if !ok { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 257 | logger.Errorw("omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 258 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 259 | } |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 260 | logger.Debugw("omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 261 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier}) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 262 | if byte(omciMsg.MessageType)&me.AK == 0 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 263 | // Not a response |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 264 | logger.Debug("RxMsg is no Omci Response Message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 265 | if omciMsg.TransactionID == 0 { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 266 | return oo.receiveOnuMessage(ctx, omciMsg) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 267 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 268 | logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 269 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 270 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 271 | 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] | 272 | |
| 273 | } |
| 274 | //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester") |
| 275 | oo.mutexRxSchedMap.Lock() |
| 276 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
| 277 | if ok && rxCallbackEntry.cbFunction != nil { |
| 278 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 279 | // how to react on erroneous frame reception, maybe can simply be ignored |
| 280 | go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel) |
| 281 | // having posted the response the request is regarded as 'done' |
| 282 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 283 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 284 | } else { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 285 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 286 | logger.Errorw("omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 287 | 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] | 288 | } |
| 289 | |
| 290 | return nil |
| 291 | /* py code was: |
| 292 | Receive and OMCI message from the proxy channel to the OLT. |
| 293 | |
| 294 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 295 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 296 | """ |
| 297 | if not self.enabled: |
| 298 | return |
| 299 | |
| 300 | try: |
| 301 | now = arrow.utcnow() |
| 302 | d = None |
| 303 | |
| 304 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 305 | # save the current value of the entity_id_to_class_map, then |
| 306 | # replace it with our custom one before decode, and then finally |
| 307 | # restore it later. Tried other ways but really made the code messy. |
| 308 | saved_me_map = omci_entities.entity_id_to_class_map |
| 309 | omci_entities.entity_id_to_class_map = self._me_map |
| 310 | |
| 311 | try: |
| 312 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 313 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 314 | except KeyError as e: |
| 315 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 316 | 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] | 317 | rx_frame = self._decode_unknown_me(msg) |
| 318 | self._rx_unknown_me += 1 |
| 319 | |
| 320 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 321 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 322 | return |
| 323 | |
| 324 | finally: |
| 325 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 326 | |
| 327 | rx_tid = rx_frame.fields['transaction_id'] |
| 328 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 329 | 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] | 330 | # Filter the Test Result frame and route through receive onu |
| 331 | # message method. |
| 332 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 333 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 334 | return self._receive_onu_message(rx_frame) |
| 335 | |
| 336 | # Previously unreachable if this is the very first round-trip Rx or we |
| 337 | # have been running consecutive errors |
| 338 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 339 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 340 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 341 | |
| 342 | self._rx_frames += 1 |
| 343 | self._consecutive_errors = 0 |
| 344 | |
| 345 | try: |
| 346 | high_priority = self._tid_is_high_priority(rx_tid) |
| 347 | index = self._get_priority_index(high_priority) |
| 348 | |
| 349 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 350 | last_tx_tuple = self._tx_request[index] |
| 351 | |
| 352 | if last_tx_tuple is None or \ |
| 353 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 354 | # Possible late Rx on a message that timed-out |
| 355 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 356 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 357 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 358 | self._rx_unknown_tid += 1 |
| 359 | self._rx_late += 1 |
| 360 | return |
| 361 | |
| 362 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 363 | if dc is not None and not dc.cancelled and not dc.called: |
| 364 | dc.cancel() |
| 365 | |
| 366 | _secs = self._update_rx_tx_stats(now, ts) |
| 367 | |
| 368 | # Late arrival already serviced by a timeout? |
| 369 | if d.called: |
| 370 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 371 | 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] | 372 | return |
| 373 | |
| 374 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 375 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 376 | if d is not None: |
| 377 | return d.errback(failure.Failure(e)) |
| 378 | return |
| 379 | |
| 380 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 381 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 382 | tx_tid = tx_frame.fields['transaction_id']) |
| 383 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 384 | |
| 385 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 386 | self._rx_response[index] = rx_frame |
| 387 | d.callback(rx_frame) |
| 388 | |
| 389 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 390 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 391 | */ |
| 392 | } |
| 393 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 394 | /* |
| 395 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 396 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 397 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 398 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 399 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 400 | |
| 401 | //Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 402 | func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 403 | receiveCallbackPair callbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 404 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 405 | logger.Debugw("register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 406 | // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ... |
| 407 | oo.mutexRxSchedMap.Lock() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 408 | oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 409 | oo.mutexRxSchedMap.Unlock() |
| 410 | |
| 411 | //just use a simple list for starting - might need some more effort, especially for multi source write access |
| 412 | omciTxRequest := omciTransferStructure{ |
| 413 | txFrame, |
| 414 | timeout, |
| 415 | retry, |
| 416 | highPrio, |
| 417 | } |
| 418 | oo.mutexTxQueue.Lock() |
| 419 | oo.txQueue.PushBack(omciTxRequest) // enqueue |
| 420 | oo.mutexTxQueue.Unlock() |
| 421 | |
| 422 | // for first test just bypass and send directly: |
| 423 | go oo.sendNextRequest(ctx) |
| 424 | return nil |
| 425 | } |
| 426 | |
| 427 | //Pull next tx request and send it |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 428 | func (oo *omciCC) sendNextRequest(ctx context.Context) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 429 | // return errors.New("sendNextRequest unimplemented") |
| 430 | |
| 431 | // just try to get something transferred !! |
| 432 | // avoid accessing the txQueue from parallel send requests |
| 433 | // block parallel omci send requests at least until SendIAP is 'committed' |
| 434 | // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed |
| 435 | oo.mutexTxQueue.Lock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 436 | defer oo.mutexTxQueue.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 437 | for oo.txQueue.Len() > 0 { |
| 438 | queueElement := oo.txQueue.Front() // First element |
| 439 | omciTxRequest := queueElement.Value.(omciTransferStructure) |
| 440 | /* compare olt device handler code: |
| 441 | func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 442 | logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 443 | var deviceType string |
| 444 | var deviceID string |
| 445 | var proxyDeviceID string |
| 446 | |
| 447 | onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId) |
| 448 | |
| 449 | if onuInCache, ok := dh.onus.Load(onuKey); !ok { |
| 450 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 451 | logger.Debugw("omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 452 | ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT) |
| 453 | kwargs := make(map[string]interface{}) |
| 454 | kwargs["onu_id"] = omciInd.OnuId |
| 455 | kwargs["parent_port_no"] = ponPort |
| 456 | |
| 457 | onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs) |
| 458 | if err != nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 459 | logger.Errorw("onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 460 | return |
| 461 | } |
| 462 | deviceType = onuDevice.Type |
| 463 | deviceID = onuDevice.Id |
| 464 | proxyDeviceID = onuDevice.ProxyAddress.DeviceId |
| 465 | //if not exist in cache, then add to cache. |
| 466 | dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID)) |
| 467 | } else { |
| 468 | //found in cache |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 469 | logger.Debugw("omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 470 | deviceType = onuInCache.(*OnuDevice).deviceType |
| 471 | deviceID = onuInCache.(*OnuDevice).deviceID |
| 472 | proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID |
| 473 | } |
| 474 | */ |
| 475 | /* and compare onu_adapter py code: |
| 476 | omci_msg = InterAdapterOmciMessage( |
| 477 | message=bytes(frame), |
| 478 | proxy_address=self._proxy_address, |
| 479 | connect_status=self._device.connect_status) |
| 480 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 481 | self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame))) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 482 | |
| 483 | yield self._adapter_proxy.send_inter_adapter_message( |
| 484 | msg=omci_msg, |
| 485 | type=InterAdapterMessageType.OMCI_REQUEST, |
| 486 | from_adapter=self._device.type, |
| 487 | to_adapter=self._proxy_address.device_type, |
| 488 | to_device_id=self._device_id, |
| 489 | proxy_device_id=self._proxy_address.device_id |
| 490 | ) |
| 491 | */ |
| 492 | device, err := oo.coreProxy.GetDevice(ctx, |
| 493 | oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child |
| 494 | if err != nil || device == nil { |
| 495 | /*TODO: needs to handle error scenarios */ |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 496 | logger.Errorw("Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 497 | "ChildId": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 498 | return fmt.Errorf("failed to fetch device %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 499 | } |
| 500 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 501 | logger.Debugw("omci-message-to-send:", log.Fields{ |
| 502 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 503 | "device-id": oo.deviceID, |
| 504 | "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType, |
| 505 | "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 506 | |
| 507 | omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame} |
| 508 | if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg, |
| 509 | ic.InterAdapterMessageType_OMCI_REQUEST, |
Matteo Scandolo | efbec27 | 2020-11-17 10:33:09 -0800 | [diff] [blame] | 510 | //fromTopic,toType,toDevId, ProxyDevId |
| 511 | oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 512 | oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 513 | logger.Errorw("send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 514 | return sendErr |
| 515 | } |
| 516 | oo.txQueue.Remove(queueElement) // Dequeue |
| 517 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 518 | return nil |
| 519 | } |
| 520 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 521 | func (oo *omciCC) getNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 522 | var next uint16 |
| 523 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 524 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 525 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 526 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 527 | if oo.hpTid < 0x8000 { |
| 528 | oo.hpTid = 0x8000 |
| 529 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 530 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 531 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 532 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 533 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 534 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 535 | if oo.tid >= 0x8000 { |
| 536 | oo.tid = 1 |
| 537 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 538 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 539 | } |
| 540 | return next |
| 541 | } |
| 542 | |
| 543 | // ################################################################################### |
| 544 | // # utility methods provided to work on OMCI messages |
| 545 | func serialize(msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) { |
| 546 | omciLayer := &omci.OMCI{ |
| 547 | TransactionID: tid, |
| 548 | MessageType: msgType, |
| 549 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 550 | return serializeOmciLayer(omciLayer, request) |
| 551 | } |
| 552 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 553 | func serializeOmciLayer(aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 554 | var options gopacket.SerializeOptions |
| 555 | options.FixLengths = true |
| 556 | |
| 557 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 558 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 559 | if err != nil { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 560 | logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 561 | return nil, err |
| 562 | } |
| 563 | return buffer.Bytes(), nil |
| 564 | } |
| 565 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 566 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 567 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 568 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 569 | hex.Encode(dst, omciPkt) |
| 570 | return dst, nil |
| 571 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 572 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 573 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 574 | //supply a response handler for omci response messages to be transferred to the requested FSM |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 575 | func (oo *omciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 576 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 577 | logger.Debugw("omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType, |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 578 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 579 | |
| 580 | if oo.pOnuDeviceEntry == nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 581 | logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 582 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 583 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 587 | // 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] | 588 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 589 | Type: OMCI, |
| 590 | Data: OmciMessage{ |
| 591 | OmciMsg: omciMsg, |
| 592 | OmciPacket: packet, |
| 593 | }, |
| 594 | } |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 595 | //logger.Debugw("Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 596 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 597 | |
| 598 | return nil |
| 599 | } |
| 600 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 601 | func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 602 | |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 603 | logger.Debugw("send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 604 | request := &omci.MibResetRequest{ |
| 605 | MeBasePacket: omci.MeBasePacket{ |
| 606 | EntityClass: me.OnuDataClassID, |
| 607 | }, |
| 608 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 609 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 610 | pkt, err := serialize(omci.MibResetRequestType, request, tid) |
| 611 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 612 | logger.Errorw("Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 613 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 614 | return err |
| 615 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 616 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 617 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 618 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 619 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 620 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 621 | } |
| 622 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 623 | func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 624 | logger.Debugw("send Reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 625 | request := &omci.RebootRequest{ |
| 626 | MeBasePacket: omci.MeBasePacket{ |
| 627 | EntityClass: me.OnuGClassID, |
| 628 | }, |
| 629 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 630 | tid := oo.getNextTid(highPrio) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 631 | pkt, err := serialize(omci.RebootRequestType, request, tid) |
| 632 | if err != nil { |
| 633 | logger.Errorw("Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 634 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 635 | return err |
| 636 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 637 | omciRxCallbackPair := callbackPair{ |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 638 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 639 | cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 640 | } |
| 641 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 642 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 643 | if err != nil { |
| 644 | logger.Errorw("Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 645 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 646 | return err |
| 647 | } |
| 648 | err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel) |
| 649 | if err != nil { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 650 | logger.Errorw("aborting ONU Reboot!", log.Fields{ |
| 651 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 652 | return err |
| 653 | } |
| 654 | return nil |
| 655 | } |
| 656 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 657 | func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 658 | logger.Debugw("send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 659 | request := &omci.MibUploadRequest{ |
| 660 | MeBasePacket: omci.MeBasePacket{ |
| 661 | EntityClass: me.OnuDataClassID, |
| 662 | }, |
| 663 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 664 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 665 | pkt, err := serialize(omci.MibUploadRequestType, request, tid) |
| 666 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 667 | logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 668 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 669 | return err |
| 670 | } |
| 671 | oo.uploadSequNo = 0 |
| 672 | oo.uploadNoOfCmds = 0 |
| 673 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 674 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 675 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 676 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 677 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 678 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 681 | func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 682 | logger.Debugw("send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 683 | request := &omci.MibUploadNextRequest{ |
| 684 | MeBasePacket: omci.MeBasePacket{ |
| 685 | EntityClass: me.OnuDataClassID, |
| 686 | }, |
| 687 | CommandSequenceNumber: oo.uploadSequNo, |
| 688 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 689 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 690 | pkt, err := serialize(omci.MibUploadNextRequestType, request, tid) |
| 691 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 692 | logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 693 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 694 | return err |
| 695 | } |
| 696 | oo.uploadSequNo++ |
| 697 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 698 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 699 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 700 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 701 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 702 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 703 | } |
| 704 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 705 | func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 706 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 707 | logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 708 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 709 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 710 | meParams := me.ParamData{ |
| 711 | EntityID: galEthernetEID, |
| 712 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 713 | } |
| 714 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 715 | if omciErr.GetError() == nil { |
| 716 | //all setByCreate parameters already set, no default option required ... |
| 717 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 718 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 719 | logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 720 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 721 | return nil |
| 722 | } |
| 723 | |
| 724 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 725 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 726 | logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 727 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 728 | return nil |
| 729 | } |
| 730 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 731 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 732 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 733 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 734 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 735 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 736 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 737 | logger.Errorw("Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 738 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 739 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 740 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 741 | logger.Debug("send GalEnetProfile-Create-msg done") |
| 742 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 743 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 744 | logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 745 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 746 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 747 | } |
| 748 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 749 | // might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!! |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 750 | func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 751 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 752 | logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 753 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 754 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 755 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 756 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 757 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 758 | // read ONU-2G from DB ???? //TODO!!! |
| 759 | meParams := me.ParamData{ |
| 760 | EntityID: 0, |
| 761 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 762 | } |
| 763 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 764 | if omciErr.GetError() == nil { |
| 765 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 766 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 767 | logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 768 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 769 | return nil |
| 770 | } |
| 771 | |
| 772 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 773 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 774 | logger.Errorw("Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 775 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 776 | return nil |
| 777 | } |
| 778 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 779 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 780 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 781 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 782 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 783 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 784 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 785 | logger.Errorw("Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 786 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 787 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 788 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 789 | logger.Debug("send ONU2-G-Set-msg done") |
| 790 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 791 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 792 | logger.Errorw("Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 793 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 794 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 795 | } |
| 796 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 797 | func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context, |
| 798 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 799 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 800 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 801 | logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 802 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 803 | |
| 804 | meParams := me.ParamData{ |
| 805 | EntityID: instID, |
| 806 | Attributes: me.AttributeValueMap{ |
| 807 | "Priority": 0x8000, |
| 808 | "MaxAge": 20 * 256, //20s |
| 809 | "HelloTime": 2 * 256, //2s |
| 810 | "ForwardDelay": 15 * 256, //15s |
| 811 | //note: DynamicFilteringAgeingTime is taken from omci lib default as |
| 812 | // which is obviously different from default value used in python lib, |
| 813 | // where the value seems to be 0 (ONU defined) - to be considered in case of test artifacts ... |
| 814 | }, |
| 815 | } |
| 816 | |
| 817 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 818 | if omciErr.GetError() == nil { |
| 819 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 820 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 821 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 822 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 823 | logger.Errorw("Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 824 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 825 | return nil |
| 826 | } |
| 827 | |
| 828 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 829 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 830 | logger.Errorw("Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 831 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 832 | return nil |
| 833 | } |
| 834 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 835 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 836 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 837 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 838 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 839 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 840 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 841 | logger.Errorw("Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 842 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 843 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 844 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 845 | logger.Debug("send MBSP-Create-msg done") |
| 846 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 847 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 848 | logger.Errorw("Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 849 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 850 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 851 | } |
| 852 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 853 | func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context, |
| 854 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 855 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 856 | instID := macBridgePortAniEID + aPUniPort.entityID |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 857 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 858 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 859 | |
| 860 | meParams := me.ParamData{ |
| 861 | EntityID: instID, |
| 862 | Attributes: me.AttributeValueMap{ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 863 | "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo), |
| 864 | "PortNum": aPUniPort.macBpNo, |
| 865 | "TpType": uint8(aPUniPort.portType), |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 866 | "TpPointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 867 | }, |
| 868 | } |
| 869 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 870 | if omciErr.GetError() == nil { |
| 871 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 872 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 873 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 874 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 875 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 876 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 877 | return nil |
| 878 | } |
| 879 | |
| 880 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 881 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 882 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 883 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 884 | return nil |
| 885 | } |
| 886 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 887 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 888 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 889 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 890 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 891 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 892 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 893 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 894 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 895 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 896 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 897 | logger.Debug("send MBPCD-Create-msg done") |
| 898 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 899 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 900 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 901 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 902 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 903 | } |
| 904 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 905 | func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context, |
| 906 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 907 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 908 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 909 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 910 | logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 911 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 912 | |
| 913 | // compare python adapter code WA VOL-1311: this is not done here! |
| 914 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 915 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 916 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 917 | if aPUniPort.portType == uniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 918 | assType = uint8(10) // for VEIP |
| 919 | } |
| 920 | meParams := me.ParamData{ |
| 921 | EntityID: instID, |
| 922 | Attributes: me.AttributeValueMap{ |
| 923 | "AssociationType": assType, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 924 | "AssociatedMePointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 925 | }, |
| 926 | } |
| 927 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 928 | if omciErr.GetError() == nil { |
| 929 | //all setByCreate parameters already set, no default option required ... |
| 930 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 931 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 932 | logger.Errorw("Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 933 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 934 | return nil |
| 935 | } |
| 936 | |
| 937 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 938 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 939 | logger.Errorw("Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 940 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 941 | return nil |
| 942 | } |
| 943 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 944 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 945 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 946 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 947 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 948 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 949 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 950 | logger.Errorw("Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 951 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 952 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 953 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 954 | logger.Debug("send EVTOCD-Create-msg done") |
| 955 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 956 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 957 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 958 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 959 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 960 | } |
| 961 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 962 | func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 963 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 964 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 965 | logger.Debugw("send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 966 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 967 | |
| 968 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 969 | meParams := me.ParamData{ |
| 970 | EntityID: 0, |
| 971 | Attributes: requestedAttributes, |
| 972 | } |
| 973 | meInstance, omciErr := me.NewOnuG(meParams) |
| 974 | if omciErr.GetError() == nil { |
| 975 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 976 | if err != nil { |
| 977 | logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 978 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 979 | return nil |
| 980 | } |
| 981 | |
| 982 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 983 | if err != nil { |
| 984 | logger.Errorw("Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 985 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 986 | return nil |
| 987 | } |
| 988 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 989 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 990 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 991 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 992 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 993 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 994 | if err != nil { |
| 995 | logger.Errorw("Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 996 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 997 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 998 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 999 | logger.Debug("send ONU-G-Set-msg done") |
| 1000 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1001 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1002 | logger.Errorw("Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1003 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1004 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1005 | } |
| 1006 | |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1007 | func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
| 1008 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 1009 | tid := oo.getNextTid(highPrio) |
| 1010 | logger.Debugw("send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1011 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1012 | |
| 1013 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1014 | meParams := me.ParamData{ |
| 1015 | EntityID: aInstNo, |
| 1016 | Attributes: requestedAttributes, |
| 1017 | } |
| 1018 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1019 | if omciErr.GetError() == nil { |
| 1020 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1021 | if err != nil { |
| 1022 | logger.Errorw("Cannot encode PPTPEthUni instance for set", log.Fields{ |
| 1023 | "Err": err, "device-id": oo.deviceID}) |
| 1024 | return nil |
| 1025 | } |
| 1026 | |
| 1027 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1028 | if err != nil { |
| 1029 | logger.Errorw("Cannot serialize PPTPEthUni-Set", log.Fields{ |
| 1030 | "Err": err, "device-id": oo.deviceID}) |
| 1031 | return nil |
| 1032 | } |
| 1033 | |
| 1034 | omciRxCallbackPair := callbackPair{ |
| 1035 | cbKey: tid, |
| 1036 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1037 | } |
| 1038 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1039 | if err != nil { |
| 1040 | logger.Errorw("Cannot send PPTPEthUni-Set", log.Fields{ |
| 1041 | "Err": err, "device-id": oo.deviceID}) |
| 1042 | return nil |
| 1043 | } |
| 1044 | logger.Debug("send PPTPEthUni-Set-msg done") |
| 1045 | return meInstance |
| 1046 | } |
| 1047 | logger.Errorw("Cannot generate PPTPEthUni", log.Fields{ |
| 1048 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1049 | return nil |
| 1050 | } |
| 1051 | |
| 1052 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1053 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1054 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1055 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1056 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1057 | logger.Debugw("send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1058 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1059 | |
| 1060 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1061 | meParams := me.ParamData{ |
| 1062 | EntityID: aInstNo, |
| 1063 | Attributes: requestedAttributes, |
| 1064 | } |
| 1065 | meInstance, omciErr := me.NewUniG(meParams) |
| 1066 | if omciErr.GetError() == nil { |
| 1067 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1068 | if err != nil { |
| 1069 | logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1070 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1071 | return nil |
| 1072 | } |
| 1073 | |
| 1074 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1075 | if err != nil { |
| 1076 | logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1077 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1078 | return nil |
| 1079 | } |
| 1080 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1081 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1082 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1083 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1084 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1085 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1086 | if err != nil { |
| 1087 | logger.Errorw("Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1088 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1089 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1090 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1091 | logger.Debug("send UNI-G-Set-msg done") |
| 1092 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1093 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1094 | logger.Errorw("Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1095 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1096 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1097 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1098 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1099 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1100 | func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1101 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1102 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1103 | logger.Debugw("send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1104 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1105 | |
| 1106 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1107 | meParams := me.ParamData{ |
| 1108 | EntityID: aInstNo, |
| 1109 | Attributes: requestedAttributes, |
| 1110 | } |
| 1111 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1112 | if omciErr.GetError() == nil { |
| 1113 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1114 | if err != nil { |
| 1115 | logger.Errorw("Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1116 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1117 | return nil |
| 1118 | } |
| 1119 | |
| 1120 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1121 | if err != nil { |
| 1122 | logger.Errorw("Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1123 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1124 | return nil |
| 1125 | } |
| 1126 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1127 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1128 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1129 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1130 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1131 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1132 | if err != nil { |
| 1133 | logger.Errorw("Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1134 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1135 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1136 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1137 | logger.Debug("send VEIP-Set-msg done") |
| 1138 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1139 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1140 | logger.Errorw("Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1141 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1142 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1143 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1144 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1145 | func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1146 | timeout int, highPrio bool) *me.ManagedEntity { |
| 1147 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1148 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1149 | logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1150 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1151 | |
| 1152 | meParams := me.ParamData{ |
| 1153 | EntityID: entityID, |
| 1154 | Attributes: requestedAttributes, |
| 1155 | } |
| 1156 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1157 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1158 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1159 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid)) |
| 1160 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1161 | logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1162 | return nil |
| 1163 | } |
| 1164 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1165 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1166 | logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1167 | return nil |
| 1168 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1169 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1170 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1171 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1172 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1173 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1174 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1175 | logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1176 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1177 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1178 | logger.Debugw("send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1179 | return meInstance |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1180 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1181 | logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1182 | return nil |
| 1183 | } |
| 1184 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1185 | func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1186 | aInstID uint16, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1187 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1188 | logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1189 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1190 | |
| 1191 | meParams := me.ParamData{ |
| 1192 | EntityID: aInstID, |
| 1193 | Attributes: me.AttributeValueMap{}, |
| 1194 | } |
| 1195 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1196 | if omciErr.GetError() == nil { |
| 1197 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1198 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1199 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1200 | if err != nil { |
| 1201 | logger.Errorw("Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1202 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1203 | return nil |
| 1204 | } |
| 1205 | |
| 1206 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1207 | if err != nil { |
| 1208 | logger.Errorw("Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1209 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1210 | return nil |
| 1211 | } |
| 1212 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1213 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1214 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1215 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1216 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1217 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1218 | if err != nil { |
| 1219 | logger.Errorw("Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1220 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1221 | return nil |
| 1222 | } |
| 1223 | logger.Debug("send .1pMapper-create-msg done") |
| 1224 | return meInstance |
| 1225 | } |
| 1226 | logger.Errorw("Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1227 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1228 | return nil |
| 1229 | } |
| 1230 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1231 | func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1232 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1233 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1234 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1235 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1236 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1237 | |
| 1238 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1239 | if omciErr.GetError() == nil { |
| 1240 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1241 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1242 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1243 | if err != nil { |
| 1244 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1245 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1246 | return nil |
| 1247 | } |
| 1248 | |
| 1249 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1250 | if err != nil { |
| 1251 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1252 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1253 | return nil |
| 1254 | } |
| 1255 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1256 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1257 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1258 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1259 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1260 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1261 | if err != nil { |
| 1262 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1263 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1264 | return nil |
| 1265 | } |
| 1266 | logger.Debug("send MBPCD-Create-msg done") |
| 1267 | return meInstance |
| 1268 | } |
| 1269 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1270 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1271 | return nil |
| 1272 | } |
| 1273 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1274 | func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1275 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1276 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1277 | logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1278 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1279 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1280 | |
| 1281 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1282 | if omciErr.GetError() == nil { |
| 1283 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1284 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1285 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1286 | if err != nil { |
| 1287 | logger.Errorw("Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1288 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1289 | return nil |
| 1290 | } |
| 1291 | |
| 1292 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1293 | if err != nil { |
| 1294 | logger.Errorw("Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1295 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1296 | return nil |
| 1297 | } |
| 1298 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1299 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1300 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1301 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1302 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1303 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1304 | if err != nil { |
| 1305 | logger.Errorw("Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1306 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1307 | return nil |
| 1308 | } |
| 1309 | logger.Debug("send GemNCTP-Create-msg done") |
| 1310 | return meInstance |
| 1311 | } |
| 1312 | logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1313 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1314 | return nil |
| 1315 | } |
| 1316 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1317 | func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1318 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1319 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1320 | logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1321 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1322 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1323 | |
| 1324 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1325 | if omciErr.GetError() == nil { |
| 1326 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1327 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1328 | omci.TransactionID(tid)) |
| 1329 | if err != nil { |
| 1330 | logger.Errorw("Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1331 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1332 | return nil |
| 1333 | } |
| 1334 | |
| 1335 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1336 | if err != nil { |
| 1337 | logger.Errorw("Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1338 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1339 | return nil |
| 1340 | } |
| 1341 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1342 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1343 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1344 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1345 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1346 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1347 | if err != nil { |
| 1348 | logger.Errorw("Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1349 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1350 | return nil |
| 1351 | } |
| 1352 | logger.Debug("send GemIwTp-Create-msg done") |
| 1353 | return meInstance |
| 1354 | } |
| 1355 | logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1356 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1357 | return nil |
| 1358 | } |
| 1359 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1360 | func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1361 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1362 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1363 | logger.Debugw("send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1364 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1365 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1366 | |
| 1367 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1368 | if omciErr.GetError() == nil { |
| 1369 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1370 | if err != nil { |
| 1371 | logger.Errorw("Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1372 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1373 | return nil |
| 1374 | } |
| 1375 | |
| 1376 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1377 | if err != nil { |
| 1378 | logger.Errorw("Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1379 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1380 | return nil |
| 1381 | } |
| 1382 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1383 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1384 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1385 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1386 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1387 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1388 | if err != nil { |
| 1389 | logger.Errorw("Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1390 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1391 | return nil |
| 1392 | } |
| 1393 | logger.Debug("send TCont-set msg done") |
| 1394 | return meInstance |
| 1395 | } |
| 1396 | logger.Errorw("Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1397 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1398 | return nil |
| 1399 | } |
| 1400 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1401 | func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1402 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1403 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1404 | logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1405 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1406 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1407 | |
| 1408 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1409 | if omciErr.GetError() == nil { |
| 1410 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1411 | if err != nil { |
| 1412 | logger.Errorw("Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1413 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1414 | return nil |
| 1415 | } |
| 1416 | |
| 1417 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1418 | if err != nil { |
| 1419 | logger.Errorw("Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1420 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1421 | return nil |
| 1422 | } |
| 1423 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1424 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1425 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1426 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1427 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1428 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1429 | if err != nil { |
| 1430 | logger.Errorw("Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1431 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1432 | return nil |
| 1433 | } |
| 1434 | logger.Debug("send PrioQueue-set msg done") |
| 1435 | return meInstance |
| 1436 | } |
| 1437 | logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1438 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1439 | return nil |
| 1440 | } |
| 1441 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1442 | func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1443 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1444 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1445 | logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1446 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1447 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1448 | |
| 1449 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1450 | if omciErr.GetError() == nil { |
| 1451 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1452 | if err != nil { |
| 1453 | logger.Errorw("Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1454 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1455 | return nil |
| 1456 | } |
| 1457 | |
| 1458 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1459 | if err != nil { |
| 1460 | logger.Errorw("Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1461 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1462 | return nil |
| 1463 | } |
| 1464 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1465 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1466 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1467 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1468 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1469 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1470 | if err != nil { |
| 1471 | logger.Errorw("Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1472 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1473 | return nil |
| 1474 | } |
| 1475 | logger.Debug("send 1PMapper-set msg done") |
| 1476 | return meInstance |
| 1477 | } |
| 1478 | logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1479 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1480 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1481 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1482 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1483 | func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1484 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1485 | tid := oo.getNextTid(highPrio) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1486 | logger.Debugw("send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1487 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1488 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1489 | |
| 1490 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1491 | if omciErr.GetError() == nil { |
| 1492 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1493 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1494 | omci.TransactionID(tid)) |
| 1495 | if err != nil { |
| 1496 | logger.Errorw("Cannot encode VTFD for create", log.Fields{ |
| 1497 | "Err": err, "device-id": oo.deviceID}) |
| 1498 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1499 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1500 | // (relevant to all used sendXX() methods and their error conditions) |
| 1501 | return nil |
| 1502 | } |
| 1503 | |
| 1504 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1505 | if err != nil { |
| 1506 | logger.Errorw("Cannot serialize VTFD create", log.Fields{ |
| 1507 | "Err": err, "device-id": oo.deviceID}) |
| 1508 | return nil |
| 1509 | } |
| 1510 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1511 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1512 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1513 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1514 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1515 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1516 | if err != nil { |
| 1517 | logger.Errorw("Cannot send VTFD create", log.Fields{ |
| 1518 | "Err": err, "device-id": oo.deviceID}) |
| 1519 | return nil |
| 1520 | } |
| 1521 | logger.Debug("send VTFD-Create-msg done") |
| 1522 | return meInstance |
| 1523 | } |
| 1524 | logger.Errorw("Cannot generate VTFD Instance", log.Fields{ |
| 1525 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1526 | return nil |
| 1527 | } |
| 1528 | |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1529 | func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
| 1530 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1531 | tid := oo.getNextTid(highPrio) |
| 1532 | logger.Debugw("send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1533 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1534 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1535 | |
| 1536 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1537 | if omciErr.GetError() == nil { |
| 1538 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, |
| 1539 | omci.TransactionID(tid)) |
| 1540 | if err != nil { |
| 1541 | logger.Errorw("Cannot encode VTFD for set", log.Fields{ |
| 1542 | "Err": err, "device-id": oo.deviceID}) |
| 1543 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1544 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1545 | // (relevant to all used sendXX() methods and their error conditions) |
| 1546 | return nil |
| 1547 | } |
| 1548 | |
| 1549 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1550 | if err != nil { |
| 1551 | logger.Errorw("Cannot serialize VTFD set", log.Fields{ |
| 1552 | "Err": err, "device-id": oo.deviceID}) |
| 1553 | return nil |
| 1554 | } |
| 1555 | |
| 1556 | omciRxCallbackPair := callbackPair{ |
| 1557 | cbKey: tid, |
| 1558 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1559 | } |
| 1560 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1561 | if err != nil { |
| 1562 | logger.Errorw("Cannot send VTFD set", log.Fields{ |
| 1563 | "Err": err, "device-id": oo.deviceID}) |
| 1564 | return nil |
| 1565 | } |
| 1566 | logger.Debug("send VTFD-Set-msg done") |
| 1567 | return meInstance |
| 1568 | } |
| 1569 | logger.Errorw("Cannot generate VTFD Instance", log.Fields{ |
| 1570 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1571 | return nil |
| 1572 | } |
| 1573 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1574 | func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1575 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1576 | tid := oo.getNextTid(highPrio) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1577 | logger.Debugw("send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1578 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1579 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1580 | |
| 1581 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1582 | if omciErr.GetError() == nil { |
| 1583 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1584 | if err != nil { |
| 1585 | logger.Errorw("Cannot encode EVTOCD for set", log.Fields{ |
| 1586 | "Err": err, "device-id": oo.deviceID}) |
| 1587 | return nil |
| 1588 | } |
| 1589 | |
| 1590 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1591 | if err != nil { |
| 1592 | logger.Errorw("Cannot serialize EVTOCD set", log.Fields{ |
| 1593 | "Err": err, "device-id": oo.deviceID}) |
| 1594 | return nil |
| 1595 | } |
| 1596 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1597 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1598 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1599 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1600 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1601 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1602 | if err != nil { |
| 1603 | logger.Errorw("Cannot send EVTOCD set", log.Fields{ |
| 1604 | "Err": err, "device-id": oo.deviceID}) |
| 1605 | return nil |
| 1606 | } |
| 1607 | logger.Debug("send EVTOCD-set msg done") |
| 1608 | return meInstance |
| 1609 | } |
| 1610 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
| 1611 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1612 | return nil |
| 1613 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1614 | |
| 1615 | func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
| 1616 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1617 | tid := oo.getNextTid(highPrio) |
| 1618 | logger.Debugw("send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1619 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1620 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1621 | |
| 1622 | meParams := me.ParamData{EntityID: aInstID} |
| 1623 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 1624 | if omciErr.GetError() == nil { |
| 1625 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1626 | omci.TransactionID(tid)) |
| 1627 | if err != nil { |
| 1628 | logger.Errorw("Cannot encode VTFD for delete", log.Fields{ |
| 1629 | "Err": err, "device-id": oo.deviceID}) |
| 1630 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1631 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1632 | // (relevant to all used sendXX() methods and their error conditions) |
| 1633 | return nil |
| 1634 | } |
| 1635 | |
| 1636 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1637 | if err != nil { |
| 1638 | logger.Errorw("Cannot serialize VTFD delete", log.Fields{ |
| 1639 | "Err": err, "device-id": oo.deviceID}) |
| 1640 | return nil |
| 1641 | } |
| 1642 | |
| 1643 | omciRxCallbackPair := callbackPair{ |
| 1644 | cbKey: tid, |
| 1645 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1646 | } |
| 1647 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1648 | if err != nil { |
| 1649 | logger.Errorw("Cannot send VTFD delete", log.Fields{ |
| 1650 | "Err": err, "device-id": oo.deviceID}) |
| 1651 | return nil |
| 1652 | } |
| 1653 | logger.Debug("send VTFD-Delete-msg done") |
| 1654 | return meInstance |
| 1655 | } |
| 1656 | logger.Errorw("Cannot generate VTFD Instance for delete", log.Fields{ |
| 1657 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1658 | return nil |
| 1659 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1660 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1661 | func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
| 1662 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1663 | tid := oo.getNextTid(highPrio) |
| 1664 | logger.Debugw("send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1665 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1666 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1667 | |
| 1668 | meParams := me.ParamData{EntityID: aInstID} |
| 1669 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 1670 | if omciErr.GetError() == nil { |
| 1671 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1672 | omci.TransactionID(tid)) |
| 1673 | if err != nil { |
| 1674 | logger.Errorw("Cannot encode GemIwTp for delete", log.Fields{ |
| 1675 | "Err": err, "device-id": oo.deviceID}) |
| 1676 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1677 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1678 | // (relevant to all used sendXX() methods and their error conditions) |
| 1679 | return nil |
| 1680 | } |
| 1681 | |
| 1682 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1683 | if err != nil { |
| 1684 | logger.Errorw("Cannot serialize GemIwTp delete", log.Fields{ |
| 1685 | "Err": err, "device-id": oo.deviceID}) |
| 1686 | return nil |
| 1687 | } |
| 1688 | |
| 1689 | omciRxCallbackPair := callbackPair{ |
| 1690 | cbKey: tid, |
| 1691 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1692 | } |
| 1693 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1694 | if err != nil { |
| 1695 | logger.Errorw("Cannot send GemIwTp delete", log.Fields{ |
| 1696 | "Err": err, "device-id": oo.deviceID}) |
| 1697 | return nil |
| 1698 | } |
| 1699 | logger.Debug("send GemIwTp-Delete-msg done") |
| 1700 | return meInstance |
| 1701 | } |
| 1702 | logger.Errorw("Cannot generate GemIwTp Instance for delete", log.Fields{ |
| 1703 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1704 | return nil |
| 1705 | } |
| 1706 | |
| 1707 | func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
| 1708 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1709 | tid := oo.getNextTid(highPrio) |
| 1710 | logger.Debugw("send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1711 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1712 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1713 | |
| 1714 | meParams := me.ParamData{EntityID: aInstID} |
| 1715 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 1716 | if omciErr.GetError() == nil { |
| 1717 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1718 | omci.TransactionID(tid)) |
| 1719 | if err != nil { |
| 1720 | logger.Errorw("Cannot encode GemNCtp for delete", log.Fields{ |
| 1721 | "Err": err, "device-id": oo.deviceID}) |
| 1722 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1723 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1724 | // (relevant to all used sendXX() methods and their error conditions) |
| 1725 | return nil |
| 1726 | } |
| 1727 | |
| 1728 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1729 | if err != nil { |
| 1730 | logger.Errorw("Cannot serialize GemNCtp delete", log.Fields{ |
| 1731 | "Err": err, "device-id": oo.deviceID}) |
| 1732 | return nil |
| 1733 | } |
| 1734 | |
| 1735 | omciRxCallbackPair := callbackPair{ |
| 1736 | cbKey: tid, |
| 1737 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1738 | } |
| 1739 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1740 | if err != nil { |
| 1741 | logger.Errorw("Cannot send GemNCtp delete", log.Fields{ |
| 1742 | "Err": err, "device-id": oo.deviceID}) |
| 1743 | return nil |
| 1744 | } |
| 1745 | logger.Debug("send GemNCtp-Delete-msg done") |
| 1746 | return meInstance |
| 1747 | } |
| 1748 | logger.Errorw("Cannot generate GemNCtp Instance for delete", log.Fields{ |
| 1749 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1750 | return nil |
| 1751 | } |
| 1752 | |
| 1753 | func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
| 1754 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1755 | tid := oo.getNextTid(highPrio) |
| 1756 | logger.Debugw("send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1757 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1758 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1759 | |
| 1760 | meParams := me.ParamData{EntityID: aInstID} |
| 1761 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1762 | if omciErr.GetError() == nil { |
| 1763 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1764 | omci.TransactionID(tid)) |
| 1765 | if err != nil { |
| 1766 | logger.Errorw("Cannot encode .1pMapper for delete", log.Fields{ |
| 1767 | "Err": err, "device-id": oo.deviceID}) |
| 1768 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1769 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1770 | // (relevant to all used sendXX() methods and their error conditions) |
| 1771 | return nil |
| 1772 | } |
| 1773 | |
| 1774 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1775 | if err != nil { |
| 1776 | logger.Errorw("Cannot serialize .1pMapper delete", log.Fields{ |
| 1777 | "Err": err, "device-id": oo.deviceID}) |
| 1778 | return nil |
| 1779 | } |
| 1780 | |
| 1781 | omciRxCallbackPair := callbackPair{ |
| 1782 | cbKey: tid, |
| 1783 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1784 | } |
| 1785 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1786 | if err != nil { |
| 1787 | logger.Errorw("Cannot send .1pMapper delete", log.Fields{ |
| 1788 | "Err": err, "device-id": oo.deviceID}) |
| 1789 | return nil |
| 1790 | } |
| 1791 | logger.Debug("send .1pMapper-Delete-msg done") |
| 1792 | return meInstance |
| 1793 | } |
| 1794 | logger.Errorw("Cannot generate .1pMapper Instance for delete", log.Fields{ |
| 1795 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1796 | return nil |
| 1797 | } |
| 1798 | |
| 1799 | func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 1800 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1801 | tid := oo.getNextTid(highPrio) |
| 1802 | logger.Debugw("send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1803 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1804 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1805 | |
| 1806 | meParams := me.ParamData{EntityID: aInstID} |
| 1807 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1808 | if omciErr.GetError() == nil { |
| 1809 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1810 | omci.TransactionID(tid)) |
| 1811 | if err != nil { |
| 1812 | logger.Errorw("Cannot encode MBPCD for delete", log.Fields{ |
| 1813 | "Err": err, "device-id": oo.deviceID}) |
| 1814 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1815 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1816 | // (relevant to all used sendXX() methods and their error conditions) |
| 1817 | return nil |
| 1818 | } |
| 1819 | |
| 1820 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1821 | if err != nil { |
| 1822 | logger.Errorw("Cannot serialize MBPCD delete", log.Fields{ |
| 1823 | "Err": err, "device-id": oo.deviceID}) |
| 1824 | return nil |
| 1825 | } |
| 1826 | |
| 1827 | omciRxCallbackPair := callbackPair{ |
| 1828 | cbKey: tid, |
| 1829 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1830 | } |
| 1831 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1832 | if err != nil { |
| 1833 | logger.Errorw("Cannot send MBPCD delete", log.Fields{ |
| 1834 | "Err": err, "device-id": oo.deviceID}) |
| 1835 | return nil |
| 1836 | } |
| 1837 | logger.Debug("send MBPCD-Delete-msg done") |
| 1838 | return meInstance |
| 1839 | } |
| 1840 | logger.Errorw("Cannot generate MBPCD Instance for delete", log.Fields{ |
| 1841 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1842 | return nil |
| 1843 | } |
| 1844 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1845 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1846 | func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 1847 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1848 | tid := oo.getNextTid(highPrio) |
| 1849 | logger.Debugw("send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1850 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1851 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1852 | |
| 1853 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 1854 | if omciErr.GetError() == nil { |
| 1855 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 1856 | omci.AddDefaults(true)) |
| 1857 | if err != nil { |
| 1858 | logger.Errorw("Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1859 | return nil |
| 1860 | } |
| 1861 | |
| 1862 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1863 | if err != nil { |
| 1864 | logger.Errorw("Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1865 | return nil |
| 1866 | } |
| 1867 | |
| 1868 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1869 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1870 | } |
| 1871 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1872 | if err != nil { |
| 1873 | logger.Errorw("Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1874 | return nil |
| 1875 | } |
| 1876 | logger.Debug("send MulticastGEMIWTP-create-msg done") |
| 1877 | return meInstance |
| 1878 | } |
| 1879 | logger.Errorw("Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 1880 | "device-id": oo.deviceID}) |
| 1881 | return nil |
| 1882 | } |
| 1883 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1884 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1885 | func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 1886 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1887 | tid := oo.getNextTid(highPrio) |
| 1888 | logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1889 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1890 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1891 | |
| 1892 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 1893 | if omciErr.GetError() == nil { |
| 1894 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 1895 | omci.AddDefaults(true)) |
| 1896 | if err != nil { |
| 1897 | logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
| 1898 | "device-id": oo.deviceID}) |
| 1899 | return nil |
| 1900 | } |
| 1901 | |
| 1902 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1903 | if err != nil { |
| 1904 | logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
| 1905 | "device-id": oo.deviceID}) |
| 1906 | return nil |
| 1907 | } |
| 1908 | |
| 1909 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1910 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1911 | } |
| 1912 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1913 | if err != nil { |
| 1914 | logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
| 1915 | "device-id": oo.deviceID}) |
| 1916 | return nil |
| 1917 | } |
| 1918 | logger.Debug("send MulticastOperationProfile-create-msg done") |
| 1919 | return meInstance |
| 1920 | } |
| 1921 | logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 1922 | "device-id": oo.deviceID}) |
| 1923 | return nil |
| 1924 | } |
| 1925 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1926 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1927 | func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 1928 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1929 | tid := oo.getNextTid(highPrio) |
| 1930 | logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1931 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1932 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1933 | |
| 1934 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 1935 | if omciErr.GetError() == nil { |
| 1936 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid), |
| 1937 | omci.AddDefaults(true)) |
| 1938 | if err != nil { |
| 1939 | logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
| 1940 | "device-id": oo.deviceID}) |
| 1941 | return nil |
| 1942 | } |
| 1943 | |
| 1944 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1945 | if err != nil { |
| 1946 | logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
| 1947 | "device-id": oo.deviceID}) |
| 1948 | return nil |
| 1949 | } |
| 1950 | |
| 1951 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1952 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1953 | } |
| 1954 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1955 | if err != nil { |
| 1956 | logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
| 1957 | "device-id": oo.deviceID}) |
| 1958 | return nil |
| 1959 | } |
| 1960 | logger.Debug("send MulticastOperationProfile-create-msg done") |
| 1961 | return meInstance |
| 1962 | } |
| 1963 | logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 1964 | "device-id": oo.deviceID}) |
| 1965 | return nil |
| 1966 | } |
| 1967 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1968 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1969 | func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
| 1970 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1971 | tid := oo.getNextTid(highPrio) |
| 1972 | logger.Debugw("send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1973 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1974 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1975 | |
| 1976 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 1977 | if omciErr.GetError() == nil { |
| 1978 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 1979 | omci.AddDefaults(true)) |
| 1980 | if err != nil { |
| 1981 | logger.Errorw("Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
| 1982 | "device-id": oo.deviceID}) |
| 1983 | return nil |
| 1984 | } |
| 1985 | |
| 1986 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1987 | if err != nil { |
| 1988 | logger.Errorw("Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
| 1989 | "device-id": oo.deviceID}) |
| 1990 | return nil |
| 1991 | } |
| 1992 | |
| 1993 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1994 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1995 | } |
| 1996 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1997 | if err != nil { |
| 1998 | logger.Errorw("Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
| 1999 | "device-id": oo.deviceID}) |
| 2000 | return nil |
| 2001 | } |
| 2002 | logger.Debug("send MulticastSubConfigInfo-create-msg done") |
| 2003 | return meInstance |
| 2004 | } |
| 2005 | logger.Errorw("Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
| 2006 | "device-id": oo.deviceID}) |
| 2007 | return nil |
| 2008 | } |