PageRenderTime 59ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/bionic/libc/include/sys/socket.h

https://gitlab.com/brian0218/rk3188_rk3066_r-box_android4.4.2_sdk
C Header | 300 lines | 243 code | 29 blank | 28 comment | 2 complexity | f32ce7dbda44e5f00f9744dc2e16fbc2 MD5 | raw file
  1. /*
  2. * Copyright (C) 2008 The Android Open Source Project
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  18. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  19. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  21. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  22. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  23. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  25. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. */
  28. #ifndef _SYS_SOCKET_H_
  29. #define _SYS_SOCKET_H_
  30. #include <sys/cdefs.h>
  31. #include <sys/types.h>
  32. #include <linux/socket.h>
  33. #include <asm/socket.h>
  34. #include <linux/sockios.h>
  35. #include <linux/uio.h>
  36. #include <linux/types.h>
  37. #include <linux/compiler.h>
  38. __BEGIN_DECLS
  39. #define sockaddr_storage __kernel_sockaddr_storage
  40. typedef __sa_family_t sa_family_t;
  41. typedef int socklen_t;
  42. #ifdef __mips__
  43. #define SOCK_DGRAM 1
  44. #define SOCK_STREAM 2
  45. #define SOCK_RAW 3
  46. #define SOCK_RDM 4
  47. #define SOCK_SEQPACKET 5
  48. #define SOCK_DCCP 6
  49. #define SOCK_PACKET 10
  50. #else
  51. #define SOCK_STREAM 1
  52. #define SOCK_DGRAM 2
  53. #define SOCK_RAW 3
  54. #define SOCK_RDM 4
  55. #define SOCK_SEQPACKET 5
  56. #define SOCK_PACKET 10
  57. #endif
  58. /* BIONIC: second argument to shutdown() */
  59. enum {
  60. SHUT_RD = 0, /* no more receptions */
  61. #define SHUT_RD SHUT_RD
  62. SHUT_WR, /* no more transmissions */
  63. #define SHUT_WR SHUT_WR
  64. SHUT_RDWR /* no more receptions or transmissions */
  65. #define SHUT_RDWR SHUT_RDWR
  66. };
  67. struct sockaddr {
  68. sa_family_t sa_family;
  69. char sa_data[14];
  70. };
  71. struct linger {
  72. int l_onoff;
  73. int l_linger;
  74. };
  75. struct msghdr {
  76. void * msg_name;
  77. int msg_namelen;
  78. struct iovec * msg_iov;
  79. __kernel_size_t msg_iovlen;
  80. void * msg_control;
  81. __kernel_size_t msg_controllen;
  82. unsigned msg_flags;
  83. };
  84. struct cmsghdr {
  85. __kernel_size_t cmsg_len;
  86. int cmsg_level;
  87. int cmsg_type;
  88. };
  89. #define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg))
  90. #define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg))
  91. #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
  92. #define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr))))
  93. #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
  94. #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
  95. #define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? (struct cmsghdr *)(ctl) : (struct cmsghdr *)NULL)
  96. #define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
  97. #define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && (cmsg)->cmsg_len <= (unsigned long) ((mhdr)->msg_controllen - ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
  98. #ifdef __GNUC__
  99. #define __KINLINE static __inline__
  100. #elif defined(__cplusplus)
  101. #define __KINLINE static inline
  102. #else
  103. #define __KINLINE static
  104. #endif
  105. __KINLINE struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size, struct cmsghdr *__cmsg) {
  106. struct cmsghdr * __ptr;
  107. __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len));
  108. if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
  109. return (struct cmsghdr *)0;
  110. return __ptr;
  111. }
  112. __KINLINE struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg) {
  113. return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
  114. }
  115. #define SCM_RIGHTS 0x01
  116. #define SCM_CREDENTIALS 0x02
  117. #define SCM_SECURITY 0x03
  118. struct ucred {
  119. __u32 pid;
  120. __u32 uid;
  121. __u32 gid;
  122. };
  123. #define AF_UNSPEC 0
  124. #define AF_UNIX 1
  125. #define AF_LOCAL 1
  126. #define AF_INET 2
  127. #define AF_AX25 3
  128. #define AF_IPX 4
  129. #define AF_APPLETALK 5
  130. #define AF_NETROM 6
  131. #define AF_BRIDGE 7
  132. #define AF_ATMPVC 8
  133. #define AF_X25 9
  134. #define AF_INET6 10
  135. #define AF_ROSE 11
  136. #define AF_DECnet 12
  137. #define AF_NETBEUI 13
  138. #define AF_SECURITY 14
  139. #define AF_KEY 15
  140. #define AF_NETLINK 16
  141. #define AF_ROUTE AF_NETLINK
  142. #define AF_PACKET 17
  143. #define AF_ASH 18
  144. #define AF_ECONET 19
  145. #define AF_ATMSVC 20
  146. #define AF_RDS 21
  147. #define AF_SNA 22
  148. #define AF_IRDA 23
  149. #define AF_PPPOX 24
  150. #define AF_WANPIPE 25
  151. #define AF_LLC 26
  152. #define AF_CAN 29
  153. #define AF_TIPC 30
  154. #define AF_BLUETOOTH 31
  155. #define AF_IUCV 32
  156. #define AF_RXRPC 33
  157. #define AF_ISDN 34
  158. #define AF_PHONET 35
  159. #define AF_IEEE802154 36
  160. #define AF_CAIF 37
  161. #define AF_ALG 38
  162. #define AF_MAX 39
  163. #define PF_UNSPEC AF_UNSPEC
  164. #define PF_UNIX AF_UNIX
  165. #define PF_LOCAL AF_LOCAL
  166. #define PF_INET AF_INET
  167. #define PF_AX25 AF_AX25
  168. #define PF_IPX AF_IPX
  169. #define PF_APPLETALK AF_APPLETALK
  170. #define PF_NETROM AF_NETROM
  171. #define PF_BRIDGE AF_BRIDGE
  172. #define PF_ATMPVC AF_ATMPVC
  173. #define PF_X25 AF_X25
  174. #define PF_INET6 AF_INET6
  175. #define PF_ROSE AF_ROSE
  176. #define PF_DECnet AF_DECnet
  177. #define PF_NETBEUI AF_NETBEUI
  178. #define PF_SECURITY AF_SECURITY
  179. #define PF_KEY AF_KEY
  180. #define PF_NETLINK AF_NETLINK
  181. #define PF_ROUTE AF_ROUTE
  182. #define PF_PACKET AF_PACKET
  183. #define PF_ASH AF_ASH
  184. #define PF_ECONET AF_ECONET
  185. #define PF_ATMSVC AF_ATMSVC
  186. #define PF_RDS AF_RDS
  187. #define PF_SNA AF_SNA
  188. #define PF_IRDA AF_IRDA
  189. #define PF_PPPOX AF_PPPOX
  190. #define PF_WANPIPE AF_WANPIPE
  191. #define PF_LLC AF_LLC
  192. #define PF_CAN AF_CAN
  193. #define PF_TIPC AF_TIPC
  194. #define PF_BLUETOOTH AF_BLUETOOTH
  195. #define PF_IUCV AF_IUCV
  196. #define PF_RXRPC AF_RXRPC
  197. #define PF_ISDN AF_ISDN
  198. #define PF_PHONET AF_PHONET
  199. #define PF_IEEE802154 AF_IEEE802154
  200. #define PF_CAIF AF_CAIF
  201. #define PF_ALG AF_ALG
  202. #define PF_MAX AF_MAX
  203. #define SOMAXCONN 128
  204. #define MSG_OOB 1
  205. #define MSG_PEEK 2
  206. #define MSG_DONTROUTE 4
  207. #define MSG_TRYHARD 4
  208. #define MSG_CTRUNC 8
  209. #define MSG_PROBE 0x10
  210. #define MSG_TRUNC 0x20
  211. #define MSG_DONTWAIT 0x40
  212. #define MSG_EOR 0x80
  213. #define MSG_WAITALL 0x100
  214. #define MSG_FIN 0x200
  215. #define MSG_SYN 0x400
  216. #define MSG_CONFIRM 0x800
  217. #define MSG_RST 0x1000
  218. #define MSG_ERRQUEUE 0x2000
  219. #define MSG_NOSIGNAL 0x4000
  220. #define MSG_MORE 0x8000
  221. #define MSG_EOF MSG_FIN
  222. #define MSG_CMSG_COMPAT 0
  223. #define SOL_IP 0
  224. #define SOL_TCP 6
  225. #define SOL_UDP 17
  226. #define SOL_IPV6 41
  227. #define SOL_ICMPV6 58
  228. #define SOL_SCTP 132
  229. #define SOL_RAW 255
  230. #define SOL_IPX 256
  231. #define SOL_AX25 257
  232. #define SOL_ATALK 258
  233. #define SOL_NETROM 259
  234. #define SOL_ROSE 260
  235. #define SOL_DECNET 261
  236. #define SOL_X25 262
  237. #define SOL_PACKET 263
  238. #define SOL_ATM 264
  239. #define SOL_AAL 265
  240. #define SOL_IRDA 266
  241. #define SOL_NETBEUI 267
  242. #define SOL_LLC 268
  243. #define SOL_DCCP 269
  244. #define SOL_NETLINK 270
  245. #define SOL_TIPC 271
  246. #define IPX_TYPE 1
  247. #ifdef __i386__
  248. # define __socketcall extern __attribute__((__cdecl__))
  249. #else
  250. # define __socketcall extern
  251. #endif
  252. __socketcall int socket(int, int, int);
  253. __socketcall int bind(int, const struct sockaddr *, int);
  254. __socketcall int connect(int, const struct sockaddr *, socklen_t);
  255. __socketcall int listen(int, int);
  256. __socketcall int accept(int, struct sockaddr *, socklen_t *);
  257. __socketcall int getsockname(int, struct sockaddr *, socklen_t *);
  258. __socketcall int getpeername(int, struct sockaddr *, socklen_t *);
  259. __socketcall int socketpair(int, int, int, int *);
  260. __socketcall int shutdown(int, int);
  261. __socketcall int setsockopt(int, int, int, const void *, socklen_t);
  262. __socketcall int getsockopt(int, int, int, void *, socklen_t *);
  263. __socketcall int sendmsg(int, const struct msghdr *, unsigned int);
  264. __socketcall int recvmsg(int, struct msghdr *, unsigned int);
  265. extern ssize_t send(int, const void *, size_t, unsigned int);
  266. extern ssize_t recv(int, void *, size_t, unsigned int);
  267. __socketcall ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
  268. __socketcall ssize_t recvfrom(int, void *, size_t, unsigned int, const struct sockaddr *, socklen_t *);
  269. #undef __socketcall
  270. __END_DECLS
  271. #endif /* _SYS_SOCKET_H */