socket.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. #if defined(TARGET_MIPS)
  2. /* MIPS special values for constants */
  3. /*
  4. * For setsockopt(2)
  5. *
  6. * This defines are ABI conformant as far as Linux supports these ...
  7. */
  8. #define TARGET_SOL_SOCKET 0xffff
  9. #define TARGET_SO_DEBUG 0x0001 /* Record debugging information. */
  10. #define TARGET_SO_REUSEADDR 0x0004 /* Allow reuse of local addresses. */
  11. #define TARGET_SO_KEEPALIVE 0x0008 /* Keep connections alive and send
  12. SIGPIPE when they die. */
  13. #define TARGET_SO_DONTROUTE 0x0010 /* Don't do local routing. */
  14. #define TARGET_SO_BROADCAST 0x0020 /* Allow transmission of
  15. broadcast messages. */
  16. #define TARGET_SO_LINGER 0x0080 /* Block on close of a reliable
  17. * socket to transmit pending data.
  18. */
  19. #define TARGET_SO_OOBINLINE 0x0100 /* Receive out-of-band data in-band.
  20. */
  21. #if 0
  22. /* To add: Allow local address and port reuse. */
  23. #define TARGET_SO_REUSEPORT 0x0200
  24. #endif
  25. #define TARGET_SO_TYPE 0x1008 /* Compatible name for SO_STYLE. */
  26. #define TARGET_SO_STYLE SO_TYPE /* Synonym */
  27. #define TARGET_SO_ERROR 0x1007 /* get error status and clear */
  28. #define TARGET_SO_SNDBUF 0x1001 /* Send buffer size. */
  29. #define TARGET_SO_RCVBUF 0x1002 /* Receive buffer. */
  30. #define TARGET_SO_SNDLOWAT 0x1003 /* send low-water mark */
  31. #define TARGET_SO_RCVLOWAT 0x1004 /* receive low-water mark */
  32. #define TARGET_SO_SNDTIMEO 0x1005 /* send timeout */
  33. #define TARGET_SO_RCVTIMEO 0x1006 /* receive timeout */
  34. #define TARGET_SO_ACCEPTCONN 0x1009
  35. /* linux-specific, might as well be the same as on i386 */
  36. #define TARGET_SO_NO_CHECK 11
  37. #define TARGET_SO_PRIORITY 12
  38. #define TARGET_SO_BSDCOMPAT 14
  39. #define TARGET_SO_PASSCRED 17
  40. #define TARGET_SO_PEERCRED 18
  41. /* Security levels - as per NRL IPv6 - don't actually do anything */
  42. #define TARGET_SO_SECURITY_AUTHENTICATION 22
  43. #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 23
  44. #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 24
  45. #define TARGET_SO_BINDTODEVICE 25
  46. /* Socket filtering */
  47. #define TARGET_SO_ATTACH_FILTER 26
  48. #define TARGET_SO_DETACH_FILTER 27
  49. #define TARGET_SO_PEERNAME 28
  50. #define TARGET_SO_TIMESTAMP 29
  51. #define SCM_TIMESTAMP SO_TIMESTAMP
  52. #define TARGET_SO_PEERSEC 30
  53. #define TARGET_SO_SNDBUFFORCE 31
  54. #define TARGET_SO_RCVBUFFORCE 33
  55. #define TARGET_SO_PASSSEC 34
  56. /** sock_type - Socket types
  57. *
  58. * Please notice that for binary compat reasons MIPS has to
  59. * override the enum sock_type in include/linux/net.h, so
  60. * we define ARCH_HAS_SOCKET_TYPES here.
  61. *
  62. * @SOCK_DGRAM - datagram (conn.less) socket
  63. * @SOCK_STREAM - stream (connection) socket
  64. * @SOCK_RAW - raw socket
  65. * @SOCK_RDM - reliably-delivered message
  66. * @SOCK_SEQPACKET - sequential packet socket
  67. * @SOCK_DCCP - Datagram Congestion Control Protocol socket
  68. * @SOCK_PACKET - linux specific way of getting packets at the dev level.
  69. * For writing rarp and other similar things on the user
  70. * level.
  71. * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
  72. * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
  73. */
  74. #define ARCH_HAS_SOCKET_TYPES 1
  75. enum sock_type {
  76. TARGET_SOCK_DGRAM = 1,
  77. TARGET_SOCK_STREAM = 2,
  78. TARGET_SOCK_RAW = 3,
  79. TARGET_SOCK_RDM = 4,
  80. TARGET_SOCK_SEQPACKET = 5,
  81. TARGET_SOCK_DCCP = 6,
  82. TARGET_SOCK_PACKET = 10,
  83. TARGET_SOCK_CLOEXEC = 02000000,
  84. TARGET_SOCK_NONBLOCK = 0200,
  85. };
  86. #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
  87. #define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX-1. */
  88. #elif defined(TARGET_ALPHA)
  89. /* For setsockopt(2) */
  90. #define TARGET_SOL_SOCKET 0xffff
  91. #define TARGET_SO_DEBUG 0x0001
  92. #define TARGET_SO_REUSEADDR 0x0004
  93. #define TARGET_SO_KEEPALIVE 0x0008
  94. #define TARGET_SO_DONTROUTE 0x0010
  95. #define TARGET_SO_BROADCAST 0x0020
  96. #define TARGET_SO_LINGER 0x0080
  97. #define TARGET_SO_OOBINLINE 0x0100
  98. /* To add :#define TARGET_SO_REUSEPORT 0x0200 */
  99. #define TARGET_SO_TYPE 0x1008
  100. #define TARGET_SO_ERROR 0x1007
  101. #define TARGET_SO_SNDBUF 0x1001
  102. #define TARGET_SO_RCVBUF 0x1002
  103. #define TARGET_SO_SNDBUFFORCE 0x100a
  104. #define TARGET_SO_RCVBUFFORCE 0x100b
  105. #define TARGET_SO_RCVLOWAT 0x1010
  106. #define TARGET_SO_SNDLOWAT 0x1011
  107. #define TARGET_SO_RCVTIMEO 0x1012
  108. #define TARGET_SO_SNDTIMEO 0x1013
  109. #define TARGET_SO_ACCEPTCONN 0x1014
  110. #define TARGET_SO_PROTOCOL 0x1028
  111. #define TARGET_SO_DOMAIN 0x1029
  112. /* linux-specific, might as well be the same as on i386 */
  113. #define TARGET_SO_NO_CHECK 11
  114. #define TARGET_SO_PRIORITY 12
  115. #define TARGET_SO_BSDCOMPAT 14
  116. #define TARGET_SO_PASSCRED 17
  117. #define TARGET_SO_PEERCRED 18
  118. #define TARGET_SO_BINDTODEVICE 25
  119. /* Socket filtering */
  120. #define TARGET_SO_ATTACH_FILTER 26
  121. #define TARGET_SO_DETACH_FILTER 27
  122. #define TARGET_SO_PEERNAME 28
  123. #define TARGET_SO_TIMESTAMP 29
  124. #define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP
  125. #define TARGET_SO_PEERSEC 30
  126. #define TARGET_SO_PASSSEC 34
  127. #define TARGET_SO_TIMESTAMPNS 35
  128. #define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS
  129. /* Security levels - as per NRL IPv6 - don't actually do anything */
  130. #define TARGET_SO_SECURITY_AUTHENTICATION 19
  131. #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 20
  132. #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 21
  133. #define TARGET_SO_MARK 36
  134. #define TARGET_SO_TIMESTAMPING 37
  135. #define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING
  136. #define TARGET_SO_RXQ_OVFL 40
  137. #define TARGET_SO_WIFI_STATUS 41
  138. #define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS
  139. #define TARGET_SO_PEEK_OFF 42
  140. /* Instruct lower device to use last 4-bytes of skb data as FCS */
  141. #define TARGET_SO_NOFCS 43
  142. /** sock_type - Socket types
  143. *
  144. * Please notice that for binary compat reasons ALPHA has to
  145. * override the enum sock_type in include/linux/net.h, so
  146. * we define ARCH_HAS_SOCKET_TYPES here.
  147. *
  148. * @SOCK_DGRAM - datagram (conn.less) socket
  149. * @SOCK_STREAM - stream (connection) socket
  150. * @SOCK_RAW - raw socket
  151. * @SOCK_RDM - reliably-delivered message
  152. * @SOCK_SEQPACKET - sequential packet socket
  153. * @SOCK_DCCP - Datagram Congestion Control Protocol socket
  154. * @SOCK_PACKET - linux specific way of getting packets at the dev level.
  155. * For writing rarp and other similar things on the user
  156. * level.
  157. * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
  158. * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
  159. */
  160. #define ARCH_HAS_SOCKET_TYPES 1
  161. enum sock_type {
  162. TARGET_SOCK_STREAM = 1,
  163. TARGET_SOCK_DGRAM = 2,
  164. TARGET_SOCK_RAW = 3,
  165. TARGET_SOCK_RDM = 4,
  166. TARGET_SOCK_SEQPACKET = 5,
  167. TARGET_SOCK_DCCP = 6,
  168. TARGET_SOCK_PACKET = 10,
  169. TARGET_SOCK_CLOEXEC = 010000000,
  170. TARGET_SOCK_NONBLOCK = 010000000000,
  171. };
  172. #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
  173. #define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX-1. */
  174. #else
  175. #if defined(TARGET_SPARC)
  176. /** sock_type - Socket types
  177. *
  178. * Please notice that for binary compat reasons SPARC has to
  179. * override the enum sock_type in include/linux/net.h, so
  180. * we define ARCH_HAS_SOCKET_TYPES here.
  181. *
  182. * @SOCK_DGRAM - datagram (conn.less) socket
  183. * @SOCK_STREAM - stream (connection) socket
  184. * @SOCK_RAW - raw socket
  185. * @SOCK_RDM - reliably-delivered message
  186. * @SOCK_SEQPACKET - sequential packet socket
  187. * @SOCK_DCCP - Datagram Congestion Control Protocol socket
  188. * @SOCK_PACKET - linux specific way of getting packets at the dev level.
  189. * For writing rarp and other similar things on the user
  190. * level.
  191. * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
  192. * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
  193. */
  194. #define ARCH_HAS_SOCKET_TYPES 1
  195. enum sock_type {
  196. TARGET_SOCK_STREAM = 1,
  197. TARGET_SOCK_DGRAM = 2,
  198. TARGET_SOCK_RAW = 3,
  199. TARGET_SOCK_RDM = 4,
  200. TARGET_SOCK_SEQPACKET = 5,
  201. TARGET_SOCK_DCCP = 6,
  202. TARGET_SOCK_PACKET = 10,
  203. TARGET_SOCK_CLOEXEC = 020000000,
  204. TARGET_SOCK_NONBLOCK = 040000,
  205. };
  206. #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
  207. #define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX-1. */
  208. #define TARGET_SO_PASSSEC 31
  209. #else
  210. #define TARGET_SO_PASSSEC 34
  211. #endif
  212. /* For setsockopt(2) */
  213. #define TARGET_SOL_SOCKET 1
  214. #define TARGET_SO_DEBUG 1
  215. #define TARGET_SO_REUSEADDR 2
  216. #define TARGET_SO_TYPE 3
  217. #define TARGET_SO_ERROR 4
  218. #define TARGET_SO_DONTROUTE 5
  219. #define TARGET_SO_BROADCAST 6
  220. #define TARGET_SO_SNDBUF 7
  221. #define TARGET_SO_RCVBUF 8
  222. #define TARGET_SO_SNDBUFFORCE 32
  223. #define TARGET_SO_RCVBUFFORCE 33
  224. #define TARGET_SO_KEEPALIVE 9
  225. #define TARGET_SO_OOBINLINE 10
  226. #define TARGET_SO_NO_CHECK 11
  227. #define TARGET_SO_PRIORITY 12
  228. #define TARGET_SO_LINGER 13
  229. #define TARGET_SO_BSDCOMPAT 14
  230. /* To add :#define TARGET_SO_REUSEPORT 15 */
  231. #if defined(TARGET_PPC)
  232. #define TARGET_SO_RCVLOWAT 16
  233. #define TARGET_SO_SNDLOWAT 17
  234. #define TARGET_SO_RCVTIMEO 18
  235. #define TARGET_SO_SNDTIMEO 19
  236. #define TARGET_SO_PASSCRED 20
  237. #define TARGET_SO_PEERCRED 21
  238. #else
  239. #define TARGET_SO_PASSCRED 16
  240. #define TARGET_SO_PEERCRED 17
  241. #define TARGET_SO_RCVLOWAT 18
  242. #define TARGET_SO_SNDLOWAT 19
  243. #define TARGET_SO_RCVTIMEO 20
  244. #define TARGET_SO_SNDTIMEO 21
  245. #endif
  246. /* Security levels - as per NRL IPv6 - don't actually do anything */
  247. #define TARGET_SO_SECURITY_AUTHENTICATION 22
  248. #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 23
  249. #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 24
  250. #define TARGET_SO_BINDTODEVICE 25
  251. /* Socket filtering */
  252. #define TARGET_SO_ATTACH_FILTER 26
  253. #define TARGET_SO_DETACH_FILTER 27
  254. #define TARGET_SO_PEERNAME 28
  255. #define TARGET_SO_TIMESTAMP 29
  256. #define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP
  257. #define TARGET_SO_ACCEPTCONN 30
  258. #define TARGET_SO_PEERSEC 31
  259. #endif
  260. #ifndef ARCH_HAS_SOCKET_TYPES
  261. /** sock_type - Socket types - default values
  262. *
  263. *
  264. * @SOCK_STREAM - stream (connection) socket
  265. * @SOCK_DGRAM - datagram (conn.less) socket
  266. * @SOCK_RAW - raw socket
  267. * @SOCK_RDM - reliably-delivered message
  268. * @SOCK_SEQPACKET - sequential packet socket
  269. * @SOCK_DCCP - Datagram Congestion Control Protocol socket
  270. * @SOCK_PACKET - linux specific way of getting packets at the dev level.
  271. * For writing rarp and other similar things on the user
  272. * level.
  273. * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
  274. * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
  275. */
  276. enum sock_type {
  277. TARGET_SOCK_STREAM = 1,
  278. TARGET_SOCK_DGRAM = 2,
  279. TARGET_SOCK_RAW = 3,
  280. TARGET_SOCK_RDM = 4,
  281. TARGET_SOCK_SEQPACKET = 5,
  282. TARGET_SOCK_DCCP = 6,
  283. TARGET_SOCK_PACKET = 10,
  284. TARGET_SOCK_CLOEXEC = 02000000,
  285. TARGET_SOCK_NONBLOCK = 04000,
  286. };
  287. #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
  288. #define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX-1. */
  289. #endif