conf: add directives to specify interfaces for binding sockets

Add binddevice, bindacqdevice, and bindcmddevice directive to specify
the interface for binding the NTP server, NTP client, and command socket
respectively.
This commit is contained in:
Miroslav Lichvar
2020-06-30 12:27:10 +02:00
parent 4ef944b734
commit c4a2550518
6 changed files with 96 additions and 12 deletions

View File

@@ -157,8 +157,8 @@ static void read_from_cmd_socket(int sock_fd, int event, void *anything);
static int
open_socket(int family)
{
const char *local_path, *iface;
IPSockAddr local_addr;
const char *local_path;
int sock_fd, port;
switch (family) {
@@ -173,7 +173,9 @@ open_socket(int family)
SCK_GetLoopbackIPAddress(family, &local_addr.ip_addr);
local_addr.port = port;
sock_fd = SCK_OpenUdpSocket(NULL, &local_addr, NULL, SCK_FLAG_RX_DEST_ADDR);
iface = CNF_GetBindCommandInterface();
sock_fd = SCK_OpenUdpSocket(NULL, &local_addr, iface, SCK_FLAG_RX_DEST_ADDR);
if (sock_fd < 0) {
LOG(LOGS_ERR, "Could not open command socket on %s",
UTI_IPSockAddrToString(&local_addr));