Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 1 | #ifndef _SYS_SOCKET_H |
2 | #define _SYS_SOCKET_H |
||
3 | |||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
8 | __BEGIN_DECLS |
||
9 | |||
10 | #define SOL_SOCKET 1 |
||
11 | |||
12 | #define SO_DEBUG 1 |
||
13 | #define SO_REUSEADDR 2 |
||
14 | #define SO_TYPE 3 |
||
15 | #define SO_ERROR 4 |
||
16 | #define SO_DONTROUTE 5 |
||
17 | #define SO_BROADCAST 6 |
||
18 | #define SO_SNDBUF 7 |
||
19 | #define SO_RCVBUF 8 |
||
20 | #define SO_KEEPALIVE 9 |
||
21 | #define SO_OOBINLINE 10 |
||
22 | #define SO_NO_CHECK 11 |
||
23 | #define SO_PRIORITY 12 |
||
24 | #define SO_LINGER 13 |
||
25 | #define SO_BSDCOMPAT 14 |
||
26 | /* To add :#define SO_REUSEPORT 15 */ |
||
27 | #define SO_PASSCRED 16 |
||
28 | #define SO_PEERCRED 17 |
||
29 | #define SO_RCVLOWAT 18 |
||
30 | #define SO_SNDLOWAT 19 |
||
31 | #define SO_RCVTIMEO 20 |
||
32 | #define SO_SNDTIMEO 21 |
||
33 | #define SO_ACCEPTCONN 30 |
||
34 | |||
35 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
||
36 | #define SO_SECURITY_AUTHENTICATION 22 |
||
37 | #define SO_SECURITY_ENCRYPTION_TRANSPORT 23 |
||
38 | #define SO_SECURITY_ENCRYPTION_NETWORK 24 |
||
39 | |||
40 | #define SO_BINDTODEVICE 25 |
||
41 | |||
42 | /* Socket filtering */ |
||
43 | #define SO_ATTACH_FILTER 26 |
||
44 | #define SO_DETACH_FILTER 27 |
||
45 | |||
46 | #define SO_PEERNAME 28 |
||
47 | #define SO_TIMESTAMP 29 |
||
48 | #define SCM_TIMESTAMP SO_TIMESTAMP |
||
49 | |||
50 | /* Socket types. */ |
||
51 | #define SOCK_STREAM 1 /* stream (connection) socket */ |
||
52 | #define SOCK_DGRAM 2 /* datagram (conn.less) socket */ |
||
53 | #define SOCK_RAW 3 /* raw socket */ |
||
54 | #define SOCK_RDM 4 /* reliably-delivered message */ |
||
55 | #define SOCK_SEQPACKET 5 /* sequential packet socket */ |
||
56 | #define SOCK_PACKET 10 /* linux specific way of */ |
||
57 | /* getting packets at the dev */ |
||
58 | /* level. For writing rarp and */ |
||
59 | /* other similar things on the */ |
||
60 | /* user level. */ |
||
61 | |||
62 | struct sockaddr { |
||
63 | sa_family_t sa_family; |
||
64 | char sa_data[14]; |
||
65 | }; |
||
66 | |||
67 | struct linger { |
||
68 | int l_onoff; |
||
69 | int l_linger; |
||
70 | }; |
||
71 | |||
72 | struct iovec { |
||
73 | void* iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ |
||
74 | size_t iov_len; /* Must be size_t (1003.1g) */ |
||
75 | }; |
||
76 | |||
77 | struct msghdr { |
||
78 | void* msg_name; /* Socket name */ |
||
79 | int msg_namelen; /* Length of name */ |
||
80 | struct iovec* msg_iov; /* Data blocks */ |
||
81 | size_t msg_iovlen; /* Number of blocks */ |
||
82 | void* msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ |
||
83 | size_t msg_controllen; /* Length of cmsg list */ |
||
84 | unsigned msg_flags; |
||
85 | }; |
||
86 | |||
87 | struct cmsghdr { |
||
88 | size_t cmsg_len; /* data byte count, including hdr */ |
||
89 | int cmsg_level; /* originating protocol */ |
||
90 | int cmsg_type; /* protocol-specific type */ |
||
91 | }; |
||
92 | |||
93 | #define UIO_FASTIOV 8 |
||
94 | #define UIO_MAXIOV 1024 |
||
95 | |||
96 | /* "Socket"-level control message types: */ |
||
97 | |||
98 | #define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ |
||
99 | #define SCM_CREDENTIALS 0x02 /* rw: struct ucred */ |
||
100 | #define SCM_CONNECT 0x03 /* rw: struct scm_connect */ |
||
101 | |||
102 | struct ucred { |
||
103 | unsigned int pid; |
||
104 | unsigned int uid; |
||
105 | unsigned int gid; |
||
106 | }; |
||
107 | |||
108 | /* Supported address families. */ |
||
109 | #define AF_UNSPEC 0 |
||
110 | #define AF_UNIX 1 /* Unix domain sockets */ |
||
111 | #define AF_LOCAL 1 /* POSIX name for AF_UNIX */ |
||
112 | #define AF_INET 2 /* Internet IP Protocol */ |
||
113 | #define AF_AX25 3 /* Amateur Radio AX.25 */ |
||
114 | #define AF_IPX 4 /* Novell IPX */ |
||
115 | #define AF_APPLETALK 5 /* AppleTalk DDP */ |
||
116 | #define AF_NETROM 6 /* Amateur Radio NET/ROM */ |
||
117 | #define AF_BRIDGE 7 /* Multiprotocol bridge */ |
||
118 | #define AF_ATMPVC 8 /* ATM PVCs */ |
||
119 | #define AF_X25 9 /* Reserved for X.25 project */ |
||
120 | #define AF_INET6 10 /* IP version 6 */ |
||
121 | #define AF_ROSE 11 /* Amateur Radio X.25 PLP */ |
||
122 | #define AF_DECnet 12 /* Reserved for DECnet project */ |
||
123 | #define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ |
||
124 | #define AF_SECURITY 14 /* Security callback pseudo AF */ |
||
125 | #define AF_KEY 15 /* PF_KEY key management API */ |
||
126 | #define AF_NETLINK 16 |
||
127 | #define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ |
||
128 | #define AF_PACKET 17 /* Packet family */ |
||
129 | #define AF_ASH 18 /* Ash */ |
||
130 | #define AF_ECONET 19 /* Acorn Econet */ |
||
131 | #define AF_ATMSVC 20 /* ATM SVCs */ |
||
132 | #define AF_SNA 22 /* Linux SNA Project (nutters!) */ |
||
133 | #define AF_IRDA 23 /* IRDA sockets */ |
||
134 | #define AF_PPPOX 24 /* PPPoX sockets */ |
||
135 | #define AF_WANPIPE 25 /* Wanpipe API Sockets */ |
||
136 | #define AF_MAX 32 /* For now.. */ |
||
137 | |||
138 | /* Protocol families, same as address families. */ |
||
139 | #define PF_UNSPEC AF_UNSPEC |
||
140 | #define PF_UNIX AF_UNIX |
||
141 | #define PF_LOCAL AF_LOCAL |
||
142 | #define PF_INET AF_INET |
||
143 | #define PF_AX25 AF_AX25 |
||
144 | #define PF_IPX AF_IPX |
||
145 | #define PF_APPLETALK AF_APPLETALK |
||
146 | #define PF_NETROM AF_NETROM |
||
147 | #define PF_BRIDGE AF_BRIDGE |
||
148 | #define PF_ATMPVC AF_ATMPVC |
||
149 | #define PF_X25 AF_X25 |
||
150 | #define PF_INET6 AF_INET6 |
||
151 | #define PF_ROSE AF_ROSE |
||
152 | #define PF_DECnet AF_DECnet |
||
153 | #define PF_NETBEUI AF_NETBEUI |
||
154 | #define PF_SECURITY AF_SECURITY |
||
155 | #define PF_KEY AF_KEY |
||
156 | #define PF_NETLINK AF_NETLINK |
||
157 | #define PF_ROUTE AF_ROUTE |
||
158 | #define PF_PACKET AF_PACKET |
||
159 | #define PF_ASH AF_ASH |
||
160 | #define PF_ECONET AF_ECONET |
||
161 | #define PF_ATMSVC AF_ATMSVC |
||
162 | #define PF_SNA AF_SNA |
||
163 | #define PF_IRDA AF_IRDA |
||
164 | #define PF_PPPOX AF_PPPOX |
||
165 | #define PF_WANPIPE AF_WANPIPE |
||
166 | #define PF_MAX AF_MAX |
||
167 | |||
168 | /* Maximum queue length specifiable by listen. */ |
||
169 | #define SOMAXCONN 128 |
||
170 | |||
171 | /* Flags we can use with send/ and recv. |
||
172 | Added those for 1003.1g not all are supported yet */ |
||
173 | #define MSG_OOB 1 |
||
174 | #define MSG_PEEK 2 |
||
175 | #define MSG_DONTROUTE 4 |
||
176 | #define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ |
||
177 | #define MSG_CTRUNC 8 |
||
178 | #define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ |
||
179 | #define MSG_TRUNC 0x20 |
||
180 | #define MSG_DONTWAIT 0x40 /* Nonblocking io */ |
||
181 | #define MSG_EOR 0x80 /* End of record */ |
||
182 | #define MSG_WAITALL 0x100 /* Wait for a full request */ |
||
183 | #define MSG_FIN 0x200 |
||
184 | #define MSG_EOF MSG_FIN |
||
185 | #define MSG_SYN 0x400 |
||
186 | #define MSG_CONFIRM 0x800 /* Confirm path validity */ |
||
187 | #define MSG_RST 0x1000 |
||
188 | #define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ |
||
189 | #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ |
||
190 | #define MSG_MORE 0x8000 /* Sender will send more */ |
||
191 | |||
192 | /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ |
||
193 | #define SOL_IP 0 |
||
194 | /* #define SOL_ICMP 1 No-no-no! Due to Linux :-) we cannot use SOL_ICMP=1 */ |
||
195 | #define SOL_TCP 6 |
||
196 | #define SOL_UDP 17 |
||
197 | #define SOL_IPV6 41 |
||
198 | #define SOL_ICMPV6 58 |
||
199 | #define SOL_RAW 255 |
||
200 | #define SOL_IPX 256 |
||
201 | #define SOL_AX25 257 |
||
202 | #define SOL_ATALK 258 |
||
203 | #define SOL_NETROM 259 |
||
204 | #define SOL_ROSE 260 |
||
205 | #define SOL_DECNET 261 |
||
206 | #define SOL_X25 262 |
||
207 | #define SOL_PACKET 263 |
||
208 | #define SOL_ATM 264 /* ATM layer (cell level) */ |
||
209 | #define SOL_AAL 265 /* ATM Adaption Layer (packet level) */ |
||
210 | #define SOL_IRDA 266 |
||
211 | |||
212 | /* IPX options */ |
||
213 | #define IPX_TYPE 1 |
||
214 | |||
215 | #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) |
||
216 | #define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg)) |
||
217 | #define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg)) |
||
218 | |||
219 | static inline struct cmsghdr* __cmsg_nxthdr(void *__ctl, size_t __size, struct cmsghdr *__cmsg) |
||
220 | { |
||
221 | struct cmsghdr * __ptr; |
||
222 | __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); |
||
223 | if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) |
||
224 | return (struct cmsghdr *)0; |
||
225 | return __ptr; |
||
226 | } |
||
227 | |||
228 | static inline struct cmsghdr* cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg) |
||
229 | { |
||
230 | return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); |
||
231 | } |
||
232 | |||
233 | #define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))) |
||
234 | #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len)) |
||
235 | #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) |
||
236 | |||
237 | #define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? \ |
||
238 | (struct cmsghdr *)(ctl) : \ |
||
239 | (struct cmsghdr *)NULL) |
||
240 | #define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) |
||
241 | |||
242 | struct sockaddr_storage { |
||
243 | sa_family_t ss_family; |
||
244 | uint32_t __ss_align; |
||
245 | char __ss_padding[(128 - (2 * sizeof (uint32_t ))) ]; |
||
246 | }; |
||
247 | |||
248 | #ifndef SOCK_DGRAM |
||
249 | /* the Linux kernel headers suck really badly on non-x86 */ |
||
250 | #define SOCK_STREAM 1 /* stream (connection) socket */ |
||
251 | #define SOCK_DGRAM 2 /* datagram (conn.less) socket */ |
||
252 | #define SOCK_RAW 3 /* raw socket */ |
||
253 | #define SOCK_RDM 4 /* reliably-delivered message */ |
||
254 | #define SOCK_SEQPACKET 5 /* sequential packet socket */ |
||
255 | #define SOCK_PACKET 10 /* linux specific way of */ |
||
256 | #endif |
||
257 | |||
258 | int socket(int domain, int type, int protocol) ; |
||
259 | int accept(int s, struct sockaddr *addr, socklen_t *addrlen) ; |
||
260 | int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) ; |
||
261 | int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen) ; |
||
262 | int recv(int s, void *buf, size_t len, int flags) ; |
||
263 | int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) ; |
||
264 | int recvmsg(int s, struct msghdr *msg, int flags) ; |
||
265 | int send(int s, const void *msg, size_t len, int flags) ; |
||
266 | int sendto(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) ; |
||
267 | int sendmsg(int s, const struct msghdr *msg, int flags) ; |
||
268 | |||
269 | int getpeername(int s, struct sockaddr *name, socklen_t *namelen) ; |
||
270 | int getsockname(int s , struct sockaddr * name , socklen_t * namelen) ; |
||
271 | |||
272 | int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) ; |
||
273 | int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) ; |
||
274 | |||
275 | int listen(int s, int backlog) ; |
||
276 | |||
277 | #define SHUT_RD 0 |
||
278 | #define SHUT_WR 1 |
||
279 | #define SHUT_RDWR 2 |
||
280 | int shutdown(int s, int how) ; |
||
281 | |||
282 | int socketpair(int d, int type, int protocol, int sv[2]); |
||
283 | |||
284 | /* currently not supported: */ |
||
285 | #define NI_NOFQDN 1 |
||
286 | |||
287 | #define NI_NUMERICHOST 2 |
||
288 | #define NI_NAMEREQD 4 |
||
289 | #define NI_NUMERICSERV 8 |
||
290 | #define NI_DGRAM 16 |
||
291 | |||
292 | struct addrinfo { |
||
293 | int ai_flags; |
||
294 | int ai_family; |
||
295 | int ai_socktype; |
||
296 | int ai_protocol; |
||
297 | size_t ai_addrlen; |
||
298 | struct sockaddr *ai_addr; |
||
299 | char *ai_canonname; |
||
300 | struct addrinfo *ai_next; |
||
301 | }; |
||
302 | |||
303 | int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, |
||
304 | size_t hostlen, char *serv, size_t servlen, int flags) ; |
||
305 | int getaddrinfo(const char *node, const char *service, const struct |
||
306 | addrinfo *hints, struct addrinfo **res) ; |
||
307 | void freeaddrinfo(struct addrinfo *res) ; |
||
308 | const char *gai_strerror(int errcode) ; |
||
309 | |||
310 | #define EAI_FAMILY -1 |
||
311 | #define EAI_SOCKTYPE -2 |
||
312 | #define EAI_BADFLAGS -3 |
||
313 | #define EAI_NONAME -4 |
||
314 | #define EAI_SERVICE -5 |
||
315 | #define EAI_ADDRFAMILY -6 |
||
316 | #define EAI_NODATA -7 |
||
317 | #define EAI_MEMORY -8 |
||
318 | #define EAI_FAIL -9 |
||
319 | #define EAI_AGAIN -10 |
||
320 | #define EAI_SYSTEM -11 |
||
321 | |||
322 | #define AI_NUMERICHOST 1 |
||
323 | #define AI_CANONNAME 2 |
||
324 | #define AI_PASSIVE 4 |
||
325 | |||
326 | /* Linux-specific socket ioctls */ |
||
327 | #define SIOCINQ FIONREAD |
||
328 | #define SIOCOUTQ TIOCOUTQ |
||
329 | |||
330 | /* Routing table calls. */ |
||
331 | #define SIOCADDRT 0x890B /* add routing table entry */ |
||
332 | #define SIOCDELRT 0x890C /* delete routing table entry */ |
||
333 | #define SIOCRTMSG 0x890D /* call to routing system */ |
||
334 | |||
335 | /* Socket configuration controls. */ |
||
336 | #define SIOCGIFNAME 0x8910 /* get iface name */ |
||
337 | #define SIOCSIFLINK 0x8911 /* set iface channel */ |
||
338 | #define SIOCGIFCONF 0x8912 /* get iface list */ |
||
339 | #define SIOCGIFFLAGS 0x8913 /* get flags */ |
||
340 | #define SIOCSIFFLAGS 0x8914 /* set flags */ |
||
341 | #define SIOCGIFADDR 0x8915 /* get PA address */ |
||
342 | #define SIOCSIFADDR 0x8916 /* set PA address */ |
||
343 | #define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ |
||
344 | #define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ |
||
345 | #define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ |
||
346 | #define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ |
||
347 | #define SIOCGIFNETMASK 0x891b /* get network PA mask */ |
||
348 | #define SIOCSIFNETMASK 0x891c /* set network PA mask */ |
||
349 | #define SIOCGIFMETRIC 0x891d /* get metric */ |
||
350 | #define SIOCSIFMETRIC 0x891e /* set metric */ |
||
351 | #define SIOCGIFMEM 0x891f /* get memory address (BSD) */ |
||
352 | #define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ |
||
353 | #define SIOCGIFMTU 0x8921 /* get MTU size */ |
||
354 | #define SIOCSIFMTU 0x8922 /* set MTU size */ |
||
355 | #define SIOCSIFNAME 0x8923 /* set interface name */ |
||
356 | #define SIOCSIFHWADDR 0x8924 /* set hardware address */ |
||
357 | #define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ |
||
358 | #define SIOCSIFENCAP 0x8926 |
||
359 | #define SIOCGIFHWADDR 0x8927 /* Get hardware address */ |
||
360 | #define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ |
||
361 | #define SIOCSIFSLAVE 0x8930 |
||
362 | #define SIOCADDMULTI 0x8931 /* Multicast address lists */ |
||
363 | #define SIOCDELMULTI 0x8932 |
||
364 | #define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ |
||
365 | #define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ |
||
366 | #define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ |
||
367 | #define SIOCGIFPFLAGS 0x8935 |
||
368 | #define SIOCDIFADDR 0x8936 /* delete PA address */ |
||
369 | #define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ |
||
370 | #define SIOCGIFCOUNT 0x8938 /* get number of devices */ |
||
371 | |||
372 | #define SIOCGIFBR 0x8940 /* Bridging support */ |
||
373 | #define SIOCSIFBR 0x8941 /* Set bridging options */ |
||
374 | |||
375 | #define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ |
||
376 | #define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ |
||
377 | |||
378 | #define SIOCGIFDIVERT 0x8944 /* Frame diversion support */ |
||
379 | #define SIOCSIFDIVERT 0x8945 /* Set frame diversion options */ |
||
380 | |||
381 | #define SIOCETHTOOL 0x8946 /* Ethtool interface */ |
||
382 | |||
383 | /* ARP cache control calls. */ |
||
384 | /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ |
||
385 | #define SIOCDARP 0x8953 /* delete ARP table entry */ |
||
386 | #define SIOCGARP 0x8954 /* get ARP table entry */ |
||
387 | #define SIOCSARP 0x8955 /* set ARP table entry */ |
||
388 | |||
389 | /* RARP cache control calls. */ |
||
390 | #define SIOCDRARP 0x8960 /* delete RARP table entry */ |
||
391 | #define SIOCGRARP 0x8961 /* get RARP table entry */ |
||
392 | #define SIOCSRARP 0x8962 /* set RARP table entry */ |
||
393 | |||
394 | /* Driver configuration calls */ |
||
395 | |||
396 | #define SIOCGIFMAP 0x8970 /* Get device parameters */ |
||
397 | #define SIOCSIFMAP 0x8971 /* Set device parameters */ |
||
398 | |||
399 | /* DLCI configuration calls */ |
||
400 | |||
401 | #define SIOCADDDLCI 0x8980 /* Create new DLCI device */ |
||
402 | #define SIOCDELDLCI 0x8981 /* Delete DLCI device */ |
||
403 | |||
404 | #define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ |
||
405 | |||
406 | #define _LINUX_SOCKET_H |
||
407 | |||
408 | __END_DECLS |
||
409 | |||
410 | #endif |