1const std = @import("../../std.zig");
2const assert = std.debug.assert;
3const windows = std.os.windows;
4
5const USHORT = windows.USHORT;
6const LONG = windows.LONG;
7
8pub const GROUP = u32;
9pub const ADDRESS_FAMILY = u16;
10
11// Microsoft use the signed c_int for this, but it should never be negative
12pub const socklen_t = u32;
13
14pub const TCP = struct {
15 pub const NODELAY = 1;
16 pub const EXPEDITED_1122 = 2;
17 pub const OFFLOAD_NO_PREFERENCE = 0;
18 pub const OFFLOAD_NOT_PREFERRED = 1;
19 pub const OFFLOAD_PREFERRED = 2;
20 pub const KEEPALIVE = 3;
21 pub const MAXSEG = 4;
22 pub const MAXRT = 5;
23 pub const STDURG = 6;
24 pub const NOURG = 7;
25 pub const ATMARK = 8;
26 pub const NOSYNRETRIES = 9;
27 pub const TIMESTAMPS = 10;
28 pub const OFFLOAD_PREFERENCE = 11;
29 pub const CONGESTION_ALGORITHM = 12;
30 pub const DELAY_FIN_ACK = 13;
31 pub const MAXRTMS = 14;
32 pub const FASTOPEN = 15;
33 pub const KEEPCNT = 16;
34 pub const KEEPINTVL = 17;
35 pub const FAIL_CONNECT_ON_ICMP_ERROR = 18;
36 pub const ICMP_ERROR_INFO = 19;
37 pub const BSDURGENT = 28672;
38};
39
40pub const AF = struct {
41 pub const UNSPEC = 0;
42 pub const UNIX = 1;
43 pub const INET = 2;
44 pub const IMPLINK = 3;
45 pub const PUP = 4;
46 pub const CHAOS = 5;
47 pub const NS = 6;
48 pub const IPX = 6;
49 pub const ISO = 7;
50 pub const ECMA = 8;
51 pub const DATAKIT = 9;
52 pub const CCITT = 10;
53 pub const SNA = 11;
54 pub const DECnet = 12;
55 pub const DLI = 13;
56 pub const LAT = 14;
57 pub const HYLINK = 15;
58 pub const APPLETALK = 16;
59 pub const NETBIOS = 17;
60 pub const VOICEVIEW = 18;
61 pub const FIREFOX = 19;
62 pub const UNKNOWN1 = 20;
63 pub const BAN = 21;
64 pub const ATM = 22;
65 pub const INET6 = 23;
66 pub const CLUSTER = 24;
67 pub const @"12844" = 25;
68 pub const IRDA = 26;
69 pub const NETDES = 28;
70 pub const MAX = 29;
71 pub const TCNPROCESS = 29;
72 pub const TCNMESSAGE = 30;
73 pub const ICLFXBM = 31;
74 pub const BTH = 32;
75 pub const LINK = 33;
76 pub const HYPERV = 34;
77};
78
79pub const SOCK = struct {
80 pub const STREAM = 1;
81 pub const DGRAM = 2;
82 pub const RAW = 3;
83 pub const RDM = 4;
84 pub const SEQPACKET = 5;
85};
86
87pub const SOL = struct {
88 pub const IRLMP = 255;
89 pub const SOCKET = 65535;
90};
91
92pub const SO = struct {
93 pub const DEBUG = 1;
94 pub const ACCEPTCONN = 2;
95 pub const REUSEADDR = 4;
96 pub const KEEPALIVE = 8;
97 pub const DONTROUTE = 16;
98 pub const BROADCAST = 32;
99 pub const USELOOPBACK = 64;
100 pub const LINGER = 128;
101 pub const OOBINLINE = 256;
102 pub const SNDBUF = 4097;
103 pub const RCVBUF = 4098;
104 pub const SNDLOWAT = 4099;
105 pub const RCVLOWAT = 4100;
106 pub const SNDTIMEO = 4101;
107 pub const RCVTIMEO = 4102;
108 pub const ERROR = 4103;
109 pub const TYPE = 4104;
110 pub const BSP_STATE = 4105;
111 pub const GROUP_ID = 8193;
112 pub const GROUP_PRIORITY = 8194;
113 pub const MAX_MSG_SIZE = 8195;
114 pub const CONDITIONAL_ACCEPT = 12290;
115 pub const PAUSE_ACCEPT = 12291;
116 pub const COMPARTMENT_ID = 12292;
117 pub const RANDOMIZE_PORT = 12293;
118 pub const PORT_SCALABILITY = 12294;
119 pub const REUSE_UNICASTPORT = 12295;
120 pub const REUSE_MULTICASTPORT = 12296;
121 pub const ORIGINAL_DST = 12303;
122 pub const PROTOCOL_INFOA = 8196;
123 pub const PROTOCOL_INFOW = 8197;
124 pub const CONNDATA = 28672;
125 pub const CONNOPT = 28673;
126 pub const DISCDATA = 28674;
127 pub const DISCOPT = 28675;
128 pub const CONNDATALEN = 28676;
129 pub const CONNOPTLEN = 28677;
130 pub const DISCDATALEN = 28678;
131 pub const DISCOPTLEN = 28679;
132 pub const OPENTYPE = 28680;
133 pub const SYNCHRONOUS_ALERT = 16;
134 pub const SYNCHRONOUS_NONALERT = 32;
135 pub const MAXDG = 28681;
136 pub const MAXPATHDG = 28682;
137 pub const UPDATE_ACCEPT_CONTEXT = 28683;
138 pub const CONNECT_TIME = 28684;
139 pub const UPDATE_CONNECT_CONTEXT = 28688;
140
141 pub const UNIX_PATH = 0x98000000;
142};
143
144pub const MSG = struct {
145 pub const OOB = 0x1;
146 pub const PEEK = 0x2;
147 pub const DONTROUTE = 0x4;
148 pub const WAITALL = 0x8;
149 pub const INTERRUPT = 0x10;
150 pub const PUSH_IMMEDIATE = 0x20;
151
152 pub const TRUNC = 0x0100;
153 pub const CTRUNC = 0x0200;
154 pub const BCAST = 0x0400;
155 pub const MCAST = 0x0800;
156
157 pub const PARTIAL = 0x8000;
158
159 pub const MAXIOVLEN = 16;
160};
161
162pub const IPPROTO = struct {
163 pub const IP = 0;
164 pub const ICMP = 1;
165 pub const IGMP = 2;
166 pub const GGP = 3;
167 pub const TCP = 6;
168 pub const PUP = 12;
169 pub const UDP = 17;
170 pub const IDP = 22;
171 pub const ND = 77;
172 pub const RM = 113;
173 pub const RAW = 255;
174 pub const MAX = 256;
175};
176
177pub const FLOWSPEC = extern struct {
178 TokenRate: u32,
179 TokenBucketSize: u32,
180 PeakBandwidth: u32,
181 Latency: u32,
182 DelayVariation: u32,
183 ServiceType: u32,
184 MaxSduSize: u32,
185 MinimumPolicedSize: u32,
186};
187
188pub const sockproto = extern struct {
189 sp_family: u16,
190 sp_protocol: u16,
191};
192
193pub const linger = extern struct {
194 onoff: u16,
195 linger: u16,
196};
197
198pub const sockaddr = extern struct {
199 family: ADDRESS_FAMILY,
200 data: [14]u8,
201
202 pub const SS_MAXSIZE = 128;
203 pub const storage = extern struct {
204 family: ADDRESS_FAMILY align(8),
205 padding: [SS_MAXSIZE - @sizeOf(ADDRESS_FAMILY)]u8 = undefined,
206
207 comptime {
208 assert(@sizeOf(storage) == SS_MAXSIZE);
209 assert(@alignOf(storage) == 8);
210 }
211 };
212
213 /// IPv4 socket address
214 pub const in = extern struct {
215 family: ADDRESS_FAMILY = AF.INET,
216 port: USHORT,
217 addr: u32,
218 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
219 };
220
221 /// IPv6 socket address
222 pub const in6 = extern struct {
223 family: ADDRESS_FAMILY = AF.INET6,
224 port: USHORT,
225 flowinfo: u32,
226 addr: [16]u8,
227 scope_id: u32,
228 };
229
230 /// UNIX domain socket address
231 pub const un = extern struct {
232 family: ADDRESS_FAMILY = AF.UNIX,
233 path: [108]u8,
234 };
235};
236
237pub const hostent = extern struct {
238 h_name: [*]u8,
239 h_aliases: **i8,
240 h_addrtype: i16,
241 h_length: i16,
242 h_addr_list: **i8,
243};
244
245pub const timeval = extern struct {
246 sec: LONG,
247 usec: LONG,
248};