Lines Matching refs:dst

87 static void ctrl_close_pipe(struct wpa_ctrl_dst *dst);
93 static void global_close_pipe(struct wpa_global_dst *dst);
116 struct wpa_ctrl_dst *dst, *next;
118 dst = priv->ctrl_dst;
120 while (dst) {
121 next = dst->next;
122 if (ctrl_broken_pipe(dst->pipe, dst->used)) {
124 dst);
125 ctrl_close_pipe(dst);
127 dst = next;
134 struct wpa_ctrl_dst *dst;
138 dst = os_zalloc(sizeof(*dst));
139 if (dst == NULL)
141 wpa_printf(MSG_DEBUG, "CTRL: Open pipe %p", dst);
143 dst->priv = priv;
144 dst->debug_level = MSG_INFO;
145 dst->pipe = INVALID_HANDLE_VALUE;
147 dst->overlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
148 if (dst->overlap.hEvent == NULL) {
154 eloop_register_event(dst->overlap.hEvent,
155 sizeof(dst->overlap.hEvent),
156 wpa_supplicant_ctrl_iface_receive, dst, NULL);
167 dst->pipe = CreateNamedPipe(name,
175 if (dst->pipe == INVALID_HANDLE_VALUE) {
181 if (ConnectNamedPipe(dst->pipe, &dst->overlap)) {
184 CloseHandle(dst->pipe);
185 os_free(dst);
198 if (SetEvent(dst->overlap.hEvent))
204 CloseHandle(dst->pipe);
205 os_free(dst);
209 dst->next = priv->ctrl_dst;
210 if (dst->next)
211 dst->next->prev = dst;
212 priv->ctrl_dst = dst;
217 ctrl_close_pipe(dst);
222 static void ctrl_close_pipe(struct wpa_ctrl_dst *dst)
224 wpa_printf(MSG_DEBUG, "CTRL: close pipe %p", dst);
226 if (dst->overlap.hEvent) {
227 eloop_unregister_event(dst->overlap.hEvent,
228 sizeof(dst->overlap.hEvent));
229 CloseHandle(dst->overlap.hEvent);
232 if (dst->pipe != INVALID_HANDLE_VALUE) {
237 * FlushFileBuffers(dst->pipe);
239 CloseHandle(dst->pipe);
242 if (dst->prev)
243 dst->prev->next = dst->next;
245 dst->priv->ctrl_dst = dst->next;
246 if (dst->next)
247 dst->next->prev = dst->prev;
249 os_free(dst->rsp_buf);
250 os_free(dst);
257 struct wpa_ctrl_dst *dst = (struct wpa_ctrl_dst *) overlap;
258 wpa_printf(MSG_DEBUG, "CTRL: Overlapped write completed: dst=%p "
259 "err=%d bytes=%d", dst, (int) err, (int) bytes);
261 ctrl_close_pipe(dst);
265 os_free(dst->rsp_buf);
266 dst->rsp_buf = NULL;
268 if (!ReadFileEx(dst->pipe, dst->req_buf, sizeof(dst->req_buf),
269 &dst->overlap, ctrl_iface_read_completed)) {
272 ctrl_close_pipe(dst);
275 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read started for %p", dst);
279 static void wpa_supplicant_ctrl_iface_rx(struct wpa_ctrl_dst *dst, size_t len)
281 struct wpa_supplicant *wpa_s = dst->priv->wpa_s;
285 char *buf = dst->req_buf;
287 dst->used = 1;
293 dst->attached = 1;
298 dst->attached = 0;
303 dst->debug_level = atoi(buf + 6);
321 os_free(dst->rsp_buf);
322 dst->rsp_buf = os_malloc(send_len);
323 if (dst->rsp_buf == NULL) {
324 ctrl_close_pipe(dst);
328 os_memcpy(dst->rsp_buf, send_buf, send_len);
331 if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap,
335 ctrl_close_pipe(dst);
338 dst);
349 struct wpa_ctrl_dst *dst = (struct wpa_ctrl_dst *) overlap;
350 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read completed: dst=%p err=%d "
351 "bytes=%d", dst, (int) err, (int) bytes);
353 wpa_supplicant_ctrl_iface_rx(dst, bytes);
359 struct wpa_ctrl_dst *dst = eloop_data;
360 struct ctrl_iface_priv *priv = dst->priv;
364 ResetEvent(dst->overlap.hEvent);
366 if (!GetOverlappedResult(dst->pipe, &dst->overlap, &bytes, FALSE)) {
378 ctrl_iface_write_completed(0, 0, &dst->overlap);
479 struct wpa_ctrl_dst *dst, *next;
486 dst = priv->ctrl_dst;
487 if (dst == NULL)
501 while (dst) {
502 next = dst->next;
503 if (dst->attached && level >= dst->debug_level) {
505 dst);
506 if (!WriteFile(dst->pipe, sbuf, llen + len, &written,
508 wpa_printf(MSG_DEBUG, "CTRL: WriteFile to dst "
510 dst, (int) GetLastError());
511 dst->errors++;
512 if (dst->errors > 10)
513 ctrl_close_pipe(dst);
515 dst->errors = 0;
518 dst = next;
558 struct wpa_global_dst *dst, *next;
560 dst = priv->ctrl_dst;
562 while (dst) {
563 next = dst->next;
564 if (ctrl_broken_pipe(dst->pipe, dst->used)) {
566 dst);
567 global_close_pipe(dst);
569 dst = next;
576 struct wpa_global_dst *dst;
579 dst = os_zalloc(sizeof(*dst));
580 if (dst == NULL)
582 wpa_printf(MSG_DEBUG, "CTRL: Open pipe %p", dst);
584 dst->priv = priv;
585 dst->pipe = INVALID_HANDLE_VALUE;
587 dst->overlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
588 if (dst->overlap.hEvent == NULL) {
594 eloop_register_event(dst->overlap.hEvent,
595 sizeof(dst->overlap.hEvent),
596 wpa_supplicant_global_iface_receive, dst, NULL);
599 dst->pipe = CreateNamedPipe(NAMED_PIPE_PREFIX,
606 if (dst->pipe == INVALID_HANDLE_VALUE) {
612 if (ConnectNamedPipe(dst->pipe, &dst->overlap)) {
615 CloseHandle(dst->pipe);
616 os_free(dst);
629 if (SetEvent(dst->overlap.hEvent))
635 CloseHandle(dst->pipe);
636 os_free(dst);
640 dst->next = priv->ctrl_dst;
641 if (dst->next)
642 dst->next->prev = dst;
643 priv->ctrl_dst = dst;
648 global_close_pipe(dst);
653 static void global_close_pipe(struct wpa_global_dst *dst)
655 wpa_printf(MSG_DEBUG, "CTRL: close pipe %p", dst);
657 if (dst->overlap.hEvent) {
658 eloop_unregister_event(dst->overlap.hEvent,
659 sizeof(dst->overlap.hEvent));
660 CloseHandle(dst->overlap.hEvent);
663 if (dst->pipe != INVALID_HANDLE_VALUE) {
668 * FlushFileBuffers(dst->pipe);
670 CloseHandle(dst->pipe);
673 if (dst->prev)
674 dst->prev->next = dst->next;
676 dst->priv->ctrl_dst = dst->next;
677 if (dst->next)
678 dst->next->prev = dst->prev;
680 os_free(dst->rsp_buf);
681 os_free(dst);
688 struct wpa_global_dst *dst = (struct wpa_global_dst *) overlap;
689 wpa_printf(MSG_DEBUG, "CTRL: Overlapped write completed: dst=%p "
690 "err=%d bytes=%d", dst, (int) err, (int) bytes);
692 global_close_pipe(dst);
696 os_free(dst->rsp_buf);
697 dst->rsp_buf = NULL;
699 if (!ReadFileEx(dst->pipe, dst->req_buf, sizeof(dst->req_buf),
700 &dst->overlap, global_iface_read_completed)) {
703 global_close_pipe(dst);
709 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read started for %p", dst);
713 static void wpa_supplicant_global_iface_rx(struct wpa_global_dst *dst,
716 struct wpa_global *global = dst->priv->global;
719 char *buf = dst->req_buf;
721 dst->used = 1;
735 os_free(dst->rsp_buf);
736 dst->rsp_buf = NULL;
740 os_free(dst->rsp_buf);
741 dst->rsp_buf = os_malloc(send_len);
742 if (dst->rsp_buf == NULL) {
743 global_close_pipe(dst);
747 os_memcpy(dst->rsp_buf, send_buf, send_len);
750 if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap,
754 global_close_pipe(dst);
757 dst);
765 struct wpa_global_dst *dst = (struct wpa_global_dst *) overlap;
766 wpa_printf(MSG_DEBUG, "CTRL: Overlapped read completed: dst=%p err=%d "
767 "bytes=%d", dst, (int) err, (int) bytes);
769 wpa_supplicant_global_iface_rx(dst, bytes);
776 struct wpa_global_dst *dst = eloop_data;
777 struct ctrl_iface_global_priv *priv = dst->priv;
781 ResetEvent(dst->overlap.hEvent);
783 if (!GetOverlappedResult(dst->pipe, &dst->overlap, &bytes, FALSE)) {
798 global_iface_write_completed(0, 0, &dst->overlap);