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;
124 dst = priv->ctrl_dst;
126 while (dst) {
127 next = dst->next;
128 if (ctrl_broken_pipe(dst->pipe, dst->used)) {
130 dst);
131 ctrl_close_pipe(dst);
133 dst = next;
140 struct wpa_ctrl_dst *dst;
144 dst = os_zalloc(sizeof(*dst));
145 if (dst == NULL)
147 wpa_printf(MSG_DEBUG, "CTRL: Open pipe %p", dst);
149 dst->priv = priv;
150 dst->debug_level = MSG_INFO;
151 dst->pipe = INVALID_HANDLE_VALUE;
153 dst->overlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
154 if (dst->overlap.hEvent == NULL) {
160 eloop_register_event(dst->overlap.hEvent,
161 sizeof(dst->overlap.hEvent),
162 wpa_supplicant_ctrl_iface_receive, dst, NULL);
173 dst->pipe = CreateNamedPipe(name,
181 if (dst->pipe == INVALID_HANDLE_VALUE) {
187 if (ConnectNamedPipe(dst->pipe, &dst->overlap)) {
190 CloseHandle(dst->pipe);
191 os_free(dst);
204 if (SetEvent(dst->overlap.hEvent))
210 CloseHandle(dst->pipe);
211 os_free(dst);
215 dst->next = priv->ctrl_dst;
216 if (dst->next)
217 dst->next->prev = dst;
218 priv->ctrl_dst = dst;
223 ctrl_close_pipe(dst);
228 static void ctrl_close_pipe(struct wpa_ctrl_dst *dst)
230 wpa_printf(MSG_DEBUG, "CTRL: close pipe %p", dst);
232 if (dst->overlap.hEvent) {
233 eloop_unregister_event(dst->overlap.hEvent,
234 sizeof(dst->overlap.hEvent));
235 CloseHandle(dst->overlap.hEvent);
238 if (dst->pipe != INVALID_HANDLE_VALUE) {
243 * FlushFileBuffers(dst->pipe);
245 CloseHandle(dst->pipe);
248 if (dst->prev)
249 dst->prev->next = dst->next;
251 dst->priv->ctrl_dst = dst->next;
252 if (dst->next)
253 dst->next->prev = dst->prev;
255 os_free(dst->rsp_buf);
256 os_free(dst);
263 struct wpa_ctrl_dst *dst = (struct wpa_ctrl_dst *) overlap;
264 wpa_printf(MSG_DEBUG, "CTRL: Overlapped write completed: dst=%p "
265 "err=%d bytes=%d", dst, (int) err, (int) bytes);
267 ctrl_close_pipe(dst);
271 os_free(dst->rsp_buf);
272 dst->rsp_buf = NULL;
274 if (!ReadFileEx(dst->pipe, dst->req_buf, sizeof(dst->req_buf),
275 &dst->overlap, ctrl_iface_read_completed)) {
278 ctrl_close_pipe(dst);
281 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read started for %p", dst);
285 static void wpa_supplicant_ctrl_iface_rx(struct wpa_ctrl_dst *dst, size_t len)
287 struct wpa_supplicant *wpa_s = dst->priv->wpa_s;
291 char *buf = dst->req_buf;
293 dst->used = 1;
299 dst->attached = 1;
304 dst->attached = 0;
309 dst->debug_level = atoi(buf + 6);
327 os_free(dst->rsp_buf);
328 dst->rsp_buf = os_malloc(send_len);
329 if (dst->rsp_buf == NULL) {
330 ctrl_close_pipe(dst);
334 os_memcpy(dst->rsp_buf, send_buf, send_len);
337 if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap,
341 ctrl_close_pipe(dst);
344 dst);
355 struct wpa_ctrl_dst *dst = (struct wpa_ctrl_dst *) overlap;
356 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read completed: dst=%p err=%d "
357 "bytes=%d", dst, (int) err, (int) bytes);
359 wpa_supplicant_ctrl_iface_rx(dst, bytes);
365 struct wpa_ctrl_dst *dst = eloop_data;
366 struct ctrl_iface_priv *priv = dst->priv;
370 ResetEvent(dst->overlap.hEvent);
372 if (!GetOverlappedResult(dst->pipe, &dst->overlap, &bytes, FALSE)) {
384 ctrl_iface_write_completed(0, 0, &dst->overlap);
485 struct wpa_ctrl_dst *dst, *next;
492 dst = priv->ctrl_dst;
493 if (dst == NULL)
507 while (dst) {
508 next = dst->next;
509 if (dst->attached && level >= dst->debug_level) {
511 dst);
512 if (!WriteFile(dst->pipe, sbuf, llen + len, &written,
514 wpa_printf(MSG_DEBUG, "CTRL: WriteFile to dst "
516 dst, (int) GetLastError());
517 dst->errors++;
518 if (dst->errors > 10)
519 ctrl_close_pipe(dst);
521 dst->errors = 0;
524 dst = next;
564 struct wpa_global_dst *dst, *next;
566 dst = priv->ctrl_dst;
568 while (dst) {
569 next = dst->next;
570 if (ctrl_broken_pipe(dst->pipe, dst->used)) {
572 dst);
573 global_close_pipe(dst);
575 dst = next;
582 struct wpa_global_dst *dst;
585 dst = os_zalloc(sizeof(*dst));
586 if (dst == NULL)
588 wpa_printf(MSG_DEBUG, "CTRL: Open pipe %p", dst);
590 dst->priv = priv;
591 dst->pipe = INVALID_HANDLE_VALUE;
593 dst->overlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
594 if (dst->overlap.hEvent == NULL) {
600 eloop_register_event(dst->overlap.hEvent,
601 sizeof(dst->overlap.hEvent),
602 wpa_supplicant_global_iface_receive, dst, NULL);
605 dst->pipe = CreateNamedPipe(NAMED_PIPE_PREFIX,
612 if (dst->pipe == INVALID_HANDLE_VALUE) {
618 if (ConnectNamedPipe(dst->pipe, &dst->overlap)) {
621 CloseHandle(dst->pipe);
622 os_free(dst);
635 if (SetEvent(dst->overlap.hEvent))
641 CloseHandle(dst->pipe);
642 os_free(dst);
646 dst->next = priv->ctrl_dst;
647 if (dst->next)
648 dst->next->prev = dst;
649 priv->ctrl_dst = dst;
654 global_close_pipe(dst);
659 static void global_close_pipe(struct wpa_global_dst *dst)
661 wpa_printf(MSG_DEBUG, "CTRL: close pipe %p", dst);
663 if (dst->overlap.hEvent) {
664 eloop_unregister_event(dst->overlap.hEvent,
665 sizeof(dst->overlap.hEvent));
666 CloseHandle(dst->overlap.hEvent);
669 if (dst->pipe != INVALID_HANDLE_VALUE) {
674 * FlushFileBuffers(dst->pipe);
676 CloseHandle(dst->pipe);
679 if (dst->prev)
680 dst->prev->next = dst->next;
682 dst->priv->ctrl_dst = dst->next;
683 if (dst->next)
684 dst->next->prev = dst->prev;
686 os_free(dst->rsp_buf);
687 os_free(dst);
694 struct wpa_global_dst *dst = (struct wpa_global_dst *) overlap;
695 wpa_printf(MSG_DEBUG, "CTRL: Overlapped write completed: dst=%p "
696 "err=%d bytes=%d", dst, (int) err, (int) bytes);
698 global_close_pipe(dst);
702 os_free(dst->rsp_buf);
703 dst->rsp_buf = NULL;
705 if (!ReadFileEx(dst->pipe, dst->req_buf, sizeof(dst->req_buf),
706 &dst->overlap, global_iface_read_completed)) {
709 global_close_pipe(dst);
715 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read started for %p", dst);
719 static void wpa_supplicant_global_iface_rx(struct wpa_global_dst *dst,
722 struct wpa_global *global = dst->priv->global;
725 char *buf = dst->req_buf;
727 dst->used = 1;
741 os_free(dst->rsp_buf);
742 dst->rsp_buf = NULL;
746 os_free(dst->rsp_buf);
747 dst->rsp_buf = os_malloc(send_len);
748 if (dst->rsp_buf == NULL) {
749 global_close_pipe(dst);
753 os_memcpy(dst->rsp_buf, send_buf, send_len);
756 if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap,
760 global_close_pipe(dst);
763 dst);
771 struct wpa_global_dst *dst = (struct wpa_global_dst *) overlap;
772 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read completed: dst=%p err=%d "
773 "bytes=%d", dst, (int) err, (int) bytes);
775 wpa_supplicant_global_iface_rx(dst, bytes);
782 struct wpa_global_dst *dst = eloop_data;
783 struct ctrl_iface_global_priv *priv = dst->priv;
787 ResetEvent(dst->overlap.hEvent);
789 if (!GetOverlappedResult(dst->pipe, &dst->overlap, &bytes, FALSE)) {
804 global_iface_write_completed(0, 0, &dst->overlap);