IPv6 API cleanup.

This commit is contained in:
Jonathan Hui
2017-01-11 21:55:17 -08:00
parent 669c792118
commit 98da7f3166
34 changed files with 513 additions and 545 deletions
+1
View File
@@ -57,6 +57,7 @@
<ItemGroup>
<ClCompile Include="..\..\src\core\api\commissioner_api.cpp" />
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp" />
<ClCompile Include="..\..\src\core\api\ip6_api.cpp" />
<ClCompile Include="..\..\src\core\api\joiner_api.cpp" />
<ClCompile Include="..\..\src\core\api\link_raw_api.cpp" />
<ClCompile Include="..\..\src\core\api\message_api.cpp" />
@@ -66,6 +66,9 @@
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\ip6_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\joiner_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
@@ -66,6 +66,7 @@
<ItemGroup>
<ClCompile Include="..\..\src\core\api\commissioner_api.cpp" />
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp" />
<ClCompile Include="..\..\src\core\api\ip6_api.cpp" />
<ClCompile Include="..\..\src\core\api\joiner_api.cpp" />
<ClCompile Include="..\..\src\core\api\message_api.cpp" />
<ClCompile Include="..\..\src\core\api\tasklet_api.cpp" />
@@ -66,6 +66,9 @@
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\ip6_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\joiner_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
+2 -2
View File
@@ -379,7 +379,7 @@ void MainPage::ConnectNetwork(Platform::Guid InterfaceGuid)
// Bring up the interface and start the Thread logic
//
otInterfaceUp(device);
otIp6SetEnabled(device, true);
otThreadStart(device);
@@ -400,7 +400,7 @@ void MainPage::DisconnectNetwork(Platform::Guid InterfaceGuid)
otThreadStop(device);
otInterfaceDown(device);
otIp6SetEnabled(device, false);
// Cleanup
otFreeMemory(device);
+10 -20
View File
@@ -1191,29 +1191,19 @@ otGetVersionString()
OTAPI
ThreadError
OTCALL
otInterfaceUp(
_In_ otInstance *aInstance
otIp6SetEnabled(
_In_ otInstance *aInstance,
bool aEnabled
)
{
if (aInstance == nullptr) return kThreadError_InvalidArgs;
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_INTERFACE, (BOOLEAN)TRUE));
}
OTAPI
ThreadError
OTCALL
otInterfaceDown(
_In_ otInstance *aInstance
)
{
if (aInstance == nullptr) return kThreadError_InvalidArgs;
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_INTERFACE, (BOOLEAN)FALSE));
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_INTERFACE, (BOOLEAN)aEnabled));
}
OTAPI
bool
OTCALL
otIsInterfaceUp(
otIp6IsEnabled(
_In_ otInstance *aInstance
)
{
@@ -1924,7 +1914,7 @@ GetAdapterAddresses(
OTAPI
const otNetifAddress *
OTCALL
otGetUnicastAddresses(
otIp6GetUnicastAddresses(
_In_ otInstance *aInstance
)
{
@@ -2039,7 +2029,7 @@ otGetUnicastAddresses(
OTAPI
ThreadError
OTCALL
otAddUnicastAddress(
otIp6AddUnicastAddress(
_In_ otInstance *aInstance,
const otNetifAddress *aAddress
)
@@ -2106,7 +2096,7 @@ otAddUnicastAddress(
OTAPI
ThreadError
OTCALL
otRemoveUnicastAddress(
otIp6RemoveUnicastAddress(
_In_ otInstance *aInstance,
const otIp6Address *aAddress
)
@@ -3688,7 +3678,7 @@ otCommissionerPanIdQuery(
OTAPI
ThreadError
OTCALL
otSendMgmtCommissionerGet(
otCommissionerSendMgmtGet(
_In_ otInstance *aInstance,
const uint8_t *aTlvs,
uint8_t aLength
@@ -3716,7 +3706,7 @@ otSendMgmtCommissionerGet(
OTAPI
ThreadError
OTCALL
otSendMgmtCommissionerSet(
otCommissionerSendMgmtSet(
_In_ otInstance *aInstance,
const otCommissioningDataset *aDataset,
const uint8_t *aTlvs,
+4 -4
View File
@@ -343,10 +343,10 @@ otLwfEventProcessingAddressChanged(
LogInfo(DRIVER_DEFAULT, "Filter %p trying to add/update address: %!IPV6ADDR!", pFilter, pAddr);
// Add (or update) the address to OpenThread
ThreadError otError = otAddUnicastAddress(pFilter->otCtx, &otAddr);
ThreadError otError = otIp6AddUnicastAddress(pFilter->otCtx, &otAddr);
if (otError != kThreadError_None)
{
LogError(DRIVER_DEFAULT, "otAddUnicastAddress failed, %!otError!", otError);
LogError(DRIVER_DEFAULT, "otIp6AddUnicastAddress failed, %!otError!", otError);
ShouldDelete = otError == kThreadError_NoBufs ? TRUE : FALSE;
}
}
@@ -378,7 +378,7 @@ otLwfEventProcessingAddressChanged(
LogInfo(DRIVER_DEFAULT, "Filter %p trying to remove address: %!IPV6ADDR!", pFilter, pAddr);
// Find the correct address from OpenThread to remove (best effort)
(void)otRemoveUnicastAddress(pFilter->otCtx, (otIp6Address*)pAddr);
(void)otIp6RemoveUnicastAddress(pFilter->otCtx, (otIp6Address*)pAddr);
}
}
@@ -398,7 +398,7 @@ otLwfRadioAddressesUpdated(
NT_ASSERT(pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE);
const otNetifAddress* addr = otGetUnicastAddresses(pFilter->otCtx);
const otNetifAddress* addr = otIp6GetUnicastAddresses(pFilter->otCtx);
// Process the addresses
while (addr)
@@ -790,7 +790,7 @@ otLwfEventWorkerThread(
// Register callbacks with OpenThread
otSetStateChangedCallback(pFilter->otCtx, otLwfStateChangedCallback, pFilter);
otSetReceiveIp6DatagramCallback(pFilter->otCtx, otLwfReceiveIp6DatagramCallback, pFilter);
otIp6SetReceiveCallback(pFilter->otCtx, otLwfReceiveIp6DatagramCallback, pFilter);
// Query the current addresses from TCPIP and cache them
(void)otLwfInitializeAddresses(pFilter);
@@ -904,7 +904,7 @@ otLwfEventWorkerThread(
ThreadError error = kThreadError_None;
// Create a new message
otMessage message = otNewIp6Message(pFilter->otCtx, TRUE);
otMessage *message = otIp6NewMessage(pFilter->otCtx, TRUE);
if (message)
{
// Write to the message
@@ -927,7 +927,7 @@ otLwfEventWorkerThread(
#endif
// Send message (it will free 'message')
error = otSendIp6Datagram(pFilter->otCtx, message);
error = otIp6Send(pFilter->otCtx, message);
if (error != kThreadError_None)
{
LogError(DRIVER_DATA_PATH, "otSendIp6Datagram failed with %!otError!", error);
+9 -14
View File
@@ -134,8 +134,8 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
{ "IOCTL_OTLWF_OT_SEND_ACTIVE_SET", REF_IOCTL_FUNC(otSendActiveSet) },
{ "IOCTL_OTLWF_OT_SEND_PENDING_GET", REF_IOCTL_FUNC(otSendPendingGet) },
{ "IOCTL_OTLWF_OT_SEND_PENDING_SET", REF_IOCTL_FUNC(otSendPendingSet) },
{ "IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_GET", REF_IOCTL_FUNC(otSendMgmtCommissionerGet) },
{ "IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_SET", REF_IOCTL_FUNC(otSendMgmtCommissionerSet) },
{ "IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_GET", REF_IOCTL_FUNC(otCommissionerSendMgmtGet) },
{ "IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_SET", REF_IOCTL_FUNC(otCommissionerSendMgmtSet) },
{ "IOCTL_OTLWF_OT_KEY_SWITCH_GUARDTIME", REF_IOCTL_FUNC_WITH_TUN(otKeySwitchGuardtime) },
{ "IOCTL_OTLWF_OT_FACTORY_RESET", REF_IOCTL_FUNC(otFactoryReset) },
{ "IOCTL_OTLWF_OT_THREAD_AUTO_START", REF_IOCTL_FUNC(otThreadAutoStart) }
@@ -456,19 +456,14 @@ otLwfIoCtl_otInterface(
// Make sure our addresses are in sync
(void)otLwfInitializeAddresses(pFilter);
otLwfRadioAddressesUpdated(pFilter);
}
status = ThreadErrorToNtstatus(otInterfaceUp(pFilter->otCtx));
}
else
{
status = ThreadErrorToNtstatus(otInterfaceDown(pFilter->otCtx));
}
status = ThreadErrorToNtstatus(otIp6SetEnabled(pFilter->otCtx, IsEnabled));
*OutBufferLength = 0;
}
else if (*OutBufferLength >= sizeof(BOOLEAN))
{
*(BOOLEAN*)OutBuffer = otIsInterfaceUp(pFilter->otCtx) ? TRUE : FALSE;
*(BOOLEAN*)OutBuffer = otIp6IsEnabled(pFilter->otCtx) ? TRUE : FALSE;
*OutBufferLength = sizeof(BOOLEAN);
status = STATUS_SUCCESS;
}
@@ -5903,7 +5898,7 @@ otLwfIoCtl_otSendPendingSet(
_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
otLwfIoCtl_otSendMgmtCommissionerGet(
otLwfIoCtl_otCommissionerSendMgmtGet(
_In_ PMS_FILTER pFilter,
_In_reads_bytes_(InBufferLength)
PUCHAR InBuffer,
@@ -5926,7 +5921,7 @@ otLwfIoCtl_otSendMgmtCommissionerGet(
if (InBufferLength >= sizeof(uint8_t) + aLength)
{
status = ThreadErrorToNtstatus(
otSendMgmtCommissionerGet(
otCommissionerSendMgmtGet(
pFilter->otCtx,
aTlvs,
aLength)
@@ -5939,7 +5934,7 @@ otLwfIoCtl_otSendMgmtCommissionerGet(
_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
otLwfIoCtl_otSendMgmtCommissionerSet(
otLwfIoCtl_otCommissionerSendMgmtSet(
_In_ PMS_FILTER pFilter,
_In_reads_bytes_(InBufferLength)
PUCHAR InBuffer,
@@ -5963,7 +5958,7 @@ otLwfIoCtl_otSendMgmtCommissionerSet(
if (InBufferLength >= sizeof(otCommissioningDataset) + sizeof(uint8_t) + aLength)
{
status = ThreadErrorToNtstatus(
otSendMgmtCommissionerSet(
otCommissionerSendMgmtSet(
pFilter->otCtx,
aDataset,
aTlvs,
+2 -2
View File
@@ -220,8 +220,8 @@ DECL_IOCTL_FUNC(otSendActiveGet);
DECL_IOCTL_FUNC(otSendActiveSet);
DECL_IOCTL_FUNC(otSendPendingGet);
DECL_IOCTL_FUNC(otSendPendingSet);
DECL_IOCTL_FUNC(otSendMgmtCommissionerGet);
DECL_IOCTL_FUNC(otSendMgmtCommissionerSet);
DECL_IOCTL_FUNC(otCommissionerSendMgmtGet);
DECL_IOCTL_FUNC(otCommissionerSendMgmtSet);
DECL_IOCTL_FUNC_WITH_TUN2(otKeySwitchGuardtime);
DECL_IOCTL_FUNC(otFactoryReset);
DECL_IOCTL_FUNC(otThreadAutoStart);
+1 -1
View File
@@ -63,7 +63,7 @@ RtlCopyBufferToMdl(
#include <openthread-core-config.h>
#include <openthread.h>
#include <openthread-icmp6.h>
#include <openthread-ip6.h>
#include <openthread/ip6.h>
#include <openthread/tasklet.h>
#include <openthread/commissioner.h>
#include <openthread/joiner.h>
+1 -1
View File
@@ -87,7 +87,7 @@ otPlatReset(
// Register callbacks with OpenThread
otSetStateChangedCallback(pFilter->otCtx, otLwfStateChangedCallback, pFilter);
otSetReceiveIp6DatagramCallback(pFilter->otCtx, otLwfReceiveIp6DatagramCallback, pFilter);
otIp6SetReceiveCallback(pFilter->otCtx, otLwfReceiveIp6DatagramCallback, pFilter);
// Query the current addresses from TCPIP and cache them
(void)otLwfInitializeAddresses(pFilter);
+1 -1
View File
@@ -376,7 +376,7 @@ void otLwfStateChangedCallback(uint32_t aFlags, _In_ void *aContext)
if ((aFlags & OT_THREAD_NETDATA_UPDATED) != 0)
{
LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_THREAD_NETDATA_UPDATED", pFilter);
otSlaacUpdate(pFilter->otCtx, pFilter->otAutoAddresses, ARRAYSIZE(pFilter->otAutoAddresses), otCreateRandomIid, NULL);
otIp6SlaacUpdate(pFilter->otCtx, pFilter->otAutoAddresses, ARRAYSIZE(pFilter->otAutoAddresses), otIp6CreateRandomIid, NULL);
#if OPENTHREAD_ENABLE_DHCP6_SERVER
otDhcp6ServerUpdate(pFilter->otCtx);
@@ -642,7 +642,7 @@ exit:
void HandleAddressChanges(otNode *aNode)
{
otLogFuncEntry();
auto addrs = otGetUnicastAddresses(aNode->mInstance);
auto addrs = otIp6GetUnicastAddresses(aNode->mInstance);
EnterCriticalSection(&aNode->mCS);
@@ -955,7 +955,7 @@ OTNODEAPI int32_t OTCALL otNodeInterfaceUp(otNode* aNode)
otLogFuncEntryMsg("[%d]", aNode->mId);
printf("%d: ifconfig up\r\n", aNode->mId);
auto error = otInterfaceUp(aNode->mInstance);
auto error = otIp6SetEnabled(aNode->mInstance, true);
otLogFuncExit();
return error;
@@ -966,7 +966,7 @@ OTNODEAPI int32_t OTCALL otNodeInterfaceDown(otNode* aNode)
otLogFuncEntryMsg("[%d]", aNode->mId);
printf("%d: ifconfig down\r\n", aNode->mId);
(void)otInterfaceDown(aNode->mInstance);
(void)otIp6SetEnabled(aNode->mInstance, false);
otLogFuncExit();
return 0;
@@ -1436,7 +1436,7 @@ OTNODEAPI int32_t OTCALL otNodeAddIpAddr(otNode* aNode, const char *aAddr)
aAddress.mPrefixLength = 64;
aAddress.mPreferred = true;
aAddress.mValid = true;
auto result = otAddUnicastAddress(aNode->mInstance, &aAddress);
auto result = otIp6AddUnicastAddress(aNode->mInstance, &aAddress);
otLogFuncExit();
return result;
}
@@ -1453,7 +1453,7 @@ OTNODEAPI const char* OTCALL otNodeGetAddrs(otNode* aNode)
otLogFuncEntryMsg("[%d]", aNode->mId);
printf("%d: ipaddr\r\n", aNode->mId);
auto addrs = otGetUnicastAddresses(aNode->mInstance);
auto addrs = otIp6GetUnicastAddresses(aNode->mInstance);
if (addrs == nullptr) return nullptr;
char* str = (char*)malloc(512);
-1
View File
@@ -60,7 +60,6 @@ include_HEADERS = \
openthread.h \
openthread-diag.h \
openthread-icmp6.h \
openthread-ip6.h \
openthread-types.h \
$(NULL)
+1 -143
View File
@@ -38,6 +38,7 @@
#include <openthread-types.h>
#include "openthread/crypto.h"
#include "openthread/ip6.h"
#include "openthread/message.h"
#include "openthread/tasklet.h"
@@ -259,43 +260,6 @@ void otInstanceFinalize(otInstance *aInstance);
#endif
/**
* This function brings up the IPv6 interface.
*
* Call this function to bring up the IPv6 interface and enables IPv6 communication.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval kThreadError_None Successfully enabled the IPv6 interface,
* or the interface was already enabled.
*
*/
OTAPI ThreadError OTCALL otInterfaceUp(otInstance *aInstance);
/**
* This function brings down the IPv6 interface.
*
* Call this function to bring down the IPv6 interface and disable all IPv6 communication.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval kThreadError_None Successfully brought the interface down,
* or the interface was already down.
*
*/
OTAPI ThreadError OTCALL otInterfaceDown(otInstance *aInstance);
/**
* This function indicates whether or not the IPv6 interface is up.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval TRUE The IPv6 interface is up.
* @retval FALSE The IPv6 interface is down.
*
*/
OTAPI bool OTCALL otIsInterfaceUp(otInstance *aInstance);
/**
* This function starts Thread protocol operation.
*
@@ -852,42 +816,6 @@ OTAPI void OTCALL otSetRouterRoleEnabled(otInstance *aInstance, bool aEnabled);
*/
OTAPI otShortAddress OTCALL otGetShortAddress(otInstance *aInstance);
/**
* Get the list of IPv6 addresses assigned to the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns A pointer to the first Network Interface Address.
*/
OTAPI const otNetifAddress *OTCALL otGetUnicastAddresses(otInstance *aInstance);
/**
* Add a Network Interface Address to the Thread interface.
*
* The passed in instance @p aAddress will be copied by the Thread interface. The Thread interface only
* supports a fixed number of externally added unicast addresses. See OPENTHREAD_CONFIG_MAX_EXT_IP_ADDRS.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to a Network Interface Address.
*
* @retval kThreadErrorNone Successfully added (or updated) the Network Interface Address.
* @retval kThreadError_InvalidArgs The IP Address indicated by @p aAddress is an internal address.
* @retval kThreadError_NoBufs The Network Interface is already storing the maximum allowed external addresses.
*/
OTAPI ThreadError OTCALL otAddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAddress);
/**
* Remove a Network Interface Address from the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to an IP Address.
*
* @retval kThreadErrorNone Successfully removed the Network Interface Address.
* @retval kThreadError_InvalidArgs The IP Address indicated by @p aAddress is an internal address.
* @retval kThreadError_NotFound The IP Address indicated by @p aAddress was not found.
*/
OTAPI ThreadError OTCALL otRemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
* This function registers a callback to indicate when certain configuration or state changes within OpenThread.
*
@@ -1235,43 +1163,6 @@ OTAPI ThreadError OTCALL otRemoveExternalRoute(otInstance *aInstance, const otIp
*/
OTAPI ThreadError OTCALL otSendServerData(otInstance *aInstance);
/**
* This function adds a port to the allowed unsecured port list.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The port value.
*
* @retval kThreadError_None The port was successfully added to the allowed unsecure port list.
* @retval kThreadError_NoBufs The unsecure port list is full.
*
*/
ThreadError otAddUnsecurePort(otInstance *aInstance, uint16_t aPort);
/**
* This function removes a port from the allowed unsecure port list.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The port value.
*
* @retval kThreadError_None The port was successfully removed from the allowed unsecure port list.
* @retval kThreadError_NotFound The port was not found in the unsecure port list.
*
*/
ThreadError otRemoveUnsecurePort(otInstance *aInstance, uint16_t aPort);
/**
* This function returns a pointer to the unsecure port list.
*
* @note Port value 0 is used to indicate an invalid entry.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aNumEntries The number of entries in the list.
*
* @returns A pointer to the unsecure port list.
*
*/
const uint16_t *otGetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries);
/**
* @}
*
@@ -2011,39 +1902,6 @@ OTAPI const otMacCounters *OTCALL otGetMacCounters(otInstance *aInstance);
*
*/
/**
* Test if two IPv6 addresses are the same.
*
* @param[in] a A pointer to the first IPv6 address to compare.
* @param[in] b A pointer to the second IPv6 address to compare.
*
* @retval TRUE The two IPv6 addresses are the same.
* @retval FALSE The two IPv6 addresses are not the same.
*/
OTAPI bool OTCALL otIsIp6AddressEqual(const otIp6Address *a, const otIp6Address *b);
/**
* Convert a human-readable IPv6 address string into a binary representation.
*
* @param[in] aString A pointer to a NULL-terminated string.
* @param[out] aAddress A pointer to an IPv6 address.
*
* @retval kThreadErrorNone Successfully parsed the string.
* @retval kThreadErrorInvalidArg Failed to parse the string.
*/
OTAPI ThreadError OTCALL otIp6AddressFromString(const char *aString, otIp6Address *aAddress);
/**
* This function returns the prefix match length (bits) for two IPv6 addresses.
*
* @param[in] aFirst A pointer to the first IPv6 address.
* @param[in] aSecond A pointer to the second IPv6 address.
*
* @returns The prefix match length in bits.
*
*/
OTAPI uint8_t OTCALL otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond);
/**
* This function converts a ThreadError enum into a string.
*
+1
View File
@@ -34,6 +34,7 @@ openthread_headers = \
crypto.h \
dhcp6_client.h \
dhcp6_server.h \
ip6.h \
jam_detection.h \
joiner.h \
message.h \
@@ -29,39 +29,19 @@
/**
* @file
* @brief
* This file defines the top-level ip6 functions for the OpenThread library.
* This file defines the OpenThread IPv6 API.
*/
#ifndef OPENTHREAD_IP6_H_
#define OPENTHREAD_IP6_H_
#include "openthread/message.h"
#include <platform/radio.h>
#include "platform/radio.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup api API
* @brief
* This module includes the application programming interface to the OpenThread stack.
*
* @{
*
* @defgroup execution Execution
* @defgroup commands Commands
* @defgroup config Configuration
* @defgroup diags Diagnostics
* @defgroup messages Message Buffers
* @defgroup ip6 IPv6
* @defgroup udp UDP
* @defgroup coap CoAP
*
* @}
*
*/
/**
* @addtogroup diags Diagnostics
*
@@ -139,13 +119,65 @@ ThreadError otSetLinkPromiscuous(otInstance *aInstance, bool aPromiscuous);
*/
/**
* Get the list of IPv6 multicast addresses subscribed to the Thread interface.
* This function brings up the IPv6 interface.
*
* Call this function to enable/disable IPv6 communication.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE to enable IPv6, FALSE otherwise.
*
* @retval kThreadError_None Successfully enabled the IPv6 interface,
* or the interface was already enabled.
*
*/
OTAPI ThreadError OTCALL otIp6SetEnabled(otInstance *aInstance, bool aEnabled);
/**
* This function indicates whether or not the IPv6 interface is up.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval TRUE The IPv6 interface is enabled.
* @retval FALSE The IPv6 interface is disabled.
*
*/
OTAPI bool OTCALL otIp6IsEnabled(otInstance *aInstance);
/**
* Add a Network Interface Address to the Thread interface.
*
* The passed in instance @p aAddress will be copied by the Thread interface. The Thread interface only
* supports a fixed number of externally added unicast addresses. See OPENTHREAD_CONFIG_MAX_EXT_IP_ADDRS.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to a Network Interface Address.
*
* @retval kThreadErrorNone Successfully added (or updated) the Network Interface Address.
* @retval kThreadError_InvalidArgs The IP Address indicated by @p aAddress is an internal address.
* @retval kThreadError_NoBufs The Network Interface is already storing the maximum allowed external addresses.
*/
OTAPI ThreadError OTCALL otIp6AddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAddress);
/**
* Remove a Network Interface Address from the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to an IP Address.
*
* @retval kThreadErrorNone Successfully removed the Network Interface Address.
* @retval kThreadError_InvalidArgs The IP Address indicated by @p aAddress is an internal address.
* @retval kThreadError_NotFound The IP Address indicated by @p aAddress was not found.
*/
OTAPI ThreadError OTCALL otIp6RemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
* Get the list of IPv6 addresses assigned to the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns A pointer to the first Network Interface Multicast Address.
* @returns A pointer to the first Network Interface Address.
*/
const otNetifMulticastAddress *otGetMulticastAddresses(otInstance *aInstance);
OTAPI const otNetifAddress *OTCALL otIp6GetUnicastAddresses(otInstance *aInstance);
/**
* Subscribe the Thread interface to a Network Interface Multicast Address.
@@ -160,7 +192,7 @@ const otNetifMulticastAddress *otGetMulticastAddresses(otInstance *aInstance);
* @retval kThreadError_InvalidArgs The IP Address indicated by @p aAddress is invalid address.
* @retval kThreadError_NoBufs The Network Interface is already storing the maximum allowed external multicast addresses.
*/
ThreadError otSubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
ThreadError otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
* Unsubscribe the Thread interface to a Network Interface Multicast Address.
@@ -172,37 +204,35 @@ ThreadError otSubscribeMulticastAddress(otInstance *aInstance, const otIp6Addres
* @retval kThreadError_InvalidArgs The IP Address indicated by @p aAddress is an internal address.
* @retval kThreadError_NotFound The IP Address indicated by @p aAddress was not found.
*/
ThreadError otUnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
ThreadError otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
* Get the list of IPv6 multicast addresses subscribed to the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns A pointer to the first Network Interface Multicast Address.
*/
const otNetifMulticastAddress *otIp6GetMulticastAddresses(otInstance *aInstance);
/**
* Check if multicast promiscuous mode is enabled on the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @sa otEnableMulticastPromiscuousMode
* @sa otDisableMulticastPromiscuousMode
* @sa otIp6SetMulticastPromiscuousEnabled
*/
bool otIsMulticastPromiscuousModeEnabled(otInstance *aInstance);
bool otIp6IsMulticastPromiscuousEnabled(otInstance *aInstance);
/**
* Enable multicast promiscuous mode on the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE to enable Multicast Promiscuous mode, FALSE otherwise.
*
* @sa otIsMulticastPromiscuousModeEnabled
* @sa otDisableMulticastPromiscuousMode
* @sa otIp6IsMulticastPromiscuousEnabled
*/
void otEnableMulticastPromiscuousMode(otInstance *aInstance);
/**
* Disable multicast promiscuous mode on the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @sa otIsMulticastPromiscuousModeEnabled
* @sa otEnableMulticastPromiscuousMode
*/
void otDisableMulticastPromiscuousMode(otInstance *aInstance);
void otIp6SetMulticastPromiscuousEnabled(otInstance *aInstance, bool aEnabled);
/**
* This function pointer is called to create IPv6 IID during SLAAC procedure.
@@ -215,7 +245,7 @@ void otDisableMulticastPromiscuousMode(otInstance *aInstance);
* @retval kThreadError_Ipv6AddressCreationFailure Creation of valid IID for given IPv6 address failed.
*
*/
typedef ThreadError(*otSlaacIidCreate)(otInstance *aInstance, otNetifAddress *aAddress, void *aContext);
typedef ThreadError(*otIp6SlaacIidCreate)(otInstance *aInstance, otNetifAddress *aAddress, void *aContext);
/**
* Update all automatically created IPv6 addresses for prefixes from current Network Data with SLAAC procedure.
@@ -227,45 +257,45 @@ typedef ThreadError(*otSlaacIidCreate)(otInstance *aInstance, otNetifAddress *aA
* @param[in] aContext A pointer to data passed to aIidCreate function.
*
*/
void otSlaacUpdate(otInstance *aInstance, otNetifAddress *aAddresses, uint32_t aNumAddresses,
otSlaacIidCreate aIidCreate, void *aContext);
void otIp6SlaacUpdate(otInstance *aInstance, otNetifAddress *aAddresses, uint32_t aNumAddresses,
otIp6SlaacIidCreate aIidCreate, void *aContext);
/**
* Create random IID for given IPv6 address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[in] aContext A pointer to unused data.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddresses A pointer to structure containing IPv6 address for which IID is being created.
* @param[in] aContext A pointer to unused data.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
*
*/
ThreadError otCreateRandomIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
ThreadError otIp6CreateRandomIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
/**
* Create IID for given IPv6 address using extended MAC address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[in] aContext A pointer to unused data.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddresses A pointer to structure containing IPv6 address for which IID is being created.
* @param[in] aContext A pointer to unused data.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
*
*/
ThreadError otCreateMacIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
ThreadError otIp6CreateMacIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
/**
* Create semantically opaque IID for given IPv6 address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[inout] aContext A pointer to a otSemanticallyOpaqueIidGeneratorData structure.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddresses A pointer to structure containing IPv6 address for which IID is being created.
* @param[inout] aContext A pointer to a otSemanticallyOpaqueIidGeneratorData structure.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
* @retval kThreadError_Ipv6AddressCreationFailure Could not create valid IID for given IPv6 address.
*
*/
ThreadError otCreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
ThreadError otIp6CreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
/**
* Allocate a new message buffer for sending an IPv6 message.
@@ -277,7 +307,7 @@ ThreadError otCreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress
*
* @sa otFreeMessage
*/
otMessage otNewIp6Message(otInstance *aInstance, bool aLinkSecurityEnabled);
otMessage otIp6NewMessage(otInstance *aInstance, bool aLinkSecurityEnabled);
/**
* This function pointer is called when an IPv6 datagram is received.
@@ -286,12 +316,12 @@ otMessage otNewIp6Message(otInstance *aInstance, bool aLinkSecurityEnabled);
* @param[in] aContext A pointer to application-specific context.
*
*/
typedef void (*otReceiveIp6DatagramCallback)(otMessage aMessage, void *aContext);
typedef void (*otIp6ReceiveCallback)(otMessage aMessage, void *aContext);
/**
* This function registers a callback to provide received IPv6 datagrams.
*
* By default, this callback does not pass Thread control traffic. See otSetReceiveIp6DatagramFilterEnabled() to
* By default, this callback does not pass Thread control traffic. See otIp6SetReceiveFilterEnabled() to
* change the Thread control traffic filter setting.
*
* @param[in] aInstance A pointer to an OpenThread instance.
@@ -299,39 +329,38 @@ typedef void (*otReceiveIp6DatagramCallback)(otMessage aMessage, void *aContext)
* NULL to disable the callback.
* @param[in] aCallbackContext A pointer to application-specific context.
*
* @sa otIsReceiveIp6DatagramFilterEnabled
* @sa otSetReceiveIp6DatagramFilterEnabled
* @sa otIp6IsReceiveFilterEnabled
* @sa otIp6SetReceiveFilterEnabled
*
*/
void otSetReceiveIp6DatagramCallback(otInstance *aInstance, otReceiveIp6DatagramCallback aCallback,
void *aCallbackContext);
void otIp6SetReceiveCallback(otInstance *aInstance, otIp6ReceiveCallback aCallback, void *aCallbackContext);
/**
* This function indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
* via the callback specified in otSetReceiveIp6DatagramCallback().
* via the callback specified in otIp6SetReceiveCallback().
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns TRUE if Thread control traffic is filtered out, FALSE otherwise.
*
* @sa otSetReceiveIp6DatagramCallback
* @sa otSetReceiveIp6DatagramFilterEnabled
* @sa otIp6SetReceiveCallback
* @sa otIp6SetReceiveFilterEnabled
*
*/
bool otIsReceiveIp6DatagramFilterEnabled(otInstance *aInstance);
bool otIp6IsReceiveFilterEnabled(otInstance *aInstance);
/**
* This function sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
* via the callback specified in otSetReceiveIp6DatagramCallback().
* via the callback specified in otIp6SetReceiveCallback().
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE if Thread control traffic is filtered out, FALSE otherwise.
*
* @sa otSetReceiveIp6DatagramCallback
* @sa otIsReceiveIp6DatagramFilterEnabled
* @sa otIp6SetReceiveCallback
* @sa otIsReceiveIp6FilterEnabled
*
*/
void otSetReceiveIp6DatagramFilterEnabled(otInstance *aInstance, bool aEnabled);
void otIp6SetReceiveFilterEnabled(otInstance *aInstance, bool aEnabled);
/**
* This function sends an IPv6 datagram via the Thread interface.
@@ -340,7 +369,77 @@ void otSetReceiveIp6DatagramFilterEnabled(otInstance *aInstance, bool aEnabled);
* @param[in] aMessage A pointer to the message buffer containing the IPv6 datagram.
*
*/
ThreadError otSendIp6Datagram(otInstance *aInstance, otMessage aMessage);
ThreadError otIp6Send(otInstance *aInstance, otMessage aMessage);
/**
* This function adds a port to the allowed unsecured port list.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The port value.
*
* @retval kThreadError_None The port was successfully added to the allowed unsecure port list.
* @retval kThreadError_NoBufs The unsecure port list is full.
*
*/
ThreadError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort);
/**
* This function removes a port from the allowed unsecure port list.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The port value.
*
* @retval kThreadError_None The port was successfully removed from the allowed unsecure port list.
* @retval kThreadError_NotFound The port was not found in the unsecure port list.
*
*/
ThreadError otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort);
/**
* This function returns a pointer to the unsecure port list.
*
* @note Port value 0 is used to indicate an invalid entry.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aNumEntries The number of entries in the list.
*
* @returns A pointer to the unsecure port list.
*
*/
const uint16_t *otIp6GetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries);
/**
* Test if two IPv6 addresses are the same.
*
* @param[in] a A pointer to the first IPv6 address to compare.
* @param[in] b A pointer to the second IPv6 address to compare.
*
* @retval TRUE The two IPv6 addresses are the same.
* @retval FALSE The two IPv6 addresses are not the same.
*/
OTAPI bool OTCALL otIp6IsAddressEqual(const otIp6Address *a, const otIp6Address *b);
/**
* Convert a human-readable IPv6 address string into a binary representation.
*
* @param[in] aString A pointer to a NULL-terminated string.
* @param[out] aAddress A pointer to an IPv6 address.
*
* @retval kThreadErrorNone Successfully parsed the string.
* @retval kThreadErrorInvalidArg Failed to parse the string.
*/
OTAPI ThreadError OTCALL otIp6AddressFromString(const char *aString, otIp6Address *aAddress);
/**
* This function returns the prefix match length (bits) for two IPv6 addresses.
*
* @param[in] aFirst A pointer to the first IPv6 address.
* @param[in] aSecond A pointer to the second IPv6 address.
*
* @returns The prefix match length in bits.
*
*/
OTAPI uint8_t OTCALL otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond);
/**
* @}
+15 -15
View File
@@ -839,7 +839,7 @@ void Interpreter::ProcessIfconfig(int argc, char *argv[])
if (argc == 0)
{
if (otIsInterfaceUp(mInstance))
if (otIp6IsEnabled(mInstance))
{
sServer->OutputFormat("up\r\n");
}
@@ -850,11 +850,11 @@ void Interpreter::ProcessIfconfig(int argc, char *argv[])
}
else if (strcmp(argv[0], "up") == 0)
{
SuccessOrExit(error = otInterfaceUp(mInstance));
SuccessOrExit(error = otIp6SetEnabled(mInstance, true));
}
else if (strcmp(argv[0], "down") == 0)
{
SuccessOrExit(error = otInterfaceDown(mInstance));
SuccessOrExit(error = otIp6SetEnabled(mInstance, false));
}
exit:
@@ -872,7 +872,7 @@ ThreadError Interpreter::ProcessIpAddrAdd(int argc, char *argv[])
aAddress.mPrefixLength = 64;
aAddress.mPreferred = true;
aAddress.mValid = true;
error = otAddUnicastAddress(mInstance, &aAddress);
error = otIp6AddUnicastAddress(mInstance, &aAddress);
exit:
return error;
@@ -886,7 +886,7 @@ ThreadError Interpreter::ProcessIpAddrDel(int argc, char *argv[])
VerifyOrExit(argc > 0, error = kThreadError_Parse);
SuccessOrExit(error = otIp6AddressFromString(argv[0], &address));
error = otRemoveUnicastAddress(mInstance, &address);
error = otIp6RemoveUnicastAddress(mInstance, &address);
exit:
return error;
@@ -898,7 +898,7 @@ void Interpreter::ProcessIpAddr(int argc, char *argv[])
if (argc == 0)
{
otNetifAddressPtr unicastAddrs(otGetUnicastAddresses(mInstance));
otNetifAddressPtr unicastAddrs(otIp6GetUnicastAddresses(mInstance));
for (const otNetifAddress *addr = unicastAddrs; addr; addr = addr->mNext)
{
@@ -938,7 +938,7 @@ ThreadError Interpreter::ProcessIpMulticastAddrAdd(int argc, char *argv[])
VerifyOrExit(argc > 0, error = kThreadError_Parse);
SuccessOrExit(error = otIp6AddressFromString(argv[0], &address));
error = otSubscribeMulticastAddress(mInstance, &address);
error = otIp6SubscribeMulticastAddress(mInstance, &address);
exit:
return error;
@@ -952,7 +952,7 @@ ThreadError Interpreter::ProcessIpMulticastAddrDel(int argc, char *argv[])
VerifyOrExit(argc > 0, error = kThreadError_Parse);
SuccessOrExit(error = otIp6AddressFromString(argv[0], &address));
error = otUnsubscribeMulticastAddress(mInstance, &address);
error = otIp6UnsubscribeMulticastAddress(mInstance, &address);
exit:
return error;
@@ -964,7 +964,7 @@ ThreadError Interpreter::ProcessMulticastPromiscuous(int argc, char *argv[])
if (argc == 0)
{
if (otIsMulticastPromiscuousModeEnabled(mInstance))
if (otIp6IsMulticastPromiscuousEnabled(mInstance))
{
sServer->OutputFormat("Enabled\r\n");
}
@@ -977,11 +977,11 @@ ThreadError Interpreter::ProcessMulticastPromiscuous(int argc, char *argv[])
{
if (strcmp(argv[0], "enable") == 0)
{
otEnableMulticastPromiscuousMode(mInstance);
otIp6SetMulticastPromiscuousEnabled(mInstance, true);
}
else if (strcmp(argv[0], "disable") == 0)
{
otDisableMulticastPromiscuousMode(mInstance);
otIp6SetMulticastPromiscuousEnabled(mInstance, false);
}
else
{
@@ -999,7 +999,7 @@ void Interpreter::ProcessIpMulticastAddr(int argc, char *argv[])
if (argc == 0)
{
for (const otNetifMulticastAddress *addr = otGetMulticastAddresses(mInstance); addr; addr = addr->mNext)
for (const otNetifMulticastAddress *addr = otIp6GetMulticastAddresses(mInstance); addr; addr = addr->mNext)
{
sServer->OutputFormat("%x:%x:%x:%x:%x:%x:%x:%x\r\n",
HostSwap16(addr->mAddress.mFields.m16[0]),
@@ -1442,7 +1442,7 @@ void Interpreter::HandlePingTimer()
otMessage message;
const otMessageInfo *messageInfo = static_cast<const otMessageInfo *>(&sMessageInfo);
VerifyOrExit((message = otNewIp6Message(mInstance, true)) != NULL, error = kThreadError_NoBufs);
VerifyOrExit((message = otIp6NewMessage(mInstance, true)) != NULL, error = kThreadError_NoBufs);
SuccessOrExit(error = otMessageAppend(message, &timestamp, sizeof(timestamp)));
SuccessOrExit(error = otMessageSetLength(message, sLength));
SuccessOrExit(error = otIcmp6SendEchoRequest(mInstance, message, messageInfo, 1));
@@ -2796,8 +2796,8 @@ void Interpreter::HandleNetifStateChanged(uint32_t aFlags)
VerifyOrExit((aFlags & OT_THREAD_NETDATA_UPDATED) != 0, ;);
#ifndef OTDLL
otSlaacUpdate(mInstance, mSlaacAddresses, sizeof(mSlaacAddresses) / sizeof(mSlaacAddresses[0]), otCreateRandomIid,
NULL);
otIp6SlaacUpdate(mInstance, mSlaacAddresses, sizeof(mSlaacAddresses) / sizeof(mSlaacAddresses[0]),
otIp6CreateRandomIid, NULL);
#if OPENTHREAD_ENABLE_DHCP6_SERVER
otDhcp6ServerUpdate(mInstance);
#endif // OPENTHREAD_ENABLE_DHCP6_SERVER
+1 -1
View File
@@ -42,7 +42,7 @@
#include <openthread.h>
#include <stdarg.h>
#include <openthread-ip6.h>
#include "openthread/ip6.h"
#include "openthread/udp.h"
#include <cli/cli_server.hpp>
+1
View File
@@ -41,6 +41,7 @@ CPPFLAGS_COMMON = \
SOURCES_COMMON = \
openthread.cpp \
api/crypto_api.cpp \
api/ip6_api.cpp \
api/message_api.cpp \
api/tasklet_api.cpp \
api/udp_api.cpp \
+226
View File
@@ -0,0 +1,226 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread UDP API.
*/
#define WPP_NAME "ip6_api.tmh"
#include "openthread/ip6.h"
#include "openthread-instance.h"
#include "common/logging.hpp"
#include "utils/slaac_address.hpp"
using namespace Thread;
#ifdef __cplusplus
extern "C" {
#endif
ThreadError otIp6SetEnabled(otInstance *aInstance, bool aEnabled)
{
ThreadError error = kThreadError_None;
otLogFuncEntry();
if (aEnabled)
{
#if OPENTHREAD_ENABLE_RAW_LINK_API
VerifyOrExit(!aInstance->mLinkRaw.IsEnabled(), error = kThreadError_InvalidState);
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
error = aInstance->mThreadNetif.Up();
}
else
{
#if OPENTHREAD_ENABLE_RAW_LINK_API
VerifyOrExit(!aInstance->mLinkRaw.IsEnabled(), error = kThreadError_InvalidState);
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
error = aInstance->mThreadNetif.Down();
}
#if OPENTHREAD_ENABLE_RAW_LINK_API
exit:
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
otLogFuncExitErr(error);
return error;
}
bool otIp6IsEnabled(otInstance *aInstance)
{
return aInstance->mThreadNetif.IsUp();
}
const otNetifAddress *otIp6GetUnicastAddresses(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetUnicastAddresses();
}
ThreadError otIp6AddUnicastAddress(otInstance *aInstance, const otNetifAddress *address)
{
return aInstance->mThreadNetif.AddExternalUnicastAddress(*static_cast<const Ip6::NetifUnicastAddress *>(address));
}
ThreadError otIp6RemoveUnicastAddress(otInstance *aInstance, const otIp6Address *address)
{
return aInstance->mThreadNetif.RemoveExternalUnicastAddress(*static_cast<const Ip6::Address *>(address));
}
const otNetifMulticastAddress *otIp6GetMulticastAddresses(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetMulticastAddresses();
}
ThreadError otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.SubscribeExternalMulticast(*static_cast<const Ip6::Address *>(aAddress));
}
ThreadError otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.UnsubscribeExternalMulticast(*static_cast<const Ip6::Address *>(aAddress));
}
bool otIp6IsMulticastPromiscuousEnabled(otInstance *aInstance)
{
return aInstance->mThreadNetif.IsMulticastPromiscuousEnabled();
}
void otIp6SetMulticastPromiscuousEnabled(otInstance *aInstance, bool aEnabled)
{
aInstance->mThreadNetif.SetMulticastPromiscuous(aEnabled);
}
void otIp6SlaacUpdate(otInstance *aInstance, otNetifAddress *aAddresses, uint32_t aNumAddresses,
otIp6SlaacIidCreate aIidCreate, void *aContext)
{
Utils::Slaac::UpdateAddresses(aInstance, aAddresses, aNumAddresses, aIidCreate, aContext);
}
ThreadError otIp6CreateRandomIid(otInstance *aInstance, otNetifAddress *aAddress, void *aContext)
{
return Utils::Slaac::CreateRandomIid(aInstance, aAddress, aContext);
}
ThreadError otIp6CreateMacIid(otInstance *aInstance, otNetifAddress *aAddress, void *)
{
memcpy(&aAddress->mAddress.mFields.m8[OT_IP6_ADDRESS_SIZE - OT_IP6_IID_SIZE],
aInstance->mThreadNetif.GetMac().GetExtAddress(), OT_IP6_IID_SIZE);
aAddress->mAddress.mFields.m8[OT_IP6_ADDRESS_SIZE - OT_IP6_IID_SIZE] ^= 0x02;
return kThreadError_None;
}
ThreadError otIp6CreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress *aAddress, void *aContext)
{
return static_cast<Utils::SemanticallyOpaqueIidGenerator *>(aContext)->CreateIid(aInstance, aAddress);
}
void otIp6SetReceiveCallback(otInstance *aInstance, otIp6ReceiveCallback aCallback, void *aCallbackContext)
{
aInstance->mIp6.SetReceiveDatagramCallback(aCallback, aCallbackContext);
}
bool otIp6IsReceiveFilterEnabled(otInstance *aInstance)
{
return aInstance->mIp6.IsReceiveIp6FilterEnabled();
}
void otIp6SetReceiveFilterEnabled(otInstance *aInstance, bool aEnabled)
{
aInstance->mIp6.SetReceiveIp6FilterEnabled(aEnabled);
}
ThreadError otIp6Send(otInstance *aInstance, otMessage aMessage)
{
ThreadError error;
otLogFuncEntry();
error = aInstance->mIp6.HandleDatagram(*static_cast<Message *>(aMessage), NULL,
aInstance->mThreadNetif.GetInterfaceId(), NULL, true);
otLogFuncExitErr(error);
return error;
}
otMessage otIp6NewMessage(otInstance *aInstance, bool aLinkSecurityEnabled)
{
Message *message = aInstance->mIp6.mMessagePool.New(Message::kTypeIp6, 0);
if (message)
{
message->SetLinkSecurityEnabled(aLinkSecurityEnabled);
}
return message;
}
ThreadError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort)
{
return aInstance->mThreadNetif.GetIp6Filter().AddUnsecurePort(aPort);
}
ThreadError otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort)
{
return aInstance->mThreadNetif.GetIp6Filter().RemoveUnsecurePort(aPort);
}
const uint16_t *otIp6GetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries)
{
return aInstance->mThreadNetif.GetIp6Filter().GetUnsecurePorts(*aNumEntries);
}
bool otIp6IsAddressEqual(const otIp6Address *a, const otIp6Address *b)
{
return *static_cast<const Ip6::Address *>(a) == *static_cast<const Ip6::Address *>(b);
}
ThreadError otIp6AddressFromString(const char *str, otIp6Address *address)
{
return static_cast<Ip6::Address *>(address)->FromString(str);
}
uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond)
{
uint8_t rval;
VerifyOrExit(aFirst != NULL && aSecond != NULL, rval = 0);
rval = static_cast<const Ip6::Address *>(aFirst)->PrefixMatch(*static_cast<const Ip6::Address *>(aSecond));
exit:
return rval;
}
#ifdef __cplusplus
} // extern "C"
#endif
+2 -2
View File
@@ -113,7 +113,7 @@ void Dhcp6Client::UpdateAddresses(otInstance *aInstance, otDhcpAddress *aAddress
if (!found)
{
otRemoveUnicastAddress(aInstance, &(address->mAddress.mAddress));
otIp6RemoveUnicastAddress(aInstance, &(address->mAddress.mAddress));
RemoveIdentityAssociation(config.mRloc16, config.mPrefix);
memset(address, 0, sizeof(*address));
}
@@ -688,7 +688,7 @@ ThreadError Dhcp6Client::ProcessIaAddress(Message &aMessage, uint16_t aOffset)
address->mValidLifetime = option.GetValidLifetime();
address->mAddress.mPreferred = address->mPreferredLifetime != 0;
address->mAddress.mValid = address->mValidLifetime != 0;
otAddUnicastAddress(mNetif.GetInstance(), &address->mAddress);
otIp6AddUnicastAddress(mNetif.GetInstance(), &address->mAddress);
break;
}
}
+2 -2
View File
@@ -113,7 +113,7 @@ uint16_t Ip6::ComputePseudoheaderChecksum(const Address &src, const Address &dst
return checksum;
}
void Ip6::SetReceiveDatagramCallback(otReceiveIp6DatagramCallback aCallback, void *aCallbackContext)
void Ip6::SetReceiveDatagramCallback(otIp6ReceiveCallback aCallback, void *aCallbackContext)
{
mReceiveIp6DatagramCallback = aCallback;
mReceiveIp6DatagramCallbackContext = aCallbackContext;
@@ -696,7 +696,7 @@ ThreadError Ip6::HandleDatagram(Message &message, Netif *netif, int8_t interface
{
receive = true;
}
else if (netif->IsMulticastPromiscuousModeEnabled())
else if (netif->IsMulticastPromiscuousEnabled())
{
multicastPromiscuous = true;
}
+3 -3
View File
@@ -36,7 +36,7 @@
#include <stddef.h>
#include <openthread-ip6.h>
#include "openthread/ip6.h"
#include "openthread/udp.h"
#include <common/encoding.hpp>
@@ -218,7 +218,7 @@ public:
* @sa SetReceiveIp6FilterEnabled
*
*/
void SetReceiveDatagramCallback(otReceiveIp6DatagramCallback aCallback, void *aCallbackContext);
void SetReceiveDatagramCallback(otIp6ReceiveCallback aCallback, void *aCallbackContext);
/**
* This method indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
@@ -377,7 +377,7 @@ private:
PriorityQueue mSendQueue;
Tasklet mSendQueueTask;
otReceiveIp6DatagramCallback mReceiveIp6DatagramCallback;
otIp6ReceiveCallback mReceiveIp6DatagramCallback;
void *mReceiveIp6DatagramCallbackContext;
bool mIsReceiveIp6FilterEnabled;
+5 -10
View File
@@ -47,7 +47,7 @@ Netif::Netif(Ip6 &aIp6, int8_t aInterfaceId):
mMulticastAddresses(NULL),
mInterfaceId(aInterfaceId),
mAllRoutersSubscribed(false),
mMulticastPromiscuousMode(false),
mMulticastPromiscuous(false),
mStateChangedTask(aIp6.mTaskletScheduler, &Netif::HandleStateChangedTask, this),
mNext(NULL),
mStateChangedFlags(0)
@@ -305,19 +305,14 @@ void Netif::UnsubscribeAllExternalMulticastAddresses(void)
}
}
bool Netif::IsMulticastPromiscuousModeEnabled(void)
bool Netif::IsMulticastPromiscuousEnabled(void)
{
return mMulticastPromiscuousMode;
return mMulticastPromiscuous;
}
void Netif::EnableMulticastPromiscuousMode(void)
void Netif::SetMulticastPromiscuous(bool aEnabled)
{
mMulticastPromiscuousMode = true;
}
void Netif::DisableMulticastPromiscuousMode(void)
{
mMulticastPromiscuousMode = false;
mMulticastPromiscuous = aEnabled;
}
const NetifUnicastAddress *Netif::GetUnicastAddresses() const
+4 -8
View File
@@ -447,19 +447,15 @@ public:
* @retval TRUE If the multicast promiscuous mode is enabled.
* @retval FALSE If the multicast promiscuous mode is disabled.
*/
bool IsMulticastPromiscuousModeEnabled(void);
bool IsMulticastPromiscuousEnabled(void);
/**
* This method enables multicast promiscuous mode on the network interface.
*
*/
void EnableMulticastPromiscuousMode(void);
/**
* This method disables multicast promiscuous mode on the network interface.
* @param[in] aEnabled TRUE if Multicast Promiscuous mode is enabled, FALSE otherwise.
*
*/
void DisableMulticastPromiscuousMode(void);
void SetMulticastPromiscuous(bool aEnabled);
/**
* This method registers a network interface callback.
@@ -545,7 +541,7 @@ private:
NetifMulticastAddress *mMulticastAddresses;
int8_t mInterfaceId;
bool mAllRoutersSubscribed;
bool mMulticastPromiscuousMode;
bool mMulticastPromiscuous;
Tasklet mStateChangedTask;
Netif *mNext;
+1 -1
View File
@@ -59,7 +59,7 @@ typedef struct otInstance
Thread::Ip6::NetifCallback mNetifCallback[OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS];
otReceiveIp6DatagramCallback mReceiveIp6DatagramCallback;
otIp6ReceiveCallback mReceiveIp6DatagramCallback;
void *mReceiveIp6DatagramCallbackContext;
otHandleActiveScanResult mActiveScanCallback;
+3 -196
View File
@@ -57,7 +57,6 @@
#include <platform/misc.h>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
#include <utils/slaac_address.hpp>
#include <openthread-instance.h>
#include <coap/coap_server.hpp>
@@ -468,21 +467,6 @@ ThreadError otSendServerData(otInstance *aInstance)
return aInstance->mThreadNetif.GetNetworkDataLocal().SendServerDataNotification();
}
ThreadError otAddUnsecurePort(otInstance *aInstance, uint16_t aPort)
{
return aInstance->mThreadNetif.GetIp6Filter().AddUnsecurePort(aPort);
}
ThreadError otRemoveUnsecurePort(otInstance *aInstance, uint16_t aPort)
{
return aInstance->mThreadNetif.GetIp6Filter().RemoveUnsecurePort(aPort);
}
const uint16_t *otGetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries)
{
return aInstance->mThreadNetif.GetIp6Filter().GetUnsecurePorts(*aNumEntries);
}
uint32_t otGetContextIdReuseDelay(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetNetworkDataLeader().GetContextIdReuseDelay();
@@ -951,86 +935,6 @@ const otMacCounters *otGetMacCounters(otInstance *aInstance)
return &aInstance->mThreadNetif.GetMac().GetCounters();
}
bool otIsIp6AddressEqual(const otIp6Address *a, const otIp6Address *b)
{
return *static_cast<const Ip6::Address *>(a) == *static_cast<const Ip6::Address *>(b);
}
ThreadError otIp6AddressFromString(const char *str, otIp6Address *address)
{
return static_cast<Ip6::Address *>(address)->FromString(str);
}
const otNetifAddress *otGetUnicastAddresses(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetUnicastAddresses();
}
ThreadError otAddUnicastAddress(otInstance *aInstance, const otNetifAddress *address)
{
return aInstance->mThreadNetif.AddExternalUnicastAddress(*static_cast<const Ip6::NetifUnicastAddress *>(address));
}
ThreadError otRemoveUnicastAddress(otInstance *aInstance, const otIp6Address *address)
{
return aInstance->mThreadNetif.RemoveExternalUnicastAddress(*static_cast<const Ip6::Address *>(address));
}
const otNetifMulticastAddress *otGetMulticastAddresses(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetMulticastAddresses();
}
ThreadError otSubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.SubscribeExternalMulticast(*static_cast<const Ip6::Address *>(aAddress));
}
ThreadError otUnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.UnsubscribeExternalMulticast(*static_cast<const Ip6::Address *>(aAddress));
}
bool otIsMulticastPromiscuousModeEnabled(otInstance *aInstance)
{
return aInstance->mThreadNetif.IsMulticastPromiscuousModeEnabled();
}
void otEnableMulticastPromiscuousMode(otInstance *aInstance)
{
aInstance->mThreadNetif.EnableMulticastPromiscuousMode();
}
void otDisableMulticastPromiscuousMode(otInstance *aInstance)
{
aInstance->mThreadNetif.DisableMulticastPromiscuousMode();
}
void otSlaacUpdate(otInstance *aInstance, otNetifAddress *aAddresses, uint32_t aNumAddresses,
otSlaacIidCreate aIidCreate, void *aContext)
{
Utils::Slaac::UpdateAddresses(aInstance, aAddresses, aNumAddresses, aIidCreate, aContext);
}
ThreadError otCreateRandomIid(otInstance *aInstance, otNetifAddress *aAddress, void *aContext)
{
return Utils::Slaac::CreateRandomIid(aInstance, aAddress, aContext);
}
ThreadError otCreateMacIid(otInstance *aInstance, otNetifAddress *aAddress, void *)
{
memcpy(&aAddress->mAddress.mFields.m8[OT_IP6_ADDRESS_SIZE - OT_IP6_IID_SIZE],
aInstance->mThreadNetif.GetMac().GetExtAddress(), OT_IP6_IID_SIZE);
aAddress->mAddress.mFields.m8[OT_IP6_ADDRESS_SIZE - OT_IP6_IID_SIZE] ^= 0x02;
return kThreadError_None;
}
ThreadError otCreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress *aAddress, void *aContext)
{
return static_cast<Utils::SemanticallyOpaqueIidGenerator *>(aContext)->CreateIid(aInstance, aAddress);
}
ThreadError otSetStateChangedCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aCallbackContext)
{
ThreadError error = kThreadError_NoBufs;
@@ -1126,13 +1030,13 @@ void otInstancePostConstructor(otInstance *aInstance)
// If auto start is configured, do that now
if (otThreadGetAutoStart(aInstance))
{
if (otInterfaceUp(aInstance) == kThreadError_None)
if (otIp6SetEnabled(aInstance, true) == kThreadError_None)
{
// Only try to start Thread if we could bring up the interface
if (otThreadStart(aInstance) != kThreadError_None)
{
// Bring the interface down if Thread failed to start
otInterfaceDown(aInstance);
otIp6SetEnabled(aInstance, false);
}
}
}
@@ -1223,7 +1127,7 @@ void otInstanceFinalize(otInstance *aInstance)
// Ensure we are disabled
(void)otThreadStop(aInstance);
(void)otInterfaceDown(aInstance);
(void)otIp6SetEnabled(aInstance, false);
#ifndef OPENTHREAD_MULTIPLE_INSTANCE
sInstance = NULL;
@@ -1231,49 +1135,6 @@ void otInstanceFinalize(otInstance *aInstance)
otLogFuncExit();
}
ThreadError otInterfaceUp(otInstance *aInstance)
{
ThreadError error = kThreadError_None;
otLogFuncEntry();
#if OPENTHREAD_ENABLE_RAW_LINK_API
VerifyOrExit(!aInstance->mLinkRaw.IsEnabled(), error = kThreadError_InvalidState);
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
error = aInstance->mThreadNetif.Up();
#if OPENTHREAD_ENABLE_RAW_LINK_API
exit:
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
otLogFuncExitErr(error);
return error;
}
ThreadError otInterfaceDown(otInstance *aInstance)
{
ThreadError error = kThreadError_None;
otLogFuncEntry();
#if OPENTHREAD_ENABLE_RAW_LINK_API
VerifyOrExit(!aInstance->mLinkRaw.IsEnabled(), error = kThreadError_InvalidState);
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
error = aInstance->mThreadNetif.Down();
#if OPENTHREAD_ENABLE_RAW_LINK_API
exit:
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
otLogFuncExitErr(error);
return error;
}
bool otIsInterfaceUp(otInstance *aInstance)
{
return aInstance->mThreadNetif.IsUp();
}
ThreadError otThreadStart(otInstance *aInstance)
{
ThreadError error = kThreadError_None;
@@ -1429,48 +1290,6 @@ ThreadError otSendMacDataRequest(otInstance *aInstance)
return aInstance->mThreadNetif.GetMeshForwarder().SendMacDataRequest();
}
void otSetReceiveIp6DatagramCallback(otInstance *aInstance, otReceiveIp6DatagramCallback aCallback,
void *aCallbackContext)
{
aInstance->mIp6.SetReceiveDatagramCallback(aCallback, aCallbackContext);
}
bool otIsReceiveIp6DatagramFilterEnabled(otInstance *aInstance)
{
return aInstance->mIp6.IsReceiveIp6FilterEnabled();
}
void otSetReceiveIp6DatagramFilterEnabled(otInstance *aInstance, bool aEnabled)
{
aInstance->mIp6.SetReceiveIp6FilterEnabled(aEnabled);
}
ThreadError otSendIp6Datagram(otInstance *aInstance, otMessage aMessage)
{
ThreadError error;
otLogFuncEntry();
error = aInstance->mIp6.HandleDatagram(*static_cast<Message *>(aMessage), NULL,
aInstance->mThreadNetif.GetInterfaceId(), NULL, true);
otLogFuncExitErr(error);
return error;
}
otMessage otNewIp6Message(otInstance *aInstance, bool aLinkSecurityEnabled)
{
Message *message = aInstance->mIp6.mMessagePool.New(Message::kTypeIp6, 0);
if (message)
{
message->SetLinkSecurityEnabled(aLinkSecurityEnabled);
}
return message;
}
bool otIcmp6IsEchoEnabled(otInstance *aInstance)
{
return aInstance->mIp6.mIcmp.IsEchoEnabled();
@@ -1494,18 +1313,6 @@ ThreadError otIcmp6SendEchoRequest(otInstance *aInstance, otMessage aMessage,
aIdentifier);
}
uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond)
{
uint8_t rval;
VerifyOrExit(aFirst != NULL && aSecond != NULL, rval = 0);
rval = static_cast<const Ip6::Address *>(aFirst)->PrefixMatch(*static_cast<const Ip6::Address *>(aSecond));
exit:
return rval;
}
ThreadError otGetActiveDataset(otInstance *aInstance, otOperationalDataset *aDataset)
{
ThreadError error = kThreadError_None;
+3 -3
View File
@@ -87,7 +87,7 @@ void Slaac::UpdateAddresses(otInstance *aInstance, otNetifAddress *aAddresses, u
if (!found)
{
otRemoveUnicastAddress(aInstance, &address->mAddress);
otIp6RemoveUnicastAddress(aInstance, &address->mAddress);
address->mValid = false;
}
}
@@ -144,7 +144,7 @@ void Slaac::UpdateAddresses(otInstance *aInstance, otNetifAddress *aAddresses, u
CreateRandomIid(aInstance, address, aContext);
}
otAddUnicastAddress(aInstance, address);
otIp6AddUnicastAddress(aInstance, address);
break;
}
}
@@ -217,7 +217,7 @@ exit:
bool SemanticallyOpaqueIidGenerator::IsAddressRegistered(otInstance *aInstance, otNetifAddress *aCreatedAddress)
{
bool result = false;
const otNetifAddress *address = otGetUnicastAddresses(aInstance);
const otNetifAddress *address = otIp6GetUnicastAddresses(aInstance);
while (address != NULL)
{
+20 -27
View File
@@ -535,10 +535,10 @@ NcpBase::NcpBase(otInstance *aInstance):
sNcpContext = this;
otSetStateChangedCallback(mInstance, &NcpBase::HandleNetifStateChanged, this);
otSetReceiveIp6DatagramCallback(mInstance, &NcpBase::HandleDatagramFromStack, this);
otIp6SetReceiveCallback(mInstance, &NcpBase::HandleDatagramFromStack, this);
otSetLinkPcapCallback(mInstance, &NcpBase::HandleRawFrame, static_cast<void*>(this));
otIcmp6SetEchoEnabled(mInstance, false);
otSetReceiveIp6DatagramFilterEnabled(mInstance, true);
otIp6SetReceiveFilterEnabled(mInstance, true);
mUpdateChangedPropsTask.Post();
@@ -1525,7 +1525,7 @@ ThreadError NcpBase::CommandHandler_RESET(uint8_t header, unsigned int command,
// In such a case we fake it.
otThreadStop(mInstance);
otInterfaceDown(mInstance);
otIp6SetEnabled(mInstance, false);
errorCode = SendLastStatus(SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0, SPINEL_STATUS_RESET_SOFTWARE);
@@ -2066,7 +2066,7 @@ ThreadError NcpBase::GetPropertyHandler_NET_IF_UP(uint8_t header, spinel_prop_ke
SPINEL_CMD_PROP_VALUE_IS,
key,
SPINEL_DATATYPE_BOOL_S,
otIsInterfaceUp(mInstance)
otIp6IsEnabled(mInstance)
);
}
@@ -2529,7 +2529,7 @@ ThreadError NcpBase::GetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
{
ThreadError errorCode = kThreadError_None;
uint8_t num_entries = 0;
const uint16_t *ports = otGetUnsecurePorts(mInstance, &num_entries);
const uint16_t *ports = otIp6GetUnsecurePorts(mInstance, &num_entries);
SuccessOrExit(errorCode = OutboundFrameBegin());
SuccessOrExit(errorCode = OutboundFrameFeedPacked("Cii", header, SPINEL_CMD_PROP_VALUE_IS, key));
@@ -2723,7 +2723,7 @@ ThreadError NcpBase::GetPropertyHandler_IPV6_ADDRESS_TABLE(uint8_t header, spine
SuccessOrExit(errorCode = OutboundFrameBegin());
SuccessOrExit(errorCode = OutboundFrameFeedPacked("Cii", header, SPINEL_CMD_PROP_VALUE_IS, key));
for (const otNetifAddress *address = otGetUnicastAddresses(mInstance); address; address = address->mNext)
for (const otNetifAddress *address = otIp6GetUnicastAddresses(mInstance); address; address = address->mNext)
{
SuccessOrExit(errorCode = OutboundFrameFeedPacked(
@@ -2769,7 +2769,7 @@ ThreadError NcpBase::GetPropertyHandler_THREAD_RLOC16_DEBUG_PASSTHRU(uint8_t hea
SPINEL_CMD_PROP_VALUE_IS,
key,
SPINEL_DATATYPE_BOOL_S,
!otIsReceiveIp6DatagramFilterEnabled(mInstance)
!otIp6IsReceiveFilterEnabled(mInstance)
);
}
@@ -3985,14 +3985,7 @@ ThreadError NcpBase::SetPropertyHandler_NET_IF_UP(uint8_t header, spinel_prop_ke
if (parsedLength > 0)
{
if (value == false)
{
errorCode = otInterfaceDown(mInstance);
}
else
{
errorCode = otInterfaceUp(mInstance);
}
errorCode = otIp6SetEnabled(mInstance, value);
}
else
{
@@ -4337,7 +4330,7 @@ ThreadError NcpBase::SetPropertyHandler_STREAM_NET_INSECURE(uint8_t header, spin
unsigned int meta_len(0);
// STREAM_NET_INSECURE packets are not secured at layer 2.
otMessage message = otNewIp6Message(mInstance, false);
otMessage message = otIp6NewMessage(mInstance, false);
if (message == NULL)
{
@@ -4369,7 +4362,7 @@ ThreadError NcpBase::SetPropertyHandler_STREAM_NET_INSECURE(uint8_t header, spin
// Ensure the insecure message is forwarded using direct transmission.
otMessageSetDirectTransmission(message, true);
errorCode = otSendIp6Datagram(mInstance, message);
errorCode = otIp6Send(mInstance, message);
}
else if (message)
{
@@ -4410,7 +4403,7 @@ ThreadError NcpBase::SetPropertyHandler_STREAM_NET(uint8_t header, spinel_prop_k
unsigned int meta_len(0);
// STREAM_NET requires layer 2 security.
otMessage message = otNewIp6Message(mInstance, true);
otMessage message = otIp6NewMessage(mInstance, true);
if (message == NULL)
{
@@ -4439,7 +4432,7 @@ ThreadError NcpBase::SetPropertyHandler_STREAM_NET(uint8_t header, spinel_prop_k
if (errorCode == kThreadError_None)
{
errorCode = otSendIp6Datagram(mInstance, message);
errorCode = otIp6Send(mInstance, message);
}
else if (message)
{
@@ -4542,7 +4535,7 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_RLOC16_DEBUG_PASSTHRU(uint8_t hea
if (parsedLength > 0)
{
// Note reverse logic: passthru enabled = filter disabled
otSetReceiveIp6DatagramFilterEnabled(mInstance, !isEnabled);
otIp6SetReceiveFilterEnabled(mInstance, !isEnabled);
errorCode = HandleCommandPropertyGet(header, key);
}
@@ -4559,14 +4552,14 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
{
ThreadError errorCode = kThreadError_None;
uint8_t num_entries = 0;
const uint16_t *ports = otGetUnsecurePorts(mInstance, &num_entries);
const uint16_t *ports = otIp6GetUnsecurePorts(mInstance, &num_entries);
spinel_ssize_t parsedLength = 1;
int ports_changed = 0;
// First, we need to remove all of the current assisting ports.
for (; num_entries != 0; ports++, num_entries--)
{
errorCode = otRemoveUnsecurePort(mInstance, *ports);
errorCode = otIp6RemoveUnsecurePort(mInstance, *ports);
if (errorCode != kThreadError_None)
{
@@ -4592,7 +4585,7 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
if (parsedLength > 0)
{
errorCode = otAddUnsecurePort(mInstance, port);
errorCode = otIp6AddUnsecurePort(mInstance, port);
}
else
{
@@ -5649,7 +5642,7 @@ ThreadError NcpBase::InsertPropertyHandler_IPV6_ADDRESS_TABLE(uint8_t header, sp
netif_addr.mPreferred = preferred_lifetime != 0;
netif_addr.mValid = valid_lifetime != 0;
errorCode = otAddUnicastAddress(mInstance, &netif_addr);
errorCode = otIp6AddUnicastAddress(mInstance, &netif_addr);
VerifyOrExit(errorCode == kThreadError_None,
errorStatus = ThreadErrorToSpinelStatus(errorCode));
@@ -5827,7 +5820,7 @@ ThreadError NcpBase::InsertPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header
if (parsedLength > 0)
{
errorCode = otAddUnsecurePort(mInstance, port);
errorCode = otIp6AddUnsecurePort(mInstance, port);
if (errorCode == kThreadError_None)
{
@@ -6021,7 +6014,7 @@ ThreadError NcpBase::RemovePropertyHandler_IPV6_ADDRESS_TABLE(uint8_t header, sp
if (parsedLength > 0)
{
errorCode = otRemoveUnicastAddress(mInstance, addr_ptr);
errorCode = otIp6RemoveUnicastAddress(mInstance, addr_ptr);
if (errorCode == kThreadError_None)
{
@@ -6166,7 +6159,7 @@ ThreadError NcpBase::RemovePropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header
if (parsedLength > 0)
{
errorCode = otRemoveUnsecurePort(mInstance, port);
errorCode = otIp6RemoveUnsecurePort(mInstance, port);
if (errorCode == kThreadError_None)
{
+1 -1
View File
@@ -40,8 +40,8 @@
#endif
#include <openthread-types.h>
#include "openthread/ip6.h"
#include "openthread/message.h"
#include <openthread-ip6.h>
#include <common/tasklet.hpp>
#include <ncp/ncp.h>
#include <ncp/ncp_buffer.hpp>
+1 -1
View File
@@ -131,7 +131,7 @@ void TestFuzz(uint32_t aSeconds)
// Start the Thread network
otSetPanId(aInstance, (otPanId)0xFACE);
otInterfaceUp(aInstance);
otIp6SetEnabled(aInstance, true);
otThreadStart(aInstance);
uint32_t countRecv = 0;
+3 -3
View File
@@ -29,8 +29,8 @@
#include "test_util.h"
#include <openthread.h>
#include "openthread/ip6.h"
#include "openthread/message.h"
#include <openthread-ip6.h>
#include <common/debug.hpp>
#include <common/message.hpp>
@@ -213,8 +213,8 @@ void TestMessageQueueOtApis(void)
for (int i = 0; i < kNumTestMessages; i++)
{
msg[i] = otNewIp6Message(instance, true);
VerifyOrQuit(msg[i] != NULL, "otNewIp6Message() failed.\n");
msg[i] = otIp6NewMessage(instance, true);
VerifyOrQuit(msg[i] != NULL, "otIp6NewMessage() failed.\n");
}
otMessageQueueInit(&queue);