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 @@...@@ -1,6 +1,7 @@
1// The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).1// The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
22
3usingnamespace @import("../windows/bits.zig");3usingnamespace @import("../windows/bits.zig");
4const ws2_32 = @import("../windows/ws2_32.zig");
45
5pub const fd_t = HANDLE;6pub const fd_t = HANDLE;
6pub const pid_t = HANDLE;7pub const pid_t = HANDLE;
...@@ -163,80 +164,63 @@ pub const F_OK = 0;...@@ -163,80 +164,63 @@ pub const F_OK = 0;
163pub const AT_REMOVEDIR = 0x200;164pub const AT_REMOVEDIR = 0x200;
164165
165pub const in_port_t = u16;166pub const in_port_t = u16;
166pub const sa_family_t = u16;167pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
167pub const socklen_t = u32;168pub const socklen_t = u32;
168169
169pub const sockaddr = extern struct {170pub const sockaddr = ws2_32.sockaddr;
170 family: sa_family_t,171pub const sockaddr_in = ws2_32.sockaddr_in;
171 data: [14]u8,172pub const sockaddr_in6 = ws2_32.sockaddr_in6;
172};173pub const sockaddr_un = ws2_32.sockaddr_un;
173pub const sockaddr_in = extern struct {174
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};
186pub const in6_addr = [16]u8;175pub const in6_addr = [16]u8;
187pub const in_addr = u32;176pub const in_addr = u32;
188177
189pub const sockaddr_un = extern struct {178pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
190 family: sa_family_t = AF_UNIX,179pub const AF_UNIX = ws2_32.AF_UNIX;
191 path: [108]u8,180pub const AF_INET = ws2_32.AF_INET;
192};181pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
193182pub const AF_PUP = ws2_32.AF_PUP;
194pub const AF_UNSPEC = 0;183pub const AF_CHAOS = ws2_32.AF_CHAOS;
195pub const AF_UNIX = 1;184pub const AF_NS = ws2_32.AF_NS;
196pub const AF_INET = 2;185pub const AF_IPX = ws2_32.AF_IPX;
197pub const AF_IMPLINK = 3;186pub const AF_ISO = ws2_32.AF_ISO;
198pub const AF_PUP = 4;187pub const AF_OSI = ws2_32.AF_OSI;
199pub const AF_CHAOS = 5;188pub const AF_ECMA = ws2_32.AF_ECMA;
200pub const AF_NS = 6;189pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
201pub const AF_IPX = AF_NS;190pub const AF_CCITT = ws2_32.AF_CCITT;
202pub const AF_ISO = 7;191pub const AF_SNA = ws2_32.AF_SNA;
203pub const AF_OSI = AF_ISO;192pub const AF_DECnet = ws2_32.AF_DECnet;
204pub const AF_ECMA = 8;193pub const AF_DLI = ws2_32.AF_DLI;
205pub const AF_DATAKIT = 9;194pub const AF_LAT = ws2_32.AF_LAT;
206pub const AF_CCITT = 10;195pub const AF_HYLINK = ws2_32.AF_HYLINK;
207pub const AF_SNA = 11;196pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
208pub const AF_DECnet = 12;197pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
209pub const AF_DLI = 13;198pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
210pub const AF_LAT = 14;199pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
211pub const AF_HYLINK = 15;200pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
212pub const AF_APPLETALK = 16;201pub const AF_BAN = ws2_32.AF_BAN;
213pub const AF_NETBIOS = 17;202pub const AF_ATM = ws2_32.AF_ATM;
214pub const AF_VOICEVIEW = 18;203pub const AF_INET6 = ws2_32.AF_INET6;
215pub const AF_FIREFOX = 19;204pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
216pub const AF_UNKNOWN1 = 20;205pub const AF_12844 = ws2_32.AF_12844;
217pub const AF_BAN = 21;206pub const AF_IRDA = ws2_32.AF_IRDA;
218pub const AF_ATM = 22;207pub const AF_NETDES = ws2_32.AF_NETDES;
219pub const AF_INET6 = 23;208pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
220pub const AF_CLUSTER = 24;209pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
221pub const AF_12844 = 25;210pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
222pub const AF_IRDA = 26;211pub const AF_BTH = ws2_32.AF_BTH;
223pub const AF_NETDES = 28;212pub const AF_MAX = ws2_32.AF_MAX;
224pub const AF_TCNPROCESS = 29;213
225pub const AF_TCNMESSAGE = 30;214pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
226pub const AF_ICLFXBM = 31;215pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
227pub const AF_BTH = 32;216pub const SOCK_RAW = ws2_32.SOCK_RAW;
228pub const AF_MAX = 33;217pub const SOCK_RDM = ws2_32.SOCK_RDM;
229218pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
230pub const SOCK_STREAM = 1;219
231pub const SOCK_DGRAM = 2;220pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
232pub const SOCK_RAW = 3;221pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
233pub const SOCK_RDM = 4;222pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
234pub const SOCK_SEQPACKET = 5;223pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
235224pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
236pub const IPPROTO_ICMP = 1;225pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
237pub const IPPROTO_IGMP = 2;226pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
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;
lib/std/os/windows/ws2_32.zig+94
...@@ -108,6 +108,100 @@ pub const WSAOVERLAPPED = extern struct {...@@ -108,6 +108,100 @@ pub const WSAOVERLAPPED = extern struct {
108108
109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void;109pub 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
111pub const WSA_INVALID_HANDLE = 6;205pub const WSA_INVALID_HANDLE = 6;
112pub const WSA_NOT_ENOUGH_MEMORY = 8;206pub const WSA_NOT_ENOUGH_MEMORY = 8;
113pub const WSA_INVALID_PARAMETER = 87;207pub const WSA_INVALID_PARAMETER = 87;