2
0

socket.h 12 KB

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