]>
Commit | Line | Data |
---|---|---|
6796bc80 | 1 | #ifndef _SYS_SOCKET_H |
2064087b | 2 | #include <socket/sys/socket.h> |
bdbf022d | 3 | |
31341567 | 4 | #ifndef _ISOMAC |
bdbf022d | 5 | /* Now define the internal interfaces. */ |
6f9ddfff AJ |
6 | |
7 | /* Create a new socket of type TYPE in domain DOMAIN, using | |
8 | protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. | |
9 | Returns a file descriptor for the new socket, or -1 for errors. */ | |
b2bffca2 | 10 | extern int __socket (int __domain, int __type, |
0595c984 JM |
11 | int __protocol); |
12 | libc_hidden_proto (__socket) | |
f720d3d2 | 13 | |
36f7b1df MK |
14 | /* Create two new sockets, of type TYPE in domain DOMAIN and using |
15 | protocol PROTOCOL, which are connected to each other, and put file | |
16 | descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero, | |
17 | one will be chosen automatically. Returns 0 on success, -1 for errors. */ | |
18 | extern int __socketpair (int __domain, int __type, int __protocol, | |
b2bffca2 | 19 | int __fds[2]) attribute_hidden; |
36f7b1df | 20 | |
f720d3d2 UD |
21 | /* Return a socket of any type. The socket can be used in subsequent |
22 | ioctl calls to talk to the kernel. */ | |
038d1caf | 23 | extern int __opensock (void) attribute_hidden; |
f720d3d2 | 24 | |
3d421b28 AJ |
25 | /* Put the address of the peer connected to socket FD into *ADDR |
26 | (which is *LEN bytes long), and its actual length into *LEN. */ | |
b2bffca2 UD |
27 | extern int __getpeername (int __fd, __SOCKADDR_ARG __addr, |
28 | socklen_t *__len) attribute_hidden; | |
3d421b28 | 29 | |
8f589a7c | 30 | /* Send N bytes of BUF to socket FD. Returns the number sent or -1. */ |
a784e502 | 31 | extern ssize_t __libc_send (int __fd, const void *__buf, size_t __n, |
91d29377 | 32 | int __flags); |
a784e502 | 33 | extern ssize_t __send (int __fd, const void *__buf, size_t __n, int __flags); |
37ba7d66 | 34 | libc_hidden_proto (__send) |
8f589a7c | 35 | |
91d29377 UD |
36 | /* Read N bytes into BUF from socket FD. |
37 | Returns the number read or -1 for errors. */ | |
38 | extern ssize_t __libc_recv (int __fd, void *__buf, size_t __n, int __flags); | |
39 | ||
6f9ddfff AJ |
40 | /* Send N bytes of BUF on socket FD to peer at address ADDR (which is |
41 | ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */ | |
a784e502 | 42 | extern ssize_t __libc_sendto (int __fd, const void *__buf, size_t __n, |
6f9ddfff AJ |
43 | int __flags, __CONST_SOCKADDR_ARG __addr, |
44 | socklen_t __addr_len); | |
45 | ||
46 | /* Read N bytes into BUF through socket FD. | |
7f0d9e61 | 47 | If ADDR is not NULL, fill in *ADDR_LEN bytes of it with the address of |
6f9ddfff AJ |
48 | the sender, and store the actual size of the address in *ADDR_LEN. |
49 | Returns the number of bytes read or -1 for errors. */ | |
50 | extern ssize_t __libc_recvfrom (int __fd, void *__restrict __buf, size_t __n, | |
51 | int __flags, __SOCKADDR_ARG __addr, | |
52 | socklen_t *__restrict __addr_len); | |
53 | ||
8f589a7c AJ |
54 | /* Open a connection on socket FD to peer at ADDR (which LEN bytes long). |
55 | For connectionless socket types, just set the default address to send to | |
56 | and the only address from which to accept transmissions. | |
57 | Return 0 on success, -1 for errors. */ | |
91d29377 UD |
58 | extern int __libc_connect (int __fd, __CONST_SOCKADDR_ARG __addr, |
59 | socklen_t __len); | |
8f589a7c | 60 | extern int __connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len); |
03277f8f | 61 | libc_hidden_proto (__connect) |
8f589a7c | 62 | |
a2274a08 RM |
63 | /* Read N bytes into BUF from socket FD. |
64 | Returns the number read or -1 for errors. | |
65 | ||
66 | This function is a cancellation point and therefore not marked with | |
67 | __THROW. */ | |
0595c984 JM |
68 | extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags); |
69 | libc_hidden_proto (__recv) | |
a2274a08 | 70 | |
b2bffca2 UD |
71 | /* Send N bytes of BUF on socket FD to peer at address ADDR (which is |
72 | ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */ | |
a784e502 | 73 | extern ssize_t __libc_sendto (int __fd, const void *__buf, size_t __n, |
91d29377 UD |
74 | int __flags, __CONST_SOCKADDR_ARG __addr, |
75 | socklen_t __addr_len); | |
a784e502 | 76 | extern ssize_t __sendto (int __fd, const void *__buf, size_t __n, |
b2bffca2 UD |
77 | int __flags, __CONST_SOCKADDR_ARG __addr, |
78 | socklen_t __addr_len) attribute_hidden; | |
79 | ||
80 | /* Read N bytes into BUF through socket FD. | |
7f0d9e61 | 81 | If ADDR is not NULL, fill in *ADDR_LEN bytes of it with the address of |
b2bffca2 UD |
82 | the sender, and store the actual size of the address in *ADDR_LEN. |
83 | Returns the number of bytes read or -1 for errors. */ | |
84 | extern ssize_t __recvfrom (int __fd, void *__restrict __buf, size_t __n, | |
85 | int __flags, __SOCKADDR_ARG __addr, | |
86 | socklen_t *__restrict __addr_len) attribute_hidden; | |
87 | ||
88 | /* Send a message described MESSAGE on socket FD. | |
89 | Returns the number of bytes sent, or -1 for errors. */ | |
a784e502 | 90 | extern ssize_t __libc_sendmsg (int __fd, const struct msghdr *__message, |
91d29377 | 91 | int __flags); |
a784e502 | 92 | extern ssize_t __sendmsg (int __fd, const struct msghdr *__message, |
b2bffca2 UD |
93 | int __flags) attribute_hidden; |
94 | ||
7f296942 | 95 | #ifdef __USE_GNU |
123be9de TS |
96 | extern int __sendmmsg (int __fd, struct mmsghdr *__vmessages, |
97 | unsigned int __vlen, int __flags); | |
98 | libc_hidden_proto (__sendmmsg) | |
7f296942 | 99 | #endif |
123be9de | 100 | |
91d29377 UD |
101 | extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message, |
102 | int __flags); | |
b2bffca2 UD |
103 | extern ssize_t __recvmsg (int __fd, struct msghdr *__message, |
104 | int __flags) attribute_hidden; | |
b16f282c | 105 | #if __TIMESIZE == 64 |
948ce73b AZ |
106 | # define __libc_recvmsg64 __libc_recvmsg |
107 | # define __recvmsg64 __recvmsg | |
b16f282c AZ |
108 | # define __recvmmsg64 __recvmmsg |
109 | #else | |
948ce73b AZ |
110 | extern ssize_t __libc_recvmsg64 (int __fd, struct msghdr *__message, |
111 | int __flags); | |
112 | extern ssize_t __recvmsg64 (int __fd, struct msghdr *__message, | |
113 | int __flags); | |
114 | /* Receive a message as described by MESSAGE from socket FD. | |
115 | Returns the number of bytes read or -1 for errors. */ | |
b16f282c AZ |
116 | extern int __recvmmsg64 (int __fd, struct mmsghdr *vmessages, |
117 | unsigned int vlen, int flags, | |
118 | struct __timespec64 *timeout); | |
119 | libc_hidden_proto (__recvmmsg64) | |
120 | #endif | |
b2bffca2 UD |
121 | |
122 | /* Set socket FD's option OPTNAME at protocol level LEVEL | |
123 | to *OPTVAL (which is OPTLEN bytes long). | |
124 | Returns 0 on success, -1 for errors. */ | |
125 | extern int __setsockopt (int __fd, int __level, int __optname, | |
a784e502 | 126 | const void *__optval, |
b8f88906 FW |
127 | socklen_t __optlen); |
128 | libc_hidden_proto (__setsockopt) | |
b2bffca2 | 129 | |
489aa29d UD |
130 | /* Put the current value for socket FD's option OPTNAME at protocol level LEVEL |
131 | into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's | |
132 | actual length. Returns 0 on success, -1 for errors. */ | |
133 | extern int __getsockopt (int __fd, int __level, int __optname, | |
134 | void *__restrict __optval, | |
135 | socklen_t *__restrict __optlen) attribute_hidden; | |
136 | ||
b2bffca2 UD |
137 | /* Put the local address of FD into *ADDR and its length in *LEN. */ |
138 | extern int __getsockname (int __fd, __SOCKADDR_ARG __addr, | |
139 | socklen_t *__restrict __len) attribute_hidden; | |
140 | ||
141 | /* Give the socket FD the local address ADDR (which is LEN bytes long). */ | |
142 | extern int __bind (int __fd, __CONST_SOCKADDR_ARG __addr, | |
143 | socklen_t __len) attribute_hidden; | |
144 | ||
145 | /* Prepare to accept connections on socket FD. | |
146 | N connection requests will be queued before further requests are refused. | |
147 | Returns 0 on success, -1 for errors. */ | |
148 | extern int __listen (int __fd, int __n) attribute_hidden; | |
149 | ||
91d29377 UD |
150 | /* Await a connection on socket FD. |
151 | When a connection arrives, open a new socket to communicate with it, | |
152 | set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting | |
153 | peer and *ADDR_LEN to the address's actual length, and return the | |
154 | new socket's descriptor, or -1 for errors. */ | |
155 | extern int __libc_accept (int __fd, __SOCKADDR_ARG __addr, | |
156 | socklen_t *__restrict __addr_len) | |
789bd351 | 157 | __THROW attribute_hidden; |
a4baf360 | 158 | libc_hidden_proto (accept) |
eb43375f TS |
159 | extern int __libc_accept4 (int __fd, __SOCKADDR_ARG __addr, |
160 | socklen_t *__restrict __addr_len, int __flags) | |
789bd351 | 161 | __THROW attribute_hidden; |
91d29377 | 162 | |
3f66a0cf UD |
163 | /* Return the length of a `sockaddr' structure. */ |
164 | #ifdef _HAVE_SA_LEN | |
165 | # define SA_LEN(_x) (_x)->sa_len | |
166 | #else | |
08f60074 | 167 | extern int __libc_sa_len (sa_family_t __af); |
03277f8f AS |
168 | libc_hidden_proto (__libc_sa_len) |
169 | # define SA_LEN(_x) __libc_sa_len((_x)->sa_family) | |
6b87a564 UD |
170 | #endif |
171 | ||
e4452a2d JM |
172 | libc_hidden_proto (__cmsg_nxthdr) |
173 | ||
13c51549 AZ |
174 | #ifndef __ASSUME_TIME64_SYSCALLS |
175 | extern void __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize) | |
176 | attribute_hidden; | |
177 | #endif | |
178 | ||
6796bc80 | 179 | #endif |
31341567 | 180 | #endif |