hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

socket.ha (11796B)


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