ntp: allow online/offline state to be selected by connectability

Allow SRC_MAYBE_ONLINE to be specified for new NTP sources and
connectivity setting to select between SRC_ONLINE and SRC_OFFLINE
according to the result of the connect() system call, i.e. check whether
the client has a route to send its requests.
This commit is contained in:
Miroslav Lichvar
2018-05-24 15:17:53 +02:00
parent ce6b896948
commit 8b9021bf34
4 changed files with 27 additions and 1 deletions

View File

@@ -574,6 +574,23 @@ NIO_IsServerSocket(int sock_fd)
/* ================================================== */
int
NIO_IsServerConnectable(NTP_Remote_Address *remote_addr)
{
int sock_fd, r;
sock_fd = prepare_separate_client_socket(remote_addr->ip_addr.family);
if (sock_fd == INVALID_SOCK_FD)
return 0;
r = connect_socket(sock_fd, remote_addr);
close_socket(sock_fd);
return r;
}
/* ================================================== */
static void
process_message(struct msghdr *hdr, int length, int sock_fd)
{