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
abcc75cb
Commit
abcc75cb
authored
Sep 30, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Oct 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Pass Win32 socket types to the server.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2d4e21d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
42 deletions
+102
-42
socket.c
dlls/ws2_32/socket.c
+2
-37
sock.c
server/sock.c
+100
-5
No files found.
dlls/ws2_32/socket.c
View file @
abcc75cb
...
...
@@ -7601,41 +7601,6 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
/* convert the socket family, type and protocol */
unixaf
=
convert_af_w2u
(
af
);
unixtype
=
convert_socktype_w2u
(
type
);
protocol
=
convert_proto_w2u
(
protocol
);
/* filter invalid parameters */
if
(
protocol
<
0
)
{
/* the type could not be converted */
if
(
type
&&
unixtype
<
0
)
{
err
=
WSAESOCKTNOSUPPORT
;
goto
done
;
}
err
=
WSAEPROTONOSUPPORT
;
goto
done
;
}
if
(
unixaf
<
0
)
{
/* both family and protocol can't be invalid */
if
(
protocol
<=
0
)
{
err
=
WSAEINVAL
;
goto
done
;
}
/* family could not be converted and neither socket type */
if
(
unixtype
<
0
&&
af
>=
0
)
{
err
=
WSAESOCKTNOSUPPORT
;
goto
done
;
}
err
=
WSAEAFNOSUPPORT
;
goto
done
;
}
RtlInitUnicodeString
(
&
string
,
afdW
);
InitializeObjectAttributes
(
&
attr
,
&
string
,
(
flags
&
WSA_FLAG_NO_HANDLE_INHERIT
)
?
0
:
OBJ_INHERIT
,
NULL
,
NULL
);
...
...
@@ -7647,8 +7612,8 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
return
INVALID_SOCKET
;
}
create_params
.
family
=
unix
af
;
create_params
.
type
=
unix
type
;
create_params
.
family
=
af
;
create_params
.
type
=
type
;
create_params
.
protocol
=
protocol
;
create_params
.
flags
=
flags
&
~
(
WSA_FLAG_NO_HANDLE_INHERIT
|
WSA_FLAG_OVERLAPPED
);
if
((
status
=
NtDeviceIoControlFile
(
handle
,
NULL
,
NULL
,
NULL
,
&
io
,
...
...
server/sock.c
View file @
abcc75cb
...
...
@@ -30,6 +30,9 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_POLL_H
# include <poll.h>
#endif
...
...
@@ -51,6 +54,29 @@
# include <linux/rtnetlink.h>
#endif
#ifdef HAVE_NETIPX_IPX_H
# include <netipx/ipx.h>
#elif defined(HAVE_LINUX_IPX_H)
# ifdef HAVE_ASM_TYPES_H
# include <asm/types.h>
# endif
# ifdef HAVE_LINUX_TYPES_H
# include <linux/types.h>
# endif
# include <linux/ipx.h>
#endif
#if defined(SOL_IPX) || defined(SO_DEFAULT_HEADERS)
# define HAS_IPX
#endif
#ifdef HAVE_LINUX_IRDA_H
# ifdef HAVE_LINUX_TYPES_H
# include <linux/types.h>
# endif
# include <linux/irda.h>
# define HAS_IRDA
#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
...
...
@@ -58,6 +84,7 @@
#include "winerror.h"
#define USE_WS_PREFIX
#include "winsock2.h"
#include "wsipx.h"
#include "wine/afd.h"
#include "process.h"
...
...
@@ -638,12 +665,80 @@ static struct sock *create_socket(void)
return
sock
;
}
static
int
get_unix_family
(
int
family
)
{
switch
(
family
)
{
case
WS_AF_INET
:
return
AF_INET
;
case
WS_AF_INET6
:
return
AF_INET6
;
#ifdef HAS_IPX
case
WS_AF_IPX
:
return
AF_IPX
;
#endif
#ifdef AF_IRDA
case
WS_AF_IRDA
:
return
AF_IRDA
;
#endif
case
WS_AF_UNSPEC
:
return
AF_UNSPEC
;
default:
return
-
1
;
}
}
static
int
get_unix_type
(
int
type
)
{
switch
(
type
)
{
case
WS_SOCK_DGRAM
:
return
SOCK_DGRAM
;
case
WS_SOCK_RAW
:
return
SOCK_RAW
;
case
WS_SOCK_STREAM
:
return
SOCK_STREAM
;
default:
return
-
1
;
}
}
static
int
get_unix_protocol
(
int
protocol
)
{
if
(
protocol
>=
WS_NSPROTO_IPX
&&
protocol
<=
WS_NSPROTO_IPX
+
255
)
return
protocol
;
switch
(
protocol
)
{
case
WS_IPPROTO_ICMP
:
return
IPPROTO_ICMP
;
case
WS_IPPROTO_IGMP
:
return
IPPROTO_IGMP
;
case
WS_IPPROTO_IP
:
return
IPPROTO_IP
;
case
WS_IPPROTO_IPIP
:
return
IPPROTO_IPIP
;
case
WS_IPPROTO_IPV6
:
return
IPPROTO_IPV6
;
case
WS_IPPROTO_RAW
:
return
IPPROTO_RAW
;
case
WS_IPPROTO_TCP
:
return
IPPROTO_TCP
;
case
WS_IPPROTO_UDP
:
return
IPPROTO_UDP
;
default:
return
-
1
;
}
}
static
int
init_socket
(
struct
sock
*
sock
,
int
family
,
int
type
,
int
protocol
,
unsigned
int
flags
)
{
unsigned
int
options
=
0
;
int
sockfd
;
int
sockfd
,
unix_type
,
unix_family
,
unix_protocol
;
unix_family
=
get_unix_family
(
family
);
unix_type
=
get_unix_type
(
type
);
unix_protocol
=
get_unix_protocol
(
protocol
);
if
(
unix_protocol
<
0
)
{
if
(
type
&&
unix_type
<
0
)
set_win32_error
(
WSAESOCKTNOSUPPORT
);
else
set_win32_error
(
WSAEPROTONOSUPPORT
);
return
-
1
;
}
if
(
unix_family
<
0
)
{
if
(
family
>=
0
&&
unix_type
<
0
)
set_win32_error
(
WSAESOCKTNOSUPPORT
);
else
set_win32_error
(
WSAEAFNOSUPPORT
);
return
-
1
;
}
sockfd
=
socket
(
family
,
type
,
protocol
);
sockfd
=
socket
(
unix_family
,
unix_type
,
unix_
protocol
);
if
(
sockfd
==
-
1
)
{
if
(
errno
==
EINVAL
)
set_win32_error
(
WSAESOCKTNOSUPPORT
);
...
...
@@ -653,9 +748,9 @@ static int init_socket( struct sock *sock, int family, int type, int protocol, u
fcntl
(
sockfd
,
F_SETFL
,
O_NONBLOCK
);
/* make socket nonblocking */
sock
->
state
=
(
type
!=
SOCK_STREAM
)
?
(
FD_READ
|
FD_WRITE
)
:
0
;
sock
->
flags
=
flags
;
sock
->
proto
=
protocol
;
sock
->
type
=
type
;
sock
->
family
=
family
;
sock
->
proto
=
unix_
protocol
;
sock
->
type
=
unix_
type
;
sock
->
family
=
unix_
family
;
if
(
sock
->
fd
)
{
...
...
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