mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 14:41:28 +00:00
Switch from inet_pton() to getnameinfo() for portability
Windows XP is supported again
This commit is contained in:
parent
7fd8f9854b
commit
540d3795a9
|
@ -9,7 +9,7 @@ Extra README file for Win32 related stuff
|
||||||
|
|
||||||
== Running iodine on Windows:
|
== 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
|
1. Install the TAP32 driver
|
||||||
http://openvpn.net/index.php/open-source/downloads.html
|
http://openvpn.net/index.php/open-source/downloads.html
|
||||||
|
|
|
@ -120,17 +120,16 @@ format_addr(struct sockaddr_storage *sockaddr, int sockaddr_len)
|
||||||
|
|
||||||
memset(dst, 0, sizeof(dst));
|
memset(dst, 0, sizeof(dst));
|
||||||
if (sockaddr->ss_family == AF_INET && sockaddr_len >= sizeof(struct sockaddr_in)) {
|
if (sockaddr->ss_family == AF_INET && sockaddr_len >= sizeof(struct sockaddr_in)) {
|
||||||
struct sockaddr_in *addr = (struct sockaddr_in *) sockaddr;
|
getnameinfo((struct sockaddr *)sockaddr, sockaddr_len, dst, sizeof(dst) - 1, NULL, 0, NI_NUMERICHOST);
|
||||||
inet_ntop(addr->sin_family, &addr->sin_addr, dst, sizeof(dst) - 1);
|
|
||||||
} else if (sockaddr->ss_family == AF_INET6 && sockaddr_len >= sizeof(struct sockaddr_in6)) {
|
} else if (sockaddr->ss_family == AF_INET6 && sockaddr_len >= sizeof(struct sockaddr_in6)) {
|
||||||
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) sockaddr;
|
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) sockaddr;
|
||||||
if (IN6_IS_ADDR_V4MAPPED(&addr->sin6_addr)) {
|
if (IN6_IS_ADDR_V4MAPPED(&addr->sin6_addr)) {
|
||||||
struct in_addr ia;
|
struct in_addr ia;
|
||||||
/* Get mapped v4 addr from last 32bit field */
|
/* Get mapped v4 addr from last 32bit field */
|
||||||
memcpy(&ia.s_addr, &addr->sin6_addr.s6_addr[12], sizeof(ia));
|
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 {
|
} 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 {
|
} else {
|
||||||
dst[0] = '?';
|
dst[0] = '?';
|
||||||
|
|
|
@ -26,6 +26,9 @@ link)
|
||||||
;;
|
;;
|
||||||
cflags)
|
cflags)
|
||||||
case $1 in
|
case $1 in
|
||||||
|
windows32)
|
||||||
|
echo '-DWINVER=0x0501';
|
||||||
|
;;
|
||||||
BeOS)
|
BeOS)
|
||||||
echo '-Dsocklen_t=int';
|
echo '-Dsocklen_t=int';
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -17,15 +17,6 @@
|
||||||
#ifndef __FIX_WINDOWS_H__
|
#ifndef __FIX_WINDOWS_H__
|
||||||
#define __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;
|
typedef unsigned int in_addr_t;
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
Loading…
Reference in a new issue