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