mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-07 00:01:49 -04:00
Merge branch 'win-32bit'
Fixes some issues when building 32-bit Windows binaries. Mostly related to the call API. Introduces a Travis 32-bit Windows build variant.
This commit is contained in:
commit
4f31b3f724
@ -38,4 +38,6 @@ matrix:
|
||||
- compiler: gcc
|
||||
env: TEST=dist
|
||||
- compiler: gcc
|
||||
env: TEST=win MONOLITHIC=yes
|
||||
env: TEST=win64 MONOLITHIC=yes
|
||||
- compiler: gcc
|
||||
env: TEST=win32 MONOLITHIC=yes
|
||||
|
17
configure.ac
17
configure.ac
@ -459,12 +459,6 @@ AC_SEARCH_LIBS(socket, socket, [SOCKLIB=$LIBS],
|
||||
)
|
||||
AC_SUBST(SOCKLIB)
|
||||
|
||||
# FreeBSD has clock_gettime in libc, Linux needs librt
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS(clock_gettime, rt, [RTLIB=$LIBS])
|
||||
AC_CHECK_FUNCS(clock_gettime)
|
||||
AC_SUBST(RTLIB)
|
||||
|
||||
# Android has pthread_* functions in bionic (libc), others need libpthread
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS(pthread_create, pthread, [PTHREADLIB=$LIBS])
|
||||
@ -759,6 +753,17 @@ AC_COMPILE_IFELSE(
|
||||
[
|
||||
AC_MSG_RESULT([no])
|
||||
openssl_lib=crypto
|
||||
|
||||
# check for clock_gettime() on non-Windows only. Otherwise this
|
||||
# check might find clock_gettime() in libwinpthread, but we don't want
|
||||
# to link against it.
|
||||
saved_LIBS=$LIBS
|
||||
# FreeBSD has clock_gettime in libc, Linux needs librt
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS(clock_gettime, rt, [RTLIB=$LIBS])
|
||||
AC_CHECK_FUNCS(clock_gettime)
|
||||
AC_SUBST(RTLIB)
|
||||
LIBS=$saved_LIBS
|
||||
]
|
||||
)
|
||||
AC_SUBST(OPENSSL_LIB, [-l$openssl_lib])
|
||||
|
@ -51,8 +51,8 @@ all)
|
||||
libnm-glib-dev libnm-glib-vpn-dev libpcsclite-dev libpam0g-dev
|
||||
binutils-dev libunwind7-dev libjson0-dev"
|
||||
;;
|
||||
win)
|
||||
CONFIG="--host=x86_64-w64-mingw32 --disable-defaults --enable-svc --enable-ikev2
|
||||
win*)
|
||||
CONFIG="--disable-defaults --enable-svc --enable-ikev2
|
||||
--enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
|
||||
--enable-constraints --enable-revocation --enable-pem --enable-pkcs1
|
||||
--enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
|
||||
@ -63,9 +63,19 @@ win)
|
||||
# no make check for Windows binaries
|
||||
TARGET=
|
||||
CFLAGS="$CFLAGS -mno-ms-bitfields"
|
||||
DEPS="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 gcc-mingw-w64-base
|
||||
mingw-w64-dev"
|
||||
CC="x86_64-w64-mingw32-gcc"
|
||||
DEPS="gcc-mingw-w64-base mingw-w64-dev"
|
||||
case "$TEST" in
|
||||
win64)
|
||||
CONFIG="--host=x86_64-w64-mingw32 $CONFIG"
|
||||
DEPS="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 $DEPS"
|
||||
CC="x86_64-w64-mingw32-gcc"
|
||||
;;
|
||||
win32)
|
||||
CONFIG="--host=i686-w64-mingw32 $CONFIG"
|
||||
DEPS="gcc-mingw-w64-i686 binutils-mingw-w64-i686 $DEPS"
|
||||
CC="i686-w64-mingw32-gcc"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
dist)
|
||||
TARGET=distcheck
|
||||
|
@ -48,8 +48,8 @@ extern void (*dbg) (debug_t group, level_t level, char *fmt, ...);
|
||||
/**
|
||||
* Forward declaration
|
||||
*/
|
||||
static DWORD service_handler(DWORD dwControl, DWORD dwEventType,
|
||||
LPVOID lpEventData, LPVOID lpContext);
|
||||
static DWORD WINAPI service_handler(DWORD dwControl, DWORD dwEventType,
|
||||
LPVOID lpEventData, LPVOID lpContext);
|
||||
|
||||
/**
|
||||
* Logging hook for library logs, using stderr output
|
||||
@ -111,7 +111,7 @@ static void update_status(DWORD state)
|
||||
/**
|
||||
* Control handler for console
|
||||
*/
|
||||
static BOOL console_handler(DWORD dwCtrlType)
|
||||
static BOOL WINAPI console_handler(DWORD dwCtrlType)
|
||||
{
|
||||
switch (dwCtrlType)
|
||||
{
|
||||
@ -135,8 +135,8 @@ static BOOL console_handler(DWORD dwCtrlType)
|
||||
/**
|
||||
* Service handler function
|
||||
*/
|
||||
static DWORD service_handler(DWORD dwControl, DWORD dwEventType,
|
||||
LPVOID lpEventData, LPVOID lpContext)
|
||||
static DWORD WINAPI service_handler(DWORD dwControl, DWORD dwEventType,
|
||||
LPVOID lpEventData, LPVOID lpContext)
|
||||
{
|
||||
switch (dwControl)
|
||||
{
|
||||
@ -285,7 +285,7 @@ static bool switch_workingdir()
|
||||
/**
|
||||
* Service main routine when running as service
|
||||
*/
|
||||
static void service_main(DWORD dwArgc, LPTSTR *lpszArgv)
|
||||
static void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
|
||||
{
|
||||
memset(&status, 0, sizeof(status));
|
||||
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
|
@ -355,9 +355,11 @@ typedef struct {
|
||||
/**
|
||||
* NotifyIpInterfaceChange() callback
|
||||
*/
|
||||
static void change_interface(private_kernel_iph_net_t *this,
|
||||
MIB_IPINTERFACE_ROW_FIXUP *row, MIB_NOTIFICATION_TYPE type)
|
||||
static void WINAPI change_interface(void *user, PMIB_IPINTERFACE_ROW row_badal,
|
||||
MIB_NOTIFICATION_TYPE type)
|
||||
{
|
||||
private_kernel_iph_net_t *this = user;
|
||||
MIB_IPINTERFACE_ROW_FIXUP* row = (MIB_IPINTERFACE_ROW_FIXUP*)row_badal;
|
||||
IP_ADAPTER_ADDRESSES addrs[64], *current;
|
||||
ULONG res, size = sizeof(addrs);
|
||||
|
||||
@ -757,7 +759,8 @@ kernel_iph_net_t *kernel_iph_net_create()
|
||||
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||
.ifaces = linked_list_create(),
|
||||
);
|
||||
|
||||
/* PIPINTERFACE_CHANGE_CALLBACK is not using WINAPI in MinGW, which seems
|
||||
* to be wrong. Force a cast to our WINAPI call */
|
||||
res = NotifyIpInterfaceChange(AF_UNSPEC, (void*)change_interface,
|
||||
this, TRUE, &this->changes);
|
||||
if (res != NO_ERROR)
|
||||
|
@ -1545,9 +1545,9 @@ static traffic_selector_t *addr2ts(FWP_IP_VERSION version, void *data,
|
||||
/**
|
||||
* FwpmNetEventSubscribe0() callback
|
||||
*/
|
||||
static void event_callback(private_kernel_wfp_ipsec_t *this,
|
||||
const FWPM_NET_EVENT1 *event)
|
||||
static void WINAPI event_callback(void *user, const FWPM_NET_EVENT1 *event)
|
||||
{
|
||||
private_kernel_wfp_ipsec_t *this = user;
|
||||
traffic_selector_t *local = NULL, *remote = NULL;
|
||||
u_int8_t protocol = 0;
|
||||
u_int16_t from_local = 0, to_local = 65535;
|
||||
@ -1610,7 +1610,7 @@ static bool register_events(private_kernel_wfp_ipsec_t *this)
|
||||
DWORD res;
|
||||
|
||||
res = FwpmNetEventSubscribe0(this->handle, &subscription,
|
||||
(void*)event_callback, this, &this->event);
|
||||
event_callback, this, &this->event);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_KNL, "registering for WFP events failed: 0x%08x", res);
|
||||
|
@ -75,14 +75,14 @@ struct private_socket_win_socket_t {
|
||||
/**
|
||||
* WSASendMsg function
|
||||
*/
|
||||
int (*WSASendMsg)(SOCKET, LPWSAMSG, DWORD, LPDWORD,
|
||||
LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
|
||||
int WINAPI (*WSASendMsg)(SOCKET, LPWSAMSG, DWORD, LPDWORD,
|
||||
LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
|
||||
|
||||
/**
|
||||
* WSARecvMsg function
|
||||
*/
|
||||
int (*WSARecvMsg)(SOCKET, LPWSAMSG, LPDWORD,
|
||||
LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
|
||||
int WINAPI (*WSARecvMsg)(SOCKET, LPWSAMSG, LPDWORD,
|
||||
LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
|
||||
};
|
||||
|
||||
METHOD(socket_t, receiver, status_t,
|
||||
|
@ -125,7 +125,7 @@ AM_LDFLAGS = \
|
||||
AM_YFLAGS = -v -d
|
||||
|
||||
if USE_WINDOWS
|
||||
libstrongswan_la_LIBADD += -lws2_32
|
||||
libstrongswan_la_LIBADD += -lws2_32 -lpsapi
|
||||
libstrongswan_la_SOURCES += \
|
||||
threading/windows/thread.c \
|
||||
threading/windows/thread_value.c \
|
||||
|
@ -138,7 +138,7 @@ static DWORD main_thread;
|
||||
/**
|
||||
* APC routine invoked by main thread on worker failure
|
||||
*/
|
||||
static void set_worker_failure(ULONG_PTR dwParam)
|
||||
static void WINAPI set_worker_failure(ULONG_PTR dwParam)
|
||||
{
|
||||
worker_failed = TRUE;
|
||||
}
|
||||
@ -180,7 +180,7 @@ void test_fail_if_worker_failed()
|
||||
/**
|
||||
* Vectored exception handler
|
||||
*/
|
||||
static long eh_handler(PEXCEPTION_POINTERS ei)
|
||||
static long WINAPI eh_handler(PEXCEPTION_POINTERS ei)
|
||||
{
|
||||
char *ename;
|
||||
bool old = FALSE;
|
||||
|
@ -378,8 +378,10 @@ void thread_set_active_condvar(CONDITION_VARIABLE *condvar)
|
||||
/**
|
||||
* APC to cancel a thread
|
||||
*/
|
||||
static void docancel(private_thread_t *this)
|
||||
static void WINAPI docancel(ULONG_PTR dwParam)
|
||||
{
|
||||
private_thread_t *this = (private_thread_t*)dwParam;
|
||||
|
||||
/* make sure cancel() does not access this anymore */
|
||||
threads_lock->lock(threads_lock);
|
||||
threads_lock->unlock(threads_lock);
|
||||
@ -398,7 +400,7 @@ METHOD(thread_t, cancel, void,
|
||||
if (!this->cancel_pending)
|
||||
{
|
||||
this->cancel_pending = TRUE;
|
||||
QueueUserAPC((void*)docancel, this->handle, (uintptr_t)this);
|
||||
QueueUserAPC(docancel, this->handle, (uintptr_t)this);
|
||||
if (this->condvar)
|
||||
{
|
||||
WakeAllConditionVariable(this->condvar);
|
||||
|
@ -33,10 +33,18 @@
|
||||
#ifdef WIN32
|
||||
# include <psapi.h>
|
||||
/* missing in MinGW */
|
||||
#ifdef WIN64
|
||||
#ifndef GetModuleInformation
|
||||
WINBOOL K32GetModuleInformation(HANDLE hProcess, HMODULE hModule,
|
||||
LPMODULEINFO lpmodinfo, DWORD cb);
|
||||
#define GetModuleInformation K32GetModuleInformation
|
||||
#endif /* !GetModuleInformation */
|
||||
#ifndef GetModuleFileNameEx
|
||||
DWORD K32GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule,
|
||||
LPTSTR lpFilename, DWORD nSize);
|
||||
#define GetModuleFileNameEx K32GetModuleFileNameExA
|
||||
#endif /* !GetModuleFileNameEx */
|
||||
#endif /* WIN64 */
|
||||
#endif
|
||||
|
||||
typedef struct private_backtrace_t private_backtrace_t;
|
||||
@ -525,9 +533,9 @@ METHOD(backtrace_t, log_, void,
|
||||
|
||||
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
||||
this->frames[i], &module) &&
|
||||
K32GetModuleInformation(GetCurrentProcess(), module,
|
||||
GetModuleInformation(GetCurrentProcess(), module,
|
||||
&info, sizeof(info)) &&
|
||||
K32GetModuleFileNameExA(GetCurrentProcess(), module,
|
||||
GetModuleFileNameEx(GetCurrentProcess(), module,
|
||||
filename, sizeof(filename)))
|
||||
{
|
||||
println(file, " %s%s%s @ %p [%p]",
|
||||
|
@ -247,7 +247,7 @@ static mutex_t *sigint_mutex;
|
||||
/**
|
||||
* Control handler to catch ^C
|
||||
*/
|
||||
static BOOL handler(DWORD dwCtrlType)
|
||||
static BOOL WINAPI handler(DWORD dwCtrlType)
|
||||
{
|
||||
switch (dwCtrlType)
|
||||
{
|
||||
|
@ -116,14 +116,14 @@ char* strndup(const char *s, size_t n);
|
||||
* Provided via ws2_32
|
||||
*/
|
||||
#ifndef InetNtop
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
const char WINAPI *inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Provided via ws2_32
|
||||
*/
|
||||
#ifndef InetPton
|
||||
int inet_pton(int af, const char *src, void *dst);
|
||||
int WINAPI inet_pton(int af, const char *src, void *dst);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user