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
35e54fa5
Commit
35e54fa5
authored
Sep 17, 2013
by
Bruno Jesus
Committed by
Alexandre Julliard
Sep 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Auto detect the socket type and family based on the protocol.
parent
8e29fcdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
26 deletions
+18
-26
socket.c
dlls/ws2_32/socket.c
+18
-13
sock.c
dlls/ws2_32/tests/sock.c
+0
-13
No files found.
dlls/ws2_32/socket.c
View file @
35e54fa5
...
...
@@ -5894,24 +5894,29 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
protocol
=
lpProtocolInfo
->
iProtocol
;
}
/* convert the socket family and type */
af
=
convert_af_w2u
(
af
);
type
=
convert_socktype_w2u
(
type
);
if
(
af
==
AF_UNSPEC
)
/* did they not specify the address family? */
if
(
!
type
&&
(
af
||
protocol
))
{
if
((
protocol
==
IPPROTO_TCP
&&
type
==
SOCK_STREAM
)
||
(
protocol
==
IPPROTO_UDP
&&
type
==
SOCK_DGRAM
))
{
af
=
AF_INET
;
}
else
WSAPROTOCOL_INFOW
infow
;
/* default to the first valid protocol */
if
(
!
protocol
)
protocol
=
valid_protocols
[
0
];
if
(
WS_EnterSingleProtocolW
(
protocol
,
&
infow
))
{
SetLastError
(
WSAEPROTOTYPE
);
return
INVALID_SOCKET
;
type
=
infow
.
iSocketType
;
/* after win2003 it's no longer possible to pass AF_UNSPEC
using the protocol info struct */
if
(
!
lpProtocolInfo
&&
af
==
WS_AF_UNSPEC
)
af
=
infow
.
iAddressFamily
;
}
}
/* convert the socket family and type */
af
=
convert_af_w2u
(
af
);
type
=
convert_socktype_w2u
(
type
);
SERVER_START_REQ
(
create_socket
)
{
req
->
family
=
af
;
...
...
dlls/ws2_32/tests/sock.c
View file @
35e54fa5
...
...
@@ -1788,7 +1788,6 @@ todo_wine
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
AF_INET
,
0
,
0
,
NULL
,
0
,
0
);
todo_wine
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
closesocket
(
sock
);
...
...
@@ -1800,14 +1799,12 @@ todo_wine
ok
(
WSASocketA
(
0
,
SOCK_STREAM
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
0
,
-
1
,
IPPROTO_UDP
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -1821,7 +1818,6 @@ todo_wine
ok
(
WSASocketA
(
0
,
-
1
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -1832,7 +1828,6 @@ todo_wine
ok
(
err
==
WSAEAFNOSUPPORT
,
"Expected 10047, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
AF_INET
,
0
,
IPPROTO_TCP
,
NULL
,
0
,
0
);
todo_wine
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
closesocket
(
sock
);
...
...
@@ -1864,7 +1859,6 @@ todo_wine
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
0
,
0
,
IPPROTO_TCP
,
NULL
,
0
,
0
);
todo_wine
ok
(
sock
!=
INVALID_SOCKET
,
"WSASocketA should have succeeded
\n
"
);
closesocket
(
sock
);
...
...
@@ -1992,20 +1986,17 @@ todo_wine
* from WSAEnumProtocols that has the flag PFL_MATCHES_PROTOCOL_ZERO
* is returned */
sock
=
WSASocketA
(
AF_INET
,
0
,
0
,
NULL
,
0
,
0
);
todo_wine
ok
(
sock
!=
INVALID_SOCKET
,
"Failed to create socket: %d
\n
"
,
WSAGetLastError
());
size
=
sizeof
(
socktype
);
socktype
=
0xdead
;
err
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_TYPE
,
(
char
*
)
&
socktype
,
&
size
);
todo_wine
ok
(
!
err
,
"getsockopt failed with %d
\n
"
,
WSAGetLastError
());
for
(
i
=
0
;
i
<
items
;
i
++
)
{
if
(
pi
[
i
].
dwProviderFlags
&
PFL_MATCHES_PROTOCOL_ZERO
)
{
todo_wine
ok
(
socktype
==
pi
[
i
].
iSocketType
,
"Wrong socket type, expected %d received %d
\n
"
,
pi
[
i
].
iSocketType
,
socktype
);
break
;
...
...
@@ -2019,14 +2010,12 @@ todo_wine
for
(
i
=
0
;
i
<
sizeof
(
autoprotocols
)
/
sizeof
(
autoprotocols
[
0
]);
i
++
)
{
sock
=
WSASocketA
(
0
,
0
,
autoprotocols
[
i
],
NULL
,
0
,
0
);
todo_wine
ok
(
sock
!=
INVALID_SOCKET
,
"Failed to create socket for protocol %d, received %d
\n
"
,
autoprotocols
[
i
],
WSAGetLastError
());
size
=
sizeof
(
socktype
);
socktype
=
0xdead
;
err
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_TYPE
,
(
char
*
)
&
socktype
,
&
size
);
todo_wine
ok
(
!
err
,
"getsockopt failed with %d
\n
"
,
WSAGetLastError
());
for
(
err
=
1
,
j
=
0
;
j
<
items
;
j
++
)
...
...
@@ -2036,13 +2025,11 @@ todo_wine
if
(
socktype
==
pi
[
j
].
iSocketType
)
err
=
0
;
else
todo_wine
ok
(
0
,
"Wrong socket type, expected %d received %d
\n
"
,
pi
[
j
].
iSocketType
,
socktype
);
break
;
}
}
todo_wine
ok
(
!
err
,
"Protocol %d not found in WSAEnumProtocols
\n
"
,
autoprotocols
[
i
]);
closesocket
(
sock
);
...
...
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