Cygwin: sockets: move type and proto checks into fhandler_socket classes

Encapsulation required

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2018-02-26 17:56:47 +01:00
parent 1e5e44a9a5
commit d35bd22992
4 changed files with 47 additions and 25 deletions

View File

@ -229,6 +229,16 @@ fhandler_socket_unix::dup (fhandler_base *child, int flags)
int
fhandler_socket_unix::socket (int af, int type, int protocol, int flags)
{
if (type != SOCK_STREAM && type != SOCK_DGRAM)
{
set_errno (EINVAL);
return -1;
}
if (protocol != 0)
{
set_errno (EPROTONOSUPPORT);
return -1;
}
set_errno (EAFNOSUPPORT);
return -1;
}
@ -237,6 +247,16 @@ int
fhandler_socket_unix::socketpair (int af, int type, int protocol, int flags,
fhandler_socket *fh_out)
{
if (type != SOCK_STREAM && type != SOCK_DGRAM)
{
set_errno (EINVAL);
return -1;
}
if (protocol != 0)
{
set_errno (EPROTONOSUPPORT);
return -1;
}
set_errno (EAFNOSUPPORT);
return -1;
}