Annotation of /trunk/mkinitrd-magellan/klibc/usr/include/sys/socket.h
Parent Directory | Revision Log
Revision 1297 -
(hide annotations)
(download)
Fri May 27 15:12:11 2011 UTC (13 years ago) by niro
File MIME type: text/plain
File size: 8702 byte(s)
Fri May 27 15:12:11 2011 UTC (13 years ago) by niro
File MIME type: text/plain
File size: 8702 byte(s)
-updated to klibc-1.5.22 with mntproc definitions patch included
1 | niro | 532 | /* |
2 | * sys/socket.h | ||
3 | */ | ||
4 | |||
5 | #ifndef _SYS_SOCKET_H | ||
6 | #define _SYS_SOCKET_H | ||
7 | |||
8 | niro | 1297 | #include <sys/types.h> |
9 | niro | 532 | #include <klibc/extern.h> |
10 | #include <klibc/compiler.h> | ||
11 | #include <klibc/sysconfig.h> | ||
12 | #include <linux/socket.h> | ||
13 | niro | 1122 | #include <linux/uio.h> |
14 | #include <asm/socket.h> | ||
15 | niro | 532 | #if _KLIBC_HAS_ARCHSOCKET_H |
16 | #include <klibc/archsocket.h> | ||
17 | #endif | ||
18 | |||
19 | /* Great job, guys! These are *architecture-specific* ABI constants, | ||
20 | that are hidden under #ifdef __KERNEL__... what a brilliant idea! | ||
21 | These are the "common" definitions; if not appropriate, override | ||
22 | them in <klibc/archsocket.h>. */ | ||
23 | niro | 1122 | |
24 | niro | 532 | #ifndef SOCK_STREAM |
25 | # define SOCK_STREAM 1 | ||
26 | # define SOCK_DGRAM 2 | ||
27 | # define SOCK_RAW 3 | ||
28 | # define SOCK_RDM 4 | ||
29 | # define SOCK_SEQPACKET 5 | ||
30 | # define SOCK_PACKET 10 | ||
31 | #endif | ||
32 | |||
33 | niro | 1122 | #ifndef AF_INET |
34 | #define AF_UNSPEC 0 | ||
35 | #define AF_UNIX 1 /* Unix domain sockets */ | ||
36 | #define AF_LOCAL 1 /* POSIX name for AF_UNIX */ | ||
37 | #define AF_INET 2 /* Internet IP Protocol */ | ||
38 | #define AF_AX25 3 /* Amateur Radio AX.25 */ | ||
39 | #define AF_IPX 4 /* Novell IPX */ | ||
40 | #define AF_APPLETALK 5 /* AppleTalk DDP */ | ||
41 | #define AF_NETROM 6 /* Amateur Radio NET/ROM */ | ||
42 | #define AF_BRIDGE 7 /* Multiprotocol bridge */ | ||
43 | #define AF_ATMPVC 8 /* ATM PVCs */ | ||
44 | #define AF_X25 9 /* Reserved for X.25 project */ | ||
45 | #define AF_INET6 10 /* IP version 6 */ | ||
46 | #define AF_ROSE 11 /* Amateur Radio X.25 PLP */ | ||
47 | #define AF_DECnet 12 /* Reserved for DECnet project */ | ||
48 | #define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ | ||
49 | #define AF_SECURITY 14 /* Security callback pseudo AF */ | ||
50 | #define AF_KEY 15 /* PF_KEY key management API */ | ||
51 | #define AF_NETLINK 16 | ||
52 | #define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ | ||
53 | #define AF_PACKET 17 /* Packet family */ | ||
54 | #define AF_ASH 18 /* Ash */ | ||
55 | #define AF_ECONET 19 /* Acorn Econet */ | ||
56 | #define AF_ATMSVC 20 /* ATM SVCs */ | ||
57 | #define AF_RDS 21 /* RDS sockets */ | ||
58 | #define AF_SNA 22 /* Linux SNA Project (nutters!) */ | ||
59 | #define AF_IRDA 23 /* IRDA sockets */ | ||
60 | #define AF_PPPOX 24 /* PPPoX sockets */ | ||
61 | #define AF_WANPIPE 25 /* Wanpipe API Sockets */ | ||
62 | #define AF_LLC 26 /* Linux LLC */ | ||
63 | #define AF_CAN 29 /* Controller Area Network */ | ||
64 | #define AF_TIPC 30 /* TIPC sockets */ | ||
65 | #define AF_BLUETOOTH 31 /* Bluetooth sockets */ | ||
66 | #define AF_IUCV 32 /* IUCV sockets */ | ||
67 | #define AF_RXRPC 33 /* RxRPC sockets */ | ||
68 | #define AF_ISDN 34 /* mISDN sockets */ | ||
69 | #define AF_PHONET 35 /* Phonet sockets */ | ||
70 | #define AF_IEEE802154 36 /* IEEE802154 sockets */ | ||
71 | #define AF_MAX 37 /* For now.. */ | ||
72 | #endif // !AF_INET | ||
73 | |||
74 | #ifndef PF_UNSPEC | ||
75 | #define PF_UNSPEC AF_UNSPEC | ||
76 | #define PF_UNIX AF_UNIX | ||
77 | #define PF_LOCAL AF_LOCAL | ||
78 | #define PF_INET AF_INET | ||
79 | #define PF_AX25 AF_AX25 | ||
80 | #define PF_IPX AF_IPX | ||
81 | #define PF_APPLETALK AF_APPLETALK | ||
82 | #define PF_NETROM AF_NETROM | ||
83 | #define PF_BRIDGE AF_BRIDGE | ||
84 | #define PF_ATMPVC AF_ATMPVC | ||
85 | #define PF_X25 AF_X25 | ||
86 | #define PF_INET6 AF_INET6 | ||
87 | #define PF_ROSE AF_ROSE | ||
88 | #define PF_DECnet AF_DECnet | ||
89 | #define PF_NETBEUI AF_NETBEUI | ||
90 | #define PF_SECURITY AF_SECURITY | ||
91 | #define PF_KEY AF_KEY | ||
92 | #define PF_NETLINK AF_NETLINK | ||
93 | #define PF_ROUTE AF_ROUTE | ||
94 | #define PF_PACKET AF_PACKET | ||
95 | #define PF_ASH AF_ASH | ||
96 | #define PF_ECONET AF_ECONET | ||
97 | #define PF_ATMSVC AF_ATMSVC | ||
98 | #define PF_RDS AF_RDS | ||
99 | #define PF_SNA AF_SNA | ||
100 | #define PF_IRDA AF_IRDA | ||
101 | #define PF_PPPOX AF_PPPOX | ||
102 | #define PF_WANPIPE AF_WANPIPE | ||
103 | #define PF_LLC AF_LLC | ||
104 | #define PF_CAN AF_CAN | ||
105 | #define PF_TIPC AF_TIPC | ||
106 | #define PF_BLUETOOTH AF_BLUETOOTH | ||
107 | #define PF_IUCV AF_IUCV | ||
108 | #define PF_RXRPC AF_RXRPC | ||
109 | #define PF_ISDN AF_ISDN | ||
110 | #define PF_PHONET AF_PHONET | ||
111 | #define PF_IEEE802154 AF_IEEE802154 | ||
112 | #define PF_MAX AF_MAX | ||
113 | #endif // !PF_UNSPEC | ||
114 | |||
115 | #ifndef MSG_OOB | ||
116 | #define MSG_OOB 1 | ||
117 | #define MSG_PEEK 2 | ||
118 | #define MSG_DONTROUTE 4 | ||
119 | #define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ | ||
120 | #define MSG_CTRUNC 8 | ||
121 | #define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ | ||
122 | #define MSG_TRUNC 0x20 | ||
123 | #define MSG_DONTWAIT 0x40 /* Nonblocking io */ | ||
124 | #define MSG_EOR 0x80 /* End of record */ | ||
125 | #define MSG_WAITALL 0x100 /* Wait for a full request */ | ||
126 | #define MSG_FIN 0x200 | ||
127 | #define MSG_SYN 0x400 | ||
128 | #define MSG_CONFIRM 0x800 /* Confirm path validity */ | ||
129 | #define MSG_RST 0x1000 | ||
130 | #define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ | ||
131 | #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ | ||
132 | #define MSG_MORE 0x8000 /* Sender will send more */ | ||
133 | |||
134 | #define MSG_EOF MSG_FIN | ||
135 | |||
136 | #define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exit for file | ||
137 | descriptor received through | ||
138 | SCM_RIGHTS */ | ||
139 | #if defined(CONFIG_COMPAT) | ||
140 | #define MSG_CMSG_COMPAT 0x80000000 /* This message needs 32 bit fixups */ | ||
141 | #else | ||
142 | #define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */ | ||
143 | #endif | ||
144 | #endif // !MSG_OOB | ||
145 | |||
146 | /* These types is hidden under __KERNEL__ in kernel sources */ | ||
147 | typedef unsigned short sa_family_t; | ||
148 | struct sockaddr { | ||
149 | sa_family_t sa_family; /* address family, AF_xxx */ | ||
150 | char sa_data[14]; /* 14 bytes of protocol address */ | ||
151 | }; | ||
152 | niro | 532 | typedef int socklen_t; |
153 | niro | 1122 | struct msghdr { |
154 | void *msg_name; | ||
155 | int msg_namelen; | ||
156 | struct iovec *msg_iov; | ||
157 | size_t msg_iovlen; | ||
158 | void *msg_control; | ||
159 | size_t msg_controllen; | ||
160 | unsigned msg_flags; | ||
161 | }; | ||
162 | niro | 532 | |
163 | niro | 1122 | /* Ancillary data structures and cmsg macros are also hidden under __KERNEL__ */ |
164 | #ifndef CMSG_FIRSTHDR | ||
165 | /* | ||
166 | * POSIX 1003.1g - ancillary data object information | ||
167 | * Ancillary data consits of a sequence of pairs of | ||
168 | * (cmsghdr, cmsg_data[]) | ||
169 | */ | ||
170 | |||
171 | struct cmsghdr { | ||
172 | __kernel_size_t cmsg_len; /* data byte count, including hdr */ | ||
173 | int cmsg_level; /* originating protocol */ | ||
174 | int cmsg_type; /* protocol-specific type */ | ||
175 | }; | ||
176 | |||
177 | /* | ||
178 | * Ancilliary data object information MACROS | ||
179 | * Table 5-14 of POSIX 1003.1g | ||
180 | */ | ||
181 | |||
182 | #define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg)) | ||
183 | #define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg)) | ||
184 | |||
185 | #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) | ||
186 | |||
187 | #define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))) | ||
188 | #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len)) | ||
189 | #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) | ||
190 | |||
191 | #define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? \ | ||
192 | (struct cmsghdr *)(ctl) : \ | ||
193 | (struct cmsghdr *)NULL) | ||
194 | #define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) | ||
195 | #define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && \ | ||
196 | (cmsg)->cmsg_len <= (unsigned long) \ | ||
197 | ((mhdr)->msg_controllen - \ | ||
198 | ((char *)(cmsg) - (char *)(mhdr)->msg_control))) | ||
199 | |||
200 | /* | ||
201 | * Get the next cmsg header | ||
202 | * | ||
203 | * PLEASE, do not touch this function. If you think, that it is | ||
204 | * incorrect, grep kernel sources and think about consequences | ||
205 | * before trying to improve it. | ||
206 | * | ||
207 | * Now it always returns valid, not truncated ancillary object | ||
208 | * HEADER. But caller still MUST check, that cmsg->cmsg_len is | ||
209 | * inside range, given by msg->msg_controllen before using | ||
210 | * ancillary object DATA. --ANK (980731) | ||
211 | */ | ||
212 | |||
213 | static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size, | ||
214 | struct cmsghdr *__cmsg) | ||
215 | { | ||
216 | struct cmsghdr * __ptr; | ||
217 | |||
218 | __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); | ||
219 | if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) | ||
220 | return (struct cmsghdr *)0; | ||
221 | |||
222 | return __ptr; | ||
223 | } | ||
224 | |||
225 | static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg) | ||
226 | { | ||
227 | return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); | ||
228 | } | ||
229 | |||
230 | /* "Socket"-level control message types: */ | ||
231 | |||
232 | #define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ | ||
233 | #define SCM_CREDENTIALS 0x02 /* rw: struct ucred */ | ||
234 | #define SCM_SECURITY 0x03 /* rw: security label */ | ||
235 | |||
236 | struct ucred { | ||
237 | __u32 pid; | ||
238 | __u32 uid; | ||
239 | __u32 gid; | ||
240 | }; | ||
241 | #endif /* CMSG_FIRSTHDR */ | ||
242 | |||
243 | |||
244 | niro | 532 | __extern int socket(int, int, int); |
245 | __extern int bind(int, struct sockaddr *, int); | ||
246 | __extern int connect(int, struct sockaddr *, socklen_t); | ||
247 | __extern int listen(int, int); | ||
248 | __extern int accept(int, struct sockaddr *, socklen_t *); | ||
249 | __extern int getsockname(int, struct sockaddr *, socklen_t *); | ||
250 | __extern int getpeername(int, struct sockaddr *, socklen_t *); | ||
251 | __extern int socketpair(int, int, int, int *); | ||
252 | __extern int send(int, const void *, size_t, unsigned int); | ||
253 | __extern int sendto(int, const void *, size_t, int, const struct sockaddr *, | ||
254 | socklen_t); | ||
255 | __extern int recv(int, void *, size_t, unsigned int); | ||
256 | __extern int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, | ||
257 | socklen_t *); | ||
258 | __extern int shutdown(int, int); | ||
259 | __extern int setsockopt(int, int, int, const void *, socklen_t); | ||
260 | __extern int getsockopt(int, int, int, void *, socklen_t *); | ||
261 | __extern int sendmsg(int, const struct msghdr *, unsigned int); | ||
262 | __extern int recvmsg(int, struct msghdr *, unsigned int); | ||
263 | |||
264 | #endif /* _SYS_SOCKET_H */ |