socket: add support for binding sockets to device

As a Linux-specific feature, allow sockets to be bound to a device using
the SO_BINDTODEVICE socket option. The CAP_NET_RAW capability is
required for setting the option.
This commit is contained in:
Miroslav Lichvar
2020-06-30 10:21:45 +02:00
parent 0f04baeb97
commit 4ef944b734
9 changed files with 45 additions and 20 deletions

View File

@@ -103,7 +103,7 @@ open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr
if (!client_only)
sock_flags |= SCK_FLAG_BROADCAST;
sock_fd = SCK_OpenUdpSocket(remote_addr, &local_addr, sock_flags);
sock_fd = SCK_OpenUdpSocket(remote_addr, &local_addr, NULL, sock_flags);
if (sock_fd < 0) {
if (!client_only)
LOG(LOGS_ERR, "Could not open NTP socket on %s", UTI_IPSockAddrToString(&local_addr));