* net.cc (cygwin_accept): Set socket type for accepted socket.

(socketpair): Set socket type for both sockets.

	From Egor Duda <deo@logos-m.ru>:

	* fhandler.h (class fhandler_socket): New member to store socket type.
	(fhandler_socket::get_socket_type): Access it.
	(fhandler_socket::set_socket_type): Ditto.
	* net.cc (cygwin_socket): Store socket type.
	(cygwin_connect): Disable security checks for connectionless sockets.
	(cygwin_accept): Ditto.
This commit is contained in:
Corinna Vinschen 2002-04-12 14:52:36 +00:00
parent fcd631cf70
commit 4deace13e4
3 changed files with 40 additions and 8 deletions

View File

@ -1,3 +1,17 @@
2002-04-12 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_accept): Set socket type for accepted socket.
(socketpair): Set socket type for both sockets.
2002-04-12 Egor Duda <deo@logos-m.ru>
* fhandler.h (class fhandler_socket): New member to store socket type.
(fhandler_socket::get_socket_type): Access it.
(fhandler_socket::set_socket_type): Ditto.
* net.cc (cygwin_socket): Store socket type.
(cygwin_connect): Disable security checks for connectionless sockets.
(cygwin_accept): Ditto.
2002-04-09 Mark Bradshaw <bradshaw@staff.crosswalk.com> 2002-04-09 Mark Bradshaw <bradshaw@staff.crosswalk.com>
* cygwin.din: Add strptime. * cygwin.din: Add strptime.

View File

@ -357,6 +357,7 @@ class fhandler_socket: public fhandler_base
{ {
private: private:
int addr_family; int addr_family;
int type;
int connect_secret [4]; int connect_secret [4];
HANDLE secret_event; HANDLE secret_event;
struct _WSAPROTOCOL_INFOA *prot_info_ptr; struct _WSAPROTOCOL_INFOA *prot_info_ptr;
@ -397,6 +398,8 @@ class fhandler_socket: public fhandler_base
select_record *select_except (select_record *s); select_record *select_except (select_record *s);
void set_addr_family (int af) {addr_family = af;} void set_addr_family (int af) {addr_family = af;}
int get_addr_family () {return addr_family;} int get_addr_family () {return addr_family;}
void set_socket_type (int st) { type = st;}
int get_socket_type () {return type;}
void set_sun_path (const char *path); void set_sun_path (const char *path);
char *get_sun_path () {return sun_path;} char *get_sun_path () {return sun_path;}
void set_connect_secret (); void set_connect_secret ();

View File

@ -518,6 +518,7 @@ cygwin_socket (int af, int type, int protocol)
{ {
int res = -1; int res = -1;
SOCKET soc = 0; SOCKET soc = 0;
fhandler_socket* fh = NULL;
cygheap_fdnew fd; cygheap_fdnew fd;
@ -539,7 +540,12 @@ cygwin_socket (int af, int type, int protocol)
else else
name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket"); name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
fdsock (fd, name, soc)->set_addr_family (af); fh = fdsock (fd, name, soc);
if (fh)
{
fh->set_addr_family (af);
fh->set_socket_type (type);
}
res = fd; res = fd;
} }
@ -881,7 +887,8 @@ cygwin_connect (int fd,
} }
set_winsock_errno (); set_winsock_errno ();
} }
if (sock->get_addr_family () == AF_LOCAL) if (sock->get_addr_family () == AF_LOCAL &&
sock->get_socket_type () == SOCK_STREAM)
{ {
if (!res || in_progress) if (!res || in_progress)
{ {
@ -1199,7 +1206,8 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
WSAGetLastError () == WSAEWOULDBLOCK) WSAGetLastError () == WSAEWOULDBLOCK)
in_progress = TRUE; in_progress = TRUE;
if (sock->get_addr_family () == AF_LOCAL) if (sock->get_addr_family () == AF_LOCAL &&
sock->get_socket_type () == SOCK_STREAM)
{ {
if ((SOCKET) res != (SOCKET) INVALID_SOCKET || in_progress) if ((SOCKET) res != (SOCKET) INVALID_SOCKET || in_progress)
{ {
@ -1242,6 +1250,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
if (sock->get_addr_family () == AF_LOCAL) if (sock->get_addr_family () == AF_LOCAL)
res_fh->set_sun_path (sock->get_sun_path ()); res_fh->set_sun_path (sock->get_sun_path ());
res_fh->set_addr_family (sock->get_addr_family ()); res_fh->set_addr_family (sock->get_addr_family ());
res_fh->set_socket_type (sock->get_socket_type ());
res = res_fd; res = res_fd;
} }
} }
@ -2266,6 +2275,7 @@ socketpair (int family, int type, int protocol, int *sb)
struct sockaddr_in sock_in, sock_out; struct sockaddr_in sock_in, sock_out;
int len; int len;
cygheap_fdnew sb0; cygheap_fdnew sb0;
fhandler_socket *fh;
if (__check_null_invalid_struct_errno (sb, 2 * sizeof(int))) if (__check_null_invalid_struct_errno (sb, 2 * sizeof(int)))
return -1; return -1;
@ -2417,25 +2427,30 @@ socketpair (int family, int type, int protocol, int *sb)
if (family == AF_LOCAL) if (family == AF_LOCAL)
{ {
fhandler_socket *fh;
fh = fdsock (sb[0], fh = fdsock (sb[0],
type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket", type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket",
insock); insock);
fh->set_sun_path (""); fh->set_sun_path ("");
fh->set_addr_family (AF_LOCAL); fh->set_addr_family (AF_LOCAL);
fh->set_socket_type (type);
fh = fdsock (sb[1], fh = fdsock (sb[1],
type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket", type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket",
outsock); outsock);
fh->set_sun_path (""); fh->set_sun_path ("");
fh->set_addr_family (AF_LOCAL); fh->set_addr_family (AF_LOCAL);
fh->set_socket_type (type);
} }
else else
{ {
fdsock (sb[0], type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp", fh = fdsock (sb[0], type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp",
insock)->set_addr_family (AF_INET); insock);
fdsock (sb[1], type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp", fh->set_addr_family (AF_INET);
outsock)->set_addr_family (AF_INET); fh->set_socket_type (type);
fh = fdsock (sb[1], type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp",
outsock);
fh->set_addr_family (AF_INET);
fh->set_socket_type (type);
} }
done: done: