Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
815ac665
Commit
815ac665
authored
Aug 04, 2021
by
Zebediah Figura
Committed by
Alexandre Julliard
Aug 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Do not use the WS_ prefix in PE code.
Signed-off-by:
Zebediah Figura
<
zfigura@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0c81cc27
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
598 additions
and
643 deletions
+598
-643
Makefile.in
dlls/ws2_32/Makefile.in
+0
-1
async.c
dlls/ws2_32/async.c
+15
-15
protocol.c
dlls/ws2_32/protocol.c
+125
-144
socket.c
dlls/ws2_32/socket.c
+422
-448
unixlib.c
dlls/ws2_32/unixlib.c
+1
-0
ws2_32.spec
dlls/ws2_32/ws2_32.spec
+31
-31
ws2_32_private.h
dlls/ws2_32/ws2_32_private.h
+4
-4
No files found.
dlls/ws2_32/Makefile.in
View file @
815ac665
EXTRADEFS
=
-DUSE_WS_PREFIX
MODULE
=
ws2_32.dll
IMPORTLIB
=
ws2_32
DELAYIMPORTS
=
advapi32 iphlpapi user32
...
...
dlls/ws2_32/async.c
View file @
815ac665
...
...
@@ -128,15 +128,15 @@ static int list_dup(char** l_src, char* ref, int item_size)
/* ----- hostent */
static
LPARAM
copy_he
(
void
*
base
,
int
size
,
const
struct
WS_
hostent
*
he
)
static
LPARAM
copy_he
(
void
*
base
,
int
size
,
const
struct
hostent
*
he
)
{
char
*
p
;
int
needed
;
struct
WS_
hostent
*
to
=
base
;
struct
hostent
*
to
=
base
;
if
(
!
he
)
return
MAKELPARAM
(
0
,
GetLastError
()
);
needed
=
sizeof
(
struct
WS_
hostent
)
+
strlen
(
he
->
h_name
)
+
1
+
needed
=
sizeof
(
struct
hostent
)
+
strlen
(
he
->
h_name
)
+
1
+
list_size
(
he
->
h_aliases
,
0
)
+
list_size
(
he
->
h_addr_list
,
he
->
h_length
);
if
(
size
<
needed
)
return
MAKELPARAM
(
needed
,
WSAENOBUFS
);
...
...
@@ -156,7 +156,7 @@ static LPARAM copy_he(void *base, int size, const struct WS_hostent *he)
static
LPARAM
async_gethostbyname
(
struct
async_query_header
*
query
)
{
struct
async_query_gethostbyname
*
aq
=
CONTAINING_RECORD
(
query
,
struct
async_query_gethostbyname
,
query
);
struct
WS_hostent
*
he
=
WS_
gethostbyname
(
aq
->
host_name
);
struct
hostent
*
he
=
gethostbyname
(
aq
->
host_name
);
return
copy_he
(
query
->
sbuf
,
query
->
sbuflen
,
he
);
}
...
...
@@ -164,22 +164,22 @@ static LPARAM async_gethostbyname( struct async_query_header *query )
static
LPARAM
async_gethostbyaddr
(
struct
async_query_header
*
query
)
{
struct
async_query_gethostbyaddr
*
aq
=
CONTAINING_RECORD
(
query
,
struct
async_query_gethostbyaddr
,
query
);
struct
WS_hostent
*
he
=
WS_
gethostbyaddr
(
aq
->
host_addr
,
aq
->
host_len
,
aq
->
host_type
);
struct
hostent
*
he
=
gethostbyaddr
(
aq
->
host_addr
,
aq
->
host_len
,
aq
->
host_type
);
return
copy_he
(
query
->
sbuf
,
query
->
sbuflen
,
he
);
}
/* ----- protoent */
static
LPARAM
copy_pe
(
void
*
base
,
int
size
,
const
struct
WS_protoent
*
pe
)
static
LPARAM
copy_pe
(
void
*
base
,
int
size
,
const
struct
protoent
*
pe
)
{
char
*
p
;
int
needed
;
struct
WS_
protoent
*
to
=
base
;
struct
protoent
*
to
=
base
;
if
(
!
pe
)
return
MAKELPARAM
(
0
,
GetLastError
()
);
needed
=
sizeof
(
struct
WS_protoent
)
+
strlen
(
pe
->
p_name
)
+
1
+
list_size
(
pe
->
p_aliases
,
0
);
needed
=
sizeof
(
struct
protoent
)
+
strlen
(
pe
->
p_name
)
+
1
+
list_size
(
pe
->
p_aliases
,
0
);
if
(
size
<
needed
)
return
MAKELPARAM
(
needed
,
WSAENOBUFS
);
to
->
p_proto
=
pe
->
p_proto
;
...
...
@@ -194,7 +194,7 @@ static LPARAM copy_pe(void *base, int size, const struct WS_protoent* pe)
static
LPARAM
async_getprotobyname
(
struct
async_query_header
*
query
)
{
struct
async_query_getprotobyname
*
aq
=
CONTAINING_RECORD
(
query
,
struct
async_query_getprotobyname
,
query
);
struct
WS_protoent
*
pe
=
WS_
getprotobyname
(
aq
->
proto_name
);
struct
protoent
*
pe
=
getprotobyname
(
aq
->
proto_name
);
return
copy_pe
(
query
->
sbuf
,
query
->
sbuflen
,
pe
);
}
...
...
@@ -202,22 +202,22 @@ static LPARAM async_getprotobyname( struct async_query_header *query )
static
LPARAM
async_getprotobynumber
(
struct
async_query_header
*
query
)
{
struct
async_query_getprotobynumber
*
aq
=
CONTAINING_RECORD
(
query
,
struct
async_query_getprotobynumber
,
query
);
struct
WS_protoent
*
pe
=
WS_
getprotobynumber
(
aq
->
proto_number
);
struct
protoent
*
pe
=
getprotobynumber
(
aq
->
proto_number
);
return
copy_pe
(
query
->
sbuf
,
query
->
sbuflen
,
pe
);
}
/* ----- servent */
static
LPARAM
copy_se
(
void
*
base
,
int
size
,
const
struct
WS_servent
*
se
)
static
LPARAM
copy_se
(
void
*
base
,
int
size
,
const
struct
servent
*
se
)
{
char
*
p
;
int
needed
;
struct
WS_
servent
*
to
=
base
;
struct
servent
*
to
=
base
;
if
(
!
se
)
return
MAKELPARAM
(
0
,
GetLastError
()
);
needed
=
sizeof
(
struct
WS_servent
)
+
strlen
(
se
->
s_proto
)
+
strlen
(
se
->
s_name
)
+
2
+
list_size
(
se
->
s_aliases
,
0
);
needed
=
sizeof
(
struct
servent
)
+
strlen
(
se
->
s_proto
)
+
strlen
(
se
->
s_name
)
+
2
+
list_size
(
se
->
s_aliases
,
0
);
if
(
size
<
needed
)
return
MAKELPARAM
(
needed
,
WSAENOBUFS
);
to
->
s_port
=
se
->
s_port
;
...
...
@@ -234,7 +234,7 @@ static LPARAM copy_se(void *base, int size, const struct WS_servent* se)
static
LPARAM
async_getservbyname
(
struct
async_query_header
*
query
)
{
struct
async_query_getservbyname
*
aq
=
CONTAINING_RECORD
(
query
,
struct
async_query_getservbyname
,
query
);
struct
WS_servent
*
se
=
WS_
getservbyname
(
aq
->
serv_name
,
aq
->
serv_proto
);
struct
servent
*
se
=
getservbyname
(
aq
->
serv_name
,
aq
->
serv_proto
);
return
copy_se
(
query
->
sbuf
,
query
->
sbuflen
,
se
);
}
...
...
@@ -242,7 +242,7 @@ static LPARAM async_getservbyname( struct async_query_header *query )
static
LPARAM
async_getservbyport
(
struct
async_query_header
*
query
)
{
struct
async_query_getservbyport
*
aq
=
CONTAINING_RECORD
(
query
,
struct
async_query_getservbyport
,
query
);
struct
WS_servent
*
se
=
WS_
getservbyport
(
aq
->
serv_port
,
aq
->
serv_proto
);
struct
servent
*
se
=
getservbyport
(
aq
->
serv_port
,
aq
->
serv_proto
);
return
copy_se
(
query
->
sbuf
,
query
->
sbuflen
,
se
);
}
...
...
dlls/ws2_32/protocol.c
View file @
815ac665
...
...
@@ -27,26 +27,6 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
winsock
);
WINE_DECLARE_DEBUG_CHANNEL
(
winediag
);
static
inline
unsigned
short
ntohs
(
unsigned
short
netshort
)
{
return
RtlUshortByteSwap
(
netshort
);
}
static
inline
unsigned
short
htons
(
unsigned
short
hostshort
)
{
return
RtlUshortByteSwap
(
hostshort
);
}
static
inline
unsigned
int
ntohl
(
unsigned
int
netlong
)
{
return
RtlUlongByteSwap
(
netlong
);
}
static
inline
unsigned
int
htonl
(
unsigned
int
hostlong
)
{
return
RtlUlongByteSwap
(
hostlong
);
}
static
char
*
get_fqdn
(
void
)
{
char
*
ret
;
...
...
@@ -65,9 +45,9 @@ static char *get_fqdn(void)
/* call Unix getaddrinfo, allocating a large enough buffer */
static
int
do_getaddrinfo
(
const
char
*
node
,
const
char
*
service
,
const
struct
WS_addrinfo
*
hints
,
struct
WS_
addrinfo
**
info
)
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
info
)
{
struct
WS_
addrinfo
*
buffer
,
*
new_buffer
;
struct
addrinfo
*
buffer
,
*
new_buffer
;
unsigned
int
size
=
1024
;
int
ret
;
...
...
@@ -95,8 +75,8 @@ static int do_getaddrinfo( const char *node, const char *service,
/***********************************************************************
* getaddrinfo (ws2_32.@)
*/
int
WINAPI
WS_
getaddrinfo
(
const
char
*
node
,
const
char
*
service
,
const
struct
WS_addrinfo
*
hints
,
struct
WS_
addrinfo
**
info
)
int
WINAPI
getaddrinfo
(
const
char
*
node
,
const
char
*
service
,
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
info
)
{
char
*
nodev6
=
NULL
,
*
fqdn
=
NULL
;
int
ret
;
...
...
@@ -118,7 +98,7 @@ int WINAPI WS_getaddrinfo( const char *node, const char *service,
if
(
!
(
fqdn
=
get_fqdn
()))
return
WSA_NOT_ENOUGH_MEMORY
;
node
=
fqdn
;
}
else
if
(
!
hints
||
hints
->
ai_family
==
WS_AF_UNSPEC
||
hints
->
ai_family
==
WS_
AF_INET6
)
else
if
(
!
hints
||
hints
->
ai_family
==
AF_UNSPEC
||
hints
->
ai_family
==
AF_INET6
)
{
/* [ipv6] or [ipv6]:portnumber are supported by Windows */
char
*
close_bracket
;
...
...
@@ -135,7 +115,7 @@ int WINAPI WS_getaddrinfo( const char *node, const char *service,
ret
=
do_getaddrinfo
(
node
,
service
,
hints
,
info
);
if
(
ret
&&
(
!
hints
||
!
(
hints
->
ai_flags
&
WS_
AI_NUMERICHOST
))
&&
node
)
if
(
ret
&&
(
!
hints
||
!
(
hints
->
ai_flags
&
AI_NUMERICHOST
))
&&
node
)
{
if
(
!
fqdn
&&
!
(
fqdn
=
get_fqdn
()))
{
...
...
@@ -149,11 +129,11 @@ int WINAPI WS_getaddrinfo( const char *node, const char *service,
* is invalid */
ERR_
(
winediag
)(
"Failed to resolve your host name IP
\n
"
);
ret
=
do_getaddrinfo
(
NULL
,
service
,
hints
,
info
);
if
(
!
ret
&&
hints
&&
(
hints
->
ai_flags
&
WS_
AI_CANONNAME
)
&&
*
info
&&
!
(
*
info
)
->
ai_canonname
)
if
(
!
ret
&&
hints
&&
(
hints
->
ai_flags
&
AI_CANONNAME
)
&&
*
info
&&
!
(
*
info
)
->
ai_canonname
)
{
WS_
freeaddrinfo
(
*
info
);
freeaddrinfo
(
*
info
);
*
info
=
NULL
;
return
WS_
EAI_NONAME
;
return
EAI_NONAME
;
}
}
}
...
...
@@ -163,7 +143,7 @@ int WINAPI WS_getaddrinfo( const char *node, const char *service,
if
(
!
ret
&&
TRACE_ON
(
winsock
))
{
struct
WS_
addrinfo
*
ai
;
struct
addrinfo
*
ai
;
for
(
ai
=
*
info
;
ai
!=
NULL
;
ai
=
ai
->
ai_next
)
{
...
...
@@ -178,7 +158,7 @@ int WINAPI WS_getaddrinfo( const char *node, const char *service,
}
static
ADDRINFOEXW
*
addrinfo_AtoW
(
const
struct
WS_
addrinfo
*
ai
)
static
ADDRINFOEXW
*
addrinfo_AtoW
(
const
struct
addrinfo
*
ai
)
{
ADDRINFOEXW
*
ret
;
...
...
@@ -217,7 +197,7 @@ static ADDRINFOEXW *addrinfo_AtoW( const struct WS_addrinfo *ai )
return
ret
;
}
static
ADDRINFOEXW
*
addrinfo_list_AtoW
(
const
struct
WS_
addrinfo
*
info
)
static
ADDRINFOEXW
*
addrinfo_list_AtoW
(
const
struct
addrinfo
*
info
)
{
ADDRINFOEXW
*
ret
,
*
infoW
;
...
...
@@ -235,11 +215,11 @@ static ADDRINFOEXW *addrinfo_list_AtoW( const struct WS_addrinfo *info )
return
ret
;
}
static
struct
WS_addrinfo
*
addrinfo_WtoA
(
const
struct
WS_
addrinfoW
*
ai
)
static
struct
addrinfo
*
addrinfo_WtoA
(
const
struct
addrinfoW
*
ai
)
{
struct
WS_
addrinfo
*
ret
;
struct
addrinfo
*
ret
;
if
(
!
(
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
struct
WS_
addrinfo
)
)))
return
NULL
;
if
(
!
(
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
struct
addrinfo
)
)))
return
NULL
;
ret
->
ai_flags
=
ai
->
ai_flags
;
ret
->
ai_family
=
ai
->
ai_family
;
ret
->
ai_socktype
=
ai
->
ai_socktype
;
...
...
@@ -260,13 +240,13 @@ static struct WS_addrinfo *addrinfo_WtoA( const struct WS_addrinfoW *ai )
}
if
(
ai
->
ai_addr
)
{
if
(
!
(
ret
->
ai_addr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
struct
WS_
sockaddr
)
)))
if
(
!
(
ret
->
ai_addr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
struct
sockaddr
)
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
ret
->
ai_canonname
);
HeapFree
(
GetProcessHeap
(),
0
,
ret
);
return
NULL
;
}
memcpy
(
ret
->
ai_addr
,
ai
->
ai_addr
,
sizeof
(
struct
WS_
sockaddr
)
);
memcpy
(
ret
->
ai_addr
,
ai
->
ai_addr
,
sizeof
(
struct
sockaddr
)
);
}
return
ret
;
}
...
...
@@ -278,7 +258,7 @@ struct getaddrinfo_args
ADDRINFOEXW
**
result
;
char
*
nodename
;
char
*
servname
;
struct
WS_
addrinfo
*
hints
;
struct
addrinfo
*
hints
;
};
static
void
WINAPI
getaddrinfo_callback
(
TP_CALLBACK_INSTANCE
*
instance
,
void
*
context
)
...
...
@@ -287,15 +267,15 @@ static void WINAPI getaddrinfo_callback(TP_CALLBACK_INSTANCE *instance, void *co
OVERLAPPED
*
overlapped
=
args
->
overlapped
;
HANDLE
event
=
overlapped
->
hEvent
;
LPLOOKUPSERVICE_COMPLETION_ROUTINE
completion_routine
=
args
->
completion_routine
;
struct
WS_
addrinfo
*
res
;
struct
addrinfo
*
res
;
int
ret
;
ret
=
WS_
getaddrinfo
(
args
->
nodename
,
args
->
servname
,
args
->
hints
,
&
res
);
ret
=
getaddrinfo
(
args
->
nodename
,
args
->
servname
,
args
->
hints
,
&
res
);
if
(
res
)
{
*
args
->
result
=
addrinfo_list_AtoW
(
res
);
overlapped
->
u
.
Pointer
=
args
->
result
;
WS_
freeaddrinfo
(
res
);
freeaddrinfo
(
res
);
}
HeapFree
(
GetProcessHeap
(),
0
,
args
->
nodename
);
...
...
@@ -307,13 +287,13 @@ static void WINAPI getaddrinfo_callback(TP_CALLBACK_INSTANCE *instance, void *co
if
(
event
)
SetEvent
(
event
);
}
static
int
WS_
getaddrinfoW
(
const
WCHAR
*
nodename
,
const
WCHAR
*
servname
,
const
struct
WS_
addrinfo
*
hints
,
ADDRINFOEXW
**
res
,
OVERLAPPED
*
overlapped
,
static
int
getaddrinfoW
(
const
WCHAR
*
nodename
,
const
WCHAR
*
servname
,
const
struct
addrinfo
*
hints
,
ADDRINFOEXW
**
res
,
OVERLAPPED
*
overlapped
,
LPLOOKUPSERVICE_COMPLETION_ROUTINE
completion_routine
)
{
int
ret
=
WS_
EAI_MEMORY
,
len
,
i
;
int
ret
=
EAI_MEMORY
,
len
,
i
;
char
*
nodenameA
=
NULL
,
*
servnameA
=
NULL
;
struct
WS_
addrinfo
*
resA
;
struct
addrinfo
*
resA
;
WCHAR
*
local_nodenameW
=
(
WCHAR
*
)
nodename
;
*
res
=
NULL
;
...
...
@@ -329,7 +309,7 @@ static int WS_getaddrinfoW( const WCHAR *nodename, const WCHAR *servname,
}
if
(
nodename
[
i
])
{
if
(
hints
&&
(
hints
->
ai_flags
&
WS_
AI_DISABLE_IDN_ENCODING
))
if
(
hints
&&
(
hints
->
ai_flags
&
AI_DISABLE_IDN_ENCODING
))
{
/* Name requires conversion but it was disabled */
ret
=
WSAHOST_NOT_FOUND
;
...
...
@@ -341,7 +321,7 @@ static int WS_getaddrinfoW( const WCHAR *nodename, const WCHAR *servname,
if
(
!
len
)
{
ERR
(
"Failed to convert %s to punycode
\n
"
,
debugstr_w
(
nodename
));
ret
=
WS_
EAI_FAIL
;
ret
=
EAI_FAIL
;
goto
end
;
}
if
(
!
(
local_nodenameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
goto
end
;
...
...
@@ -379,7 +359,7 @@ static int WS_getaddrinfoW( const WCHAR *nodename, const WCHAR *servname,
args
->
servname
=
servnameA
;
if
(
hints
)
{
args
->
hints
=
(
struct
WS_
addrinfo
*
)(
args
+
1
);
args
->
hints
=
(
struct
addrinfo
*
)(
args
+
1
);
args
->
hints
->
ai_flags
=
hints
->
ai_flags
;
args
->
hints
->
ai_family
=
hints
->
ai_family
;
args
->
hints
->
ai_socktype
=
hints
->
ai_socktype
;
...
...
@@ -401,11 +381,11 @@ static int WS_getaddrinfoW( const WCHAR *nodename, const WCHAR *servname,
return
ERROR_IO_PENDING
;
}
ret
=
WS_
getaddrinfo
(
nodenameA
,
servnameA
,
hints
,
&
resA
);
ret
=
getaddrinfo
(
nodenameA
,
servnameA
,
hints
,
&
resA
);
if
(
!
ret
)
{
*
res
=
addrinfo_list_AtoW
(
resA
);
WS_
freeaddrinfo
(
resA
);
freeaddrinfo
(
resA
);
}
end:
...
...
@@ -422,7 +402,7 @@ end:
*/
int
WINAPI
GetAddrInfoExW
(
const
WCHAR
*
name
,
const
WCHAR
*
servname
,
DWORD
namespace
,
GUID
*
namespace_id
,
const
ADDRINFOEXW
*
hints
,
ADDRINFOEXW
**
result
,
struct
WS_
timeval
*
timeout
,
OVERLAPPED
*
overlapped
,
struct
timeval
*
timeout
,
OVERLAPPED
*
overlapped
,
LPLOOKUPSERVICE_COMPLETION_ROUTINE
completion_routine
,
HANDLE
*
handle
)
{
int
ret
;
...
...
@@ -439,7 +419,7 @@ int WINAPI GetAddrInfoExW( const WCHAR *name, const WCHAR *servname, DWORD names
if
(
handle
)
FIXME
(
"Unsupported cancel handle
\n
"
);
ret
=
WS_getaddrinfoW
(
name
,
servname
,
(
struct
WS_
addrinfo
*
)
hints
,
result
,
overlapped
,
completion_routine
);
ret
=
getaddrinfoW
(
name
,
servname
,
(
struct
addrinfo
*
)
hints
,
result
,
overlapped
,
completion_routine
);
if
(
ret
)
return
ret
;
if
(
handle
)
*
handle
=
(
HANDLE
)
0xdeadbeef
;
return
0
;
...
...
@@ -471,17 +451,17 @@ int WINAPI GetAddrInfoExCancel( HANDLE *handle )
*/
int
WINAPI
GetAddrInfoW
(
const
WCHAR
*
nodename
,
const
WCHAR
*
servname
,
const
ADDRINFOW
*
hints
,
ADDRINFOW
**
res
)
{
struct
WS_
addrinfo
*
hintsA
=
NULL
;
struct
addrinfo
*
hintsA
=
NULL
;
ADDRINFOEXW
*
resex
;
int
ret
=
WS_
EAI_MEMORY
;
int
ret
=
EAI_MEMORY
;
TRACE
(
"nodename %s, servname %s, hints %p, result %p
\n
"
,
debugstr_w
(
nodename
),
debugstr_w
(
servname
),
hints
,
res
);
*
res
=
NULL
;
if
(
hints
)
hintsA
=
addrinfo_WtoA
(
hints
);
ret
=
WS_
getaddrinfoW
(
nodename
,
servname
,
hintsA
,
&
resex
,
NULL
,
NULL
);
WS_
freeaddrinfo
(
hintsA
);
ret
=
getaddrinfoW
(
nodename
,
servname
,
hintsA
,
&
resex
,
NULL
,
NULL
);
freeaddrinfo
(
hintsA
);
if
(
ret
)
return
ret
;
if
(
resex
)
...
...
@@ -502,7 +482,7 @@ int WINAPI GetAddrInfoW(const WCHAR *nodename, const WCHAR *servname, const ADDR
/***********************************************************************
* freeaddrinfo (ws2_32.@)
*/
void
WINAPI
WS_freeaddrinfo
(
struct
WS_
addrinfo
*
info
)
void
WINAPI
freeaddrinfo
(
struct
addrinfo
*
info
)
{
TRACE
(
"%p
\n
"
,
info
);
...
...
@@ -568,7 +548,7 @@ void WINAPI FreeAddrInfoExW( ADDRINFOEXW *ai )
/***********************************************************************
* getnameinfo (ws2_32.@)
*/
int
WINAPI
WS_getnameinfo
(
const
SOCKADDR
*
addr
,
WS_
socklen_t
addr_len
,
char
*
host
,
int
WINAPI
getnameinfo
(
const
SOCKADDR
*
addr
,
socklen_t
addr_len
,
char
*
host
,
DWORD
host_len
,
char
*
serv
,
DWORD
serv_len
,
int
flags
)
{
TRACE
(
"addr %s, addr_len %d, host %p, host_len %u, serv %p, serv_len %d, flags %#x
\n
"
,
...
...
@@ -581,21 +561,21 @@ int WINAPI WS_getnameinfo( const SOCKADDR *addr, WS_socklen_t addr_len, char *ho
/***********************************************************************
* GetNameInfoW (ws2_32.@)
*/
int
WINAPI
GetNameInfoW
(
const
SOCKADDR
*
addr
,
WS_
socklen_t
addr_len
,
WCHAR
*
host
,
int
WINAPI
GetNameInfoW
(
const
SOCKADDR
*
addr
,
socklen_t
addr_len
,
WCHAR
*
host
,
DWORD
host_len
,
WCHAR
*
serv
,
DWORD
serv_len
,
int
flags
)
{
int
ret
;
char
*
hostA
=
NULL
,
*
servA
=
NULL
;
if
(
host
&&
(
!
(
hostA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
host_len
))))
return
WS_
EAI_MEMORY
;
return
EAI_MEMORY
;
if
(
serv
&&
(
!
(
servA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
serv_len
))))
{
HeapFree
(
GetProcessHeap
(),
0
,
hostA
);
return
WS_
EAI_MEMORY
;
return
EAI_MEMORY
;
}
ret
=
WS_
getnameinfo
(
addr
,
addr_len
,
hostA
,
host_len
,
servA
,
serv_len
,
flags
);
ret
=
getnameinfo
(
addr
,
addr_len
,
hostA
,
host_len
,
servA
,
serv_len
,
flags
);
if
(
!
ret
)
{
if
(
host
)
MultiByteToWideChar
(
CP_ACP
,
0
,
hostA
,
-
1
,
host
,
host_len
);
...
...
@@ -608,7 +588,7 @@ int WINAPI GetNameInfoW( const SOCKADDR *addr, WS_socklen_t addr_len, WCHAR *hos
}
static
struct
WS_
hostent
*
get_hostent_buffer
(
unsigned
int
size
)
static
struct
hostent
*
get_hostent_buffer
(
unsigned
int
size
)
{
struct
per_thread_data
*
data
=
get_per_thread_data
();
if
(
data
->
he_buffer
)
...
...
@@ -632,12 +612,12 @@ static struct WS_hostent *get_hostent_buffer( unsigned int size )
* the list has no items ("aliases" and "addresses" must be
* at least "1", a truly empty list is invalid).
*/
static
struct
WS_
hostent
*
create_hostent
(
char
*
name
,
int
alias_count
,
int
aliases_size
,
int
address_count
,
int
address_length
)
static
struct
hostent
*
create_hostent
(
char
*
name
,
int
alias_count
,
int
aliases_size
,
int
address_count
,
int
address_length
)
{
struct
WS_
hostent
*
p_to
;
struct
hostent
*
p_to
;
char
*
p
;
unsigned
int
size
=
sizeof
(
struct
WS_
hostent
),
i
;
unsigned
int
size
=
sizeof
(
struct
hostent
),
i
;
size
+=
strlen
(
name
)
+
1
;
size
+=
alias_count
*
sizeof
(
char
*
);
...
...
@@ -679,10 +659,10 @@ static struct WS_hostent *create_hostent( char *name, int alias_count, int alias
/***********************************************************************
* gethostbyaddr (ws2_32.51)
*/
struct
WS_hostent
*
WINAPI
WS_
gethostbyaddr
(
const
char
*
addr
,
int
len
,
int
family
)
struct
hostent
*
WINAPI
gethostbyaddr
(
const
char
*
addr
,
int
len
,
int
family
)
{
unsigned
int
size
=
1024
;
struct
WS_
hostent
*
host
;
struct
hostent
*
host
;
int
ret
;
if
(
!
(
host
=
get_hostent_buffer
(
size
)))
...
...
@@ -701,7 +681,7 @@ struct WS_hostent * WINAPI WS_gethostbyaddr( const char *addr, int len, int fami
struct
route
{
struct
WS_
in_addr
addr
;
struct
in_addr
addr
;
IF_INDEX
interface
;
DWORD
metric
,
default_route
;
};
...
...
@@ -727,11 +707,11 @@ static int __cdecl compare_routes_by_metric_asc( const void *left, const void *r
* Please note that the returned hostent is only freed when the thread
* closes and is replaced if another hostent is requested.
*/
static
struct
WS_
hostent
*
get_local_ips
(
char
*
hostname
)
static
struct
hostent
*
get_local_ips
(
char
*
hostname
)
{
int
numroutes
=
0
,
i
,
j
,
default_routes
=
0
;
IP_ADAPTER_INFO
*
adapters
=
NULL
,
*
k
;
struct
WS_
hostent
*
hostlist
=
NULL
;
struct
hostent
*
hostlist
=
NULL
;
MIB_IPFORWARDTABLE
*
routes
=
NULL
;
struct
route
*
route_addrs
=
NULL
;
DWORD
adap_size
,
route_size
,
n
;
...
...
@@ -788,7 +768,7 @@ static struct WS_hostent *get_local_ips( char *hostname )
/* If no IP is found in the next step (for whatever reason)
* then fall back to the magic loopback address.
*/
memcpy
(
&
route_addrs
[
numroutes
].
addr
.
WS_
s_addr
,
magic_loopback_addr
,
4
);
memcpy
(
&
route_addrs
[
numroutes
].
addr
.
s_addr
,
magic_loopback_addr
,
4
);
numroutes
++
;
}
if
(
numroutes
==
0
)
...
...
@@ -802,20 +782,20 @@ static struct WS_hostent *get_local_ips( char *hostname )
char
*
ip
=
k
->
IpAddressList
.
IpAddress
.
String
;
if
(
route_addrs
[
i
].
interface
==
k
->
Index
)
route_addrs
[
i
].
addr
.
WS_s_addr
=
WS_
inet_addr
(
ip
);
route_addrs
[
i
].
addr
.
s_addr
=
inet_addr
(
ip
);
}
}
/* Allocate a hostent and enough memory for all the IPs,
* including the NULL at the end of the list.
*/
hostlist
=
create_hostent
(
hostname
,
1
,
0
,
numroutes
+
1
,
sizeof
(
struct
WS_
in_addr
)
);
hostlist
=
create_hostent
(
hostname
,
1
,
0
,
numroutes
+
1
,
sizeof
(
struct
in_addr
)
);
if
(
hostlist
==
NULL
)
goto
cleanup
;
hostlist
->
h_addr_list
[
numroutes
]
=
NULL
;
hostlist
->
h_aliases
[
0
]
=
NULL
;
hostlist
->
h_addrtype
=
WS_
AF_INET
;
hostlist
->
h_length
=
sizeof
(
struct
WS_
in_addr
);
hostlist
->
h_addrtype
=
AF_INET
;
hostlist
->
h_length
=
sizeof
(
struct
in_addr
);
/* Reorder the entries before placing them in the host list. Windows expects
* the IP list in order from highest priority to lowest (the critical thing
...
...
@@ -825,7 +805,7 @@ static struct WS_hostent *get_local_ips( char *hostname )
qsort
(
route_addrs
,
numroutes
,
sizeof
(
struct
route
),
compare_routes_by_metric_asc
);
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
*
(
struct
WS_
in_addr
*
)
hostlist
->
h_addr_list
[
i
]
=
route_addrs
[
i
].
addr
;
*
(
struct
in_addr
*
)
hostlist
->
h_addr_list
[
i
]
=
route_addrs
[
i
].
addr
;
cleanup:
HeapFree
(
GetProcessHeap
(),
0
,
route_addrs
);
...
...
@@ -838,9 +818,9 @@ cleanup:
/***********************************************************************
* gethostbyname (ws2_32.52)
*/
struct
WS_hostent
*
WINAPI
WS_
gethostbyname
(
const
char
*
name
)
struct
hostent
*
WINAPI
gethostbyname
(
const
char
*
name
)
{
struct
WS_
hostent
*
host
=
NULL
;
struct
hostent
*
host
=
NULL
;
char
hostname
[
100
];
int
ret
;
...
...
@@ -900,7 +880,7 @@ struct WS_hostent * WINAPI WS_gethostbyname( const char *name )
/***********************************************************************
* gethostname (ws2_32.57)
*/
int
WINAPI
WS_
gethostname
(
char
*
name
,
int
namelen
)
int
WINAPI
gethostname
(
char
*
name
,
int
namelen
)
{
char
buf
[
256
];
int
len
,
ret
;
...
...
@@ -1017,7 +997,8 @@ static char *next_non_space( const char *p, const char *end )
return
(
char
*
)
p
;
}
static
struct
WS_protoent
*
get_protoent_buffer
(
unsigned
int
size
)
static
struct
protoent
*
get_protoent_buffer
(
unsigned
int
size
)
{
struct
per_thread_data
*
data
=
get_per_thread_data
();
...
...
@@ -1035,7 +1016,7 @@ static struct WS_protoent *get_protoent_buffer( unsigned int size )
/* Parse the first valid line into a protoent structure, returning NULL if
* there is no valid line. Updates cursor to point to the start of the next
* line or the end of the file. */
static
struct
WS_
protoent
*
get_next_protocol
(
const
char
**
cursor
,
const
char
*
end
)
static
struct
protoent
*
get_next_protocol
(
const
char
**
cursor
,
const
char
*
end
)
{
const
char
*
p
=
*
cursor
;
...
...
@@ -1044,7 +1025,7 @@ static struct WS_protoent *get_next_protocol( const char **cursor, const char *e
const
char
*
line_end
,
*
next_line
;
size_t
needed_size
,
line_len
;
unsigned
int
alias_count
=
0
;
struct
WS_
protoent
*
proto
;
struct
protoent
*
proto
;
const
char
*
name
;
int
number
;
char
*
q
;
...
...
@@ -1143,9 +1124,9 @@ static struct WS_protoent *get_next_protocol( const char **cursor, const char *e
/***********************************************************************
* getprotobyname (ws2_32.53)
*/
struct
WS_protoent
*
WINAPI
WS_
getprotobyname
(
const
char
*
name
)
struct
protoent
*
WINAPI
getprotobyname
(
const
char
*
name
)
{
struct
WS_
protoent
*
proto
;
struct
protoent
*
proto
;
const
char
*
cursor
;
char
*
file
;
DWORD
size
;
...
...
@@ -1173,9 +1154,9 @@ struct WS_protoent * WINAPI WS_getprotobyname( const char *name )
/***********************************************************************
* getprotobynumber (ws2_32.54)
*/
struct
WS_protoent
*
WINAPI
WS_
getprotobynumber
(
int
number
)
struct
protoent
*
WINAPI
getprotobynumber
(
int
number
)
{
struct
WS_
protoent
*
proto
;
struct
protoent
*
proto
;
const
char
*
cursor
;
char
*
file
;
DWORD
size
;
...
...
@@ -1200,7 +1181,7 @@ struct WS_protoent * WINAPI WS_getprotobynumber( int number )
}
static
struct
WS_
servent
*
get_servent_buffer
(
int
size
)
static
struct
servent
*
get_servent_buffer
(
int
size
)
{
struct
per_thread_data
*
data
=
get_per_thread_data
();
if
(
data
->
se_buffer
)
...
...
@@ -1217,7 +1198,7 @@ static struct WS_servent *get_servent_buffer( int size )
/* Parse the first valid line into a servent structure, returning NULL if
* there is no valid line. Updates cursor to point to the start of the next
* line or the end of the file. */
static
struct
WS_
servent
*
get_next_service
(
const
char
**
cursor
,
const
char
*
end
)
static
struct
servent
*
get_next_service
(
const
char
**
cursor
,
const
char
*
end
)
{
const
char
*
p
=
*
cursor
;
...
...
@@ -1226,7 +1207,7 @@ static struct WS_servent *get_next_service( const char **cursor, const char *end
const
char
*
line_end
,
*
next_line
;
size_t
needed_size
,
line_len
;
unsigned
int
alias_count
=
0
;
struct
WS_
servent
*
serv
;
struct
servent
*
serv
;
const
char
*
name
;
int
port
;
char
*
q
;
...
...
@@ -1334,9 +1315,9 @@ static struct WS_servent *get_next_service( const char **cursor, const char *end
/***********************************************************************
* getservbyname (ws2_32.55)
*/
struct
WS_servent
*
WINAPI
WS_
getservbyname
(
const
char
*
name
,
const
char
*
proto
)
struct
servent
*
WINAPI
getservbyname
(
const
char
*
name
,
const
char
*
proto
)
{
struct
WS_
servent
*
serv
;
struct
servent
*
serv
;
const
char
*
cursor
;
char
*
file
;
DWORD
size
;
...
...
@@ -1364,9 +1345,9 @@ struct WS_servent * WINAPI WS_getservbyname( const char *name, const char *proto
/***********************************************************************
* getservbyport (ws2_32.56)
*/
struct
WS_servent
*
WINAPI
WS_
getservbyport
(
int
port
,
const
char
*
proto
)
struct
servent
*
WINAPI
getservbyport
(
int
port
,
const
char
*
proto
)
{
struct
WS_
servent
*
serv
;
struct
servent
*
serv
;
const
char
*
cursor
;
char
*
file
;
DWORD
size
;
...
...
@@ -1394,9 +1375,9 @@ struct WS_servent * WINAPI WS_getservbyport( int port, const char *proto )
/***********************************************************************
* inet_ntoa (ws2_32.12)
*/
char
*
WINAPI
WS_inet_ntoa
(
struct
WS_
in_addr
in
)
char
*
WINAPI
inet_ntoa
(
struct
in_addr
in
)
{
unsigned
int
long_ip
=
ntohl
(
in
.
WS_
s_addr
);
unsigned
int
long_ip
=
ntohl
(
in
.
s_addr
);
struct
per_thread_data
*
data
=
get_per_thread_data
();
sprintf
(
data
->
ntoa_buffer
,
"%u.%u.%u.%u"
,
...
...
@@ -1412,7 +1393,7 @@ char * WINAPI WS_inet_ntoa( struct WS_in_addr in )
/***********************************************************************
* inet_ntop (ws2_32.@)
*/
const
char
*
WINAPI
WS_
inet_ntop
(
int
family
,
void
*
addr
,
char
*
buffer
,
SIZE_T
len
)
const
char
*
WINAPI
inet_ntop
(
int
family
,
void
*
addr
,
char
*
buffer
,
SIZE_T
len
)
{
NTSTATUS
status
;
ULONG
size
=
min
(
len
,
(
ULONG
)
-
1
);
...
...
@@ -1426,12 +1407,12 @@ const char * WINAPI WS_inet_ntop( int family, void *addr, char *buffer, SIZE_T l
switch
(
family
)
{
case
WS_
AF_INET
:
case
AF_INET
:
{
status
=
RtlIpv4AddressToStringExA
(
(
IN_ADDR
*
)
addr
,
0
,
buffer
,
&
size
);
break
;
}
case
WS_
AF_INET6
:
case
AF_INET6
:
{
status
=
RtlIpv6AddressToStringExA
(
(
IN6_ADDR
*
)
addr
,
0
,
0
,
buffer
,
&
size
);
break
;
...
...
@@ -1449,7 +1430,7 @@ const char * WINAPI WS_inet_ntop( int family, void *addr, char *buffer, SIZE_T l
/***********************************************************************
* inet_pton (ws2_32.@)
*/
int
WINAPI
WS_
inet_pton
(
int
family
,
const
char
*
addr
,
void
*
buffer
)
int
WINAPI
inet_pton
(
int
family
,
const
char
*
addr
,
void
*
buffer
)
{
NTSTATUS
status
;
const
char
*
terminator
;
...
...
@@ -1464,10 +1445,10 @@ int WINAPI WS_inet_pton( int family, const char *addr, void *buffer )
switch
(
family
)
{
case
WS_
AF_INET
:
case
AF_INET
:
status
=
RtlIpv4StringToAddressA
(
addr
,
TRUE
,
&
terminator
,
buffer
);
break
;
case
WS_
AF_INET6
:
case
AF_INET6
:
status
=
RtlIpv6StringToAddressA
(
addr
,
&
terminator
,
buffer
);
break
;
default:
...
...
@@ -1503,7 +1484,7 @@ int WINAPI InetPtonW( int family, const WCHAR *addr, void *buffer )
}
WideCharToMultiByte
(
CP_ACP
,
0
,
addr
,
-
1
,
addrA
,
len
,
NULL
,
NULL
);
ret
=
WS_
inet_pton
(
family
,
addrA
,
buffer
);
ret
=
inet_pton
(
family
,
addrA
,
buffer
);
if
(
!
ret
)
SetLastError
(
WSAEINVAL
);
HeapFree
(
GetProcessHeap
(),
0
,
addrA
);
...
...
@@ -1515,12 +1496,12 @@ int WINAPI InetPtonW( int family, const WCHAR *addr, void *buffer )
*/
const
WCHAR
*
WINAPI
InetNtopW
(
int
family
,
void
*
addr
,
WCHAR
*
buffer
,
SIZE_T
len
)
{
char
bufferA
[
WS_
INET6_ADDRSTRLEN
];
char
bufferA
[
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
(
inet_ntop
(
family
,
addr
,
bufferA
,
sizeof
(
bufferA
)
))
{
if
(
MultiByteToWideChar
(
CP_ACP
,
0
,
bufferA
,
-
1
,
buffer
,
len
))
ret
=
buffer
;
...
...
@@ -1535,7 +1516,7 @@ const WCHAR * WINAPI InetNtopW( int family, void *addr, WCHAR *buffer, SIZE_T le
* WSAStringToAddressA (ws2_32.@)
*/
int
WINAPI
WSAStringToAddressA
(
char
*
string
,
int
family
,
WSAPROTOCOL_INFOA
*
protocol_info
,
struct
WS_
sockaddr
*
addr
,
int
*
addr_len
)
struct
sockaddr
*
addr
,
int
*
addr_len
)
{
NTSTATUS
status
;
...
...
@@ -1554,17 +1535,17 @@ int WINAPI WSAStringToAddressA( char *string, int family, WSAPROTOCOL_INFOA *pro
switch
(
family
)
{
case
WS_
AF_INET
:
case
AF_INET
:
{
struct
WS_sockaddr_in
*
addr4
=
(
struct
WS_
sockaddr_in
*
)
addr
;
struct
sockaddr_in
*
addr4
=
(
struct
sockaddr_in
*
)
addr
;
if
(
*
addr_len
<
sizeof
(
struct
WS_
sockaddr_in
))
if
(
*
addr_len
<
sizeof
(
struct
sockaddr_in
))
{
*
addr_len
=
sizeof
(
struct
WS_
sockaddr_in
);
*
addr_len
=
sizeof
(
struct
sockaddr_in
);
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
memset
(
addr
,
0
,
sizeof
(
struct
WS_
sockaddr_in
)
);
memset
(
addr
,
0
,
sizeof
(
struct
sockaddr_in
)
);
status
=
RtlIpv4StringToAddressExA
(
string
,
FALSE
,
&
addr4
->
sin_addr
,
&
addr4
->
sin_port
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
@@ -1572,21 +1553,21 @@ int WINAPI WSAStringToAddressA( char *string, int family, WSAPROTOCOL_INFOA *pro
SetLastError
(
WSAEINVAL
);
return
-
1
;
}
addr4
->
sin_family
=
WS_
AF_INET
;
*
addr_len
=
sizeof
(
struct
WS_
sockaddr_in
);
addr4
->
sin_family
=
AF_INET
;
*
addr_len
=
sizeof
(
struct
sockaddr_in
);
return
0
;
}
case
WS_
AF_INET6
:
case
AF_INET6
:
{
struct
WS_sockaddr_in6
*
addr6
=
(
struct
WS_
sockaddr_in6
*
)
addr
;
struct
sockaddr_in6
*
addr6
=
(
struct
sockaddr_in6
*
)
addr
;
if
(
*
addr_len
<
sizeof
(
struct
WS_
sockaddr_in6
))
if
(
*
addr_len
<
sizeof
(
struct
sockaddr_in6
))
{
*
addr_len
=
sizeof
(
struct
WS_
sockaddr_in6
);
*
addr_len
=
sizeof
(
struct
sockaddr_in6
);
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
memset
(
addr
,
0
,
sizeof
(
struct
WS_
sockaddr_in6
)
);
memset
(
addr
,
0
,
sizeof
(
struct
sockaddr_in6
)
);
status
=
RtlIpv6StringToAddressExA
(
string
,
&
addr6
->
sin6_addr
,
&
addr6
->
sin6_scope_id
,
&
addr6
->
sin6_port
);
if
(
status
!=
STATUS_SUCCESS
)
...
...
@@ -1594,8 +1575,8 @@ int WINAPI WSAStringToAddressA( char *string, int family, WSAPROTOCOL_INFOA *pro
SetLastError
(
WSAEINVAL
);
return
-
1
;
}
addr6
->
sin6_family
=
WS_
AF_INET6
;
*
addr_len
=
sizeof
(
struct
WS_
sockaddr_in6
);
addr6
->
sin6_family
=
AF_INET6
;
*
addr_len
=
sizeof
(
struct
sockaddr_in6
);
return
0
;
}
default:
...
...
@@ -1611,7 +1592,7 @@ int WINAPI WSAStringToAddressA( char *string, int family, WSAPROTOCOL_INFOA *pro
* WSAStringToAddressW (ws2_32.@)
*/
int
WINAPI
WSAStringToAddressW
(
WCHAR
*
string
,
int
family
,
WSAPROTOCOL_INFOW
*
protocol_info
,
struct
WS_
sockaddr
*
addr
,
int
*
addr_len
)
struct
sockaddr
*
addr
,
int
*
addr_len
)
{
WSAPROTOCOL_INFOA
infoA
;
WSAPROTOCOL_INFOA
*
protocol_infoA
=
NULL
;
...
...
@@ -1657,7 +1638,7 @@ int WINAPI WSAStringToAddressW( WCHAR *string, int family, WSAPROTOCOL_INFOW *pr
/***********************************************************************
* WSAAddressToStringA (ws2_32.@)
*/
int
WINAPI
WSAAddressToStringA
(
struct
WS_
sockaddr
*
addr
,
DWORD
addr_len
,
int
WINAPI
WSAAddressToStringA
(
struct
sockaddr
*
addr
,
DWORD
addr_len
,
WSAPROTOCOL_INFOA
*
info
,
char
*
string
,
DWORD
*
string_len
)
{
char
buffer
[
54
];
/* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */
...
...
@@ -1670,13 +1651,13 @@ int WINAPI WSAAddressToStringA( struct WS_sockaddr *addr, DWORD addr_len,
switch
(
addr
->
sa_family
)
{
case
WS_
AF_INET
:
case
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
);
const
struct
sockaddr_in
*
addr4
=
(
const
struct
sockaddr_in
*
)
addr
;
unsigned
int
long_ip
=
ntohl
(
addr4
->
sin_addr
.
s_addr
);
char
*
p
;
if
(
addr_len
<
sizeof
(
struct
WS_
sockaddr_in
))
return
-
1
;
if
(
addr_len
<
sizeof
(
struct
sockaddr_in
))
return
-
1
;
sprintf
(
buffer
,
"%u.%u.%u.%u:%u"
,
(
long_ip
>>
24
)
&
0xff
,
(
long_ip
>>
16
)
&
0xff
,
...
...
@@ -1688,17 +1669,17 @@ int WINAPI WSAAddressToStringA( struct WS_sockaddr *addr, DWORD addr_len,
if
(
!
addr4
->
sin_port
)
*
p
=
0
;
break
;
}
case
WS_
AF_INET6
:
case
AF_INET6
:
{
struct
WS_sockaddr_in6
*
addr6
=
(
struct
WS_
sockaddr_in6
*
)
addr
;
struct
sockaddr_in6
*
addr6
=
(
struct
sockaddr_in6
*
)
addr
;
size_t
len
;
buffer
[
0
]
=
0
;
if
(
addr_len
<
sizeof
(
struct
WS_
sockaddr_in6
))
return
-
1
;
if
(
addr_len
<
sizeof
(
struct
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
))
if
(
!
inet_ntop
(
AF_INET6
,
&
addr6
->
sin6_addr
,
&
buffer
[
len
],
sizeof
(
buffer
)
-
len
))
{
SetLastError
(
WSAEINVAL
);
return
-
1
;
...
...
@@ -1734,7 +1715,7 @@ int WINAPI WSAAddressToStringA( struct WS_sockaddr *addr, DWORD addr_len,
/***********************************************************************
* WSAAddressToStringW (ws2_32.@)
*/
int
WINAPI
WSAAddressToStringW
(
struct
WS_
sockaddr
*
addr
,
DWORD
addr_len
,
int
WINAPI
WSAAddressToStringW
(
struct
sockaddr
*
addr
,
DWORD
addr_len
,
WSAPROTOCOL_INFOW
*
info
,
WCHAR
*
string
,
DWORD
*
string_len
)
{
INT
ret
;
...
...
@@ -1753,20 +1734,20 @@ int WINAPI WSAAddressToStringW( struct WS_sockaddr *addr, DWORD addr_len,
/***********************************************************************
* inet_addr (ws2_32.11)
*/
WS_u_long
WINAPI
WS_
inet_addr
(
const
char
*
str
)
u_long
WINAPI
inet_addr
(
const
char
*
str
)
{
WS_
u_long
addr
;
u_long
addr
;
if
(
WS_inet_pton
(
WS_
AF_INET
,
str
,
&
addr
)
==
1
)
if
(
inet_pton
(
AF_INET
,
str
,
&
addr
)
==
1
)
return
addr
;
return
WS_
INADDR_NONE
;
return
INADDR_NONE
;
}
/***********************************************************************
* htonl (ws2_32.8)
*/
WS_u_long
WINAPI
WS_htonl
(
WS_
u_long
hostlong
)
u_long
WINAPI
WS_htonl
(
u_long
hostlong
)
{
return
htonl
(
hostlong
);
}
...
...
@@ -1775,7 +1756,7 @@ WS_u_long WINAPI WS_htonl( WS_u_long hostlong )
/***********************************************************************
* htons (ws2_32.9)
*/
WS_u_short
WINAPI
WS_htons
(
WS_
u_short
hostshort
)
u_short
WINAPI
WS_htons
(
u_short
hostshort
)
{
return
htons
(
hostshort
);
}
...
...
@@ -1784,7 +1765,7 @@ WS_u_short WINAPI WS_htons( WS_u_short hostshort )
/***********************************************************************
* WSAHtonl (ws2_32.@)
*/
int
WINAPI
WSAHtonl
(
SOCKET
s
,
WS_u_long
hostlong
,
WS_
u_long
*
netlong
)
int
WINAPI
WSAHtonl
(
SOCKET
s
,
u_long
hostlong
,
u_long
*
netlong
)
{
if
(
netlong
)
{
...
...
@@ -1799,7 +1780,7 @@ int WINAPI WSAHtonl( SOCKET s, WS_u_long hostlong, WS_u_long *netlong )
/***********************************************************************
* WSAHtons (ws2_32.@)
*/
int
WINAPI
WSAHtons
(
SOCKET
s
,
WS_u_short
hostshort
,
WS_
u_short
*
netshort
)
int
WINAPI
WSAHtons
(
SOCKET
s
,
u_short
hostshort
,
u_short
*
netshort
)
{
if
(
netshort
)
{
...
...
@@ -1814,7 +1795,7 @@ int WINAPI WSAHtons( SOCKET s, WS_u_short hostshort, WS_u_short *netshort )
/***********************************************************************
* ntohl (ws2_32.14)
*/
WS_u_long
WINAPI
WS_ntohl
(
WS_
u_long
netlong
)
u_long
WINAPI
WS_ntohl
(
u_long
netlong
)
{
return
ntohl
(
netlong
);
}
...
...
@@ -1823,7 +1804,7 @@ WS_u_long WINAPI WS_ntohl( WS_u_long netlong )
/***********************************************************************
* ntohs (ws2_32.15)
*/
WS_u_short
WINAPI
WS_ntohs
(
WS_
u_short
netshort
)
u_short
WINAPI
WS_ntohs
(
u_short
netshort
)
{
return
ntohs
(
netshort
);
}
...
...
@@ -1832,7 +1813,7 @@ WS_u_short WINAPI WS_ntohs( WS_u_short netshort )
/***********************************************************************
* WSANtohl (ws2_32.@)
*/
int
WINAPI
WSANtohl
(
SOCKET
s
,
WS_u_long
netlong
,
WS_
u_long
*
hostlong
)
int
WINAPI
WSANtohl
(
SOCKET
s
,
u_long
netlong
,
u_long
*
hostlong
)
{
if
(
!
hostlong
)
return
WSAEFAULT
;
...
...
@@ -1844,7 +1825,7 @@ int WINAPI WSANtohl( SOCKET s, WS_u_long netlong, WS_u_long *hostlong )
/***********************************************************************
* WSANtohs (ws2_32.@)
*/
int
WINAPI
WSANtohs
(
SOCKET
s
,
WS_u_short
netshort
,
WS_
u_short
*
hostshort
)
int
WINAPI
WSANtohs
(
SOCKET
s
,
u_short
netshort
,
u_short
*
hostshort
)
{
if
(
!
hostshort
)
return
WSAEFAULT
;
...
...
dlls/ws2_32/socket.c
View file @
815ac665
...
...
@@ -28,16 +28,6 @@
#include "ws2_32_private.h"
static
inline
unsigned
short
ntohs
(
unsigned
short
netshort
)
{
return
RtlUshortByteSwap
(
netshort
);
}
static
inline
unsigned
int
ntohl
(
unsigned
int
netlong
)
{
return
RtlUlongByteSwap
(
netlong
);
}
#define FILE_USE_FILE_POINTER_POSITION ((LONGLONG)-2)
WINE_DEFAULT_DEBUG_CHANNEL
(
winsock
);
...
...
@@ -55,11 +45,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1001
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_INET
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr_in
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_in
),
.
iSocketType
=
WS_
SOCK_STREAM
,
.
iProtocol
=
WS_
IPPROTO_TCP
,
.
iAddressFamily
=
AF_INET
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr_in
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_in
),
.
iSocketType
=
SOCK_STREAM
,
.
iProtocol
=
IPPROTO_TCP
,
.
szProtocol
=
L"TCP/IP"
,
},
{
...
...
@@ -70,11 +60,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1002
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_INET
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr_in
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_in
),
.
iSocketType
=
WS_
SOCK_DGRAM
,
.
iProtocol
=
WS_
IPPROTO_UDP
,
.
iAddressFamily
=
AF_INET
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr_in
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_in
),
.
iSocketType
=
SOCK_DGRAM
,
.
iProtocol
=
IPPROTO_UDP
,
.
dwMessageSize
=
0xffbb
,
.
szProtocol
=
L"UDP/IP"
,
},
...
...
@@ -86,11 +76,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1004
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_INET6
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr_in6
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_in6
),
.
iSocketType
=
WS_
SOCK_STREAM
,
.
iProtocol
=
WS_
IPPROTO_TCP
,
.
iAddressFamily
=
AF_INET6
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr_in6
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_in6
),
.
iSocketType
=
SOCK_STREAM
,
.
iProtocol
=
IPPROTO_TCP
,
.
szProtocol
=
L"TCP/IPv6"
,
},
{
...
...
@@ -101,11 +91,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1005
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_INET6
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr_in6
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_in6
),
.
iSocketType
=
WS_
SOCK_DGRAM
,
.
iProtocol
=
WS_
IPPROTO_UDP
,
.
iAddressFamily
=
AF_INET6
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr_in6
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_in6
),
.
iSocketType
=
SOCK_DGRAM
,
.
iProtocol
=
IPPROTO_UDP
,
.
dwMessageSize
=
0xffbb
,
.
szProtocol
=
L"UDP/IPv6"
,
},
...
...
@@ -117,11 +107,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1030
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_IPX
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_ipx
),
.
iSocketType
=
WS_
SOCK_DGRAM
,
.
iProtocol
=
WS_
NSPROTO_IPX
,
.
iAddressFamily
=
AF_IPX
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_ipx
),
.
iSocketType
=
SOCK_DGRAM
,
.
iProtocol
=
NSPROTO_IPX
,
.
iProtocolMaxOffset
=
255
,
.
dwMessageSize
=
0x240
,
.
szProtocol
=
L"IPX"
,
...
...
@@ -134,11 +124,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1031
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_IPX
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_ipx
),
.
iSocketType
=
WS_
SOCK_SEQPACKET
,
.
iProtocol
=
WS_
NSPROTO_SPX
,
.
iAddressFamily
=
AF_IPX
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_ipx
),
.
iSocketType
=
SOCK_SEQPACKET
,
.
iProtocol
=
NSPROTO_SPX
,
.
dwMessageSize
=
UINT_MAX
,
.
szProtocol
=
L"SPX"
,
},
...
...
@@ -150,11 +140,11 @@ static const WSAPROTOCOL_INFOW supported_protocols[] =
.
dwCatalogEntryId
=
1033
,
.
ProtocolChain
.
ChainLen
=
1
,
.
iVersion
=
2
,
.
iAddressFamily
=
WS_
AF_IPX
,
.
iMaxSockAddr
=
sizeof
(
struct
WS_
sockaddr
),
.
iMinSockAddr
=
sizeof
(
struct
WS_
sockaddr_ipx
),
.
iSocketType
=
WS_
SOCK_SEQPACKET
,
.
iProtocol
=
WS_
NSPROTO_SPXII
,
.
iAddressFamily
=
AF_IPX
,
.
iMaxSockAddr
=
sizeof
(
struct
sockaddr
),
.
iMinSockAddr
=
sizeof
(
struct
sockaddr_ipx
),
.
iSocketType
=
SOCK_SEQPACKET
,
.
iProtocol
=
NSPROTO_SPXII
,
.
dwMessageSize
=
UINT_MAX
,
.
szProtocol
=
L"SPX II"
,
},
...
...
@@ -165,41 +155,41 @@ DECLARE_CRITICAL_SECTION(cs_socket_list);
static
SOCKET
*
socket_list
;
static
unsigned
int
socket_list_size
;
const
char
*
debugstr_sockaddr
(
const
struct
WS_
sockaddr
*
a
)
const
char
*
debugstr_sockaddr
(
const
struct
sockaddr
*
a
)
{
if
(
!
a
)
return
"(nil)"
;
switch
(
a
->
sa_family
)
{
case
WS_
AF_INET
:
case
AF_INET
:
{
char
buf
[
16
];
const
char
*
p
;
struct
WS_sockaddr_in
*
sin
=
(
struct
WS_
sockaddr_in
*
)
a
;
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
a
;
p
=
WS_inet_ntop
(
WS_
AF_INET
,
&
sin
->
sin_addr
,
buf
,
sizeof
(
buf
)
);
p
=
inet_ntop
(
AF_INET
,
&
sin
->
sin_addr
,
buf
,
sizeof
(
buf
)
);
if
(
!
p
)
p
=
"(unknown IPv4 address)"
;
return
wine_dbg_sprintf
(
"{ family AF_INET, address %s, port %d }"
,
p
,
ntohs
(
sin
->
sin_port
));
}
case
WS_
AF_INET6
:
case
AF_INET6
:
{
char
buf
[
46
];
const
char
*
p
;
struct
WS_sockaddr_in6
*
sin
=
(
struct
WS_
sockaddr_in6
*
)
a
;
struct
sockaddr_in6
*
sin
=
(
struct
sockaddr_in6
*
)
a
;
p
=
WS_inet_ntop
(
WS_
AF_INET6
,
&
sin
->
sin6_addr
,
buf
,
sizeof
(
buf
)
);
p
=
inet_ntop
(
AF_INET6
,
&
sin
->
sin6_addr
,
buf
,
sizeof
(
buf
)
);
if
(
!
p
)
p
=
"(unknown IPv6 address)"
;
return
wine_dbg_sprintf
(
"{ family AF_INET6, address %s, flow label %#x, port %d, scope %u }"
,
p
,
sin
->
sin6_flowinfo
,
ntohs
(
sin
->
sin6_port
),
sin
->
sin6_scope_id
);
}
case
WS_
AF_IPX
:
case
AF_IPX
:
{
int
i
;
char
netnum
[
16
],
nodenum
[
16
];
struct
WS_sockaddr_ipx
*
sin
=
(
struct
WS_
sockaddr_ipx
*
)
a
;
struct
sockaddr_ipx
*
sin
=
(
struct
sockaddr_ipx
*
)
a
;
for
(
i
=
0
;
i
<
4
;
i
++
)
sprintf
(
netnum
+
i
*
2
,
"%02X"
,
(
unsigned
char
)
sin
->
sa_netnum
[
i
]);
for
(
i
=
0
;
i
<
6
;
i
++
)
sprintf
(
nodenum
+
i
*
2
,
"%02X"
,
(
unsigned
char
)
sin
->
sa_nodenum
[
i
]);
...
...
@@ -207,7 +197,7 @@ const char *debugstr_sockaddr( const struct WS_sockaddr *a )
return
wine_dbg_sprintf
(
"{ family AF_IPX, address %s.%s, ipx socket %d }"
,
netnum
,
nodenum
,
sin
->
sa_socket
);
}
case
WS_
AF_IRDA
:
case
AF_IRDA
:
{
DWORD
addr
;
...
...
@@ -231,100 +221,100 @@ static inline const char *debugstr_sockopt(int level, int optname)
switch
(
level
)
{
DEBUG_SOCKLEVEL
(
WS_
SOL_SOCKET
);
DEBUG_SOCKLEVEL
(
SOL_SOCKET
);
switch
(
optname
)
{
DEBUG_SOCKOPT
(
WS_
SO_ACCEPTCONN
);
DEBUG_SOCKOPT
(
WS_
SO_BROADCAST
);
DEBUG_SOCKOPT
(
WS_
SO_BSP_STATE
);
DEBUG_SOCKOPT
(
WS_
SO_CONDITIONAL_ACCEPT
);
DEBUG_SOCKOPT
(
WS_
SO_CONNECT_TIME
);
DEBUG_SOCKOPT
(
WS_
SO_DEBUG
);
DEBUG_SOCKOPT
(
WS_
SO_DONTLINGER
);
DEBUG_SOCKOPT
(
WS_
SO_DONTROUTE
);
DEBUG_SOCKOPT
(
WS_
SO_ERROR
);
DEBUG_SOCKOPT
(
WS_
SO_EXCLUSIVEADDRUSE
);
DEBUG_SOCKOPT
(
WS_
SO_GROUP_ID
);
DEBUG_SOCKOPT
(
WS_
SO_GROUP_PRIORITY
);
DEBUG_SOCKOPT
(
WS_
SO_KEEPALIVE
);
DEBUG_SOCKOPT
(
WS_
SO_LINGER
);
DEBUG_SOCKOPT
(
WS_
SO_MAX_MSG_SIZE
);
DEBUG_SOCKOPT
(
WS_
SO_OOBINLINE
);
DEBUG_SOCKOPT
(
WS_
SO_OPENTYPE
);
DEBUG_SOCKOPT
(
WS_
SO_PROTOCOL_INFOA
);
DEBUG_SOCKOPT
(
WS_
SO_PROTOCOL_INFOW
);
DEBUG_SOCKOPT
(
WS_
SO_RCVBUF
);
DEBUG_SOCKOPT
(
WS_
SO_RCVTIMEO
);
DEBUG_SOCKOPT
(
WS_
SO_REUSEADDR
);
DEBUG_SOCKOPT
(
WS_
SO_SNDBUF
);
DEBUG_SOCKOPT
(
WS_
SO_SNDTIMEO
);
DEBUG_SOCKOPT
(
WS_
SO_TYPE
);
DEBUG_SOCKOPT
(
WS_
SO_UPDATE_CONNECT_CONTEXT
);
DEBUG_SOCKOPT
(
SO_ACCEPTCONN
);
DEBUG_SOCKOPT
(
SO_BROADCAST
);
DEBUG_SOCKOPT
(
SO_BSP_STATE
);
DEBUG_SOCKOPT
(
SO_CONDITIONAL_ACCEPT
);
DEBUG_SOCKOPT
(
SO_CONNECT_TIME
);
DEBUG_SOCKOPT
(
SO_DEBUG
);
DEBUG_SOCKOPT
(
SO_DONTLINGER
);
DEBUG_SOCKOPT
(
SO_DONTROUTE
);
DEBUG_SOCKOPT
(
SO_ERROR
);
DEBUG_SOCKOPT
(
SO_EXCLUSIVEADDRUSE
);
DEBUG_SOCKOPT
(
SO_GROUP_ID
);
DEBUG_SOCKOPT
(
SO_GROUP_PRIORITY
);
DEBUG_SOCKOPT
(
SO_KEEPALIVE
);
DEBUG_SOCKOPT
(
SO_LINGER
);
DEBUG_SOCKOPT
(
SO_MAX_MSG_SIZE
);
DEBUG_SOCKOPT
(
SO_OOBINLINE
);
DEBUG_SOCKOPT
(
SO_OPENTYPE
);
DEBUG_SOCKOPT
(
SO_PROTOCOL_INFOA
);
DEBUG_SOCKOPT
(
SO_PROTOCOL_INFOW
);
DEBUG_SOCKOPT
(
SO_RCVBUF
);
DEBUG_SOCKOPT
(
SO_RCVTIMEO
);
DEBUG_SOCKOPT
(
SO_REUSEADDR
);
DEBUG_SOCKOPT
(
SO_SNDBUF
);
DEBUG_SOCKOPT
(
SO_SNDTIMEO
);
DEBUG_SOCKOPT
(
SO_TYPE
);
DEBUG_SOCKOPT
(
SO_UPDATE_CONNECT_CONTEXT
);
}
break
;
DEBUG_SOCKLEVEL
(
WS_
NSPROTO_IPX
);
DEBUG_SOCKLEVEL
(
NSPROTO_IPX
);
switch
(
optname
)
{
DEBUG_SOCKOPT
(
WS_
IPX_PTYPE
);
DEBUG_SOCKOPT
(
WS_
IPX_FILTERPTYPE
);
DEBUG_SOCKOPT
(
WS_
IPX_DSTYPE
);
DEBUG_SOCKOPT
(
WS_
IPX_RECVHDR
);
DEBUG_SOCKOPT
(
WS_
IPX_MAXSIZE
);
DEBUG_SOCKOPT
(
WS_
IPX_ADDRESS
);
DEBUG_SOCKOPT
(
WS_
IPX_MAX_ADAPTER_NUM
);
DEBUG_SOCKOPT
(
IPX_PTYPE
);
DEBUG_SOCKOPT
(
IPX_FILTERPTYPE
);
DEBUG_SOCKOPT
(
IPX_DSTYPE
);
DEBUG_SOCKOPT
(
IPX_RECVHDR
);
DEBUG_SOCKOPT
(
IPX_MAXSIZE
);
DEBUG_SOCKOPT
(
IPX_ADDRESS
);
DEBUG_SOCKOPT
(
IPX_MAX_ADAPTER_NUM
);
}
break
;
DEBUG_SOCKLEVEL
(
WS_
SOL_IRLMP
);
DEBUG_SOCKLEVEL
(
SOL_IRLMP
);
switch
(
optname
)
{
DEBUG_SOCKOPT
(
WS_
IRLMP_ENUMDEVICES
);
DEBUG_SOCKOPT
(
IRLMP_ENUMDEVICES
);
}
break
;
DEBUG_SOCKLEVEL
(
WS_
IPPROTO_TCP
);
DEBUG_SOCKLEVEL
(
IPPROTO_TCP
);
switch
(
optname
)
{
DEBUG_SOCKOPT
(
WS_
TCP_BSDURGENT
);
DEBUG_SOCKOPT
(
WS_
TCP_EXPEDITED_1122
);
DEBUG_SOCKOPT
(
WS_
TCP_NODELAY
);
DEBUG_SOCKOPT
(
TCP_BSDURGENT
);
DEBUG_SOCKOPT
(
TCP_EXPEDITED_1122
);
DEBUG_SOCKOPT
(
TCP_NODELAY
);
}
break
;
DEBUG_SOCKLEVEL
(
WS_
IPPROTO_IP
);
DEBUG_SOCKLEVEL
(
IPPROTO_IP
);
switch
(
optname
)
{
DEBUG_SOCKOPT
(
WS_
IP_ADD_MEMBERSHIP
);
DEBUG_SOCKOPT
(
WS_
IP_DONTFRAGMENT
);
DEBUG_SOCKOPT
(
WS_
IP_DROP_MEMBERSHIP
);
DEBUG_SOCKOPT
(
WS_
IP_HDRINCL
);
DEBUG_SOCKOPT
(
WS_
IP_MULTICAST_IF
);
DEBUG_SOCKOPT
(
WS_
IP_MULTICAST_LOOP
);
DEBUG_SOCKOPT
(
WS_
IP_MULTICAST_TTL
);
DEBUG_SOCKOPT
(
WS_
IP_OPTIONS
);
DEBUG_SOCKOPT
(
WS_
IP_PKTINFO
);
DEBUG_SOCKOPT
(
WS_
IP_RECEIVE_BROADCAST
);
DEBUG_SOCKOPT
(
WS_
IP_TOS
);
DEBUG_SOCKOPT
(
WS_
IP_TTL
);
DEBUG_SOCKOPT
(
WS_
IP_UNICAST_IF
);
DEBUG_SOCKOPT
(
IP_ADD_MEMBERSHIP
);
DEBUG_SOCKOPT
(
IP_DONTFRAGMENT
);
DEBUG_SOCKOPT
(
IP_DROP_MEMBERSHIP
);
DEBUG_SOCKOPT
(
IP_HDRINCL
);
DEBUG_SOCKOPT
(
IP_MULTICAST_IF
);
DEBUG_SOCKOPT
(
IP_MULTICAST_LOOP
);
DEBUG_SOCKOPT
(
IP_MULTICAST_TTL
);
DEBUG_SOCKOPT
(
IP_OPTIONS
);
DEBUG_SOCKOPT
(
IP_PKTINFO
);
DEBUG_SOCKOPT
(
IP_RECEIVE_BROADCAST
);
DEBUG_SOCKOPT
(
IP_TOS
);
DEBUG_SOCKOPT
(
IP_TTL
);
DEBUG_SOCKOPT
(
IP_UNICAST_IF
);
}
break
;
DEBUG_SOCKLEVEL
(
WS_
IPPROTO_IPV6
);
DEBUG_SOCKLEVEL
(
IPPROTO_IPV6
);
switch
(
optname
)
{
DEBUG_SOCKOPT
(
WS_
IPV6_ADD_MEMBERSHIP
);
DEBUG_SOCKOPT
(
WS_
IPV6_DROP_MEMBERSHIP
);
DEBUG_SOCKOPT
(
WS_
IPV6_HOPLIMIT
);
DEBUG_SOCKOPT
(
WS_
IPV6_MULTICAST_IF
);
DEBUG_SOCKOPT
(
WS_
IPV6_MULTICAST_HOPS
);
DEBUG_SOCKOPT
(
WS_
IPV6_MULTICAST_LOOP
);
DEBUG_SOCKOPT
(
WS_
IPV6_PKTINFO
);
DEBUG_SOCKOPT
(
WS_
IPV6_UNICAST_HOPS
);
DEBUG_SOCKOPT
(
WS_
IPV6_V6ONLY
);
DEBUG_SOCKOPT
(
WS_
IPV6_UNICAST_IF
);
DEBUG_SOCKOPT
(
WS_
IPV6_DONTFRAG
);
DEBUG_SOCKOPT
(
IPV6_ADD_MEMBERSHIP
);
DEBUG_SOCKOPT
(
IPV6_DROP_MEMBERSHIP
);
DEBUG_SOCKOPT
(
IPV6_HOPLIMIT
);
DEBUG_SOCKOPT
(
IPV6_MULTICAST_IF
);
DEBUG_SOCKOPT
(
IPV6_MULTICAST_HOPS
);
DEBUG_SOCKOPT
(
IPV6_MULTICAST_LOOP
);
DEBUG_SOCKOPT
(
IPV6_PKTINFO
);
DEBUG_SOCKOPT
(
IPV6_UNICAST_HOPS
);
DEBUG_SOCKOPT
(
IPV6_V6ONLY
);
DEBUG_SOCKOPT
(
IPV6_UNICAST_IF
);
DEBUG_SOCKOPT
(
IPV6_DONTFRAG
);
}
break
;
}
...
...
@@ -332,11 +322,11 @@ static inline const char *debugstr_sockopt(int level, int optname)
#undef DEBUG_SOCKOPT
if
(
!
strlevel
)
strlevel
=
wine_dbg_sprintf
(
"
WS_
0x%x"
,
level
);
strlevel
=
wine_dbg_sprintf
(
"0x%x"
,
level
);
if
(
!
stropt
)
stropt
=
wine_dbg_sprintf
(
"
WS_
0x%x"
,
optname
);
stropt
=
wine_dbg_sprintf
(
"0x%x"
,
optname
);
return
wine_dbg_sprintf
(
"level %s, name %s"
,
strlevel
+
3
,
stropt
+
3
);
return
wine_dbg_sprintf
(
"level %s, name %s"
,
strlevel
,
stropt
);
}
static
inline
const
char
*
debugstr_optval
(
const
char
*
optval
,
int
optlenval
)
...
...
@@ -420,8 +410,8 @@ static BOOL socket_list_remove( SOCKET socket )
return
FALSE
;
}
#define
WS_
MAX_SOCKETS_PER_PROCESS 128
/* reasonable guess */
#define
WS_
MAX_UDP_DATAGRAM 1024
#define MAX_SOCKETS_PER_PROCESS 128
/* reasonable guess */
#define MAX_UDP_DATAGRAM 1024
static
INT
WINAPI
WSA_DefaultBlockingHook
(
FARPROC
x
);
int
num_startup
;
...
...
@@ -589,8 +579,8 @@ int WINAPI WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData)
lpWSAData
->
wHighVersion
=
0x0202
;
strcpy
(
lpWSAData
->
szDescription
,
"WinSock 2.0"
);
strcpy
(
lpWSAData
->
szSystemStatus
,
"Running"
);
lpWSAData
->
iMaxSockets
=
WS_
MAX_SOCKETS_PER_PROCESS
;
lpWSAData
->
iMaxUdpDg
=
WS_
MAX_UDP_DATAGRAM
;
lpWSAData
->
iMaxSockets
=
MAX_SOCKETS_PER_PROCESS
;
lpWSAData
->
iMaxUdpDg
=
MAX_UDP_DATAGRAM
;
/* don't do anything with lpWSAData->lpVendorInfo */
/* (some apps don't allocate the space for this field) */
...
...
@@ -637,7 +627,6 @@ void WINAPI WSASetLastError(INT iError) {
SetLastError
(
iError
);
}
static
INT
WS_DuplicateSocket
(
BOOL
unicode
,
SOCKET
s
,
DWORD
dwProcessId
,
LPWSAPROTOCOL_INFOW
lpProtocolInfo
)
{
HANDLE
hProcess
;
...
...
@@ -725,7 +714,7 @@ static BOOL ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, i
/***********************************************************************
* accept (WS2_32.1)
*/
SOCKET
WINAPI
WS_accept
(
SOCKET
s
,
struct
WS_
sockaddr
*
addr
,
int
*
len
)
SOCKET
WINAPI
accept
(
SOCKET
s
,
struct
sockaddr
*
addr
,
int
*
len
)
{
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
...
...
@@ -757,9 +746,9 @@ SOCKET WINAPI WS_accept( SOCKET s, struct WS_sockaddr *addr, int *len )
CloseHandle
(
SOCKET2HANDLE
(
ret
)
);
return
INVALID_SOCKET
;
}
if
(
addr
&&
len
&&
WS_
getpeername
(
ret
,
addr
,
len
))
if
(
addr
&&
len
&&
getpeername
(
ret
,
addr
,
len
))
{
WS_
closesocket
(
ret
);
closesocket
(
ret
);
return
INVALID_SOCKET
;
}
...
...
@@ -867,9 +856,9 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE file, DWORD file_len, DWOR
/***********************************************************************
* GetAcceptExSockaddrs
*/
static
void
WINAPI
WS2_GetAcceptExSockaddrs
(
PVOID
buffer
,
DWORD
data_size
,
DWORD
local_size
,
DWORD
remote_size
,
struct
WS_
sockaddr
**
local_addr
,
LPINT
local_addr_len
,
struct
WS_sockaddr
**
remote_addr
,
LPINT
remote_addr_len
)
static
void
WINAPI
WS2_GetAcceptExSockaddrs
(
void
*
buffer
,
DWORD
data_size
,
DWORD
local_size
,
DWORD
remote_size
,
struct
sockaddr
**
local_addr
,
LPINT
local_addr_len
,
struct
sockaddr
**
remote_addr
,
LPINT
remote_addr_len
)
{
char
*
cbuf
=
buffer
;
TRACE
(
"(%p, %d, %d, %d, %p, %p, %p, %p)
\n
"
,
buffer
,
data_size
,
local_size
,
remote_size
,
local_addr
,
...
...
@@ -877,12 +866,12 @@ static void WINAPI WS2_GetAcceptExSockaddrs(PVOID buffer, DWORD data_size, DWORD
cbuf
+=
data_size
;
*
local_addr_len
=
*
(
int
*
)
cbuf
;
*
local_addr
=
(
struct
WS_
sockaddr
*
)(
cbuf
+
sizeof
(
int
));
*
local_addr
=
(
struct
sockaddr
*
)(
cbuf
+
sizeof
(
int
));
cbuf
+=
local_size
;
*
remote_addr_len
=
*
(
int
*
)
cbuf
;
*
remote_addr
=
(
struct
WS_
sockaddr
*
)(
cbuf
+
sizeof
(
int
));
*
remote_addr
=
(
struct
sockaddr
*
)(
cbuf
+
sizeof
(
int
));
}
...
...
@@ -893,7 +882,7 @@ static void WINAPI socket_apc( void *apc_user, IO_STATUS_BLOCK *io, ULONG reserv
}
static
int
WS2_recv_base
(
SOCKET
s
,
WSABUF
*
buffers
,
DWORD
buffer_count
,
DWORD
*
ret_size
,
DWORD
*
flags
,
struct
WS_
sockaddr
*
addr
,
int
*
addr_len
,
OVERLAPPED
*
overlapped
,
struct
sockaddr
*
addr
,
int
*
addr_len
,
OVERLAPPED
*
overlapped
,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
completion
,
WSABUF
*
control
)
{
IO_STATUS_BLOCK
iosb
,
*
piosb
=
&
iosb
;
...
...
@@ -948,7 +937,7 @@ static int WS2_recv_base( SOCKET s, WSABUF *buffers, DWORD buffer_count, DWORD *
}
static
int
WS2_sendto
(
SOCKET
s
,
WSABUF
*
buffers
,
DWORD
buffer_count
,
DWORD
*
ret_size
,
DWORD
flags
,
const
struct
WS_
sockaddr
*
addr
,
int
addr_len
,
OVERLAPPED
*
overlapped
,
const
struct
sockaddr
*
addr
,
int
addr_len
,
OVERLAPPED
*
overlapped
,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
completion
)
{
IO_STATUS_BLOCK
iosb
,
*
piosb
=
&
iosb
;
...
...
@@ -1059,10 +1048,10 @@ static int WINAPI WS2_WSARecvMsg( SOCKET s, LPWSAMSG msg, LPDWORD lpNumberOfByte
/***********************************************************************
* bind (ws2_32.2)
*/
int
WINAPI
WS_bind
(
SOCKET
s
,
const
struct
WS_
sockaddr
*
addr
,
int
len
)
int
WINAPI
bind
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
int
len
)
{
struct
afd_bind_params
*
params
;
struct
WS_
sockaddr
*
ret_addr
;
struct
sockaddr
*
ret_addr
;
IO_STATUS_BLOCK
io
;
HANDLE
sync_event
;
NTSTATUS
status
;
...
...
@@ -1077,31 +1066,31 @@ int WINAPI WS_bind( SOCKET s, const struct WS_sockaddr *addr, int len )
switch
(
addr
->
sa_family
)
{
case
WS_
AF_INET
:
if
(
len
<
sizeof
(
struct
WS_
sockaddr_in
))
case
AF_INET
:
if
(
len
<
sizeof
(
struct
sockaddr_in
))
{
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
break
;
case
WS_
AF_INET6
:
if
(
len
<
sizeof
(
struct
WS_
sockaddr_in6
))
case
AF_INET6
:
if
(
len
<
sizeof
(
struct
sockaddr_in6
))
{
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
break
;
case
WS_
AF_IPX
:
if
(
len
<
sizeof
(
struct
WS_
sockaddr_ipx
))
case
AF_IPX
:
if
(
len
<
sizeof
(
struct
sockaddr_ipx
))
{
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
break
;
case
WS_
AF_IRDA
:
case
AF_IRDA
:
if
(
len
<
sizeof
(
SOCKADDR_IRDA
))
{
SetLastError
(
WSAEFAULT
);
...
...
@@ -1149,7 +1138,7 @@ int WINAPI WS_bind( SOCKET s, const struct WS_sockaddr *addr, int len )
/***********************************************************************
* closesocket (ws2_32.3)
*/
int
WINAPI
WS_
closesocket
(
SOCKET
s
)
int
WINAPI
closesocket
(
SOCKET
s
)
{
TRACE
(
"%#lx
\n
"
,
s
);
...
...
@@ -1173,7 +1162,7 @@ int WINAPI WS_closesocket( SOCKET s )
/***********************************************************************
* connect (ws2_32.4)
*/
int
WINAPI
WS_connect
(
SOCKET
s
,
const
struct
WS_
sockaddr
*
addr
,
int
len
)
int
WINAPI
connect
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
int
len
)
{
struct
afd_connect_params
*
params
;
IO_STATUS_BLOCK
io
;
...
...
@@ -1214,17 +1203,17 @@ int WINAPI WS_connect( SOCKET s, const struct WS_sockaddr *addr, int len )
/***********************************************************************
* WSAConnect (WS2_32.30)
*/
int
WINAPI
WSAConnect
(
SOCKET
s
,
const
struct
WS_sockaddr
*
name
,
int
namelen
,
int
WINAPI
WSAConnect
(
SOCKET
s
,
const
struct
sockaddr
*
name
,
int
namelen
,
LPWSABUF
lpCallerData
,
LPWSABUF
lpCalleeData
,
LPQOS
lpSQOS
,
LPQOS
lpGQOS
)
{
if
(
lpCallerData
||
lpCalleeData
||
lpSQOS
||
lpGQOS
)
FIXME
(
"unsupported parameters!
\n
"
);
return
WS_
connect
(
s
,
name
,
namelen
);
return
connect
(
s
,
name
,
namelen
);
}
static
BOOL
WINAPI
WS2_ConnectEx
(
SOCKET
s
,
const
struct
WS_
sockaddr
*
name
,
int
namelen
,
static
BOOL
WINAPI
WS2_ConnectEx
(
SOCKET
s
,
const
struct
sockaddr
*
name
,
int
namelen
,
void
*
send_buffer
,
DWORD
send_len
,
DWORD
*
ret_len
,
OVERLAPPED
*
overlapped
)
{
struct
afd_connect_params
*
params
;
...
...
@@ -1297,7 +1286,7 @@ static BOOL WINAPI WS2_DisconnectEx( SOCKET s, OVERLAPPED *overlapped, DWORD fla
/***********************************************************************
* getpeername (ws2_32.5)
*/
int
WINAPI
WS_getpeername
(
SOCKET
s
,
struct
WS_
sockaddr
*
addr
,
int
*
len
)
int
WINAPI
getpeername
(
SOCKET
s
,
struct
sockaddr
*
addr
,
int
*
len
)
{
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
...
...
@@ -1328,7 +1317,7 @@ int WINAPI WS_getpeername( SOCKET s, struct WS_sockaddr *addr, int *len )
/***********************************************************************
* getsockname (ws2_32.6)
*/
int
WINAPI
WS_getsockname
(
SOCKET
s
,
struct
WS_
sockaddr
*
addr
,
int
*
len
)
int
WINAPI
getsockname
(
SOCKET
s
,
struct
sockaddr
*
addr
,
int
*
len
)
{
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
...
...
@@ -1364,8 +1353,7 @@ static int server_getsockopt( SOCKET s, ULONG code, char *optval, int *optlen )
/***********************************************************************
* getsockopt (WS2_32.7)
*/
INT
WINAPI
WS_getsockopt
(
SOCKET
s
,
INT
level
,
INT
optname
,
char
*
optval
,
INT
*
optlen
)
int
WINAPI
getsockopt
(
SOCKET
s
,
int
level
,
int
optname
,
char
*
optval
,
int
*
optlen
)
{
INT
ret
=
0
;
...
...
@@ -1375,17 +1363,17 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
switch
(
level
)
{
case
WS_
SOL_SOCKET
:
case
SOL_SOCKET
:
{
switch
(
optname
)
{
case
WS_
SO_ACCEPTCONN
:
case
SO_ACCEPTCONN
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_ACCEPTCONN
,
optval
,
optlen
);
case
WS_
SO_BROADCAST
:
case
SO_BROADCAST
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_BROADCAST
,
optval
,
optlen
);
case
WS_
SO_BSP_STATE
:
case
SO_BSP_STATE
:
{
CSADDR_INFO
*
csinfo
=
(
CSADDR_INFO
*
)
optval
;
WSAPROTOCOL_INFOW
infow
;
...
...
@@ -1394,10 +1382,10 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if
(
!
ws_protocol_info
(
s
,
TRUE
,
&
infow
,
&
addr_size
))
return
-
1
;
if
(
infow
.
iAddressFamily
==
WS_
AF_INET
)
addr_size
=
sizeof
(
struct
WS_
sockaddr_in
);
else
if
(
infow
.
iAddressFamily
==
WS_
AF_INET6
)
addr_size
=
sizeof
(
struct
WS_
sockaddr_in6
);
if
(
infow
.
iAddressFamily
==
AF_INET
)
addr_size
=
sizeof
(
struct
sockaddr_in
);
else
if
(
infow
.
iAddressFamily
==
AF_INET6
)
addr_size
=
sizeof
(
struct
sockaddr_in6
);
else
{
FIXME
(
"family %d is unsupported for SO_BSP_STATE
\n
"
,
infow
.
iAddressFamily
);
...
...
@@ -1412,18 +1400,18 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
-
1
;
}
csinfo
->
LocalAddr
.
lpSockaddr
=
(
struct
WS_
sockaddr
*
)(
csinfo
+
1
);
csinfo
->
RemoteAddr
.
lpSockaddr
=
(
struct
WS_
sockaddr
*
)((
char
*
)(
csinfo
+
1
)
+
addr_size
);
csinfo
->
LocalAddr
.
lpSockaddr
=
(
struct
sockaddr
*
)(
csinfo
+
1
);
csinfo
->
RemoteAddr
.
lpSockaddr
=
(
struct
sockaddr
*
)((
char
*
)(
csinfo
+
1
)
+
addr_size
);
csinfo
->
LocalAddr
.
iSockaddrLength
=
addr_size
;
if
(
WS_
getsockname
(
s
,
csinfo
->
LocalAddr
.
lpSockaddr
,
&
csinfo
->
LocalAddr
.
iSockaddrLength
)
<
0
)
if
(
getsockname
(
s
,
csinfo
->
LocalAddr
.
lpSockaddr
,
&
csinfo
->
LocalAddr
.
iSockaddrLength
)
<
0
)
{
csinfo
->
LocalAddr
.
lpSockaddr
=
NULL
;
csinfo
->
LocalAddr
.
iSockaddrLength
=
0
;
}
csinfo
->
RemoteAddr
.
iSockaddrLength
=
addr_size
;
if
(
WS_
getpeername
(
s
,
csinfo
->
RemoteAddr
.
lpSockaddr
,
&
csinfo
->
RemoteAddr
.
iSockaddrLength
)
<
0
)
if
(
getpeername
(
s
,
csinfo
->
RemoteAddr
.
lpSockaddr
,
&
csinfo
->
RemoteAddr
.
iSockaddrLength
)
<
0
)
{
csinfo
->
RemoteAddr
.
lpSockaddr
=
NULL
;
csinfo
->
RemoteAddr
.
iSockaddrLength
=
0
;
...
...
@@ -1434,15 +1422,15 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
0
;
}
case
WS_
SO_DEBUG
:
case
SO_DEBUG
:
WARN
(
"returning 0 for SO_DEBUG
\n
"
);
*
(
DWORD
*
)
optval
=
0
;
SetLastError
(
0
);
return
0
;
case
WS_
SO_DONTLINGER
:
case
SO_DONTLINGER
:
{
struct
WS_
linger
linger
;
struct
linger
linger
;
int
len
=
sizeof
(
linger
);
int
ret
;
...
...
@@ -1452,7 +1440,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
SOCKET_ERROR
;
}
if
(
!
(
ret
=
WS_getsockopt
(
s
,
WS_SOL_SOCKET
,
WS_
SO_LINGER
,
(
char
*
)
&
linger
,
&
len
)))
if
(
!
(
ret
=
getsockopt
(
s
,
SOL_SOCKET
,
SO_LINGER
,
(
char
*
)
&
linger
,
&
len
)))
{
*
(
BOOL
*
)
optval
=
!
linger
.
l_onoff
;
*
optlen
=
sizeof
(
BOOL
);
...
...
@@ -1460,10 +1448,10 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
ret
;
}
case
WS_
SO_CONNECT_TIME
:
case
SO_CONNECT_TIME
:
{
static
int
pretendtime
=
0
;
struct
WS_
sockaddr
addr
;
struct
sockaddr
addr
;
int
len
=
sizeof
(
addr
);
if
(
!
optlen
||
*
optlen
<
sizeof
(
DWORD
)
||
!
optval
)
...
...
@@ -1471,11 +1459,11 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
SetLastError
(
WSAEFAULT
);
return
SOCKET_ERROR
;
}
if
(
WS_
getpeername
(
s
,
&
addr
,
&
len
)
==
SOCKET_ERROR
)
if
(
getpeername
(
s
,
&
addr
,
&
len
)
==
SOCKET_ERROR
)
*
(
DWORD
*
)
optval
=
~
0u
;
else
{
if
(
!
pretendtime
)
FIXME
(
"
WS_
SO_CONNECT_TIME - faking results
\n
"
);
if
(
!
pretendtime
)
FIXME
(
"SO_CONNECT_TIME - faking results
\n
"
);
*
(
DWORD
*
)
optval
=
pretendtime
++
;
}
*
optlen
=
sizeof
(
DWORD
);
...
...
@@ -1483,7 +1471,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
}
/* As mentioned in setsockopt, Windows ignores this, so we
* always return true here */
case
WS_
SO_DONTROUTE
:
case
SO_DONTROUTE
:
if
(
!
optlen
||
*
optlen
<
sizeof
(
BOOL
)
||
!
optval
)
{
SetLastError
(
WSAEFAULT
);
...
...
@@ -1493,13 +1481,13 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
*
optlen
=
sizeof
(
BOOL
);
return
0
;
case
WS_
SO_ERROR
:
case
SO_ERROR
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_ERROR
,
optval
,
optlen
);
case
WS_
SO_KEEPALIVE
:
case
SO_KEEPALIVE
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_KEEPALIVE
,
optval
,
optlen
);
case
WS_
SO_LINGER
:
case
SO_LINGER
:
{
WSAPROTOCOL_INFOW
info
;
int
size
;
...
...
@@ -1514,7 +1502,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if
(
!
ws_protocol_info
(
s
,
TRUE
,
&
info
,
&
size
))
return
-
1
;
if
(
info
.
iSocketType
==
WS_
SOCK_DGRAM
)
if
(
info
.
iSocketType
==
SOCK_DGRAM
)
{
SetLastError
(
WSAENOPROTOOPT
);
return
-
1
;
...
...
@@ -1523,7 +1511,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_LINGER
,
optval
,
optlen
);
}
case
WS_
SO_MAX_MSG_SIZE
:
case
SO_MAX_MSG_SIZE
:
if
(
!
optlen
||
*
optlen
<
sizeof
(
int
)
||
!
optval
)
{
SetLastError
(
WSAEFAULT
);
...
...
@@ -1534,11 +1522,11 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
*
optlen
=
sizeof
(
int
);
return
0
;
case
WS_
SO_OOBINLINE
:
case
SO_OOBINLINE
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_OOBINLINE
,
optval
,
optlen
);
/* SO_OPENTYPE does not require a valid socket handle. */
case
WS_
SO_OPENTYPE
:
case
SO_OPENTYPE
:
if
(
!
optlen
||
*
optlen
<
sizeof
(
int
)
||
!
optval
)
{
SetLastError
(
WSAEFAULT
);
...
...
@@ -1548,13 +1536,14 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
*
optlen
=
sizeof
(
int
);
TRACE
(
"getting global SO_OPENTYPE = 0x%x
\n
"
,
*
((
int
*
)
optval
)
);
return
0
;
case
WS_SO_PROTOCOL_INFOA
:
case
WS_SO_PROTOCOL_INFOW
:
case
SO_PROTOCOL_INFOA
:
case
SO_PROTOCOL_INFOW
:
{
int
size
;
WSAPROTOCOL_INFOW
infow
;
ret
=
ws_protocol_info
(
s
,
optname
==
WS_
SO_PROTOCOL_INFOW
,
&
infow
,
&
size
);
ret
=
ws_protocol_info
(
s
,
optname
==
SO_PROTOCOL_INFOW
,
&
infow
,
&
size
);
if
(
ret
)
{
if
(
!
optlen
||
!
optval
||
*
optlen
<
size
)
...
...
@@ -1569,22 +1558,22 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
ret
?
0
:
SOCKET_ERROR
;
}
case
WS_
SO_RCVBUF
:
case
SO_RCVBUF
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_RCVBUF
,
optval
,
optlen
);
case
WS_
SO_RCVTIMEO
:
case
SO_RCVTIMEO
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_RCVTIMEO
,
optval
,
optlen
);
case
WS_
SO_REUSEADDR
:
case
SO_REUSEADDR
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_REUSEADDR
,
optval
,
optlen
);
case
WS_
SO_SNDBUF
:
case
SO_SNDBUF
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_SNDBUF
,
optval
,
optlen
);
case
WS_
SO_SNDTIMEO
:
case
SO_SNDTIMEO
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_SO_SNDTIMEO
,
optval
,
optlen
);
case
WS_
SO_TYPE
:
case
SO_TYPE
:
{
WSAPROTOCOL_INFOW
info
;
int
size
;
...
...
@@ -1607,16 +1596,16 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
SetLastError
(
WSAENOPROTOOPT
);
return
SOCKET_ERROR
;
}
/* end switch(optname) */
}
/* end case
WS_
SOL_SOCKET */
}
/* end case SOL_SOCKET */
case
WS_
NSPROTO_IPX
:
case
NSPROTO_IPX
:
{
struct
WS_
sockaddr_ipx
addr
;
struct
sockaddr_ipx
addr
;
IPX_ADDRESS_DATA
*
data
;
int
namelen
;
switch
(
optname
)
{
case
WS_
IPX_ADDRESS
:
case
IPX_ADDRESS
:
/*
* On a Win2000 system with one network card there are usually
* three ipx devices one with a speed of 28.8kbps, 10Mbps and 100Mbps.
...
...
@@ -1626,9 +1615,9 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
* query things like the linkspeed.
*/
FIXME
(
"IPX_ADDRESS
\n
"
);
namelen
=
sizeof
(
struct
WS_
sockaddr_ipx
);
memset
(
&
addr
,
0
,
sizeof
(
struct
WS_sockaddr_ipx
)
);
WS_getsockname
(
s
,
(
struct
WS_sockaddr
*
)
&
addr
,
&
namelen
);
namelen
=
sizeof
(
struct
sockaddr_ipx
);
memset
(
&
addr
,
0
,
sizeof
(
struct
sockaddr_ipx
)
);
getsockname
(
s
,
(
struct
sockaddr
*
)
&
addr
,
&
namelen
);
data
=
(
IPX_ADDRESS_DATA
*
)
optval
;
memcpy
(
data
->
nodenum
,
addr
.
sa_nodenum
,
sizeof
(
data
->
nodenum
));
...
...
@@ -1641,37 +1630,37 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
* note 1MB = 1000kB in this case */
return
0
;
case
WS_
IPX_MAX_ADAPTER_NUM
:
case
IPX_MAX_ADAPTER_NUM
:
FIXME
(
"IPX_MAX_ADAPTER_NUM
\n
"
);
*
(
int
*
)
optval
=
1
;
/* As noted under IPX_ADDRESS we have just one card. */
return
0
;
case
WS_
IPX_PTYPE
:
case
IPX_PTYPE
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPX_PTYPE
,
optval
,
optlen
);
default:
FIXME
(
"IPX optname:%x
\n
"
,
optname
);
return
SOCKET_ERROR
;
}
/* end switch(optname) */
}
/* end case
WS_
NSPROTO_IPX */
}
/* end case NSPROTO_IPX */
case
WS_
SOL_IRLMP
:
case
SOL_IRLMP
:
switch
(
optname
)
{
case
WS_
IRLMP_ENUMDEVICES
:
case
IRLMP_ENUMDEVICES
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES
,
optval
,
optlen
);
default:
FIXME
(
"IrDA optname:0x%x
\n
"
,
optname
);
return
SOCKET_ERROR
;
}
break
;
/* case
WS_
SOL_IRLMP */
break
;
/* case SOL_IRLMP */
/* Levels
WS_IPPROTO_TCP and WS_
IPPROTO_IP convert directly */
case
WS_
IPPROTO_TCP
:
/* Levels
IPPROTO_TCP and
IPPROTO_IP convert directly */
case
IPPROTO_TCP
:
switch
(
optname
)
{
case
WS_
TCP_NODELAY
:
case
TCP_NODELAY
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_TCP_NODELAY
,
optval
,
optlen
);
default:
...
...
@@ -1680,85 +1669,85 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return
-
1
;
}
case
WS_
IPPROTO_IP
:
case
IPPROTO_IP
:
switch
(
optname
)
{
case
WS_
IP_DONTFRAGMENT
:
case
IP_DONTFRAGMENT
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_DONTFRAGMENT
,
optval
,
optlen
);
case
WS_
IP_HDRINCL
:
case
IP_HDRINCL
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_HDRINCL
,
optval
,
optlen
);
case
WS_
IP_MULTICAST_IF
:
case
IP_MULTICAST_IF
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_MULTICAST_IF
,
optval
,
optlen
);
case
WS_
IP_MULTICAST_LOOP
:
case
IP_MULTICAST_LOOP
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_MULTICAST_LOOP
,
optval
,
optlen
);
case
WS_
IP_MULTICAST_TTL
:
case
IP_MULTICAST_TTL
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_MULTICAST_TTL
,
optval
,
optlen
);
case
WS_
IP_OPTIONS
:
case
IP_OPTIONS
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_OPTIONS
,
optval
,
optlen
);
case
WS_
IP_PKTINFO
:
case
IP_PKTINFO
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_PKTINFO
,
optval
,
optlen
);
case
WS_
IP_TOS
:
case
IP_TOS
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_TOS
,
optval
,
optlen
);
case
WS_
IP_TTL
:
case
IP_TTL
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_TTL
,
optval
,
optlen
);
case
WS_
IP_UNICAST_IF
:
case
IP_UNICAST_IF
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IP_UNICAST_IF
,
optval
,
optlen
);
default:
FIXME
(
"unrecognized IP option %u
\n
"
,
optname
);
/* fall through */
case
WS_
IP_ADD_MEMBERSHIP
:
case
WS_
IP_DROP_MEMBERSHIP
:
case
IP_ADD_MEMBERSHIP
:
case
IP_DROP_MEMBERSHIP
:
SetLastError
(
WSAENOPROTOOPT
);
return
-
1
;
}
case
WS_
IPPROTO_IPV6
:
case
IPPROTO_IPV6
:
switch
(
optname
)
{
case
WS_
IPV6_DONTFRAG
:
case
IPV6_DONTFRAG
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_DONTFRAG
,
optval
,
optlen
);
case
WS_
IPV6_HOPLIMIT
:
case
IPV6_HOPLIMIT
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_RECVHOPLIMIT
,
optval
,
optlen
);
case
WS_
IPV6_MULTICAST_HOPS
:
case
IPV6_MULTICAST_HOPS
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_MULTICAST_HOPS
,
optval
,
optlen
);
case
WS_
IPV6_MULTICAST_IF
:
case
IPV6_MULTICAST_IF
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_MULTICAST_IF
,
optval
,
optlen
);
case
WS_
IPV6_MULTICAST_LOOP
:
case
IPV6_MULTICAST_LOOP
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_MULTICAST_LOOP
,
optval
,
optlen
);
case
WS_
IPV6_PKTINFO
:
case
IPV6_PKTINFO
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_RECVPKTINFO
,
optval
,
optlen
);
case
WS_
IPV6_UNICAST_HOPS
:
case
IPV6_UNICAST_HOPS
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_UNICAST_HOPS
,
optval
,
optlen
);
case
WS_
IPV6_UNICAST_IF
:
case
IPV6_UNICAST_IF
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_UNICAST_IF
,
optval
,
optlen
);
case
WS_
IPV6_V6ONLY
:
case
IPV6_V6ONLY
:
return
server_getsockopt
(
s
,
IOCTL_AFD_WINE_GET_IPV6_V6ONLY
,
optval
,
optlen
);
default:
FIXME
(
"unrecognized IPv6 option %u
\n
"
,
optname
);
/* fall through */
case
WS_
IPV6_ADD_MEMBERSHIP
:
case
WS_
IPV6_DROP_MEMBERSHIP
:
case
IPV6_ADD_MEMBERSHIP
:
case
IPV6_DROP_MEMBERSHIP
:
SetLastError
(
WSAENOPROTOOPT
);
return
-
1
;
}
...
...
@@ -1773,87 +1762,84 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
static
const
char
*
debugstr_wsaioctl
(
DWORD
code
)
{
const
char
*
name
=
NULL
,
*
buf_type
,
*
family
;
const
char
*
buf_type
,
*
family
;
#define IOCTL_NAME(x) case x:
name = #x; break
#define IOCTL_NAME(x) case x:
return #x
switch
(
code
)
{
IOCTL_NAME
(
WS_
FIONBIO
);
IOCTL_NAME
(
WS_
FIONREAD
);
IOCTL_NAME
(
WS_
SIOCATMARK
);
/* IOCTL_NAME(
WS_
SIO_ACQUIRE_PORT_RESERVATION); */
IOCTL_NAME
(
WS_
SIO_ADDRESS_LIST_CHANGE
);
IOCTL_NAME
(
WS_
SIO_ADDRESS_LIST_QUERY
);
IOCTL_NAME
(
WS_
SIO_ASSOCIATE_HANDLE
);
/* IOCTL_NAME(
WS_
SIO_ASSOCIATE_PORT_RESERVATION);
IOCTL_NAME(
WS_
SIO_BASE_HANDLE);
IOCTL_NAME(
WS_
SIO_BSP_HANDLE);
IOCTL_NAME(
WS_
SIO_BSP_HANDLE_SELECT);
IOCTL_NAME(
WS_
SIO_BSP_HANDLE_POLL);
IOCTL_NAME(
WS_
SIO_CHK_QOS); */
IOCTL_NAME
(
WS_
SIO_ENABLE_CIRCULAR_QUEUEING
);
IOCTL_NAME
(
WS_
SIO_FIND_ROUTE
);
IOCTL_NAME
(
WS_
SIO_FLUSH
);
IOCTL_NAME
(
WS_
SIO_GET_BROADCAST_ADDRESS
);
IOCTL_NAME
(
WS_
SIO_GET_EXTENSION_FUNCTION_POINTER
);
IOCTL_NAME
(
WS_
SIO_GET_GROUP_QOS
);
IOCTL_NAME
(
WS_
SIO_GET_INTERFACE_LIST
);
/* IOCTL_NAME(
WS_
SIO_GET_INTERFACE_LIST_EX); */
IOCTL_NAME
(
WS_
SIO_GET_QOS
);
IOCTL_NAME
(
WS_
SIO_IDEAL_SEND_BACKLOG_CHANGE
);
IOCTL_NAME
(
WS_
SIO_IDEAL_SEND_BACKLOG_QUERY
);
IOCTL_NAME
(
WS_
SIO_KEEPALIVE_VALS
);
IOCTL_NAME
(
WS_
SIO_MULTIPOINT_LOOPBACK
);
IOCTL_NAME
(
WS_
SIO_MULTICAST_SCOPE
);
/* IOCTL_NAME(
WS_
SIO_QUERY_RSS_SCALABILITY_INFO);
IOCTL_NAME(
WS_
SIO_QUERY_WFP_ALE_ENDPOINT_HANDLE); */
IOCTL_NAME
(
WS_
SIO_RCVALL
);
IOCTL_NAME
(
WS_
SIO_RCVALL_IGMPMCAST
);
IOCTL_NAME
(
WS_
SIO_RCVALL_MCAST
);
/* IOCTL_NAME(
WS_
SIO_RELEASE_PORT_RESERVATION); */
IOCTL_NAME
(
WS_
SIO_ROUTING_INTERFACE_CHANGE
);
IOCTL_NAME
(
WS_
SIO_ROUTING_INTERFACE_QUERY
);
IOCTL_NAME
(
WS_
SIO_SET_COMPATIBILITY_MODE
);
IOCTL_NAME
(
WS_
SIO_SET_GROUP_QOS
);
IOCTL_NAME
(
WS_
SIO_SET_QOS
);
IOCTL_NAME
(
WS_
SIO_TRANSLATE_HANDLE
);
IOCTL_NAME
(
WS_
SIO_UDP_CONNRESET
);
IOCTL_NAME
(
FIONBIO
);
IOCTL_NAME
(
FIONREAD
);
IOCTL_NAME
(
SIOCATMARK
);
/* IOCTL_NAME(SIO_ACQUIRE_PORT_RESERVATION); */
IOCTL_NAME
(
SIO_ADDRESS_LIST_CHANGE
);
IOCTL_NAME
(
SIO_ADDRESS_LIST_QUERY
);
IOCTL_NAME
(
SIO_ASSOCIATE_HANDLE
);
/* IOCTL_NAME(SIO_ASSOCIATE_PORT_RESERVATION);
IOCTL_NAME(SIO_BASE_HANDLE);
IOCTL_NAME(SIO_BSP_HANDLE);
IOCTL_NAME(SIO_BSP_HANDLE_SELECT);
IOCTL_NAME(SIO_BSP_HANDLE_POLL);
IOCTL_NAME(SIO_CHK_QOS); */
IOCTL_NAME
(
SIO_ENABLE_CIRCULAR_QUEUEING
);
IOCTL_NAME
(
SIO_FIND_ROUTE
);
IOCTL_NAME
(
SIO_FLUSH
);
IOCTL_NAME
(
SIO_GET_BROADCAST_ADDRESS
);
IOCTL_NAME
(
SIO_GET_EXTENSION_FUNCTION_POINTER
);
IOCTL_NAME
(
SIO_GET_GROUP_QOS
);
IOCTL_NAME
(
SIO_GET_INTERFACE_LIST
);
/* IOCTL_NAME(SIO_GET_INTERFACE_LIST_EX); */
IOCTL_NAME
(
SIO_GET_QOS
);
IOCTL_NAME
(
SIO_IDEAL_SEND_BACKLOG_CHANGE
);
IOCTL_NAME
(
SIO_IDEAL_SEND_BACKLOG_QUERY
);
IOCTL_NAME
(
SIO_KEEPALIVE_VALS
);
IOCTL_NAME
(
SIO_MULTIPOINT_LOOPBACK
);
IOCTL_NAME
(
SIO_MULTICAST_SCOPE
);
/* IOCTL_NAME(SIO_QUERY_RSS_SCALABILITY_INFO);
IOCTL_NAME(SIO_QUERY_WFP_ALE_ENDPOINT_HANDLE); */
IOCTL_NAME
(
SIO_RCVALL
);
IOCTL_NAME
(
SIO_RCVALL_IGMPMCAST
);
IOCTL_NAME
(
SIO_RCVALL_MCAST
);
/* IOCTL_NAME(SIO_RELEASE_PORT_RESERVATION); */
IOCTL_NAME
(
SIO_ROUTING_INTERFACE_CHANGE
);
IOCTL_NAME
(
SIO_ROUTING_INTERFACE_QUERY
);
IOCTL_NAME
(
SIO_SET_COMPATIBILITY_MODE
);
IOCTL_NAME
(
SIO_SET_GROUP_QOS
);
IOCTL_NAME
(
SIO_SET_QOS
);
IOCTL_NAME
(
SIO_TRANSLATE_HANDLE
);
IOCTL_NAME
(
SIO_UDP_CONNRESET
);
}
#undef IOCTL_NAME
if
(
name
)
return
name
+
3
;
/* If this is not a known code split its bits */
switch
(
code
&
0x18000000
)
{
case
WS_
IOC_WS2
:
case
IOC_WS2
:
family
=
"IOC_WS2"
;
break
;
case
WS_
IOC_PROTOCOL
:
case
IOC_PROTOCOL
:
family
=
"IOC_PROTOCOL"
;
break
;
case
WS_
IOC_VENDOR
:
case
IOC_VENDOR
:
family
=
"IOC_VENDOR"
;
break
;
default:
/*
WS_
IOC_UNIX */
default:
/* IOC_UNIX */
{
BYTE
size
=
(
code
>>
16
)
&
WS_
IOCPARM_MASK
;
BYTE
size
=
(
code
>>
16
)
&
IOCPARM_MASK
;
char
x
=
(
code
&
0xff00
)
>>
8
;
BYTE
y
=
code
&
0xff
;
char
args
[
14
];
switch
(
code
&
(
WS_IOC_VOID
|
WS_
IOC_INOUT
))
switch
(
code
&
(
IOC_VOID
|
IOC_INOUT
))
{
case
WS_
IOC_VOID
:
case
IOC_VOID
:
buf_type
=
"_IO"
;
sprintf
(
args
,
"%d, %d"
,
x
,
y
);
break
;
case
WS_
IOC_IN
:
case
IOC_IN
:
buf_type
=
"_IOW"
;
sprintf
(
args
,
"'%c', %d, %d"
,
x
,
y
,
size
);
break
;
case
WS_
IOC_OUT
:
case
IOC_OUT
:
buf_type
=
"_IOR"
;
sprintf
(
args
,
"'%c', %d, %d"
,
x
,
y
,
size
);
break
;
...
...
@@ -1866,19 +1852,19 @@ static const char *debugstr_wsaioctl(DWORD code)
}
}
/* We are different from
WS_
IOC_UNIX. */
switch
(
code
&
(
WS_IOC_VOID
|
WS_
IOC_INOUT
))
/* We are different from IOC_UNIX. */
switch
(
code
&
(
IOC_VOID
|
IOC_INOUT
))
{
case
WS_
IOC_VOID
:
case
IOC_VOID
:
buf_type
=
"_WSAIO"
;
break
;
case
WS_
IOC_INOUT
:
case
IOC_INOUT
:
buf_type
=
"_WSAIORW"
;
break
;
case
WS_
IOC_IN
:
case
IOC_IN
:
buf_type
=
"_WSAIOW"
;
break
;
case
WS_
IOC_OUT
:
case
IOC_OUT
:
buf_type
=
"_WSAIOR"
;
break
;
default:
...
...
@@ -1960,7 +1946,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
switch
(
code
)
{
case
WS_
FIONBIO
:
case
FIONBIO
:
{
DWORD
ret
;
...
...
@@ -1978,29 +1964,29 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
return
ret
?
-
1
:
0
;
}
case
WS_
FIONREAD
:
case
FIONREAD
:
{
DWORD
ret
;
ret
=
server_ioctl_sock
(
s
,
IOCTL_AFD_WINE_FIONREAD
,
in_buff
,
in_size
,
out_buff
,
out_size
,
ret_size
,
overlapped
,
completion
);
SetLastError
(
ret
);
if
(
!
ret
)
*
ret_size
=
sizeof
(
WS_
u_long
);
if
(
!
ret
)
*
ret_size
=
sizeof
(
u_long
);
return
ret
?
-
1
:
0
;
}
case
WS_
SIOCATMARK
:
case
SIOCATMARK
:
{
DWORD
ret
;
ret
=
server_ioctl_sock
(
s
,
IOCTL_AFD_WINE_SIOCATMARK
,
in_buff
,
in_size
,
out_buff
,
out_size
,
ret_size
,
overlapped
,
completion
);
SetLastError
(
ret
);
if
(
!
ret
)
*
ret_size
=
sizeof
(
WS_
u_long
);
if
(
!
ret
)
*
ret_size
=
sizeof
(
u_long
);
return
ret
?
-
1
:
0
;
}
case
WS_
SIO_GET_INTERFACE_LIST
:
case
SIO_GET_INTERFACE_LIST
:
{
DWORD
ret
;
...
...
@@ -2011,7 +1997,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
return
ret
?
-
1
:
0
;
}
case
WS_
SIO_ADDRESS_LIST_QUERY
:
case
SIO_ADDRESS_LIST_QUERY
:
{
DWORD
size
,
total
;
...
...
@@ -2066,9 +2052,9 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
sa
[
i
].
lpSockaddr
=
(
SOCKADDR
*
)
&
sockaddr
[
i
];
sa
[
i
].
iSockaddrLength
=
sizeof
(
SOCKADDR
);
sockaddr
[
i
].
sin_family
=
WS_
AF_INET
;
sockaddr
[
i
].
sin_family
=
AF_INET
;
sockaddr
[
i
].
sin_port
=
0
;
sockaddr
[
i
].
sin_addr
.
WS_s_addr
=
WS_inet_addr
(
p
->
IpAddressList
.
IpAddress
.
String
);
sockaddr
[
i
].
sin_addr
.
s_addr
=
inet_addr
(
p
->
IpAddressList
.
IpAddress
.
String
);
i
++
;
}
...
...
@@ -2088,7 +2074,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
}
}
case
WS_
SIO_GET_EXTENSION_FUNCTION_POINTER
:
case
SIO_GET_EXTENSION_FUNCTION_POINTER
:
{
#define EXTENSION_FUNCTION(x, y) { x, y, #y },
static
const
struct
...
...
@@ -2132,7 +2118,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
return
-
1
;
}
case
WS_
SIO_KEEPALIVE_VALS
:
case
SIO_KEEPALIVE_VALS
:
{
DWORD
ret
;
...
...
@@ -2143,25 +2129,23 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
return
ret
?
-
1
:
0
;
}
case
WS_
SIO_ROUTING_INTERFACE_QUERY
:
case
SIO_ROUTING_INTERFACE_QUERY
:
{
struct
WS_sockaddr
*
daddr
=
(
struct
WS_
sockaddr
*
)
in_buff
;
struct
WS_sockaddr_in
*
daddr_in
=
(
struct
WS_
sockaddr_in
*
)
daddr
;
struct
WS_
sockaddr_in
*
saddr_in
=
out_buff
;
struct
sockaddr
*
daddr
=
(
struct
sockaddr
*
)
in_buff
;
struct
sockaddr_in
*
daddr_in
=
(
struct
sockaddr_in
*
)
daddr
;
struct
sockaddr_in
*
saddr_in
=
out_buff
;
MIB_IPFORWARDROW
row
;
PMIB_IPADDRTABLE
ipAddrTable
=
NULL
;
DWORD
size
,
i
,
found_index
,
ret
=
0
;
NTSTATUS
status
=
STATUS_SUCCESS
;
TRACE
(
"-> WS_SIO_ROUTING_INTERFACE_QUERY request
\n
"
);
if
(
!
in_buff
||
in_size
<
sizeof
(
struct
WS_sockaddr
)
||
!
out_buff
||
out_size
<
sizeof
(
struct
WS_sockaddr_in
))
if
(
!
in_buff
||
in_size
<
sizeof
(
struct
sockaddr
)
||
!
out_buff
||
out_size
<
sizeof
(
struct
sockaddr_in
))
{
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
if
(
daddr
->
sa_family
!=
WS_
AF_INET
)
if
(
daddr
->
sa_family
!=
AF_INET
)
{
FIXME
(
"unsupported address family %d
\n
"
,
daddr
->
sa_family
);
SetLastError
(
WSAEAFNOSUPPORT
);
...
...
@@ -2194,19 +2178,19 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
SetLastError
(
WSAEFAULT
);
return
-
1
;
}
saddr_in
->
sin_family
=
WS_
AF_INET
;
saddr_in
->
sin_family
=
AF_INET
;
saddr_in
->
sin_addr
.
S_un
.
S_addr
=
ipAddrTable
->
table
[
found_index
].
dwAddr
;
saddr_in
->
sin_port
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
ipAddrTable
);
ret
=
server_ioctl_sock
(
s
,
IOCTL_AFD_WINE_COMPLETE_ASYNC
,
&
status
,
sizeof
(
status
),
NULL
,
0
,
ret_size
,
overlapped
,
completion
);
if
(
!
ret
)
*
ret_size
=
sizeof
(
struct
WS_
sockaddr_in
);
if
(
!
ret
)
*
ret_size
=
sizeof
(
struct
sockaddr_in
);
SetLastError
(
ret
);
return
ret
?
-
1
:
0
;
}
case
WS_
SIO_ADDRESS_LIST_CHANGE
:
case
SIO_ADDRESS_LIST_CHANGE
:
{
int
force_async
=
!!
overlapped
;
DWORD
ret
;
...
...
@@ -2217,19 +2201,19 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
return
ret
?
-
1
:
0
;
}
case
WS_
SIO_UDP_CONNRESET
:
case
SIO_UDP_CONNRESET
:
{
NTSTATUS
status
=
STATUS_SUCCESS
;
DWORD
ret
;
FIXME
(
"
WS_
SIO_UDP_CONNRESET stub
\n
"
);
FIXME
(
"SIO_UDP_CONNRESET stub
\n
"
);
ret
=
server_ioctl_sock
(
s
,
IOCTL_AFD_WINE_COMPLETE_ASYNC
,
&
status
,
sizeof
(
status
),
NULL
,
0
,
ret_size
,
overlapped
,
completion
);
SetLastError
(
ret
);
return
ret
?
-
1
:
0
;
}
case
WS_
SIO_BASE_HANDLE
:
case
SIO_BASE_HANDLE
:
{
NTSTATUS
status
;
DWORD
ret
;
...
...
@@ -2254,8 +2238,8 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
default:
FIXME
(
"unimplemented ioctl %s
\n
"
,
debugstr_wsaioctl
(
code
)
);
/* fall through */
case
LOWORD
(
WS_
FIONBIO
):
/* Netscape tries to use this */
case
WS_
SIO_SET_COMPATIBILITY_MODE
:
case
LOWORD
(
FIONBIO
):
/* Netscape tries to use this */
case
SIO_SET_COMPATIBILITY_MODE
:
{
NTSTATUS
status
=
STATUS_NOT_SUPPORTED
;
...
...
@@ -2279,17 +2263,17 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
/***********************************************************************
* ioctlsocket (WS2_32.10)
*/
int
WINAPI
WS_ioctlsocket
(
SOCKET
s
,
LONG
cmd
,
WS_u_long
*
argp
)
int
WINAPI
ioctlsocket
(
SOCKET
s
,
LONG
cmd
,
u_long
*
argp
)
{
DWORD
ret_size
;
return
WSAIoctl
(
s
,
cmd
,
argp
,
sizeof
(
WS_u_long
),
argp
,
sizeof
(
WS_
u_long
),
&
ret_size
,
NULL
,
NULL
);
return
WSAIoctl
(
s
,
cmd
,
argp
,
sizeof
(
u_long
),
argp
,
sizeof
(
u_long
),
&
ret_size
,
NULL
,
NULL
);
}
/***********************************************************************
* listen (ws2_32.13)
*/
int
WINAPI
WS_
listen
(
SOCKET
s
,
int
backlog
)
int
WINAPI
listen
(
SOCKET
s
,
int
backlog
)
{
struct
afd_listen_params
params
=
{.
backlog
=
backlog
};
IO_STATUS_BLOCK
io
;
...
...
@@ -2307,7 +2291,7 @@ int WINAPI WS_listen( SOCKET s, int backlog )
/***********************************************************************
* recv (WS2_32.16)
*/
int
WINAPI
WS_recv
(
SOCKET
s
,
char
*
buf
,
int
len
,
int
flags
)
int
WINAPI
recv
(
SOCKET
s
,
char
*
buf
,
int
len
,
int
flags
)
{
DWORD
n
,
dwFlags
=
flags
;
WSABUF
wsabuf
;
...
...
@@ -2324,8 +2308,7 @@ int WINAPI WS_recv(SOCKET s, char *buf, int len, int flags)
/***********************************************************************
* recvfrom (WS2_32.17)
*/
int
WINAPI
WS_recvfrom
(
SOCKET
s
,
char
*
buf
,
INT
len
,
int
flags
,
struct
WS_sockaddr
*
from
,
int
*
fromlen
)
int
WINAPI
recvfrom
(
SOCKET
s
,
char
*
buf
,
int
len
,
int
flags
,
struct
sockaddr
*
from
,
int
*
fromlen
)
{
DWORD
n
,
dwFlags
=
flags
;
WSABUF
wsabuf
;
...
...
@@ -2341,7 +2324,7 @@ int WINAPI WS_recvfrom(SOCKET s, char *buf, INT len, int flags,
/* as FD_SET(), but returns 1 if the fd was added, 0 otherwise */
static
int
add_fd_to_set
(
SOCKET
fd
,
struct
WS_
fd_set
*
set
)
static
int
add_fd_to_set
(
SOCKET
fd
,
struct
fd_set
*
set
)
{
unsigned
int
i
;
...
...
@@ -2351,7 +2334,7 @@ static int add_fd_to_set( SOCKET fd, struct WS_fd_set *set )
return
0
;
}
if
(
set
->
fd_count
<
WS_
FD_SETSIZE
)
if
(
set
->
fd_count
<
FD_SETSIZE
)
{
set
->
fd_array
[
set
->
fd_count
++
]
=
fd
;
return
1
;
...
...
@@ -2364,12 +2347,12 @@ static int add_fd_to_set( SOCKET fd, struct WS_fd_set *set )
/***********************************************************************
* select (ws2_32.18)
*/
int
WINAPI
WS_select
(
int
count
,
WS_fd_set
*
read_ptr
,
WS_
fd_set
*
write_ptr
,
WS_fd_set
*
except_ptr
,
const
struct
WS_
timeval
*
timeout
)
int
WINAPI
select
(
int
count
,
fd_set
*
read_ptr
,
fd_set
*
write_ptr
,
fd_set
*
except_ptr
,
const
struct
timeval
*
timeout
)
{
char
buffer
[
offsetof
(
struct
afd_poll_params
,
sockets
[
WS_
FD_SETSIZE
*
3
]
)]
=
{
0
};
char
buffer
[
offsetof
(
struct
afd_poll_params
,
sockets
[
FD_SETSIZE
*
3
]
)]
=
{
0
};
struct
afd_poll_params
*
params
=
(
struct
afd_poll_params
*
)
buffer
;
struct
WS_
fd_set
read
,
write
,
except
;
struct
fd_set
read
,
write
,
except
;
ULONG
params_size
,
i
,
j
;
SOCKET
poll_socket
=
0
;
IO_STATUS_BLOCK
io
;
...
...
@@ -2379,9 +2362,9 @@ int WINAPI WS_select( int count, WS_fd_set *read_ptr, WS_fd_set *write_ptr,
TRACE
(
"read %p, write %p, except %p, timeout %p
\n
"
,
read_ptr
,
write_ptr
,
except_ptr
,
timeout
);
WS_
FD_ZERO
(
&
read
);
WS_
FD_ZERO
(
&
write
);
WS_
FD_ZERO
(
&
except
);
FD_ZERO
(
&
read
);
FD_ZERO
(
&
write
);
FD_ZERO
(
&
except
);
if
(
read_ptr
)
read
=
*
read_ptr
;
if
(
write_ptr
)
write
=
*
write_ptr
;
if
(
except_ptr
)
except
=
*
except_ptr
;
...
...
@@ -2437,9 +2420,9 @@ int WINAPI WS_select( int count, WS_fd_set *read_ptr, WS_fd_set *write_ptr,
if
(
!
status
)
{
/* pointers may alias, so clear them all first */
if
(
read_ptr
)
WS_
FD_ZERO
(
read_ptr
);
if
(
write_ptr
)
WS_
FD_ZERO
(
write_ptr
);
if
(
except_ptr
)
WS_
FD_ZERO
(
except_ptr
);
if
(
read_ptr
)
FD_ZERO
(
read_ptr
);
if
(
write_ptr
)
FD_ZERO
(
write_ptr
);
if
(
except_ptr
)
FD_ZERO
(
except_ptr
);
for
(
i
=
0
;
i
<
params
->
count
;
++
i
)
{
...
...
@@ -2545,18 +2528,18 @@ int WINAPI WSAPoll( WSAPOLLFD *fds, ULONG count, int timeout )
if
((
INT_PTR
)
fds
[
i
].
fd
<
0
||
!
socket_list_find
(
fds
[
i
].
fd
))
{
fds
[
i
].
revents
=
WS_
POLLNVAL
;
fds
[
i
].
revents
=
POLLNVAL
;
continue
;
}
poll_socket
=
fds
[
i
].
fd
;
params
->
sockets
[
params
->
count
].
socket
=
fds
[
i
].
fd
;
if
(
fds
[
i
].
events
&
WS_
POLLRDNORM
)
if
(
fds
[
i
].
events
&
POLLRDNORM
)
flags
|=
AFD_POLL_ACCEPT
|
AFD_POLL_READ
;
if
(
fds
[
i
].
events
&
WS_
POLLRDBAND
)
if
(
fds
[
i
].
events
&
POLLRDBAND
)
flags
|=
AFD_POLL_OOB
;
if
(
fds
[
i
].
events
&
WS_
POLLWRNORM
)
if
(
fds
[
i
].
events
&
POLLWRNORM
)
flags
|=
AFD_POLL_WRITE
;
params
->
sockets
[
params
->
count
].
flags
=
flags
;
++
params
->
count
;
...
...
@@ -2593,19 +2576,19 @@ int WINAPI WSAPoll( WSAPOLLFD *fds, ULONG count, int timeout )
unsigned
int
revents
=
0
;
if
(
params
->
sockets
[
j
].
flags
&
(
AFD_POLL_ACCEPT
|
AFD_POLL_READ
))
revents
|=
WS_
POLLRDNORM
;
revents
|=
POLLRDNORM
;
if
(
params
->
sockets
[
j
].
flags
&
AFD_POLL_OOB
)
revents
|=
WS_
POLLRDBAND
;
revents
|=
POLLRDBAND
;
if
(
params
->
sockets
[
j
].
flags
&
AFD_POLL_WRITE
)
revents
|=
WS_
POLLWRNORM
;
revents
|=
POLLWRNORM
;
if
(
params
->
sockets
[
j
].
flags
&
AFD_POLL_HUP
)
revents
|=
WS_
POLLHUP
;
revents
|=
POLLHUP
;
if
(
params
->
sockets
[
j
].
flags
&
(
AFD_POLL_RESET
|
AFD_POLL_CONNECT_ERR
))
revents
|=
WS_
POLLERR
;
revents
|=
POLLERR
;
if
(
params
->
sockets
[
j
].
flags
&
AFD_POLL_CLOSE
)
revents
|=
WS_
POLLNVAL
;
revents
|=
POLLNVAL
;
fds
[
i
].
revents
=
revents
&
(
fds
[
i
].
events
|
WS_POLLHUP
|
WS_POLLERR
|
WS_
POLLNVAL
);
fds
[
i
].
revents
=
revents
&
(
fds
[
i
].
events
|
POLLHUP
|
POLLERR
|
POLLNVAL
);
if
(
fds
[
i
].
revents
)
++
ret_count
;
...
...
@@ -2625,7 +2608,7 @@ int WINAPI WSAPoll( WSAPOLLFD *fds, ULONG count, int timeout )
/***********************************************************************
* send (WS2_32.19)
*/
int
WINAPI
WS_send
(
SOCKET
s
,
const
char
*
buf
,
int
len
,
int
flags
)
int
WINAPI
send
(
SOCKET
s
,
const
char
*
buf
,
int
len
,
int
flags
)
{
DWORD
n
;
WSABUF
wsabuf
;
...
...
@@ -2656,7 +2639,7 @@ INT WINAPI WSASend( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
*/
INT
WINAPI
WSASendDisconnect
(
SOCKET
s
,
LPWSABUF
lpBuffers
)
{
return
WS_
shutdown
(
s
,
SD_SEND
);
return
shutdown
(
s
,
SD_SEND
);
}
...
...
@@ -2665,7 +2648,7 @@ INT WINAPI WSASendDisconnect( SOCKET s, LPWSABUF lpBuffers )
*/
INT
WINAPI
WSASendTo
(
SOCKET
s
,
LPWSABUF
lpBuffers
,
DWORD
dwBufferCount
,
LPDWORD
lpNumberOfBytesSent
,
DWORD
dwFlags
,
const
struct
WS_
sockaddr
*
to
,
int
tolen
,
const
struct
sockaddr
*
to
,
int
tolen
,
LPWSAOVERLAPPED
lpOverlapped
,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
lpCompletionRoutine
)
{
...
...
@@ -2679,8 +2662,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
/***********************************************************************
* sendto (WS2_32.20)
*/
int
WINAPI
WS_sendto
(
SOCKET
s
,
const
char
*
buf
,
int
len
,
int
flags
,
const
struct
WS_sockaddr
*
to
,
int
tolen
)
int
WINAPI
sendto
(
SOCKET
s
,
const
char
*
buf
,
int
len
,
int
flags
,
const
struct
sockaddr
*
to
,
int
tolen
)
{
DWORD
n
;
WSABUF
wsabuf
;
...
...
@@ -2709,8 +2691,7 @@ static int server_setsockopt( SOCKET s, ULONG code, const char *optval, int optl
/***********************************************************************
* setsockopt (WS2_32.21)
*/
int
WINAPI
WS_setsockopt
(
SOCKET
s
,
int
level
,
int
optname
,
const
char
*
optval
,
int
optlen
)
int
WINAPI
setsockopt
(
SOCKET
s
,
int
level
,
int
optname
,
const
char
*
optval
,
int
optlen
)
{
TRACE
(
"(socket %04lx, %s, optval %s, optlen %d)
\n
"
,
s
,
debugstr_sockopt
(
level
,
optname
),
debugstr_optval
(
optval
,
optlen
),
...
...
@@ -2725,15 +2706,15 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
switch
(
level
)
{
case
WS_
SOL_SOCKET
:
case
SOL_SOCKET
:
switch
(
optname
)
{
case
WS_
SO_BROADCAST
:
case
SO_BROADCAST
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_BROADCAST
,
optval
,
optlen
);
case
WS_
SO_DONTLINGER
:
case
SO_DONTLINGER
:
{
struct
WS_
linger
linger
;
struct
linger
linger
;
if
(
!
optval
)
{
...
...
@@ -2743,69 +2724,69 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
linger
.
l_onoff
=
!*
(
const
BOOL
*
)
optval
;
linger
.
l_linger
=
0
;
return
WS_setsockopt
(
s
,
WS_SOL_SOCKET
,
WS_
SO_LINGER
,
(
char
*
)
&
linger
,
sizeof
(
linger
)
);
return
setsockopt
(
s
,
SOL_SOCKET
,
SO_LINGER
,
(
char
*
)
&
linger
,
sizeof
(
linger
)
);
}
case
WS_
SO_ERROR
:
case
SO_ERROR
:
FIXME
(
"SO_ERROR, stub!
\n
"
);
SetLastError
(
WSAENOPROTOOPT
);
return
-
1
;
case
WS_
SO_KEEPALIVE
:
case
SO_KEEPALIVE
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_KEEPALIVE
,
optval
,
optlen
);
case
WS_
SO_LINGER
:
case
SO_LINGER
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_LINGER
,
optval
,
optlen
);
case
WS_
SO_OOBINLINE
:
case
SO_OOBINLINE
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_OOBINLINE
,
optval
,
optlen
);
case
WS_
SO_RCVBUF
:
case
SO_RCVBUF
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_RCVBUF
,
optval
,
optlen
);
case
WS_
SO_RCVTIMEO
:
case
SO_RCVTIMEO
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_RCVTIMEO
,
optval
,
optlen
);
case
WS_
SO_REUSEADDR
:
case
SO_REUSEADDR
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_REUSEADDR
,
optval
,
optlen
);
case
WS_
SO_SNDBUF
:
case
SO_SNDBUF
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_SNDBUF
,
optval
,
optlen
);
case
WS_
SO_SNDTIMEO
:
case
SO_SNDTIMEO
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_SO_SNDTIMEO
,
optval
,
optlen
);
/* SO_DEBUG is a privileged operation, ignore it. */
case
WS_
SO_DEBUG
:
case
SO_DEBUG
:
TRACE
(
"Ignoring SO_DEBUG
\n
"
);
return
0
;
/* For some reason the game GrandPrixLegends does set SO_DONTROUTE on its
* socket. According to MSDN, this option is silently ignored.*/
case
WS_
SO_DONTROUTE
:
case
SO_DONTROUTE
:
TRACE
(
"Ignoring SO_DONTROUTE
\n
"
);
return
0
;
/* Stops two sockets from being bound to the same port. Always happens
* on unix systems, so just drop it. */
case
WS_
SO_EXCLUSIVEADDRUSE
:
case
SO_EXCLUSIVEADDRUSE
:
TRACE
(
"Ignoring SO_EXCLUSIVEADDRUSE, is always set.
\n
"
);
return
0
;
/* After a ConnectEx call succeeds, the socket can't be used with half of the
* normal winsock functions on windows. We don't have that problem. */
case
WS_
SO_UPDATE_CONNECT_CONTEXT
:
case
SO_UPDATE_CONNECT_CONTEXT
:
TRACE
(
"Ignoring SO_UPDATE_CONNECT_CONTEXT, since our sockets are normal
\n
"
);
return
0
;
/* After a AcceptEx call succeeds, the socket can't be used with half of the
* normal winsock functions on windows. We don't have that problem. */
case
WS_
SO_UPDATE_ACCEPT_CONTEXT
:
case
SO_UPDATE_ACCEPT_CONTEXT
:
TRACE
(
"Ignoring SO_UPDATE_ACCEPT_CONTEXT, since our sockets are normal
\n
"
);
return
0
;
/* SO_OPENTYPE does not require a valid socket handle. */
case
WS_
SO_OPENTYPE
:
case
SO_OPENTYPE
:
if
(
!
optlen
||
optlen
<
sizeof
(
int
)
||
!
optval
)
{
SetLastError
(
WSAEFAULT
);
...
...
@@ -2815,40 +2796,40 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
TRACE
(
"setting global SO_OPENTYPE = 0x%x
\n
"
,
*
((
const
int
*
)
optval
)
);
return
0
;
case
WS_
SO_RANDOMIZE_PORT
:
FIXME
(
"Ignoring
WS_
SO_RANDOMIZE_PORT
\n
"
);
case
SO_RANDOMIZE_PORT
:
FIXME
(
"Ignoring SO_RANDOMIZE_PORT
\n
"
);
return
0
;
case
WS_
SO_PORT_SCALABILITY
:
FIXME
(
"Ignoring
WS_
SO_PORT_SCALABILITY
\n
"
);
case
SO_PORT_SCALABILITY
:
FIXME
(
"Ignoring SO_PORT_SCALABILITY
\n
"
);
return
0
;
case
WS_
SO_REUSE_UNICASTPORT
:
FIXME
(
"Ignoring
WS_
SO_REUSE_UNICASTPORT
\n
"
);
case
SO_REUSE_UNICASTPORT
:
FIXME
(
"Ignoring SO_REUSE_UNICASTPORT
\n
"
);
return
0
;
case
WS_
SO_REUSE_MULTICASTPORT
:
FIXME
(
"Ignoring
WS_
SO_REUSE_MULTICASTPORT
\n
"
);
case
SO_REUSE_MULTICASTPORT
:
FIXME
(
"Ignoring SO_REUSE_MULTICASTPORT
\n
"
);
return
0
;
default:
TRACE
(
"Unknown SOL_SOCKET optname: 0x%08x
\n
"
,
optname
);
/* fall through */
case
WS_
SO_ACCEPTCONN
:
case
WS_
SO_TYPE
:
case
SO_ACCEPTCONN
:
case
SO_TYPE
:
SetLastError
(
WSAENOPROTOOPT
);
return
SOCKET_ERROR
;
}
break
;
/* case
WS_
SOL_SOCKET */
break
;
/* case SOL_SOCKET */
case
WS_
NSPROTO_IPX
:
case
NSPROTO_IPX
:
switch
(
optname
)
{
case
WS_
IPX_PTYPE
:
case
IPX_PTYPE
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPX_PTYPE
,
optval
,
optlen
);
case
WS_
IPX_FILTERPTYPE
:
case
IPX_FILTERPTYPE
:
/* Sets the receive filter packet type, at the moment we don't support it */
FIXME
(
"IPX_FILTERPTYPE: %x
\n
"
,
*
optval
);
/* Returning 0 is better for now than returning a SOCKET_ERROR */
...
...
@@ -2858,12 +2839,12 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
FIXME
(
"opt_name:%x
\n
"
,
optname
);
return
SOCKET_ERROR
;
}
break
;
/* case
WS_
NSPROTO_IPX */
break
;
/* case NSPROTO_IPX */
case
WS_
IPPROTO_TCP
:
case
IPPROTO_TCP
:
switch
(
optname
)
{
case
WS_
TCP_NODELAY
:
case
TCP_NODELAY
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_TCP_NODELAY
,
optval
,
optlen
);
default:
...
...
@@ -2872,55 +2853,55 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
}
break
;
case
WS_
IPPROTO_IP
:
case
IPPROTO_IP
:
switch
(
optname
)
{
case
WS_
IP_ADD_MEMBERSHIP
:
case
IP_ADD_MEMBERSHIP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_ADD_MEMBERSHIP
,
optval
,
optlen
);
case
WS_
IP_ADD_SOURCE_MEMBERSHIP
:
case
IP_ADD_SOURCE_MEMBERSHIP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_ADD_SOURCE_MEMBERSHIP
,
optval
,
optlen
);
case
WS_
IP_BLOCK_SOURCE
:
case
IP_BLOCK_SOURCE
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_BLOCK_SOURCE
,
optval
,
optlen
);
case
WS_
IP_DONTFRAGMENT
:
case
IP_DONTFRAGMENT
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_DONTFRAGMENT
,
optval
,
optlen
);
case
WS_
IP_DROP_MEMBERSHIP
:
case
IP_DROP_MEMBERSHIP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_DROP_MEMBERSHIP
,
optval
,
optlen
);
case
WS_
IP_DROP_SOURCE_MEMBERSHIP
:
case
IP_DROP_SOURCE_MEMBERSHIP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_DROP_SOURCE_MEMBERSHIP
,
optval
,
optlen
);
case
WS_
IP_HDRINCL
:
case
IP_HDRINCL
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_HDRINCL
,
optval
,
optlen
);
case
WS_
IP_MULTICAST_IF
:
case
IP_MULTICAST_IF
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_MULTICAST_IF
,
optval
,
optlen
);
case
WS_
IP_MULTICAST_LOOP
:
case
IP_MULTICAST_LOOP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_MULTICAST_LOOP
,
optval
,
optlen
);
case
WS_
IP_MULTICAST_TTL
:
case
IP_MULTICAST_TTL
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_MULTICAST_TTL
,
optval
,
optlen
);
case
WS_
IP_OPTIONS
:
case
IP_OPTIONS
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_OPTIONS
,
optval
,
optlen
);
case
WS_
IP_PKTINFO
:
case
IP_PKTINFO
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_PKTINFO
,
optval
,
optlen
);
case
WS_
IP_TOS
:
case
IP_TOS
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_TOS
,
optval
,
optlen
);
case
WS_
IP_TTL
:
case
IP_TTL
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_TTL
,
optval
,
optlen
);
case
WS_
IP_UNBLOCK_SOURCE
:
case
IP_UNBLOCK_SOURCE
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_UNBLOCK_SOURCE
,
optval
,
optlen
);
case
WS_
IP_UNICAST_IF
:
case
IP_UNICAST_IF
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IP_UNICAST_IF
,
optval
,
optlen
);
default:
...
...
@@ -2929,44 +2910,44 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
}
break
;
case
WS_
IPPROTO_IPV6
:
case
IPPROTO_IPV6
:
switch
(
optname
)
{
case
WS_
IPV6_ADD_MEMBERSHIP
:
case
IPV6_ADD_MEMBERSHIP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_ADD_MEMBERSHIP
,
optval
,
optlen
);
case
WS_
IPV6_DONTFRAG
:
case
IPV6_DONTFRAG
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_DONTFRAG
,
optval
,
optlen
);
case
WS_
IPV6_DROP_MEMBERSHIP
:
case
IPV6_DROP_MEMBERSHIP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_DROP_MEMBERSHIP
,
optval
,
optlen
);
case
WS_
IPV6_HOPLIMIT
:
case
IPV6_HOPLIMIT
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_RECVHOPLIMIT
,
optval
,
optlen
);
case
WS_
IPV6_MULTICAST_HOPS
:
case
IPV6_MULTICAST_HOPS
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_MULTICAST_HOPS
,
optval
,
optlen
);
case
WS_
IPV6_MULTICAST_IF
:
case
IPV6_MULTICAST_IF
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_MULTICAST_IF
,
optval
,
optlen
);
case
WS_
IPV6_MULTICAST_LOOP
:
case
IPV6_MULTICAST_LOOP
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_MULTICAST_LOOP
,
optval
,
optlen
);
case
WS_
IPV6_PKTINFO
:
case
IPV6_PKTINFO
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_RECVPKTINFO
,
optval
,
optlen
);
case
WS_
IPV6_PROTECTION_LEVEL
:
case
IPV6_PROTECTION_LEVEL
:
FIXME
(
"IPV6_PROTECTION_LEVEL is ignored!
\n
"
);
return
0
;
case
WS_
IPV6_UNICAST_HOPS
:
case
IPV6_UNICAST_HOPS
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_UNICAST_HOPS
,
optval
,
optlen
);
case
WS_
IPV6_UNICAST_IF
:
case
IPV6_UNICAST_IF
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_UNICAST_IF
,
optval
,
optlen
);
case
WS_
IPV6_V6ONLY
:
case
IPV6_V6ONLY
:
return
server_setsockopt
(
s
,
IOCTL_AFD_WINE_SET_IPV6_V6ONLY
,
optval
,
optlen
);
default:
...
...
@@ -2986,7 +2967,7 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
/***********************************************************************
* shutdown (ws2_32.22)
*/
int
WINAPI
WS_
shutdown
(
SOCKET
s
,
int
how
)
int
WINAPI
shutdown
(
SOCKET
s
,
int
how
)
{
IO_STATUS_BLOCK
io
;
NTSTATUS
status
;
...
...
@@ -3003,7 +2984,7 @@ int WINAPI WS_shutdown( SOCKET s, int how )
/***********************************************************************
* socket (WS2_32.23)
*/
SOCKET
WINAPI
WS_socket
(
int
af
,
int
type
,
int
protocol
)
SOCKET
WINAPI
socket
(
int
af
,
int
type
,
int
protocol
)
{
TRACE
(
"af=%d type=%d protocol=%d
\n
"
,
af
,
type
,
protocol
);
...
...
@@ -3329,7 +3310,7 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
err
=
RtlNtStatusToDosError
(
status
);
if
(
err
==
WSAEACCES
)
/* raw socket denied */
{
if
(
type
==
WS_
SOCK_RAW
)
if
(
type
==
SOCK_RAW
)
ERR_
(
winediag
)(
"Failed to create a socket of type SOCK_RAW, this requires special permissions.
\n
"
);
else
ERR_
(
winediag
)(
"Failed to create socket, this requires special permissions.
\n
"
);
...
...
@@ -3359,15 +3340,8 @@ done:
* WSAJoinLeaf (WS2_32.58)
*
*/
SOCKET
WINAPI
WSAJoinLeaf
(
SOCKET
s
,
const
struct
WS_sockaddr
*
addr
,
int
addrlen
,
LPWSABUF
lpCallerData
,
LPWSABUF
lpCalleeData
,
LPQOS
lpSQOS
,
LPQOS
lpGQOS
,
DWORD
dwFlags
)
SOCKET
WINAPI
WSAJoinLeaf
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
int
addrlen
,
WSABUF
*
caller_data
,
WSABUF
*
callee_data
,
QOS
*
socket_qos
,
QOS
*
group_qos
,
DWORD
flags
)
{
FIXME
(
"stub.
\n
"
);
return
INVALID_SOCKET
;
...
...
@@ -3376,7 +3350,7 @@ SOCKET WINAPI WSAJoinLeaf(
/***********************************************************************
* __WSAFDIsSet (WS2_32.151)
*/
int
WINAPI
__WSAFDIsSet
(
SOCKET
s
,
WS_fd_set
*
set
)
int
WINAPI
__WSAFDIsSet
(
SOCKET
s
,
fd_set
*
set
)
{
int
i
=
set
->
fd_count
,
ret
=
0
;
...
...
@@ -3463,7 +3437,7 @@ int WINAPI WSARecv(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
* WSARecvFrom (WS2_32.69)
*/
INT
WINAPI
WSARecvFrom
(
SOCKET
s
,
LPWSABUF
lpBuffers
,
DWORD
dwBufferCount
,
LPDWORD
lpNumberOfBytesRecvd
,
LPDWORD
lpFlags
,
struct
WS_
sockaddr
*
lpFrom
,
DWORD
*
lpNumberOfBytesRecvd
,
DWORD
*
lpFlags
,
struct
sockaddr
*
lpFrom
,
LPINT
lpFromlen
,
LPWSAOVERLAPPED
lpOverlapped
,
LPWSAOVERLAPPED_COMPLETION_ROUTINE
lpCompletionRoutine
)
...
...
@@ -3479,19 +3453,19 @@ INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
/***********************************************************************
* WSAAccept (ws2_32.@)
*/
SOCKET
WINAPI
WSAAccept
(
SOCKET
s
,
struct
WS_
sockaddr
*
addr
,
int
*
addrlen
,
SOCKET
WINAPI
WSAAccept
(
SOCKET
s
,
struct
sockaddr
*
addr
,
int
*
addrlen
,
LPCONDITIONPROC
callback
,
DWORD_PTR
context
)
{
int
ret
=
0
,
size
;
WSABUF
caller_id
,
caller_data
,
callee_id
,
callee_data
;
struct
WS_
sockaddr
src_addr
,
dst_addr
;
struct
sockaddr
src_addr
,
dst_addr
;
GROUP
group
;
SOCKET
cs
;
TRACE
(
"socket %#lx, addr %p, addrlen %p, callback %p, context %#lx
\n
"
,
s
,
addr
,
addrlen
,
callback
,
context
);
cs
=
WS_accept
(
s
,
addr
,
addrlen
);
cs
=
accept
(
s
,
addr
,
addrlen
);
if
(
cs
==
SOCKET_ERROR
)
return
SOCKET_ERROR
;
if
(
!
callback
)
return
cs
;
...
...
@@ -3503,7 +3477,7 @@ SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, int *addrlen,
else
{
size
=
sizeof
(
src_addr
);
WS_
getpeername
(
cs
,
&
src_addr
,
&
size
);
getpeername
(
cs
,
&
src_addr
,
&
size
);
caller_id
.
buf
=
(
char
*
)
&
src_addr
;
caller_id
.
len
=
size
;
}
...
...
@@ -3511,7 +3485,7 @@ SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, int *addrlen,
caller_data
.
len
=
0
;
size
=
sizeof
(
dst_addr
);
WS_
getsockname
(
cs
,
&
dst_addr
,
&
size
);
getsockname
(
cs
,
&
dst_addr
,
&
size
);
callee_id
.
buf
=
(
char
*
)
&
dst_addr
;
callee_id
.
len
=
sizeof
(
dst_addr
);
...
...
@@ -3537,7 +3511,7 @@ SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, int *addrlen,
}
case
CF_REJECT
:
WS_
closesocket
(
cs
);
closesocket
(
cs
);
SetLastError
(
WSAECONNREFUSED
);
return
SOCKET_ERROR
;
...
...
@@ -3583,7 +3557,7 @@ INT WINAPI WSARecvDisconnect( SOCKET s, LPWSABUF disconnectdata )
{
TRACE
(
"(%04lx %p)
\n
"
,
s
,
disconnectdata
);
return
WS_
shutdown
(
s
,
SD_RECEIVE
);
return
shutdown
(
s
,
SD_RECEIVE
);
}
...
...
dlls/ws2_32/unixlib.c
View file @
815ac665
...
...
@@ -101,6 +101,7 @@
#include "windef.h"
#include "winerror.h"
#include "winternl.h"
#define USE_WS_PREFIX
#include "winsock2.h"
#include "ws2tcpip.h"
#include "wsipx.h"
...
...
dlls/ws2_32/ws2_32.spec
View file @
815ac665
1 stdcall accept(long ptr ptr)
WS_accept
2 stdcall bind(long ptr long)
WS_bind
3 stdcall closesocket(long)
WS_closesocket
4 stdcall connect(long ptr long)
WS_connect
5 stdcall getpeername(long ptr ptr)
WS_getpeername
6 stdcall getsockname(long ptr ptr)
WS_getsockname
7 stdcall getsockopt(long long long ptr ptr)
WS_getsockopt
1 stdcall accept(long ptr ptr)
2 stdcall bind(long ptr long)
3 stdcall closesocket(long)
4 stdcall connect(long ptr long)
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
10 stdcall ioctlsocket(long long ptr)
WS_ioctlsocket
11 stdcall inet_addr(str)
WS_inet_addr
12 stdcall inet_ntoa(ptr)
WS_inet_ntoa
13 stdcall listen(long long)
WS_listen
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
16 stdcall recv(long ptr long long)
WS_recv
17 stdcall recvfrom(long ptr long long ptr ptr)
WS_recvfrom
18 stdcall select(long ptr ptr ptr ptr)
WS_select
19 stdcall send(long ptr long long)
WS_send
20 stdcall sendto(long ptr long long ptr long)
WS_sendto
21 stdcall setsockopt(long long long ptr long)
WS_setsockopt
22 stdcall shutdown(long long)
WS_shutdown
23 stdcall socket(long long long)
WS_socket
51 stdcall gethostbyaddr(ptr long long)
WS_gethostbyaddr
52 stdcall gethostbyname(str)
WS_gethostbyname
53 stdcall getprotobyname(str)
WS_getprotobyname
54 stdcall getprotobynumber(long)
WS_getprotobynumber
55 stdcall getservbyname(str str)
WS_getservbyname
56 stdcall getservbyport(long str)
WS_getservbyport
57 stdcall gethostname(ptr long)
WS_gethostname
16 stdcall recv(long ptr long long)
17 stdcall recvfrom(long ptr long long ptr ptr)
18 stdcall select(long ptr ptr ptr ptr)
19 stdcall send(long ptr long long)
20 stdcall sendto(long ptr long long ptr long)
21 stdcall setsockopt(long long long ptr long)
22 stdcall shutdown(long long)
23 stdcall socket(long long long)
51 stdcall gethostbyaddr(ptr long long)
52 stdcall gethostbyname(str)
53 stdcall getprotobyname(str)
54 stdcall getprotobynumber(long)
55 stdcall getservbyname(str str)
56 stdcall getservbyport(long str)
57 stdcall gethostname(ptr long)
101 stdcall WSAAsyncSelect(long long long long)
102 stdcall WSAAsyncGetHostByAddr(long long ptr long long ptr long)
...
...
@@ -128,8 +128,8 @@
@ stub WSCUpdateProvider
@ stub WSCWriteNameSpaceOrder
@ stdcall WSCWriteProviderOrder(ptr long)
@ stdcall freeaddrinfo(ptr)
WS_freeaddrinfo
@ stdcall getaddrinfo(str str ptr ptr)
WS_getaddrinfo
@ stdcall getnameinfo(ptr long ptr long ptr long long)
WS_getnameinfo
@ stdcall inet_ntop(long ptr ptr long)
WS_inet_ntop
@ stdcall inet_pton(long str ptr)
WS_inet_pton
@ stdcall freeaddrinfo(ptr)
@ stdcall getaddrinfo(str str ptr ptr)
@ stdcall getnameinfo(ptr long ptr long ptr long long)
@ stdcall inet_ntop(long ptr ptr long)
@ stdcall inet_pton(long str ptr)
dlls/ws2_32/ws2_32_private.h
View file @
815ac665
...
...
@@ -62,15 +62,15 @@
static
const
char
magic_loopback_addr
[]
=
{
127
,
12
,
34
,
56
};
const
char
*
debugstr_sockaddr
(
const
struct
WS_
sockaddr
*
addr
)
DECLSPEC_HIDDEN
;
const
char
*
debugstr_sockaddr
(
const
struct
sockaddr
*
addr
)
DECLSPEC_HIDDEN
;
struct
per_thread_data
{
HANDLE
sync_event
;
/* event to wait on for synchronous ioctls */
int
opentype
;
struct
WS_
hostent
*
he_buffer
;
struct
WS_
servent
*
se_buffer
;
struct
WS_
protoent
*
pe_buffer
;
struct
hostent
*
he_buffer
;
struct
servent
*
se_buffer
;
struct
protoent
*
pe_buffer
;
int
he_len
;
int
se_len
;
int
pe_len
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment