]>
Commit | Line | Data |
---|---|---|
15c0b25d AP |
1 | // Copyright 2009 The Go Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style | |
3 | // license that can be found in the LICENSE file. | |
4 | ||
5 | // +build ignore | |
6 | ||
7 | /* | |
8 | Input to cgo -godefs. See README.md | |
9 | */ | |
10 | ||
11 | // +godefs map struct_in_addr [4]byte /* in_addr */ | |
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ | |
13 | ||
14 | package unix | |
15 | ||
16 | /* | |
17 | #define _WANT_FREEBSD11_STAT 1 | |
18 | #define _WANT_FREEBSD11_STATFS 1 | |
19 | #define _WANT_FREEBSD11_DIRENT 1 | |
20 | #define _WANT_FREEBSD11_KEVENT 1 | |
21 | ||
22 | #include <dirent.h> | |
23 | #include <fcntl.h> | |
24 | #include <poll.h> | |
25 | #include <signal.h> | |
26 | #include <termios.h> | |
27 | #include <stdio.h> | |
28 | #include <unistd.h> | |
107c1cdb | 29 | #include <sys/capsicum.h> |
15c0b25d AP |
30 | #include <sys/event.h> |
31 | #include <sys/mman.h> | |
32 | #include <sys/mount.h> | |
33 | #include <sys/param.h> | |
34 | #include <sys/ptrace.h> | |
35 | #include <sys/resource.h> | |
36 | #include <sys/select.h> | |
37 | #include <sys/signal.h> | |
38 | #include <sys/socket.h> | |
39 | #include <sys/stat.h> | |
40 | #include <sys/time.h> | |
41 | #include <sys/types.h> | |
42 | #include <sys/un.h> | |
43 | #include <sys/utsname.h> | |
44 | #include <sys/wait.h> | |
45 | #include <net/bpf.h> | |
46 | #include <net/if.h> | |
47 | #include <net/if_dl.h> | |
48 | #include <net/route.h> | |
49 | #include <netinet/in.h> | |
50 | #include <netinet/icmp6.h> | |
51 | #include <netinet/tcp.h> | |
52 | ||
53 | enum { | |
54 | sizeofPtr = sizeof(void*), | |
55 | }; | |
56 | ||
57 | union sockaddr_all { | |
58 | struct sockaddr s1; // this one gets used for fields | |
59 | struct sockaddr_in s2; // these pad it out | |
60 | struct sockaddr_in6 s3; | |
61 | struct sockaddr_un s4; | |
62 | struct sockaddr_dl s5; | |
63 | }; | |
64 | ||
65 | struct sockaddr_any { | |
66 | struct sockaddr addr; | |
67 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; | |
68 | }; | |
69 | ||
70 | // This structure is a duplicate of if_data on FreeBSD 8-STABLE. | |
71 | // See /usr/include/net/if.h. | |
72 | struct if_data8 { | |
73 | u_char ifi_type; | |
74 | u_char ifi_physical; | |
75 | u_char ifi_addrlen; | |
76 | u_char ifi_hdrlen; | |
77 | u_char ifi_link_state; | |
78 | u_char ifi_spare_char1; | |
79 | u_char ifi_spare_char2; | |
80 | u_char ifi_datalen; | |
81 | u_long ifi_mtu; | |
82 | u_long ifi_metric; | |
83 | u_long ifi_baudrate; | |
84 | u_long ifi_ipackets; | |
85 | u_long ifi_ierrors; | |
86 | u_long ifi_opackets; | |
87 | u_long ifi_oerrors; | |
88 | u_long ifi_collisions; | |
89 | u_long ifi_ibytes; | |
90 | u_long ifi_obytes; | |
91 | u_long ifi_imcasts; | |
92 | u_long ifi_omcasts; | |
93 | u_long ifi_iqdrops; | |
94 | u_long ifi_noproto; | |
95 | u_long ifi_hwassist; | |
96 | // FIXME: these are now unions, so maybe need to change definitions? | |
97 | #undef ifi_epoch | |
98 | time_t ifi_epoch; | |
99 | #undef ifi_lastchange | |
100 | struct timeval ifi_lastchange; | |
101 | }; | |
102 | ||
103 | // This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE. | |
104 | // See /usr/include/net/if.h. | |
105 | struct if_msghdr8 { | |
106 | u_short ifm_msglen; | |
107 | u_char ifm_version; | |
108 | u_char ifm_type; | |
109 | int ifm_addrs; | |
110 | int ifm_flags; | |
111 | u_short ifm_index; | |
112 | struct if_data8 ifm_data; | |
113 | }; | |
114 | */ | |
115 | import "C" | |
116 | ||
117 | // Machine characteristics | |
118 | ||
119 | const ( | |
120 | SizeofPtr = C.sizeofPtr | |
121 | SizeofShort = C.sizeof_short | |
122 | SizeofInt = C.sizeof_int | |
123 | SizeofLong = C.sizeof_long | |
124 | SizeofLongLong = C.sizeof_longlong | |
125 | ) | |
126 | ||
127 | // Basic types | |
128 | ||
129 | type ( | |
130 | _C_short C.short | |
131 | _C_int C.int | |
132 | _C_long C.long | |
133 | _C_long_long C.longlong | |
134 | ) | |
135 | ||
136 | // Time | |
137 | ||
138 | type Timespec C.struct_timespec | |
139 | ||
140 | type Timeval C.struct_timeval | |
141 | ||
142 | // Processes | |
143 | ||
144 | type Rusage C.struct_rusage | |
145 | ||
146 | type Rlimit C.struct_rlimit | |
147 | ||
148 | type _Gid_t C.gid_t | |
149 | ||
150 | // Files | |
151 | ||
152 | const ( | |
153 | _statfsVersion = C.STATFS_VERSION | |
154 | _dirblksiz = C.DIRBLKSIZ | |
155 | ) | |
156 | ||
157 | type Stat_t C.struct_stat | |
158 | ||
159 | type stat_freebsd11_t C.struct_freebsd11_stat | |
160 | ||
161 | type Statfs_t C.struct_statfs | |
162 | ||
163 | type statfs_freebsd11_t C.struct_freebsd11_statfs | |
164 | ||
165 | type Flock_t C.struct_flock | |
166 | ||
167 | type Dirent C.struct_dirent | |
168 | ||
169 | type dirent_freebsd11 C.struct_freebsd11_dirent | |
170 | ||
171 | type Fsid C.struct_fsid | |
172 | ||
173 | // File system limits | |
174 | ||
175 | const ( | |
176 | PathMax = C.PATH_MAX | |
177 | ) | |
178 | ||
179 | // Advice to Fadvise | |
180 | ||
181 | const ( | |
182 | FADV_NORMAL = C.POSIX_FADV_NORMAL | |
183 | FADV_RANDOM = C.POSIX_FADV_RANDOM | |
184 | FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL | |
185 | FADV_WILLNEED = C.POSIX_FADV_WILLNEED | |
186 | FADV_DONTNEED = C.POSIX_FADV_DONTNEED | |
187 | FADV_NOREUSE = C.POSIX_FADV_NOREUSE | |
188 | ) | |
189 | ||
190 | // Sockets | |
191 | ||
192 | type RawSockaddrInet4 C.struct_sockaddr_in | |
193 | ||
194 | type RawSockaddrInet6 C.struct_sockaddr_in6 | |
195 | ||
196 | type RawSockaddrUnix C.struct_sockaddr_un | |
197 | ||
198 | type RawSockaddrDatalink C.struct_sockaddr_dl | |
199 | ||
200 | type RawSockaddr C.struct_sockaddr | |
201 | ||
202 | type RawSockaddrAny C.struct_sockaddr_any | |
203 | ||
204 | type _Socklen C.socklen_t | |
205 | ||
206 | type Linger C.struct_linger | |
207 | ||
208 | type Iovec C.struct_iovec | |
209 | ||
210 | type IPMreq C.struct_ip_mreq | |
211 | ||
212 | type IPMreqn C.struct_ip_mreqn | |
213 | ||
214 | type IPv6Mreq C.struct_ipv6_mreq | |
215 | ||
216 | type Msghdr C.struct_msghdr | |
217 | ||
218 | type Cmsghdr C.struct_cmsghdr | |
219 | ||
220 | type Inet6Pktinfo C.struct_in6_pktinfo | |
221 | ||
222 | type IPv6MTUInfo C.struct_ip6_mtuinfo | |
223 | ||
224 | type ICMPv6Filter C.struct_icmp6_filter | |
225 | ||
226 | const ( | |
227 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in | |
228 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 | |
229 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any | |
230 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un | |
231 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl | |
232 | SizeofLinger = C.sizeof_struct_linger | |
233 | SizeofIPMreq = C.sizeof_struct_ip_mreq | |
234 | SizeofIPMreqn = C.sizeof_struct_ip_mreqn | |
235 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq | |
236 | SizeofMsghdr = C.sizeof_struct_msghdr | |
237 | SizeofCmsghdr = C.sizeof_struct_cmsghdr | |
238 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo | |
239 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo | |
240 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter | |
241 | ) | |
242 | ||
243 | // Ptrace requests | |
244 | ||
245 | const ( | |
246 | PTRACE_TRACEME = C.PT_TRACE_ME | |
247 | PTRACE_CONT = C.PT_CONTINUE | |
248 | PTRACE_KILL = C.PT_KILL | |
249 | ) | |
250 | ||
251 | // Events (kqueue, kevent) | |
252 | ||
253 | type Kevent_t C.struct_kevent_freebsd11 | |
254 | ||
255 | // Select | |
256 | ||
257 | type FdSet C.fd_set | |
258 | ||
259 | // Routing and interface messages | |
260 | ||
261 | const ( | |
262 | sizeofIfMsghdr = C.sizeof_struct_if_msghdr | |
263 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 | |
264 | sizeofIfData = C.sizeof_struct_if_data | |
265 | SizeofIfData = C.sizeof_struct_if_data8 | |
266 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr | |
267 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr | |
268 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr | |
269 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr | |
270 | SizeofRtMetrics = C.sizeof_struct_rt_metrics | |
271 | ) | |
272 | ||
273 | type ifMsghdr C.struct_if_msghdr | |
274 | ||
275 | type IfMsghdr C.struct_if_msghdr8 | |
276 | ||
277 | type ifData C.struct_if_data | |
278 | ||
279 | type IfData C.struct_if_data8 | |
280 | ||
281 | type IfaMsghdr C.struct_ifa_msghdr | |
282 | ||
283 | type IfmaMsghdr C.struct_ifma_msghdr | |
284 | ||
285 | type IfAnnounceMsghdr C.struct_if_announcemsghdr | |
286 | ||
287 | type RtMsghdr C.struct_rt_msghdr | |
288 | ||
289 | type RtMetrics C.struct_rt_metrics | |
290 | ||
291 | // Berkeley packet filter | |
292 | ||
293 | const ( | |
294 | SizeofBpfVersion = C.sizeof_struct_bpf_version | |
295 | SizeofBpfStat = C.sizeof_struct_bpf_stat | |
296 | SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf | |
297 | SizeofBpfProgram = C.sizeof_struct_bpf_program | |
298 | SizeofBpfInsn = C.sizeof_struct_bpf_insn | |
299 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr | |
300 | SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header | |
301 | ) | |
302 | ||
303 | type BpfVersion C.struct_bpf_version | |
304 | ||
305 | type BpfStat C.struct_bpf_stat | |
306 | ||
307 | type BpfZbuf C.struct_bpf_zbuf | |
308 | ||
309 | type BpfProgram C.struct_bpf_program | |
310 | ||
311 | type BpfInsn C.struct_bpf_insn | |
312 | ||
313 | type BpfHdr C.struct_bpf_hdr | |
314 | ||
315 | type BpfZbufHeader C.struct_bpf_zbuf_header | |
316 | ||
317 | // Terminal handling | |
318 | ||
319 | type Termios C.struct_termios | |
320 | ||
321 | type Winsize C.struct_winsize | |
322 | ||
323 | // fchmodat-like syscalls. | |
324 | ||
325 | const ( | |
326 | AT_FDCWD = C.AT_FDCWD | |
327 | AT_REMOVEDIR = C.AT_REMOVEDIR | |
328 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW | |
329 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW | |
330 | ) | |
331 | ||
332 | // poll | |
333 | ||
334 | type PollFd C.struct_pollfd | |
335 | ||
336 | const ( | |
337 | POLLERR = C.POLLERR | |
338 | POLLHUP = C.POLLHUP | |
339 | POLLIN = C.POLLIN | |
340 | POLLINIGNEOF = C.POLLINIGNEOF | |
341 | POLLNVAL = C.POLLNVAL | |
342 | POLLOUT = C.POLLOUT | |
343 | POLLPRI = C.POLLPRI | |
344 | POLLRDBAND = C.POLLRDBAND | |
345 | POLLRDNORM = C.POLLRDNORM | |
346 | POLLWRBAND = C.POLLWRBAND | |
347 | POLLWRNORM = C.POLLWRNORM | |
348 | ) | |
349 | ||
350 | // Capabilities | |
351 | ||
352 | type CapRights C.struct_cap_rights | |
353 | ||
354 | // Uname | |
355 | ||
356 | type Utsname C.struct_utsname |