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 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 14package 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> 29#include <sys/capsicum.h> 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 53enum { 54 sizeofPtr = sizeof(void*), 55}; 56 57union 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 65struct 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. 72struct 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. 105struct 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*/ 115import "C" 116 117// Machine characteristics 118 119const ( 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 129type ( 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 138type Timespec C.struct_timespec 139 140type Timeval C.struct_timeval 141 142// Processes 143 144type Rusage C.struct_rusage 145 146type Rlimit C.struct_rlimit 147 148type _Gid_t C.gid_t 149 150// Files 151 152const ( 153 _statfsVersion = C.STATFS_VERSION 154 _dirblksiz = C.DIRBLKSIZ 155) 156 157type Stat_t C.struct_stat 158 159type stat_freebsd11_t C.struct_freebsd11_stat 160 161type Statfs_t C.struct_statfs 162 163type statfs_freebsd11_t C.struct_freebsd11_statfs 164 165type Flock_t C.struct_flock 166 167type Dirent C.struct_dirent 168 169type dirent_freebsd11 C.struct_freebsd11_dirent 170 171type Fsid C.struct_fsid 172 173// File system limits 174 175const ( 176 PathMax = C.PATH_MAX 177) 178 179// Advice to Fadvise 180 181const ( 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 192type RawSockaddrInet4 C.struct_sockaddr_in 193 194type RawSockaddrInet6 C.struct_sockaddr_in6 195 196type RawSockaddrUnix C.struct_sockaddr_un 197 198type RawSockaddrDatalink C.struct_sockaddr_dl 199 200type RawSockaddr C.struct_sockaddr 201 202type RawSockaddrAny C.struct_sockaddr_any 203 204type _Socklen C.socklen_t 205 206type Linger C.struct_linger 207 208type Iovec C.struct_iovec 209 210type IPMreq C.struct_ip_mreq 211 212type IPMreqn C.struct_ip_mreqn 213 214type IPv6Mreq C.struct_ipv6_mreq 215 216type Msghdr C.struct_msghdr 217 218type Cmsghdr C.struct_cmsghdr 219 220type Inet6Pktinfo C.struct_in6_pktinfo 221 222type IPv6MTUInfo C.struct_ip6_mtuinfo 223 224type ICMPv6Filter C.struct_icmp6_filter 225 226const ( 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 245const ( 246 PTRACE_ATTACH = C.PT_ATTACH 247 PTRACE_CONT = C.PT_CONTINUE 248 PTRACE_DETACH = C.PT_DETACH 249 PTRACE_GETFPREGS = C.PT_GETFPREGS 250 PTRACE_GETFSBASE = C.PT_GETFSBASE 251 PTRACE_GETLWPLIST = C.PT_GETLWPLIST 252 PTRACE_GETNUMLWPS = C.PT_GETNUMLWPS 253 PTRACE_GETREGS = C.PT_GETREGS 254 PTRACE_GETXSTATE = C.PT_GETXSTATE 255 PTRACE_IO = C.PT_IO 256 PTRACE_KILL = C.PT_KILL 257 PTRACE_LWPEVENTS = C.PT_LWP_EVENTS 258 PTRACE_LWPINFO = C.PT_LWPINFO 259 PTRACE_SETFPREGS = C.PT_SETFPREGS 260 PTRACE_SETREGS = C.PT_SETREGS 261 PTRACE_SINGLESTEP = C.PT_STEP 262 PTRACE_TRACEME = C.PT_TRACE_ME 263) 264 265const ( 266 PIOD_READ_D = C.PIOD_READ_D 267 PIOD_WRITE_D = C.PIOD_WRITE_D 268 PIOD_READ_I = C.PIOD_READ_I 269 PIOD_WRITE_I = C.PIOD_WRITE_I 270) 271 272const ( 273 PL_FLAG_BORN = C.PL_FLAG_BORN 274 PL_FLAG_EXITED = C.PL_FLAG_EXITED 275 PL_FLAG_SI = C.PL_FLAG_SI 276) 277 278const ( 279 TRAP_BRKPT = C.TRAP_BRKPT 280 TRAP_TRACE = C.TRAP_TRACE 281) 282 283type PtraceLwpInfoStruct C.struct_ptrace_lwpinfo 284 285type __Siginfo C.struct___siginfo 286 287type Sigset_t C.sigset_t 288 289type Reg C.struct_reg 290 291type FpReg C.struct_fpreg 292 293type PtraceIoDesc C.struct_ptrace_io_desc 294 295// Events (kqueue, kevent) 296 297type Kevent_t C.struct_kevent_freebsd11 298 299// Select 300 301type FdSet C.fd_set 302 303// Routing and interface messages 304 305const ( 306 sizeofIfMsghdr = C.sizeof_struct_if_msghdr 307 SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 308 sizeofIfData = C.sizeof_struct_if_data 309 SizeofIfData = C.sizeof_struct_if_data8 310 SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 311 SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 312 SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 313 SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 314 SizeofRtMetrics = C.sizeof_struct_rt_metrics 315) 316 317type ifMsghdr C.struct_if_msghdr 318 319type IfMsghdr C.struct_if_msghdr8 320 321type ifData C.struct_if_data 322 323type IfData C.struct_if_data8 324 325type IfaMsghdr C.struct_ifa_msghdr 326 327type IfmaMsghdr C.struct_ifma_msghdr 328 329type IfAnnounceMsghdr C.struct_if_announcemsghdr 330 331type RtMsghdr C.struct_rt_msghdr 332 333type RtMetrics C.struct_rt_metrics 334 335// Berkeley packet filter 336 337const ( 338 SizeofBpfVersion = C.sizeof_struct_bpf_version 339 SizeofBpfStat = C.sizeof_struct_bpf_stat 340 SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf 341 SizeofBpfProgram = C.sizeof_struct_bpf_program 342 SizeofBpfInsn = C.sizeof_struct_bpf_insn 343 SizeofBpfHdr = C.sizeof_struct_bpf_hdr 344 SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header 345) 346 347type BpfVersion C.struct_bpf_version 348 349type BpfStat C.struct_bpf_stat 350 351type BpfZbuf C.struct_bpf_zbuf 352 353type BpfProgram C.struct_bpf_program 354 355type BpfInsn C.struct_bpf_insn 356 357type BpfHdr C.struct_bpf_hdr 358 359type BpfZbufHeader C.struct_bpf_zbuf_header 360 361// Terminal handling 362 363type Termios C.struct_termios 364 365type Winsize C.struct_winsize 366 367// fchmodat-like syscalls. 368 369const ( 370 AT_FDCWD = C.AT_FDCWD 371 AT_REMOVEDIR = C.AT_REMOVEDIR 372 AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 373 AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 374) 375 376// poll 377 378type PollFd C.struct_pollfd 379 380const ( 381 POLLERR = C.POLLERR 382 POLLHUP = C.POLLHUP 383 POLLIN = C.POLLIN 384 POLLINIGNEOF = C.POLLINIGNEOF 385 POLLNVAL = C.POLLNVAL 386 POLLOUT = C.POLLOUT 387 POLLPRI = C.POLLPRI 388 POLLRDBAND = C.POLLRDBAND 389 POLLRDNORM = C.POLLRDNORM 390 POLLWRBAND = C.POLLWRBAND 391 POLLWRNORM = C.POLLWRNORM 392) 393 394// Capabilities 395 396type CapRights C.struct_cap_rights 397 398// Uname 399 400type Utsname C.struct_utsname 401