diff --git a/dlls/inetmib1/Makefile.in b/dlls/inetmib1/Makefile.in index 25391ff2624..553c8911792 100644 --- a/dlls/inetmib1/Makefile.in +++ b/dlls/inetmib1/Makefile.in @@ -1,5 +1,5 @@ MODULE = inetmib1.dll -IMPORTS = snmpapi +IMPORTS = snmpapi ws2_32 DELAYIMPORTS = iphlpapi C_SRCS = \ diff --git a/dlls/iphlpapi/Makefile.in b/dlls/iphlpapi/Makefile.in index d01c764c61f..63d27a90df9 100644 --- a/dlls/iphlpapi/Makefile.in +++ b/dlls/iphlpapi/Makefile.in @@ -1,6 +1,6 @@ MODULE = iphlpapi.dll IMPORTLIB = iphlpapi -IMPORTS = advapi32 dnsapi nsi uuid +IMPORTS = advapi32 dnsapi nsi uuid ws2_32 C_SRCS = \ iphlpapi_main.c diff --git a/dlls/iphlpapi/tests/Makefile.in b/dlls/iphlpapi/tests/Makefile.in index d8131013546..23e8d1b80d3 100644 --- a/dlls/iphlpapi/tests/Makefile.in +++ b/dlls/iphlpapi/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = iphlpapi.dll -IMPORTS = iphlpapi +IMPORTS = iphlpapi ws2_32 C_SRCS = \ iphlpapi.c diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 4cc722836e1..0d0b2d370f3 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -40,6 +40,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll); WINE_DECLARE_DEBUG_CHANNEL(debugstr); +#define htons(x) RtlUshortByteSwap(x) +#define ntohs(x) RtlUshortByteSwap(x) + /* CRC polynomial 0xedb88320 */ static const DWORD CRC_table[256] = { diff --git a/dlls/ntoskrnl.exe/tests/driver_netio.c b/dlls/ntoskrnl.exe/tests/driver_netio.c index 365c90a05ab..5574707e636 100644 --- a/dlls/ntoskrnl.exe/tests/driver_netio.c +++ b/dlls/ntoskrnl.exe/tests/driver_netio.c @@ -40,6 +40,11 @@ #include "utils.h" +#define htonl(x) RtlUlongByteSwap(x) +#define htons(x) RtlUshortByteSwap(x) +#define ntohl(x) RtlUlongByteSwap(x) +#define ntohs(x) RtlUshortByteSwap(x) + static DRIVER_OBJECT *driver_obj; static DEVICE_OBJECT *device_obj; @@ -148,7 +153,7 @@ static void test_wsk_get_address_info(void) ok(addr_info->ai_addrlen == sizeof(*addr), "Got unexpected ai_addrlen %I64u.\n", (UINT64)addr_info->ai_addrlen); ok(addr->sin_family == AF_INET, "Got unexpected sin_family %u.\n", addr->sin_family); ok(ntohs(addr->sin_port) == 12345, "Got unexpected sin_port %u.\n", ntohs(addr->sin_port)); - ok(ntohl(addr->sin_addr.s_addr) == 0x7f000001, "Got unexpected sin_addr %#lx.\n", + ok(ntohl(addr->sin_addr.s_addr) == INADDR_LOOPBACK, "Got unexpected sin_addr %#lx.\n", ntohl(addr->sin_addr.s_addr)); ++count; @@ -308,12 +313,12 @@ static void test_wsk_listen_socket(void) ok(local_addr.sin_family == AF_INET, "Got unexpected sin_family %u.\n", local_addr.sin_family); ok(local_addr.sin_port == htons(SERVER_LISTEN_PORT), "Got unexpected sin_port %u.\n", ntohs(local_addr.sin_port)); - ok(local_addr.sin_addr.s_addr == htonl(0x7f000001), "Got unexpected sin_addr %#lx.\n", + ok(local_addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK), "Got unexpected sin_addr %#lx.\n", ntohl(local_addr.sin_addr.s_addr)); ok(remote_addr.sin_family == AF_INET, "Got unexpected sin_family %u.\n", remote_addr.sin_family); ok(remote_addr.sin_port, "Got zero sin_port.\n"); - ok(remote_addr.sin_addr.s_addr == htonl(0x7f000001), "Got unexpected sin_addr %#lx.\n", + ok(remote_addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK), "Got unexpected sin_addr %#lx.\n", ntohl(remote_addr.sin_addr.s_addr)); accept_socket = (WSK_SOCKET *)wsk_irp->IoStatus.Information; @@ -415,7 +420,7 @@ static void test_wsk_connect_socket(void) memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(CLIENT_LISTEN_PORT); - addr.sin_addr.s_addr = htonl(0x7f000001); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); IoReuseIrp(wsk_irp, STATUS_UNSUCCESSFUL); IoSetCompletionRoutine(wsk_irp, irp_completion_routine, &irp_complete_event, TRUE, TRUE, TRUE); @@ -443,7 +448,7 @@ static void test_wsk_connect_socket(void) wsk_irp->IoStatus.Information); addr.sin_port = htons(CLIENT_LISTEN_PORT); - addr.sin_addr.s_addr = htonl(0x7f000001); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); IoReuseIrp(wsk_irp, STATUS_UNSUCCESSFUL); IoSetCompletionRoutine(wsk_irp, irp_completion_routine, &irp_complete_event, TRUE, TRUE, TRUE); diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index 4d0f6561ad4..c19f8430d98 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -1895,18 +1895,18 @@ u_long WINAPI inet_addr( const char *str ) /*********************************************************************** * htonl (ws2_32.8) */ -u_long WINAPI WS_htonl( u_long hostlong ) +u_long WINAPI htonl( u_long hostlong ) { - return htonl( hostlong ); + return RtlUlongByteSwap( hostlong ); } /*********************************************************************** * htons (ws2_32.9) */ -u_short WINAPI WS_htons( u_short hostshort ) +u_short WINAPI htons( u_short hostshort ) { - return htons( hostshort ); + return RtlUshortByteSwap( hostshort ); } @@ -1943,18 +1943,18 @@ int WINAPI WSAHtons( SOCKET s, u_short hostshort, u_short *netshort ) /*********************************************************************** * ntohl (ws2_32.14) */ -u_long WINAPI WS_ntohl( u_long netlong ) +u_long WINAPI ntohl( u_long netlong ) { - return ntohl( netlong ); + return RtlUlongByteSwap( netlong ); } /*********************************************************************** * ntohs (ws2_32.15) */ -u_short WINAPI WS_ntohs( u_short netshort ) +u_short WINAPI ntohs( u_short netshort ) { - return ntohs( netshort ); + return RtlUshortByteSwap( netshort ); } diff --git a/dlls/ws2_32/ws2_32.spec b/dlls/ws2_32/ws2_32.spec index 6a07895d2f6..3266a239f9c 100644 --- a/dlls/ws2_32/ws2_32.spec +++ b/dlls/ws2_32/ws2_32.spec @@ -5,14 +5,14 @@ 5 stdcall getpeername(long ptr ptr) 6 stdcall getsockname(long ptr ptr) 7 stdcall getsockopt(long long long ptr ptr) -8 stdcall htonl(long) WS_htonl -9 stdcall htons(long) WS_htons +8 stdcall htonl(long) +9 stdcall htons(long) 10 stdcall ioctlsocket(long long ptr) 11 stdcall inet_addr(str) 12 stdcall inet_ntoa(ptr) 13 stdcall listen(long long) -14 stdcall ntohl(long) WS_ntohl -15 stdcall ntohs(long) WS_ntohs +14 stdcall ntohl(long) +15 stdcall ntohs(long) 16 stdcall recv(long ptr long long) 17 stdcall recvfrom(long ptr long long ptr ptr) 18 stdcall select(long ptr ptr ptr ptr) diff --git a/include/winsock.h b/include/winsock.h index 350e5636f81..812b7eeb7a9 100644 --- a/include/winsock.h +++ b/include/winsock.h @@ -480,48 +480,6 @@ WINSOCK_API_LINKAGE int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*); #endif /* WS_DEFINE_SELECT */ -/* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */ -#ifndef USE_WS_PREFIX - -#undef htonl -#undef htons -#undef ntohl -#undef ntohs - -#ifdef WORDS_BIGENDIAN - -static inline u_short __wine_ushort_noop(u_short s) -{ - return s; -} -static inline ULONG __wine_ulong_noop(ULONG l) -{ - return l; -} -#define htonl __wine_ulong_noop -#define htons __wine_ushort_noop -#define ntohl __wine_ulong_noop -#define ntohs __wine_ushort_noop - -#else /* WORDS_BIGENDIAN */ - -static inline u_short __wine_ushort_swap(u_short s) -{ - return (s >> 8) | (s << 8); -} -static inline ULONG __wine_ulong_swap(ULONG l) -{ - return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16)); -} -#define htonl __wine_ulong_swap -#define htons __wine_ushort_swap -#define ntohl __wine_ulong_swap -#define ntohs __wine_ushort_swap - -#endif /* WORDS_BIGENDIAN */ - -#endif /* USE_WS_PREFIX */ - /* * Internet address (old style... should be updated) */ @@ -966,10 +924,14 @@ WINSOCK_API_LINKAGE struct WS(servent)* WINAPI WS(getservbyname)(const char*,con WINSOCK_API_LINKAGE struct WS(servent)* WINAPI WS(getservbyport)(int,const char*); WINSOCK_API_LINKAGE int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*); WINSOCK_API_LINKAGE int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*); +WINSOCK_API_LINKAGE ULONG WINAPI WS(htonl)(ULONG); +WINSOCK_API_LINKAGE WS(u_short) WINAPI WS(htons)(WS(u_short)); WINSOCK_API_LINKAGE ULONG WINAPI WS(inet_addr)(const char*); WINSOCK_API_LINKAGE char* WINAPI WS(inet_ntoa)(struct WS(in_addr)); WINSOCK_API_LINKAGE int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*); WINSOCK_API_LINKAGE int WINAPI WS(listen)(SOCKET,int); +WINSOCK_API_LINKAGE ULONG WINAPI WS(ntohl)(ULONG); +WINSOCK_API_LINKAGE WS(u_short) WINAPI WS(ntohs)(WS(u_short)); WINSOCK_API_LINKAGE int WINAPI WS(recv)(SOCKET,char*,int,int); WINSOCK_API_LINKAGE int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*); WINSOCK_API_LINKAGE int WINAPI WS(send)(SOCKET,const char*,int,int); diff --git a/include/winsock2.h b/include/winsock2.h index a08a68c8db8..1d2d7888909 100644 --- a/include/winsock2.h +++ b/include/winsock2.h @@ -1001,46 +1001,6 @@ typedef struct WSAData #endif } WSADATA, *LPWSADATA; -#ifndef USE_WS_PREFIX - -#undef htonl -#undef htons -#undef ntohl -#undef ntohs - -#ifdef WORDS_BIGENDIAN - -static inline u_short __wine_ushort_noop(u_short s) -{ - return s; -} -static inline ULONG __wine_ulong_noop(ULONG l) -{ - return l; -} -#define htonl __wine_ulong_noop -#define htons __wine_ushort_noop -#define ntohl __wine_ulong_noop -#define ntohs __wine_ushort_noop - -#else /* WORDS_BIGENDIAN */ - -static inline u_short __wine_ushort_swap(u_short s) -{ - return (s >> 8) | (s << 8); -} -static inline ULONG __wine_ulong_swap(ULONG l) -{ - return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16)); -} -#define htonl __wine_ulong_swap -#define htons __wine_ushort_swap -#define ntohl __wine_ulong_swap -#define ntohs __wine_ushort_swap - -#endif /* WORDS_BIGENDIAN */ -#endif /* USE_WS_PREFIX */ - #define WSAMAKEASYNCREPLY(size, error) MAKELONG(size, error) #define WSAMAKESELECTREPLY(flags, error) MAKELONG(flags, error) #define WSAGETASYNCBUFLEN(x) LOWORD(x) @@ -1134,10 +1094,14 @@ WINSOCK_API_LINKAGE struct WS(servent) * WINAPI WS(getservbyname)(const char *, WINSOCK_API_LINKAGE struct WS(servent) * WINAPI WS(getservbyport)(int, const char *); WINSOCK_API_LINKAGE int WINAPI WS(getsockname)(SOCKET, struct WS(sockaddr) *, int *); WINSOCK_API_LINKAGE int WINAPI WS(getsockopt)(SOCKET, int, int, char *, int *); +WINSOCK_API_LINKAGE ULONG WINAPI WS(htonl)(ULONG); +WINSOCK_API_LINKAGE WS(u_short) WINAPI WS(htons)(WS(u_short)); WINSOCK_API_LINKAGE ULONG WINAPI WS(inet_addr)(const char *); WINSOCK_API_LINKAGE char * WINAPI WS(inet_ntoa)(struct WS(in_addr)); WINSOCK_API_LINKAGE int WINAPI WS(ioctlsocket)(SOCKET, LONG, WS(u_long) *); WINSOCK_API_LINKAGE int WINAPI WS(listen)(SOCKET, int); +WINSOCK_API_LINKAGE ULONG WINAPI WS(ntohl)(ULONG); +WINSOCK_API_LINKAGE WS(u_short) WINAPI WS(ntohs)(WS(u_short)); WINSOCK_API_LINKAGE int WINAPI WS(recv)(SOCKET, char *, int, int); WINSOCK_API_LINKAGE int WINAPI WS(recvfrom)(SOCKET, char *, int, int, struct WS(sockaddr) *, int *); #ifdef WS_DEFINE_SELECT diff --git a/libs/ldap/libldap/sasl_w.c b/libs/ldap/libldap/sasl_w.c index 83e78adb2a5..db4d830cfc3 100644 --- a/libs/ldap/libldap/sasl_w.c +++ b/libs/ldap/libldap/sasl_w.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include