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