mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 09:29:51 +00:00
Add Dhcp6 Client/Server Support to Windows Driver (#1084)
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -59,12 +59,15 @@ RtlCopyBufferToMdl(
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openthread-windows-config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread.h>
|
||||
#include <openthread-ip6.h>
|
||||
#include <openthread-tasklet.h>
|
||||
#include <commissioning/commissioner.h>
|
||||
#include <commissioning/joiner.h>
|
||||
#include <dhcp6/dhcp6_server.h>
|
||||
#include <dhcp6/dhcp6_client.h>
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/logging.h>
|
||||
#include <platform/logging-windows.h>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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_
|
||||
@@ -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
|
||||
|
||||
+2
-1
@@ -46,6 +46,7 @@
|
||||
#include <openthread-diag.h>
|
||||
#include <commissioning/commissioner.h>
|
||||
#include <commissioning/joiner.h>
|
||||
#include <dhcp6/dhcp6_server.h>
|
||||
#include <dhcp6/dhcp6_client.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -1012,6 +1012,13 @@ ThreadError otRemoveUnicastAddress(otInstance *aInstance, const otIp6Address *ad
|
||||
return aInstance->mThreadNetif.RemoveExternalUnicastAddress(*static_cast<const Ip6::Address *>(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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user