github.com/fjballest/golang@v0.0.0-20151209143359-e4c5fe594ca8/src/syscall/types_linux.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 _LARGEFILE_SOURCE
    18  #define _LARGEFILE64_SOURCE
    19  #define _FILE_OFFSET_BITS 64
    20  #define _GNU_SOURCE
    21  
    22  #include <dirent.h>
    23  #include <fcntl.h>
    24  #include <netinet/in.h>
    25  #include <netinet/tcp.h>
    26  #include <netpacket/packet.h>
    27  #include <signal.h>
    28  #include <stdio.h>
    29  #include <sys/epoll.h>
    30  #include <sys/inotify.h>
    31  #include <sys/mman.h>
    32  #include <sys/mount.h>
    33  #include <sys/param.h>
    34  #include <sys/ptrace.h>
    35  #include <sys/resource.h>
    36  #include <sys/select.h>
    37  #include <sys/signal.h>
    38  #include <sys/stat.h>
    39  #include <sys/statfs.h>
    40  #include <sys/sysinfo.h>
    41  #include <sys/time.h>
    42  #include <sys/times.h>
    43  #include <sys/timex.h>
    44  #include <sys/types.h>
    45  #include <sys/un.h>
    46  #include <sys/user.h>
    47  #include <sys/utsname.h>
    48  #include <sys/wait.h>
    49  #include <linux/filter.h>
    50  #include <linux/netlink.h>
    51  #include <linux/rtnetlink.h>
    52  #include <linux/icmpv6.h>
    53  #include <termios.h>
    54  #include <time.h>
    55  #include <unistd.h>
    56  #include <ustat.h>
    57  #include <utime.h>
    58  
    59  enum {
    60  	sizeofPtr = sizeof(void*),
    61  };
    62  
    63  union sockaddr_all {
    64  	struct sockaddr s1;	// this one gets used for fields
    65  	struct sockaddr_in s2;	// these pad it out
    66  	struct sockaddr_in6 s3;
    67  	struct sockaddr_un s4;
    68  	struct sockaddr_ll s5;
    69  	struct sockaddr_nl s6;
    70  };
    71  
    72  struct sockaddr_any {
    73  	struct sockaddr addr;
    74  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    75  };
    76  
    77  // copied from /usr/include/linux/un.h
    78  struct my_sockaddr_un {
    79  	sa_family_t sun_family;
    80  #if defined(__ARM_EABI__) || defined(__powerpc64__)
    81  	// on ARM and PPC char is by default unsigned
    82  	signed char sun_path[108];
    83  #else
    84  	char sun_path[108];
    85  #endif
    86  };
    87  
    88  #ifdef __ARM_EABI__
    89  typedef struct user_regs PtraceRegs;
    90  #elif defined(__aarch64__)
    91  typedef struct user_pt_regs PtraceRegs;
    92  #elif defined(__powerpc64__)
    93  typedef struct pt_regs PtraceRegs;
    94  #elif defined(__mips__)
    95  typedef struct user PtraceRegs;
    96  #else
    97  typedef struct user_regs_struct PtraceRegs;
    98  #endif
    99  
   100  // The real epoll_event is a union, and godefs doesn't handle it well.
   101  struct my_epoll_event {
   102  	uint32_t events;
   103  #ifdef __ARM_EABI__
   104  	// padding is not specified in linux/eventpoll.h but added to conform to the
   105  	// alignment requirements of EABI
   106  	int32_t padFd;
   107  #endif
   108  	int32_t fd;
   109  	int32_t pad;
   110  };
   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  	PathMax        = C.PATH_MAX
   124  )
   125  
   126  // Basic types
   127  
   128  type (
   129  	_C_short     C.short
   130  	_C_int       C.int
   131  	_C_long      C.long
   132  	_C_long_long C.longlong
   133  )
   134  
   135  // Time
   136  
   137  type Timespec C.struct_timespec
   138  
   139  type Timeval C.struct_timeval
   140  
   141  type Timex C.struct_timex
   142  
   143  type Time_t C.time_t
   144  
   145  type Tms C.struct_tms
   146  
   147  type Utimbuf C.struct_utimbuf
   148  
   149  // Processes
   150  
   151  type Rusage C.struct_rusage
   152  
   153  type Rlimit C.struct_rlimit
   154  
   155  type _Gid_t C.gid_t
   156  
   157  // Files
   158  
   159  type Stat_t C.struct_stat
   160  
   161  type Statfs_t C.struct_statfs
   162  
   163  type Dirent C.struct_dirent
   164  
   165  type Fsid C.fsid_t
   166  
   167  type Flock_t C.struct_flock
   168  
   169  // Sockets
   170  
   171  type RawSockaddrInet4 C.struct_sockaddr_in
   172  
   173  type RawSockaddrInet6 C.struct_sockaddr_in6
   174  
   175  type RawSockaddrUnix C.struct_my_sockaddr_un
   176  
   177  type RawSockaddrLinklayer C.struct_sockaddr_ll
   178  
   179  type RawSockaddrNetlink C.struct_sockaddr_nl
   180  
   181  type RawSockaddr C.struct_sockaddr
   182  
   183  type RawSockaddrAny C.struct_sockaddr_any
   184  
   185  type _Socklen C.socklen_t
   186  
   187  type Linger C.struct_linger
   188  
   189  type Iovec C.struct_iovec
   190  
   191  type IPMreq C.struct_ip_mreq
   192  
   193  type IPMreqn C.struct_ip_mreqn
   194  
   195  type IPv6Mreq C.struct_ipv6_mreq
   196  
   197  type Msghdr C.struct_msghdr
   198  
   199  type Cmsghdr C.struct_cmsghdr
   200  
   201  type Inet4Pktinfo C.struct_in_pktinfo
   202  
   203  type Inet6Pktinfo C.struct_in6_pktinfo
   204  
   205  type IPv6MTUInfo C.struct_ip6_mtuinfo
   206  
   207  type ICMPv6Filter C.struct_icmp6_filter
   208  
   209  type Ucred C.struct_ucred
   210  
   211  type TCPInfo C.struct_tcp_info
   212  
   213  const (
   214  	SizeofSockaddrInet4     = C.sizeof_struct_sockaddr_in
   215  	SizeofSockaddrInet6     = C.sizeof_struct_sockaddr_in6
   216  	SizeofSockaddrAny       = C.sizeof_struct_sockaddr_any
   217  	SizeofSockaddrUnix      = C.sizeof_struct_sockaddr_un
   218  	SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll
   219  	SizeofSockaddrNetlink   = C.sizeof_struct_sockaddr_nl
   220  	SizeofLinger            = C.sizeof_struct_linger
   221  	SizeofIPMreq            = C.sizeof_struct_ip_mreq
   222  	SizeofIPMreqn           = C.sizeof_struct_ip_mreqn
   223  	SizeofIPv6Mreq          = C.sizeof_struct_ipv6_mreq
   224  	SizeofMsghdr            = C.sizeof_struct_msghdr
   225  	SizeofCmsghdr           = C.sizeof_struct_cmsghdr
   226  	SizeofInet4Pktinfo      = C.sizeof_struct_in_pktinfo
   227  	SizeofInet6Pktinfo      = C.sizeof_struct_in6_pktinfo
   228  	SizeofIPv6MTUInfo       = C.sizeof_struct_ip6_mtuinfo
   229  	SizeofICMPv6Filter      = C.sizeof_struct_icmp6_filter
   230  	SizeofUcred             = C.sizeof_struct_ucred
   231  	SizeofTCPInfo           = C.sizeof_struct_tcp_info
   232  )
   233  
   234  // Netlink routing and interface messages
   235  
   236  const (
   237  	IFA_UNSPEC          = C.IFA_UNSPEC
   238  	IFA_ADDRESS         = C.IFA_ADDRESS
   239  	IFA_LOCAL           = C.IFA_LOCAL
   240  	IFA_LABEL           = C.IFA_LABEL
   241  	IFA_BROADCAST       = C.IFA_BROADCAST
   242  	IFA_ANYCAST         = C.IFA_ANYCAST
   243  	IFA_CACHEINFO       = C.IFA_CACHEINFO
   244  	IFA_MULTICAST       = C.IFA_MULTICAST
   245  	IFLA_UNSPEC         = C.IFLA_UNSPEC
   246  	IFLA_ADDRESS        = C.IFLA_ADDRESS
   247  	IFLA_BROADCAST      = C.IFLA_BROADCAST
   248  	IFLA_IFNAME         = C.IFLA_IFNAME
   249  	IFLA_MTU            = C.IFLA_MTU
   250  	IFLA_LINK           = C.IFLA_LINK
   251  	IFLA_QDISC          = C.IFLA_QDISC
   252  	IFLA_STATS          = C.IFLA_STATS
   253  	IFLA_COST           = C.IFLA_COST
   254  	IFLA_PRIORITY       = C.IFLA_PRIORITY
   255  	IFLA_MASTER         = C.IFLA_MASTER
   256  	IFLA_WIRELESS       = C.IFLA_WIRELESS
   257  	IFLA_PROTINFO       = C.IFLA_PROTINFO
   258  	IFLA_TXQLEN         = C.IFLA_TXQLEN
   259  	IFLA_MAP            = C.IFLA_MAP
   260  	IFLA_WEIGHT         = C.IFLA_WEIGHT
   261  	IFLA_OPERSTATE      = C.IFLA_OPERSTATE
   262  	IFLA_LINKMODE       = C.IFLA_LINKMODE
   263  	IFLA_LINKINFO       = C.IFLA_LINKINFO
   264  	IFLA_NET_NS_PID     = C.IFLA_NET_NS_PID
   265  	IFLA_IFALIAS        = C.IFLA_IFALIAS
   266  	IFLA_MAX            = C.IFLA_MAX
   267  	RT_SCOPE_UNIVERSE   = C.RT_SCOPE_UNIVERSE
   268  	RT_SCOPE_SITE       = C.RT_SCOPE_SITE
   269  	RT_SCOPE_LINK       = C.RT_SCOPE_LINK
   270  	RT_SCOPE_HOST       = C.RT_SCOPE_HOST
   271  	RT_SCOPE_NOWHERE    = C.RT_SCOPE_NOWHERE
   272  	RT_TABLE_UNSPEC     = C.RT_TABLE_UNSPEC
   273  	RT_TABLE_COMPAT     = C.RT_TABLE_COMPAT
   274  	RT_TABLE_DEFAULT    = C.RT_TABLE_DEFAULT
   275  	RT_TABLE_MAIN       = C.RT_TABLE_MAIN
   276  	RT_TABLE_LOCAL      = C.RT_TABLE_LOCAL
   277  	RT_TABLE_MAX        = C.RT_TABLE_MAX
   278  	RTA_UNSPEC          = C.RTA_UNSPEC
   279  	RTA_DST             = C.RTA_DST
   280  	RTA_SRC             = C.RTA_SRC
   281  	RTA_IIF             = C.RTA_IIF
   282  	RTA_OIF             = C.RTA_OIF
   283  	RTA_GATEWAY         = C.RTA_GATEWAY
   284  	RTA_PRIORITY        = C.RTA_PRIORITY
   285  	RTA_PREFSRC         = C.RTA_PREFSRC
   286  	RTA_METRICS         = C.RTA_METRICS
   287  	RTA_MULTIPATH       = C.RTA_MULTIPATH
   288  	RTA_FLOW            = C.RTA_FLOW
   289  	RTA_CACHEINFO       = C.RTA_CACHEINFO
   290  	RTA_TABLE           = C.RTA_TABLE
   291  	RTN_UNSPEC          = C.RTN_UNSPEC
   292  	RTN_UNICAST         = C.RTN_UNICAST
   293  	RTN_LOCAL           = C.RTN_LOCAL
   294  	RTN_BROADCAST       = C.RTN_BROADCAST
   295  	RTN_ANYCAST         = C.RTN_ANYCAST
   296  	RTN_MULTICAST       = C.RTN_MULTICAST
   297  	RTN_BLACKHOLE       = C.RTN_BLACKHOLE
   298  	RTN_UNREACHABLE     = C.RTN_UNREACHABLE
   299  	RTN_PROHIBIT        = C.RTN_PROHIBIT
   300  	RTN_THROW           = C.RTN_THROW
   301  	RTN_NAT             = C.RTN_NAT
   302  	RTN_XRESOLVE        = C.RTN_XRESOLVE
   303  	RTNLGRP_NONE        = C.RTNLGRP_NONE
   304  	RTNLGRP_LINK        = C.RTNLGRP_LINK
   305  	RTNLGRP_NOTIFY      = C.RTNLGRP_NOTIFY
   306  	RTNLGRP_NEIGH       = C.RTNLGRP_NEIGH
   307  	RTNLGRP_TC          = C.RTNLGRP_TC
   308  	RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR
   309  	RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE
   310  	RTNLGRP_IPV4_ROUTE  = C.RTNLGRP_IPV4_ROUTE
   311  	RTNLGRP_IPV4_RULE   = C.RTNLGRP_IPV4_RULE
   312  	RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR
   313  	RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE
   314  	RTNLGRP_IPV6_ROUTE  = C.RTNLGRP_IPV6_ROUTE
   315  	RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO
   316  	RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX
   317  	RTNLGRP_IPV6_RULE   = C.RTNLGRP_IPV6_RULE
   318  	RTNLGRP_ND_USEROPT  = C.RTNLGRP_ND_USEROPT
   319  	SizeofNlMsghdr      = C.sizeof_struct_nlmsghdr
   320  	SizeofNlMsgerr      = C.sizeof_struct_nlmsgerr
   321  	SizeofRtGenmsg      = C.sizeof_struct_rtgenmsg
   322  	SizeofNlAttr        = C.sizeof_struct_nlattr
   323  	SizeofRtAttr        = C.sizeof_struct_rtattr
   324  	SizeofIfInfomsg     = C.sizeof_struct_ifinfomsg
   325  	SizeofIfAddrmsg     = C.sizeof_struct_ifaddrmsg
   326  	SizeofRtMsg         = C.sizeof_struct_rtmsg
   327  	SizeofRtNexthop     = C.sizeof_struct_rtnexthop
   328  )
   329  
   330  type NlMsghdr C.struct_nlmsghdr
   331  
   332  type NlMsgerr C.struct_nlmsgerr
   333  
   334  type RtGenmsg C.struct_rtgenmsg
   335  
   336  type NlAttr C.struct_nlattr
   337  
   338  type RtAttr C.struct_rtattr
   339  
   340  type IfInfomsg C.struct_ifinfomsg
   341  
   342  type IfAddrmsg C.struct_ifaddrmsg
   343  
   344  type RtMsg C.struct_rtmsg
   345  
   346  type RtNexthop C.struct_rtnexthop
   347  
   348  // Linux socket filter
   349  
   350  const (
   351  	SizeofSockFilter = C.sizeof_struct_sock_filter
   352  	SizeofSockFprog  = C.sizeof_struct_sock_fprog
   353  )
   354  
   355  type SockFilter C.struct_sock_filter
   356  
   357  type SockFprog C.struct_sock_fprog
   358  
   359  // Inotify
   360  
   361  type InotifyEvent C.struct_inotify_event
   362  
   363  const SizeofInotifyEvent = C.sizeof_struct_inotify_event
   364  
   365  // Ptrace
   366  
   367  // Register structures
   368  type PtraceRegs C.PtraceRegs
   369  
   370  // Misc
   371  
   372  type FdSet C.fd_set
   373  
   374  type Sysinfo_t C.struct_sysinfo
   375  
   376  type Utsname C.struct_utsname
   377  
   378  type Ustat_t C.struct_ustat
   379  
   380  type EpollEvent C.struct_my_epoll_event
   381  
   382  const (
   383  	_AT_FDCWD            = C.AT_FDCWD
   384  	_AT_REMOVEDIR        = C.AT_REMOVEDIR
   385  	_AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
   386  )
   387  
   388  // Terminal handling
   389  
   390  type Termios C.struct_termios
   391  
   392  const (
   393  	IUCLC  = C.IUCLC
   394  	OLCUC  = C.OLCUC
   395  	TCGETS = C.TCGETS
   396  	TCSETS = C.TCSETS
   397  	XCASE  = C.XCASE
   398  )