PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/arm-cortex_a15-linux-gnueabihf-linaro_4.9.1-2014.05/arm-cortex_a15-linux-gnueabihf/libc/usr/include/sys/socket.h

https://github.com/hyperion70/linaro_toolchains_2014
C Header | 285 lines | 115 code | 44 blank | 126 comment | 3 complexity | cfa54ce63703bce96cd0e962f2945e84 MD5 | raw file
Possible License(s): GPL-3.0
  1. /* Declarations of socket constants, types, and functions.
  2. Copyright (C) 1991-2014 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _SYS_SOCKET_H
  16. #define _SYS_SOCKET_H 1
  17. #include <features.h>
  18. __BEGIN_DECLS
  19. #include <sys/uio.h>
  20. #define __need_size_t
  21. #include <stddef.h>
  22. #ifdef __USE_GNU
  23. /* Get the __sigset_t definition. */
  24. # include <bits/sigset.h>
  25. #endif
  26. /* This operating system-specific header file defines the SOCK_*, PF_*,
  27. AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',
  28. `struct msghdr', and `struct linger' types. */
  29. #include <bits/socket.h>
  30. #ifdef __USE_BSD
  31. /* This is the 4.3 BSD `struct sockaddr' format, which is used as wire
  32. format in the grotty old 4.3 `talk' protocol. */
  33. struct osockaddr
  34. {
  35. unsigned short int sa_family;
  36. unsigned char sa_data[14];
  37. };
  38. #endif
  39. /* The following constants should be used for the second parameter of
  40. `shutdown'. */
  41. enum
  42. {
  43. SHUT_RD = 0, /* No more receptions. */
  44. #define SHUT_RD SHUT_RD
  45. SHUT_WR, /* No more transmissions. */
  46. #define SHUT_WR SHUT_WR
  47. SHUT_RDWR /* No more receptions or transmissions. */
  48. #define SHUT_RDWR SHUT_RDWR
  49. };
  50. /* This is the type we use for generic socket address arguments.
  51. With GCC 2.7 and later, the funky union causes redeclarations or
  52. uses with any of the listed types to be allowed without complaint.
  53. G++ 2.7 does not support transparent unions so there we want the
  54. old-style declaration, too. */
  55. #if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU
  56. # define __SOCKADDR_ARG struct sockaddr *__restrict
  57. # define __CONST_SOCKADDR_ARG const struct sockaddr *
  58. #else
  59. /* Add more `struct sockaddr_AF' types here as necessary.
  60. These are all the ones I found on NetBSD and Linux. */
  61. # define __SOCKADDR_ALLTYPES \
  62. __SOCKADDR_ONETYPE (sockaddr) \
  63. __SOCKADDR_ONETYPE (sockaddr_at) \
  64. __SOCKADDR_ONETYPE (sockaddr_ax25) \
  65. __SOCKADDR_ONETYPE (sockaddr_dl) \
  66. __SOCKADDR_ONETYPE (sockaddr_eon) \
  67. __SOCKADDR_ONETYPE (sockaddr_in) \
  68. __SOCKADDR_ONETYPE (sockaddr_in6) \
  69. __SOCKADDR_ONETYPE (sockaddr_inarp) \
  70. __SOCKADDR_ONETYPE (sockaddr_ipx) \
  71. __SOCKADDR_ONETYPE (sockaddr_iso) \
  72. __SOCKADDR_ONETYPE (sockaddr_ns) \
  73. __SOCKADDR_ONETYPE (sockaddr_un) \
  74. __SOCKADDR_ONETYPE (sockaddr_x25)
  75. # define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
  76. typedef union { __SOCKADDR_ALLTYPES
  77. } __SOCKADDR_ARG __attribute__ ((__transparent_union__));
  78. # undef __SOCKADDR_ONETYPE
  79. # define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
  80. typedef union { __SOCKADDR_ALLTYPES
  81. } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));
  82. # undef __SOCKADDR_ONETYPE
  83. #endif
  84. #ifdef __USE_GNU
  85. /* For `recvmmsg' and `sendmmsg'. */
  86. struct mmsghdr
  87. {
  88. struct msghdr msg_hdr; /* Actual message header. */
  89. unsigned int msg_len; /* Number of received or sent bytes for the
  90. entry. */
  91. };
  92. #endif
  93. /* Create a new socket of type TYPE in domain DOMAIN, using
  94. protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
  95. Returns a file descriptor for the new socket, or -1 for errors. */
  96. extern int socket (int __domain, int __type, int __protocol) __THROW;
  97. /* Create two new sockets, of type TYPE in domain DOMAIN and using
  98. protocol PROTOCOL, which are connected to each other, and put file
  99. descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
  100. one will be chosen automatically. Returns 0 on success, -1 for errors. */
  101. extern int socketpair (int __domain, int __type, int __protocol,
  102. int __fds[2]) __THROW;
  103. /* Give the socket FD the local address ADDR (which is LEN bytes long). */
  104. extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
  105. __THROW;
  106. /* Put the local address of FD into *ADDR and its length in *LEN. */
  107. extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
  108. socklen_t *__restrict __len) __THROW;
  109. /* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
  110. For connectionless socket types, just set the default address to send to
  111. and the only address from which to accept transmissions.
  112. Return 0 on success, -1 for errors.
  113. This function is a cancellation point and therefore not marked with
  114. __THROW. */
  115. extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
  116. /* Put the address of the peer connected to socket FD into *ADDR
  117. (which is *LEN bytes long), and its actual length into *LEN. */
  118. extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
  119. socklen_t *__restrict __len) __THROW;
  120. /* Send N bytes of BUF to socket FD. Returns the number sent or -1.
  121. This function is a cancellation point and therefore not marked with
  122. __THROW. */
  123. extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);
  124. /* Read N bytes into BUF from socket FD.
  125. Returns the number read or -1 for errors.
  126. This function is a cancellation point and therefore not marked with
  127. __THROW. */
  128. extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
  129. /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
  130. ADDR_LEN bytes long). Returns the number sent, or -1 for errors.
  131. This function is a cancellation point and therefore not marked with
  132. __THROW. */
  133. extern ssize_t sendto (int __fd, const void *__buf, size_t __n,
  134. int __flags, __CONST_SOCKADDR_ARG __addr,
  135. socklen_t __addr_len);
  136. /* Read N bytes into BUF through socket FD.
  137. If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
  138. the sender, and store the actual size of the address in *ADDR_LEN.
  139. Returns the number of bytes read or -1 for errors.
  140. This function is a cancellation point and therefore not marked with
  141. __THROW. */
  142. extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
  143. int __flags, __SOCKADDR_ARG __addr,
  144. socklen_t *__restrict __addr_len);
  145. /* Send a message described MESSAGE on socket FD.
  146. Returns the number of bytes sent, or -1 for errors.
  147. This function is a cancellation point and therefore not marked with
  148. __THROW. */
  149. extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
  150. int __flags);
  151. #ifdef __USE_GNU
  152. /* Send a VLEN messages as described by VMESSAGES to socket FD.
  153. Returns the number of datagrams successfully written or -1 for errors.
  154. This function is a cancellation point and therefore not marked with
  155. __THROW. */
  156. extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
  157. unsigned int __vlen, int __flags);
  158. #endif
  159. /* Receive a message as described by MESSAGE from socket FD.
  160. Returns the number of bytes read or -1 for errors.
  161. This function is a cancellation point and therefore not marked with
  162. __THROW. */
  163. extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
  164. #ifdef __USE_GNU
  165. /* Receive up to VLEN messages as described by VMESSAGES from socket FD.
  166. Returns the number of bytes read or -1 for errors.
  167. This function is a cancellation point and therefore not marked with
  168. __THROW. */
  169. extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
  170. unsigned int __vlen, int __flags,
  171. const struct timespec *__tmo);
  172. #endif
  173. /* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
  174. into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
  175. actual length. Returns 0 on success, -1 for errors. */
  176. extern int getsockopt (int __fd, int __level, int __optname,
  177. void *__restrict __optval,
  178. socklen_t *__restrict __optlen) __THROW;
  179. /* Set socket FD's option OPTNAME at protocol level LEVEL
  180. to *OPTVAL (which is OPTLEN bytes long).
  181. Returns 0 on success, -1 for errors. */
  182. extern int setsockopt (int __fd, int __level, int __optname,
  183. const void *__optval, socklen_t __optlen) __THROW;
  184. /* Prepare to accept connections on socket FD.
  185. N connection requests will be queued before further requests are refused.
  186. Returns 0 on success, -1 for errors. */
  187. extern int listen (int __fd, int __n) __THROW;
  188. /* Await a connection on socket FD.
  189. When a connection arrives, open a new socket to communicate with it,
  190. set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
  191. peer and *ADDR_LEN to the address's actual length, and return the
  192. new socket's descriptor, or -1 for errors.
  193. This function is a cancellation point and therefore not marked with
  194. __THROW. */
  195. extern int accept (int __fd, __SOCKADDR_ARG __addr,
  196. socklen_t *__restrict __addr_len);
  197. #ifdef __USE_GNU
  198. /* Similar to 'accept' but takes an additional parameter to specify flags.
  199. This function is a cancellation point and therefore not marked with
  200. __THROW. */
  201. extern int accept4 (int __fd, __SOCKADDR_ARG __addr,
  202. socklen_t *__restrict __addr_len, int __flags);
  203. #endif
  204. /* Shut down all or part of the connection open on socket FD.
  205. HOW determines what to shut down:
  206. SHUT_RD = No more receptions;
  207. SHUT_WR = No more transmissions;
  208. SHUT_RDWR = No more receptions or transmissions.
  209. Returns 0 on success, -1 for errors. */
  210. extern int shutdown (int __fd, int __how) __THROW;
  211. #ifdef __USE_XOPEN2K
  212. /* Determine wheter socket is at a out-of-band mark. */
  213. extern int sockatmark (int __fd) __THROW;
  214. #endif
  215. #ifdef __USE_MISC
  216. /* FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>;
  217. returns 1 if FD is open on an object of the indicated type, 0 if not,
  218. or -1 for errors (setting errno). */
  219. extern int isfdtype (int __fd, int __fdtype) __THROW;
  220. #endif
  221. /* Define some macros helping to catch buffer overflows. */
  222. #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
  223. # include <bits/socket2.h>
  224. #endif
  225. __END_DECLS
  226. #endif /* sys/socket.h */