blob: 68a69312b207982ca988ef9226587f05b7719bfe [file] [log] [blame]
Russ Coxdd2abe52011-11-10 19:08:28 -05001// 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
Russ Cox8fe75a22012-02-02 19:42:02 -05005// +build ignore
6
Russ Coxdd2abe52011-11-10 19:08:28 -05007/*
8Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9*/
10
Russ Coxdd2abe52011-11-10 19:08:28 -050011// +godefs map struct_in_addr [4]byte /* in_addr */
12// +godefs map struct_in6_addr [16]byte /* in6_addr */
13
14package syscall
15
16/*
17#define KERNEL
18#include <dirent.h>
19#include <fcntl.h>
20#include <signal.h>
Michael Gehring5ce3e6a2014-01-13 13:57:38 -080021#include <termios.h>
Russ Coxdd2abe52011-11-10 19:08:28 -050022#include <stdio.h>
23#include <unistd.h>
24#include <sys/event.h>
25#include <sys/mman.h>
26#include <sys/mount.h>
27#include <sys/param.h>
28#include <sys/ptrace.h>
29#include <sys/resource.h>
30#include <sys/select.h>
31#include <sys/signal.h>
32#include <sys/socket.h>
33#include <sys/stat.h>
34#include <sys/time.h>
35#include <sys/types.h>
36#include <sys/un.h>
37#include <sys/wait.h>
38#include <net/bpf.h>
39#include <net/if.h>
40#include <net/if_dl.h>
41#include <net/route.h>
42#include <netinet/in.h>
Mikio Haraadbe59e2013-05-23 16:22:05 +090043#include <netinet/icmp6.h>
Russ Coxdd2abe52011-11-10 19:08:28 -050044#include <netinet/tcp.h>
45
46enum {
47 sizeofPtr = sizeof(void*),
48};
49
50union sockaddr_all {
51 struct sockaddr s1; // this one gets used for fields
52 struct sockaddr_in s2; // these pad it out
53 struct sockaddr_in6 s3;
54 struct sockaddr_un s4;
55 struct sockaddr_dl s5;
56};
57
58struct sockaddr_any {
59 struct sockaddr addr;
60 char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
61};
62
Mikio Hara737efeb2014-03-04 09:26:01 +090063// This structure is a duplicate of stat on FreeBSD 8-STABLE.
64// See /usr/include/sys/stat.h.
65struct stat8 {
66#undef st_atimespec st_atim
67#undef st_mtimespec st_mtim
68#undef st_ctimespec st_ctim
69#undef st_birthtimespec st_birthtim
70 __dev_t st_dev;
71 ino_t st_ino;
72 mode_t st_mode;
73 nlink_t st_nlink;
74 uid_t st_uid;
75 gid_t st_gid;
76 __dev_t st_rdev;
77#if __BSD_VISIBLE
78 struct timespec st_atimespec;
79 struct timespec st_mtimespec;
80 struct timespec st_ctimespec;
81#else
82 time_t st_atime;
83 long __st_atimensec;
84 time_t st_mtime;
85 long __st_mtimensec;
86 time_t st_ctime;
87 long __st_ctimensec;
88#endif
89 off_t st_size;
90 blkcnt_t st_blocks;
91 blksize_t st_blksize;
92 fflags_t st_flags;
93 __uint32_t st_gen;
94 __int32_t st_lspare;
95#if __BSD_VISIBLE
96 struct timespec st_birthtimespec;
97 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
98 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
99#else
100 time_t st_birthtime;
101 long st_birthtimensec;
102 unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
103 unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
104#endif
105};
106
107// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
108// See /usr/include/net/if.h.
109struct if_data8 {
110 u_char ifi_type;
111 u_char ifi_physical;
112 u_char ifi_addrlen;
113 u_char ifi_hdrlen;
114 u_char ifi_link_state;
115 u_char ifi_spare_char1;
116 u_char ifi_spare_char2;
117 u_char ifi_datalen;
118 u_long ifi_mtu;
119 u_long ifi_metric;
120 u_long ifi_baudrate;
121 u_long ifi_ipackets;
122 u_long ifi_ierrors;
123 u_long ifi_opackets;
124 u_long ifi_oerrors;
125 u_long ifi_collisions;
126 u_long ifi_ibytes;
127 u_long ifi_obytes;
128 u_long ifi_imcasts;
129 u_long ifi_omcasts;
130 u_long ifi_iqdrops;
131 u_long ifi_noproto;
132 u_long ifi_hwassist;
133 time_t ifi_epoch;
134 struct timeval ifi_lastchange;
135};
136
137// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
138// See /usr/include/net/if.h.
139struct if_msghdr8 {
140 u_short ifm_msglen;
141 u_char ifm_version;
142 u_char ifm_type;
143 int ifm_addrs;
144 int ifm_flags;
145 u_short ifm_index;
146 struct if_data8 ifm_data;
147};
Russ Coxdd2abe52011-11-10 19:08:28 -0500148*/
149import "C"
150
151// Machine characteristics; for internal use.
152
153const (
154 sizeofPtr = C.sizeofPtr
155 sizeofShort = C.sizeof_short
156 sizeofInt = C.sizeof_int
157 sizeofLong = C.sizeof_long
158 sizeofLongLong = C.sizeof_longlong
159)
160
161// Basic types
162
163type (
164 _C_short C.short
165 _C_int C.int
166 _C_long C.long
167 _C_long_long C.longlong
168)
169
170// Time
171
172type Timespec C.struct_timespec
173
174type Timeval C.struct_timeval
175
176// Processes
177
178type Rusage C.struct_rusage
179
180type Rlimit C.struct_rlimit
181
182type _Gid_t C.gid_t
183
184// Files
185
Russ Coxdd2abe52011-11-10 19:08:28 -0500186const ( // Directory mode bits
187 S_IFMT = C.S_IFMT
188 S_IFIFO = C.S_IFIFO
189 S_IFCHR = C.S_IFCHR
190 S_IFDIR = C.S_IFDIR
191 S_IFBLK = C.S_IFBLK
192 S_IFREG = C.S_IFREG
193 S_IFLNK = C.S_IFLNK
194 S_IFSOCK = C.S_IFSOCK
195 S_ISUID = C.S_ISUID
196 S_ISGID = C.S_ISGID
197 S_ISVTX = C.S_ISVTX
198 S_IRUSR = C.S_IRUSR
199 S_IWUSR = C.S_IWUSR
200 S_IXUSR = C.S_IXUSR
201)
202
Mikio Hara737efeb2014-03-04 09:26:01 +0900203type Stat_t C.struct_stat8
Russ Coxdd2abe52011-11-10 19:08:28 -0500204
205type Statfs_t C.struct_statfs
206
207type Flock_t C.struct_flock
208
209type Dirent C.struct_dirent
210
211type Fsid C.struct_fsid
212
213// Sockets
214
215type RawSockaddrInet4 C.struct_sockaddr_in
216
217type RawSockaddrInet6 C.struct_sockaddr_in6
218
219type RawSockaddrUnix C.struct_sockaddr_un
220
221type RawSockaddrDatalink C.struct_sockaddr_dl
222
223type RawSockaddr C.struct_sockaddr
224
225type RawSockaddrAny C.struct_sockaddr_any
226
227type _Socklen C.socklen_t
228
229type Linger C.struct_linger
230
231type Iovec C.struct_iovec
232
233type IPMreq C.struct_ip_mreq
234
235type IPMreqn C.struct_ip_mreqn
236
237type IPv6Mreq C.struct_ipv6_mreq
238
239type Msghdr C.struct_msghdr
240
241type Cmsghdr C.struct_cmsghdr
242
243type Inet6Pktinfo C.struct_in6_pktinfo
244
Mikio Haraadbe59e2013-05-23 16:22:05 +0900245type IPv6MTUInfo C.struct_ip6_mtuinfo
246
247type ICMPv6Filter C.struct_icmp6_filter
248
Russ Coxdd2abe52011-11-10 19:08:28 -0500249const (
250 SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
251 SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
252 SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
253 SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
254 SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
255 SizeofLinger = C.sizeof_struct_linger
256 SizeofIPMreq = C.sizeof_struct_ip_mreq
257 SizeofIPMreqn = C.sizeof_struct_ip_mreqn
258 SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
259 SizeofMsghdr = C.sizeof_struct_msghdr
260 SizeofCmsghdr = C.sizeof_struct_cmsghdr
261 SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
Mikio Haraadbe59e2013-05-23 16:22:05 +0900262 SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
263 SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
Russ Coxdd2abe52011-11-10 19:08:28 -0500264)
265
266// Ptrace requests
267
268const (
269 PTRACE_TRACEME = C.PT_TRACE_ME
270 PTRACE_CONT = C.PT_CONTINUE
271 PTRACE_KILL = C.PT_KILL
272)
273
274// Events (kqueue, kevent)
275
276type Kevent_t C.struct_kevent
277
278// Select
279
280type FdSet C.fd_set
281
282// Routing and interface messages
283
284const (
Mikio Hara737efeb2014-03-04 09:26:01 +0900285 sizeofIfMsghdr = C.sizeof_struct_if_msghdr
286 SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
287 sizeofIfData = C.sizeof_struct_if_data
288 SizeofIfData = C.sizeof_struct_if_data8
Mikio Harab1d51c62013-02-24 12:04:48 +0900289 SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
290 SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
291 SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
292 SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
293 SizeofRtMetrics = C.sizeof_struct_rt_metrics
Russ Coxdd2abe52011-11-10 19:08:28 -0500294)
295
Mikio Hara737efeb2014-03-04 09:26:01 +0900296type ifMsghdr C.struct_if_msghdr
Russ Coxdd2abe52011-11-10 19:08:28 -0500297
Mikio Hara737efeb2014-03-04 09:26:01 +0900298type IfMsghdr C.struct_if_msghdr8
299
300type ifData C.struct_if_data
301
302type IfData C.struct_if_data8
Russ Coxdd2abe52011-11-10 19:08:28 -0500303
304type IfaMsghdr C.struct_ifa_msghdr
305
306type IfmaMsghdr C.struct_ifma_msghdr
307
Mikio Harab1d51c62013-02-24 12:04:48 +0900308type IfAnnounceMsghdr C.struct_if_announcemsghdr
309
Russ Coxdd2abe52011-11-10 19:08:28 -0500310type RtMsghdr C.struct_rt_msghdr
311
312type RtMetrics C.struct_rt_metrics
313
314// Berkeley packet filter
315
316const (
317 SizeofBpfVersion = C.sizeof_struct_bpf_version
318 SizeofBpfStat = C.sizeof_struct_bpf_stat
319 SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf
320 SizeofBpfProgram = C.sizeof_struct_bpf_program
321 SizeofBpfInsn = C.sizeof_struct_bpf_insn
322 SizeofBpfHdr = C.sizeof_struct_bpf_hdr
323 SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
324)
325
326type BpfVersion C.struct_bpf_version
327
328type BpfStat C.struct_bpf_stat
329
330type BpfZbuf C.struct_bpf_zbuf
331
332type BpfProgram C.struct_bpf_program
333
334type BpfInsn C.struct_bpf_insn
335
336type BpfHdr C.struct_bpf_hdr
337
338type BpfZbufHeader C.struct_bpf_zbuf_header
Michael Gehring5ce3e6a2014-01-13 13:57:38 -0800339
340// Terminal handling
341
342type Termios C.struct_termios