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