diff --git a/examples/drivers/windows/otLwf/filter.h b/examples/drivers/windows/otLwf/filter.h index 5c42ababa..6cbd43946 100644 --- a/examples/drivers/windows/otLwf/filter.h +++ b/examples/drivers/windows/otLwf/filter.h @@ -36,8 +36,13 @@ #define _FILT_H // The maximum allowed addresses an OpenThread interface -#define OT_MAX_ADDRESSES 10 -#define OT_MAX_AUTO_ADDRESSES (OT_MAX_ADDRESSES - 4) +#if (OPENTHREAD_ENABLE_DHCP6_CLIENT && OPENTHREAD_ENABLE_DHCP6_SERVER) +#define OT_MAX_ADDRESSES (4 + OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES + 2 * OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES) +#elif (OPENTHREAD_ENABLE_DHCP6_CLIENT || OPENTHREAD_ENABLE_DHCP6_SERVER) +#define OT_MAX_ADDRESSES (4 + OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES + OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES) +#else +#define OT_MAX_ADDRESSES (4 + OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES) +#endif #define OTLWF_ALLOC_TAG 'mFto' // otFm @@ -137,7 +142,10 @@ typedef struct _MS_FILTER IN6_ADDR otCachedAddr[OT_MAX_ADDRESSES]; ULONG otCachedAddrCount; IN6_ADDR otLinkLocalAddr; - otNetifAddress otAutoAddresses[OT_MAX_AUTO_ADDRESSES]; + otNetifAddress otAutoAddresses[OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES]; +#if OPENTHREAD_ENABLE_DHCP6_CLIENT + otNetifAddress otDhcpAddresses[OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES]; +#endif // OPENTHREAD_ENABLE_DHCP6_CLIENT union { diff --git a/examples/drivers/windows/otLwf/precomp.h b/examples/drivers/windows/otLwf/precomp.h index 7126b4ebe..4e10ac1ef 100644 --- a/examples/drivers/windows/otLwf/precomp.h +++ b/examples/drivers/windows/otLwf/precomp.h @@ -59,12 +59,15 @@ RtlCopyBufferToMdl( #include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include diff --git a/examples/drivers/windows/otLwf/thread.c b/examples/drivers/windows/otLwf/thread.c index 2fbb1c853..e6a1d9b02 100644 --- a/examples/drivers/windows/otLwf/thread.c +++ b/examples/drivers/windows/otLwf/thread.c @@ -378,6 +378,14 @@ void otLwfStateChangedCallback(uint32_t aFlags, _In_ void *aContext) { LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_THREAD_NETDATA_UPDATED", pFilter); otSlaacUpdate(pFilter->otCtx, pFilter->otAutoAddresses, ARRAYSIZE(pFilter->otAutoAddresses), otCreateRandomIid, NULL); + +#if OPENTHREAD_ENABLE_DHCP6_SERVER + otDhcp6ServerUpdate(pFilter->otCtx); +#endif // OPENTHREAD_ENABLE_DHCP6_SERVER + +#if OPENTHREAD_ENABLE_DHCP6_CLIENT + otDhcp6ClientUpdate(pFilter->otCtx, pFilter->otDhcpAddresses, ARRAYSIZE(pFilter->otDhcpAddresses), NULL); +#endif // OPENTHREAD_ENABLE_DHCP6_CLIENT } if ((aFlags & OT_IP6_ML_ADDR_CHANGED) != 0) diff --git a/include/dhcp6/Makefile.am b/include/dhcp6/Makefile.am index 73a2be700..f921db93d 100644 --- a/include/dhcp6/Makefile.am +++ b/include/dhcp6/Makefile.am @@ -30,6 +30,7 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am ot_dhcp6_headers = \ dhcp6_client.h \ + dhcp6_server.h \ $(NULL) ot_dhcp6dir = $(includedir)/dhcp6 diff --git a/include/dhcp6/dhcp6_server.h b/include/dhcp6/dhcp6_server.h new file mode 100644 index 000000000..c820cb520 --- /dev/null +++ b/include/dhcp6/dhcp6_server.h @@ -0,0 +1,66 @@ +/* + * 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 + * @brief + * This file includes the platform abstraction for the Thread DHCPv6 server. + */ + +#ifndef OPENTHREAD_DHCP6_SERVER_H_ +#define OPENTHREAD_DHCP6_SERVER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup core-dhcp6-server + * + * @{ + * + */ + +/** + * Update updates DHCP Agents and DHCP Alocs. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + */ +void otDhcp6ServerUpdate(otInstance *aInstance); + +/** + * @} + * + */ + +#ifdef __cplusplus +} // end of extern "C" +#endif + +#endif // OPENTHREAD_DHCP6_SERVER_H_ diff --git a/include/openthread-windows-config.h b/include/openthread-windows-config.h index f2dc0aa49..dfdc2256d 100644 --- a/include/openthread-windows-config.h +++ b/include/openthread-windows-config.h @@ -48,10 +48,10 @@ #define OPENTHREAD_ENABLE_JAM_DETECTION 0 /* Define to 1 to enable DHCPv6 Client. */ -#define OPENTHREAD_ENABLE_DHCP6_CLIENT 0 +#define OPENTHREAD_ENABLE_DHCP6_CLIENT 1 /* Define to 1 to enable DHCPv6 SERVER. */ -#define OPENTHREAD_ENABLE_DHCP6_SERVER 0 +#define OPENTHREAD_ENABLE_DHCP6_SERVER 1 /* Define to 1 to enable MAC whitelist/blacklist feature. */ #define OPENTHREAD_ENABLE_MAC_WHITELIST 1 diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index c7c031824..21686159f 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include "cli.hpp" @@ -2637,7 +2638,7 @@ void Interpreter::HandleNetifStateChanged(uint32_t aFlags) otSlaacUpdate(mInstance, mSlaacAddresses, sizeof(mSlaacAddresses) / sizeof(mSlaacAddresses[0]), otCreateRandomIid, NULL); #if OPENTHREAD_ENABLE_DHCP6_SERVER - mInstance->mThreadNetif.GetDhcp6Server().UpdateService(); + otDhcp6ServerUpdate(mInstance); #endif // OPENTHREAD_ENABLE_DHCP6_SERVER #if OPENTHREAD_ENABLE_DHCP6_CLIENT diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index f25728331..144b9e05b 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -1012,6 +1012,13 @@ ThreadError otRemoveUnicastAddress(otInstance *aInstance, const otIp6Address *ad return aInstance->mThreadNetif.RemoveExternalUnicastAddress(*static_cast(address)); } +#if OPENTHREAD_ENABLE_DHCP6_SERVER +void otDhcp6ServerUpdate(otInstance *aInstance) +{ + aInstance->mThreadNetif.GetDhcp6Server().UpdateService(); +} +#endif // OPENTHREAD_ENABLE_DHCP6_SERVER + #if OPENTHREAD_ENABLE_DHCP6_CLIENT void otDhcp6ClientUpdate(otInstance *aInstance, otNetifAddress *aAddresses, uint32_t aNumAddresses, void *aContext) {