Black Lives Matter. Support the Equal Justice Initiative.

Source file src/syscall/types_freebsd.go

Documentation: syscall

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

View as plain text