1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-21 20:46:06 +03:00

Switch from inet_pton() to getnameinfo() for portability

Windows XP is supported again
This commit is contained in:
Erik Ekman 2014-02-06 22:50:23 +01:00
parent 7fd8f9854b
commit 540d3795a9
4 changed files with 7 additions and 14 deletions

View File

@ -9,7 +9,7 @@ Extra README file for Win32 related stuff
== Running iodine on Windows:
0. After iodine 0.6, you need Windows Vista or newer to run.
0. After iodine 0.6, you need Windows XP or newer to run.
1. Install the TAP32 driver
http://openvpn.net/index.php/open-source/downloads.html

View File

@ -120,17 +120,16 @@ format_addr(struct sockaddr_storage *sockaddr, int sockaddr_len)
memset(dst, 0, sizeof(dst));
if (sockaddr->ss_family == AF_INET && sockaddr_len >= sizeof(struct sockaddr_in)) {
struct sockaddr_in *addr = (struct sockaddr_in *) sockaddr;
inet_ntop(addr->sin_family, &addr->sin_addr, dst, sizeof(dst) - 1);
getnameinfo((struct sockaddr *)sockaddr, sockaddr_len, dst, sizeof(dst) - 1, NULL, 0, NI_NUMERICHOST);
} else if (sockaddr->ss_family == AF_INET6 && sockaddr_len >= sizeof(struct sockaddr_in6)) {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) sockaddr;
if (IN6_IS_ADDR_V4MAPPED(&addr->sin6_addr)) {
struct in_addr ia;
/* Get mapped v4 addr from last 32bit field */
memcpy(&ia.s_addr, &addr->sin6_addr.s6_addr[12], sizeof(ia));
inet_ntop(AF_INET, &ia, dst, sizeof(dst) - 1);
strcpy(dst, inet_ntoa(ia));
} else {
inet_ntop(addr->sin6_family, &addr->sin6_addr, dst, sizeof(dst) - 1);
getnameinfo((struct sockaddr *)sockaddr, sockaddr_len, dst, sizeof(dst) - 1, NULL, 0, NI_NUMERICHOST);
}
} else {
dst[0] = '?';

View File

@ -26,6 +26,9 @@ link)
;;
cflags)
case $1 in
windows32)
echo '-DWINVER=0x0501';
;;
BeOS)
echo '-Dsocklen_t=int';
;;

View File

@ -17,15 +17,6 @@
#ifndef __FIX_WINDOWS_H__
#define __FIX_WINDOWS_H__
#include <w32api.h>
/* Need Vista or Later to get IPv6 support */
#undef WINVER
#undef _WIN32_WINDOWS
#undef _WIN32_WINNT
#define WINVER WindowsVista
#define _WIN32_WINDOWS WindowsVista
#define _WIN32_WINNT WindowsVista
typedef unsigned int in_addr_t;
#include <winsock2.h>