socket.ha (11769B)
1 // SPDX-License-Identifier: MPL-2.0 2 // (c) Hare authors <https://harelang.org> 3 4 export type sa_family_t = u8; 5 export type socklen_t = u32; 6 7 export type in_addr = struct { 8 s_addr: u32 9 }; 10 11 export type sockaddr_in = struct { 12 sin_len: u8, 13 sin_family: sa_family_t, 14 sin_port: u16, 15 sin_addr: in_addr, 16 __pad: [8]u8, 17 }; 18 19 export type in6_addr = struct { 20 union { 21 s6_addr: [16]u8, 22 s6_addr16: [8]u16, 23 s6_addr32: [4]u32, 24 } 25 }; 26 27 export type sockaddr_in6 = struct { 28 sin6_len: u8, 29 sin6_family: sa_family_t, 30 sin6_port: u16, 31 sin6_flowinfo: u32, 32 sin6_addr: in6_addr, 33 sin6_scope_id: u32, 34 }; 35 36 export def UNIX_PATH_MAX: size = 104; 37 38 export type sockaddr_un = struct { 39 sun_len: u8, 40 sun_family: sa_family_t, 41 sun_path: [UNIX_PATH_MAX]u8, 42 }; 43 44 export type sockaddr = struct { 45 union { 46 in: sockaddr_in, 47 in6: sockaddr_in6, 48 un: sockaddr_un, 49 }, 50 }; 51 52 export def SCM_RIGHTS: int = 0x01; 53 export def SCM_CREDENTIALS: int = 0x02; 54 55 export type msghdr = struct { 56 msg_name: nullable *opaque, 57 msg_namelen: socklen_t, 58 59 msg_iov: nullable *[*]iovec, 60 msg_iovlen: int, 61 62 msg_control: nullable *opaque, 63 msg_controllen: socklen_t, 64 65 msg_flags: int 66 }; 67 68 export type cmsghdr = struct { 69 cmsg_len: socklen_t, 70 cmsg_level: int, 71 cmsg_type: int, 72 }; 73 74 export type cmsg = struct { 75 hdr: cmsghdr, 76 cmsg_data: [*]u8, 77 }; 78 79 export def AF_UNSPEC: sa_family_t = 0; 80 export def AF_UNIX: sa_family_t = 1; 81 export def AF_LOCAL: sa_family_t = AF_UNIX; 82 export def AF_INET: sa_family_t = 2; 83 export def AF_IMPLINK: sa_family_t = 3; 84 export def AF_PUP: sa_family_t = 4; 85 export def AF_CHAOS: sa_family_t = 5; 86 export def AF_NETBIOS: sa_family_t = 6; 87 export def AF_ISO: sa_family_t = 7; 88 export def AF_OSI: sa_family_t = AF_ISO; 89 export def AF_ECMA: sa_family_t = 8; 90 export def AF_DATAKIT: sa_family_t = 9; 91 export def AF_CCITT: sa_family_t = 10; 92 export def AF_SNA: sa_family_t = 11; 93 export def AF_DECnet: sa_family_t = 12; 94 export def AF_DLI: sa_family_t = 13; 95 export def AF_LAT: sa_family_t = 14; 96 export def AF_HYLINK: sa_family_t = 15; 97 export def AF_APPLETALK: sa_family_t = 16; 98 export def AF_ROUTE: sa_family_t = 17; 99 export def AF_LINK: sa_family_t = 18; 100 export def pseudo_AF_XTP: sa_family_t = 19; 101 export def AF_COIP: sa_family_t = 20; 102 export def AF_CNT: sa_family_t = 21; 103 export def pseudo_AF_RTIP: sa_family_t = 22; 104 export def AF_IPX: sa_family_t = 23; 105 export def AF_SIP: sa_family_t = 24; 106 export def pseudo_AF_PIP: sa_family_t = 25; 107 export def AF_ISDN: sa_family_t = 26; 108 export def AF_E164: sa_family_t = AF_ISDN; 109 export def AF_INET6: sa_family_t = 28; 110 export def AF_NATM: sa_family_t = 29; 111 export def AF_ATM: sa_family_t = 30; 112 export def AF_NETGRAPH: sa_family_t = 32; 113 export def AF_SLOW: sa_family_t = 33; 114 export def AF_SCLUSTER: sa_family_t = 34; 115 export def AF_ARP: sa_family_t = 35; 116 export def AF_BLUETOOTH: sa_family_t = 36; 117 export def AF_IEEE80211: sa_family_t = 37; 118 export def AF_INET_SDP: sa_family_t = 40; 119 export def AF_INET6_SDP: sa_family_t = 42; 120 export def AF_HYPERV: sa_family_t = 43; 121 export def AF_MAX: sa_family_t = 43; 122 export def AF_VENDOR00: sa_family_t = 39; 123 export def AF_VENDOR01: sa_family_t = 41; 124 export def AF_VENDOR03: sa_family_t = 45; 125 export def AF_VENDOR04: sa_family_t = 47; 126 export def AF_VENDOR05: sa_family_t = 49; 127 export def AF_VENDOR06: sa_family_t = 51; 128 export def AF_VENDOR07: sa_family_t = 53; 129 export def AF_VENDOR08: sa_family_t = 55; 130 export def AF_VENDOR09: sa_family_t = 57; 131 export def AF_VENDOR10: sa_family_t = 59; 132 export def AF_VENDOR11: sa_family_t = 61; 133 export def AF_VENDOR12: sa_family_t = 63; 134 export def AF_VENDOR13: sa_family_t = 65; 135 export def AF_VENDOR14: sa_family_t = 67; 136 export def AF_VENDOR15: sa_family_t = 69; 137 export def AF_VENDOR16: sa_family_t = 71; 138 export def AF_VENDOR17: sa_family_t = 73; 139 export def AF_VENDOR18: sa_family_t = 75; 140 export def AF_VENDOR19: sa_family_t = 77; 141 export def AF_VENDOR20: sa_family_t = 79; 142 export def AF_VENDOR21: sa_family_t = 81; 143 export def AF_VENDOR22: sa_family_t = 83; 144 export def AF_VENDOR23: sa_family_t = 85; 145 export def AF_VENDOR24: sa_family_t = 87; 146 export def AF_VENDOR25: sa_family_t = 89; 147 export def AF_VENDOR26: sa_family_t = 91; 148 export def AF_VENDOR27: sa_family_t = 93; 149 export def AF_VENDOR28: sa_family_t = 95; 150 export def AF_VENDOR29: sa_family_t = 97; 151 export def AF_VENDOR30: sa_family_t = 99; 152 export def AF_VENDOR31: sa_family_t = 101; 153 export def AF_VENDOR32: sa_family_t = 103; 154 export def AF_VENDOR33: sa_family_t = 105; 155 export def AF_VENDOR34: sa_family_t = 107; 156 export def AF_VENDOR35: sa_family_t = 109; 157 export def AF_VENDOR36: sa_family_t = 111; 158 export def AF_VENDOR37: sa_family_t = 113; 159 export def AF_VENDOR38: sa_family_t = 115; 160 export def AF_VENDOR39: sa_family_t = 117; 161 export def AF_VENDOR40: sa_family_t = 119; 162 export def AF_VENDOR41: sa_family_t = 121; 163 export def AF_VENDOR42: sa_family_t = 123; 164 export def AF_VENDOR43: sa_family_t = 125; 165 export def AF_VENDOR44: sa_family_t = 127; 166 export def AF_VENDOR45: sa_family_t = 129; 167 export def AF_VENDOR46: sa_family_t = 131; 168 export def AF_VENDOR47: sa_family_t = 133; 169 170 export def SOCK_STREAM: int = 1; 171 export def SOCK_DGRAM: int = 2; 172 export def SOCK_RAW: int = 3; 173 export def SOCK_RDM: int = 4; 174 export def SOCK_SEQPACKET: int = 5; 175 export def SOCK_CLOEXEC: int = 0x10000000; 176 export def SOCK_NONBLOCK: int = 0x20000000; 177 178 export def IPPROTO_IP: int = 0; 179 export def IPPROTO_ICMP: int = 1; 180 export def IPPROTO_TCP: int = 6; 181 export def IPPROTO_UDP: int = 17; 182 export def IPPROTO_IPV6: int = 41; 183 export def IPPROTO_RAW: int = 255; 184 export def IPPROTO_HOPOPTS: int = 0; 185 export def IPPROTO_IGMP: int = 2; 186 export def IPPROTO_GGP: int = 3; 187 export def IPPROTO_IPV4: int = 4; 188 export def IPPROTO_IPIP: int = IPPROTO_IPV4; 189 export def IPPROTO_ST: int = 7; 190 export def IPPROTO_EGP: int = 8; 191 export def IPPROTO_PIGP: int = 9; 192 export def IPPROTO_RCCMON: int = 10; 193 export def IPPROTO_NVPII: int = 11; 194 export def IPPROTO_PUP: int = 12; 195 export def IPPROTO_ARGUS: int = 13; 196 export def IPPROTO_EMCON: int = 14; 197 export def IPPROTO_XNET: int = 15; 198 export def IPPROTO_CHAOS: int = 16; 199 export def IPPROTO_MUX: int = 18; 200 export def IPPROTO_MEAS: int = 19; 201 export def IPPROTO_HMP: int = 20; 202 export def IPPROTO_PRM: int = 21; 203 export def IPPROTO_IDP: int = 22; 204 export def IPPROTO_TRUNK1: int = 23; 205 export def IPPROTO_TRUNK2: int = 24; 206 export def IPPROTO_LEAF1: int = 25; 207 export def IPPROTO_LEAF2: int = 26; 208 export def IPPROTO_RDP: int = 27; 209 export def IPPROTO_IRTP: int = 28; 210 export def IPPROTO_TP: int = 29; 211 export def IPPROTO_BLT: int = 30; 212 export def IPPROTO_NSP: int = 31; 213 export def IPPROTO_INP: int = 32; 214 export def IPPROTO_DCCP: int = 33; 215 export def IPPROTO_3PC: int = 34; 216 export def IPPROTO_IDPR: int = 35; 217 export def IPPROTO_XTP: int = 36; 218 export def IPPROTO_DDP: int = 37; 219 export def IPPROTO_CMTP: int = 38; 220 export def IPPROTO_TPXX: int = 39; 221 export def IPPROTO_IL: int = 40; 222 export def IPPROTO_SDRP: int = 42; 223 export def IPPROTO_ROUTING: int = 43; 224 export def IPPROTO_FRAGMENT: int = 44; 225 export def IPPROTO_IDRP: int = 45; 226 export def IPPROTO_RSVP: int = 46; 227 export def IPPROTO_GRE: int = 47; 228 export def IPPROTO_MHRP: int = 48; 229 export def IPPROTO_BHA: int = 49; 230 export def IPPROTO_ESP: int = 50; 231 export def IPPROTO_AH: int = 51; 232 export def IPPROTO_INLSP: int = 52; 233 export def IPPROTO_SWIPE: int = 53; 234 export def IPPROTO_NHRP: int = 54; 235 export def IPPROTO_MOBILE: int = 55; 236 export def IPPROTO_TLSP: int = 56; 237 export def IPPROTO_SKIP: int = 57; 238 export def IPPROTO_ICMPV6: int = 58; 239 export def IPPROTO_NONE: int = 59; 240 export def IPPROTO_DSTOPTS: int = 60; 241 export def IPPROTO_AHIP: int = 61; 242 export def IPPROTO_CFTP: int = 62; 243 export def IPPROTO_HELLO: int = 63; 244 export def IPPROTO_SATEXPAK: int = 64; 245 export def IPPROTO_KRYPTOLAN: int = 65; 246 export def IPPROTO_RVD: int = 66; 247 export def IPPROTO_IPPC: int = 67; 248 export def IPPROTO_ADFS: int = 68; 249 export def IPPROTO_SATMON: int = 69; 250 export def IPPROTO_VISA: int = 70; 251 export def IPPROTO_IPCV: int = 71; 252 export def IPPROTO_CPNX: int = 72; 253 export def IPPROTO_CPHB: int = 73; 254 export def IPPROTO_WSN: int = 74; 255 export def IPPROTO_PVP: int = 75; 256 export def IPPROTO_BRSATMON: int = 76; 257 export def IPPROTO_ND: int = 77; 258 export def IPPROTO_WBMON: int = 78; 259 export def IPPROTO_WBEXPAK: int = 79; 260 export def IPPROTO_EON: int = 80; 261 export def IPPROTO_VMTP: int = 81; 262 export def IPPROTO_SVMTP: int = 82; 263 export def IPPROTO_VINES: int = 83; 264 export def IPPROTO_TTP: int = 84; 265 export def IPPROTO_IGP: int = 85; 266 export def IPPROTO_DGP: int = 86; 267 export def IPPROTO_TCF: int = 87; 268 export def IPPROTO_IGRP: int = 88; 269 export def IPPROTO_OSPFIGP: int = 89; 270 export def IPPROTO_SRPC: int = 90; 271 export def IPPROTO_LARP: int = 91; 272 export def IPPROTO_MTP: int = 92; 273 export def IPPROTO_AX25: int = 93; 274 export def IPPROTO_IPEIP: int = 94; 275 export def IPPROTO_MICP: int = 95; 276 export def IPPROTO_SCCSP: int = 96; 277 export def IPPROTO_ETHERIP: int = 97; 278 export def IPPROTO_ENCAP: int = 98; 279 export def IPPROTO_APES: int = 99; 280 export def IPPROTO_GMTP: int = 100; 281 export def IPPROTO_IPCOMP: int = 108; 282 export def IPPROTO_SCTP: int = 132; 283 export def IPPROTO_MH: int = 135; 284 export def IPPROTO_UDPLITE: int = 136; 285 export def IPPROTO_HIP: int = 139; 286 export def IPPROTO_SHIM6: int = 140; 287 export def IPPROTO_PIM: int = 103; 288 export def IPPROTO_CARP: int = 112; 289 export def IPPROTO_PGM: int = 113; 290 export def IPPROTO_MPLS: int = 137; 291 export def IPPROTO_PFSYNC: int = 240; 292 export def IPPROTO_RESERVED_253: int = 253; 293 export def IPPROTO_RESERVED_254: int = 254; 294 295 export def MSG_OOB: int = 0x00000001; 296 export def MSG_PEEK: int = 0x00000002; 297 export def MSG_DONTROUTE: int = 0x00000004; 298 export def MSG_EOR: int = 0x00000008; 299 export def MSG_TRUNC: int = 0x00000010; 300 export def MSG_CTRUNC: int = 0x00000020; 301 export def MSG_WAITALL: int = 0x00000040; 302 export def MSG_DONTWAIT: int = 0x00000080; 303 export def MSG_EOF: int = 0x00000100; 304 export def MSG_NOTIFICATION: int = 0x00002000; 305 export def MSG_NBIO: int = 0x00004000; 306 export def MSG_COMPAT: int = 0x00008000; 307 export def MSG_NOSIGNAL: int = 0x00020000; 308 export def MSG_CMSG_CLOEXEC: int = 0x00040000; 309 export def MSG_WAITFORONE: int = 0x00080000; 310 311 export def SO_DEBUG: int = 0x00000001; 312 export def SO_ACCEPTCONN: int = 0x00000002; 313 export def SO_REUSEADDR: int = 0x00000004; 314 export def SO_KEEPALIVE: int = 0x00000008; 315 export def SO_DONTROUTE: int = 0x00000010; 316 export def SO_BROADCAST: int = 0x00000020; 317 export def SO_USELOOPBACK: int = 0x00000040; 318 export def SO_LINGER: int = 0x00000080; 319 export def SO_OOBINLINE: int = 0x00000100; 320 export def SO_REUSEPORT: int = 0x00000200; 321 export def SO_TIMESTAMP: int = 0x00000400; 322 export def SO_NOSIGPIPE: int = 0x00000800; 323 export def SO_ACCEPTFILTER: int = 0x00001000; 324 export def SO_BINTIME: int = 0x00002000; 325 export def SO_NO_OFFLOAD: int = 0x00004000; 326 export def SO_NO_DDP: int = 0x00008000; 327 export def SO_REUSEPORT_LB: int = 0x00010000; 328 export def SO_SNDBUF: int = 0x1001; 329 export def SO_RCVBUF: int = 0x1002; 330 export def SO_SNDLOWAT: int = 0x1003; 331 export def SO_RCVLOWAT: int = 0x1004; 332 export def SO_SNDTIMEO: int = 0x1005; 333 export def SO_RCVTIMEO: int = 0x1006; 334 export def SO_ERROR: int = 0x1007; 335 export def SO_TYPE: int = 0x1008; 336 export def SO_LABEL: int = 0x1009; 337 export def SO_PEERLABEL: int = 0x1010; 338 export def SO_LISTENQLIMIT: int = 0x1011; 339 export def SO_LISTENQLEN: int = 0x1012; 340 export def SO_LISTENINCQLEN: int = 0x1013; 341 export def SO_SETFIB: int = 0x1014; 342 export def SO_USER_COOKIE: int = 0x1015; 343 export def SO_PROTOCOL: int = 0x1016; 344 export def SO_PROTOTYPE: int = SO_PROTOCOL; 345 export def SO_TS_CLOCK: int = 0x1017; 346 export def SO_MAX_PACING_RATE: int = 0x1018; 347 export def SO_DOMAIN: int = 0x1019; 348 export def SO_TS_REALTIME_MICRO: int = 0; 349 export def SO_TS_BINTIME: int = 1; 350 export def SO_TS_REALTIME: int = 2; 351 export def SO_TS_MONOTONIC: int = 3; 352 export def SO_TS_DEFAULT: int = SO_TS_REALTIME_MICRO; 353 export def SO_TS_CLOCK_MAX: int = SO_TS_MONOTONIC; 354 355 export def SOL_SOCKET: int = 0xffff;