]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. |
2 | * | |
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
4 | * of this software and associated documentation files (the "Software"), to | |
5 | * deal in the Software without restriction, including without limitation the | |
6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
7 | * sell copies of the Software, and to permit persons to whom the Software is | |
8 | * furnished to do so, subject to the following conditions: | |
9 | * | |
10 | * The above copyright notice and this permission notice shall be included in | |
11 | * all copies or substantial portions of the Software. | |
12 | * | |
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
19 | * IN THE SOFTWARE. | |
20 | */ | |
21 | ||
22 | #ifndef UV_WIN_INTERNAL_H_ | |
23 | #define UV_WIN_INTERNAL_H_ | |
24 | ||
25 | #include "uv.h" | |
26 | #include "../uv-common.h" | |
27 | ||
28 | #include "tree.h" | |
29 | #include "winapi.h" | |
30 | #include "winsock.h" | |
31 | ||
32 | ||
33 | /* | |
34 | * Handles | |
35 | * (also see handle-inl.h) | |
36 | */ | |
37 | ||
38 | /* Used by all handles. */ | |
39 | #define UV_HANDLE_CLOSED 0x00000002 | |
40 | #define UV_HANDLE_ENDGAME_QUEUED 0x00000004 | |
41 | #define UV_HANDLE_ACTIVE 0x00000010 | |
42 | ||
43 | /* uv-common.h: #define UV__HANDLE_CLOSING 0x00000001 */ | |
44 | /* uv-common.h: #define UV__HANDLE_ACTIVE 0x00000040 */ | |
45 | /* uv-common.h: #define UV__HANDLE_REF 0x00000020 */ | |
46 | /* uv-common.h: #define UV_HANDLE_INTERNAL 0x00000080 */ | |
47 | ||
48 | /* Used by streams and UDP handles. */ | |
49 | #define UV_HANDLE_READING 0x00000100 | |
50 | #define UV_HANDLE_BOUND 0x00000200 | |
51 | #define UV_HANDLE_BIND_ERROR 0x00000400 | |
52 | #define UV_HANDLE_LISTENING 0x00000800 | |
53 | #define UV_HANDLE_CONNECTION 0x00001000 | |
54 | #define UV_HANDLE_CONNECTED 0x00002000 | |
55 | #define UV_HANDLE_READABLE 0x00008000 | |
56 | #define UV_HANDLE_WRITABLE 0x00010000 | |
57 | #define UV_HANDLE_READ_PENDING 0x00020000 | |
58 | #define UV_HANDLE_SYNC_BYPASS_IOCP 0x00040000 | |
59 | #define UV_HANDLE_ZERO_READ 0x00080000 | |
60 | #define UV_HANDLE_EMULATE_IOCP 0x00100000 | |
61 | ||
62 | /* Only used by uv_tcp_t handles. */ | |
63 | #define UV_HANDLE_IPV6 0x01000000 | |
64 | #define UV_HANDLE_TCP_NODELAY 0x02000000 | |
65 | #define UV_HANDLE_TCP_KEEPALIVE 0x04000000 | |
66 | #define UV_HANDLE_TCP_SINGLE_ACCEPT 0x08000000 | |
67 | #define UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 0x10000000 | |
68 | #define UV_HANDLE_TCP_SOCKET_CLOSED 0x20000000 | |
69 | #define UV_HANDLE_SHARED_TCP_SOCKET 0x40000000 | |
70 | ||
71 | /* Only used by uv_pipe_t handles. */ | |
72 | #define UV_HANDLE_NON_OVERLAPPED_PIPE 0x01000000 | |
73 | #define UV_HANDLE_PIPESERVER 0x02000000 | |
74 | ||
75 | /* Only used by uv_tty_t handles. */ | |
76 | #define UV_HANDLE_TTY_READABLE 0x01000000 | |
77 | #define UV_HANDLE_TTY_RAW 0x02000000 | |
78 | #define UV_HANDLE_TTY_SAVED_POSITION 0x04000000 | |
79 | #define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x08000000 | |
80 | ||
81 | /* Only used by uv_poll_t handles. */ | |
82 | #define UV_HANDLE_POLL_SLOW 0x02000000 | |
83 | ||
84 | ||
85 | /* | |
86 | * Requests: see req-inl.h | |
87 | */ | |
88 | ||
89 | ||
90 | /* | |
91 | * Streams: see stream-inl.h | |
92 | */ | |
93 | ||
94 | ||
95 | /* | |
96 | * TCP | |
97 | */ | |
98 | int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb); | |
99 | int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client); | |
100 | int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb, | |
101 | uv_read_cb read_cb); | |
102 | int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle, | |
103 | uv_buf_t bufs[], int bufcnt, uv_write_cb cb); | |
104 | ||
105 | void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, uv_req_t* req); | |
106 | void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, | |
107 | uv_write_t* req); | |
108 | void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle, | |
109 | uv_req_t* req); | |
110 | void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, | |
111 | uv_connect_t* req); | |
112 | ||
113 | void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp); | |
114 | void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle); | |
115 | ||
116 | int uv_tcp_import(uv_tcp_t* tcp, WSAPROTOCOL_INFOW* socket_protocol_info, | |
117 | int tcp_connection); | |
118 | ||
119 | int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, | |
120 | LPWSAPROTOCOL_INFOW protocol_info); | |
121 | ||
122 | ||
123 | /* | |
124 | * UDP | |
125 | */ | |
126 | void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req); | |
127 | void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, | |
128 | uv_udp_send_t* req); | |
129 | ||
130 | void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle); | |
131 | void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle); | |
132 | ||
133 | ||
134 | /* | |
135 | * Pipes | |
136 | */ | |
137 | uv_err_t uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access, | |
138 | char* name, size_t nameSize); | |
139 | ||
140 | int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); | |
141 | int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client); | |
142 | int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, | |
143 | uv_read_cb read_cb); | |
144 | int uv_pipe_read2_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, | |
145 | uv_read2_cb read_cb); | |
146 | int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, | |
147 | uv_buf_t bufs[], int bufcnt, uv_write_cb cb); | |
148 | int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle, | |
149 | uv_buf_t bufs[], int bufcnt, uv_stream_t* send_handle, uv_write_cb cb); | |
150 | ||
151 | void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, | |
152 | uv_req_t* req); | |
153 | void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, | |
154 | uv_write_t* req); | |
155 | void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, | |
156 | uv_req_t* raw_req); | |
157 | void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle, | |
158 | uv_connect_t* req); | |
159 | void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle, | |
160 | uv_shutdown_t* req); | |
161 | ||
162 | void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle); | |
163 | void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle); | |
164 | void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle); | |
165 | ||
166 | ||
167 | /* | |
168 | * TTY | |
169 | */ | |
170 | void uv_console_init(); | |
171 | ||
172 | int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, | |
173 | uv_read_cb read_cb); | |
174 | int uv_tty_read_stop(uv_tty_t* handle); | |
175 | int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle, | |
176 | uv_buf_t bufs[], int bufcnt, uv_write_cb cb); | |
177 | void uv_tty_close(uv_tty_t* handle); | |
178 | ||
179 | void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle, | |
180 | uv_req_t* req); | |
181 | void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, | |
182 | uv_write_t* req); | |
183 | /* TODO: remove me */ | |
184 | void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle, | |
185 | uv_req_t* raw_req); | |
186 | /* TODO: remove me */ | |
187 | void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle, | |
188 | uv_connect_t* req); | |
189 | ||
190 | void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle); | |
191 | ||
192 | ||
193 | /* | |
194 | * Poll watchers | |
195 | */ | |
196 | void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, | |
197 | uv_req_t* req); | |
198 | ||
199 | void uv_poll_close(uv_loop_t* loop, uv_poll_t* handle); | |
200 | void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle); | |
201 | ||
202 | ||
203 | /* | |
204 | * Timers | |
205 | */ | |
206 | void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle); | |
207 | ||
208 | DWORD uv_get_poll_timeout(uv_loop_t* loop); | |
209 | void uv_process_timers(uv_loop_t* loop); | |
210 | ||
211 | ||
212 | /* | |
213 | * Loop watchers | |
214 | */ | |
215 | void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle); | |
216 | ||
217 | void uv_prepare_invoke(uv_loop_t* loop); | |
218 | void uv_check_invoke(uv_loop_t* loop); | |
219 | void uv_idle_invoke(uv_loop_t* loop); | |
220 | ||
221 | void uv__once_init(); | |
222 | ||
223 | ||
224 | /* | |
225 | * Async watcher | |
226 | */ | |
227 | void uv_async_close(uv_loop_t* loop, uv_async_t* handle); | |
228 | void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle); | |
229 | ||
230 | void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, | |
231 | uv_req_t* req); | |
232 | ||
233 | ||
234 | /* | |
235 | * Signal watcher | |
236 | */ | |
237 | void uv_signals_init(); | |
238 | int uv__signal_dispatch(int signum); | |
239 | ||
240 | void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle); | |
241 | void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle); | |
242 | ||
243 | void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle, | |
244 | uv_req_t* req); | |
245 | ||
246 | ||
247 | /* | |
248 | * Spawn | |
249 | */ | |
250 | void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle); | |
251 | void uv_process_close(uv_loop_t* loop, uv_process_t* handle); | |
252 | void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle); | |
253 | ||
254 | ||
255 | /* | |
256 | * Getaddrinfo | |
257 | */ | |
258 | void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* req); | |
259 | ||
260 | ||
261 | /* | |
262 | * FS | |
263 | */ | |
264 | void uv_fs_init(); | |
265 | void uv_process_fs_req(uv_loop_t* loop, uv_fs_t* req); | |
266 | ||
267 | ||
268 | /* | |
269 | * Threadpool | |
270 | */ | |
271 | void uv_process_work_req(uv_loop_t* loop, uv_work_t* req); | |
272 | ||
273 | ||
274 | /* | |
275 | * FS Event | |
276 | */ | |
277 | void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, | |
278 | uv_fs_event_t* handle); | |
279 | void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle); | |
280 | void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle); | |
281 | ||
282 | ||
283 | /* | |
284 | * Stat poller. | |
285 | */ | |
286 | void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle); | |
287 | ||
288 | ||
289 | /* | |
290 | * Utilities. | |
291 | */ | |
292 | void uv__util_init(); | |
293 | ||
294 | int uv_parent_pid(); | |
295 | void uv_fatal_error(const int errorno, const char* syscall); | |
296 | uv_err_code uv_translate_sys_error(int sys_errno); | |
297 | ||
298 | ||
299 | /* | |
300 | * Process stdio handles. | |
301 | */ | |
302 | uv_err_t uv__stdio_create(uv_loop_t* loop, uv_process_options_t* options, | |
303 | BYTE** buffer_ptr); | |
304 | void uv__stdio_destroy(BYTE* buffer); | |
305 | void uv__stdio_noinherit(BYTE* buffer); | |
306 | int uv__stdio_verify(BYTE* buffer, WORD size); | |
307 | WORD uv__stdio_size(BYTE* buffer); | |
308 | HANDLE uv__stdio_handle(BYTE* buffer, int fd); | |
309 | ||
310 | ||
311 | /* | |
312 | * Winapi and ntapi utility functions | |
313 | */ | |
314 | void uv_winapi_init(); | |
315 | ||
316 | ||
317 | /* | |
318 | * Winsock utility functions | |
319 | */ | |
320 | void uv_winsock_init(); | |
321 | ||
322 | int uv_ntstatus_to_winsock_error(NTSTATUS status); | |
323 | ||
324 | BOOL uv_get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target); | |
325 | BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target); | |
326 | ||
327 | int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF* buffers, | |
328 | DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped, | |
329 | LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); | |
330 | int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers, | |
331 | DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr, | |
332 | int* addr_len, WSAOVERLAPPED *overlapped, | |
333 | LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); | |
334 | ||
335 | int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info, | |
336 | OVERLAPPED* overlapped); | |
337 | ||
338 | /* Whether there are any non-IFS LSPs stacked on TCP */ | |
339 | extern int uv_tcp_non_ifs_lsp_ipv4; | |
340 | extern int uv_tcp_non_ifs_lsp_ipv6; | |
341 | ||
342 | /* Ip address used to bind to any port at any interface */ | |
343 | extern struct sockaddr_in uv_addr_ip4_any_; | |
344 | extern struct sockaddr_in6 uv_addr_ip6_any_; | |
345 | ||
346 | #endif /* UV_WIN_INTERNAL_H_ */ |