Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/protocol.c | 369 ++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 411 ----------------------------------------- 2 files changed, 369 insertions(+), 411 deletions(-)
diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index 2cb6ef4be1c..fe30f26db53 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -1653,3 +1653,372 @@ struct WS_servent * WINAPI WS_getservbyport( int port, const char *proto ) TRACE( "%d (i.e. port %d), %s ret %p\n", port, (int)ntohl(port), debugstr_a(proto), retval ); return retval; } + + +/*********************************************************************** + * inet_ntoa (ws2_32.12) + */ +char * WINAPI WS_inet_ntoa( struct WS_in_addr in ) +{ + unsigned int long_ip = ntohl( in.WS_s_addr ); + struct per_thread_data *data = get_per_thread_data(); + + sprintf( data->ntoa_buffer, "%u.%u.%u.%u", + (long_ip >> 24) & 0xff, + (long_ip >> 16) & 0xff, + (long_ip >> 8) & 0xff, + long_ip & 0xff ); + + return data->ntoa_buffer; +} + + +/*********************************************************************** + * inet_ntop (ws2_32.@) + */ +const char * WINAPI WS_inet_ntop( int family, void *addr, char *buffer, SIZE_T len ) +{ + NTSTATUS status; + ULONG size = min( len, (ULONG)-1 ); + + TRACE( "family %d, addr %p, buffer %p, len %ld\n", family, addr, buffer, len ); + if (!buffer) + { + SetLastError( STATUS_INVALID_PARAMETER ); + return NULL; + } + + switch (family) + { + case WS_AF_INET: + { + status = RtlIpv4AddressToStringExA( (IN_ADDR *)addr, 0, buffer, &size ); + break; + } + case WS_AF_INET6: + { + status = RtlIpv6AddressToStringExA( (IN6_ADDR *)addr, 0, 0, buffer, &size ); + break; + } + default: + SetLastError( WSAEAFNOSUPPORT ); + return NULL; + } + + if (status == STATUS_SUCCESS) return buffer; + SetLastError( STATUS_INVALID_PARAMETER ); + return NULL; +} + +/*********************************************************************** + * inet_pton (ws2_32.@) + */ +int WINAPI WS_inet_pton( int family, const char *addr, void *buffer ) +{ + NTSTATUS status; + const char *terminator; + + TRACE( "family %d, addr %s, buffer %p\n", family, debugstr_a(addr), buffer ); + + if (!addr || !buffer) + { + SetLastError( WSAEFAULT ); + return -1; + } + + switch (family) + { + case WS_AF_INET: + status = RtlIpv4StringToAddressA(addr, TRUE, &terminator, buffer); + break; + case WS_AF_INET6: + status = RtlIpv6StringToAddressA(addr, &terminator, buffer); + break; + default: + SetLastError( WSAEAFNOSUPPORT ); + return -1; + } + + return (status == STATUS_SUCCESS && *terminator == 0); +} + +/*********************************************************************** + * InetPtonW (ws2_32.@) + */ +int WINAPI InetPtonW( int family, const WCHAR *addr, void *buffer ) +{ + char *addrA; + int len; + INT ret; + + TRACE( "family %d, addr %s, buffer %p\n", family, debugstr_w(addr), buffer ); + + if (!addr) + { + SetLastError(WSAEFAULT); + return SOCKET_ERROR; + } + + len = WideCharToMultiByte( CP_ACP, 0, addr, -1, NULL, 0, NULL, NULL ); + if (!(addrA = HeapAlloc( GetProcessHeap(), 0, len ))) + { + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; + } + WideCharToMultiByte( CP_ACP, 0, addr, -1, addrA, len, NULL, NULL ); + + ret = WS_inet_pton( family, addrA, buffer ); + if (!ret) SetLastError( WSAEINVAL ); + + HeapFree( GetProcessHeap(), 0, addrA ); + return ret; +} + +/*********************************************************************** + * InetNtopW (ws2_32.@) + */ +const WCHAR * WINAPI InetNtopW( int family, void *addr, WCHAR *buffer, SIZE_T len ) +{ + char bufferA[WS_INET6_ADDRSTRLEN]; + PWSTR ret = NULL; + + TRACE( "family %d, addr %p, buffer %p, len %ld\n", family, addr, buffer, len ); + + if (WS_inet_ntop( family, addr, bufferA, sizeof(bufferA) )) + { + if (MultiByteToWideChar( CP_ACP, 0, bufferA, -1, buffer, len )) + ret = buffer; + else + SetLastError( ERROR_INVALID_PARAMETER ); + } + return ret; +} + + +/*********************************************************************** + * WSAStringToAddressA (ws2_32.@) + */ +int WINAPI WSAStringToAddressA( char *string, int family, WSAPROTOCOL_INFOA *protocol_info, + struct WS_sockaddr *addr, int *addr_len ) +{ + NTSTATUS status; + + TRACE( "string %s, family %u\n", debugstr_a(string), family ); + + if (!addr || !addr_len) return -1; + + if (!string) + { + SetLastError( WSAEINVAL ); + return -1; + } + + if (protocol_info) + FIXME( "ignoring protocol_info\n" ); + + switch (family) + { + case WS_AF_INET: + { + struct WS_sockaddr_in *addr4 = (struct WS_sockaddr_in *)addr; + + if (*addr_len < sizeof(struct WS_sockaddr_in)) + { + *addr_len = sizeof(struct WS_sockaddr_in); + SetLastError( WSAEFAULT ); + return -1; + } + memset( addr, 0, sizeof(struct WS_sockaddr_in) ); + + status = RtlIpv4StringToAddressExA( string, FALSE, &addr4->sin_addr, &addr4->sin_port ); + if (status != STATUS_SUCCESS) + { + SetLastError( WSAEINVAL ); + return -1; + } + addr4->sin_family = WS_AF_INET; + *addr_len = sizeof(struct WS_sockaddr_in); + return 0; + } + case WS_AF_INET6: + { + struct WS_sockaddr_in6 *addr6 = (struct WS_sockaddr_in6 *)addr; + + if (*addr_len < sizeof(struct WS_sockaddr_in6)) + { + *addr_len = sizeof(struct WS_sockaddr_in6); + SetLastError( WSAEFAULT ); + return -1; + } + memset( addr, 0, sizeof(struct WS_sockaddr_in6) ); + + status = RtlIpv6StringToAddressExA( string, &addr6->sin6_addr, &addr6->sin6_scope_id, &addr6->sin6_port ); + if (status != STATUS_SUCCESS) + { + SetLastError( WSAEINVAL ); + return -1; + } + addr6->sin6_family = WS_AF_INET6; + *addr_len = sizeof(struct WS_sockaddr_in6); + return 0; + } + default: + /* According to MSDN, only AF_INET and AF_INET6 are supported. */ + TRACE( "Unsupported address family specified: %d.\n", family ); + SetLastError( WSAEINVAL ); + return -1; + } +} + + +/*********************************************************************** + * WSAStringToAddressW (ws2_32.@) + */ +int WINAPI WSAStringToAddressW( WCHAR *string, int family, WSAPROTOCOL_INFOW *protocol_info, + struct WS_sockaddr *addr, int *addr_len ) +{ + WSAPROTOCOL_INFOA infoA; + WSAPROTOCOL_INFOA *protocol_infoA = NULL; + int sizeA, ret; + char *stringA; + + TRACE( "string %s, family %u\n", debugstr_w(string), family ); + + if (!addr || !addr_len) return -1; + + if (protocol_info) + { + protocol_infoA = &infoA; + memcpy( protocol_infoA, protocol_info, FIELD_OFFSET( WSAPROTOCOL_INFOA, szProtocol ) ); + + if (!WideCharToMultiByte( CP_ACP, 0, protocol_info->szProtocol, -1, protocol_infoA->szProtocol, + sizeof(protocol_infoA->szProtocol), NULL, NULL )) + { + SetLastError( WSAEINVAL ); + return -1; + } + } + + if (!string) + { + SetLastError( WSAEINVAL ); + return -1; + } + + sizeA = WideCharToMultiByte( CP_ACP, 0, string, -1, NULL, 0, NULL, NULL ); + if (!(stringA = HeapAlloc( GetProcessHeap(), 0, sizeA ))) + { + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; + } + WideCharToMultiByte( CP_ACP, 0, string, -1, stringA, sizeA, NULL, NULL ); + ret = WSAStringToAddressA( stringA, family, protocol_infoA, addr, addr_len ); + HeapFree( GetProcessHeap(), 0, stringA ); + return ret; +} + + +/*********************************************************************** + * WSAAddressToStringA (ws2_32.@) + */ +int WINAPI WSAAddressToStringA( struct WS_sockaddr *addr, DWORD addr_len, + WSAPROTOCOL_INFOA *info, char *string, DWORD *string_len ) +{ + char buffer[54]; /* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */ + DWORD size; + + TRACE( "addr %s\n", debugstr_sockaddr(addr) ); + + if (!addr) return SOCKET_ERROR; + if (!string || !string_len) return SOCKET_ERROR; + + switch (addr->sa_family) + { + case WS_AF_INET: + { + const struct WS_sockaddr_in *addr4 = (const struct WS_sockaddr_in *)addr; + unsigned int long_ip = ntohl( addr4->sin_addr.WS_s_addr ); + char *p; + + if (addr_len < sizeof(struct WS_sockaddr_in)) return -1; + sprintf( buffer, "%u.%u.%u.%u:%u", + (long_ip >> 24) & 0xff, + (long_ip >> 16) & 0xff, + (long_ip >> 8) & 0xff, + long_ip & 0xff, + ntohs( addr4->sin_port ) ); + + p = strchr( buffer, ':' ); + if (!addr4->sin_port) *p = 0; + break; + } + case WS_AF_INET6: + { + struct WS_sockaddr_in6 *addr6 = (struct WS_sockaddr_in6 *)addr; + size_t len; + + buffer[0] = 0; + if (addr_len < sizeof(struct WS_sockaddr_in6)) return -1; + if (addr6->sin6_port) + strcpy( buffer, "[" ); + len = strlen( buffer ); + if (!WS_inet_ntop( WS_AF_INET6, &addr6->sin6_addr, &buffer[len], sizeof(buffer) - len )) + { + SetLastError( WSAEINVAL ); + return -1; + } + if (addr6->sin6_scope_id) + sprintf( buffer + strlen( buffer ), "%%%u", addr6->sin6_scope_id ); + if (addr6->sin6_port) + sprintf( buffer + strlen( buffer ), "]:%u", ntohs( addr6->sin6_port ) ); + break; + } + + default: + SetLastError( WSAEINVAL ); + return -1; + } + + size = strlen( buffer ) + 1; + + if (*string_len < size) + { + *string_len = size; + SetLastError( WSAEFAULT ); + return -1; + } + + TRACE( "=> %s, %u bytes\n", debugstr_a(buffer), size ); + *string_len = size; + strcpy( string, buffer ); + return 0; +} + + +/*********************************************************************** + * WSAAddressToStringW (ws2_32.@) + */ +int WINAPI WSAAddressToStringW( struct WS_sockaddr *addr, DWORD addr_len, + WSAPROTOCOL_INFOW *info, WCHAR *string, DWORD *string_len ) +{ + INT ret; + char buf[54]; /* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */ + + TRACE( "(%p, %d, %p, %p, %p)\n", addr, addr_len, info, string, string_len ); + + if ((ret = WSAAddressToStringA( addr, addr_len, NULL, buf, string_len ))) return ret; + + MultiByteToWideChar( CP_ACP, 0, buf, *string_len, string, *string_len ); + TRACE( "=> %s, %u chars\n", debugstr_w(string), *string_len ); + return 0; +} + + +/*********************************************************************** + * inet_addr (ws2_32.11) + */ +WS_u_long WINAPI WS_inet_addr( const char *cp ) +{ + if (!cp) return INADDR_NONE; + return inet_addr( cp ); +} diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 2776e2f0014..3d930d13bb6 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -40,10 +40,6 @@ # define sipx_node sipx_addr.x_host.c_host #endif /* __FreeBSD__ */
-#ifndef INADDR_NONE -#define INADDR_NONE ~0UL -#endif - #if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) /* TCP_KEEPALIVE is the Mac OS name for TCP_KEEPIDLE */ #define TCP_KEEPIDLE TCP_KEEPALIVE @@ -3896,16 +3892,6 @@ int WINAPI WSAHtons(SOCKET s, WS_u_short hostshort, WS_u_short *lpnetshort) }
-/*********************************************************************** - * inet_addr (WS2_32.11) - */ -WS_u_long WINAPI WS_inet_addr(const char *cp) -{ - if (!cp) return INADDR_NONE; - return inet_addr(cp); -} - - /*********************************************************************** * ntohl (WS2_32.14) */ @@ -3924,23 +3910,6 @@ WS_u_short WINAPI WS_ntohs(WS_u_short netshort) }
-/*********************************************************************** - * inet_ntoa (WS2_32.12) - */ -char* WINAPI WS_inet_ntoa(struct WS_in_addr in) -{ - unsigned int long_ip = ntohl(in.WS_s_addr); - struct per_thread_data *data = get_per_thread_data(); - - sprintf( data->ntoa_buffer, "%u.%u.%u.%u", - (long_ip >> 24) & 0xff, - (long_ip >> 16) & 0xff, - (long_ip >> 8) & 0xff, - long_ip & 0xff); - - return data->ntoa_buffer; -} - static const char *debugstr_wsaioctl(DWORD code) { const char *name = NULL, *buf_type, *family; @@ -6449,386 +6418,6 @@ int WINAPI WSARemoveServiceClass(LPGUID info) return SOCKET_ERROR; }
-/*********************************************************************** - * inet_ntop (WS2_32.@) - */ -PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, SIZE_T len ) -{ - NTSTATUS status; - ULONG size = min( len, (ULONG)-1 ); - - TRACE("family %d, addr (%p), buffer (%p), len %ld\n", family, addr, buffer, len); - if (!buffer) - { - SetLastError( STATUS_INVALID_PARAMETER ); - return NULL; - } - - switch (family) - { - case WS_AF_INET: - { - status = RtlIpv4AddressToStringExA( (IN_ADDR *)addr, 0, buffer, &size ); - break; - } - case WS_AF_INET6: - { - status = RtlIpv6AddressToStringExA( (IN6_ADDR *)addr, 0, 0, buffer, &size ); - break; - } - default: - SetLastError( WSAEAFNOSUPPORT ); - return NULL; - } - - if (status == STATUS_SUCCESS) return buffer; - SetLastError( STATUS_INVALID_PARAMETER ); - return NULL; -} - -/*********************************************************************** -* inet_pton (WS2_32.@) -*/ -INT WINAPI WS_inet_pton(INT family, const char *addr, void *buffer) -{ - NTSTATUS status; - const char *terminator; - - TRACE("family %d, addr %s, buffer (%p)\n", family, debugstr_a(addr), buffer); - - if (!addr || !buffer) - { - SetLastError(WSAEFAULT); - return SOCKET_ERROR; - } - - switch (family) - { - case WS_AF_INET: - status = RtlIpv4StringToAddressA(addr, TRUE, &terminator, buffer); - break; - case WS_AF_INET6: - status = RtlIpv6StringToAddressA(addr, &terminator, buffer); - break; - default: - SetLastError(WSAEAFNOSUPPORT); - return SOCKET_ERROR; - } - - return (status == STATUS_SUCCESS && *terminator == 0); -} - -/*********************************************************************** -* InetPtonW (WS2_32.@) -*/ -INT WINAPI InetPtonW(INT family, PCWSTR addr, PVOID buffer) -{ - char *addrA; - int len; - INT ret; - - TRACE("family %d, addr %s, buffer (%p)\n", family, debugstr_w(addr), buffer); - - if (!addr) - { - SetLastError(WSAEFAULT); - return SOCKET_ERROR; - } - - len = WideCharToMultiByte(CP_ACP, 0, addr, -1, NULL, 0, NULL, NULL); - if (!(addrA = HeapAlloc(GetProcessHeap(), 0, len))) - { - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; - } - WideCharToMultiByte(CP_ACP, 0, addr, -1, addrA, len, NULL, NULL); - - ret = WS_inet_pton(family, addrA, buffer); - if (!ret) SetLastError(WSAEINVAL); - - HeapFree(GetProcessHeap(), 0, addrA); - return ret; -} - -/*********************************************************************** - * InetNtopW (WS2_32.@) - */ -PCWSTR WINAPI InetNtopW(INT family, PVOID addr, PWSTR buffer, SIZE_T len) -{ - char bufferA[WS_INET6_ADDRSTRLEN]; - PWSTR ret = NULL; - - TRACE("family %d, addr (%p), buffer (%p), len %ld\n", family, addr, buffer, len); - - if (WS_inet_ntop(family, addr, bufferA, sizeof(bufferA))) - { - if (MultiByteToWideChar(CP_ACP, 0, bufferA, -1, buffer, len)) - ret = buffer; - else - SetLastError(ERROR_INVALID_PARAMETER); - } - return ret; -} - -/*********************************************************************** - * WSAStringToAddressA (WS2_32.80) - */ -INT WINAPI WSAStringToAddressA(LPSTR AddressString, - INT AddressFamily, - LPWSAPROTOCOL_INFOA lpProtocolInfo, - LPSOCKADDR lpAddress, - LPINT lpAddressLength) -{ - INT res=0; - NTSTATUS status; - - TRACE( "(%s, %x, %p, %p, %p)\n", debugstr_a(AddressString), AddressFamily, - lpProtocolInfo, lpAddress, lpAddressLength ); - - if (!lpAddressLength || !lpAddress) return SOCKET_ERROR; - - if (!AddressString) - { - SetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - - if (lpProtocolInfo) - FIXME("ProtocolInfo not implemented.\n"); - - switch(AddressFamily) - { - case WS_AF_INET: - { - SOCKADDR_IN *addr4 = (SOCKADDR_IN *)lpAddress; - - /* If lpAddressLength is too small, tell caller the size we need */ - if (*lpAddressLength < sizeof(SOCKADDR_IN)) - { - *lpAddressLength = sizeof(SOCKADDR_IN); - res = WSAEFAULT; - break; - } - memset(lpAddress, 0, sizeof(SOCKADDR_IN)); - - status = RtlIpv4StringToAddressExA(AddressString, FALSE, &addr4->sin_addr, &addr4->sin_port); - if (status != STATUS_SUCCESS) - { - res = WSAEINVAL; - break; - } - addr4->sin_family = WS_AF_INET; - *lpAddressLength = sizeof(SOCKADDR_IN); - break; - } - case WS_AF_INET6: - { - SOCKADDR_IN6 *addr6 = (SOCKADDR_IN6 *)lpAddress; - - /* If lpAddressLength is too small, tell caller the size we need */ - if (*lpAddressLength < sizeof(SOCKADDR_IN6)) - { - *lpAddressLength = sizeof(SOCKADDR_IN6); - res = WSAEFAULT; - break; - } - memset(lpAddress, 0, sizeof(SOCKADDR_IN6)); - - status = RtlIpv6StringToAddressExA(AddressString, &addr6->sin6_addr, &addr6->sin6_scope_id, &addr6->sin6_port); - if (status != STATUS_SUCCESS) - { - res = WSAEINVAL; - break; - } - addr6->sin6_family = WS_AF_INET6; - *lpAddressLength = sizeof(SOCKADDR_IN6); - break; - } - default: - /* According to MSDN, only AF_INET and AF_INET6 are supported. */ - TRACE("Unsupported address family specified: %d.\n", AddressFamily); - res = WSAEINVAL; - } - - if (!res) return 0; - SetLastError(res); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAStringToAddressW (WS2_32.81) - * - * FIXME: Does anybody know if this function allows using Hebrew/Arabic/Chinese... digits? - * If this should be the case, it would be required to map these digits - * to Unicode digits (0-9) using FoldString first. - */ -INT WINAPI WSAStringToAddressW(LPWSTR AddressString, - INT AddressFamily, - LPWSAPROTOCOL_INFOW lpProtocolInfo, - LPSOCKADDR lpAddress, - LPINT lpAddressLength) -{ - INT sBuffer,res=0; - LPSTR workBuffer=NULL; - WSAPROTOCOL_INFOA infoA; - LPWSAPROTOCOL_INFOA lpProtoInfoA = NULL; - - TRACE( "(%s, %x, %p, %p, %p)\n", debugstr_w(AddressString), AddressFamily, lpProtocolInfo, - lpAddress, lpAddressLength ); - - if (!lpAddressLength || !lpAddress) return SOCKET_ERROR; - - /* if ProtocolInfo is available - convert to ANSI variant */ - if (lpProtocolInfo) - { - lpProtoInfoA = &infoA; - memcpy( lpProtoInfoA, lpProtocolInfo, FIELD_OFFSET( WSAPROTOCOL_INFOA, szProtocol ) ); - - if (!WideCharToMultiByte( CP_ACP, 0, lpProtocolInfo->szProtocol, -1, - lpProtoInfoA->szProtocol, WSAPROTOCOL_LEN+1, NULL, NULL )) - { - SetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - } - - if (AddressString) - { - /* Translate AddressString to ANSI code page - assumes that only - standard digits 0-9 are used with this API call */ - sBuffer = WideCharToMultiByte( CP_ACP, 0, AddressString, -1, NULL, 0, NULL, NULL ); - workBuffer = HeapAlloc( GetProcessHeap(), 0, sBuffer ); - - if (workBuffer) - { - WideCharToMultiByte( CP_ACP, 0, AddressString, -1, workBuffer, sBuffer, NULL, NULL ); - res = WSAStringToAddressA(workBuffer,AddressFamily,lpProtoInfoA, - lpAddress,lpAddressLength); - HeapFree( GetProcessHeap(), 0, workBuffer ); - return res; - } - else - res = WSA_NOT_ENOUGH_MEMORY; - } - else - res = WSAEINVAL; - - SetLastError(res); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAAddressToStringA (WS2_32.27) - * - * See WSAAddressToStringW - */ -INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len, - LPWSAPROTOCOL_INFOA info, LPSTR string, - LPDWORD lenstr ) -{ - DWORD size; - CHAR buffer[54]; /* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */ - CHAR *p; - - TRACE( "(%p, %d, %p, %p, %p)\n", sockaddr, len, info, string, lenstr ); - - if (!sockaddr) return SOCKET_ERROR; - if (!string || !lenstr) return SOCKET_ERROR; - - switch(sockaddr->sa_family) - { - case WS_AF_INET: - { - unsigned int long_ip = ntohl(((SOCKADDR_IN *)sockaddr)->sin_addr.WS_s_addr); - if (len < sizeof(SOCKADDR_IN)) return SOCKET_ERROR; - sprintf( buffer, "%u.%u.%u.%u:%u", - (long_ip >> 24) & 0xff, - (long_ip >> 16) & 0xff, - (long_ip >> 8) & 0xff, - long_ip & 0xff, - ntohs( ((SOCKADDR_IN *)sockaddr)->sin_port ) ); - - p = strchr( buffer, ':' ); - if (!((SOCKADDR_IN *)sockaddr)->sin_port) *p = 0; - break; - } - case WS_AF_INET6: - { - struct WS_sockaddr_in6 *sockaddr6 = (LPSOCKADDR_IN6) sockaddr; - size_t slen; - - buffer[0] = 0; - if (len < sizeof(SOCKADDR_IN6)) return SOCKET_ERROR; - if ((sockaddr6->sin6_port)) - strcpy(buffer, "["); - slen = strlen(buffer); - if (!WS_inet_ntop(WS_AF_INET6, &sockaddr6->sin6_addr, &buffer[slen], sizeof(buffer) - slen)) - { - SetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - if ((sockaddr6->sin6_scope_id)) - sprintf(buffer+strlen(buffer), "%%%u", sockaddr6->sin6_scope_id); - if ((sockaddr6->sin6_port)) - sprintf(buffer+strlen(buffer), "]:%u", ntohs(sockaddr6->sin6_port)); - break; - } - - default: - SetLastError(WSAEINVAL); - return SOCKET_ERROR; - } - - size = strlen( buffer ) + 1; - - if (*lenstr < size) - { - *lenstr = size; - SetLastError(WSAEFAULT); - return SOCKET_ERROR; - } - - TRACE("=> %s,%u bytes\n", debugstr_a(buffer), size); - *lenstr = size; - strcpy( string, buffer ); - return 0; -} - -/*********************************************************************** - * WSAAddressToStringW (WS2_32.28) - * - * Convert a sockaddr address into a readable address string. - * - * PARAMS - * sockaddr [I] Pointer to a sockaddr structure. - * len [I] Size of the sockaddr structure. - * info [I] Pointer to a WSAPROTOCOL_INFOW structure (optional). - * string [I/O] Pointer to a buffer to receive the address string. - * lenstr [I/O] Size of the receive buffer in WCHARs. - * - * RETURNS - * Success: 0 - * Failure: SOCKET_ERROR - * - * NOTES - * The 'info' parameter is ignored. - */ -INT WINAPI WSAAddressToStringW( LPSOCKADDR sockaddr, DWORD len, - LPWSAPROTOCOL_INFOW info, LPWSTR string, - LPDWORD lenstr ) -{ - INT ret; - char buf[54]; /* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */ - - TRACE( "(%p, %d, %p, %p, %p)\n", sockaddr, len, info, string, lenstr ); - - if ((ret = WSAAddressToStringA(sockaddr, len, NULL, buf, lenstr))) return ret; - - MultiByteToWideChar(CP_ACP, 0, buf, *lenstr, string, *lenstr); - TRACE("=> %s,%u chars\n", debugstr_w(string), *lenstr); - return 0; -} - /*********************************************************************** * WSAEnumNameSpaceProvidersA (WS2_32.34) */
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/protocol.c | 90 +++++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 97 ------------------------------------------ 2 files changed, 90 insertions(+), 97 deletions(-)
diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index fe30f26db53..abbe5738b88 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -2022,3 +2022,93 @@ WS_u_long WINAPI WS_inet_addr( const char *cp ) if (!cp) return INADDR_NONE; return inet_addr( cp ); } + + +/*********************************************************************** + * htonl (ws2_32.8) + */ +WS_u_long WINAPI WS_htonl( WS_u_long hostlong ) +{ + return htonl( hostlong ); +} + + +/*********************************************************************** + * htons (ws2_32.9) + */ +WS_u_short WINAPI WS_htons( WS_u_short hostshort ) +{ + return htons( hostshort ); +} + + +/*********************************************************************** + * WSAHtonl (ws2_32.@) + */ +int WINAPI WSAHtonl( SOCKET s, WS_u_long hostlong, WS_u_long *netlong ) +{ + if (netlong) + { + *netlong = htonl( hostlong ); + return 0; + } + SetLastError( WSAEFAULT ); + return -1; +} + + +/*********************************************************************** + * WSAHtons (ws2_32.@) + */ +int WINAPI WSAHtons( SOCKET s, WS_u_short hostshort, WS_u_short *netshort ) +{ + if (netshort) + { + *netshort = htons( hostshort ); + return 0; + } + SetLastError( WSAEFAULT ); + return -1; +} + + +/*********************************************************************** + * ntohl (ws2_32.14) + */ +WS_u_long WINAPI WS_ntohl( WS_u_long netlong ) +{ + return ntohl( netlong ); +} + + +/*********************************************************************** + * ntohs (ws2_32.15) + */ +WS_u_short WINAPI WS_ntohs( WS_u_short netshort ) +{ + return ntohs( netshort ); +} + + +/*********************************************************************** + * WSANtohl (ws2_32.@) + */ +int WINAPI WSANtohl( SOCKET s, WS_u_long netlong, WS_u_long *hostlong ) +{ + if (!hostlong) return WSAEFAULT; + + *hostlong = ntohl( netlong ); + return 0; +} + + +/*********************************************************************** + * WSANtohs (ws2_32.@) + */ +int WINAPI WSANtohs( SOCKET s, WS_u_short netshort, WS_u_short *hostshort ) +{ + if (!hostshort) return WSAEFAULT; + + *hostshort = ntohs( netshort ); + return 0; +} diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 3d930d13bb6..3c63b93d737 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3837,78 +3837,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, } /* end switch(level) */ }
-/*********************************************************************** - * htonl (WS2_32.8) - */ -WS_u_long WINAPI WS_htonl(WS_u_long hostlong) -{ - return htonl(hostlong); -} - - -/*********************************************************************** - * htons (WS2_32.9) - */ -WS_u_short WINAPI WS_htons(WS_u_short hostshort) -{ - return htons(hostshort); -} - -/*********************************************************************** - * WSAHtonl (WS2_32.46) - * From MSDN description of error codes, this function should also - * check if WinSock has been initialized and the socket is a valid - * socket. But why? This function only translates a host byte order - * u_long into a network byte order u_long... - */ -int WINAPI WSAHtonl(SOCKET s, WS_u_long hostlong, WS_u_long *lpnetlong) -{ - if (lpnetlong) - { - *lpnetlong = htonl(hostlong); - return 0; - } - SetLastError(WSAEFAULT); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAHtons (WS2_32.47) - * From MSDN description of error codes, this function should also - * check if WinSock has been initialized and the socket is a valid - * socket. But why? This function only translates a host byte order - * u_short into a network byte order u_short... - */ -int WINAPI WSAHtons(SOCKET s, WS_u_short hostshort, WS_u_short *lpnetshort) -{ - - if (lpnetshort) - { - *lpnetshort = htons(hostshort); - return 0; - } - SetLastError(WSAEFAULT); - return SOCKET_ERROR; -} - - -/*********************************************************************** - * ntohl (WS2_32.14) - */ -WS_u_long WINAPI WS_ntohl(WS_u_long netlong) -{ - return ntohl(netlong); -} - - -/*********************************************************************** - * ntohs (WS2_32.15) - */ -WS_u_short WINAPI WS_ntohs(WS_u_short netshort) -{ - return ntohs(netshort); -} -
static const char *debugstr_wsaioctl(DWORD code) { @@ -6544,31 +6472,6 @@ INT WINAPI WSALookupServiceNextW( HANDLE lookup, DWORD flags, LPDWORD len, LPWSA return SOCKET_ERROR; }
-/*********************************************************************** - * WSANtohl (WS2_32.64) - */ -INT WINAPI WSANtohl( SOCKET s, WS_u_long netlong, WS_u_long* lphostlong ) -{ - TRACE( "(%04lx 0x%08x %p)\n", s, netlong, lphostlong ); - - if (!lphostlong) return WSAEFAULT; - - *lphostlong = ntohl( netlong ); - return 0; -} - -/*********************************************************************** - * WSANtohs (WS2_32.65) - */ -INT WINAPI WSANtohs( SOCKET s, WS_u_short netshort, WS_u_short* lphostshort ) -{ - TRACE( "(%04lx 0x%08x %p)\n", s, netshort, lphostshort ); - - if (!lphostshort) return WSAEFAULT; - - *lphostshort = ntohs( netshort ); - return 0; -}
/*********************************************************************** * WSAProviderConfigChange (WS2_32.66)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/protocol.c | 337 +++++++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 333 ---------------------------------------- 2 files changed, 337 insertions(+), 333 deletions(-)
diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index abbe5738b88..64af105f0b9 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -2112,3 +2112,340 @@ int WINAPI WSANtohs( SOCKET s, WS_u_short netshort, WS_u_short *hostshort ) *hostshort = ntohs( netshort ); return 0; } + + +/*********************************************************************** + * WSAInstallServiceClassA (ws2_32.@) + */ +int WINAPI WSAInstallServiceClassA( WSASERVICECLASSINFOA *info ) +{ + FIXME( "Request to install service %s\n", debugstr_a(info->lpszServiceClassName) ); + SetLastError( WSAEACCES ); + return -1; +} + + +/*********************************************************************** + * WSAInstallServiceClassW (ws2_32.@) + */ +int WINAPI WSAInstallServiceClassW( WSASERVICECLASSINFOW *info ) +{ + FIXME( "Request to install service %s\n", debugstr_w(info->lpszServiceClassName) ); + SetLastError( WSAEACCES ); + return -1; +} + + +/*********************************************************************** + * WSARemoveServiceClass (ws2_32.@) + */ +int WINAPI WSARemoveServiceClass( GUID *info ) +{ + FIXME( "Request to remove service %s\n", debugstr_guid(info) ); + SetLastError( WSATYPE_NOT_FOUND ); + return -1; +} + + +/*********************************************************************** + * WSAGetServiceClassInfoA (ws2_32.@) + */ +int WINAPI WSAGetServiceClassInfoA( GUID *provider, GUID *service, DWORD *len, + WSASERVICECLASSINFOA *info ) +{ + FIXME( "(%s %s %p %p) Stub!\n", debugstr_guid(provider), debugstr_guid(service), len, info ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSAGetServiceClassInfoW (ws2_32.@) + */ +int WINAPI WSAGetServiceClassInfoW( GUID *provider, GUID *service, DWORD *len, + WSASERVICECLASSINFOW *info ) +{ + FIXME( "(%s %s %p %p) Stub!\n", debugstr_guid(provider), debugstr_guid(service), len, info ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSAGetServiceClassNameByClassIdA (ws2_32.@) + */ +int WINAPI WSAGetServiceClassNameByClassIdA( GUID *class, char *service, DWORD *len ) +{ + FIXME( "(%s %p %p) Stub!\n", debugstr_guid(class), service, len ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSAGetServiceClassNameByClassIdW (ws2_32.@) + */ +int WINAPI WSAGetServiceClassNameByClassIdW( GUID *class, WCHAR *service, DWORD *len ) +{ + FIXME( "(%s %p %p) Stub!\n", debugstr_guid(class), service, len ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSALookupServiceBeginA (ws2_32.@) + */ +int WINAPI WSALookupServiceBeginA( WSAQUERYSETA *query, DWORD flags, HANDLE *lookup ) +{ + FIXME( "(%p 0x%08x %p) Stub!\n", query, flags, lookup ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSALookupServiceBeginW (ws2_32.@) + */ +int WINAPI WSALookupServiceBeginW( WSAQUERYSETW *query, DWORD flags, HANDLE *lookup ) +{ + FIXME( "(%p 0x%08x %p) Stub!\n", query, flags, lookup ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSALookupServiceEnd (ws2_32.@) + */ +int WINAPI WSALookupServiceEnd( HANDLE lookup ) +{ + FIXME("(%p) Stub!\n", lookup ); + return 0; +} + + +/*********************************************************************** + * WSALookupServiceNextA (ws2_32.@) + */ +int WINAPI WSALookupServiceNextA( HANDLE lookup, DWORD flags, DWORD *len, WSAQUERYSETA *results ) +{ + FIXME( "(%p 0x%08x %p %p) Stub!\n", lookup, flags, len, results ); + SetLastError( WSA_E_NO_MORE ); + return -1; +} + + +/*********************************************************************** + * WSALookupServiceNextW (ws2_32.@) + */ +int WINAPI WSALookupServiceNextW( HANDLE lookup, DWORD flags, DWORD *len, WSAQUERYSETW *results ) +{ + FIXME( "(%p 0x%08x %p %p) Stub!\n", lookup, flags, len, results ); + SetLastError( WSA_E_NO_MORE ); + return -1; +} + + +/*********************************************************************** + * WSASetServiceA (ws2_32.@) + */ +int WINAPI WSASetServiceA( WSAQUERYSETA *query, WSAESETSERVICEOP operation, DWORD flags ) +{ + FIXME( "(%p 0x%08x 0x%08x) Stub!\n", query, operation, flags ); + return 0; +} + + +/*********************************************************************** + * WSASetServiceW (ws2_32.@) + */ +int WINAPI WSASetServiceW( WSAQUERYSETW *query, WSAESETSERVICEOP operation, DWORD flags ) +{ + FIXME( "(%p 0x%08x 0x%08x) Stub!\n", query, operation, flags ); + return 0; +} + + +/*********************************************************************** + * WSAEnumNameSpaceProvidersA (ws2_32.@) + */ +int WINAPI WSAEnumNameSpaceProvidersA( DWORD *len, WSANAMESPACE_INFOA *buffer ) +{ + FIXME( "(%p %p) Stub!\n", len, buffer ); + return 0; +} + + +/*********************************************************************** + * WSAEnumNameSpaceProvidersW (ws2_32.@) + */ +int WINAPI WSAEnumNameSpaceProvidersW( DWORD *len, WSANAMESPACE_INFOW *buffer ) +{ + FIXME( "(%p %p) Stub!\n", len, buffer ); + return 0; +} + + +/*********************************************************************** + * WSAProviderConfigChange (ws2_32.@) + */ +int WINAPI WSAProviderConfigChange( HANDLE *handle, OVERLAPPED *overlapped, + LPWSAOVERLAPPED_COMPLETION_ROUTINE completion ) +{ + FIXME( "(%p %p %p) Stub!\n", handle, overlapped, completion ); + return -1; +} + + +/*********************************************************************** + * WSANSPIoctl (ws2_32.@) + */ +int WINAPI WSANSPIoctl( HANDLE lookup, DWORD code, void *in_buffer, + DWORD in_size, void *out_buffer, DWORD out_size, + DWORD *ret_size, WSACOMPLETION *completion ) +{ + FIXME( "(%p, 0x%08x, %p, 0x%08x, %p, 0x%08x, %p, %p) Stub!\n", lookup, code, + in_buffer, in_size, out_buffer, out_size, ret_size, completion ); + SetLastError( WSA_NOT_ENOUGH_MEMORY ); + return -1; +} + + +/*********************************************************************** + * WSCEnableNSProvider (ws2_32.@) + */ +int WINAPI WSCEnableNSProvider( GUID *provider, BOOL enable ) +{ + FIXME( "(%s 0x%08x) Stub!\n", debugstr_guid(provider), enable ); + return 0; +} + + +/*********************************************************************** + * WSCGetProviderInfo (ws2_32.@) + */ +int WINAPI WSCGetProviderInfo( GUID *provider, WSC_PROVIDER_INFO_TYPE info_type, + BYTE *info, size_t *len, DWORD flags, int *errcode ) +{ + FIXME( "(%s 0x%08x %p %p 0x%08x %p) Stub!\n", + debugstr_guid(provider), info_type, info, len, flags, errcode ); + + if (!errcode) + return -1; + + if (!provider) + { + *errcode = WSAEFAULT; + return -1; + } + + *errcode = WSANO_RECOVERY; + return -1; +} + + +/*********************************************************************** + * WSCGetProviderPath (ws2_32.@) + */ +int WINAPI WSCGetProviderPath( GUID *provider, WCHAR *path, int *len, int *errcode ) +{ + FIXME( "(%s %p %p %p) Stub!\n", debugstr_guid(provider), path, len, errcode ); + + if (!provider || !len) + { + if (errcode) + *errcode = WSAEFAULT; + return -1; + } + + if (*len <= 0) + { + if (errcode) + *errcode = WSAEINVAL; + return -1; + } + + return 0; +} + + +/*********************************************************************** + * WSCInstallNameSpace (ws2_32.@) + */ +int WINAPI WSCInstallNameSpace( WCHAR *identifier, WCHAR *path, DWORD namespace, + DWORD version, GUID *provider ) +{ + FIXME( "(%s %s 0x%08x 0x%08x %s) Stub!\n", debugstr_w(identifier), debugstr_w(path), + namespace, version, debugstr_guid(provider) ); + return 0; +} + + +/*********************************************************************** + * WSCUnInstallNameSpace (ws2_32.@) + */ +int WINAPI WSCUnInstallNameSpace( GUID *provider ) +{ + FIXME( "(%s) Stub!\n", debugstr_guid(provider) ); + return NO_ERROR; +} + + +/*********************************************************************** + * WSCWriteProviderOrder (ws2_32.@) + */ +int WINAPI WSCWriteProviderOrder( DWORD *entry, DWORD number ) +{ + FIXME( "(%p 0x%08x) Stub!\n", entry, number ); + return 0; +} + + +/*********************************************************************** + * WSCInstallProvider (ws2_32.@) + */ +int WINAPI WSCInstallProvider( GUID *provider, const WCHAR *path, + WSAPROTOCOL_INFOW *protocol_info, DWORD count, int *err ) +{ + FIXME( "(%s, %s, %p, %d, %p): stub !\n", debugstr_guid(provider), + debugstr_w(path), protocol_info, count, err ); + *err = 0; + return 0; +} + + +/*********************************************************************** + * WSCDeinstallProvider (ws2_32.@) + */ +int WINAPI WSCDeinstallProvider( GUID *provider, int *err ) +{ + FIXME( "(%s, %p): stub !\n", debugstr_guid(provider), err ); + *err = 0; + return 0; +} + + +/*********************************************************************** + * WSCSetApplicationCategory (ws2_32.@) + */ +int WINAPI WSCSetApplicationCategory( const WCHAR *path, DWORD len, const WCHAR *extra, DWORD extralen, + DWORD lspcat, DWORD *prev_lspcat, int *err ) +{ + FIXME( "(%s %d %s %d %d %p) Stub!\n", debugstr_w(path), len, debugstr_w(extra), + extralen, lspcat, prev_lspcat ); + return 0; +} + + +/*********************************************************************** + * WSCEnumProtocols (ws2_32.@) + */ +int WINAPI WSCEnumProtocols( int *protocols, WSAPROTOCOL_INFOW *info, DWORD *len, int *err ) +{ + int ret = WSAEnumProtocolsW( protocols, info, len ); + + if (ret == SOCKET_ERROR) *err = WSAENOBUFS; + + return ret; +} diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 3c63b93d737..5dc725c4a58 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -6199,33 +6199,6 @@ INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, lpOverlapped, lpCompletionRoutine, NULL ); }
-/*********************************************************************** - * WSCInstallProvider (WS2_32.88) - */ -INT WINAPI WSCInstallProvider( const LPGUID lpProviderId, - LPCWSTR lpszProviderDllPath, - const LPWSAPROTOCOL_INFOW lpProtocolInfoList, - DWORD dwNumberOfEntries, - LPINT lpErrno ) -{ - FIXME("(%s, %s, %p, %d, %p): stub !\n", debugstr_guid(lpProviderId), - debugstr_w(lpszProviderDllPath), lpProtocolInfoList, - dwNumberOfEntries, lpErrno); - *lpErrno = 0; - return 0; -} - - -/*********************************************************************** - * WSCDeinstallProvider (WS2_32.83) - */ -INT WINAPI WSCDeinstallProvider(LPGUID lpProviderId, LPINT lpErrno) -{ - FIXME("(%s, %p): stub !\n", debugstr_guid(lpProviderId), lpErrno); - *lpErrno = 0; - return 0; -} -
/*********************************************************************** * WSAAccept (WS2_32.26) @@ -6316,53 +6289,6 @@ int WINAPI WSADuplicateSocketW( SOCKET s, DWORD dwProcessId, LPWSAPROTOCOL_INFOW return WS_DuplicateSocket(TRUE, s, dwProcessId, lpProtocolInfo); }
-/*********************************************************************** - * WSAInstallServiceClassA (WS2_32.48) - */ -int WINAPI WSAInstallServiceClassA(LPWSASERVICECLASSINFOA info) -{ - FIXME("Request to install service %s\n",debugstr_a(info->lpszServiceClassName)); - SetLastError(WSAEACCES); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAInstallServiceClassW (WS2_32.49) - */ -int WINAPI WSAInstallServiceClassW(LPWSASERVICECLASSINFOW info) -{ - FIXME("Request to install service %s\n",debugstr_w(info->lpszServiceClassName)); - SetLastError(WSAEACCES); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSARemoveServiceClass (WS2_32.70) - */ -int WINAPI WSARemoveServiceClass(LPGUID info) -{ - FIXME("Request to remove service %s\n", debugstr_guid(info)); - SetLastError(WSATYPE_NOT_FOUND); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAEnumNameSpaceProvidersA (WS2_32.34) - */ -INT WINAPI WSAEnumNameSpaceProvidersA( LPDWORD len, LPWSANAMESPACE_INFOA buffer ) -{ - FIXME( "(%p %p) Stub!\n", len, buffer ); - return 0; -} - -/*********************************************************************** - * WSAEnumNameSpaceProvidersW (WS2_32.35) - */ -INT WINAPI WSAEnumNameSpaceProvidersW( LPDWORD len, LPWSANAMESPACE_INFOW buffer ) -{ - FIXME( "(%p %p) Stub!\n", len, buffer ); - return 0; -}
/*********************************************************************** * WSAGetQOSByName (WS2_32.41) @@ -6373,115 +6299,6 @@ BOOL WINAPI WSAGetQOSByName( SOCKET s, LPWSABUF lpQOSName, LPQOS lpQOS ) return FALSE; }
-/*********************************************************************** - * WSAGetServiceClassInfoA (WS2_32.42) - */ -INT WINAPI WSAGetServiceClassInfoA( LPGUID provider, LPGUID service, LPDWORD len, - LPWSASERVICECLASSINFOA info ) -{ - FIXME( "(%s %s %p %p) Stub!\n", debugstr_guid(provider), debugstr_guid(service), - len, info ); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAGetServiceClassInfoW (WS2_32.43) - */ -INT WINAPI WSAGetServiceClassInfoW( LPGUID provider, LPGUID service, LPDWORD len, - LPWSASERVICECLASSINFOW info ) -{ - FIXME( "(%s %s %p %p) Stub!\n", debugstr_guid(provider), debugstr_guid(service), - len, info ); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAGetServiceClassNameByClassIdA (WS2_32.44) - */ -INT WINAPI WSAGetServiceClassNameByClassIdA( LPGUID class, LPSTR service, LPDWORD len ) -{ - FIXME( "(%s %p %p) Stub!\n", debugstr_guid(class), service, len ); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSAGetServiceClassNameByClassIdW (WS2_32.45) - */ -INT WINAPI WSAGetServiceClassNameByClassIdW( LPGUID class, LPWSTR service, LPDWORD len ) -{ - FIXME( "(%s %p %p) Stub!\n", debugstr_guid(class), service, len ); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSALookupServiceBeginA (WS2_32.59) - */ -INT WINAPI WSALookupServiceBeginA( LPWSAQUERYSETA lpqsRestrictions, - DWORD dwControlFlags, - LPHANDLE lphLookup) -{ - FIXME("(%p 0x%08x %p) Stub!\n", lpqsRestrictions, dwControlFlags, - lphLookup); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSALookupServiceBeginW (WS2_32.60) - */ -INT WINAPI WSALookupServiceBeginW( LPWSAQUERYSETW lpqsRestrictions, - DWORD dwControlFlags, - LPHANDLE lphLookup) -{ - FIXME("(%p 0x%08x %p) Stub!\n", lpqsRestrictions, dwControlFlags, - lphLookup); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSALookupServiceEnd (WS2_32.61) - */ -INT WINAPI WSALookupServiceEnd( HANDLE lookup ) -{ - FIXME("(%p) Stub!\n", lookup ); - return 0; -} - -/*********************************************************************** - * WSALookupServiceNextA (WS2_32.62) - */ -INT WINAPI WSALookupServiceNextA( HANDLE lookup, DWORD flags, LPDWORD len, LPWSAQUERYSETA results ) -{ - FIXME( "(%p 0x%08x %p %p) Stub!\n", lookup, flags, len, results ); - SetLastError(WSA_E_NO_MORE); - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSALookupServiceNextW (WS2_32.63) - */ -INT WINAPI WSALookupServiceNextW( HANDLE lookup, DWORD flags, LPDWORD len, LPWSAQUERYSETW results ) -{ - FIXME( "(%p 0x%08x %p %p) Stub!\n", lookup, flags, len, results ); - SetLastError(WSA_E_NO_MORE); - return SOCKET_ERROR; -} - - -/*********************************************************************** - * WSAProviderConfigChange (WS2_32.66) - */ -INT WINAPI WSAProviderConfigChange( LPHANDLE handle, LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion ) -{ - FIXME( "(%p %p %p) Stub!\n", handle, overlapped, completion ); - return SOCKET_ERROR; -}
/*********************************************************************** * WSARecvDisconnect (WS2_32.68) @@ -6493,130 +6310,6 @@ INT WINAPI WSARecvDisconnect( SOCKET s, LPWSABUF disconnectdata ) return WS_shutdown( s, SD_RECEIVE ); }
-/*********************************************************************** - * WSASetServiceA (WS2_32.76) - */ -INT WINAPI WSASetServiceA( LPWSAQUERYSETA query, WSAESETSERVICEOP operation, DWORD flags ) -{ - FIXME( "(%p 0x%08x 0x%08x) Stub!\n", query, operation, flags ); - return 0; -} - -/*********************************************************************** - * WSASetServiceW (WS2_32.77) - */ -INT WINAPI WSASetServiceW( LPWSAQUERYSETW query, WSAESETSERVICEOP operation, DWORD flags ) -{ - FIXME( "(%p 0x%08x 0x%08x) Stub!\n", query, operation, flags ); - return 0; -} - -/*********************************************************************** - * WSCEnableNSProvider (WS2_32.84) - */ -INT WINAPI WSCEnableNSProvider( LPGUID provider, BOOL enable ) -{ - FIXME( "(%s 0x%08x) Stub!\n", debugstr_guid(provider), enable ); - return 0; -} - -/*********************************************************************** - * WSCGetProviderInfo - */ -INT WINAPI WSCGetProviderInfo( LPGUID provider, WSC_PROVIDER_INFO_TYPE info_type, - PBYTE info, size_t* len, DWORD flags, LPINT errcode ) -{ - FIXME( "(%s 0x%08x %p %p 0x%08x %p) Stub!\n", - debugstr_guid(provider), info_type, info, len, flags, errcode ); - - if (!errcode) - return SOCKET_ERROR; - - if (!provider) { - *errcode = WSAEFAULT; - return SOCKET_ERROR; - } - - *errcode = WSANO_RECOVERY; - return SOCKET_ERROR; -} - -/*********************************************************************** - * WSCGetProviderPath (WS2_32.86) - */ -INT WINAPI WSCGetProviderPath( LPGUID provider, LPWSTR path, LPINT len, LPINT errcode ) -{ - FIXME( "(%s %p %p %p) Stub!\n", debugstr_guid(provider), path, len, errcode ); - - if (!provider || !len) - { - if (errcode) - *errcode = WSAEFAULT; - return SOCKET_ERROR; - } - - if (*len <= 0) - { - if (errcode) - *errcode = WSAEINVAL; - return SOCKET_ERROR; - } - - return 0; -} - -/*********************************************************************** - * WSCInstallNameSpace (WS2_32.87) - */ -INT WINAPI WSCInstallNameSpace( LPWSTR identifier, LPWSTR path, DWORD namespace, - DWORD version, LPGUID provider ) -{ - FIXME( "(%s %s 0x%08x 0x%08x %s) Stub!\n", debugstr_w(identifier), debugstr_w(path), - namespace, version, debugstr_guid(provider) ); - return 0; -} - -/*********************************************************************** - * WSCUnInstallNameSpace (WS2_32.89) - */ -INT WINAPI WSCUnInstallNameSpace( LPGUID lpProviderId ) -{ - FIXME("(%s) Stub!\n", debugstr_guid(lpProviderId)); - return NO_ERROR; -} - -/*********************************************************************** - * WSCWriteProviderOrder (WS2_32.91) - */ -INT WINAPI WSCWriteProviderOrder( LPDWORD entry, DWORD number ) -{ - FIXME("(%p 0x%08x) Stub!\n", entry, number); - return 0; -} - -/*********************************************************************** - * WSCSetApplicationCategory (WS2_32.@) - */ -INT WINAPI WSCSetApplicationCategory( LPCWSTR path, DWORD len, LPCWSTR extra, DWORD extralen, - DWORD lspcat, DWORD *prev_lspcat, LPINT err ) -{ - FIXME("(%s %d %s %d %d %p) Stub!\n", debugstr_w(path), len, debugstr_w(extra), - extralen, lspcat, prev_lspcat); - return 0; -} - -/*********************************************************************** - * WSANSPIoctl (WS2_32.91) - */ -INT WINAPI WSANSPIoctl( HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, - DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, - LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion ) -{ - FIXME("(%p, 0x%08x, %p, 0x%08x, %p, 0x%08x, %p, %p) Stub!\n", hLookup, dwControlCode, - lpvInBuffer, cbInBuffer, lpvOutBuffer, cbOutBuffer, lpcbBytesReturned, lpCompletion); - SetLastError(WSA_NOT_ENOUGH_MEMORY); - return SOCKET_ERROR; -}
static BOOL protocol_matches_filter( const int *filter, int protocol ) { @@ -6730,29 +6423,3 @@ int WINAPI WSAEnumProtocolsW( int *filter, WSAPROTOCOL_INFOW *protocols, DWORD * } return count; } - -/***************************************************************************** - * WSCEnumProtocols [WS2_32.@] - * - * PARAMS - * protocols [I] Null-terminated array of iProtocol values. - * buffer [O] Buffer of WSAPROTOCOL_INFOW structures. - * len [I/O] Size of buffer on input/output. - * errno [O] Error code. - * - * RETURNS - * Success: number of protocols to be reported on. - * Failure: SOCKET_ERROR. error is in errno. - * - * BUGS - * Doesn't supply info on layered protocols. - * - */ -INT WINAPI WSCEnumProtocols( LPINT protocols, LPWSAPROTOCOL_INFOW buffer, LPDWORD len, LPINT err ) -{ - INT ret = WSAEnumProtocolsW( protocols, buffer, len ); - - if (ret == SOCKET_ERROR) *err = WSAENOBUFS; - - return ret; -}
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/error.c b/dlls/ntdll/error.c index 738f55b42dc..3df63b16c21 100644 --- a/dlls/ntdll/error.c +++ b/dlls/ntdll/error.c @@ -60,7 +60,7 @@ ULONG WINAPI RtlNtStatusToDosErrorNoTeb( NTSTATUS status )
ret = map_status( status ); if (ret == ERROR_MR_MID_NOT_FOUND && status != STATUS_MESSAGE_NOT_FOUND) - FIXME( "no mapping for %08x\n", status ); + WARN( "no mapping for %08x\n", status ); return ret; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89871
Your paranoid android.
=== debiant2 (32 bit Chinese:China report) ===
ntdll: om.c:2322: Test failed: got 89
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/tests/sock.c | 144 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 60577d49984..627c12b8a1f 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -8573,6 +8573,149 @@ static void test_connecting_socket(void) closesocket(client); }
+static DWORD map_status( NTSTATUS status ) +{ + static const struct + { + NTSTATUS status; + DWORD error; + } + errors[] = + { + {STATUS_PENDING, ERROR_IO_INCOMPLETE}, + + {STATUS_BUFFER_OVERFLOW, WSAEMSGSIZE}, + + {STATUS_NOT_IMPLEMENTED, WSAEOPNOTSUPP}, + {STATUS_ACCESS_VIOLATION, WSAEFAULT}, + {STATUS_PAGEFILE_QUOTA, WSAENOBUFS}, + {STATUS_INVALID_HANDLE, WSAENOTSOCK}, + {STATUS_NO_SUCH_DEVICE, WSAENETDOWN}, + {STATUS_NO_SUCH_FILE, WSAENETDOWN}, + {STATUS_NO_MEMORY, WSAENOBUFS}, + {STATUS_CONFLICTING_ADDRESSES, WSAENOBUFS}, + {STATUS_ACCESS_DENIED, WSAEACCES}, + {STATUS_BUFFER_TOO_SMALL, WSAEFAULT}, + {STATUS_OBJECT_TYPE_MISMATCH, WSAENOTSOCK}, + {STATUS_OBJECT_NAME_NOT_FOUND, WSAENETDOWN}, + {STATUS_OBJECT_PATH_NOT_FOUND, WSAENETDOWN}, + {STATUS_SHARING_VIOLATION, WSAEADDRINUSE}, + {STATUS_QUOTA_EXCEEDED, WSAENOBUFS}, + {STATUS_TOO_MANY_PAGING_FILES, WSAENOBUFS}, + {STATUS_INSUFFICIENT_RESOURCES, WSAENOBUFS}, + {STATUS_WORKING_SET_QUOTA, WSAENOBUFS}, + {STATUS_DEVICE_NOT_READY, WSAEWOULDBLOCK}, + {STATUS_PIPE_DISCONNECTED, WSAESHUTDOWN}, + {STATUS_IO_TIMEOUT, WSAETIMEDOUT}, + {STATUS_NOT_SUPPORTED, WSAEOPNOTSUPP}, + {STATUS_REMOTE_NOT_LISTENING, WSAECONNREFUSED}, + {STATUS_BAD_NETWORK_PATH, WSAENETUNREACH}, + {STATUS_NETWORK_BUSY, WSAENETDOWN}, + {STATUS_INVALID_NETWORK_RESPONSE, WSAENETDOWN}, + {STATUS_UNEXPECTED_NETWORK_ERROR, WSAENETDOWN}, + {STATUS_REQUEST_NOT_ACCEPTED, WSAEWOULDBLOCK}, + {STATUS_CANCELLED, ERROR_OPERATION_ABORTED}, + {STATUS_COMMITMENT_LIMIT, WSAENOBUFS}, + {STATUS_LOCAL_DISCONNECT, WSAECONNABORTED}, + {STATUS_REMOTE_DISCONNECT, WSAECONNRESET}, + {STATUS_REMOTE_RESOURCES, WSAENOBUFS}, + {STATUS_LINK_FAILED, WSAECONNRESET}, + {STATUS_LINK_TIMEOUT, WSAETIMEDOUT}, + {STATUS_INVALID_CONNECTION, WSAENOTCONN}, + {STATUS_INVALID_ADDRESS, WSAEADDRNOTAVAIL}, + {STATUS_INVALID_BUFFER_SIZE, WSAEMSGSIZE}, + {STATUS_INVALID_ADDRESS_COMPONENT, WSAEADDRNOTAVAIL}, + {STATUS_TOO_MANY_ADDRESSES, WSAENOBUFS}, + {STATUS_ADDRESS_ALREADY_EXISTS, WSAEADDRINUSE}, + {STATUS_CONNECTION_DISCONNECTED, WSAECONNRESET}, + {STATUS_CONNECTION_RESET, WSAECONNRESET}, + {STATUS_TRANSACTION_ABORTED, WSAECONNABORTED}, + {STATUS_CONNECTION_REFUSED, WSAECONNREFUSED}, + {STATUS_GRACEFUL_DISCONNECT, WSAEDISCON}, + {STATUS_CONNECTION_ACTIVE, WSAEISCONN}, + {STATUS_NETWORK_UNREACHABLE, WSAENETUNREACH}, + {STATUS_HOST_UNREACHABLE, WSAEHOSTUNREACH}, + {STATUS_PROTOCOL_UNREACHABLE, WSAENETUNREACH}, + {STATUS_PORT_UNREACHABLE, WSAECONNRESET}, + {STATUS_REQUEST_ABORTED, WSAEINTR}, + {STATUS_CONNECTION_ABORTED, WSAECONNABORTED}, + {STATUS_DATATYPE_MISALIGNMENT_ERROR,WSAEFAULT}, + {STATUS_HOST_DOWN, WSAEHOSTDOWN}, + {0x80070000 | ERROR_IO_INCOMPLETE, ERROR_IO_INCOMPLETE}, + {0xc0010000 | ERROR_IO_INCOMPLETE, ERROR_IO_INCOMPLETE}, + {0xc0070000 | ERROR_IO_INCOMPLETE, ERROR_IO_INCOMPLETE}, + }; + + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(errors); ++i) + { + if (errors[i].status == status) + return errors[i].error; + } + + return NT_SUCCESS(status) ? RtlNtStatusToDosErrorNoTeb(status) : WSAEINVAL; +} + +static void test_WSAGetOverlappedResult(void) +{ + OVERLAPPED overlapped = {0}; + DWORD size, flags; + NTSTATUS status; + unsigned int i; + SOCKET s; + BOOL ret; + + static const NTSTATUS ranges[][2] = + { + {0x0, 0x10000}, + {0x40000000, 0x40001000}, + {0x80000000, 0x80001000}, + {0x80070000, 0x80080000}, + {0xc0000000, 0xc0001000}, + {0xc0070000, 0xc0080000}, + {0xd0000000, 0xd0001000}, + {0xd0070000, 0xd0080000}, + }; + + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + + for (i = 0; i < ARRAY_SIZE(ranges); ++i) + { + for (status = ranges[i][0]; status < ranges[i][1]; ++status) + { + BOOL expect_ret = NT_SUCCESS(status) && status != STATUS_PENDING; + DWORD expect = map_status(status); + + overlapped.Internal = status; + WSASetLastError(0xdeadbeef); + ret = WSAGetOverlappedResult(s, &overlapped, &size, FALSE, &flags); + todo_wine_if (expect_ret && status) + ok(ret == expect_ret, "status %#x: expected %d, got %d\n", status, expect_ret, ret); + if (ret) + { + ok(WSAGetLastError() == expect /* >= win10 1809 */ + || !WSAGetLastError() /* < win10 1809 */ + || WSAGetLastError() == 0xdeadbeef, /* < win7 */ + "status %#x: expected error %u, got %u\n", status, expect, WSAGetLastError()); + } + else + { + todo_wine_if (!NT_SUCCESS(status) + && LOWORD(status) != WSAEINVAL + && status != STATUS_CANCELLED + && status != (0x80070000 | ERROR_IO_INCOMPLETE) + && status != (0xc0070000 | ERROR_IO_INCOMPLETE)) + ok(WSAGetLastError() == expect + || (status == (0xc0070000 | ERROR_IO_INCOMPLETE) && WSAGetLastError() == WSAEINVAL), /* < win8 */ + "status %#x: expected error %u, got %u\n", status, expect, WSAGetLastError()); + } + } + } + + closesocket(s); +} + START_TEST( sock ) { int i; @@ -8628,6 +8771,7 @@ START_TEST( sock ) test_address_list_query(); test_bind(); test_connecting_socket(); + test_WSAGetOverlappedResult();
/* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */ test_send();