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/*
8Input to cgo -godefs.  See also mkerrors.sh and mkall.sh
9*/
10
11// +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	_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 <signal.h>
25#include <termios.h>
26#include <stdio.h>
27#include <unistd.h>
28#include <sys/event.h>
29#include <sys/mman.h>
30#include <sys/mount.h>
31#include <sys/param.h>
32#include <sys/ptrace.h>
33#include <sys/resource.h>
34#include <sys/select.h>
35#include <sys/signal.h>
36#include <sys/socket.h>
37#include <sys/stat.h>
38#include <sys/time.h>
39#include <sys/types.h>
40#include <sys/un.h>
41#include <sys/wait.h>
42#include <net/bpf.h>
43#include <net/if.h>
44#include <net/if_dl.h>
45#include <net/route.h>
46#include <netinet/in.h>
47#include <netinet/icmp6.h>
48#include <netinet/tcp.h>
49
50enum {
51	sizeofPtr = sizeof(void*),
52};
53
54union sockaddr_all {
55	struct sockaddr s1;	// this one gets used for fields
56	struct sockaddr_in s2;	// these pad it out
57	struct sockaddr_in6 s3;
58	struct sockaddr_un s4;
59	struct sockaddr_dl s5;
60};
61
62struct sockaddr_any {
63	struct sockaddr addr;
64	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
65};
66
67// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
68// See /usr/include/net/if.h.
69struct if_data8 {
70	u_char  ifi_type;
71	u_char  ifi_physical;
72	u_char  ifi_addrlen;
73	u_char  ifi_hdrlen;
74	u_char  ifi_link_state;
75	u_char  ifi_spare_char1;
76	u_char  ifi_spare_char2;
77	u_char  ifi_datalen;
78	u_long  ifi_mtu;
79	u_long  ifi_metric;
80	u_long  ifi_baudrate;
81	u_long  ifi_ipackets;
82	u_long  ifi_ierrors;
83	u_long  ifi_opackets;
84	u_long  ifi_oerrors;
85	u_long  ifi_collisions;
86	u_long  ifi_ibytes;
87	u_long  ifi_obytes;
88	u_long  ifi_imcasts;
89	u_long  ifi_omcasts;
90	u_long  ifi_iqdrops;
91	u_long  ifi_noproto;
92	u_long  ifi_hwassist;
93// FIXME: these are now unions, so maybe need to change definitions?
94#undef ifi_epoch
95	time_t  ifi_epoch;
96#undef ifi_lastchange
97	struct  timeval ifi_lastchange;
98};
99
100// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
101// See /usr/include/net/if.h.
102struct if_msghdr8 {
103	u_short ifm_msglen;
104	u_char  ifm_version;
105	u_char  ifm_type;
106	int     ifm_addrs;
107	int     ifm_flags;
108	u_short ifm_index;
109	struct  if_data8 ifm_data;
110};
111*/
112import "C"
113
114// Machine characteristics; for internal use.
115
116const (
117	sizeofPtr      = C.sizeofPtr
118	sizeofShort    = C.sizeof_short
119	sizeofInt      = C.sizeof_int
120	sizeofLong     = C.sizeof_long
121	sizeofLongLong = C.sizeof_longlong
122)
123
124// Basic types
125
126type (
127	_C_short     C.short
128	_C_int       C.int
129	_C_long      C.long
130	_C_long_long C.longlong
131)
132
133// Time
134
135type Timespec C.struct_timespec
136
137type Timeval C.struct_timeval
138
139// Processes
140
141type Rusage C.struct_rusage
142
143type Rlimit C.struct_rlimit
144
145type _Gid_t C.gid_t
146
147// Files
148
149const ( // Directory mode bits
150	S_IFMT   = C.S_IFMT
151	S_IFIFO  = C.S_IFIFO
152	S_IFCHR  = C.S_IFCHR
153	S_IFDIR  = C.S_IFDIR
154	S_IFBLK  = C.S_IFBLK
155	S_IFREG  = C.S_IFREG
156	S_IFLNK  = C.S_IFLNK
157	S_IFSOCK = C.S_IFSOCK
158	S_ISUID  = C.S_ISUID
159	S_ISGID  = C.S_ISGID
160	S_ISVTX  = C.S_ISVTX
161	S_IRUSR  = C.S_IRUSR
162	S_IWUSR  = C.S_IWUSR
163	S_IXUSR  = C.S_IXUSR
164	S_IRWXG  = C.S_IRWXG
165	S_IRWXO  = C.S_IRWXO
166)
167
168const (
169	_statfsVersion = C.STATFS_VERSION
170	_dirblksiz     = C.DIRBLKSIZ
171)
172
173type Stat_t C.struct_stat
174
175type stat_freebsd11_t C.struct_freebsd11_stat
176
177type Statfs_t C.struct_statfs
178
179type statfs_freebsd11_t C.struct_freebsd11_statfs
180
181type Flock_t C.struct_flock
182
183type Dirent C.struct_dirent
184
185type dirent_freebsd11 C.struct_freebsd11_dirent
186
187type Fsid C.struct_fsid
188
189// File system limits
190
191const (
192	pathMax = C.PATH_MAX
193)
194
195// Sockets
196
197type RawSockaddrInet4 C.struct_sockaddr_in
198
199type RawSockaddrInet6 C.struct_sockaddr_in6
200
201type RawSockaddrUnix C.struct_sockaddr_un
202
203type RawSockaddrDatalink C.struct_sockaddr_dl
204
205type RawSockaddr C.struct_sockaddr
206
207type RawSockaddrAny C.struct_sockaddr_any
208
209type _Socklen C.socklen_t
210
211type Linger C.struct_linger
212
213type Iovec C.struct_iovec
214
215type IPMreq C.struct_ip_mreq
216
217type IPMreqn C.struct_ip_mreqn
218
219type IPv6Mreq C.struct_ipv6_mreq
220
221type Msghdr C.struct_msghdr
222
223type Cmsghdr C.struct_cmsghdr
224
225type Inet6Pktinfo C.struct_in6_pktinfo
226
227type IPv6MTUInfo C.struct_ip6_mtuinfo
228
229type ICMPv6Filter C.struct_icmp6_filter
230
231const (
232	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
233	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
234	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
235	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
236	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
237	SizeofLinger           = C.sizeof_struct_linger
238	SizeofIPMreq           = C.sizeof_struct_ip_mreq
239	SizeofIPMreqn          = C.sizeof_struct_ip_mreqn
240	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
241	SizeofMsghdr           = C.sizeof_struct_msghdr
242	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
243	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
244	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
245	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
246)
247
248// Ptrace requests
249
250const (
251	PTRACE_TRACEME = C.PT_TRACE_ME
252	PTRACE_CONT    = C.PT_CONTINUE
253	PTRACE_KILL    = C.PT_KILL
254)
255
256// Events (kqueue, kevent)
257
258type Kevent_t C.struct_kevent_freebsd11
259
260// Select
261
262type FdSet C.fd_set
263
264// Routing and interface messages
265
266const (
267	sizeofIfMsghdr         = C.sizeof_struct_if_msghdr
268	SizeofIfMsghdr         = C.sizeof_struct_if_msghdr8
269	sizeofIfData           = C.sizeof_struct_if_data
270	SizeofIfData           = C.sizeof_struct_if_data8
271	SizeofIfaMsghdr        = C.sizeof_struct_ifa_msghdr
272	SizeofIfmaMsghdr       = C.sizeof_struct_ifma_msghdr
273	SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
274	SizeofRtMsghdr         = C.sizeof_struct_rt_msghdr
275	SizeofRtMetrics        = C.sizeof_struct_rt_metrics
276)
277
278type ifMsghdr C.struct_if_msghdr
279
280type IfMsghdr C.struct_if_msghdr8
281
282type ifData C.struct_if_data
283
284type IfData C.struct_if_data8
285
286type IfaMsghdr C.struct_ifa_msghdr
287
288type IfmaMsghdr C.struct_ifma_msghdr
289
290type IfAnnounceMsghdr C.struct_if_announcemsghdr
291
292type RtMsghdr C.struct_rt_msghdr
293
294type RtMetrics C.struct_rt_metrics
295
296// Berkeley packet filter
297
298const (
299	SizeofBpfVersion    = C.sizeof_struct_bpf_version
300	SizeofBpfStat       = C.sizeof_struct_bpf_stat
301	SizeofBpfZbuf       = C.sizeof_struct_bpf_zbuf
302	SizeofBpfProgram    = C.sizeof_struct_bpf_program
303	SizeofBpfInsn       = C.sizeof_struct_bpf_insn
304	SizeofBpfHdr        = C.sizeof_struct_bpf_hdr
305	SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
306)
307
308type BpfVersion C.struct_bpf_version
309
310type BpfStat C.struct_bpf_stat
311
312type BpfZbuf C.struct_bpf_zbuf
313
314type BpfProgram C.struct_bpf_program
315
316type BpfInsn C.struct_bpf_insn
317
318type BpfHdr C.struct_bpf_hdr
319
320type BpfZbufHeader C.struct_bpf_zbuf_header
321
322// Misc
323
324const (
325	_AT_FDCWD            = C.AT_FDCWD
326	_AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
327	_AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
328)
329
330// Terminal handling
331
332type Termios C.struct_termios
333