Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'win32_fixes' of ssh://github.com/mrash/fwknop into win3…

…2_fixes
  • Loading branch information...
commit 63fed301b82b8f92bc9a80fa7167743c2fd0cd54 2 parents 2c1a911 + c0c0941
@damienstuart damienstuart authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 client/utils.c
View
20 client/utils.c
@@ -212,7 +212,12 @@ resolve_dest_adr(const char *dns_str, struct addrinfo *hints, char *ip_str, size
int error; /* Function error return code */
struct addrinfo *result; /* Result of getaddrinfo() */
struct addrinfo *rp; /* Element of the linked list returned by getaddrinfo() */
+#if WIN32 && WINVER <= 0x0600
+ struct sockaddr_in *in;
+ char *win_ip;
+#else
struct sockaddr_in *sai_remote; /* Remote host information as a sockaddr_in structure */
+#endif
/* Try to resolve the host name */
error = getaddrinfo(dns_str, NULL, hints, &result);
@@ -226,11 +231,20 @@ resolve_dest_adr(const char *dns_str, struct addrinfo *hints, char *ip_str, size
/* Go through the linked list of addrinfo structures */
for (rp = result; rp != NULL; rp = rp->ai_next)
{
- sai_remote = (struct sockaddr_in *)get_in_addr((struct sockaddr *)(rp->ai_addr));
-
memset(ip_str, 0, ip_bufsize);
+#if WIN32 && WINVER <= 0x0600
+ /* On older Windows systems (anything before Vista?),
+ * we use inet_ntoa for now.
+ */
+ in = (struct sockaddr_in*)(rp->ai_addr);
+ win_ip = inet_ntoa(in->sin_addr);
+
+ if (win_ip != NULL && (strlcpy(ip_str, win_ip, ip_bufsize) > 0))
+#else
+ sai_remote = (struct sockaddr_in *)get_in_addr((struct sockaddr *)(rp->ai_addr));
if (inet_ntop(rp->ai_family, sai_remote, ip_str, ip_bufsize) != NULL)
- {
+#endif
+ {
error = 0;
break;
}
Please sign in to comment.
Something went wrong with that request. Please try again.