| ... | ... | @@ -80,9 +80,9 @@ const SIG_BLOCK = 0; |
| 80 | 80 | const SIG_UNBLOCK = 1; |
| 81 | 81 | const SIG_SETMASK = 2; |
| 82 | 82 | |
| 83 | | const SOCK_STREAM = 1; |
| 84 | | const SOCK_DGRAM = 2; |
| 85 | | const SOCK_RAW = 3; |
| 83 | pub const SOCK_STREAM = 1; |
| 84 | pub const SOCK_DGRAM = 2; |
| 85 | pub const SOCK_RAW = 3; |
| 86 | 86 | pub const SOCK_RDM = 4; |
| 87 | 87 | pub const SOCK_SEQPACKET = 5; |
| 88 | 88 | pub const SOCK_DCCP = 6; |
| ... | ... | @@ -91,6 +91,135 @@ pub const SOCK_CLOEXEC = 0o2000000; |
| 91 | 91 | pub const SOCK_NONBLOCK = 0o4000; |
| 92 | 92 | |
| 93 | 93 | |
| 94 | pub const PROTO_ip = 0o000; |
| 95 | pub const PROTO_icmp = 0o001; |
| 96 | pub const PROTO_igmp = 0o002; |
| 97 | pub const PROTO_ggp = 0o003; |
| 98 | pub const PROTO_ipencap = 0o004; |
| 99 | pub const PROTO_st = 0o005; |
| 100 | pub const PROTO_tcp = 0o006; |
| 101 | pub const PROTO_egp = 0o010; |
| 102 | pub const PROTO_pup = 0o014; |
| 103 | pub const PROTO_udp = 0o021; |
| 104 | pub const PROTO_hmp = 0o024; |
| 105 | pub const PROTO_xns_idp = 0o026; |
| 106 | pub const PROTO_rdp = 0o033; |
| 107 | pub const PROTO_iso_tp4 = 0o035; |
| 108 | pub const PROTO_xtp = 0o044; |
| 109 | pub const PROTO_ddp = 0o045; |
| 110 | pub const PROTO_idpr_cmtp = 0o046; |
| 111 | pub const PROTO_ipv6 = 0o051; |
| 112 | pub const PROTO_ipv6_route = 0o053; |
| 113 | pub const PROTO_ipv6_frag = 0o054; |
| 114 | pub const PROTO_idrp = 0o055; |
| 115 | pub const PROTO_rsvp = 0o056; |
| 116 | pub const PROTO_gre = 0o057; |
| 117 | pub const PROTO_esp = 0o062; |
| 118 | pub const PROTO_ah = 0o063; |
| 119 | pub const PROTO_skip = 0o071; |
| 120 | pub const PROTO_ipv6_icmp = 0o072; |
| 121 | pub const PROTO_ipv6_nonxt = 0o073; |
| 122 | pub const PROTO_ipv6_opts = 0o074; |
| 123 | pub const PROTO_rspf = 0o111; |
| 124 | pub const PROTO_vmtp = 0o121; |
| 125 | pub const PROTO_ospf = 0o131; |
| 126 | pub const PROTO_ipip = 0o136; |
| 127 | pub const PROTO_encap = 0o142; |
| 128 | pub const PROTO_pim = 0o147; |
| 129 | pub const PROTO_raw = 0o377; |
| 130 | |
| 131 | pub const PF_UNSPEC = 0; |
| 132 | pub const PF_LOCAL = 1; |
| 133 | pub const PF_UNIX = PF_LOCAL; |
| 134 | pub const PF_FILE = PF_LOCAL; |
| 135 | pub const PF_INET = 2; |
| 136 | pub const PF_AX25 = 3; |
| 137 | pub const PF_IPX = 4; |
| 138 | pub const PF_APPLETALK = 5; |
| 139 | pub const PF_NETROM = 6; |
| 140 | pub const PF_BRIDGE = 7; |
| 141 | pub const PF_ATMPVC = 8; |
| 142 | pub const PF_X25 = 9; |
| 143 | pub const PF_INET6 = 10; |
| 144 | pub const PF_ROSE = 11; |
| 145 | pub const PF_DECnet = 12; |
| 146 | pub const PF_NETBEUI = 13; |
| 147 | pub const PF_SECURITY = 14; |
| 148 | pub const PF_KEY = 15; |
| 149 | pub const PF_NETLINK = 16; |
| 150 | pub const PF_ROUTE = PF_NETLINK; |
| 151 | pub const PF_PACKET = 17; |
| 152 | pub const PF_ASH = 18; |
| 153 | pub const PF_ECONET = 19; |
| 154 | pub const PF_ATMSVC = 20; |
| 155 | pub const PF_RDS = 21; |
| 156 | pub const PF_SNA = 22; |
| 157 | pub const PF_IRDA = 23; |
| 158 | pub const PF_PPPOX = 24; |
| 159 | pub const PF_WANPIPE = 25; |
| 160 | pub const PF_LLC = 26; |
| 161 | pub const PF_IB = 27; |
| 162 | pub const PF_MPLS = 28; |
| 163 | pub const PF_CAN = 29; |
| 164 | pub const PF_TIPC = 30; |
| 165 | pub const PF_BLUETOOTH = 31; |
| 166 | pub const PF_IUCV = 32; |
| 167 | pub const PF_RXRPC = 33; |
| 168 | pub const PF_ISDN = 34; |
| 169 | pub const PF_PHONET = 35; |
| 170 | pub const PF_IEEE802154 = 36; |
| 171 | pub const PF_CAIF = 37; |
| 172 | pub const PF_ALG = 38; |
| 173 | pub const PF_NFC = 39; |
| 174 | pub const PF_VSOCK = 40; |
| 175 | pub const PF_MAX = 41; |
| 176 | |
| 177 | pub const AF_UNSPEC = PF_UNSPEC; |
| 178 | pub const AF_LOCAL = PF_LOCAL; |
| 179 | pub const AF_UNIX = AF_LOCAL; |
| 180 | pub const AF_FILE = AF_LOCAL; |
| 181 | pub const AF_INET = PF_INET; |
| 182 | pub const AF_AX25 = PF_AX25; |
| 183 | pub const AF_IPX = PF_IPX; |
| 184 | pub const AF_APPLETALK = PF_APPLETALK; |
| 185 | pub const AF_NETROM = PF_NETROM; |
| 186 | pub const AF_BRIDGE = PF_BRIDGE; |
| 187 | pub const AF_ATMPVC = PF_ATMPVC; |
| 188 | pub const AF_X25 = PF_X25; |
| 189 | pub const AF_INET6 = PF_INET6; |
| 190 | pub const AF_ROSE = PF_ROSE; |
| 191 | pub const AF_DECnet = PF_DECnet; |
| 192 | pub const AF_NETBEUI = PF_NETBEUI; |
| 193 | pub const AF_SECURITY = PF_SECURITY; |
| 194 | pub const AF_KEY = PF_KEY; |
| 195 | pub const AF_NETLINK = PF_NETLINK; |
| 196 | pub const AF_ROUTE = PF_ROUTE; |
| 197 | pub const AF_PACKET = PF_PACKET; |
| 198 | pub const AF_ASH = PF_ASH; |
| 199 | pub const AF_ECONET = PF_ECONET; |
| 200 | pub const AF_ATMSVC = PF_ATMSVC; |
| 201 | pub const AF_RDS = PF_RDS; |
| 202 | pub const AF_SNA = PF_SNA; |
| 203 | pub const AF_IRDA = PF_IRDA; |
| 204 | pub const AF_PPPOX = PF_PPPOX; |
| 205 | pub const AF_WANPIPE = PF_WANPIPE; |
| 206 | pub const AF_LLC = PF_LLC; |
| 207 | pub const AF_IB = PF_IB; |
| 208 | pub const AF_MPLS = PF_MPLS; |
| 209 | pub const AF_CAN = PF_CAN; |
| 210 | pub const AF_TIPC = PF_TIPC; |
| 211 | pub const AF_BLUETOOTH = PF_BLUETOOTH; |
| 212 | pub const AF_IUCV = PF_IUCV; |
| 213 | pub const AF_RXRPC = PF_RXRPC; |
| 214 | pub const AF_ISDN = PF_ISDN; |
| 215 | pub const AF_PHONET = PF_PHONET; |
| 216 | pub const AF_IEEE802154 = PF_IEEE802154; |
| 217 | pub const AF_CAIF = PF_CAIF; |
| 218 | pub const AF_ALG = PF_ALG; |
| 219 | pub const AF_NFC = PF_NFC; |
| 220 | pub const AF_VSOCK = PF_VSOCK; |
| 221 | pub const AF_MAX = PF_MAX; |
| 222 | |
| 94 | 223 | /// Get the errno from a syscall return value, or 0 for no error. |
| 95 | 224 | pub fn get_errno(r: isize) -> isize { |
| 96 | 225 | if (r > -4096) -r else 0 |
| ... | ... | @@ -185,10 +314,35 @@ fn restore_signals(set: &sigset_t) { |
| 185 | 314 | |
| 186 | 315 | pub type sa_family_t = u16; |
| 187 | 316 | pub type socklen_t = u32; |
| 317 | pub type in_addr_t = u32; |
| 318 | |
| 319 | export struct in_addr { |
| 320 | s_addr: in_addr_t, |
| 321 | } |
| 188 | 322 | |
| 189 | 323 | export struct sockaddr { |
| 190 | | sa_family: sa_family_t, |
| 191 | | sa_data: [14]u8, |
| 324 | family: sa_family_t, |
| 325 | port: u16, |
| 326 | data: [12]u8, |
| 327 | } |
| 328 | |
| 329 | export struct sockaddr_in { |
| 330 | family: sa_family_t, |
| 331 | port: u16, |
| 332 | addr: in_addr, |
| 333 | zero: [8]u8, |
| 334 | } |
| 335 | |
| 336 | export struct sockaddr_in6 { |
| 337 | family: sa_family_t, |
| 338 | port: u16, |
| 339 | flowinfo: u32, |
| 340 | addr: in6_addr, |
| 341 | scope_id: u32, |
| 342 | } |
| 343 | |
| 344 | export struct in6_addr { |
| 345 | addr: [16]u8, |
| 192 | 346 | } |
| 193 | 347 | |
| 194 | 348 | export struct iovec { |