Concentrate more windows wierdness in one place - allowing proper ordering of crazy defs and includes

This commit is contained in:
Hamish Coleman 2023-08-02 21:10:24 +01:00
parent 65359c7916
commit f79153166b
14 changed files with 42 additions and 36 deletions

View File

@ -43,8 +43,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ADD, HASH_C... #include "uthash.h" // for UT_hash_handle, HASH_ADD, HASH_C...
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#else #else
#include <arpa/inet.h> // for inet_addr, inet_ntop #include <arpa/inet.h> // for inet_addr, inet_ntop
#include <netinet/in.h> // for INADDR_ANY, INADDR_NONE, ntohl #include <netinet/in.h> // for INADDR_ANY, INADDR_NONE, ntohl

View File

@ -36,8 +36,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ITER #include "uthash.h" // for UT_hash_handle, HASH_ITER
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#else #else
#include <arpa/inet.h> // for inet_ntoa #include <arpa/inet.h> // for inet_ntoa
#include <netinet/in.h> // for in_addr, htonl, in_addr_t #include <netinet/in.h> // for in_addr, htonl, in_addr_t

View File

@ -41,8 +41,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_COUNT, HASH... #include "uthash.h" // for UT_hash_handle, HASH_COUNT, HASH...
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#include "win32/edge_utils_win32.h" #include "win32/edge_utils_win32.h"
#else #else
#include <arpa/inet.h> // for inet_ntoa, inet_addr, inet_ntop #include <arpa/inet.h> // for inet_ntoa, inet_addr, inet_ntop

View File

@ -12,7 +12,9 @@
#include "management.h" #include "management.h"
#include "n2n.h" // for TRACE_DEBUG, traceEvent #include "n2n.h" // for TRACE_DEBUG, traceEvent
#ifndef _WIN32 #ifdef _WIN32
#include "win32/defs.h"
#else
#include <netdb.h> // for getnameinfo, NI_NUMERICHOST, NI_NUMERICSERV #include <netdb.h> // for getnameinfo, NI_NUMERICHOST, NI_NUMERICSERV
#include <sys/socket.h> // for sendto, sockaddr #include <sys/socket.h> // for sendto, sockaddr
#endif #endif

View File

@ -35,9 +35,8 @@
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2def.h> #include <ws2def.h>
#include <ws2tcpip.h>
#else #else
#include <arpa/inet.h> // for inet_ntop #include <arpa/inet.h> // for inet_ntop
#include <netdb.h> // for addrinfo, freeaddrinfo, gai_strerror #include <netdb.h> // for addrinfo, freeaddrinfo, gai_strerror

View File

@ -26,8 +26,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_DEL #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_DEL
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#else #else
#include <arpa/inet.h> // for inet_ntoa, inet_addr #include <arpa/inet.h> // for inet_ntoa, inet_addr
#include <netinet/in.h> // for in_addr, in_addr_t, ntohs, ntohl #include <netinet/in.h> // for in_addr, in_addr_t, ntohs, ntohl

View File

@ -36,7 +36,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_COUNT #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_COUNT
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#else #else
#include <sys/socket.h> // for sendto, socklen_t #include <sys/socket.h> // for sendto, socklen_t
#endif #endif

View File

@ -41,8 +41,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_DEL #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_DEL
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#else #else
#include <arpa/inet.h> // for inet_addr, inet_ntoa #include <arpa/inet.h> // for inet_addr, inet_ntoa
#include <netinet/in.h> // for ntohl, in_addr_t, sockaddr_in, INADDR... #include <netinet/in.h> // for ntohl, in_addr_t, sockaddr_in, INADDR...

View File

@ -36,8 +36,7 @@
#include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_ADD_STR #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_ADD_STR
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#else #else
#include <arpa/inet.h> // for inet_addr #include <arpa/inet.h> // for inet_addr
#include <netinet/in.h> // for ntohl, INADDR_ANY, INADDR_NONE, in_addr_t #include <netinet/in.h> // for ntohl, INADDR_ANY, INADDR_NONE, in_addr_t

27
src/win32/defs.h Normal file
View File

@ -0,0 +1,27 @@
/*
* Basic definitions needed for any windows compile
*
*/
#ifndef _WIN32_DEFS_H_
#define _WIN32_DEFS_H_
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#define WIN32_LEAN_AND_MEAN
#ifndef _WIN64
/* needs to be defined before winsock gets included */
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x501
const char *subst_inet_ntop (int, const void *, char *, int);
#define inet_ntop subst_inet_ntop
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#endif

View File

@ -16,7 +16,7 @@
* *
*/ */
#include <winsock2.h> #include "defs.h"
#include <iphlpapi.h> #include <iphlpapi.h>
#include "edge_utils_win32.h" #include "edge_utils_win32.h"
@ -28,7 +28,7 @@
* This function was not included in windows until after Windows XP * This function was not included in windows until after Windows XP
*/ */
const char *inet_ntop (int af, const void *src, char *dst, socklen_t size) { const char *subst_inet_ntop (int af, const void *src, char *dst, int size) {
if(af == AF_INET) { if(af == AF_INET) {
struct sockaddr_in in; struct sockaddr_in in;
memset(&in, 0, sizeof(in)); memset(&in, 0, sizeof(in));

View File

@ -7,21 +7,6 @@
#ifndef _N2N_WIN32_H_ #ifndef _N2N_WIN32_H_
#define _N2N_WIN32_H_ #define _N2N_WIN32_H_
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#define WIN32_LEAN_AND_MEAN
#if defined(__MINGW32__)
/* should be defined here and before winsock gets included */
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x501 //Otherwise the linker doesnt find getaddrinfo
#endif /* #ifndef _WIN32_WINNT */
#include <inttypes.h>
#endif /* #if defined(__MINGW32__) */
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#include <ws2def.h> #include <ws2def.h>

View File

@ -2,8 +2,8 @@
(C) 2007-22 - Luca Deri <deri@ntop.org> (C) 2007-22 - Luca Deri <deri@ntop.org>
*/ */
#include "defs.h"
#ifndef _WIN64 #ifndef _WIN64
#include <winsock2.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#endif #endif

View File

@ -34,8 +34,7 @@
#include "n2n_wire.h" // for decode_PACKET, decode_PEER_INFO, decode_QUER... #include "n2n_wire.h" // for decode_PACKET, decode_PEER_INFO, decode_QUER...
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "win32/defs.h"
#include <ws2tcpip.h>
#else #else
#include <netinet/in.h> // for sockaddr_in, sockaddr_in6, in6_addr, in_addr #include <netinet/in.h> // for sockaddr_in, sockaddr_in6, in6_addr, in_addr
#include <sys/socket.h> // for AF_INET, AF_INET6, SOCK_STREAM, SOCK_DGRAM #include <sys/socket.h> // for AF_INET, AF_INET6, SOCK_STREAM, SOCK_DGRAM