authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-11-22 14:40:22+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-11-27 13:01:32+11:00
log19f26578c0be503c22f9503d9e5bf316d7e06f3b
tree8ab4edbdab7a23552b441040c63aec6884f0b8de
parent8aa3d6019c57c00282085d7cf87e84bff25cbe36
signature Commit is signed but in an unrecognized format.

std: windows sockaddr constants come from ws2_32


2 files changed, 150 insertions(+), 72 deletions(-)

lib/std/os/bits/windows.zig+56-72
......@@ -1,6 +1,7 @@
11// The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
22
33usingnamespace @import("../windows/bits.zig");
4const ws2_32 = @import("../windows/ws2_32.zig");
45
56pub const fd_t = HANDLE;
67pub const pid_t = HANDLE;
......@@ -163,80 +164,63 @@ pub const F_OK = 0;
163164pub const AT_REMOVEDIR = 0x200;
164165
165166pub const in_port_t = u16;
166pub const sa_family_t = u16;
167pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
167168pub const socklen_t = u32;
168169
169pub const sockaddr = extern struct {
170 family: sa_family_t,
171 data: [14]u8,
172};
173pub const sockaddr_in = extern struct {
174 family: sa_family_t = AF_INET,
175 port: in_port_t,
176 addr: in_addr,
177 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
178};
179pub const sockaddr_in6 = extern struct {
180 family: sa_family_t = AF_INET6,
181 port: in_port_t,
182 flowinfo: u32,
183 addr: in6_addr,
184 scope_id: u32,
185};
170pub const sockaddr = ws2_32.sockaddr;
171pub const sockaddr_in = ws2_32.sockaddr_in;
172pub const sockaddr_in6 = ws2_32.sockaddr_in6;
173pub const sockaddr_un = ws2_32.sockaddr_un;
174
186175pub const in6_addr = [16]u8;
187176pub const in_addr = u32;
188177
189pub const sockaddr_un = extern struct {
190 family: sa_family_t = AF_UNIX,
191 path: [108]u8,
192};
193
194pub const AF_UNSPEC = 0;
195pub const AF_UNIX = 1;
196pub const AF_INET = 2;
197pub const AF_IMPLINK = 3;
198pub const AF_PUP = 4;
199pub const AF_CHAOS = 5;
200pub const AF_NS = 6;
201pub const AF_IPX = AF_NS;
202pub const AF_ISO = 7;
203pub const AF_OSI = AF_ISO;
204pub const AF_ECMA = 8;
205pub const AF_DATAKIT = 9;
206pub const AF_CCITT = 10;
207pub const AF_SNA = 11;
208pub const AF_DECnet = 12;
209pub const AF_DLI = 13;
210pub const AF_LAT = 14;
211pub const AF_HYLINK = 15;
212pub const AF_APPLETALK = 16;
213pub const AF_NETBIOS = 17;
214pub const AF_VOICEVIEW = 18;
215pub const AF_FIREFOX = 19;
216pub const AF_UNKNOWN1 = 20;
217pub const AF_BAN = 21;
218pub const AF_ATM = 22;
219pub const AF_INET6 = 23;
220pub const AF_CLUSTER = 24;
221pub const AF_12844 = 25;
222pub const AF_IRDA = 26;
223pub const AF_NETDES = 28;
224pub const AF_TCNPROCESS = 29;
225pub const AF_TCNMESSAGE = 30;
226pub const AF_ICLFXBM = 31;
227pub const AF_BTH = 32;
228pub const AF_MAX = 33;
229
230pub const SOCK_STREAM = 1;
231pub const SOCK_DGRAM = 2;
232pub const SOCK_RAW = 3;
233pub const SOCK_RDM = 4;
234pub const SOCK_SEQPACKET = 5;
235
236pub const IPPROTO_ICMP = 1;
237pub const IPPROTO_IGMP = 2;
238pub const BTHPROTO_RFCOMM = 3;
239pub const IPPROTO_TCP = 6;
240pub const IPPROTO_UDP = 17;
241pub const IPPROTO_ICMPV6 = 58;
242pub const IPPROTO_RM = 113;
178pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
179pub const AF_UNIX = ws2_32.AF_UNIX;
180pub const AF_INET = ws2_32.AF_INET;
181pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
182pub const AF_PUP = ws2_32.AF_PUP;
183pub const AF_CHAOS = ws2_32.AF_CHAOS;
184pub const AF_NS = ws2_32.AF_NS;
185pub const AF_IPX = ws2_32.AF_IPX;
186pub const AF_ISO = ws2_32.AF_ISO;
187pub const AF_OSI = ws2_32.AF_OSI;
188pub const AF_ECMA = ws2_32.AF_ECMA;
189pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
190pub const AF_CCITT = ws2_32.AF_CCITT;
191pub const AF_SNA = ws2_32.AF_SNA;
192pub const AF_DECnet = ws2_32.AF_DECnet;
193pub const AF_DLI = ws2_32.AF_DLI;
194pub const AF_LAT = ws2_32.AF_LAT;
195pub const AF_HYLINK = ws2_32.AF_HYLINK;
196pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
197pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
198pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
199pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
200pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
201pub const AF_BAN = ws2_32.AF_BAN;
202pub const AF_ATM = ws2_32.AF_ATM;
203pub const AF_INET6 = ws2_32.AF_INET6;
204pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
205pub const AF_12844 = ws2_32.AF_12844;
206pub const AF_IRDA = ws2_32.AF_IRDA;
207pub const AF_NETDES = ws2_32.AF_NETDES;
208pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
209pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
210pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
211pub const AF_BTH = ws2_32.AF_BTH;
212pub const AF_MAX = ws2_32.AF_MAX;
213
214pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
215pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
216pub const SOCK_RAW = ws2_32.SOCK_RAW;
217pub const SOCK_RDM = ws2_32.SOCK_RDM;
218pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
219
220pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
221pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
222pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
223pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
224pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
225pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
226pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
lib/std/os/windows/ws2_32.zig+94
......@@ -108,6 +108,100 @@ pub const WSAOVERLAPPED = extern struct {
108108
109109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void;
110110
111pub const ADDRESS_FAMILY = u16;
112
113pub const AF_UNSPEC = 0;
114pub const AF_UNIX = 1;
115pub const AF_INET = 2;
116pub const AF_IMPLINK = 3;
117pub const AF_PUP = 4;
118pub const AF_CHAOS = 5;
119pub const AF_NS = 6;
120pub const AF_IPX = AF_NS;
121pub const AF_ISO = 7;
122pub const AF_OSI = AF_ISO;
123pub const AF_ECMA = 8;
124pub const AF_DATAKIT = 9;
125pub const AF_CCITT = 10;
126pub const AF_SNA = 11;
127pub const AF_DECnet = 12;
128pub const AF_DLI = 13;
129pub const AF_LAT = 14;
130pub const AF_HYLINK = 15;
131pub const AF_APPLETALK = 16;
132pub const AF_NETBIOS = 17;
133pub const AF_VOICEVIEW = 18;
134pub const AF_FIREFOX = 19;
135pub const AF_UNKNOWN1 = 20;
136pub const AF_BAN = 21;
137pub const AF_ATM = 22;
138pub const AF_INET6 = 23;
139pub const AF_CLUSTER = 24;
140pub const AF_12844 = 25;
141pub const AF_IRDA = 26;
142pub const AF_NETDES = 28;
143pub const AF_TCNPROCESS = 29;
144pub const AF_TCNMESSAGE = 30;
145pub const AF_ICLFXBM = 31;
146pub const AF_BTH = 32;
147pub const AF_MAX = 33;
148
149pub const SOCK_STREAM = 1;
150pub const SOCK_DGRAM = 2;
151pub const SOCK_RAW = 3;
152pub const SOCK_RDM = 4;
153pub const SOCK_SEQPACKET = 5;
154
155pub const IPPROTO_ICMP = 1;
156pub const IPPROTO_IGMP = 2;
157pub const BTHPROTO_RFCOMM = 3;
158pub const IPPROTO_TCP = 6;
159pub const IPPROTO_UDP = 17;
160pub const IPPROTO_ICMPV6 = 58;
161pub const IPPROTO_RM = 113;
162
163pub const sockaddr = extern struct {
164 family: ADDRESS_FAMILY,
165 data: [14]u8,
166};
167
168/// IPv4 socket address
169pub const sockaddr_in = extern struct {
170 family: ADDRESS_FAMILY = AF_INET,
171 port: USHORT,
172 addr: u32,
173 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
174};
175
176/// IPv6 socket address
177pub const sockaddr_in6 = extern struct {
178 family: ADDRESS_FAMILY = AF_INET6,
179 port: USHORT,
180 flowinfo: u32,
181 addr: [16]u8,
182 scope_id: u32,
183};
184
185/// UNIX domain socket address
186pub const sockaddr_un = extern struct {
187 family: ADDRESS_FAMILY = AF_UNIX,
188 path: [108]u8,
189};
190
191pub const WSABUF = extern struct {
192 len: ULONG,
193 buf: [*]u8,
194};
195
196pub const WSAMSG = extern struct {
197 name: *const sockaddr,
198 namelen: INT,
199 lpBuffers: [*]WSABUF,
200 dwBufferCount: DWORD,
201 Control: WSABUF,
202 dwFlags: DWORD,
203};
204
111205pub const WSA_INVALID_HANDLE = 6;
112206pub const WSA_NOT_ENOUGH_MEMORY = 8;
113207pub const WSA_INVALID_PARAMETER = 87;