From 21ac30c12196dc9e72217ceec6a4b7b2c6e59bca Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Sat, 24 Jun 2023 19:33:31 +0100 Subject: [PATCH] Use the correct modern windows sockets header As suggested in a PR from @Legend-Master (this change is basically unrelated to the main point of his PR, so extracted here) Windows is a confusing and disappointing development environment. They completely replaced all the definitions in winsock.h with exact equivalents in winsock2.h (except for a small number of deprecated functions). However they didnt make them mutually exclusive - so if you include both, you get errors. They also automatically include winsock.h from windows.h, so you must remember to include winsock2.h first. They also didnt just remove winsock.h and replace it with the new contents. (Probably in the name of "compatibility", whilst swearing that the new winsock is the same as the old one - because if you cannot believe two inconsistent things simultaneously, you shouldnt be a windows programmer) All these things are totally nuts. Thanks, windows dev environment, for not noticing that this is nuts --- include/n2n.h | 2 +- src/edge.c | 2 +- src/edge_management.c | 2 +- src/edge_utils.c | 2 +- src/example_sn_embed.c | 2 +- src/management.h | 2 +- src/n2n.c | 2 +- src/network_traffic_filter.c | 2 +- src/sn_management.c | 2 +- src/sn_utils.c | 2 +- src/supernode.c | 2 +- src/wire.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/n2n.h b/include/n2n.h index e5b0bfd..f41f2a4 100644 --- a/include/n2n.h +++ b/include/n2n.h @@ -56,11 +56,11 @@ #include "n2n_typedefs.h" #ifdef WIN32 +#include /* for tcp */ #include /* for privilege check in tools/n2n-route */ #include /* for privilege check in tools/n2n-route */ #include #include /* for privilege check in tools/n2n-route */ -#include /* for tcp */ #include "wintap.h" #define SHUT_RDWR SD_BOTH /* for tcp */ #endif /* #ifdef WIN32 */ diff --git a/src/edge.c b/src/edge.c index d2c0288..5e76ab5 100644 --- a/src/edge.c +++ b/src/edge.c @@ -43,7 +43,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_ADD, HASH_C... #ifdef WIN32 -#include +#include #include #else #include // for inet_addr, inet_ntop diff --git a/src/edge_management.c b/src/edge_management.c index 53e0b6f..7381f1c 100644 --- a/src/edge_management.c +++ b/src/edge_management.c @@ -36,7 +36,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_ITER #ifdef WIN32 -#include +#include #include #include "edge_utils_win32.h" #else diff --git a/src/edge_utils.c b/src/edge_utils.c index e560b24..d59f1ad 100644 --- a/src/edge_utils.c +++ b/src/edge_utils.c @@ -41,7 +41,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_COUNT, HASH... #ifdef WIN32 -#include +#include #include #include "edge_utils_win32.h" #else diff --git a/src/example_sn_embed.c b/src/example_sn_embed.c index 713d068..cdd16ed 100644 --- a/src/example_sn_embed.c +++ b/src/example_sn_embed.c @@ -22,7 +22,7 @@ #include "n2n.h" // for n2n_sn_t, open_socket, run_sn_loop, sn_init #ifdef WIN32 -#include +#include #else #include // for INADDR_ANY, INADDR_LOOPBACK #endif diff --git a/src/management.h b/src/management.h index 3e95458..53592bd 100644 --- a/src/management.h +++ b/src/management.h @@ -17,7 +17,7 @@ #include "strbuf.h" #ifdef WIN32 -#include +#include #else #include // for sockaddr, sockaddr_storage, socklen_t #endif diff --git a/src/n2n.c b/src/n2n.c index 3d6ce08..bcba07b 100644 --- a/src/n2n.c +++ b/src/n2n.c @@ -31,7 +31,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_DEL, HASH_ITER, HAS... #ifdef WIN32 -#include +#include #include #include #else diff --git a/src/network_traffic_filter.c b/src/network_traffic_filter.c index fc8b4c1..4ba0d0b 100644 --- a/src/network_traffic_filter.c +++ b/src/network_traffic_filter.c @@ -26,7 +26,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_DEL #ifdef WIN32 -#include +#include #include #else #include // for inet_ntoa, inet_addr diff --git a/src/sn_management.c b/src/sn_management.c index 3dae672..4954cdf 100644 --- a/src/sn_management.c +++ b/src/sn_management.c @@ -36,7 +36,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_COUNT #ifdef WIN32 -#include +#include #include "edge_utils_win32.h" #else #include // for sendto, socklen_t diff --git a/src/sn_utils.c b/src/sn_utils.c index 9b57f58..88686f7 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -41,7 +41,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_DEL #ifdef WIN32 -#include +#include #include #else #include // for inet_addr, inet_ntoa diff --git a/src/supernode.c b/src/supernode.c index 1c640f1..2f60416 100644 --- a/src/supernode.c +++ b/src/supernode.c @@ -36,7 +36,7 @@ #include "uthash.h" // for UT_hash_handle, HASH_ITER, HASH_ADD_STR #ifdef WIN32 -#include +#include #include #else #include // for inet_addr diff --git a/src/wire.c b/src/wire.c index af1011f..765a8e7 100644 --- a/src/wire.c +++ b/src/wire.c @@ -34,7 +34,7 @@ #include "n2n_wire.h" // for decode_PACKET, decode_PEER_INFO, decode_QUER... #ifdef WIN32 -#include +#include #include #else #include // for sockaddr_in, sockaddr_in6, in6_addr, in_addr