Source file src/syscall/types_freebsd.go

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

View as plain text