[posix-trel] allow using fixed TREL UDP port (#7646)

This commit adds the configuration
`OPENTHREAD_CONFIG_POSIX_TREL_UDP_PORT` to allow TREL to use a fixed
UDP port number on POSIX platform.
This commit is contained in:
Simon Lin
2022-05-01 19:18:34 -07:00
committed by GitHub
parent b0e532b138
commit 972ed8d793
2 changed files with 12 additions and 1 deletions
@@ -229,4 +229,15 @@
#error "OPENTHREAD_CONFIG_POSIX_TREL_USE_NETLINK_SOCKET was removed (no longer applicable with TREL over DNS-SD)."
#endif
/**
* @def OPENTHREAD_POSIX_CONFIG_TREL_UDP_PORT
*
* This setting configures the TREL UDP port number.
* Define as 0 to use an ephemeral port number.
*
*/
#ifndef OPENTHREAD_POSIX_CONFIG_TREL_UDP_PORT
#define OPENTHREAD_POSIX_CONFIG_TREL_UDP_PORT 0
#endif
#endif // OPENTHREAD_PLATFORM_CONFIG_H_
+1 -1
View File
@@ -137,7 +137,7 @@ static void PrepareSocket(uint16_t &aUdpPort)
memset(&sockAddr, 0, sizeof(sockAddr));
sockAddr.sin6_family = AF_INET6;
sockAddr.sin6_addr = in6addr_any;
sockAddr.sin6_port = 0;
sockAddr.sin6_port = OPENTHREAD_POSIX_CONFIG_TREL_UDP_PORT;
if (bind(sSocket, (struct sockaddr *)&sockAddr, sizeof(sockAddr)) == -1)
{