github.com/Andyfoo/golang/x/sys@v0.0.0-20190901054642-57c1bf301704/unix/types_freebsd.go (about)

     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>
    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  
    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_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  
   265  const (
   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  
   272  const (
   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  
   278  const (
   279  	TRAP_BRKPT = C.TRAP_BRKPT
   280  	TRAP_TRACE = C.TRAP_TRACE
   281  )
   282  
   283  type PtraceLwpInfoStruct C.struct_ptrace_lwpinfo
   284  
   285  type __Siginfo C.struct___siginfo
   286  
   287  type Sigset_t C.sigset_t
   288  
   289  type Reg C.struct_reg
   290  
   291  type FpReg C.struct_fpreg
   292  
   293  type PtraceIoDesc C.struct_ptrace_io_desc
   294  
   295  // Events (kqueue, kevent)
   296  
   297  type Kevent_t C.struct_kevent_freebsd11
   298  
   299  // Select
   300  
   301  type FdSet C.fd_set
   302  
   303  // Routing and interface messages
   304  
   305  const (
   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  
   317  type ifMsghdr C.struct_if_msghdr
   318  
   319  type IfMsghdr C.struct_if_msghdr8
   320  
   321  type ifData C.struct_if_data
   322  
   323  type IfData C.struct_if_data8
   324  
   325  type IfaMsghdr C.struct_ifa_msghdr
   326  
   327  type IfmaMsghdr C.struct_ifma_msghdr
   328  
   329  type IfAnnounceMsghdr C.struct_if_announcemsghdr
   330  
   331  type RtMsghdr C.struct_rt_msghdr
   332  
   333  type RtMetrics C.struct_rt_metrics
   334  
   335  // Berkeley packet filter
   336  
   337  const (
   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  
   347  type BpfVersion C.struct_bpf_version
   348  
   349  type BpfStat C.struct_bpf_stat
   350  
   351  type BpfZbuf C.struct_bpf_zbuf
   352  
   353  type BpfProgram C.struct_bpf_program
   354  
   355  type BpfInsn C.struct_bpf_insn
   356  
   357  type BpfHdr C.struct_bpf_hdr
   358  
   359  type BpfZbufHeader C.struct_bpf_zbuf_header
   360  
   361  // Terminal handling
   362  
   363  type Termios C.struct_termios
   364  
   365  type Winsize C.struct_winsize
   366  
   367  // fchmodat-like syscalls.
   368  
   369  const (
   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  
   378  type PollFd C.struct_pollfd
   379  
   380  const (
   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  
   396  type CapRights C.struct_cap_rights
   397  
   398  // Uname
   399  
   400  type Utsname C.struct_utsname