mirror of
https://github.com/espressif/openthread.git
synced 2026-08-25 19:59:51 +00:00
IPv6 API cleanup.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user