github.com/flyinox/gosm@v0.0.0-20171117061539-16768cb62077/src/syscall/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 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 KERNEL
    18  #include <dirent.h>
    19  #include <fcntl.h>
    20  #include <signal.h>
    21  #include <termios.h>
    22  #include <stdio.h>
    23  #include <unistd.h>
    24  #include <sys/event.h>
    25  #include <sys/mman.h>
    26  #include <sys/mount.h>
    27  #include <sys/param.h>
    28  #include <sys/ptrace.h>
    29  #include <sys/resource.h>
    30  #include <sys/select.h>
    31  #include <sys/signal.h>
    32  #include <sys/socket.h>
    33  #include <sys/stat.h>
    34  #include <sys/time.h>
    35  #include <sys/types.h>
    36  #include <sys/un.h>
    37  #include <sys/wait.h>
    38  #include <net/bpf.h>
    39  #include <net/if.h>
    40  #include <net/if_dl.h>
    41  #include <net/route.h>
    42  #include <netinet/in.h>
    43  #include <netinet/icmp6.h>
    44  #include <netinet/tcp.h>
    45  
    46  enum {
    47  	sizeofPtr = sizeof(void*),
    48  };
    49  
    50  union sockaddr_all {
    51  	struct sockaddr s1;	// this one gets used for fields
    52  	struct sockaddr_in s2;	// these pad it out
    53  	struct sockaddr_in6 s3;
    54  	struct sockaddr_un s4;
    55  	struct sockaddr_dl s5;
    56  };
    57  
    58  struct sockaddr_any {
    59  	struct sockaddr addr;
    60  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    61  };
    62  
    63  // This structure is a duplicate of stat on FreeBSD 8-STABLE.
    64  // See /usr/include/sys/stat.h.
    65  struct stat8 {
    66  #undef st_atimespec	st_atim
    67  #undef st_mtimespec	st_mtim
    68  #undef st_ctimespec	st_ctim
    69  #undef st_birthtimespec	st_birthtim
    70  	__dev_t   st_dev;
    71  	ino_t     st_ino;
    72  	mode_t    st_mode;
    73  	nlink_t   st_nlink;
    74  	uid_t     st_uid;
    75  	gid_t     st_gid;
    76  	__dev_t   st_rdev;
    77  #if __BSD_VISIBLE
    78  	struct  timespec st_atimespec;
    79  	struct  timespec st_mtimespec;
    80  	struct  timespec st_ctimespec;
    81  #else
    82  	time_t    st_atime;
    83  	long      __st_atimensec;
    84  	time_t    st_mtime;
    85  	long      __st_mtimensec;
    86  	time_t    st_ctime;
    87  	long      __st_ctimensec;
    88  #endif
    89  	off_t     st_size;
    90  	blkcnt_t st_blocks;
    91  	blksize_t st_blksize;
    92  	fflags_t  st_flags;
    93  	__uint32_t st_gen;
    94  	__int32_t st_lspare;
    95  #if __BSD_VISIBLE
    96  	struct timespec st_birthtimespec;
    97  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
    98  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
    99  #else
   100  	time_t    st_birthtime;
   101  	long      st_birthtimensec;
   102  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
   103  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
   104  #endif
   105  };
   106  
   107  // This structure is a duplicate of if_data on FreeBSD 8-STABLE.
   108  // See /usr/include/net/if.h.
   109  struct if_data8 {
   110  	u_char  ifi_type;
   111  	u_char  ifi_physical;
   112  	u_char  ifi_addrlen;
   113  	u_char  ifi_hdrlen;
   114  	u_char  ifi_link_state;
   115  	u_char  ifi_spare_char1;
   116  	u_char  ifi_spare_char2;
   117  	u_char  ifi_datalen;
   118  	u_long  ifi_mtu;
   119  	u_long  ifi_metric;
   120  	u_long  ifi_baudrate;
   121  	u_long  ifi_ipackets;
   122  	u_long  ifi_ierrors;
   123  	u_long  ifi_opackets;
   124  	u_long  ifi_oerrors;
   125  	u_long  ifi_collisions;
   126  	u_long  ifi_ibytes;
   127  	u_long  ifi_obytes;
   128  	u_long  ifi_imcasts;
   129  	u_long  ifi_omcasts;
   130  	u_long  ifi_iqdrops;
   131  	u_long  ifi_noproto;
   132  	u_long  ifi_hwassist;
   133  	time_t  ifi_epoch;
   134  	struct  timeval ifi_lastchange;
   135  };
   136  
   137  // This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
   138  // See /usr/include/net/if.h.
   139  struct if_msghdr8 {
   140  	u_short ifm_msglen;
   141  	u_char  ifm_version;
   142  	u_char  ifm_type;
   143  	int     ifm_addrs;
   144  	int     ifm_flags;
   145  	u_short ifm_index;
   146  	struct  if_data8 ifm_data;
   147  };
   148  */
   149  import "C"
   150  
   151  // Machine characteristics; for internal use.
   152  
   153  const (
   154  	sizeofPtr      = C.sizeofPtr
   155  	sizeofShort    = C.sizeof_short
   156  	sizeofInt      = C.sizeof_int
   157  	sizeofLong     = C.sizeof_long
   158  	sizeofLongLong = C.sizeof_longlong
   159  )
   160  
   161  // Basic types
   162  
   163  type (
   164  	_C_short     C.short
   165  	_C_int       C.int
   166  	_C_long      C.long
   167  	_C_long_long C.longlong
   168  )
   169  
   170  // Time
   171  
   172  type Timespec C.struct_timespec
   173  
   174  type Timeval C.struct_timeval
   175  
   176  // Processes
   177  
   178  type Rusage C.struct_rusage
   179  
   180  type Rlimit C.struct_rlimit
   181  
   182  type _Gid_t C.gid_t
   183  
   184  // Files
   185  
   186  const ( // Directory mode bits
   187  	S_IFMT   = C.S_IFMT
   188  	S_IFIFO  = C.S_IFIFO
   189  	S_IFCHR  = C.S_IFCHR
   190  	S_IFDIR  = C.S_IFDIR
   191  	S_IFBLK  = C.S_IFBLK
   192  	S_IFREG  = C.S_IFREG
   193  	S_IFLNK  = C.S_IFLNK
   194  	S_IFSOCK = C.S_IFSOCK
   195  	S_ISUID  = C.S_ISUID
   196  	S_ISGID  = C.S_ISGID
   197  	S_ISVTX  = C.S_ISVTX
   198  	S_IRUSR  = C.S_IRUSR
   199  	S_IWUSR  = C.S_IWUSR
   200  	S_IXUSR  = C.S_IXUSR
   201  )
   202  
   203  type Stat_t C.struct_stat8
   204  
   205  type Statfs_t C.struct_statfs
   206  
   207  type Flock_t C.struct_flock
   208  
   209  type Dirent C.struct_dirent
   210  
   211  type Fsid C.struct_fsid
   212  
   213  // Sockets
   214  
   215  type RawSockaddrInet4 C.struct_sockaddr_in
   216  
   217  type RawSockaddrInet6 C.struct_sockaddr_in6
   218  
   219  type RawSockaddrUnix C.struct_sockaddr_un
   220  
   221  type RawSockaddrDatalink C.struct_sockaddr_dl
   222  
   223  type RawSockaddr C.struct_sockaddr
   224  
   225  type RawSockaddrAny C.struct_sockaddr_any
   226  
   227  type _Socklen C.socklen_t
   228  
   229  type Linger C.struct_linger
   230  
   231  type Iovec C.struct_iovec
   232  
   233  type IPMreq C.struct_ip_mreq
   234  
   235  type IPMreqn C.struct_ip_mreqn
   236  
   237  type IPv6Mreq C.struct_ipv6_mreq
   238  
   239  type Msghdr C.struct_msghdr
   240  
   241  type Cmsghdr C.struct_cmsghdr
   242  
   243  type Inet6Pktinfo C.struct_in6_pktinfo
   244  
   245  type IPv6MTUInfo C.struct_ip6_mtuinfo
   246  
   247  type ICMPv6Filter C.struct_icmp6_filter
   248  
   249  const (
   250  	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
   251  	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
   252  	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
   253  	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
   254  	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
   255  	SizeofLinger           = C.sizeof_struct_linger
   256  	SizeofIPMreq           = C.sizeof_struct_ip_mreq
   257  	SizeofIPMreqn          = C.sizeof_struct_ip_mreqn
   258  	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
   259  	SizeofMsghdr           = C.sizeof_struct_msghdr
   260  	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
   261  	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
   262  	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
   263  	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
   264  )
   265  
   266  // Ptrace requests
   267  
   268  const (
   269  	PTRACE_TRACEME = C.PT_TRACE_ME
   270  	PTRACE_CONT    = C.PT_CONTINUE
   271  	PTRACE_KILL    = C.PT_KILL
   272  )
   273  
   274  // Events (kqueue, kevent)
   275  
   276  type Kevent_t C.struct_kevent
   277  
   278  // Select
   279  
   280  type FdSet C.fd_set
   281  
   282  // Routing and interface messages
   283  
   284  const (
   285  	sizeofIfMsghdr         = C.sizeof_struct_if_msghdr
   286  	SizeofIfMsghdr         = C.sizeof_struct_if_msghdr8
   287  	sizeofIfData           = C.sizeof_struct_if_data
   288  	SizeofIfData           = C.sizeof_struct_if_data8
   289  	SizeofIfaMsghdr        = C.sizeof_struct_ifa_msghdr
   290  	SizeofIfmaMsghdr       = C.sizeof_struct_ifma_msghdr
   291  	SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
   292  	SizeofRtMsghdr         = C.sizeof_struct_rt_msghdr
   293  	SizeofRtMetrics        = C.sizeof_struct_rt_metrics
   294  )
   295  
   296  type ifMsghdr C.struct_if_msghdr
   297  
   298  type IfMsghdr C.struct_if_msghdr8
   299  
   300  type ifData C.struct_if_data
   301  
   302  type IfData C.struct_if_data8
   303  
   304  type IfaMsghdr C.struct_ifa_msghdr
   305  
   306  type IfmaMsghdr C.struct_ifma_msghdr
   307  
   308  type IfAnnounceMsghdr C.struct_if_announcemsghdr
   309  
   310  type RtMsghdr C.struct_rt_msghdr
   311  
   312  type RtMetrics C.struct_rt_metrics
   313  
   314  // Berkeley packet filter
   315  
   316  const (
   317  	SizeofBpfVersion    = C.sizeof_struct_bpf_version
   318  	SizeofBpfStat       = C.sizeof_struct_bpf_stat
   319  	SizeofBpfZbuf       = C.sizeof_struct_bpf_zbuf
   320  	SizeofBpfProgram    = C.sizeof_struct_bpf_program
   321  	SizeofBpfInsn       = C.sizeof_struct_bpf_insn
   322  	SizeofBpfHdr        = C.sizeof_struct_bpf_hdr
   323  	SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
   324  )
   325  
   326  type BpfVersion C.struct_bpf_version
   327  
   328  type BpfStat C.struct_bpf_stat
   329  
   330  type BpfZbuf C.struct_bpf_zbuf
   331  
   332  type BpfProgram C.struct_bpf_program
   333  
   334  type BpfInsn C.struct_bpf_insn
   335  
   336  type BpfHdr C.struct_bpf_hdr
   337  
   338  type BpfZbufHeader C.struct_bpf_zbuf_header
   339  
   340  // Terminal handling
   341  
   342  type Termios C.struct_termios