mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 20:27:47 +00:00
[dns-sd] add DNS-SD server network interface binding configuration(#6838)
This commit allows DNS-SD server to configure the network interface to bind the UDP socket.
This commit is contained in:
@@ -273,6 +273,7 @@ do_build_otbr_docker()
|
||||
"-DOT_SRP_CLIENT=ON"
|
||||
"-DOT_TREL=OFF"
|
||||
"-DOTBR_DUA_ROUTING=ON"
|
||||
"-DCMAKE_CXX_FLAGS='-DOPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF=1'"
|
||||
)
|
||||
local otbr_docker_image=${OTBR_DOCKER_IMAGE:-otbr-ot12-backbone-ci}
|
||||
|
||||
|
||||
@@ -55,6 +55,16 @@
|
||||
#define OPENTHREAD_CONFIG_DNSSD_SERVER_PORT 53
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF
|
||||
*
|
||||
* Define to 1 to bind DNS-SD server to unspecified interface, 0 to bind to Thread interface.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF
|
||||
#define OPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DNSSD_QUERY_TIMEOUT
|
||||
*
|
||||
|
||||
@@ -69,7 +69,7 @@ Error Server::Start(void)
|
||||
VerifyOrExit(!IsRunning());
|
||||
|
||||
SuccessOrExit(error = mSocket.Open(&Server::HandleUdpReceive, this));
|
||||
SuccessOrExit(error = mSocket.Bind(kPort, OT_NETIF_UNSPECIFIED));
|
||||
SuccessOrExit(error = mSocket.Bind(kPort, kBindUnspecifiedNetif ? OT_NETIF_UNSPECIFIED : OT_NETIF_THREAD));
|
||||
|
||||
exit:
|
||||
otLogInfoDns("[server] started: %s", ErrorToString(error));
|
||||
|
||||
@@ -71,6 +71,8 @@ public:
|
||||
kDnsQueryResolveHost = OT_DNSSD_QUERY_TYPE_RESOLVE_HOST, ///< Service type resolve hostname.
|
||||
};
|
||||
|
||||
static constexpr uint16_t kPort = OPENTHREAD_CONFIG_DNSSD_SERVER_PORT; ///< The DNS-SD server port.
|
||||
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
@@ -224,7 +226,7 @@ private:
|
||||
uint16_t mHostNameOffset; // Offset of host name serialization into the response message.
|
||||
};
|
||||
|
||||
static constexpr uint16_t kPort = OPENTHREAD_CONFIG_DNSSD_SERVER_PORT;
|
||||
static constexpr bool kBindUnspecifiedNetif = OPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF;
|
||||
static constexpr uint8_t kProtocolLabelLength = 4;
|
||||
static constexpr uint8_t kSubTypeLabelLength = 4;
|
||||
static constexpr uint16_t kMaxConcurrentQueries = 32;
|
||||
|
||||
@@ -558,6 +558,9 @@ bool Udp::IsPortInUse(uint16_t aPort) const
|
||||
bool Udp::ShouldUsePlatformUdp(uint16_t aPort) const
|
||||
{
|
||||
return (aPort != Mle::kUdpPort && aPort != Tmf::kUdpPort
|
||||
#if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE && !OPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF
|
||||
&& aPort != Dns::ServiceDiscovery::Server::kPort
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
|
||||
&& aPort != Get<MeshCoP::BorderAgent>().GetUdpProxyPort()
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user