golang.org/x/sys@v0.9.0/unix/types_solaris.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  // +build ignore
     7  
     8  /*
     9  Input to cgo -godefs.  See README.md
    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 unix
    16  
    17  /*
    18  #define KERNEL
    19  // These defines ensure that builds done on newer versions of Solaris are
    20  // backwards-compatible with older versions of Solaris and
    21  // OpenSolaris-based derivatives.
    22  #define __USE_SUNOS_SOCKETS__          // msghdr
    23  #define __USE_LEGACY_PROTOTYPES__      // iovec
    24  #include <dirent.h>
    25  #include <fcntl.h>
    26  #include <netdb.h>
    27  #include <limits.h>
    28  #include <poll.h>
    29  #include <signal.h>
    30  #include <termios.h>
    31  #include <termio.h>
    32  #include <stdio.h>
    33  #include <unistd.h>
    34  #include <sys/mman.h>
    35  #include <sys/mount.h>
    36  #include <sys/param.h>
    37  #include <sys/port.h>
    38  #include <sys/resource.h>
    39  #include <sys/select.h>
    40  #include <sys/signal.h>
    41  #include <sys/socket.h>
    42  #include <sys/sockio.h>
    43  #include <sys/stat.h>
    44  #include <sys/statvfs.h>
    45  #include <sys/stropts.h>
    46  #include <sys/time.h>
    47  #include <sys/times.h>
    48  #include <sys/types.h>
    49  #include <sys/utsname.h>
    50  #include <sys/un.h>
    51  #include <sys/wait.h>
    52  #include <net/bpf.h>
    53  #include <net/if.h>
    54  #include <net/if_dl.h>
    55  #include <net/route.h>
    56  #include <netinet/in.h>
    57  #include <netinet/icmp6.h>
    58  #include <netinet/tcp.h>
    59  #include <ustat.h>
    60  #include <utime.h>
    61  
    62  enum {
    63  	sizeofPtr = sizeof(void*),
    64  };
    65  
    66  union sockaddr_all {
    67  	struct sockaddr s1;	// this one gets used for fields
    68  	struct sockaddr_in s2;	// these pad it out
    69  	struct sockaddr_in6 s3;
    70  	struct sockaddr_un s4;
    71  	struct sockaddr_dl s5;
    72  };
    73  
    74  struct sockaddr_any {
    75  	struct sockaddr addr;
    76  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    77  };
    78  
    79  // Solaris and the major illumos distributions ship a 3rd party tun/tap driver
    80  // from https://github.com/kaizawa/tuntap
    81  // It supports a pair of IOCTLs defined at
    82  // https://github.com/kaizawa/tuntap/blob/master/if_tun.h#L91-L93
    83  #define TUNNEWPPA	(('T'<<16) | 0x0001)
    84  #define TUNSETPPA	(('T'<<16) | 0x0002)
    85  */
    86  import "C"
    87  
    88  // Machine characteristics
    89  
    90  const (
    91  	SizeofPtr      = C.sizeofPtr
    92  	SizeofShort    = C.sizeof_short
    93  	SizeofInt      = C.sizeof_int
    94  	SizeofLong     = C.sizeof_long
    95  	SizeofLongLong = C.sizeof_longlong
    96  	PathMax        = C.PATH_MAX
    97  	MaxHostNameLen = C.MAXHOSTNAMELEN
    98  )
    99  
   100  // Basic types
   101  
   102  type (
   103  	_C_short     C.short
   104  	_C_int       C.int
   105  	_C_long      C.long
   106  	_C_long_long C.longlong
   107  )
   108  
   109  // Time
   110  
   111  type Timespec C.struct_timespec
   112  
   113  type Timeval C.struct_timeval
   114  
   115  type Timeval32 C.struct_timeval32
   116  
   117  type Tms C.struct_tms
   118  
   119  type Utimbuf C.struct_utimbuf
   120  
   121  // Processes
   122  
   123  type Rusage C.struct_rusage
   124  
   125  type Rlimit C.struct_rlimit
   126  
   127  type _Gid_t C.gid_t
   128  
   129  // Files
   130  
   131  type Stat_t C.struct_stat
   132  
   133  type Flock_t C.struct_flock
   134  
   135  type Dirent C.struct_dirent
   136  
   137  // Filesystems
   138  
   139  type _Fsblkcnt_t C.fsblkcnt_t
   140  
   141  type Statvfs_t C.struct_statvfs
   142  
   143  // Sockets
   144  
   145  type RawSockaddrInet4 C.struct_sockaddr_in
   146  
   147  type RawSockaddrInet6 C.struct_sockaddr_in6
   148  
   149  type RawSockaddrUnix C.struct_sockaddr_un
   150  
   151  type RawSockaddrDatalink C.struct_sockaddr_dl
   152  
   153  type RawSockaddr C.struct_sockaddr
   154  
   155  type RawSockaddrAny C.struct_sockaddr_any
   156  
   157  type _Socklen C.socklen_t
   158  
   159  type Linger C.struct_linger
   160  
   161  type Iovec C.struct_iovec
   162  
   163  type IPMreq C.struct_ip_mreq
   164  
   165  type IPv6Mreq C.struct_ipv6_mreq
   166  
   167  type Msghdr C.struct_msghdr
   168  
   169  type Cmsghdr C.struct_cmsghdr
   170  
   171  type Inet4Pktinfo C.struct_in_pktinfo
   172  
   173  type Inet6Pktinfo C.struct_in6_pktinfo
   174  
   175  type IPv6MTUInfo C.struct_ip6_mtuinfo
   176  
   177  type ICMPv6Filter C.struct_icmp6_filter
   178  
   179  const (
   180  	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
   181  	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
   182  	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
   183  	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
   184  	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
   185  	SizeofLinger           = C.sizeof_struct_linger
   186  	SizeofIovec            = C.sizeof_struct_iovec
   187  	SizeofIPMreq           = C.sizeof_struct_ip_mreq
   188  	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
   189  	SizeofMsghdr           = C.sizeof_struct_msghdr
   190  	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
   191  	SizeofInet4Pktinfo     = C.sizeof_struct_in_pktinfo
   192  	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
   193  	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
   194  	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
   195  )
   196  
   197  // Select
   198  
   199  type FdSet C.fd_set
   200  
   201  // Misc
   202  
   203  type Utsname C.struct_utsname
   204  
   205  type Ustat_t C.struct_ustat
   206  
   207  const (
   208  	AT_FDCWD            = C.AT_FDCWD
   209  	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
   210  	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
   211  	AT_REMOVEDIR        = C.AT_REMOVEDIR
   212  	AT_EACCESS          = C.AT_EACCESS
   213  )
   214  
   215  // Routing and interface messages
   216  
   217  const (
   218  	SizeofIfMsghdr  = C.sizeof_struct_if_msghdr
   219  	SizeofIfData    = C.sizeof_struct_if_data
   220  	SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
   221  	SizeofRtMsghdr  = C.sizeof_struct_rt_msghdr
   222  	SizeofRtMetrics = C.sizeof_struct_rt_metrics
   223  )
   224  
   225  type IfMsghdr C.struct_if_msghdr
   226  
   227  type IfData C.struct_if_data
   228  
   229  type IfaMsghdr C.struct_ifa_msghdr
   230  
   231  type RtMsghdr C.struct_rt_msghdr
   232  
   233  type RtMetrics C.struct_rt_metrics
   234  
   235  // Berkeley packet filter
   236  
   237  const (
   238  	SizeofBpfVersion = C.sizeof_struct_bpf_version
   239  	SizeofBpfStat    = C.sizeof_struct_bpf_stat
   240  	SizeofBpfProgram = C.sizeof_struct_bpf_program
   241  	SizeofBpfInsn    = C.sizeof_struct_bpf_insn
   242  	SizeofBpfHdr     = C.sizeof_struct_bpf_hdr
   243  )
   244  
   245  type BpfVersion C.struct_bpf_version
   246  
   247  type BpfStat C.struct_bpf_stat
   248  
   249  type BpfProgram C.struct_bpf_program
   250  
   251  type BpfInsn C.struct_bpf_insn
   252  
   253  type BpfTimeval C.struct_bpf_timeval
   254  
   255  type BpfHdr C.struct_bpf_hdr
   256  
   257  // Terminal handling
   258  
   259  type Termios C.struct_termios
   260  
   261  type Termio C.struct_termio
   262  
   263  type Winsize C.struct_winsize
   264  
   265  // poll
   266  
   267  type PollFd C.struct_pollfd
   268  
   269  const (
   270  	POLLERR    = C.POLLERR
   271  	POLLHUP    = C.POLLHUP
   272  	POLLIN     = C.POLLIN
   273  	POLLNVAL   = C.POLLNVAL
   274  	POLLOUT    = C.POLLOUT
   275  	POLLPRI    = C.POLLPRI
   276  	POLLRDBAND = C.POLLRDBAND
   277  	POLLRDNORM = C.POLLRDNORM
   278  	POLLWRBAND = C.POLLWRBAND
   279  	POLLWRNORM = C.POLLWRNORM
   280  )
   281  
   282  // Event Ports
   283  
   284  type fileObj C.struct_file_obj
   285  
   286  type portEvent C.struct_port_event
   287  
   288  const (
   289  	PORT_SOURCE_AIO    = C.PORT_SOURCE_AIO
   290  	PORT_SOURCE_TIMER  = C.PORT_SOURCE_TIMER
   291  	PORT_SOURCE_USER   = C.PORT_SOURCE_USER
   292  	PORT_SOURCE_FD     = C.PORT_SOURCE_FD
   293  	PORT_SOURCE_ALERT  = C.PORT_SOURCE_ALERT
   294  	PORT_SOURCE_MQ     = C.PORT_SOURCE_MQ
   295  	PORT_SOURCE_FILE   = C.PORT_SOURCE_FILE
   296  	PORT_ALERT_SET     = C.PORT_ALERT_SET
   297  	PORT_ALERT_UPDATE  = C.PORT_ALERT_UPDATE
   298  	PORT_ALERT_INVALID = C.PORT_ALERT_INVALID
   299  	FILE_ACCESS        = C.FILE_ACCESS
   300  	FILE_MODIFIED      = C.FILE_MODIFIED
   301  	FILE_ATTRIB        = C.FILE_ATTRIB
   302  	FILE_TRUNC         = C.FILE_TRUNC
   303  	FILE_NOFOLLOW      = C.FILE_NOFOLLOW
   304  	FILE_DELETE        = C.FILE_DELETE
   305  	FILE_RENAME_TO     = C.FILE_RENAME_TO
   306  	FILE_RENAME_FROM   = C.FILE_RENAME_FROM
   307  	UNMOUNTED          = C.UNMOUNTED
   308  	MOUNTEDOVER        = C.MOUNTEDOVER
   309  	FILE_EXCEPTION     = C.FILE_EXCEPTION
   310  )
   311  
   312  // STREAMS and Tun
   313  
   314  const (
   315  	TUNNEWPPA = C.TUNNEWPPA
   316  	TUNSETPPA = C.TUNSETPPA
   317  
   318  	// sys/stropts.h:
   319  	I_STR     = C.I_STR
   320  	I_POP     = C.I_POP
   321  	I_PUSH    = C.I_PUSH
   322  	I_LINK    = C.I_LINK
   323  	I_UNLINK  = C.I_UNLINK
   324  	I_PLINK   = C.I_PLINK
   325  	I_PUNLINK = C.I_PUNLINK
   326  
   327  	// sys/sockio.h:
   328  	IF_UNITSEL = C.IF_UNITSEL
   329  )
   330  
   331  type strbuf C.struct_strbuf
   332  
   333  type Strioctl C.struct_strioctl
   334  
   335  type Lifreq C.struct_lifreq