1998-09-06 23:45:24 +00:00
|
|
|
#ifndef _SYS_SOCKET_H
|
1996-07-14 06:04:09 +00:00
|
|
|
#include <socket/sys/socket.h>
|
1998-08-09 17:39:48 +00:00
|
|
|
|
2012-02-25 23:18:39 -05:00
|
|
|
#ifndef _ISOMAC
|
1998-08-09 17:39:48 +00:00
|
|
|
/* Now define the internal interfaces. */
|
2002-07-08 17:17:36 +00:00
|
|
|
|
|
|
|
|
/* Create a new socket of type TYPE in domain DOMAIN, using
|
|
|
|
|
protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
|
|
|
|
|
Returns a file descriptor for the new socket, or -1 for errors. */
|
2002-05-15 00:22:23 +00:00
|
|
|
extern int __socket (int __domain, int __type,
|
2015-06-17 20:20:08 +00:00
|
|
|
int __protocol);
|
|
|
|
|
libc_hidden_proto (__socket)
|
1999-10-29 21:40:21 +00:00
|
|
|
|
2000-08-09 21:05:45 +00:00
|
|
|
/* Create two new sockets, of type TYPE in domain DOMAIN and using
|
|
|
|
|
protocol PROTOCOL, which are connected to each other, and put file
|
|
|
|
|
descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
|
|
|
|
|
one will be chosen automatically. Returns 0 on success, -1 for errors. */
|
|
|
|
|
extern int __socketpair (int __domain, int __type, int __protocol,
|
2002-05-15 00:22:23 +00:00
|
|
|
int __fds[2]) attribute_hidden;
|
2000-08-09 21:05:45 +00:00
|
|
|
|
1999-10-29 21:40:21 +00:00
|
|
|
/* Return a socket of any type. The socket can be used in subsequent
|
|
|
|
|
ioctl calls to talk to the kernel. */
|
2017-08-17 10:18:04 +02:00
|
|
|
extern int __opensock (void) attribute_hidden;
|
1999-10-29 21:40:21 +00:00
|
|
|
|
2000-08-21 08:37:43 +00:00
|
|
|
/* Put the address of the peer connected to socket FD into *ADDR
|
|
|
|
|
(which is *LEN bytes long), and its actual length into *LEN. */
|
2002-05-15 00:22:23 +00:00
|
|
|
extern int __getpeername (int __fd, __SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t *__len) attribute_hidden;
|
2000-08-21 08:37:43 +00:00
|
|
|
|
2000-08-23 17:05:51 +00:00
|
|
|
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __libc_send (int __fd, const void *__buf, size_t __n,
|
2002-09-17 17:06:49 +00:00
|
|
|
int __flags);
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __send (int __fd, const void *__buf, size_t __n, int __flags);
|
2002-08-03 07:02:10 +00:00
|
|
|
libc_hidden_proto (__send)
|
2000-08-23 17:05:51 +00:00
|
|
|
|
2002-09-17 17:06:49 +00:00
|
|
|
/* Read N bytes into BUF from socket FD.
|
|
|
|
|
Returns the number read or -1 for errors. */
|
|
|
|
|
extern ssize_t __libc_recv (int __fd, void *__buf, size_t __n, int __flags);
|
|
|
|
|
|
2002-07-08 17:17:36 +00:00
|
|
|
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
|
|
|
|
|
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __libc_sendto (int __fd, const void *__buf, size_t __n,
|
2002-07-08 17:17:36 +00:00
|
|
|
int __flags, __CONST_SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t __addr_len);
|
|
|
|
|
|
|
|
|
|
/* Read N bytes into BUF through socket FD.
|
|
|
|
|
If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
|
|
|
|
|
the sender, and store the actual size of the address in *ADDR_LEN.
|
|
|
|
|
Returns the number of bytes read or -1 for errors. */
|
|
|
|
|
extern ssize_t __libc_recvfrom (int __fd, void *__restrict __buf, size_t __n,
|
|
|
|
|
int __flags, __SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t *__restrict __addr_len);
|
|
|
|
|
|
2000-08-23 17:05:51 +00:00
|
|
|
/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
|
|
|
|
|
For connectionless socket types, just set the default address to send to
|
|
|
|
|
and the only address from which to accept transmissions.
|
|
|
|
|
Return 0 on success, -1 for errors. */
|
2002-09-17 17:06:49 +00:00
|
|
|
extern int __libc_connect (int __fd, __CONST_SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t __len);
|
2000-08-23 17:05:51 +00:00
|
|
|
extern int __connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
|
2012-05-29 22:40:00 +02:00
|
|
|
libc_hidden_proto (__connect)
|
2000-08-23 17:05:51 +00:00
|
|
|
|
2005-02-22 22:51:17 +00:00
|
|
|
/* Read N bytes into BUF from socket FD.
|
|
|
|
|
Returns the number read or -1 for errors.
|
|
|
|
|
|
|
|
|
|
This function is a cancellation point and therefore not marked with
|
|
|
|
|
__THROW. */
|
2015-06-17 20:20:08 +00:00
|
|
|
extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags);
|
|
|
|
|
libc_hidden_proto (__recv)
|
2005-02-22 22:51:17 +00:00
|
|
|
|
2002-05-15 00:22:23 +00:00
|
|
|
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
|
|
|
|
|
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __libc_sendto (int __fd, const void *__buf, size_t __n,
|
2002-09-17 17:06:49 +00:00
|
|
|
int __flags, __CONST_SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t __addr_len);
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __sendto (int __fd, const void *__buf, size_t __n,
|
2002-05-15 00:22:23 +00:00
|
|
|
int __flags, __CONST_SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t __addr_len) attribute_hidden;
|
|
|
|
|
|
|
|
|
|
/* Read N bytes into BUF through socket FD.
|
|
|
|
|
If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
|
|
|
|
|
the sender, and store the actual size of the address in *ADDR_LEN.
|
|
|
|
|
Returns the number of bytes read or -1 for errors. */
|
|
|
|
|
extern ssize_t __recvfrom (int __fd, void *__restrict __buf, size_t __n,
|
|
|
|
|
int __flags, __SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t *__restrict __addr_len) attribute_hidden;
|
|
|
|
|
|
|
|
|
|
/* Send a message described MESSAGE on socket FD.
|
|
|
|
|
Returns the number of bytes sent, or -1 for errors. */
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __libc_sendmsg (int __fd, const struct msghdr *__message,
|
2002-09-17 17:06:49 +00:00
|
|
|
int __flags);
|
2012-01-07 23:57:22 -05:00
|
|
|
extern ssize_t __sendmsg (int __fd, const struct msghdr *__message,
|
2002-05-15 00:22:23 +00:00
|
|
|
int __flags) attribute_hidden;
|
|
|
|
|
|
2014-12-11 14:54:22 -05:00
|
|
|
#ifdef __USE_GNU
|
2012-11-03 18:29:46 +01:00
|
|
|
extern int __sendmmsg (int __fd, struct mmsghdr *__vmessages,
|
|
|
|
|
unsigned int __vlen, int __flags);
|
|
|
|
|
libc_hidden_proto (__sendmmsg)
|
2014-12-11 14:54:22 -05:00
|
|
|
#endif
|
2012-11-03 18:29:46 +01:00
|
|
|
|
2002-09-17 17:06:49 +00:00
|
|
|
extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message,
|
|
|
|
|
int __flags);
|
2002-05-15 00:22:23 +00:00
|
|
|
extern ssize_t __recvmsg (int __fd, struct msghdr *__message,
|
|
|
|
|
int __flags) attribute_hidden;
|
2020-07-06 16:55:46 -03:00
|
|
|
#if __TIMESIZE == 64
|
2022-01-27 16:45:18 -03:00
|
|
|
# define __libc_recvmsg64 __libc_recvmsg
|
|
|
|
|
# define __recvmsg64 __recvmsg
|
2020-07-06 16:55:46 -03:00
|
|
|
# define __recvmmsg64 __recvmmsg
|
|
|
|
|
#else
|
2022-01-27 16:45:18 -03:00
|
|
|
extern ssize_t __libc_recvmsg64 (int __fd, struct msghdr *__message,
|
|
|
|
|
int __flags);
|
|
|
|
|
extern ssize_t __recvmsg64 (int __fd, struct msghdr *__message,
|
|
|
|
|
int __flags);
|
|
|
|
|
/* Receive a message as described by MESSAGE from socket FD.
|
|
|
|
|
Returns the number of bytes read or -1 for errors. */
|
2020-07-06 16:55:46 -03:00
|
|
|
extern int __recvmmsg64 (int __fd, struct mmsghdr *vmessages,
|
|
|
|
|
unsigned int vlen, int flags,
|
|
|
|
|
struct __timespec64 *timeout);
|
|
|
|
|
libc_hidden_proto (__recvmmsg64)
|
|
|
|
|
#endif
|
2002-05-15 00:22:23 +00:00
|
|
|
|
|
|
|
|
/* Set socket FD's option OPTNAME at protocol level LEVEL
|
|
|
|
|
to *OPTVAL (which is OPTLEN bytes long).
|
|
|
|
|
Returns 0 on success, -1 for errors. */
|
|
|
|
|
extern int __setsockopt (int __fd, int __level, int __optname,
|
2012-01-07 23:57:22 -05:00
|
|
|
const void *__optval,
|
2021-07-15 08:28:50 +02:00
|
|
|
socklen_t __optlen);
|
|
|
|
|
libc_hidden_proto (__setsockopt)
|
2002-05-15 00:22:23 +00:00
|
|
|
|
2004-08-06 04:56:04 +00:00
|
|
|
/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
|
|
|
|
|
into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
|
|
|
|
|
actual length. Returns 0 on success, -1 for errors. */
|
|
|
|
|
extern int __getsockopt (int __fd, int __level, int __optname,
|
|
|
|
|
void *__restrict __optval,
|
|
|
|
|
socklen_t *__restrict __optlen) attribute_hidden;
|
|
|
|
|
|
2002-05-15 00:22:23 +00:00
|
|
|
/* Put the local address of FD into *ADDR and its length in *LEN. */
|
|
|
|
|
extern int __getsockname (int __fd, __SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t *__restrict __len) attribute_hidden;
|
|
|
|
|
|
|
|
|
|
/* Give the socket FD the local address ADDR (which is LEN bytes long). */
|
|
|
|
|
extern int __bind (int __fd, __CONST_SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t __len) attribute_hidden;
|
|
|
|
|
|
|
|
|
|
/* Prepare to accept connections on socket FD.
|
|
|
|
|
N connection requests will be queued before further requests are refused.
|
|
|
|
|
Returns 0 on success, -1 for errors. */
|
|
|
|
|
extern int __listen (int __fd, int __n) attribute_hidden;
|
|
|
|
|
|
2002-09-17 17:06:49 +00:00
|
|
|
/* Await a connection on socket FD.
|
|
|
|
|
When a connection arrives, open a new socket to communicate with it,
|
|
|
|
|
set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
|
|
|
|
|
peer and *ADDR_LEN to the address's actual length, and return the
|
|
|
|
|
new socket's descriptor, or -1 for errors. */
|
|
|
|
|
extern int __libc_accept (int __fd, __SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t *__restrict __addr_len)
|
2012-07-31 09:43:14 -07:00
|
|
|
__THROW attribute_hidden;
|
2002-12-31 20:46:11 +00:00
|
|
|
libc_hidden_proto (accept)
|
2012-05-10 12:53:02 -07:00
|
|
|
extern int __libc_accept4 (int __fd, __SOCKADDR_ARG __addr,
|
|
|
|
|
socklen_t *__restrict __addr_len, int __flags)
|
2012-07-31 09:43:14 -07:00
|
|
|
__THROW attribute_hidden;
|
2002-09-17 17:06:49 +00:00
|
|
|
|
2001-01-31 06:16:26 +00:00
|
|
|
/* Return the length of a `sockaddr' structure. */
|
|
|
|
|
#ifdef _HAVE_SA_LEN
|
|
|
|
|
# define SA_LEN(_x) (_x)->sa_len
|
|
|
|
|
#else
|
2002-04-14 20:15:40 +00:00
|
|
|
extern int __libc_sa_len (sa_family_t __af);
|
2012-05-29 22:40:00 +02:00
|
|
|
libc_hidden_proto (__libc_sa_len)
|
|
|
|
|
# define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
|
2002-04-09 20:36:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2018-02-15 20:59:12 +00:00
|
|
|
libc_hidden_proto (__cmsg_nxthdr)
|
|
|
|
|
|
2020-09-07 17:08:46 -03:00
|
|
|
#ifndef __ASSUME_TIME64_SYSCALLS
|
|
|
|
|
extern void __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
|
|
|
|
|
attribute_hidden;
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-09-06 23:45:24 +00:00
|
|
|
#endif
|
2012-02-25 23:18:39 -05:00
|
|
|
#endif
|