mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 14:17:47 +00:00
[posix] bind infra IF socket to specific interface (#6089)
This is for ensuring sending ICMP6 packets on only the specified infrastructure interface.
This commit is contained in:
@@ -231,6 +231,13 @@ void platformInfraIfInit(otInstance *aInstance, const char *aIfName)
|
||||
rval = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &kHopLimit, sizeof(kHopLimit));
|
||||
VerifyOrDie(rval == 0, OT_EXIT_ERROR_ERRNO);
|
||||
|
||||
#ifdef __linux__
|
||||
rval = setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, sInfraIfName, strlen(sInfraIfName));
|
||||
#else // __NetBSD__ || __FreeBSD__ || __APPLE__
|
||||
rval = setsockopt(sock, IPPROTO_IP, IP_BOUND_IF, &sInfraIfIndex, sizeof(sInfraIfIndex));
|
||||
#endif // __linux__
|
||||
VerifyOrDie(rval == 0, OT_EXIT_ERROR_ERRNO);
|
||||
|
||||
sInfraIfIcmp6Socket = sock;
|
||||
SuccessOrDie(InitLinkLocalAddress());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user