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.

types_freebsd.go 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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 README.md
  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 _WANT_FREEBSD11_STAT 1
  13. #define _WANT_FREEBSD11_STATFS 1
  14. #define _WANT_FREEBSD11_DIRENT 1
  15. #define _WANT_FREEBSD11_KEVENT 1
  16. #include <dirent.h>
  17. #include <fcntl.h>
  18. #include <poll.h>
  19. #include <signal.h>
  20. #include <termios.h>
  21. #include <stdio.h>
  22. #include <unistd.h>
  23. #include <sys/capsicum.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/utsname.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. enum {
  47. sizeofPtr = sizeof(void*),
  48. };
  49. union sockaddr_all {
  50. struct sockaddr s1; // this one gets used for fields
  51. struct sockaddr_in s2; // these pad it out
  52. struct sockaddr_in6 s3;
  53. struct sockaddr_un s4;
  54. struct sockaddr_dl s5;
  55. };
  56. struct sockaddr_any {
  57. struct sockaddr addr;
  58. char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
  59. };
  60. // This structure is a duplicate of if_data on FreeBSD 8-STABLE.
  61. // See /usr/include/net/if.h.
  62. struct if_data8 {
  63. u_char ifi_type;
  64. u_char ifi_physical;
  65. u_char ifi_addrlen;
  66. u_char ifi_hdrlen;
  67. u_char ifi_link_state;
  68. u_char ifi_spare_char1;
  69. u_char ifi_spare_char2;
  70. u_char ifi_datalen;
  71. u_long ifi_mtu;
  72. u_long ifi_metric;
  73. u_long ifi_baudrate;
  74. u_long ifi_ipackets;
  75. u_long ifi_ierrors;
  76. u_long ifi_opackets;
  77. u_long ifi_oerrors;
  78. u_long ifi_collisions;
  79. u_long ifi_ibytes;
  80. u_long ifi_obytes;
  81. u_long ifi_imcasts;
  82. u_long ifi_omcasts;
  83. u_long ifi_iqdrops;
  84. u_long ifi_noproto;
  85. u_long ifi_hwassist;
  86. // FIXME: these are now unions, so maybe need to change definitions?
  87. #undef ifi_epoch
  88. time_t ifi_epoch;
  89. #undef ifi_lastchange
  90. struct timeval ifi_lastchange;
  91. };
  92. // This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
  93. // See /usr/include/net/if.h.
  94. struct if_msghdr8 {
  95. u_short ifm_msglen;
  96. u_char ifm_version;
  97. u_char ifm_type;
  98. int ifm_addrs;
  99. int ifm_flags;
  100. u_short ifm_index;
  101. struct if_data8 ifm_data;
  102. };
  103. */
  104. import "C"
  105. // Machine characteristics
  106. const (
  107. SizeofPtr = C.sizeofPtr
  108. SizeofShort = C.sizeof_short
  109. SizeofInt = C.sizeof_int
  110. SizeofLong = C.sizeof_long
  111. SizeofLongLong = C.sizeof_longlong
  112. )
  113. // Basic types
  114. type (
  115. _C_short C.short
  116. _C_int C.int
  117. _C_long C.long
  118. _C_long_long C.longlong
  119. )
  120. // Time
  121. type Timespec C.struct_timespec
  122. type Timeval C.struct_timeval
  123. // Processes
  124. type Rusage C.struct_rusage
  125. type Rlimit C.struct_rlimit
  126. type _Gid_t C.gid_t
  127. // Files
  128. const (
  129. _statfsVersion = C.STATFS_VERSION
  130. _dirblksiz = C.DIRBLKSIZ
  131. )
  132. type Stat_t C.struct_stat
  133. type stat_freebsd11_t C.struct_freebsd11_stat
  134. type Statfs_t C.struct_statfs
  135. type statfs_freebsd11_t C.struct_freebsd11_statfs
  136. type Flock_t C.struct_flock
  137. type Dirent C.struct_dirent
  138. type dirent_freebsd11 C.struct_freebsd11_dirent
  139. type Fsid C.struct_fsid
  140. // File system limits
  141. const (
  142. PathMax = C.PATH_MAX
  143. )
  144. // Advice to Fadvise
  145. const (
  146. FADV_NORMAL = C.POSIX_FADV_NORMAL
  147. FADV_RANDOM = C.POSIX_FADV_RANDOM
  148. FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
  149. FADV_WILLNEED = C.POSIX_FADV_WILLNEED
  150. FADV_DONTNEED = C.POSIX_FADV_DONTNEED
  151. FADV_NOREUSE = C.POSIX_FADV_NOREUSE
  152. )
  153. // Sockets
  154. type RawSockaddrInet4 C.struct_sockaddr_in
  155. type RawSockaddrInet6 C.struct_sockaddr_in6
  156. type RawSockaddrUnix C.struct_sockaddr_un
  157. type RawSockaddrDatalink C.struct_sockaddr_dl
  158. type RawSockaddr C.struct_sockaddr
  159. type RawSockaddrAny C.struct_sockaddr_any
  160. type _Socklen C.socklen_t
  161. type Linger C.struct_linger
  162. type Iovec C.struct_iovec
  163. type IPMreq C.struct_ip_mreq
  164. type IPMreqn C.struct_ip_mreqn
  165. type IPv6Mreq C.struct_ipv6_mreq
  166. type Msghdr C.struct_msghdr
  167. type Cmsghdr C.struct_cmsghdr
  168. type Inet6Pktinfo C.struct_in6_pktinfo
  169. type IPv6MTUInfo C.struct_ip6_mtuinfo
  170. type ICMPv6Filter C.struct_icmp6_filter
  171. const (
  172. SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
  173. SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
  174. SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
  175. SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
  176. SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
  177. SizeofLinger = C.sizeof_struct_linger
  178. SizeofIPMreq = C.sizeof_struct_ip_mreq
  179. SizeofIPMreqn = C.sizeof_struct_ip_mreqn
  180. SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
  181. SizeofMsghdr = C.sizeof_struct_msghdr
  182. SizeofCmsghdr = C.sizeof_struct_cmsghdr
  183. SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
  184. SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
  185. SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
  186. )
  187. // Ptrace requests
  188. const (
  189. PTRACE_ATTACH = C.PT_ATTACH
  190. PTRACE_CONT = C.PT_CONTINUE
  191. PTRACE_DETACH = C.PT_DETACH
  192. PTRACE_GETFPREGS = C.PT_GETFPREGS
  193. PTRACE_GETFSBASE = C.PT_GETFSBASE
  194. PTRACE_GETLWPLIST = C.PT_GETLWPLIST
  195. PTRACE_GETNUMLWPS = C.PT_GETNUMLWPS
  196. PTRACE_GETREGS = C.PT_GETREGS
  197. PTRACE_GETXSTATE = C.PT_GETXSTATE
  198. PTRACE_IO = C.PT_IO
  199. PTRACE_KILL = C.PT_KILL
  200. PTRACE_LWPEVENTS = C.PT_LWP_EVENTS
  201. PTRACE_LWPINFO = C.PT_LWPINFO
  202. PTRACE_SETFPREGS = C.PT_SETFPREGS
  203. PTRACE_SETREGS = C.PT_SETREGS
  204. PTRACE_SINGLESTEP = C.PT_STEP
  205. PTRACE_TRACEME = C.PT_TRACE_ME
  206. )
  207. const (
  208. PIOD_READ_D = C.PIOD_READ_D
  209. PIOD_WRITE_D = C.PIOD_WRITE_D
  210. PIOD_READ_I = C.PIOD_READ_I
  211. PIOD_WRITE_I = C.PIOD_WRITE_I
  212. )
  213. const (
  214. PL_FLAG_BORN = C.PL_FLAG_BORN
  215. PL_FLAG_EXITED = C.PL_FLAG_EXITED
  216. PL_FLAG_SI = C.PL_FLAG_SI
  217. )
  218. const (
  219. TRAP_BRKPT = C.TRAP_BRKPT
  220. TRAP_TRACE = C.TRAP_TRACE
  221. )
  222. type PtraceLwpInfoStruct C.struct_ptrace_lwpinfo
  223. type __Siginfo C.struct___siginfo
  224. type Sigset_t C.sigset_t
  225. type Reg C.struct_reg
  226. type FpReg C.struct_fpreg
  227. type PtraceIoDesc C.struct_ptrace_io_desc
  228. // Events (kqueue, kevent)
  229. type Kevent_t C.struct_kevent_freebsd11
  230. // Select
  231. type FdSet C.fd_set
  232. // Routing and interface messages
  233. const (
  234. sizeofIfMsghdr = C.sizeof_struct_if_msghdr
  235. SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
  236. sizeofIfData = C.sizeof_struct_if_data
  237. SizeofIfData = C.sizeof_struct_if_data8
  238. SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
  239. SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
  240. SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
  241. SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
  242. SizeofRtMetrics = C.sizeof_struct_rt_metrics
  243. )
  244. type ifMsghdr C.struct_if_msghdr
  245. type IfMsghdr C.struct_if_msghdr8
  246. type ifData C.struct_if_data
  247. type IfData C.struct_if_data8
  248. type IfaMsghdr C.struct_ifa_msghdr
  249. type IfmaMsghdr C.struct_ifma_msghdr
  250. type IfAnnounceMsghdr C.struct_if_announcemsghdr
  251. type RtMsghdr C.struct_rt_msghdr
  252. type RtMetrics C.struct_rt_metrics
  253. // Berkeley packet filter
  254. const (
  255. SizeofBpfVersion = C.sizeof_struct_bpf_version
  256. SizeofBpfStat = C.sizeof_struct_bpf_stat
  257. SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf
  258. SizeofBpfProgram = C.sizeof_struct_bpf_program
  259. SizeofBpfInsn = C.sizeof_struct_bpf_insn
  260. SizeofBpfHdr = C.sizeof_struct_bpf_hdr
  261. SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
  262. )
  263. type BpfVersion C.struct_bpf_version
  264. type BpfStat C.struct_bpf_stat
  265. type BpfZbuf C.struct_bpf_zbuf
  266. type BpfProgram C.struct_bpf_program
  267. type BpfInsn C.struct_bpf_insn
  268. type BpfHdr C.struct_bpf_hdr
  269. type BpfZbufHeader C.struct_bpf_zbuf_header
  270. // Terminal handling
  271. type Termios C.struct_termios
  272. type Winsize C.struct_winsize
  273. // fchmodat-like syscalls.
  274. const (
  275. AT_FDCWD = C.AT_FDCWD
  276. AT_REMOVEDIR = C.AT_REMOVEDIR
  277. AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
  278. AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
  279. )
  280. // poll
  281. type PollFd C.struct_pollfd
  282. const (
  283. POLLERR = C.POLLERR
  284. POLLHUP = C.POLLHUP
  285. POLLIN = C.POLLIN
  286. POLLINIGNEOF = C.POLLINIGNEOF
  287. POLLNVAL = C.POLLNVAL
  288. POLLOUT = C.POLLOUT
  289. POLLPRI = C.POLLPRI
  290. POLLRDBAND = C.POLLRDBAND
  291. POLLRDNORM = C.POLLRDNORM
  292. POLLWRBAND = C.POLLWRBAND
  293. POLLWRNORM = C.POLLWRNORM
  294. )
  295. // Capabilities
  296. type CapRights C.struct_cap_rights
  297. // Uname
  298. type Utsname C.struct_utsname