1*cfb92d14SAndroid Build Coastguard Worker /* 2*cfb92d14SAndroid Build Coastguard Worker * Copyright (c) 2016, The OpenThread Authors. 3*cfb92d14SAndroid Build Coastguard Worker * All rights reserved. 4*cfb92d14SAndroid Build Coastguard Worker * 5*cfb92d14SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without 6*cfb92d14SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions are met: 7*cfb92d14SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright 8*cfb92d14SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer. 9*cfb92d14SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright 10*cfb92d14SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the 11*cfb92d14SAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution. 12*cfb92d14SAndroid Build Coastguard Worker * 3. Neither the name of the copyright holder nor the 13*cfb92d14SAndroid Build Coastguard Worker * names of its contributors may be used to endorse or promote products 14*cfb92d14SAndroid Build Coastguard Worker * derived from this software without specific prior written permission. 15*cfb92d14SAndroid Build Coastguard Worker * 16*cfb92d14SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17*cfb92d14SAndroid Build Coastguard Worker * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18*cfb92d14SAndroid Build Coastguard Worker * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19*cfb92d14SAndroid Build Coastguard Worker * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20*cfb92d14SAndroid Build Coastguard Worker * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21*cfb92d14SAndroid Build Coastguard Worker * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22*cfb92d14SAndroid Build Coastguard Worker * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23*cfb92d14SAndroid Build Coastguard Worker * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24*cfb92d14SAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25*cfb92d14SAndroid Build Coastguard Worker * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*cfb92d14SAndroid Build Coastguard Worker */ 27*cfb92d14SAndroid Build Coastguard Worker 28*cfb92d14SAndroid Build Coastguard Worker /** 29*cfb92d14SAndroid Build Coastguard Worker * @file 30*cfb92d14SAndroid Build Coastguard Worker * This file contains definitions a spinel interface to the OpenThread stack. 31*cfb92d14SAndroid Build Coastguard Worker */ 32*cfb92d14SAndroid Build Coastguard Worker 33*cfb92d14SAndroid Build Coastguard Worker #ifndef NCP_BASE_HPP_ 34*cfb92d14SAndroid Build Coastguard Worker #define NCP_BASE_HPP_ 35*cfb92d14SAndroid Build Coastguard Worker 36*cfb92d14SAndroid Build Coastguard Worker #include "openthread-core-config.h" 37*cfb92d14SAndroid Build Coastguard Worker 38*cfb92d14SAndroid Build Coastguard Worker #include "ncp/ncp_config.h" 39*cfb92d14SAndroid Build Coastguard Worker 40*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_MTD || OPENTHREAD_FTD 41*cfb92d14SAndroid Build Coastguard Worker #include <openthread/ip6.h> 42*cfb92d14SAndroid Build Coastguard Worker #else 43*cfb92d14SAndroid Build Coastguard Worker #include <openthread/platform/radio.h> 44*cfb92d14SAndroid Build Coastguard Worker #endif 45*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_FTD 46*cfb92d14SAndroid Build Coastguard Worker #include <openthread/thread_ftd.h> 47*cfb92d14SAndroid Build Coastguard Worker #endif 48*cfb92d14SAndroid Build Coastguard Worker #include <openthread/message.h> 49*cfb92d14SAndroid Build Coastguard Worker #include <openthread/ncp.h> 50*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTI_RADIO 51*cfb92d14SAndroid Build Coastguard Worker #include <openthread/multi_radio.h> 52*cfb92d14SAndroid Build Coastguard Worker #endif 53*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 54*cfb92d14SAndroid Build Coastguard Worker #include <openthread/srp_client.h> 55*cfb92d14SAndroid Build Coastguard Worker #endif 56*cfb92d14SAndroid Build Coastguard Worker 57*cfb92d14SAndroid Build Coastguard Worker #include "changed_props_set.hpp" 58*cfb92d14SAndroid Build Coastguard Worker #include "common/tasklet.hpp" 59*cfb92d14SAndroid Build Coastguard Worker #include "instance/instance.hpp" 60*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel.h" 61*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel_buffer.hpp" 62*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel_decoder.hpp" 63*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel_encoder.hpp" 64*cfb92d14SAndroid Build Coastguard Worker 65*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 66*cfb92d14SAndroid Build Coastguard Worker #define SPINEL_HEADER_IID_BROADCAST OPENTHREAD_SPINEL_CONFIG_BROADCAST_IID 67*cfb92d14SAndroid Build Coastguard Worker #else 68*cfb92d14SAndroid Build Coastguard Worker #define SPINEL_HEADER_IID_BROADCAST SPINEL_HEADER_IID_0 69*cfb92d14SAndroid Build Coastguard Worker #endif 70*cfb92d14SAndroid Build Coastguard Worker 71*cfb92d14SAndroid Build Coastguard Worker // In case of host<->ncp<->rcp configuration, notifications shall be 72*cfb92d14SAndroid Build Coastguard Worker // received on broadcast iid on ncp, but transmitted on IID 0 to host. 73*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE && OPENTHREAD_RADIO 74*cfb92d14SAndroid Build Coastguard Worker #define SPINEL_HEADER_TX_NOTIFICATION_IID SPINEL_HEADER_IID_BROADCAST 75*cfb92d14SAndroid Build Coastguard Worker #else 76*cfb92d14SAndroid Build Coastguard Worker #define SPINEL_HEADER_TX_NOTIFICATION_IID SPINEL_HEADER_IID_0 77*cfb92d14SAndroid Build Coastguard Worker #endif 78*cfb92d14SAndroid Build Coastguard Worker 79*cfb92d14SAndroid Build Coastguard Worker namespace ot { 80*cfb92d14SAndroid Build Coastguard Worker namespace Ncp { 81*cfb92d14SAndroid Build Coastguard Worker 82*cfb92d14SAndroid Build Coastguard Worker class NcpBase 83*cfb92d14SAndroid Build Coastguard Worker { 84*cfb92d14SAndroid Build Coastguard Worker public: 85*cfb92d14SAndroid Build Coastguard Worker enum 86*cfb92d14SAndroid Build Coastguard Worker { 87*cfb92d14SAndroid Build Coastguard Worker kSpinelCmdHeaderSize = 2, ///< Size of spinel command header (in bytes). 88*cfb92d14SAndroid Build Coastguard Worker kSpinelPropIdSize = 3, ///< Size of spinel property identifier (in bytes). 89*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && OPENTHREAD_RADIO 90*cfb92d14SAndroid Build Coastguard Worker kSpinelInterfaceCount = SPINEL_HEADER_IID_MAX + 1, // Number of supported spinel interfaces 91*cfb92d14SAndroid Build Coastguard Worker #else 92*cfb92d14SAndroid Build Coastguard Worker kSpinelInterfaceCount = 1, // Only one interface supported in single instance configuration 93*cfb92d14SAndroid Build Coastguard Worker #endif 94*cfb92d14SAndroid Build Coastguard Worker }; 95*cfb92d14SAndroid Build Coastguard Worker 96*cfb92d14SAndroid Build Coastguard Worker /** 97*cfb92d14SAndroid Build Coastguard Worker * Creates and initializes an NcpBase instance. 98*cfb92d14SAndroid Build Coastguard Worker * 99*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 100*cfb92d14SAndroid Build Coastguard Worker * 101*cfb92d14SAndroid Build Coastguard Worker */ 102*cfb92d14SAndroid Build Coastguard Worker explicit NcpBase(Instance *aInstance); 103*cfb92d14SAndroid Build Coastguard Worker 104*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE && OPENTHREAD_RADIO 105*cfb92d14SAndroid Build Coastguard Worker /** 106*cfb92d14SAndroid Build Coastguard Worker * Creates and initializes an NcpBase instance. 107*cfb92d14SAndroid Build Coastguard Worker * 108*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstances The OpenThread instances structure pointer array. 109*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCount Number of the instances in the array. 110*cfb92d14SAndroid Build Coastguard Worker * 111*cfb92d14SAndroid Build Coastguard Worker */ 112*cfb92d14SAndroid Build Coastguard Worker explicit NcpBase(Instance **aInstances, uint8_t aCount); 113*cfb92d14SAndroid Build Coastguard Worker 114*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE && OPENTHREAD_RADIO 115*cfb92d14SAndroid Build Coastguard Worker 116*cfb92d14SAndroid Build Coastguard Worker /** 117*cfb92d14SAndroid Build Coastguard Worker * Returns the pointer to the single NCP instance. 118*cfb92d14SAndroid Build Coastguard Worker * 119*cfb92d14SAndroid Build Coastguard Worker * @returns Pointer to the single NCP instance. 120*cfb92d14SAndroid Build Coastguard Worker * 121*cfb92d14SAndroid Build Coastguard Worker */ 122*cfb92d14SAndroid Build Coastguard Worker static NcpBase *GetNcpInstance(void); 123*cfb92d14SAndroid Build Coastguard Worker 124*cfb92d14SAndroid Build Coastguard Worker /** 125*cfb92d14SAndroid Build Coastguard Worker * Returns an IID for the given instance 126*cfb92d14SAndroid Build Coastguard Worker * 127*cfb92d14SAndroid Build Coastguard Worker * Returned IID is an integer value that must be shifted by SPINEL_HEADER_IID_SHIFT before putting into spinel 128*cfb92d14SAndroid Build Coastguard Worker * header. If multipan interface is not enabled or build is not for RCP IID=0 is returned. If nullptr is passed it 129*cfb92d14SAndroid Build Coastguard Worker * matches broadcast IID in current implementation. Broadcast IID is also returned in case no match was found. 130*cfb92d14SAndroid Build Coastguard Worker * 131*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance Instance pointer to match with IID 132*cfb92d14SAndroid Build Coastguard Worker * 133*cfb92d14SAndroid Build Coastguard Worker * @returns Spinel Interface Identifier to use for communication for this instance 134*cfb92d14SAndroid Build Coastguard Worker * 135*cfb92d14SAndroid Build Coastguard Worker */ 136*cfb92d14SAndroid Build Coastguard Worker uint8_t InstanceToIid(Instance *aInstance); 137*cfb92d14SAndroid Build Coastguard Worker 138*cfb92d14SAndroid Build Coastguard Worker /** 139*cfb92d14SAndroid Build Coastguard Worker * Returns an OT instance for the given IID 140*cfb92d14SAndroid Build Coastguard Worker * 141*cfb92d14SAndroid Build Coastguard Worker * Returns an OpenThread instance object associated to the given IID. 142*cfb92d14SAndroid Build Coastguard Worker * If multipan interface is not enabled or build is not for RCP returned value is the same instance object 143*cfb92d14SAndroid Build Coastguard Worker * regardless of the aIid parameter In current implementation nullptr is returned for broadcast IID and values 144*cfb92d14SAndroid Build Coastguard Worker * exceeding the instances count but lower than kSpinelInterfaceCount. 145*cfb92d14SAndroid Build Coastguard Worker * 146*cfb92d14SAndroid Build Coastguard Worker * @param[in] aIid IID used in the Spinel communication 147*cfb92d14SAndroid Build Coastguard Worker * 148*cfb92d14SAndroid Build Coastguard Worker * @returns OpenThread instance object associated with the given IID 149*cfb92d14SAndroid Build Coastguard Worker * 150*cfb92d14SAndroid Build Coastguard Worker */ 151*cfb92d14SAndroid Build Coastguard Worker Instance *IidToInstance(uint8_t aIid); 152*cfb92d14SAndroid Build Coastguard Worker 153*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 154*cfb92d14SAndroid Build Coastguard Worker /** 155*cfb92d14SAndroid Build Coastguard Worker * Called to send notification to host about switchower results. 156*cfb92d14SAndroid Build Coastguard Worker */ 157*cfb92d14SAndroid Build Coastguard Worker void NotifySwitchoverDone(otInstance *aInstance, bool aSuccess); 158*cfb92d14SAndroid Build Coastguard Worker #endif 159*cfb92d14SAndroid Build Coastguard Worker 160*cfb92d14SAndroid Build Coastguard Worker /** 161*cfb92d14SAndroid Build Coastguard Worker * This method returns the IID of the current spinel command. 162*cfb92d14SAndroid Build Coastguard Worker * 163*cfb92d14SAndroid Build Coastguard Worker * @returns IID. 164*cfb92d14SAndroid Build Coastguard Worker * 165*cfb92d14SAndroid Build Coastguard Worker */ 166*cfb92d14SAndroid Build Coastguard Worker spinel_iid_t GetCurCommandIid(void) const; 167*cfb92d14SAndroid Build Coastguard Worker 168*cfb92d14SAndroid Build Coastguard Worker /** 169*cfb92d14SAndroid Build Coastguard Worker * Sends data to host via specific stream. 170*cfb92d14SAndroid Build Coastguard Worker * 171*cfb92d14SAndroid Build Coastguard Worker * 172*cfb92d14SAndroid Build Coastguard Worker * @param[in] aStreamId A numeric identifier for the stream to write to. 173*cfb92d14SAndroid Build Coastguard Worker * If set to '0', will default to the debug stream. 174*cfb92d14SAndroid Build Coastguard Worker * @param[in] aDataPtr A pointer to the data to send on the stream. 175*cfb92d14SAndroid Build Coastguard Worker * If aDataLen is non-zero, this param MUST NOT be nullptr. 176*cfb92d14SAndroid Build Coastguard Worker * @param[in] aDataLen The number of bytes of data from aDataPtr to send. 177*cfb92d14SAndroid Build Coastguard Worker * 178*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE The data was queued for delivery to the host. 179*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY There are not enough resources to complete this 180*cfb92d14SAndroid Build Coastguard Worker * request. This is usually a temporary condition. 181*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS The given aStreamId was invalid. 182*cfb92d14SAndroid Build Coastguard Worker * 183*cfb92d14SAndroid Build Coastguard Worker */ 184*cfb92d14SAndroid Build Coastguard Worker otError StreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen); 185*cfb92d14SAndroid Build Coastguard Worker 186*cfb92d14SAndroid Build Coastguard Worker /** 187*cfb92d14SAndroid Build Coastguard Worker * Send an OpenThread log message to host via `SPINEL_PROP_STREAM_LOG` property. 188*cfb92d14SAndroid Build Coastguard Worker * 189*cfb92d14SAndroid Build Coastguard Worker * @param[in] aLogLevel The log level 190*cfb92d14SAndroid Build Coastguard Worker * @param[in] aLogRegion The log region 191*cfb92d14SAndroid Build Coastguard Worker * @param[in] aLogString The log string 192*cfb92d14SAndroid Build Coastguard Worker * 193*cfb92d14SAndroid Build Coastguard Worker */ 194*cfb92d14SAndroid Build Coastguard Worker void Log(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aLogString); 195*cfb92d14SAndroid Build Coastguard Worker 196*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE 197*cfb92d14SAndroid Build Coastguard Worker /** 198*cfb92d14SAndroid Build Coastguard Worker * Registers peek/poke delegate functions with NCP module. 199*cfb92d14SAndroid Build Coastguard Worker * 200*cfb92d14SAndroid Build Coastguard Worker * @param[in] aAllowPeekDelegate Delegate function pointer for peek operation. 201*cfb92d14SAndroid Build Coastguard Worker * @param[in] aAllowPokeDelegate Delegate function pointer for poke operation. 202*cfb92d14SAndroid Build Coastguard Worker * 203*cfb92d14SAndroid Build Coastguard Worker */ 204*cfb92d14SAndroid Build Coastguard Worker void RegisterPeekPokeDelegates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate, 205*cfb92d14SAndroid Build Coastguard Worker otNcpDelegateAllowPeekPoke aAllowPokeDelegate); 206*cfb92d14SAndroid Build Coastguard Worker #endif 207*cfb92d14SAndroid Build Coastguard Worker 208*cfb92d14SAndroid Build Coastguard Worker /** 209*cfb92d14SAndroid Build Coastguard Worker * Is called by the framer whenever a framing error is detected. 210*cfb92d14SAndroid Build Coastguard Worker */ 211*cfb92d14SAndroid Build Coastguard Worker void IncrementFrameErrorCounter(void); 212*cfb92d14SAndroid Build Coastguard Worker 213*cfb92d14SAndroid Build Coastguard Worker /** 214*cfb92d14SAndroid Build Coastguard Worker * Called by the subclass to indicate when a frame has been received. 215*cfb92d14SAndroid Build Coastguard Worker */ 216*cfb92d14SAndroid Build Coastguard Worker void HandleReceive(const uint8_t *aBuf, uint16_t aBufLength); 217*cfb92d14SAndroid Build Coastguard Worker 218*cfb92d14SAndroid Build Coastguard Worker /** 219*cfb92d14SAndroid Build Coastguard Worker * Called by the subclass to learn when the host wake operation must be issued. 220*cfb92d14SAndroid Build Coastguard Worker */ 221*cfb92d14SAndroid Build Coastguard Worker bool ShouldWakeHost(void); 222*cfb92d14SAndroid Build Coastguard Worker 223*cfb92d14SAndroid Build Coastguard Worker /** 224*cfb92d14SAndroid Build Coastguard Worker * Called by the subclass to learn when the transfer to the host should be deferred. 225*cfb92d14SAndroid Build Coastguard Worker */ 226*cfb92d14SAndroid Build Coastguard Worker bool ShouldDeferHostSend(void); 227*cfb92d14SAndroid Build Coastguard Worker 228*cfb92d14SAndroid Build Coastguard Worker protected: 229*cfb92d14SAndroid Build Coastguard Worker static constexpr uint8_t kBitsPerByte = 8; ///< Number of bits in a byte. 230*cfb92d14SAndroid Build Coastguard Worker 231*cfb92d14SAndroid Build Coastguard Worker typedef otError (NcpBase::*PropertyHandler)(void); 232*cfb92d14SAndroid Build Coastguard Worker 233*cfb92d14SAndroid Build Coastguard Worker /** 234*cfb92d14SAndroid Build Coastguard Worker * Represents the `ResponseEntry` type. 235*cfb92d14SAndroid Build Coastguard Worker * 236*cfb92d14SAndroid Build Coastguard Worker */ 237*cfb92d14SAndroid Build Coastguard Worker enum ResponseType 238*cfb92d14SAndroid Build Coastguard Worker { 239*cfb92d14SAndroid Build Coastguard Worker kResponseTypeGet = 0, ///< Response entry is for a `VALUE_GET` command. 240*cfb92d14SAndroid Build Coastguard Worker kResponseTypeSet, ///< Response entry is for a `VALUE_SET` command. 241*cfb92d14SAndroid Build Coastguard Worker kResponseTypeLastStatus, ///< Response entry is a `VALUE_IS(LAST_STATUS)`. 242*cfb92d14SAndroid Build Coastguard Worker }; 243*cfb92d14SAndroid Build Coastguard Worker 244*cfb92d14SAndroid Build Coastguard Worker /** 245*cfb92d14SAndroid Build Coastguard Worker * Represents a spinel response entry. 246*cfb92d14SAndroid Build Coastguard Worker * 247*cfb92d14SAndroid Build Coastguard Worker */ 248*cfb92d14SAndroid Build Coastguard Worker struct ResponseEntry 249*cfb92d14SAndroid Build Coastguard Worker { 250*cfb92d14SAndroid Build Coastguard Worker uint8_t mIid : 2; ///< Spinel interface id. 251*cfb92d14SAndroid Build Coastguard Worker uint8_t mTid : 4; ///< Spinel transaction id. 252*cfb92d14SAndroid Build Coastguard Worker bool mIsInUse : 1; ///< `true` if this entry is in use, `false` otherwise. 253*cfb92d14SAndroid Build Coastguard Worker ResponseType mType : 2; ///< Response type. 254*cfb92d14SAndroid Build Coastguard Worker uint32_t mPropKeyOrStatus : 24; ///< 3 bytes for either property key or spinel status. 255*cfb92d14SAndroid Build Coastguard Worker }; 256*cfb92d14SAndroid Build Coastguard Worker 257*cfb92d14SAndroid Build Coastguard Worker struct HandlerEntry 258*cfb92d14SAndroid Build Coastguard Worker { 259*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t mKey; 260*cfb92d14SAndroid Build Coastguard Worker NcpBase::PropertyHandler mHandler; 261*cfb92d14SAndroid Build Coastguard Worker }; 262*cfb92d14SAndroid Build Coastguard Worker 263*cfb92d14SAndroid Build Coastguard Worker Spinel::Buffer::FrameTag GetLastOutboundFrameTag(void); 264*cfb92d14SAndroid Build Coastguard Worker 265*cfb92d14SAndroid Build Coastguard Worker otError HandleCommand(uint8_t aHeader); 266*cfb92d14SAndroid Build Coastguard Worker 267*cfb92d14SAndroid Build Coastguard Worker #if __cplusplus >= 201103L 268*cfb92d14SAndroid Build Coastguard Worker static constexpr bool AreHandlerEntriesSorted(const HandlerEntry *aHandlerEntries, size_t aSize); 269*cfb92d14SAndroid Build Coastguard Worker #endif 270*cfb92d14SAndroid Build Coastguard Worker 271*cfb92d14SAndroid Build Coastguard Worker static PropertyHandler FindPropertyHandler(const HandlerEntry *aHandlerEntries, 272*cfb92d14SAndroid Build Coastguard Worker size_t aSize, 273*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t aKey); 274*cfb92d14SAndroid Build Coastguard Worker static PropertyHandler FindGetPropertyHandler(spinel_prop_key_t aKey); 275*cfb92d14SAndroid Build Coastguard Worker static PropertyHandler FindSetPropertyHandler(spinel_prop_key_t aKey); 276*cfb92d14SAndroid Build Coastguard Worker static PropertyHandler FindInsertPropertyHandler(spinel_prop_key_t aKey); 277*cfb92d14SAndroid Build Coastguard Worker static PropertyHandler FindRemovePropertyHandler(spinel_prop_key_t aKey); 278*cfb92d14SAndroid Build Coastguard Worker 279*cfb92d14SAndroid Build Coastguard Worker bool HandlePropertySetForSpecialProperties(uint8_t aHeader, spinel_prop_key_t aKey, otError &aError); 280*cfb92d14SAndroid Build Coastguard Worker otError HandleCommandPropertySet(uint8_t aHeader, spinel_prop_key_t aKey); 281*cfb92d14SAndroid Build Coastguard Worker otError HandleCommandPropertyInsertRemove(uint8_t aHeader, spinel_prop_key_t aKey, unsigned int aCommand); 282*cfb92d14SAndroid Build Coastguard Worker 283*cfb92d14SAndroid Build Coastguard Worker otError WriteLastStatusFrame(uint8_t aHeader, spinel_status_t aLastStatus); 284*cfb92d14SAndroid Build Coastguard Worker otError WritePropertyValueIsFrame(uint8_t aHeader, spinel_prop_key_t aPropKey, bool aIsGetResponse = true); 285*cfb92d14SAndroid Build Coastguard Worker otError WritePropertyValueInsertedRemovedFrame(uint8_t aHeader, 286*cfb92d14SAndroid Build Coastguard Worker unsigned int aResponseCommand, 287*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t aPropKey, 288*cfb92d14SAndroid Build Coastguard Worker const uint8_t *aValuePtr, 289*cfb92d14SAndroid Build Coastguard Worker uint16_t aValueLen); 290*cfb92d14SAndroid Build Coastguard Worker 291*cfb92d14SAndroid Build Coastguard Worker otError SendQueuedResponses(void); IsResponseQueueEmpty(void) const292*cfb92d14SAndroid Build Coastguard Worker bool IsResponseQueueEmpty(void) const { return (mResponseQueueHead == mResponseQueueTail); } 293*cfb92d14SAndroid Build Coastguard Worker otError EnqueueResponse(uint8_t aHeader, ResponseType aType, unsigned int aPropKeyOrStatus); 294*cfb92d14SAndroid Build Coastguard Worker PrepareGetResponse(uint8_t aHeader,spinel_prop_key_t aPropKey)295*cfb92d14SAndroid Build Coastguard Worker otError PrepareGetResponse(uint8_t aHeader, spinel_prop_key_t aPropKey) 296*cfb92d14SAndroid Build Coastguard Worker { 297*cfb92d14SAndroid Build Coastguard Worker return EnqueueResponse(aHeader, kResponseTypeGet, aPropKey); 298*cfb92d14SAndroid Build Coastguard Worker } PrepareSetResponse(uint8_t aHeader,spinel_prop_key_t aPropKey)299*cfb92d14SAndroid Build Coastguard Worker otError PrepareSetResponse(uint8_t aHeader, spinel_prop_key_t aPropKey) 300*cfb92d14SAndroid Build Coastguard Worker { 301*cfb92d14SAndroid Build Coastguard Worker return EnqueueResponse(aHeader, kResponseTypeSet, aPropKey); 302*cfb92d14SAndroid Build Coastguard Worker } PrepareLastStatusResponse(uint8_t aHeader,spinel_status_t aStatus)303*cfb92d14SAndroid Build Coastguard Worker otError PrepareLastStatusResponse(uint8_t aHeader, spinel_status_t aStatus) 304*cfb92d14SAndroid Build Coastguard Worker { 305*cfb92d14SAndroid Build Coastguard Worker return EnqueueResponse(aHeader, kResponseTypeLastStatus, aStatus); 306*cfb92d14SAndroid Build Coastguard Worker } 307*cfb92d14SAndroid Build Coastguard Worker 308*cfb92d14SAndroid Build Coastguard Worker static uint8_t GetWrappedResponseQueueIndex(uint8_t aPosition); 309*cfb92d14SAndroid Build Coastguard Worker 310*cfb92d14SAndroid Build Coastguard Worker static void UpdateChangedProps(Tasklet &aTasklet); 311*cfb92d14SAndroid Build Coastguard Worker void UpdateChangedProps(void); 312*cfb92d14SAndroid Build Coastguard Worker 313*cfb92d14SAndroid Build Coastguard Worker static void HandleFrameRemovedFromNcpBuffer(void *aContext, 314*cfb92d14SAndroid Build Coastguard Worker Spinel::Buffer::FrameTag aFrameTag, 315*cfb92d14SAndroid Build Coastguard Worker Spinel::Buffer::Priority aPriority, 316*cfb92d14SAndroid Build Coastguard Worker Spinel::Buffer *aNcpBuffer); 317*cfb92d14SAndroid Build Coastguard Worker void HandleFrameRemovedFromNcpBuffer(Spinel::Buffer::FrameTag aFrameTag); 318*cfb92d14SAndroid Build Coastguard Worker 319*cfb92d14SAndroid Build Coastguard Worker otError EncodeChannelMask(uint32_t aChannelMask); 320*cfb92d14SAndroid Build Coastguard Worker otError DecodeChannelMask(uint32_t &aChannelMask); 321*cfb92d14SAndroid Build Coastguard Worker 322*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE 323*cfb92d14SAndroid Build Coastguard Worker otError PackRadioFrame(otRadioFrame *aFrame, otError aError); 324*cfb92d14SAndroid Build Coastguard Worker 325*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 326*cfb92d14SAndroid Build Coastguard Worker void NotifySwitchoverDone(bool aSuccess); 327*cfb92d14SAndroid Build Coastguard Worker #endif 328*cfb92d14SAndroid Build Coastguard Worker 329*cfb92d14SAndroid Build Coastguard Worker static void LinkRawReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError); 330*cfb92d14SAndroid Build Coastguard Worker void LinkRawReceiveDone(uint8_t aIid, otRadioFrame *aFrame, otError aError); 331*cfb92d14SAndroid Build Coastguard Worker 332*cfb92d14SAndroid Build Coastguard Worker static void LinkRawTransmitDone(otInstance *aInstance, 333*cfb92d14SAndroid Build Coastguard Worker otRadioFrame *aFrame, 334*cfb92d14SAndroid Build Coastguard Worker otRadioFrame *aAckFrame, 335*cfb92d14SAndroid Build Coastguard Worker otError aError); 336*cfb92d14SAndroid Build Coastguard Worker void LinkRawTransmitDone(uint8_t aIid, otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError); 337*cfb92d14SAndroid Build Coastguard Worker 338*cfb92d14SAndroid Build Coastguard Worker static void LinkRawEnergyScanDone(otInstance *aInstance, int8_t aEnergyScanMaxRssi); 339*cfb92d14SAndroid Build Coastguard Worker void LinkRawEnergyScanDone(uint8_t aIid, int8_t aEnergyScanMaxRssi); 340*cfb92d14SAndroid Build Coastguard Worker GetNcpBaseIid(otInstance * aInstance)341*cfb92d14SAndroid Build Coastguard Worker static inline uint8_t GetNcpBaseIid(otInstance *aInstance) 342*cfb92d14SAndroid Build Coastguard Worker { 343*cfb92d14SAndroid Build Coastguard Worker return sNcpInstance->InstanceToIid(static_cast<Instance *>(aInstance)); 344*cfb92d14SAndroid Build Coastguard Worker } 345*cfb92d14SAndroid Build Coastguard Worker 346*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE 347*cfb92d14SAndroid Build Coastguard Worker 348*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_MTD || OPENTHREAD_FTD 349*cfb92d14SAndroid Build Coastguard Worker static void HandleStateChanged(otChangedFlags aFlags, void *aContext); 350*cfb92d14SAndroid Build Coastguard Worker void ProcessThreadChangedFlags(void); 351*cfb92d14SAndroid Build Coastguard Worker 352*cfb92d14SAndroid Build Coastguard Worker static void HandlePcapFrame(const otRadioFrame *aFrame, bool aIsTx, void *aContext); 353*cfb92d14SAndroid Build Coastguard Worker void HandlePcapFrame(const otRadioFrame *aFrame, bool aIsTx); 354*cfb92d14SAndroid Build Coastguard Worker 355*cfb92d14SAndroid Build Coastguard Worker static void HandleTimeSyncUpdate(void *aContext); 356*cfb92d14SAndroid Build Coastguard Worker void HandleTimeSyncUpdate(void); 357*cfb92d14SAndroid Build Coastguard Worker 358*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_FTD 359*cfb92d14SAndroid Build Coastguard Worker static void HandleNeighborTableChanged(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntry); 360*cfb92d14SAndroid Build Coastguard Worker void HandleNeighborTableChanged(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo &aEntry); 361*cfb92d14SAndroid Build Coastguard Worker 362*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE 363*cfb92d14SAndroid Build Coastguard Worker static void HandleParentResponseInfo(otThreadParentResponseInfo *aInfo, void *aContext); 364*cfb92d14SAndroid Build Coastguard Worker void HandleParentResponseInfo(const otThreadParentResponseInfo &aInfo); 365*cfb92d14SAndroid Build Coastguard Worker #endif 366*cfb92d14SAndroid Build Coastguard Worker #endif 367*cfb92d14SAndroid Build Coastguard Worker 368*cfb92d14SAndroid Build Coastguard Worker static void HandleDatagramFromStack(otMessage *aMessage, void *aContext); 369*cfb92d14SAndroid Build Coastguard Worker void HandleDatagramFromStack(otMessage *aMessage); 370*cfb92d14SAndroid Build Coastguard Worker 371*cfb92d14SAndroid Build Coastguard Worker otError SendQueuedDatagramMessages(void); 372*cfb92d14SAndroid Build Coastguard Worker otError SendDatagramMessage(otMessage *aMessage); 373*cfb92d14SAndroid Build Coastguard Worker 374*cfb92d14SAndroid Build Coastguard Worker static void HandleActiveScanResult_Jump(otActiveScanResult *aResult, void *aContext); 375*cfb92d14SAndroid Build Coastguard Worker void HandleActiveScanResult(otActiveScanResult *aResult); 376*cfb92d14SAndroid Build Coastguard Worker 377*cfb92d14SAndroid Build Coastguard Worker static void HandleEnergyScanResult_Jump(otEnergyScanResult *aResult, void *aContext); 378*cfb92d14SAndroid Build Coastguard Worker void HandleEnergyScanResult(otEnergyScanResult *aResult); 379*cfb92d14SAndroid Build Coastguard Worker 380*cfb92d14SAndroid Build Coastguard Worker static void HandleJamStateChange_Jump(bool aJamState, void *aContext); 381*cfb92d14SAndroid Build Coastguard Worker void HandleJamStateChange(bool aJamState); 382*cfb92d14SAndroid Build Coastguard Worker 383*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 384*cfb92d14SAndroid Build Coastguard Worker static void HandleCommissionerEnergyReport_Jump(uint32_t aChannelMask, 385*cfb92d14SAndroid Build Coastguard Worker const uint8_t *aEnergyData, 386*cfb92d14SAndroid Build Coastguard Worker uint8_t aLength, 387*cfb92d14SAndroid Build Coastguard Worker void *aContext); 388*cfb92d14SAndroid Build Coastguard Worker void HandleCommissionerEnergyReport(uint32_t aChannelMask, const uint8_t *aEnergyData, uint8_t aLength); 389*cfb92d14SAndroid Build Coastguard Worker 390*cfb92d14SAndroid Build Coastguard Worker static void HandleCommissionerPanIdConflict_Jump(uint16_t aPanId, uint32_t aChannelMask, void *aContext); 391*cfb92d14SAndroid Build Coastguard Worker void HandleCommissionerPanIdConflict(uint16_t aPanId, uint32_t aChannelMask); 392*cfb92d14SAndroid Build Coastguard Worker #endif 393*cfb92d14SAndroid Build Coastguard Worker 394*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_JOINER_ENABLE 395*cfb92d14SAndroid Build Coastguard Worker static void HandleJoinerCallback_Jump(otError aError, void *aContext); 396*cfb92d14SAndroid Build Coastguard Worker void HandleJoinerCallback(otError aError); 397*cfb92d14SAndroid Build Coastguard Worker #endif 398*cfb92d14SAndroid Build Coastguard Worker 399*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 400*cfb92d14SAndroid Build Coastguard Worker static void HandleLinkMetricsReport_Jump(const otIp6Address *aSource, 401*cfb92d14SAndroid Build Coastguard Worker const otLinkMetricsValues *aMetricsValues, 402*cfb92d14SAndroid Build Coastguard Worker otLinkMetricsStatus aStatus, 403*cfb92d14SAndroid Build Coastguard Worker void *aContext); 404*cfb92d14SAndroid Build Coastguard Worker 405*cfb92d14SAndroid Build Coastguard Worker void HandleLinkMetricsReport(const otIp6Address *aSource, 406*cfb92d14SAndroid Build Coastguard Worker const otLinkMetricsValues *aMetricsValues, 407*cfb92d14SAndroid Build Coastguard Worker otLinkMetricsStatus aStatus); 408*cfb92d14SAndroid Build Coastguard Worker 409*cfb92d14SAndroid Build Coastguard Worker static void HandleLinkMetricsMgmtResponse_Jump(const otIp6Address *aSource, 410*cfb92d14SAndroid Build Coastguard Worker otLinkMetricsStatus aStatus, 411*cfb92d14SAndroid Build Coastguard Worker void *aContext); 412*cfb92d14SAndroid Build Coastguard Worker 413*cfb92d14SAndroid Build Coastguard Worker void HandleLinkMetricsMgmtResponse(const otIp6Address *aSource, otLinkMetricsStatus aStatus); 414*cfb92d14SAndroid Build Coastguard Worker 415*cfb92d14SAndroid Build Coastguard Worker static void HandleLinkMetricsEnhAckProbingIeReport_Jump(otShortAddress aShortAddress, 416*cfb92d14SAndroid Build Coastguard Worker const otExtAddress *aExtAddress, 417*cfb92d14SAndroid Build Coastguard Worker const otLinkMetricsValues *aMetricsValues, 418*cfb92d14SAndroid Build Coastguard Worker void *aContext); 419*cfb92d14SAndroid Build Coastguard Worker 420*cfb92d14SAndroid Build Coastguard Worker void HandleLinkMetricsEnhAckProbingIeReport(otShortAddress aShortAddress, 421*cfb92d14SAndroid Build Coastguard Worker const otExtAddress *aExtAddress, 422*cfb92d14SAndroid Build Coastguard Worker const otLinkMetricsValues *aMetricsValues); 423*cfb92d14SAndroid Build Coastguard Worker #endif 424*cfb92d14SAndroid Build Coastguard Worker 425*cfb92d14SAndroid Build Coastguard Worker static void HandleMlrRegResult_Jump(void *aContext, 426*cfb92d14SAndroid Build Coastguard Worker otError aError, 427*cfb92d14SAndroid Build Coastguard Worker uint8_t aMlrStatus, 428*cfb92d14SAndroid Build Coastguard Worker const otIp6Address *aFailedAddresses, 429*cfb92d14SAndroid Build Coastguard Worker uint8_t aFailedAddressNum); 430*cfb92d14SAndroid Build Coastguard Worker void HandleMlrRegResult(otError aError, 431*cfb92d14SAndroid Build Coastguard Worker uint8_t aMlrStatus, 432*cfb92d14SAndroid Build Coastguard Worker const otIp6Address *aFailedAddresses, 433*cfb92d14SAndroid Build Coastguard Worker uint8_t aFailedAddressNum); 434*cfb92d14SAndroid Build Coastguard Worker 435*cfb92d14SAndroid Build Coastguard Worker otError EncodeOperationalDataset(const otOperationalDataset &aDataset); 436*cfb92d14SAndroid Build Coastguard Worker 437*cfb92d14SAndroid Build Coastguard Worker otError DecodeOperationalDataset(otOperationalDataset &aDataset, 438*cfb92d14SAndroid Build Coastguard Worker const uint8_t **aTlvs = nullptr, 439*cfb92d14SAndroid Build Coastguard Worker uint8_t *aTlvsLength = nullptr, 440*cfb92d14SAndroid Build Coastguard Worker const otIp6Address **aDestIpAddress = nullptr, 441*cfb92d14SAndroid Build Coastguard Worker bool aAllowEmptyValues = false); 442*cfb92d14SAndroid Build Coastguard Worker 443*cfb92d14SAndroid Build Coastguard Worker otError EncodeNeighborInfo(const otNeighborInfo &aNeighborInfo); 444*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTI_RADIO 445*cfb92d14SAndroid Build Coastguard Worker otError EncodeNeighborMultiRadioInfo(uint32_t aSpinelRadioLink, const otRadioLinkInfo &aInfo); 446*cfb92d14SAndroid Build Coastguard Worker #endif 447*cfb92d14SAndroid Build Coastguard Worker 448*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_FTD 449*cfb92d14SAndroid Build Coastguard Worker otError EncodeChildInfo(const otChildInfo &aChildInfo); 450*cfb92d14SAndroid Build Coastguard Worker #endif 451*cfb92d14SAndroid Build Coastguard Worker 452*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 453*cfb92d14SAndroid Build Coastguard Worker otError EncodeLinkMetricsValues(const otLinkMetricsValues *aMetricsValues); 454*cfb92d14SAndroid Build Coastguard Worker #endif 455*cfb92d14SAndroid Build Coastguard Worker 456*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 457*cfb92d14SAndroid Build Coastguard Worker static void HandleUdpForwardStream(otMessage *aMessage, 458*cfb92d14SAndroid Build Coastguard Worker uint16_t aPeerPort, 459*cfb92d14SAndroid Build Coastguard Worker otIp6Address *aPeerAddr, 460*cfb92d14SAndroid Build Coastguard Worker uint16_t aSockPort, 461*cfb92d14SAndroid Build Coastguard Worker void *aContext); 462*cfb92d14SAndroid Build Coastguard Worker void HandleUdpForwardStream(otMessage *aMessage, uint16_t aPeerPort, otIp6Address &aPeerAddr, uint16_t aPort); 463*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 464*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_MTD || OPENTHREAD_FTD 465*cfb92d14SAndroid Build Coastguard Worker 466*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 467*cfb92d14SAndroid Build Coastguard Worker otError DecodeLinkMetrics(otLinkMetrics *aMetrics, bool aAllowPduCount); 468*cfb92d14SAndroid Build Coastguard Worker #endif 469*cfb92d14SAndroid Build Coastguard Worker 470*cfb92d14SAndroid Build Coastguard Worker otError CommandHandler_NOOP(uint8_t aHeader); 471*cfb92d14SAndroid Build Coastguard Worker otError CommandHandler_RESET(uint8_t aHeader); 472*cfb92d14SAndroid Build Coastguard Worker // Combined command handler for `VALUE_GET`, `VALUE_SET`, `VALUE_INSERT` and `VALUE_REMOVE`. 473*cfb92d14SAndroid Build Coastguard Worker otError CommandHandler_PROP_VALUE_update(uint8_t aHeader, unsigned int aCommand); 474*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE 475*cfb92d14SAndroid Build Coastguard Worker otError CommandHandler_PEEK(uint8_t aHeader); 476*cfb92d14SAndroid Build Coastguard Worker otError CommandHandler_POKE(uint8_t aHeader); 477*cfb92d14SAndroid Build Coastguard Worker #endif 478*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_MTD || OPENTHREAD_FTD 479*cfb92d14SAndroid Build Coastguard Worker otError CommandHandler_NET_CLEAR(uint8_t aHeader); 480*cfb92d14SAndroid Build Coastguard Worker #endif 481*cfb92d14SAndroid Build Coastguard Worker 482*cfb92d14SAndroid Build Coastguard Worker // ---------------------------------------------------------------------------- 483*cfb92d14SAndroid Build Coastguard Worker // Property Handlers 484*cfb92d14SAndroid Build Coastguard Worker // ---------------------------------------------------------------------------- 485*cfb92d14SAndroid Build Coastguard Worker // 486*cfb92d14SAndroid Build Coastguard Worker // There are 4 types of property handlers for "get", "set", "insert", and 487*cfb92d14SAndroid Build Coastguard Worker // "remove" commands. 488*cfb92d14SAndroid Build Coastguard Worker // 489*cfb92d14SAndroid Build Coastguard Worker // "Get" handlers should get/retrieve the property value and then encode and 490*cfb92d14SAndroid Build Coastguard Worker // write the value into the NCP buffer. If the "get" operation itself fails, 491*cfb92d14SAndroid Build Coastguard Worker // "get" handler should write a `LAST_STATUS` with the error status into the NCP 492*cfb92d14SAndroid Build Coastguard Worker // buffer. The `otError` returned from a "get" handler is the error of writing 493*cfb92d14SAndroid Build Coastguard Worker // into the NCP buffer (e.g., running out buffer), and not of the "get" operation 494*cfb92d14SAndroid Build Coastguard Worker // itself. 495*cfb92d14SAndroid Build Coastguard Worker // 496*cfb92d14SAndroid Build Coastguard Worker // "Set/Insert/Remove" handlers should first decode/parse the value from the 497*cfb92d14SAndroid Build Coastguard Worker // input Spinel frame and then perform the corresponding set/insert/remove 498*cfb92d14SAndroid Build Coastguard Worker // operation. They are not responsible for preparing the Spinel response and 499*cfb92d14SAndroid Build Coastguard Worker // therefore should not write anything to the NCP buffer. The `otError` returned 500*cfb92d14SAndroid Build Coastguard Worker // from a "set/insert/remove" handler indicates the error in either parsing of 501*cfb92d14SAndroid Build Coastguard Worker // the input or the error of set/insert/remove operation. 502*cfb92d14SAndroid Build Coastguard Worker // 503*cfb92d14SAndroid Build Coastguard Worker // The corresponding command handler (e.g., `HandleCommandPropertySet()` for 504*cfb92d14SAndroid Build Coastguard Worker // `VALUE_SET` command) will take care of preparing the Spinel response after 505*cfb92d14SAndroid Build Coastguard Worker // invoking the "set/insert/remove" handler for a given property. For example, 506*cfb92d14SAndroid Build Coastguard Worker // for a `VALUE_SET` command, if the "set" handler returns an error, then a 507*cfb92d14SAndroid Build Coastguard Worker // `LAST_STATUS` update response is prepared, otherwise on success the "get" 508*cfb92d14SAndroid Build Coastguard Worker // handler for the property is used to prepare a `VALUE_IS` Spinel response (in 509*cfb92d14SAndroid Build Coastguard Worker // cases where there is no "get" handler for the property, the input value is 510*cfb92d14SAndroid Build Coastguard Worker // echoed in the response). 511*cfb92d14SAndroid Build Coastguard Worker // 512*cfb92d14SAndroid Build Coastguard Worker // Few properties require special treatment where the response needs to be 513*cfb92d14SAndroid Build Coastguard Worker // prepared directly in the "set" handler (e.g., `HOST_POWER_STATE` or 514*cfb92d14SAndroid Build Coastguard Worker // `NEST_STREAM_MFG`). These properties have a different handler method format 515*cfb92d14SAndroid Build Coastguard Worker // (they expect `aHeader` as an input argument) and are processed separately in 516*cfb92d14SAndroid Build Coastguard Worker // `HandleCommandPropertySet()`. 517*cfb92d14SAndroid Build Coastguard Worker 518*cfb92d14SAndroid Build Coastguard Worker template <spinel_prop_key_t aKey> otError HandlePropertyGet(void); 519*cfb92d14SAndroid Build Coastguard Worker template <spinel_prop_key_t aKey> otError HandlePropertySet(void); 520*cfb92d14SAndroid Build Coastguard Worker template <spinel_prop_key_t aKey> otError HandlePropertyInsert(void); 521*cfb92d14SAndroid Build Coastguard Worker template <spinel_prop_key_t aKey> otError HandlePropertyRemove(void); 522*cfb92d14SAndroid Build Coastguard Worker 523*cfb92d14SAndroid Build Coastguard Worker // -------------------------------------------------------------------------- 524*cfb92d14SAndroid Build Coastguard Worker // Property "set" handlers for special properties for which the spinel 525*cfb92d14SAndroid Build Coastguard Worker // response needs to be created from within the set handler. 526*cfb92d14SAndroid Build Coastguard Worker 527*cfb92d14SAndroid Build Coastguard Worker otError HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(uint8_t aHeader); 528*cfb92d14SAndroid Build Coastguard Worker 529*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 530*cfb92d14SAndroid Build Coastguard Worker static_assert(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= 531*cfb92d14SAndroid Build Coastguard Worker OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE - kSpinelCmdHeaderSize - kSpinelPropIdSize, 532*cfb92d14SAndroid Build Coastguard Worker "diag output buffer should be smaller than NCP HDLC tx buffer"); 533*cfb92d14SAndroid Build Coastguard Worker 534*cfb92d14SAndroid Build Coastguard Worker otError HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(uint8_t aHeader); 535*cfb92d14SAndroid Build Coastguard Worker #endif 536*cfb92d14SAndroid Build Coastguard Worker 537*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 538*cfb92d14SAndroid Build Coastguard Worker otError HandlePropertySet_SPINEL_PROP_MESHCOP_COMMISSIONER_GENERATE_PSKC(uint8_t aHeader); 539*cfb92d14SAndroid Build Coastguard Worker otError HandlePropertySet_SPINEL_PROP_THREAD_COMMISSIONER_ENABLED(uint8_t aHeader); 540*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_FTD 541*cfb92d14SAndroid Build Coastguard Worker 542*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE 543*cfb92d14SAndroid Build Coastguard Worker otError DecodeStreamRawTxRequest(otRadioFrame &aFrame); 544*cfb92d14SAndroid Build Coastguard Worker otError HandlePropertySet_SPINEL_PROP_STREAM_RAW(uint8_t aHeader); 545*cfb92d14SAndroid Build Coastguard Worker #endif 546*cfb92d14SAndroid Build Coastguard Worker 547*cfb92d14SAndroid Build Coastguard Worker void ResetCounters(void); 548*cfb92d14SAndroid Build Coastguard Worker 549*cfb92d14SAndroid Build Coastguard Worker static uint8_t ConvertLogLevel(otLogLevel aLogLevel); 550*cfb92d14SAndroid Build Coastguard Worker static unsigned int ConvertLogRegion(otLogRegion aLogRegion); 551*cfb92d14SAndroid Build Coastguard Worker 552*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 553*cfb92d14SAndroid Build Coastguard Worker static void HandleDiagOutput_Jump(const char *aFormat, va_list aArguments, void *aContext); 554*cfb92d14SAndroid Build Coastguard Worker void HandleDiagOutput(const char *aFormat, va_list aArguments); 555*cfb92d14SAndroid Build Coastguard Worker #endif 556*cfb92d14SAndroid Build Coastguard Worker 557*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 558*cfb92d14SAndroid Build Coastguard Worker /** 559*cfb92d14SAndroid Build Coastguard Worker * Defines a vendor "command handler" hook to process vendor-specific spinel commands. 560*cfb92d14SAndroid Build Coastguard Worker * 561*cfb92d14SAndroid Build Coastguard Worker * @param[in] aHeader The spinel frame header. 562*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCommand The spinel command key. 563*cfb92d14SAndroid Build Coastguard Worker * 564*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE The response is prepared. 565*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_BUFS Out of buffer while preparing the response. 566*cfb92d14SAndroid Build Coastguard Worker * 567*cfb92d14SAndroid Build Coastguard Worker */ 568*cfb92d14SAndroid Build Coastguard Worker otError VendorCommandHandler(uint8_t aHeader, unsigned int aCommand); 569*cfb92d14SAndroid Build Coastguard Worker 570*cfb92d14SAndroid Build Coastguard Worker /** 571*cfb92d14SAndroid Build Coastguard Worker * Is a callback which mirrors `NcpBase::HandleFrameRemovedFromNcpBuffer()`. It is called when a 572*cfb92d14SAndroid Build Coastguard Worker * spinel frame is sent and removed from NCP buffer. 573*cfb92d14SAndroid Build Coastguard Worker * 574*cfb92d14SAndroid Build Coastguard Worker * (a) This can be used to track and verify that a vendor spinel frame response is delivered to the host (tracking 575*cfb92d14SAndroid Build Coastguard Worker * the frame using its tag). 576*cfb92d14SAndroid Build Coastguard Worker * 577*cfb92d14SAndroid Build Coastguard Worker * (b) It indicates that NCP buffer space is now available (since a spinel frame is removed). This can be used to 578*cfb92d14SAndroid Build Coastguard Worker * implement mechanisms to re-send a failed/pending response or an async spinel frame. 579*cfb92d14SAndroid Build Coastguard Worker * 580*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrameTag The tag of the frame removed from NCP buffer. 581*cfb92d14SAndroid Build Coastguard Worker * 582*cfb92d14SAndroid Build Coastguard Worker */ 583*cfb92d14SAndroid Build Coastguard Worker void VendorHandleFrameRemovedFromNcpBuffer(Spinel::Buffer::FrameTag aFrameTag); 584*cfb92d14SAndroid Build Coastguard Worker 585*cfb92d14SAndroid Build Coastguard Worker /** 586*cfb92d14SAndroid Build Coastguard Worker * Defines a vendor "get property handler" hook to process vendor spinel properties. 587*cfb92d14SAndroid Build Coastguard Worker * 588*cfb92d14SAndroid Build Coastguard Worker * The vendor handler should return `OT_ERROR_NOT_FOUND` status if it does not support "get" operation for the 589*cfb92d14SAndroid Build Coastguard Worker * given property key. Otherwise, the vendor handler should behave like other property get handlers, i.e., it 590*cfb92d14SAndroid Build Coastguard Worker * should retrieve the property value and then encode and write the value into the NCP buffer. If the "get" 591*cfb92d14SAndroid Build Coastguard Worker * operation itself fails, handler should write a `LAST_STATUS` with the error status into the NCP buffer. 592*cfb92d14SAndroid Build Coastguard Worker * 593*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPropKey The spinel property key. 594*cfb92d14SAndroid Build Coastguard Worker * 595*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully retrieved the property value and prepared the response. 596*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_FOUND Does not support the given property key. 597*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_BUFS Out of buffer while preparing the response. 598*cfb92d14SAndroid Build Coastguard Worker * 599*cfb92d14SAndroid Build Coastguard Worker */ 600*cfb92d14SAndroid Build Coastguard Worker otError VendorGetPropertyHandler(spinel_prop_key_t aPropKey); 601*cfb92d14SAndroid Build Coastguard Worker 602*cfb92d14SAndroid Build Coastguard Worker /** 603*cfb92d14SAndroid Build Coastguard Worker * Defines a vendor "set property handler" hook to process vendor spinel properties. 604*cfb92d14SAndroid Build Coastguard Worker * 605*cfb92d14SAndroid Build Coastguard Worker * The vendor handler should return `OT_ERROR_NOT_FOUND` status if it does not support "set" operation for the 606*cfb92d14SAndroid Build Coastguard Worker * given property key. Otherwise, the vendor handler should behave like other property set handlers, i.e., it 607*cfb92d14SAndroid Build Coastguard Worker * should first decode the value from the input spinel frame and then perform the corresponding set operation. The 608*cfb92d14SAndroid Build Coastguard Worker * handler should not prepare the spinel response and therefore should not write anything to the NCP buffer. The 609*cfb92d14SAndroid Build Coastguard Worker * `otError` returned from handler (other than `OT_ERROR_NOT_FOUND`) indicates the error in either parsing of the 610*cfb92d14SAndroid Build Coastguard Worker * input or the error of the set operation. In case of a successful "set", `NcpBase` set command handler will call 611*cfb92d14SAndroid Build Coastguard Worker * the `VendorGetPropertyHandler()` for the same property key to prepare the response. 612*cfb92d14SAndroid Build Coastguard Worker * 613*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPropKey The spinel property key. 614*cfb92d14SAndroid Build Coastguard Worker * 615*cfb92d14SAndroid Build Coastguard Worker * @returns OT_ERROR_NOT_FOUND if it does not support the given property key, otherwise the error in either parsing 616*cfb92d14SAndroid Build Coastguard Worker * of the input or the "set" operation. 617*cfb92d14SAndroid Build Coastguard Worker * 618*cfb92d14SAndroid Build Coastguard Worker */ 619*cfb92d14SAndroid Build Coastguard Worker otError VendorSetPropertyHandler(spinel_prop_key_t aPropKey); 620*cfb92d14SAndroid Build Coastguard Worker 621*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 622*cfb92d14SAndroid Build Coastguard Worker 623*cfb92d14SAndroid Build Coastguard Worker static void ThreadDetachGracefullyHandler(void *aContext); 624*cfb92d14SAndroid Build Coastguard Worker 625*cfb92d14SAndroid Build Coastguard Worker void ThreadDetachGracefullyHandler(void); 626*cfb92d14SAndroid Build Coastguard Worker 627*cfb92d14SAndroid Build Coastguard Worker static void DatasetSendMgmtPendingSetHandler(otError aResult, void *aContext); 628*cfb92d14SAndroid Build Coastguard Worker 629*cfb92d14SAndroid Build Coastguard Worker void DatasetSendMgmtPendingSetHandler(otError aResult); 630*cfb92d14SAndroid Build Coastguard Worker 631*cfb92d14SAndroid Build Coastguard Worker protected: 632*cfb92d14SAndroid Build Coastguard Worker static NcpBase *sNcpInstance; 633*cfb92d14SAndroid Build Coastguard Worker static spinel_status_t ThreadErrorToSpinelStatus(otError aError); 634*cfb92d14SAndroid Build Coastguard Worker static uint8_t LinkFlagsToFlagByte(bool aRxOnWhenIdle, bool aDeviceType, bool aNetworkData); 635*cfb92d14SAndroid Build Coastguard Worker 636*cfb92d14SAndroid Build Coastguard Worker enum 637*cfb92d14SAndroid Build Coastguard Worker { 638*cfb92d14SAndroid Build Coastguard Worker kTxBufferSize = OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE, // Tx Buffer size (used by mTxFrameBuffer). 639*cfb92d14SAndroid Build Coastguard Worker kResponseQueueSize = OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE, 640*cfb92d14SAndroid Build Coastguard Worker kInvalidScanChannel = -1, // Invalid scan channel. 641*cfb92d14SAndroid Build Coastguard Worker }; 642*cfb92d14SAndroid Build Coastguard Worker 643*cfb92d14SAndroid Build Coastguard Worker Instance *mInstance; 644*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && OPENTHREAD_RADIO 645*cfb92d14SAndroid Build Coastguard Worker Instance *mInstances[kSpinelInterfaceCount]; 646*cfb92d14SAndroid Build Coastguard Worker #endif 647*cfb92d14SAndroid Build Coastguard Worker Spinel::Buffer mTxFrameBuffer; 648*cfb92d14SAndroid Build Coastguard Worker Spinel::Encoder mEncoder; 649*cfb92d14SAndroid Build Coastguard Worker Spinel::Decoder mDecoder; 650*cfb92d14SAndroid Build Coastguard Worker bool mHostPowerStateInProgress; 651*cfb92d14SAndroid Build Coastguard Worker 652*cfb92d14SAndroid Build Coastguard Worker spinel_status_t mLastStatus; 653*cfb92d14SAndroid Build Coastguard Worker uint32_t mScanChannelMask; 654*cfb92d14SAndroid Build Coastguard Worker uint16_t mScanPeriod; 655*cfb92d14SAndroid Build Coastguard Worker bool mDiscoveryScanJoinerFlag; 656*cfb92d14SAndroid Build Coastguard Worker bool mDiscoveryScanEnableFiltering; 657*cfb92d14SAndroid Build Coastguard Worker uint16_t mDiscoveryScanPanId; 658*cfb92d14SAndroid Build Coastguard Worker 659*cfb92d14SAndroid Build Coastguard Worker Tasklet mUpdateChangedPropsTask; 660*cfb92d14SAndroid Build Coastguard Worker uint32_t mThreadChangedFlags; 661*cfb92d14SAndroid Build Coastguard Worker ChangedPropsSet mChangedPropsSet; 662*cfb92d14SAndroid Build Coastguard Worker 663*cfb92d14SAndroid Build Coastguard Worker spinel_host_power_state_t mHostPowerState; 664*cfb92d14SAndroid Build Coastguard Worker Spinel::Buffer::FrameTag mHostPowerReplyFrameTag; 665*cfb92d14SAndroid Build Coastguard Worker uint8_t mHostPowerStateHeader; 666*cfb92d14SAndroid Build Coastguard Worker 667*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE 668*cfb92d14SAndroid Build Coastguard Worker otNcpDelegateAllowPeekPoke mAllowPeekDelegate; 669*cfb92d14SAndroid Build Coastguard Worker otNcpDelegateAllowPeekPoke mAllowPokeDelegate; 670*cfb92d14SAndroid Build Coastguard Worker #endif 671*cfb92d14SAndroid Build Coastguard Worker 672*cfb92d14SAndroid Build Coastguard Worker uint8_t mTxBuffer[kTxBufferSize]; 673*cfb92d14SAndroid Build Coastguard Worker 674*cfb92d14SAndroid Build Coastguard Worker spinel_tid_t mNextExpectedTid[kSpinelInterfaceCount]; 675*cfb92d14SAndroid Build Coastguard Worker 676*cfb92d14SAndroid Build Coastguard Worker uint8_t mResponseQueueHead; 677*cfb92d14SAndroid Build Coastguard Worker uint8_t mResponseQueueTail; 678*cfb92d14SAndroid Build Coastguard Worker ResponseEntry mResponseQueue[kResponseQueueSize]; 679*cfb92d14SAndroid Build Coastguard Worker 680*cfb92d14SAndroid Build Coastguard Worker bool mAllowLocalNetworkDataChange; 681*cfb92d14SAndroid Build Coastguard Worker bool mRequireJoinExistingNetwork; 682*cfb92d14SAndroid Build Coastguard Worker bool mIsRawStreamEnabled[kSpinelInterfaceCount]; 683*cfb92d14SAndroid Build Coastguard Worker bool mPcapEnabled; 684*cfb92d14SAndroid Build Coastguard Worker bool mDisableStreamWrite; 685*cfb92d14SAndroid Build Coastguard Worker bool mShouldEmitChildTableUpdate; 686*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 687*cfb92d14SAndroid Build Coastguard Worker bool mAllowLocalServerDataChange; 688*cfb92d14SAndroid Build Coastguard Worker #endif 689*cfb92d14SAndroid Build Coastguard Worker 690*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_FTD 691*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE 692*cfb92d14SAndroid Build Coastguard Worker otExtAddress mSteeringDataAddress; 693*cfb92d14SAndroid Build Coastguard Worker #endif 694*cfb92d14SAndroid Build Coastguard Worker uint8_t mPreferredRouteId; 695*cfb92d14SAndroid Build Coastguard Worker #endif 696*cfb92d14SAndroid Build Coastguard Worker uint8_t mCurCommandIid; 697*cfb92d14SAndroid Build Coastguard Worker 698*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE 699*cfb92d14SAndroid Build Coastguard Worker uint8_t mCurTransmitTID[kSpinelInterfaceCount]; 700*cfb92d14SAndroid Build Coastguard Worker int8_t mCurScanChannel[kSpinelInterfaceCount]; 701*cfb92d14SAndroid Build Coastguard Worker bool mSrcMatchEnabled[kSpinelInterfaceCount]; 702*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE 703*cfb92d14SAndroid Build Coastguard Worker 704*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_MTD || OPENTHREAD_FTD 705*cfb92d14SAndroid Build Coastguard Worker otMessageQueue mMessageQueue; 706*cfb92d14SAndroid Build Coastguard Worker 707*cfb92d14SAndroid Build Coastguard Worker uint32_t mInboundSecureIpFrameCounter; // Number of secure inbound data/IP frames. 708*cfb92d14SAndroid Build Coastguard Worker uint32_t mInboundInsecureIpFrameCounter; // Number of insecure inbound data/IP frames. 709*cfb92d14SAndroid Build Coastguard Worker uint32_t mOutboundSecureIpFrameCounter; // Number of secure outbound data/IP frames. 710*cfb92d14SAndroid Build Coastguard Worker uint32_t mOutboundInsecureIpFrameCounter; // Number of insecure outbound data/IP frames. 711*cfb92d14SAndroid Build Coastguard Worker uint32_t mDroppedOutboundIpFrameCounter; // Number of dropped outbound data/IP frames. 712*cfb92d14SAndroid Build Coastguard Worker uint32_t mDroppedInboundIpFrameCounter; // Number of dropped inbound data/IP frames. 713*cfb92d14SAndroid Build Coastguard Worker 714*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 715*cfb92d14SAndroid Build Coastguard Worker enum : uint8_t 716*cfb92d14SAndroid Build Coastguard Worker { 717*cfb92d14SAndroid Build Coastguard Worker kSrpClientMaxHostAddresses = OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES, 718*cfb92d14SAndroid Build Coastguard Worker }; 719*cfb92d14SAndroid Build Coastguard Worker 720*cfb92d14SAndroid Build Coastguard Worker otError EncodeSrpClientHostInfo(const otSrpClientHostInfo &aHostInfo); 721*cfb92d14SAndroid Build Coastguard Worker otError EncodeSrpClientServices(const otSrpClientService *aServices); 722*cfb92d14SAndroid Build Coastguard Worker 723*cfb92d14SAndroid Build Coastguard Worker static void HandleSrpClientCallback(otError aError, 724*cfb92d14SAndroid Build Coastguard Worker const otSrpClientHostInfo *aHostInfo, 725*cfb92d14SAndroid Build Coastguard Worker const otSrpClientService *aServices, 726*cfb92d14SAndroid Build Coastguard Worker const otSrpClientService *aRemovedServices, 727*cfb92d14SAndroid Build Coastguard Worker void *aContext); 728*cfb92d14SAndroid Build Coastguard Worker void HandleSrpClientCallback(otError aError, 729*cfb92d14SAndroid Build Coastguard Worker const otSrpClientHostInfo *aHostInfo, 730*cfb92d14SAndroid Build Coastguard Worker const otSrpClientService *aServices, 731*cfb92d14SAndroid Build Coastguard Worker const otSrpClientService *aRemovedServices); 732*cfb92d14SAndroid Build Coastguard Worker 733*cfb92d14SAndroid Build Coastguard Worker bool mSrpClientCallbackEnabled; 734*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 735*cfb92d14SAndroid Build Coastguard Worker 736*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_MTD || OPENTHREAD_FTD 737*cfb92d14SAndroid Build Coastguard Worker 738*cfb92d14SAndroid Build Coastguard Worker uint32_t mFramingErrorCounter; // Number of improperly formed received spinel frames. 739*cfb92d14SAndroid Build Coastguard Worker uint32_t mRxSpinelFrameCounter; // Number of received (inbound) spinel frames. 740*cfb92d14SAndroid Build Coastguard Worker uint32_t mRxSpinelOutOfOrderTidCounter; // Number of out of order received spinel frames (tid increase > 1). 741*cfb92d14SAndroid Build Coastguard Worker uint32_t mTxSpinelFrameCounter; // Number of sent (outbound) spinel frames. 742*cfb92d14SAndroid Build Coastguard Worker 743*cfb92d14SAndroid Build Coastguard Worker bool mDidInitialUpdates; 744*cfb92d14SAndroid Build Coastguard Worker 745*cfb92d14SAndroid Build Coastguard Worker spinel_status_t mDatasetSendMgmtPendingSetResult; 746*cfb92d14SAndroid Build Coastguard Worker 747*cfb92d14SAndroid Build Coastguard Worker uint64_t mLogTimestampBase; // Timestamp base used for logging 748*cfb92d14SAndroid Build Coastguard Worker 749*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 750*cfb92d14SAndroid Build Coastguard Worker char *mDiagOutput; 751*cfb92d14SAndroid Build Coastguard Worker uint16_t mDiagOutputLen; 752*cfb92d14SAndroid Build Coastguard Worker #endif 753*cfb92d14SAndroid Build Coastguard Worker }; 754*cfb92d14SAndroid Build Coastguard Worker 755*cfb92d14SAndroid Build Coastguard Worker } // namespace Ncp 756*cfb92d14SAndroid Build Coastguard Worker } // namespace ot 757*cfb92d14SAndroid Build Coastguard Worker 758*cfb92d14SAndroid Build Coastguard Worker #endif // NCP_BASE_HPP_ 759