From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Sun, 31 Oct 2021 09:58:17 +0000 (+0000) Subject: get IPvX family when creating each clock record. X-Git-Tag: 1.2~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e02deec657ac6547c822049c9624198b2e0676f;p=thirdparty%2Fnqptp.git get IPvX family when creating each clock record. --- diff --git a/nqptp-clock-sources.c b/nqptp-clock-sources.c index 4354c15..9128c67 100644 --- a/nqptp-clock-sources.c +++ b/nqptp-clock-sources.c @@ -26,10 +26,11 @@ #include #include #include +#include +#include #ifdef CONFIG_FOR_FREEBSD #include -#include #endif #ifndef FIELD_SIZEOF @@ -72,14 +73,12 @@ int create_clock_source_record(char *sender_string, if (found == 1) { int family = 0; - int ret; - // check its ipv4/6 family + + // check its ipv4/6 family -- derived froom https://stackoverflow.com/a/3736377, with thanks. struct addrinfo hint, *res = NULL; memset(&hint, '\0', sizeof hint); hint.ai_family = PF_UNSPEC; hint.ai_flags = AI_NUMERICHOST; - - ret = getaddrinfo(sender_string, NULL, &hint, &res); if (getaddrinfo(sender_string, NULL, &hint, &res) == 0) { family = res->ai_family; freeaddrinfo(res); @@ -90,7 +89,7 @@ int create_clock_source_record(char *sender_string, clocks_private_info[i].family = family; clocks_private_info[i].vacant_samples = MAX_TIMING_SAMPLES; clocks_private_info[i].in_use = 1; - debug(1, "create record for ip: %s, family: %d.", &clocks_private_info[i].ip, clocks_private_info[i].family); + debug(1, "create record for ip: %s, family: %s.", &clocks_private_info[i].ip, clocks_private_info[i].family == AF_INET6 ? "IPv6" : "IPv4"); } else { die("cannot getaddrinfo for ip: %s.", &clocks_private_info[i].ip); }