From c10b66b579cb8cb0f80ba5b9fa0f4be41f7e988e Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 13 Jul 2020 14:16:42 +0200 Subject: [PATCH] nts: follow bind*device settings for NTS-KE sockets Bind the server and client NTS-KE sockets to the specified device. --- nts_ke_client.c | 7 ++++--- nts_ke_server.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nts_ke_client.c b/nts_ke_client.c index 967e014..5b5441e 100644 --- a/nts_ke_client.c +++ b/nts_ke_client.c @@ -308,7 +308,7 @@ int NKC_Start(NKC_Instance inst) { IPSockAddr local_addr; - char label[512]; + char label[512], *iface; int sock_fd; assert(!NKC_IsActive(inst)); @@ -318,14 +318,15 @@ NKC_Start(NKC_Instance inst) return 0; } - /* Follow the bindacqaddress setting */ + /* Follow the bindacqaddress and bindacqdevice settings */ CNF_GetBindAcquisitionAddress(inst->address.ip_addr.family, &local_addr.ip_addr); if (local_addr.ip_addr.family != inst->address.ip_addr.family) SCK_GetAnyLocalIPAddress(inst->address.ip_addr.family, &local_addr.ip_addr); local_addr.port = 0; + iface = CNF_GetBindAcquisitionInterface(); - sock_fd = SCK_OpenTcpSocket(&inst->address, &local_addr, NULL, 0); + sock_fd = SCK_OpenTcpSocket(&inst->address, &local_addr, iface, 0); if (sock_fd < 0) return 0; diff --git a/nts_ke_server.c b/nts_ke_server.c index 2b94b9b..7dc6d70 100644 --- a/nts_ke_server.c +++ b/nts_ke_server.c @@ -256,19 +256,21 @@ static int open_socket(int family, int port) { IPSockAddr local_addr; + char *iface; int sock_fd; if (!SCK_IsIpFamilyEnabled(family)) return INVALID_SOCK_FD; CNF_GetBindAddress(family, &local_addr.ip_addr); + iface = CNF_GetBindNtpInterface(); if (local_addr.ip_addr.family != family) SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr); local_addr.port = port; - sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, NULL, 0); + sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, iface, 0); if (sock_fd < 0) { LOG(LOGS_ERR, "Could not open NTS-KE socket on %s", UTI_IPSockAddrToString(&local_addr)); return INVALID_SOCK_FD;