mirror of
https://github.com/espressif/openthread.git
synced 2026-09-06 17:20:09 +00:00
Add --enable-border-router configure option (#1834)
* Use `OPENTHREAD_ENABLE_BORDER_ROUTER` feature flag to wrap Border Router related features * MTD devices could also act as a Border Router
This commit is contained in:
@@ -1806,16 +1806,51 @@ otThreadSetNetworkName(
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otNetDataGetNextPrefixInfo(
|
||||
otNetDataGetNextOnMeshPrefix(
|
||||
_In_ otInstance *aInstance,
|
||||
bool _aLocal,
|
||||
_Inout_ otNetworkDataIterator *aIterator,
|
||||
_Out_ otBorderRouterConfig *aConfig
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr || aConfig == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
|
||||
BOOLEAN aLocal = _aLocal ? TRUE : FALSE;
|
||||
BOOLEAN aLocal = FALSE;
|
||||
PackedBuffer3<GUID,BOOLEAN,otNetworkDataIterator> InBuffer(aInstance->InterfaceGuid, aLocal, *aIterator);
|
||||
BYTE OutBuffer[sizeof(uint8_t) + sizeof(otBorderRouterConfig)];
|
||||
|
||||
otError aError =
|
||||
DwordToThreadError(
|
||||
SendIOCTL(
|
||||
aInstance->ApiHandle,
|
||||
IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX,
|
||||
&InBuffer, sizeof(InBuffer),
|
||||
OutBuffer, sizeof(OutBuffer)));
|
||||
|
||||
if (aError == OT_ERROR_NONE)
|
||||
{
|
||||
memcpy(aIterator, OutBuffer, sizeof(uint8_t));
|
||||
memcpy(aConfig, OutBuffer + sizeof(uint8_t), sizeof(otBorderRouterConfig));
|
||||
}
|
||||
else
|
||||
{
|
||||
ZeroMemory(aConfig, sizeof(otBorderRouterConfig));
|
||||
}
|
||||
|
||||
return aError;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otBorderRouterGetNextOnMeshPrefix(
|
||||
_In_ otInstance *aInstance,
|
||||
_Inout_ otNetworkDataIterator *aIterator,
|
||||
_Out_ otBorderRouterConfig *aConfig
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr || aConfig == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
|
||||
BOOLEAN aLocal = TRUE;
|
||||
PackedBuffer3<GUID,BOOLEAN,otNetworkDataIterator> InBuffer(aInstance->InterfaceGuid, aLocal, *aIterator);
|
||||
BYTE OutBuffer[sizeof(uint8_t) + sizeof(otBorderRouterConfig)];
|
||||
|
||||
@@ -2467,7 +2502,7 @@ otThreadSetJoinerUdpPort(
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otNetDataAddPrefixInfo(
|
||||
otBorderRouterAddOnMeshPrefix(
|
||||
_In_ otInstance *aInstance,
|
||||
const otBorderRouterConfig *aConfig
|
||||
)
|
||||
@@ -2479,7 +2514,7 @@ otNetDataAddPrefixInfo(
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otNetDataRemovePrefixInfo(
|
||||
otBorderRouterRemoveOnMeshPrefix(
|
||||
_In_ otInstance *aInstance,
|
||||
const otIp6Prefix *aPrefix
|
||||
)
|
||||
@@ -2491,7 +2526,7 @@ otNetDataRemovePrefixInfo(
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otNetDataAddRoute(
|
||||
otBorderRouterAddRoute(
|
||||
_In_ otInstance *aInstance,
|
||||
const otExternalRouteConfig *aConfig
|
||||
)
|
||||
@@ -2503,7 +2538,7 @@ otNetDataAddRoute(
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otNetDataRemoveRoute(
|
||||
otBorderRouterRemoveRoute(
|
||||
_In_ otInstance *aInstance,
|
||||
const otIp6Prefix *aPrefix
|
||||
)
|
||||
@@ -2515,7 +2550,7 @@ otNetDataRemoveRoute(
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otNetDataRegister(
|
||||
otBorderRouterRegister(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define OTAPI EXTERN_C __declspec(dllexport)
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/border_router.h>
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#include <openthread/thread_ftd.h>
|
||||
#include <openthread/commissioner.h>
|
||||
|
||||
@@ -2586,7 +2586,7 @@ otLwfIoCtl_otAddBorderRouter(
|
||||
|
||||
if (InBufferLength >= sizeof(otBorderRouterConfig))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otNetDataAddPrefixInfo(pFilter->otCtx, (otBorderRouterConfig*)InBuffer));
|
||||
status = ThreadErrorToNtstatus(otBorderRouterAddOnMeshPrefix(pFilter->otCtx, (otBorderRouterConfig*)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -2667,7 +2667,7 @@ otLwfIoCtl_otRemoveBorderRouter(
|
||||
|
||||
if (InBufferLength >= sizeof(otIp6Prefix))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otNetDataRemovePrefixInfo(pFilter->otCtx, (otIp6Prefix*)InBuffer));
|
||||
status = ThreadErrorToNtstatus(otBorderRouterRemoveOnMeshPrefix(pFilter->otCtx, (otIp6Prefix*)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -2730,7 +2730,7 @@ otLwfIoCtl_otAddExternalRoute(
|
||||
|
||||
if (InBufferLength >= sizeof(otExternalRouteConfig))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otNetDataAddRoute(pFilter->otCtx, (otExternalRouteConfig*)InBuffer));
|
||||
status = ThreadErrorToNtstatus(otBorderRouterAddRoute(pFilter->otCtx, (otExternalRouteConfig*)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -2802,7 +2802,7 @@ otLwfIoCtl_otRemoveExternalRoute(
|
||||
|
||||
if (InBufferLength >= sizeof(otIp6Prefix))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otNetDataRemoveRoute(pFilter->otCtx, (otIp6Prefix*)InBuffer));
|
||||
status = ThreadErrorToNtstatus(otBorderRouterRemoveRoute(pFilter->otCtx, (otIp6Prefix*)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -2865,7 +2865,7 @@ otLwfIoCtl_otSendServerData(
|
||||
UNREFERENCED_PARAMETER(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
|
||||
status = ThreadErrorToNtstatus(otNetDataRegister(pFilter->otCtx));
|
||||
status = ThreadErrorToNtstatus(otBorderRouterRegister(pFilter->otCtx));
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -4804,13 +4804,24 @@ otLwfIoCtl_otNextOnMeshPrefix(
|
||||
BOOLEAN aLocal = *(BOOLEAN*)InBuffer;
|
||||
uint8_t aIterator = *(uint8_t*)(InBuffer + sizeof(BOOLEAN));
|
||||
otBorderRouterConfig* aConfig = (otBorderRouterConfig*)((PUCHAR)OutBuffer + sizeof(uint8_t));
|
||||
status = ThreadErrorToNtstatus(
|
||||
otNetDataGetNextPrefixInfo(
|
||||
pFilter->otCtx,
|
||||
aLocal,
|
||||
&aIterator,
|
||||
aConfig)
|
||||
);
|
||||
if (aLocal)
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otBorderRouterGetNextOnMeshPrefix(
|
||||
pFilter->otCtx,
|
||||
&aIterator,
|
||||
aConfig)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otNetDataGetNextOnMeshPrefix(
|
||||
pFilter->otCtx,
|
||||
&aIterator,
|
||||
aConfig)
|
||||
);
|
||||
}
|
||||
*OutBufferLength = sizeof(uint8_t) + sizeof(otBorderRouterConfig);
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ RtlCopyBufferToMdl(
|
||||
#include <openthread-windows-config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/border_router.h>
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#include <openthread/thread_ftd.h>
|
||||
#include <openthread/icmp6.h>
|
||||
|
||||
@@ -1610,7 +1610,7 @@ OTNODEAPI int32_t OTCALL otNodeAddPrefix(otNode* aNode, const char *aPrefix, con
|
||||
return OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
|
||||
auto result = otNetDataAddPrefixInfo(aNode->mInstance, &config);
|
||||
auto result = otBorderRouterAddOnMeshPrefix(aNode->mInstance, &config);
|
||||
otLogFuncExit();
|
||||
return result;
|
||||
}
|
||||
@@ -1623,7 +1623,7 @@ OTNODEAPI int32_t OTCALL otNodeRemovePrefix(otNode* aNode, const char *aPrefix)
|
||||
auto error = otNodeParsePrefix(aPrefix, &prefix);
|
||||
if (error != OT_ERROR_NONE) return error;
|
||||
|
||||
auto result = otNetDataRemovePrefixInfo(aNode->mInstance, &prefix);
|
||||
auto result = otBorderRouterRemoveOnMeshPrefix(aNode->mInstance, &prefix);
|
||||
otLogFuncExit();
|
||||
return result;
|
||||
}
|
||||
@@ -1653,7 +1653,7 @@ OTNODEAPI int32_t OTCALL otNodeAddRoute(otNode* aNode, const char *aPrefix, cons
|
||||
return OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
|
||||
auto result = otNetDataAddRoute(aNode->mInstance, &config);
|
||||
auto result = otBorderRouterAddRoute(aNode->mInstance, &config);
|
||||
otLogFuncExit();
|
||||
return result;
|
||||
}
|
||||
@@ -1666,7 +1666,7 @@ OTNODEAPI int32_t OTCALL otNodeRemoveRoute(otNode* aNode, const char *aPrefix)
|
||||
auto error = otNodeParsePrefix(aPrefix, &prefix);
|
||||
if (error != OT_ERROR_NONE) return error;
|
||||
|
||||
auto result = otNetDataRemoveRoute(aNode->mInstance, &prefix);
|
||||
auto result = otBorderRouterRemoveRoute(aNode->mInstance, &prefix);
|
||||
otLogFuncExit();
|
||||
return result;
|
||||
}
|
||||
@@ -1675,7 +1675,7 @@ OTNODEAPI int32_t OTCALL otNodeRegisterNetdata(otNode* aNode)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: registernetdata\r\n", aNode->mId);
|
||||
auto result = otNetDataRegister(aNode->mInstance);
|
||||
auto result = otBorderRouterRegister(aNode->mInstance);
|
||||
otLogFuncExit();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ using namespace std;
|
||||
#define OTNODEAPI EXTERN_C __declspec(dllexport)
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/border_router.h>
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#include <openthread/thread_ftd.h>
|
||||
#include <openthread/commissioner.h>
|
||||
|
||||
Reference in New Issue
Block a user