socket.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. struct msghdr
  2. {
  3. void *msg_name;
  4. socklen_t msg_namelen;
  5. struct iovec *msg_iov;
  6. int msg_iovlen;
  7. void *msg_control;
  8. socklen_t msg_controllen;
  9. int msg_flags;
  10. };
  11. struct cmsghdr
  12. {
  13. socklen_t cmsg_len;
  14. int cmsg_level;
  15. int cmsg_type;
  16. };
  17. struct ucred
  18. {
  19. pid_t pid;
  20. uid_t uid;
  21. gid_t gid;
  22. };
  23. struct linger
  24. {
  25. int l_onoff;
  26. int l_linger;
  27. };
  28. #define SHUT_RD 0
  29. #define SHUT_WD 1
  30. #define SHUT_RDWR 2
  31. #define SOCK_STREAM 1
  32. #define SOCK_DGRAM 2
  33. #define SOCK_RAW 3
  34. #define SOCK_RDM 4
  35. #define SOCK_SEQPACKET 5
  36. #define SOCK_DCCP 6
  37. #define SOCK_PACKET 10
  38. /* linux extensions */
  39. #define SOCK_CLOEXEC 02000000
  40. #define SOCK_NONBLOCK 04000
  41. #define PF_UNSPEC 0
  42. #define PF_LOCAL 1
  43. #define PF_UNIX PF_LOCAL
  44. #define PF_FILE PF_LOCAL
  45. #define PF_INET 2
  46. #define PF_AX25 3
  47. #define PF_IPX 4
  48. #define PF_APPLETALK 5
  49. #define PF_NETROM 6
  50. #define PF_BRIDGE 7
  51. #define PF_ATMPVC 8
  52. #define PF_X25 9
  53. #define PF_INET6 10
  54. #define PF_ROSE 11
  55. #define PF_DECnet 12
  56. #define PF_NETBEUI 13
  57. #define PF_SECURITY 14
  58. #define PF_KEY 15
  59. #define PF_NETLINK 16
  60. #define PF_ROUTE PF_NETLINK
  61. #define PF_PACKET 17
  62. #define PF_ASH 18
  63. #define PF_ECONET 19
  64. #define PF_ATMSVC 20
  65. #define PF_SNA 22
  66. #define PF_IRDA 23
  67. #define PF_PPPOX 24
  68. #define PF_WANPIPE 25
  69. #define PF_BLUETOOTH 31
  70. #define PF_IUCV 32
  71. #define PF_RXRPC 33
  72. #define PF_ISDN 34
  73. #define PF_PHONET 35
  74. #define PF_IEEE802154 36
  75. #define PF_CAIF 37
  76. #define PF_ALG 38
  77. #define PF_MAX 39
  78. #define AF_UNSPEC PF_UNSPEC
  79. #define AF_LOCAL PF_LOCAL
  80. #define AF_UNIX AF_LOCAL
  81. #define AF_FILE AF_LOCAL
  82. #define AF_INET PF_INET
  83. #define AF_AX25 PF_AX25
  84. #define AF_IPX PF_IPX
  85. #define AF_APPLETALK PF_APPLETALK
  86. #define AF_NETROM PF_NETROM
  87. #define AF_BRIDGE PF_BRIDGE
  88. #define AF_ATMPVC PF_ATMPVC
  89. #define AF_X25 PF_X25
  90. #define AF_INET6 PF_INET6
  91. #define AF_ROSE PF_ROSE
  92. #define AF_DECnet PF_DECnet
  93. #define AF_NETBEUI PF_NETBEUI
  94. #define AF_SECURITY PF_SECURITY
  95. #define AF_KEY PF_KEY
  96. #define AF_NETLINK PF_NETLINK
  97. #define AF_ROUTE AF_NETLINK
  98. #define AF_PACKET PF_PACKET
  99. #define AF_ASH PF_ASH
  100. #define AF_ECONET PF_ECONET
  101. #define AF_ATMSVC PF_ATMSVC
  102. #define AF_SNA PF_SNA
  103. #define AF_IRDA PF_IRDA
  104. #define AF_PPPOX PF_PPPOX
  105. #define AF_WANPIPE PF_WANPIPE
  106. #define AF_BLUETOOTH PF_BLUETOOTH
  107. #define AF_IUCV PF_IUCV
  108. #define AF_RXRPC PF_RXRPC
  109. #define AF_ISDN PF_ISDN
  110. #define AF_PHONET PF_PHONET
  111. #define AF_IEEE802154 PF_IEEE802154
  112. #define AF_CAIF PF_CAIF
  113. #define AF_ALG PF_ALG
  114. #define AF_MAX PF_MAX
  115. #define SO_DEBUG 1
  116. #define SO_REUSEADDR 2
  117. #define SO_TYPE 3
  118. #define SO_ERROR 4
  119. #define SO_DONTROUTE 5
  120. #define SO_BROADCAST 6
  121. #define SO_SNDBUF 7
  122. #define SO_RCVBUF 8
  123. #define SO_KEEPALIVE 9
  124. #define SO_OOBINLINE 10
  125. #define SO_NO_CHECK 11
  126. #define SO_PRIORITY 12
  127. #define SO_LINGER 13
  128. #define SO_BSDCOMPAT 14
  129. #define SO_REUSEPORT 15
  130. #define SO_PASSCRED 16
  131. #define SO_PEERCRED 17
  132. #define SO_RCVLOWAT 18
  133. #define SO_SNDLOWAT 19
  134. #define SO_RCVTIMEO 20
  135. #define SO_SNDTIMEO 21
  136. #define SO_SECURITY_AUTHENTICATION 22
  137. #define SO_SECURITY_ENCRYPTION_TRANSPORT 23
  138. #define SO_SECURITY_ENCRYPTION_NETWORK 24
  139. #define SO_BINDTODEVICE 25
  140. #define SO_ATTACH_FILTER 26
  141. #define SO_DETACH_FILTER 27
  142. #define SO_PEERNAME 28
  143. #define SO_TIMESTAMP 29
  144. #define SCM_TIMESTAMP SO_TIMESTAMP
  145. #define SO_ACCEPTCONN 30
  146. #define SOL_SOCKET 1
  147. /* ??? */
  148. #define SOL_RAW 255
  149. #define SOL_DECNET 261
  150. #define SOL_X25 262
  151. #define SOL_PACKET 263
  152. #define SOL_ATM 264
  153. #define SOL_AAL 265
  154. #define SOL_IRDA 266
  155. #define SOMAXCONN 128
  156. #define MSG_OOB 0x0001
  157. #define MSG_PEEK 0x0002
  158. #define MSG_DONTROUTE 0x0004
  159. #define MSG_CTRUNC 0x0008
  160. #define MSG_PROXY 0x0010
  161. #define MSG_TRUNC 0x0020
  162. #define MSG_DONTWAIT 0x0040
  163. #define MSG_EOR 0x0080
  164. #define MSG_WAITALL 0x0100
  165. #define MSG_FIN 0x0200
  166. #define MSD_SYN 0x0400
  167. #define MSG_CONFIRM 0x0800
  168. #define MSG_RST 0x1000
  169. #define MSG_ERRQUEUE 0x2000
  170. #define MSG_NOSIGNAL 0x4000
  171. #define MSG_MORE 0x8000
  172. #define MSG_WAITFORONE 0x10000
  173. #define MSG_CMSG_CLOEXEC 0x40000000
  174. /* Internal use only!! to make CMSG_NXTHDR definition readable by mortals */
  175. #define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
  176. #define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
  177. #define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
  178. #define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
  179. #define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) ? (struct cmsghdr *)0 : \
  180. (__CMSG_NEXT(cmsg) + sizeof (struct cmsghdr) >= __MHDR_END(mhdr) ? (struct cmsghdr *)0 : \
  181. ((struct cmsghdr *)__CMSG_NEXT(cmsg))))
  182. #define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
  183. #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
  184. #define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
  185. #define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
  186. #define SCM_RIGHTS 0x01
  187. #define SCM_CREDENTIALS 0x02