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