mirror of
https://github.com/strongswan/strongswan.git
synced 2025-12-09 00:00:27 -05:00
kernel-wfp: Fix/Complete some fwpuclnt functionality in MinGW
While MinGW declares all the required symbols, some of them are missing in the library files. We provide missing variables locally, functions get a stub that call the GetProcAddress()ed function from the DLL. Also some MinGW headers define some enum values incorrectly, we overload these using defines.
This commit is contained in:
parent
ebb9362d85
commit
b1ba0a666c
@ -14,6 +14,7 @@ endif
|
||||
|
||||
libstrongswan_kernel_wfp_la_SOURCES = \
|
||||
kernel_wfp_plugin.h kernel_wfp_plugin.c \
|
||||
kernel_wfp_compat.c kernel_wfp_compat.h \
|
||||
kernel_wfp_ipsec.h kernel_wfp_ipsec.c
|
||||
|
||||
libstrongswan_kernel_wfp_la_LDFLAGS = -module -avoid-version
|
||||
|
||||
83
src/libcharon/plugins/kernel_wfp/kernel_wfp_compat.c
Normal file
83
src/libcharon/plugins/kernel_wfp/kernel_wfp_compat.c
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Martin Willi
|
||||
* Copyright (C) 2013 revosec AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <library.h>
|
||||
|
||||
const GUID FWPM_CONDITION_IP_REMOTE_ADDRESS = {
|
||||
0xb235ae9a, 0x1d64, 0x49b8, { 0xa4,0x4c,0x5f,0xf3,0xd9,0x09,0x50,0x45 }
|
||||
};
|
||||
const GUID FWPM_CONDITION_IP_LOCAL_ADDRESS = {
|
||||
0xd9ee00de, 0xc1ef, 0x4617, { 0xbf,0xe3,0xff,0xd8,0xf5,0xa0,0x89,0x57 }
|
||||
};
|
||||
const GUID FWPM_LAYER_INBOUND_TRANSPORT_V4 = {
|
||||
0x5926dfc8, 0xe3cf, 0x4426, { 0xa2,0x83,0xdc,0x39,0x3f,0x5d,0x0f,0x9d }
|
||||
};
|
||||
const GUID FWPM_LAYER_OUTBOUND_TRANSPORT_V4 = {
|
||||
0x09e61aea, 0xd214, 0x46e2, { 0x9b,0x21,0xb2,0x6b,0x0b,0x2f,0x28,0xc8 }
|
||||
};
|
||||
const GUID FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V4 = {
|
||||
0x5132900d, 0x5e84, 0x4b5f, { 0x80,0xe4,0x01,0x74,0x1e,0x81,0xff,0x10 }
|
||||
};
|
||||
const GUID FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V4 = {
|
||||
0x4b46bf0a, 0x4523, 0x4e57, { 0xaa,0x38,0xa8,0x79,0x87,0xc9,0x10,0xd9 }
|
||||
};
|
||||
|
||||
/**
|
||||
* Load a function symbol from a loaded dll
|
||||
*/
|
||||
static inline void *load_function(char *dll, char *name)
|
||||
{
|
||||
HANDLE handle;
|
||||
void *sym = NULL;
|
||||
|
||||
handle = GetModuleHandle(dll);
|
||||
if (!handle)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
sym = GetProcAddress(handle, name);
|
||||
return sym;
|
||||
}
|
||||
|
||||
/**
|
||||
* Macro that defines a stub for a function that calls the same DLL function
|
||||
*
|
||||
* @param dll DLL to find function in
|
||||
* @param ret return type of function
|
||||
* @param name function name
|
||||
* @param size size of all arguments on stack
|
||||
* @param ... arguments of function
|
||||
*/
|
||||
#define STUB(dll, ret, name, size, ...) \
|
||||
ret WINAPI name(__VA_ARGS__) \
|
||||
{ \
|
||||
static void (*fun)() = NULL; \
|
||||
if (!fun) \
|
||||
{ \
|
||||
fun = load_function(#dll, #name); \
|
||||
} \
|
||||
if (fun) \
|
||||
{ \
|
||||
__builtin_return(__builtin_apply(fun, __builtin_apply_args(), size)); \
|
||||
} \
|
||||
return ERROR_NOT_SUPPORTED; \
|
||||
}
|
||||
|
||||
STUB(fwpuclnt, DWORD, IPsecSaContextCreate1, 40,
|
||||
HANDLE engineHandle, const void *outboundTraffic,
|
||||
const void *virtualIfTunnelInfo, UINT64 *inboundFilterId, UINT64 *id)
|
||||
|
||||
STUB(fwpuclnt, DWORD, IPsecSaContextSetSpi0, 32,
|
||||
HANDLE engineHandle, UINT64 id, const void *getSpi, UINT32 inboundSpi)
|
||||
48
src/libcharon/plugins/kernel_wfp/kernel_wfp_compat.h
Normal file
48
src/libcharon/plugins/kernel_wfp/kernel_wfp_compat.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Martin Willi
|
||||
* Copyright (C) 2013 revosec AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup kernel_wfp_compat kernel_wfp_compat
|
||||
* @{ @ingroup kernel_wfp
|
||||
*/
|
||||
|
||||
#ifndef KERNEL_WFP_COMPAT_H_
|
||||
#define KERNEL_WFP_COMPAT_H_
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <ipsectypes.h>
|
||||
|
||||
/* MinGW defines CIPHERs incorrectly starting at 0 */
|
||||
#define IPSEC_CIPHER_TYPE_DES 1
|
||||
#define IPSEC_CIPHER_TYPE_3DES 2
|
||||
#define IPSEC_CIPHER_TYPE_AES_128 3
|
||||
#define IPSEC_CIPHER_TYPE_AES_192 4
|
||||
#define IPSEC_CIPHER_TYPE_AES_256 5
|
||||
#define IPSEC_CIPHER_TYPE_MAX 6
|
||||
|
||||
#include <fwpmtypes.h>
|
||||
#include <fwpmu.h>
|
||||
#undef interface
|
||||
|
||||
/* MinGW defines TRANSFORMs incorrectly starting at 0 */
|
||||
#define IPSEC_TRANSFORM_AH 1
|
||||
#define IPSEC_TRANSFORM_ESP_AUTH 2
|
||||
#define IPSEC_TRANSFORM_ESP_CIPHER 3
|
||||
#define IPSEC_TRANSFORM_ESP_AUTH_AND_CIPHER 4
|
||||
#define IPSEC_TRANSFORM_ESP_AUTH_FW 5
|
||||
#define IPSEC_TRANSFORM_TYPE_MAX 6
|
||||
|
||||
#endif /** KERNEL_WFP_COMPAT_H_ @}*/
|
||||
@ -16,6 +16,7 @@
|
||||
/* Windows 7, for some fwpmu.h functionality */
|
||||
#define _WIN32_WINNT 0x0601
|
||||
|
||||
#include "kernel_wfp_compat.h"
|
||||
#include "kernel_wfp_ipsec.h"
|
||||
|
||||
#include <daemon.h>
|
||||
@ -23,9 +24,6 @@
|
||||
#include <collections/array.h>
|
||||
#include <collections/hashtable.h>
|
||||
|
||||
#include <fwpmtypes.h>
|
||||
#include <fwpmu.h>
|
||||
#undef interface
|
||||
|
||||
typedef struct private_kernel_wfp_ipsec_t private_kernel_wfp_ipsec_t;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user