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/* 8Input 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 14package 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/param.h> 25#include <sys/types.h> 26#include <sys/event.h> 27#include <sys/mman.h> 28#include <sys/mount.h> 29#include <sys/ptrace.h> 30#include <sys/resource.h> 31#include <sys/select.h> 32#include <sys/signal.h> 33#include <sys/socket.h> 34#include <sys/stat.h> 35#include <sys/sysctl.h> 36#include <sys/time.h> 37#include <sys/uio.h> 38#include <sys/un.h> 39#include <sys/wait.h> 40#include <net/bpf.h> 41#include <net/if.h> 42#include <net/if_dl.h> 43#include <net/route.h> 44#include <netinet/in.h> 45#include <netinet/icmp6.h> 46#include <netinet/tcp.h> 47 48enum { 49 sizeofPtr = sizeof(void*), 50}; 51 52union sockaddr_all { 53 struct sockaddr s1; // this one gets used for fields 54 struct sockaddr_in s2; // these pad it out 55 struct sockaddr_in6 s3; 56 struct sockaddr_un s4; 57 struct sockaddr_dl s5; 58}; 59 60struct sockaddr_any { 61 struct sockaddr addr; 62 char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 63}; 64 65*/ 66import "C" 67 68// Machine characteristics; for internal use. 69 70const ( 71 sizeofPtr = C.sizeofPtr 72 sizeofShort = C.sizeof_short 73 sizeofInt = C.sizeof_int 74 sizeofLong = C.sizeof_long 75 sizeofLongLong = C.sizeof_longlong 76) 77 78// Basic types 79 80type ( 81 _C_short C.short 82 _C_int C.int 83 _C_long C.long 84 _C_long_long C.longlong 85) 86 87// Time 88 89type Timespec C.struct_timespec 90 91type Timeval C.struct_timeval 92 93// Processes 94 95type Rusage C.struct_rusage 96 97type Rlimit C.struct_rlimit 98 99type _Gid_t C.gid_t 100 101// Files 102 103type Stat_t C.struct_stat 104 105type Statfs_t C.struct_statfs 106 107type Flock_t C.struct_flock 108 109type Dirent C.struct_dirent 110 111type Fsid C.fsid_t 112 113// Sockets 114 115type RawSockaddrInet4 C.struct_sockaddr_in 116 117type RawSockaddrInet6 C.struct_sockaddr_in6 118 119type RawSockaddrUnix C.struct_sockaddr_un 120 121type RawSockaddrDatalink C.struct_sockaddr_dl 122 123type RawSockaddr C.struct_sockaddr 124 125type RawSockaddrAny C.struct_sockaddr_any 126 127type _Socklen C.socklen_t 128 129type Linger C.struct_linger 130 131type Iovec C.struct_iovec 132 133type IPMreq C.struct_ip_mreq 134 135type IPv6Mreq C.struct_ipv6_mreq 136 137type Msghdr C.struct_msghdr 138 139type Cmsghdr C.struct_cmsghdr 140 141type Inet6Pktinfo C.struct_in6_pktinfo 142 143type IPv6MTUInfo C.struct_ip6_mtuinfo 144 145type ICMPv6Filter C.struct_icmp6_filter 146 147const ( 148 SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 149 SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 150 SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 151 SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 152 SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 153 SizeofLinger = C.sizeof_struct_linger 154 SizeofIPMreq = C.sizeof_struct_ip_mreq 155 SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 156 SizeofMsghdr = C.sizeof_struct_msghdr 157 SizeofCmsghdr = C.sizeof_struct_cmsghdr 158 SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 159 SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 160 SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 161) 162 163// Ptrace requests 164 165const ( 166 PTRACE_TRACEME = C.PT_TRACE_ME 167 PTRACE_CONT = C.PT_CONTINUE 168 PTRACE_KILL = C.PT_KILL 169) 170 171// Events (kqueue, kevent) 172 173type Kevent_t C.struct_kevent 174 175// Select 176 177type FdSet C.fd_set 178 179// Routing and interface messages 180 181const ( 182 SizeofIfMsghdr = C.sizeof_struct_if_msghdr 183 SizeofIfData = C.sizeof_struct_if_data 184 SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 185 SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 186 SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 187 SizeofRtMetrics = C.sizeof_struct_rt_metrics 188) 189 190type IfMsghdr C.struct_if_msghdr 191 192type IfData C.struct_if_data 193 194type IfaMsghdr C.struct_ifa_msghdr 195 196type IfAnnounceMsghdr C.struct_if_announcemsghdr 197 198type RtMsghdr C.struct_rt_msghdr 199 200type RtMetrics C.struct_rt_metrics 201 202type Mclpool C.struct_mclpool 203 204// Berkeley packet filter 205 206const ( 207 SizeofBpfVersion = C.sizeof_struct_bpf_version 208 SizeofBpfStat = C.sizeof_struct_bpf_stat 209 SizeofBpfProgram = C.sizeof_struct_bpf_program 210 SizeofBpfInsn = C.sizeof_struct_bpf_insn 211 SizeofBpfHdr = C.sizeof_struct_bpf_hdr 212) 213 214type BpfVersion C.struct_bpf_version 215 216type BpfStat C.struct_bpf_stat 217 218type BpfProgram C.struct_bpf_program 219 220type BpfInsn C.struct_bpf_insn 221 222type BpfHdr C.struct_bpf_hdr 223 224type BpfTimeval C.struct_bpf_timeval 225 226// Terminal handling 227 228type Termios C.struct_termios 229 230// Sysctl 231 232type Sysctlnode C.struct_sysctlnode 233