1*4a64e381SAndroid Build Coastguard Worker /* 2*4a64e381SAndroid Build Coastguard Worker * Copyright (c) 2024, The OpenThread Authors. 3*4a64e381SAndroid Build Coastguard Worker * All rights reserved. 4*4a64e381SAndroid Build Coastguard Worker * 5*4a64e381SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without 6*4a64e381SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions are met: 7*4a64e381SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright 8*4a64e381SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer. 9*4a64e381SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright 10*4a64e381SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the 11*4a64e381SAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution. 12*4a64e381SAndroid Build Coastguard Worker * 3. Neither the name of the copyright holder nor the 13*4a64e381SAndroid Build Coastguard Worker * names of its contributors may be used to endorse or promote products 14*4a64e381SAndroid Build Coastguard Worker * derived from this software without specific prior written permission. 15*4a64e381SAndroid Build Coastguard Worker * 16*4a64e381SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17*4a64e381SAndroid Build Coastguard Worker * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*4a64e381SAndroid Build Coastguard Worker * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*4a64e381SAndroid Build Coastguard Worker * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20*4a64e381SAndroid Build Coastguard Worker * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*4a64e381SAndroid Build Coastguard Worker * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*4a64e381SAndroid Build Coastguard Worker * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*4a64e381SAndroid Build Coastguard Worker * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*4a64e381SAndroid Build Coastguard Worker * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*4a64e381SAndroid Build Coastguard Worker * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*4a64e381SAndroid Build Coastguard Worker * POSSIBILITY OF SUCH DAMAGE. 27*4a64e381SAndroid Build Coastguard Worker */ 28*4a64e381SAndroid Build Coastguard Worker 29*4a64e381SAndroid Build Coastguard Worker /** 30*4a64e381SAndroid Build Coastguard Worker * @file 31*4a64e381SAndroid Build Coastguard Worker * This file includes definitions for the spinel based Thread controller. 32*4a64e381SAndroid Build Coastguard Worker */ 33*4a64e381SAndroid Build Coastguard Worker 34*4a64e381SAndroid Build Coastguard Worker #ifndef OTBR_AGENT_NCP_SPINEL_HPP_ 35*4a64e381SAndroid Build Coastguard Worker #define OTBR_AGENT_NCP_SPINEL_HPP_ 36*4a64e381SAndroid Build Coastguard Worker 37*4a64e381SAndroid Build Coastguard Worker #include <functional> 38*4a64e381SAndroid Build Coastguard Worker #include <memory> 39*4a64e381SAndroid Build Coastguard Worker 40*4a64e381SAndroid Build Coastguard Worker #include <openthread/dataset.h> 41*4a64e381SAndroid Build Coastguard Worker #include <openthread/error.h> 42*4a64e381SAndroid Build Coastguard Worker #include <openthread/link.h> 43*4a64e381SAndroid Build Coastguard Worker #include <openthread/thread.h> 44*4a64e381SAndroid Build Coastguard Worker 45*4a64e381SAndroid Build Coastguard Worker #include "lib/spinel/spinel.h" 46*4a64e381SAndroid Build Coastguard Worker #include "lib/spinel/spinel_buffer.hpp" 47*4a64e381SAndroid Build Coastguard Worker #include "lib/spinel/spinel_driver.hpp" 48*4a64e381SAndroid Build Coastguard Worker #include "lib/spinel/spinel_encoder.hpp" 49*4a64e381SAndroid Build Coastguard Worker 50*4a64e381SAndroid Build Coastguard Worker #include "common/task_runner.hpp" 51*4a64e381SAndroid Build Coastguard Worker #include "common/types.hpp" 52*4a64e381SAndroid Build Coastguard Worker #include "ncp/async_task.hpp" 53*4a64e381SAndroid Build Coastguard Worker 54*4a64e381SAndroid Build Coastguard Worker namespace otbr { 55*4a64e381SAndroid Build Coastguard Worker namespace Ncp { 56*4a64e381SAndroid Build Coastguard Worker 57*4a64e381SAndroid Build Coastguard Worker /** 58*4a64e381SAndroid Build Coastguard Worker * This interface is an observer to subscribe the network properties from NCP. 59*4a64e381SAndroid Build Coastguard Worker */ 60*4a64e381SAndroid Build Coastguard Worker class PropsObserver 61*4a64e381SAndroid Build Coastguard Worker { 62*4a64e381SAndroid Build Coastguard Worker public: 63*4a64e381SAndroid Build Coastguard Worker /** 64*4a64e381SAndroid Build Coastguard Worker * Updates the device role. 65*4a64e381SAndroid Build Coastguard Worker * 66*4a64e381SAndroid Build Coastguard Worker * @param[in] aRole The device role. 67*4a64e381SAndroid Build Coastguard Worker */ 68*4a64e381SAndroid Build Coastguard Worker virtual void SetDeviceRole(otDeviceRole aRole) = 0; 69*4a64e381SAndroid Build Coastguard Worker 70*4a64e381SAndroid Build Coastguard Worker /** 71*4a64e381SAndroid Build Coastguard Worker * Updates the active dataset. 72*4a64e381SAndroid Build Coastguard Worker * 73*4a64e381SAndroid Build Coastguard Worker * @param[in] aActiveOpDatasetTlvs The active dataset tlvs. 74*4a64e381SAndroid Build Coastguard Worker */ 75*4a64e381SAndroid Build Coastguard Worker virtual void SetDatasetActiveTlvs(const otOperationalDatasetTlvs &aActiveOpDatasetTlvs) = 0; 76*4a64e381SAndroid Build Coastguard Worker 77*4a64e381SAndroid Build Coastguard Worker /** 78*4a64e381SAndroid Build Coastguard Worker * The destructor. 79*4a64e381SAndroid Build Coastguard Worker */ 80*4a64e381SAndroid Build Coastguard Worker virtual ~PropsObserver(void) = default; 81*4a64e381SAndroid Build Coastguard Worker }; 82*4a64e381SAndroid Build Coastguard Worker 83*4a64e381SAndroid Build Coastguard Worker /** 84*4a64e381SAndroid Build Coastguard Worker * The class provides methods for controlling the Thread stack on the network co-processor (NCP). 85*4a64e381SAndroid Build Coastguard Worker */ 86*4a64e381SAndroid Build Coastguard Worker class NcpSpinel 87*4a64e381SAndroid Build Coastguard Worker { 88*4a64e381SAndroid Build Coastguard Worker public: 89*4a64e381SAndroid Build Coastguard Worker using Ip6AddressTableCallback = std::function<void(const std::vector<Ip6AddressInfo> &)>; 90*4a64e381SAndroid Build Coastguard Worker using Ip6MulticastAddressTableCallback = std::function<void(const std::vector<Ip6Address> &)>; 91*4a64e381SAndroid Build Coastguard Worker using NetifStateChangedCallback = std::function<void(bool)>; 92*4a64e381SAndroid Build Coastguard Worker 93*4a64e381SAndroid Build Coastguard Worker /** 94*4a64e381SAndroid Build Coastguard Worker * Constructor. 95*4a64e381SAndroid Build Coastguard Worker */ 96*4a64e381SAndroid Build Coastguard Worker NcpSpinel(void); 97*4a64e381SAndroid Build Coastguard Worker 98*4a64e381SAndroid Build Coastguard Worker /** 99*4a64e381SAndroid Build Coastguard Worker * Do the initialization. 100*4a64e381SAndroid Build Coastguard Worker * 101*4a64e381SAndroid Build Coastguard Worker * @param[in] aSpinelDriver A reference to the SpinelDriver instance that this object depends. 102*4a64e381SAndroid Build Coastguard Worker * @param[in] aObserver A reference to the Network properties observer. 103*4a64e381SAndroid Build Coastguard Worker */ 104*4a64e381SAndroid Build Coastguard Worker void Init(ot::Spinel::SpinelDriver &aSpinelDriver, PropsObserver &aObserver); 105*4a64e381SAndroid Build Coastguard Worker 106*4a64e381SAndroid Build Coastguard Worker /** 107*4a64e381SAndroid Build Coastguard Worker * Do the de-initialization. 108*4a64e381SAndroid Build Coastguard Worker */ 109*4a64e381SAndroid Build Coastguard Worker void Deinit(void); 110*4a64e381SAndroid Build Coastguard Worker 111*4a64e381SAndroid Build Coastguard Worker /** 112*4a64e381SAndroid Build Coastguard Worker * Returns the Co-processor version string. 113*4a64e381SAndroid Build Coastguard Worker */ GetCoprocessorVersion(void)114*4a64e381SAndroid Build Coastguard Worker const char *GetCoprocessorVersion(void) { return mSpinelDriver->GetVersion(); } 115*4a64e381SAndroid Build Coastguard Worker 116*4a64e381SAndroid Build Coastguard Worker /** 117*4a64e381SAndroid Build Coastguard Worker * This method sets the active dataset on the NCP. 118*4a64e381SAndroid Build Coastguard Worker * 119*4a64e381SAndroid Build Coastguard Worker * If this method is called again before the previous call completed, no action will be taken. 120*4a64e381SAndroid Build Coastguard Worker * The new receiver @p aAsyncTask will be set a result OT_ERROR_BUSY. 121*4a64e381SAndroid Build Coastguard Worker * 122*4a64e381SAndroid Build Coastguard Worker * @param[in] aActiveOpDatasetTlvs A reference to the active operational dataset of the Thread network. 123*4a64e381SAndroid Build Coastguard Worker * @param[in] aAsyncTask A pointer to an async result to receive the result of this operation. 124*4a64e381SAndroid Build Coastguard Worker */ 125*4a64e381SAndroid Build Coastguard Worker void DatasetSetActiveTlvs(const otOperationalDatasetTlvs &aActiveOpDatasetTlvs, AsyncTaskPtr aAsyncTask); 126*4a64e381SAndroid Build Coastguard Worker 127*4a64e381SAndroid Build Coastguard Worker /** 128*4a64e381SAndroid Build Coastguard Worker * This method instructs the NCP to send a MGMT_SET to set Thread Pending Operational Dataset. 129*4a64e381SAndroid Build Coastguard Worker * 130*4a64e381SAndroid Build Coastguard Worker * If this method is called again before the previous call completed, no action will be taken. 131*4a64e381SAndroid Build Coastguard Worker * The new receiver @p aAsyncTask will be set a result OT_ERROR_BUSY. 132*4a64e381SAndroid Build Coastguard Worker * 133*4a64e381SAndroid Build Coastguard Worker * @param[in] aPendingOpDatasetTlvsPtr A shared pointer to the pending operational dataset of the Thread network. 134*4a64e381SAndroid Build Coastguard Worker * @param[in] aAsyncTask A pointer to an async result to receive the result of this operation. 135*4a64e381SAndroid Build Coastguard Worker */ 136*4a64e381SAndroid Build Coastguard Worker void DatasetMgmtSetPending(std::shared_ptr<otOperationalDatasetTlvs> aPendingOpDatasetTlvsPtr, 137*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr aAsyncTask); 138*4a64e381SAndroid Build Coastguard Worker 139*4a64e381SAndroid Build Coastguard Worker /** 140*4a64e381SAndroid Build Coastguard Worker * This method enableds/disables the IP6 on the NCP. 141*4a64e381SAndroid Build Coastguard Worker * 142*4a64e381SAndroid Build Coastguard Worker * If this method is called again before the previous call completed, no action will be taken. 143*4a64e381SAndroid Build Coastguard Worker * The new receiver @p aAsyncTask will be set a result OT_ERROR_BUSY. 144*4a64e381SAndroid Build Coastguard Worker * 145*4a64e381SAndroid Build Coastguard Worker * @param[in] aEnable TRUE to enable and FALSE to disable. 146*4a64e381SAndroid Build Coastguard Worker * @param[in] aAsyncTask A pointer to an async result to receive the result of this operation. 147*4a64e381SAndroid Build Coastguard Worker */ 148*4a64e381SAndroid Build Coastguard Worker void Ip6SetEnabled(bool aEnable, AsyncTaskPtr aAsyncTask); 149*4a64e381SAndroid Build Coastguard Worker 150*4a64e381SAndroid Build Coastguard Worker /** 151*4a64e381SAndroid Build Coastguard Worker * This method sets the callback to receive the IPv6 address table from the NCP. 152*4a64e381SAndroid Build Coastguard Worker * 153*4a64e381SAndroid Build Coastguard Worker * The callback will be invoked when receiving an IPv6 address table from the NCP. When the 154*4a64e381SAndroid Build Coastguard Worker * callback is invoked, the callback MUST copy the otIp6AddressInfo objects and maintain it 155*4a64e381SAndroid Build Coastguard Worker * if it's not used immediately (within the callback). 156*4a64e381SAndroid Build Coastguard Worker * 157*4a64e381SAndroid Build Coastguard Worker * @param[in] aCallback The callback to handle the IP6 address table. 158*4a64e381SAndroid Build Coastguard Worker */ Ip6SetAddressCallback(const Ip6AddressTableCallback & aCallback)159*4a64e381SAndroid Build Coastguard Worker void Ip6SetAddressCallback(const Ip6AddressTableCallback &aCallback) { mIp6AddressTableCallback = aCallback; } 160*4a64e381SAndroid Build Coastguard Worker 161*4a64e381SAndroid Build Coastguard Worker /** 162*4a64e381SAndroid Build Coastguard Worker * This method sets the callback to receive the IPv6 multicast address table from the NCP. 163*4a64e381SAndroid Build Coastguard Worker * 164*4a64e381SAndroid Build Coastguard Worker * @param[in] aCallback The callback to handle the IPv6 address table. 165*4a64e381SAndroid Build Coastguard Worker * 166*4a64e381SAndroid Build Coastguard Worker * The callback will be invoked when receiving an IPv6 multicast address table from the NCP. 167*4a64e381SAndroid Build Coastguard Worker * When the callback is invoked, the callback MUST copy the otIp6Address objects and maintain it 168*4a64e381SAndroid Build Coastguard Worker * if it's not used immediately (within the callback). 169*4a64e381SAndroid Build Coastguard Worker */ Ip6SetAddressMulticastCallback(const Ip6MulticastAddressTableCallback & aCallback)170*4a64e381SAndroid Build Coastguard Worker void Ip6SetAddressMulticastCallback(const Ip6MulticastAddressTableCallback &aCallback) 171*4a64e381SAndroid Build Coastguard Worker { 172*4a64e381SAndroid Build Coastguard Worker mIp6MulticastAddressTableCallback = aCallback; 173*4a64e381SAndroid Build Coastguard Worker } 174*4a64e381SAndroid Build Coastguard Worker 175*4a64e381SAndroid Build Coastguard Worker /** 176*4a64e381SAndroid Build Coastguard Worker * This methods sends an IP6 datagram through the NCP. 177*4a64e381SAndroid Build Coastguard Worker * 178*4a64e381SAndroid Build Coastguard Worker * @param[in] aData A pointer to the beginning of the IP6 datagram. 179*4a64e381SAndroid Build Coastguard Worker * @param[in] aLength The length of the datagram. 180*4a64e381SAndroid Build Coastguard Worker * 181*4a64e381SAndroid Build Coastguard Worker * @retval OTBR_ERROR_NONE The datagram is sent to NCP successfully. 182*4a64e381SAndroid Build Coastguard Worker * @retval OTBR_ERROR_BUSY NcpSpinel is busy with other requests. 183*4a64e381SAndroid Build Coastguard Worker */ 184*4a64e381SAndroid Build Coastguard Worker otbrError Ip6Send(const uint8_t *aData, uint16_t aLength); 185*4a64e381SAndroid Build Coastguard Worker 186*4a64e381SAndroid Build Coastguard Worker /** 187*4a64e381SAndroid Build Coastguard Worker * This method enableds/disables the Thread network on the NCP. 188*4a64e381SAndroid Build Coastguard Worker * 189*4a64e381SAndroid Build Coastguard Worker * If this method is called again before the previous call completed, no action will be taken. 190*4a64e381SAndroid Build Coastguard Worker * The new receiver @p aAsyncTask will be set a result OT_ERROR_BUSY. 191*4a64e381SAndroid Build Coastguard Worker * 192*4a64e381SAndroid Build Coastguard Worker * @param[in] aEnable TRUE to enable and FALSE to disable. 193*4a64e381SAndroid Build Coastguard Worker * @param[in] aAsyncTask A pointer to an async result to receive the result of this operation. 194*4a64e381SAndroid Build Coastguard Worker */ 195*4a64e381SAndroid Build Coastguard Worker void ThreadSetEnabled(bool aEnable, AsyncTaskPtr aAsyncTask); 196*4a64e381SAndroid Build Coastguard Worker 197*4a64e381SAndroid Build Coastguard Worker /** 198*4a64e381SAndroid Build Coastguard Worker * This method instructs the device to leave the current network gracefully. 199*4a64e381SAndroid Build Coastguard Worker * 200*4a64e381SAndroid Build Coastguard Worker * If this method is called again before the previous call completed, no action will be taken. 201*4a64e381SAndroid Build Coastguard Worker * The new receiver @p aAsyncTask will be set a result OT_ERROR_BUSY. 202*4a64e381SAndroid Build Coastguard Worker * 203*4a64e381SAndroid Build Coastguard Worker * @param[in] aAsyncTask A pointer to an async result to receive the result of this operation. 204*4a64e381SAndroid Build Coastguard Worker */ 205*4a64e381SAndroid Build Coastguard Worker void ThreadDetachGracefully(AsyncTaskPtr aAsyncTask); 206*4a64e381SAndroid Build Coastguard Worker 207*4a64e381SAndroid Build Coastguard Worker /** 208*4a64e381SAndroid Build Coastguard Worker * This method instructs the NCP to erase the persistent network info. 209*4a64e381SAndroid Build Coastguard Worker * 210*4a64e381SAndroid Build Coastguard Worker * If this method is called again before the previous call completed, no action will be taken. 211*4a64e381SAndroid Build Coastguard Worker * The new receiver @p aAsyncTask will be set a result OT_ERROR_BUSY. 212*4a64e381SAndroid Build Coastguard Worker * 213*4a64e381SAndroid Build Coastguard Worker * @param[in] aAsyncTask A pointer to an async result to receive the result of this operation. 214*4a64e381SAndroid Build Coastguard Worker */ 215*4a64e381SAndroid Build Coastguard Worker void ThreadErasePersistentInfo(AsyncTaskPtr aAsyncTask); 216*4a64e381SAndroid Build Coastguard Worker 217*4a64e381SAndroid Build Coastguard Worker /** 218*4a64e381SAndroid Build Coastguard Worker * This method sets the callback invoked when the network interface state changes. 219*4a64e381SAndroid Build Coastguard Worker * 220*4a64e381SAndroid Build Coastguard Worker * @param[in] aCallback The callback invoked when the network interface state changes. 221*4a64e381SAndroid Build Coastguard Worker */ NetifSetStateChangedCallback(const NetifStateChangedCallback & aCallback)222*4a64e381SAndroid Build Coastguard Worker void NetifSetStateChangedCallback(const NetifStateChangedCallback &aCallback) 223*4a64e381SAndroid Build Coastguard Worker { 224*4a64e381SAndroid Build Coastguard Worker mNetifStateChangedCallback = aCallback; 225*4a64e381SAndroid Build Coastguard Worker } 226*4a64e381SAndroid Build Coastguard Worker 227*4a64e381SAndroid Build Coastguard Worker private: 228*4a64e381SAndroid Build Coastguard Worker using FailureHandler = std::function<void(otError)>; 229*4a64e381SAndroid Build Coastguard Worker 230*4a64e381SAndroid Build Coastguard Worker static constexpr uint8_t kMaxTids = 16; 231*4a64e381SAndroid Build Coastguard Worker SafeInvoke(Function & aFunc,Args &&...aArgs)232*4a64e381SAndroid Build Coastguard Worker template <typename Function, typename... Args> static void SafeInvoke(Function &aFunc, Args &&...aArgs) 233*4a64e381SAndroid Build Coastguard Worker { 234*4a64e381SAndroid Build Coastguard Worker if (aFunc) 235*4a64e381SAndroid Build Coastguard Worker { 236*4a64e381SAndroid Build Coastguard Worker aFunc(std::forward<Args>(aArgs)...); 237*4a64e381SAndroid Build Coastguard Worker } 238*4a64e381SAndroid Build Coastguard Worker } 239*4a64e381SAndroid Build Coastguard Worker CallAndClear(AsyncTaskPtr & aResult,otError aError,const std::string & aErrorInfo="")240*4a64e381SAndroid Build Coastguard Worker static void CallAndClear(AsyncTaskPtr &aResult, otError aError, const std::string &aErrorInfo = "") 241*4a64e381SAndroid Build Coastguard Worker { 242*4a64e381SAndroid Build Coastguard Worker if (aResult) 243*4a64e381SAndroid Build Coastguard Worker { 244*4a64e381SAndroid Build Coastguard Worker aResult->SetResult(aError, aErrorInfo); 245*4a64e381SAndroid Build Coastguard Worker aResult = nullptr; 246*4a64e381SAndroid Build Coastguard Worker } 247*4a64e381SAndroid Build Coastguard Worker } 248*4a64e381SAndroid Build Coastguard Worker 249*4a64e381SAndroid Build Coastguard Worker static otbrError SpinelDataUnpack(const uint8_t *aDataIn, spinel_size_t aDataLen, const char *aPackFormat, ...); 250*4a64e381SAndroid Build Coastguard Worker 251*4a64e381SAndroid Build Coastguard Worker static void HandleReceivedFrame(const uint8_t *aFrame, 252*4a64e381SAndroid Build Coastguard Worker uint16_t aLength, 253*4a64e381SAndroid Build Coastguard Worker uint8_t aHeader, 254*4a64e381SAndroid Build Coastguard Worker bool &aSave, 255*4a64e381SAndroid Build Coastguard Worker void *aContext); 256*4a64e381SAndroid Build Coastguard Worker void HandleReceivedFrame(const uint8_t *aFrame, uint16_t aLength, uint8_t aHeader, bool &aShouldSaveFrame); 257*4a64e381SAndroid Build Coastguard Worker static void HandleSavedFrame(const uint8_t *aFrame, uint16_t aLength, void *aContext); 258*4a64e381SAndroid Build Coastguard Worker 259*4a64e381SAndroid Build Coastguard Worker static otDeviceRole SpinelRoleToDeviceRole(spinel_net_role_t aRole); 260*4a64e381SAndroid Build Coastguard Worker 261*4a64e381SAndroid Build Coastguard Worker void HandleNotification(const uint8_t *aFrame, uint16_t aLength); 262*4a64e381SAndroid Build Coastguard Worker void HandleResponse(spinel_tid_t aTid, const uint8_t *aFrame, uint16_t aLength); 263*4a64e381SAndroid Build Coastguard Worker void HandleValueIs(spinel_prop_key_t aKey, const uint8_t *aBuffer, uint16_t aLength); 264*4a64e381SAndroid Build Coastguard Worker otbrError HandleResponseForPropSet(spinel_tid_t aTid, 265*4a64e381SAndroid Build Coastguard Worker spinel_prop_key_t aKey, 266*4a64e381SAndroid Build Coastguard Worker const uint8_t *aData, 267*4a64e381SAndroid Build Coastguard Worker uint16_t aLength); 268*4a64e381SAndroid Build Coastguard Worker 269*4a64e381SAndroid Build Coastguard Worker spinel_tid_t GetNextTid(void); 270*4a64e381SAndroid Build Coastguard Worker void FreeTidTableItem(spinel_tid_t aTid); 271*4a64e381SAndroid Build Coastguard Worker 272*4a64e381SAndroid Build Coastguard Worker using EncodingFunc = std::function<otError(void)>; 273*4a64e381SAndroid Build Coastguard Worker otError SetProperty(spinel_prop_key_t aKey, const EncodingFunc &aEncodingFunc); 274*4a64e381SAndroid Build Coastguard Worker otError SendEncodedFrame(void); 275*4a64e381SAndroid Build Coastguard Worker 276*4a64e381SAndroid Build Coastguard Worker otError ParseIp6AddressTable(const uint8_t *aBuf, uint16_t aLength, std::vector<Ip6AddressInfo> &aAddressTable); 277*4a64e381SAndroid Build Coastguard Worker otError ParseIp6MulticastAddresses(const uint8_t *aBuf, uint8_t aLen, std::vector<Ip6Address> &aAddressList); 278*4a64e381SAndroid Build Coastguard Worker otError ParseIp6StreamNet(const uint8_t *aBuf, uint8_t aLen, const uint8_t *&aData, uint16_t &aDataLen); 279*4a64e381SAndroid Build Coastguard Worker otError ParseOperationalDatasetTlvs(const uint8_t *aBuf, uint8_t aLen, otOperationalDatasetTlvs &aDatasetTlvs); 280*4a64e381SAndroid Build Coastguard Worker 281*4a64e381SAndroid Build Coastguard Worker ot::Spinel::SpinelDriver *mSpinelDriver; 282*4a64e381SAndroid Build Coastguard Worker uint16_t mCmdTidsInUse; ///< Used transaction ids. 283*4a64e381SAndroid Build Coastguard Worker spinel_tid_t mCmdNextTid; ///< Next available transaction id. 284*4a64e381SAndroid Build Coastguard Worker 285*4a64e381SAndroid Build Coastguard Worker spinel_prop_key_t mWaitingKeyTable[kMaxTids]; ///< The property keys of ongoing transactions. 286*4a64e381SAndroid Build Coastguard Worker spinel_command_t mCmdTable[kMaxTids]; ///< The mapping of spinel command and tids when the response 287*4a64e381SAndroid Build Coastguard Worker ///< is LAST_STATUS. 288*4a64e381SAndroid Build Coastguard Worker 289*4a64e381SAndroid Build Coastguard Worker static constexpr uint16_t kTxBufferSize = 2048; 290*4a64e381SAndroid Build Coastguard Worker uint8_t mTxBuffer[kTxBufferSize]; 291*4a64e381SAndroid Build Coastguard Worker ot::Spinel::Buffer mNcpBuffer; 292*4a64e381SAndroid Build Coastguard Worker ot::Spinel::Encoder mEncoder; 293*4a64e381SAndroid Build Coastguard Worker spinel_iid_t mIid; /// < Interface Id used to in Spinel header 294*4a64e381SAndroid Build Coastguard Worker 295*4a64e381SAndroid Build Coastguard Worker TaskRunner mTaskRunner; 296*4a64e381SAndroid Build Coastguard Worker 297*4a64e381SAndroid Build Coastguard Worker PropsObserver *mPropsObserver; 298*4a64e381SAndroid Build Coastguard Worker 299*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr mDatasetSetActiveTask; 300*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr mDatasetMgmtSetPendingTask; 301*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr mIp6SetEnabledTask; 302*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr mThreadSetEnabledTask; 303*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr mThreadDetachGracefullyTask; 304*4a64e381SAndroid Build Coastguard Worker AsyncTaskPtr mThreadErasePersistentInfoTask; 305*4a64e381SAndroid Build Coastguard Worker 306*4a64e381SAndroid Build Coastguard Worker Ip6AddressTableCallback mIp6AddressTableCallback; 307*4a64e381SAndroid Build Coastguard Worker Ip6MulticastAddressTableCallback mIp6MulticastAddressTableCallback; 308*4a64e381SAndroid Build Coastguard Worker NetifStateChangedCallback mNetifStateChangedCallback; 309*4a64e381SAndroid Build Coastguard Worker }; 310*4a64e381SAndroid Build Coastguard Worker 311*4a64e381SAndroid Build Coastguard Worker } // namespace Ncp 312*4a64e381SAndroid Build Coastguard Worker } // namespace otbr 313*4a64e381SAndroid Build Coastguard Worker 314*4a64e381SAndroid Build Coastguard Worker #endif // OTBR_AGENT_NCP_SPINEL_HPP_ 315