From: Florian Forster Date: Wed, 1 Nov 2006 08:43:35 +0000 (+0100) Subject: ntpd plugin: Pass a `struct sockaddr' to `getnameinfo', rather than a `struct in_addr'. X-Git-Tag: collectd-3.10.2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8694f0e52bacc8899a349a8d01f88b3f14cf897b;p=collectd.git ntpd plugin: Pass a `struct sockaddr' to `getnameinfo', rather than a `struct in_addr'. Thanks to Lubos Stanek for pointing me in the right direction :) --- diff --git a/src/ntpd.c b/src/ntpd.c index fc76a245..d65d1ed9 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -897,8 +897,15 @@ static void ntpd_read (void) if (ptr->v6_flag) { - status = getnameinfo ((const struct sockaddr *) &ptr->srcadr6, - sizeof (ptr->srcadr6), + struct sockaddr_in6 sa; + + memset (&sa, 0, sizeof (sa)); + sa.sin6_family = AF_INET6; + sa.sin6_port = htons (123); + memcpy (&sa.sin6_addr, &ptr->srcadr6, sizeof (struct in6_addr)); + + status = getnameinfo ((const struct sockaddr *) &sa, + sizeof (sa), peername, sizeof (peername), NULL, 0, 0 /* no flags */); if (status != 0)