github.com/kooksee/kchain@v0.0.0-20180613035215-4aef51c04906/src/golang.org/x/sys/unix/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 README.md 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 unix 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 // Advice to Fadvise 214 215 const ( 216 FADV_NORMAL = C.POSIX_FADV_NORMAL 217 FADV_RANDOM = C.POSIX_FADV_RANDOM 218 FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL 219 FADV_WILLNEED = C.POSIX_FADV_WILLNEED 220 FADV_DONTNEED = C.POSIX_FADV_DONTNEED 221 FADV_NOREUSE = C.POSIX_FADV_NOREUSE 222 ) 223 224 // Sockets 225 226 type RawSockaddrInet4 C.struct_sockaddr_in 227 228 type RawSockaddrInet6 C.struct_sockaddr_in6 229 230 type RawSockaddrUnix C.struct_sockaddr_un 231 232 type RawSockaddrDatalink C.struct_sockaddr_dl 233 234 type RawSockaddr C.struct_sockaddr 235 236 type RawSockaddrAny C.struct_sockaddr_any 237 238 type _Socklen C.socklen_t 239 240 type Linger C.struct_linger 241 242 type Iovec C.struct_iovec 243 244 type IPMreq C.struct_ip_mreq 245 246 type IPMreqn C.struct_ip_mreqn 247 248 type IPv6Mreq C.struct_ipv6_mreq 249 250 type Msghdr C.struct_msghdr 251 252 type Cmsghdr C.struct_cmsghdr 253 254 type Inet6Pktinfo C.struct_in6_pktinfo 255 256 type IPv6MTUInfo C.struct_ip6_mtuinfo 257 258 type ICMPv6Filter C.struct_icmp6_filter 259 260 const ( 261 SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 262 SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 263 SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 264 SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 265 SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 266 SizeofLinger = C.sizeof_struct_linger 267 SizeofIPMreq = C.sizeof_struct_ip_mreq 268 SizeofIPMreqn = C.sizeof_struct_ip_mreqn 269 SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 270 SizeofMsghdr = C.sizeof_struct_msghdr 271 SizeofCmsghdr = C.sizeof_struct_cmsghdr 272 SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 273 SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 274 SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 275 ) 276 277 // Ptrace requests 278 279 const ( 280 PTRACE_TRACEME = C.PT_TRACE_ME 281 PTRACE_CONT = C.PT_CONTINUE 282 PTRACE_KILL = C.PT_KILL 283 ) 284 285 // Events (kqueue, kevent) 286 287 type Kevent_t C.struct_kevent 288 289 // Select 290 291 type FdSet C.fd_set 292 293 // Routing and interface messages 294 295 const ( 296 sizeofIfMsghdr = C.sizeof_struct_if_msghdr 297 SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 298 sizeofIfData = C.sizeof_struct_if_data 299 SizeofIfData = C.sizeof_struct_if_data8 300 SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 301 SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 302 SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 303 SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 304 SizeofRtMetrics = C.sizeof_struct_rt_metrics 305 ) 306 307 type ifMsghdr C.struct_if_msghdr 308 309 type IfMsghdr C.struct_if_msghdr8 310 311 type ifData C.struct_if_data 312 313 type IfData C.struct_if_data8 314 315 type IfaMsghdr C.struct_ifa_msghdr 316 317 type IfmaMsghdr C.struct_ifma_msghdr 318 319 type IfAnnounceMsghdr C.struct_if_announcemsghdr 320 321 type RtMsghdr C.struct_rt_msghdr 322 323 type RtMetrics C.struct_rt_metrics 324 325 // Berkeley packet filter 326 327 const ( 328 SizeofBpfVersion = C.sizeof_struct_bpf_version 329 SizeofBpfStat = C.sizeof_struct_bpf_stat 330 SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf 331 SizeofBpfProgram = C.sizeof_struct_bpf_program 332 SizeofBpfInsn = C.sizeof_struct_bpf_insn 333 SizeofBpfHdr = C.sizeof_struct_bpf_hdr 334 SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header 335 ) 336 337 type BpfVersion C.struct_bpf_version 338 339 type BpfStat C.struct_bpf_stat 340 341 type BpfZbuf C.struct_bpf_zbuf 342 343 type BpfProgram C.struct_bpf_program 344 345 type BpfInsn C.struct_bpf_insn 346 347 type BpfHdr C.struct_bpf_hdr 348 349 type BpfZbufHeader C.struct_bpf_zbuf_header 350 351 // Terminal handling 352 353 type Termios C.struct_termios