You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

243 lines
4.9 KiB

  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. // +build ignore
  5. /*
  6. Input to cgo -godefs. See also mkerrors.sh and mkall.sh
  7. */
  8. // +godefs map struct_in_addr [4]byte /* in_addr */
  9. // +godefs map struct_in6_addr [16]byte /* in6_addr */
  10. package unix
  11. /*
  12. #define KERNEL
  13. #include <dirent.h>
  14. #include <fcntl.h>
  15. #include <signal.h>
  16. #include <termios.h>
  17. #include <stdio.h>
  18. #include <unistd.h>
  19. #include <sys/event.h>
  20. #include <sys/mman.h>
  21. #include <sys/mount.h>
  22. #include <sys/param.h>
  23. #include <sys/ptrace.h>
  24. #include <sys/resource.h>
  25. #include <sys/select.h>
  26. #include <sys/signal.h>
  27. #include <sys/socket.h>
  28. #include <sys/stat.h>
  29. #include <sys/time.h>
  30. #include <sys/types.h>
  31. #include <sys/un.h>
  32. #include <sys/wait.h>
  33. #include <net/bpf.h>
  34. #include <net/if.h>
  35. #include <net/if_dl.h>
  36. #include <net/route.h>
  37. #include <netinet/in.h>
  38. #include <netinet/icmp6.h>
  39. #include <netinet/tcp.h>
  40. enum {
  41. sizeofPtr = sizeof(void*),
  42. };
  43. union sockaddr_all {
  44. struct sockaddr s1; // this one gets used for fields
  45. struct sockaddr_in s2; // these pad it out
  46. struct sockaddr_in6 s3;
  47. struct sockaddr_un s4;
  48. struct sockaddr_dl s5;
  49. };
  50. struct sockaddr_any {
  51. struct sockaddr addr;
  52. char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
  53. };
  54. */
  55. import "C"
  56. // Machine characteristics; for internal use.
  57. const (
  58. sizeofPtr = C.sizeofPtr
  59. sizeofShort = C.sizeof_short
  60. sizeofInt = C.sizeof_int
  61. sizeofLong = C.sizeof_long
  62. sizeofLongLong = C.sizeof_longlong
  63. )
  64. // Basic types
  65. type (
  66. _C_short C.short
  67. _C_int C.int
  68. _C_long C.long
  69. _C_long_long C.longlong
  70. )
  71. // Time
  72. type Timespec C.struct_timespec
  73. type Timeval C.struct_timeval
  74. // Processes
  75. type Rusage C.struct_rusage
  76. type Rlimit C.struct_rlimit
  77. type _Gid_t C.gid_t
  78. // Files
  79. const ( // Directory mode bits
  80. S_IFMT = C.S_IFMT
  81. S_IFIFO = C.S_IFIFO
  82. S_IFCHR = C.S_IFCHR
  83. S_IFDIR = C.S_IFDIR
  84. S_IFBLK = C.S_IFBLK
  85. S_IFREG = C.S_IFREG
  86. S_IFLNK = C.S_IFLNK
  87. S_IFSOCK = C.S_IFSOCK
  88. S_ISUID = C.S_ISUID
  89. S_ISGID = C.S_ISGID
  90. S_ISVTX = C.S_ISVTX
  91. S_IRUSR = C.S_IRUSR
  92. S_IWUSR = C.S_IWUSR
  93. S_IXUSR = C.S_IXUSR
  94. )
  95. type Stat_t C.struct_stat
  96. type Statfs_t C.struct_statfs
  97. type Flock_t C.struct_flock
  98. type Dirent C.struct_dirent
  99. type Fsid C.struct_fsid
  100. // Sockets
  101. type RawSockaddrInet4 C.struct_sockaddr_in
  102. type RawSockaddrInet6 C.struct_sockaddr_in6
  103. type RawSockaddrUnix C.struct_sockaddr_un
  104. type RawSockaddrDatalink C.struct_sockaddr_dl
  105. type RawSockaddr C.struct_sockaddr
  106. type RawSockaddrAny C.struct_sockaddr_any
  107. type _Socklen C.socklen_t
  108. type Linger C.struct_linger
  109. type Iovec C.struct_iovec
  110. type IPMreq C.struct_ip_mreq
  111. type IPv6Mreq C.struct_ipv6_mreq
  112. type Msghdr C.struct_msghdr
  113. type Cmsghdr C.struct_cmsghdr
  114. type Inet6Pktinfo C.struct_in6_pktinfo
  115. type IPv6MTUInfo C.struct_ip6_mtuinfo
  116. type ICMPv6Filter C.struct_icmp6_filter
  117. const (
  118. SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
  119. SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
  120. SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
  121. SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
  122. SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
  123. SizeofLinger = C.sizeof_struct_linger
  124. SizeofIPMreq = C.sizeof_struct_ip_mreq
  125. SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
  126. SizeofMsghdr = C.sizeof_struct_msghdr
  127. SizeofCmsghdr = C.sizeof_struct_cmsghdr
  128. SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
  129. SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
  130. SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
  131. )
  132. // Ptrace requests
  133. const (
  134. PTRACE_TRACEME = C.PT_TRACE_ME
  135. PTRACE_CONT = C.PT_CONTINUE
  136. PTRACE_KILL = C.PT_KILL
  137. )
  138. // Events (kqueue, kevent)
  139. type Kevent_t C.struct_kevent
  140. // Select
  141. type FdSet C.fd_set
  142. // Routing and interface messages
  143. const (
  144. SizeofIfMsghdr = C.sizeof_struct_if_msghdr
  145. SizeofIfData = C.sizeof_struct_if_data
  146. SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
  147. SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
  148. SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
  149. SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
  150. SizeofRtMetrics = C.sizeof_struct_rt_metrics
  151. )
  152. type IfMsghdr C.struct_if_msghdr
  153. type IfData C.struct_if_data
  154. type IfaMsghdr C.struct_ifa_msghdr
  155. type IfmaMsghdr C.struct_ifma_msghdr
  156. type IfAnnounceMsghdr C.struct_if_announcemsghdr
  157. type RtMsghdr C.struct_rt_msghdr
  158. type RtMetrics C.struct_rt_metrics
  159. // Berkeley packet filter
  160. const (
  161. SizeofBpfVersion = C.sizeof_struct_bpf_version
  162. SizeofBpfStat = C.sizeof_struct_bpf_stat
  163. SizeofBpfProgram = C.sizeof_struct_bpf_program
  164. SizeofBpfInsn = C.sizeof_struct_bpf_insn
  165. SizeofBpfHdr = C.sizeof_struct_bpf_hdr
  166. )
  167. type BpfVersion C.struct_bpf_version
  168. type BpfStat C.struct_bpf_stat
  169. type BpfProgram C.struct_bpf_program
  170. type BpfInsn C.struct_bpf_insn
  171. type BpfHdr C.struct_bpf_hdr
  172. // Terminal handling
  173. type Termios C.struct_termios