Jean-Francois Penven | fd52919 | 2022-03-25 21:43:47 -0400 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) 2020-2021 Project CHIP Authors |
| 4 | * Copyright (c) 2015-2017 Nest Labs, Inc. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | /** |
| 20 | * Shared state for OpenThread implementations of TCPEndPoint and UDPEndPoint. |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #include <inet/EndPointBasis.h> |
| 26 | |
| 27 | #include <inet/IPAddress.h> |
| 28 | |
| 29 | namespace chip { |
| 30 | namespace Inet { |
| 31 | |
| 32 | /** |
| 33 | * Definitions shared by all OpenThread EndPoint classes. |
| 34 | */ |
| 35 | class DLL_EXPORT EndPointStateOpenThread |
| 36 | { |
Jean-Francois Penven | 9405c20 | 2022-05-03 15:37:44 -0400 | [diff] [blame] | 37 | public: |
| 38 | typedef void (*openThreadTaskSyncCb)(void); |
| 39 | struct OpenThreadEndpointInitParam |
| 40 | { |
| 41 | openThreadTaskSyncCb lockCb = nullptr; |
| 42 | openThreadTaskSyncCb unlockCb = nullptr; |
| 43 | otInstance * openThreadInstancePtr = nullptr; |
| 44 | }; |
| 45 | |
Jean-Francois Penven | fd52919 | 2022-03-25 21:43:47 -0400 | [diff] [blame] | 46 | protected: |
| 47 | EndPointStateOpenThread() : mOpenThreadEndPointType(OpenThreadEndPointType::Unknown) {} |
| 48 | |
| 49 | enum class OpenThreadEndPointType : uint8_t |
| 50 | { |
| 51 | Unknown = 0, |
| 52 | UDP = 1, |
| 53 | TCP = 2 |
| 54 | } mOpenThreadEndPointType; |
Jean-Francois Penven | 9405c20 | 2022-05-03 15:37:44 -0400 | [diff] [blame] | 55 | |
| 56 | void LockOpenThread(void) |
| 57 | { |
| 58 | if (lockOpenThread != nullptr) |
| 59 | lockOpenThread(); |
| 60 | } |
| 61 | void UnlockOpenThread(void) |
| 62 | { |
| 63 | if (unlockOpenThread != nullptr) |
| 64 | unlockOpenThread(); |
| 65 | } |
| 66 | |
| 67 | otInstance * mOTInstance = nullptr; |
| 68 | openThreadTaskSyncCb lockOpenThread = nullptr; |
| 69 | openThreadTaskSyncCb unlockOpenThread = nullptr; |
Jean-Francois Penven | fd52919 | 2022-03-25 21:43:47 -0400 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace Inet |
| 73 | } // namespace chip |