Lines Matching refs:dst
93 static void ctrl_close_pipe(struct wpa_ctrl_dst *dst);
99 static void global_close_pipe(struct wpa_global_dst *dst);
122 struct wpa_ctrl_dst *dst, *next; in ctrl_flush_broken_pipes() local
124 dst = priv->ctrl_dst; in ctrl_flush_broken_pipes()
126 while (dst) { in ctrl_flush_broken_pipes()
127 next = dst->next; in ctrl_flush_broken_pipes()
128 if (ctrl_broken_pipe(dst->pipe, dst->used)) { in ctrl_flush_broken_pipes()
130 dst); in ctrl_flush_broken_pipes()
131 ctrl_close_pipe(dst); in ctrl_flush_broken_pipes()
133 dst = next; in ctrl_flush_broken_pipes()
140 struct wpa_ctrl_dst *dst; in ctrl_open_pipe() local
144 dst = os_zalloc(sizeof(*dst)); in ctrl_open_pipe()
145 if (dst == NULL) in ctrl_open_pipe()
147 wpa_printf(MSG_DEBUG, "CTRL: Open pipe %p", dst); in ctrl_open_pipe()
149 dst->priv = priv; in ctrl_open_pipe()
150 dst->debug_level = MSG_INFO; in ctrl_open_pipe()
151 dst->pipe = INVALID_HANDLE_VALUE; in ctrl_open_pipe()
153 dst->overlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); in ctrl_open_pipe()
154 if (dst->overlap.hEvent == NULL) { in ctrl_open_pipe()
160 eloop_register_event(dst->overlap.hEvent, in ctrl_open_pipe()
161 sizeof(dst->overlap.hEvent), in ctrl_open_pipe()
162 wpa_supplicant_ctrl_iface_receive, dst, NULL); in ctrl_open_pipe()
173 dst->pipe = CreateNamedPipe(name, in ctrl_open_pipe()
181 if (dst->pipe == INVALID_HANDLE_VALUE) { in ctrl_open_pipe()
187 if (ConnectNamedPipe(dst->pipe, &dst->overlap)) { in ctrl_open_pipe()
190 CloseHandle(dst->pipe); in ctrl_open_pipe()
191 os_free(dst); in ctrl_open_pipe()
204 if (SetEvent(dst->overlap.hEvent)) in ctrl_open_pipe()
210 CloseHandle(dst->pipe); in ctrl_open_pipe()
211 os_free(dst); in ctrl_open_pipe()
215 dst->next = priv->ctrl_dst; in ctrl_open_pipe()
216 if (dst->next) in ctrl_open_pipe()
217 dst->next->prev = dst; in ctrl_open_pipe()
218 priv->ctrl_dst = dst; in ctrl_open_pipe()
223 ctrl_close_pipe(dst); in ctrl_open_pipe()
228 static void ctrl_close_pipe(struct wpa_ctrl_dst *dst) in ctrl_close_pipe() argument
230 wpa_printf(MSG_DEBUG, "CTRL: close pipe %p", dst); in ctrl_close_pipe()
232 if (dst->overlap.hEvent) { in ctrl_close_pipe()
233 eloop_unregister_event(dst->overlap.hEvent, in ctrl_close_pipe()
234 sizeof(dst->overlap.hEvent)); in ctrl_close_pipe()
235 CloseHandle(dst->overlap.hEvent); in ctrl_close_pipe()
238 if (dst->pipe != INVALID_HANDLE_VALUE) { in ctrl_close_pipe()
245 CloseHandle(dst->pipe); in ctrl_close_pipe()
248 if (dst->prev) in ctrl_close_pipe()
249 dst->prev->next = dst->next; in ctrl_close_pipe()
251 dst->priv->ctrl_dst = dst->next; in ctrl_close_pipe()
252 if (dst->next) in ctrl_close_pipe()
253 dst->next->prev = dst->prev; in ctrl_close_pipe()
255 os_free(dst->rsp_buf); in ctrl_close_pipe()
256 os_free(dst); in ctrl_close_pipe()
263 struct wpa_ctrl_dst *dst = (struct wpa_ctrl_dst *) overlap; in ctrl_iface_write_completed() local
265 "err=%d bytes=%d", dst, (int) err, (int) bytes); in ctrl_iface_write_completed()
267 ctrl_close_pipe(dst); in ctrl_iface_write_completed()
271 os_free(dst->rsp_buf); in ctrl_iface_write_completed()
272 dst->rsp_buf = NULL; in ctrl_iface_write_completed()
274 if (!ReadFileEx(dst->pipe, dst->req_buf, sizeof(dst->req_buf), in ctrl_iface_write_completed()
275 &dst->overlap, ctrl_iface_read_completed)) { in ctrl_iface_write_completed()
278 ctrl_close_pipe(dst); in ctrl_iface_write_completed()
281 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read started for %p", dst); in ctrl_iface_write_completed()
285 static void wpa_supplicant_ctrl_iface_rx(struct wpa_ctrl_dst *dst, size_t len) in wpa_supplicant_ctrl_iface_rx() argument
287 struct wpa_supplicant *wpa_s = dst->priv->wpa_s; in wpa_supplicant_ctrl_iface_rx()
291 char *buf = dst->req_buf; in wpa_supplicant_ctrl_iface_rx()
293 dst->used = 1; in wpa_supplicant_ctrl_iface_rx()
299 dst->attached = 1; in wpa_supplicant_ctrl_iface_rx()
304 dst->attached = 0; in wpa_supplicant_ctrl_iface_rx()
309 dst->debug_level = atoi(buf + 6); in wpa_supplicant_ctrl_iface_rx()
327 os_free(dst->rsp_buf); in wpa_supplicant_ctrl_iface_rx()
328 dst->rsp_buf = os_malloc(send_len); in wpa_supplicant_ctrl_iface_rx()
329 if (dst->rsp_buf == NULL) { in wpa_supplicant_ctrl_iface_rx()
330 ctrl_close_pipe(dst); in wpa_supplicant_ctrl_iface_rx()
334 os_memcpy(dst->rsp_buf, send_buf, send_len); in wpa_supplicant_ctrl_iface_rx()
337 if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap, in wpa_supplicant_ctrl_iface_rx()
341 ctrl_close_pipe(dst); in wpa_supplicant_ctrl_iface_rx()
344 dst); in wpa_supplicant_ctrl_iface_rx()
355 struct wpa_ctrl_dst *dst = (struct wpa_ctrl_dst *) overlap; in ctrl_iface_read_completed() local
357 "bytes=%d", dst, (int) err, (int) bytes); in ctrl_iface_read_completed()
359 wpa_supplicant_ctrl_iface_rx(dst, bytes); in ctrl_iface_read_completed()
365 struct wpa_ctrl_dst *dst = eloop_data; in wpa_supplicant_ctrl_iface_receive() local
366 struct ctrl_iface_priv *priv = dst->priv; in wpa_supplicant_ctrl_iface_receive()
370 ResetEvent(dst->overlap.hEvent); in wpa_supplicant_ctrl_iface_receive()
372 if (!GetOverlappedResult(dst->pipe, &dst->overlap, &bytes, FALSE)) { in wpa_supplicant_ctrl_iface_receive()
384 ctrl_iface_write_completed(0, 0, &dst->overlap); in wpa_supplicant_ctrl_iface_receive()
484 struct wpa_ctrl_dst *dst, *next; in wpa_supplicant_ctrl_iface_send() local
491 dst = priv->ctrl_dst; in wpa_supplicant_ctrl_iface_send()
492 if (dst == NULL) in wpa_supplicant_ctrl_iface_send()
506 while (dst) { in wpa_supplicant_ctrl_iface_send()
507 next = dst->next; in wpa_supplicant_ctrl_iface_send()
508 if (dst->attached && level >= dst->debug_level) { in wpa_supplicant_ctrl_iface_send()
510 dst); in wpa_supplicant_ctrl_iface_send()
511 if (!WriteFile(dst->pipe, sbuf, llen + len, &written, in wpa_supplicant_ctrl_iface_send()
515 dst, (int) GetLastError()); in wpa_supplicant_ctrl_iface_send()
516 dst->errors++; in wpa_supplicant_ctrl_iface_send()
517 if (dst->errors > 10) in wpa_supplicant_ctrl_iface_send()
518 ctrl_close_pipe(dst); in wpa_supplicant_ctrl_iface_send()
520 dst->errors = 0; in wpa_supplicant_ctrl_iface_send()
523 dst = next; in wpa_supplicant_ctrl_iface_send()
563 struct wpa_global_dst *dst, *next; in global_flush_broken_pipes() local
565 dst = priv->ctrl_dst; in global_flush_broken_pipes()
567 while (dst) { in global_flush_broken_pipes()
568 next = dst->next; in global_flush_broken_pipes()
569 if (ctrl_broken_pipe(dst->pipe, dst->used)) { in global_flush_broken_pipes()
571 dst); in global_flush_broken_pipes()
572 global_close_pipe(dst); in global_flush_broken_pipes()
574 dst = next; in global_flush_broken_pipes()
581 struct wpa_global_dst *dst; in global_open_pipe() local
584 dst = os_zalloc(sizeof(*dst)); in global_open_pipe()
585 if (dst == NULL) in global_open_pipe()
587 wpa_printf(MSG_DEBUG, "CTRL: Open pipe %p", dst); in global_open_pipe()
589 dst->priv = priv; in global_open_pipe()
590 dst->pipe = INVALID_HANDLE_VALUE; in global_open_pipe()
592 dst->overlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); in global_open_pipe()
593 if (dst->overlap.hEvent == NULL) { in global_open_pipe()
599 eloop_register_event(dst->overlap.hEvent, in global_open_pipe()
600 sizeof(dst->overlap.hEvent), in global_open_pipe()
601 wpa_supplicant_global_iface_receive, dst, NULL); in global_open_pipe()
604 dst->pipe = CreateNamedPipe(NAMED_PIPE_PREFIX, in global_open_pipe()
611 if (dst->pipe == INVALID_HANDLE_VALUE) { in global_open_pipe()
617 if (ConnectNamedPipe(dst->pipe, &dst->overlap)) { in global_open_pipe()
620 CloseHandle(dst->pipe); in global_open_pipe()
621 os_free(dst); in global_open_pipe()
634 if (SetEvent(dst->overlap.hEvent)) in global_open_pipe()
640 CloseHandle(dst->pipe); in global_open_pipe()
641 os_free(dst); in global_open_pipe()
645 dst->next = priv->ctrl_dst; in global_open_pipe()
646 if (dst->next) in global_open_pipe()
647 dst->next->prev = dst; in global_open_pipe()
648 priv->ctrl_dst = dst; in global_open_pipe()
653 global_close_pipe(dst); in global_open_pipe()
658 static void global_close_pipe(struct wpa_global_dst *dst) in global_close_pipe() argument
660 wpa_printf(MSG_DEBUG, "CTRL: close pipe %p", dst); in global_close_pipe()
662 if (dst->overlap.hEvent) { in global_close_pipe()
663 eloop_unregister_event(dst->overlap.hEvent, in global_close_pipe()
664 sizeof(dst->overlap.hEvent)); in global_close_pipe()
665 CloseHandle(dst->overlap.hEvent); in global_close_pipe()
668 if (dst->pipe != INVALID_HANDLE_VALUE) { in global_close_pipe()
675 CloseHandle(dst->pipe); in global_close_pipe()
678 if (dst->prev) in global_close_pipe()
679 dst->prev->next = dst->next; in global_close_pipe()
681 dst->priv->ctrl_dst = dst->next; in global_close_pipe()
682 if (dst->next) in global_close_pipe()
683 dst->next->prev = dst->prev; in global_close_pipe()
685 os_free(dst->rsp_buf); in global_close_pipe()
686 os_free(dst); in global_close_pipe()
693 struct wpa_global_dst *dst = (struct wpa_global_dst *) overlap; in global_iface_write_completed() local
695 "err=%d bytes=%d", dst, (int) err, (int) bytes); in global_iface_write_completed()
697 global_close_pipe(dst); in global_iface_write_completed()
701 os_free(dst->rsp_buf); in global_iface_write_completed()
702 dst->rsp_buf = NULL; in global_iface_write_completed()
704 if (!ReadFileEx(dst->pipe, dst->req_buf, sizeof(dst->req_buf), in global_iface_write_completed()
705 &dst->overlap, global_iface_read_completed)) { in global_iface_write_completed()
708 global_close_pipe(dst); in global_iface_write_completed()
714 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read started for %p", dst); in global_iface_write_completed()
718 static void wpa_supplicant_global_iface_rx(struct wpa_global_dst *dst, in wpa_supplicant_global_iface_rx() argument
721 struct wpa_global *global = dst->priv->global; in wpa_supplicant_global_iface_rx()
724 char *buf = dst->req_buf; in wpa_supplicant_global_iface_rx()
726 dst->used = 1; in wpa_supplicant_global_iface_rx()
740 os_free(dst->rsp_buf); in wpa_supplicant_global_iface_rx()
741 dst->rsp_buf = NULL; in wpa_supplicant_global_iface_rx()
745 os_free(dst->rsp_buf); in wpa_supplicant_global_iface_rx()
746 dst->rsp_buf = os_malloc(send_len); in wpa_supplicant_global_iface_rx()
747 if (dst->rsp_buf == NULL) { in wpa_supplicant_global_iface_rx()
748 global_close_pipe(dst); in wpa_supplicant_global_iface_rx()
752 os_memcpy(dst->rsp_buf, send_buf, send_len); in wpa_supplicant_global_iface_rx()
755 if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap, in wpa_supplicant_global_iface_rx()
759 global_close_pipe(dst); in wpa_supplicant_global_iface_rx()
762 dst); in wpa_supplicant_global_iface_rx()
770 struct wpa_global_dst *dst = (struct wpa_global_dst *) overlap; in global_iface_read_completed() local
772 "bytes=%d", dst, (int) err, (int) bytes); in global_iface_read_completed()
774 wpa_supplicant_global_iface_rx(dst, bytes); in global_iface_read_completed()
781 struct wpa_global_dst *dst = eloop_data; in wpa_supplicant_global_iface_receive() local
782 struct ctrl_iface_global_priv *priv = dst->priv; in wpa_supplicant_global_iface_receive()
786 ResetEvent(dst->overlap.hEvent); in wpa_supplicant_global_iface_receive()
788 if (!GetOverlappedResult(dst->pipe, &dst->overlap, &bytes, FALSE)) { in wpa_supplicant_global_iface_receive()
803 global_iface_write_completed(0, 0, &dst->overlap); in wpa_supplicant_global_iface_receive()