Lines Matching refs:iface
56 static void wpa_priv_cmd_register(struct wpa_priv_interface *iface, in wpa_priv_cmd_register() argument
61 if (iface->drv_priv) { in wpa_priv_cmd_register()
63 if (iface->driver->deinit) in wpa_priv_cmd_register()
64 iface->driver->deinit(iface->drv_priv); in wpa_priv_cmd_register()
65 iface->drv_priv = NULL; in wpa_priv_cmd_register()
66 if (iface->drv_global_priv) { in wpa_priv_cmd_register()
67 iface->driver->global_deinit(iface->drv_global_priv); in wpa_priv_cmd_register()
68 iface->drv_global_priv = NULL; in wpa_priv_cmd_register()
70 iface->wpas_registered = 0; in wpa_priv_cmd_register()
74 if (iface->l2[i]) { in wpa_priv_cmd_register()
77 l2_packet_deinit(iface->l2[i]); in wpa_priv_cmd_register()
78 iface->l2[i] = NULL; in wpa_priv_cmd_register()
82 if (iface->driver->init2) { in wpa_priv_cmd_register()
83 if (iface->driver->global_init) { in wpa_priv_cmd_register()
84 iface->drv_global_priv = in wpa_priv_cmd_register()
85 iface->driver->global_init(iface->ctx); in wpa_priv_cmd_register()
86 if (!iface->drv_global_priv) { in wpa_priv_cmd_register()
92 iface->drv_global_priv = NULL; in wpa_priv_cmd_register()
94 iface->drv_priv = iface->driver->init2(iface, iface->ifname, in wpa_priv_cmd_register()
95 iface->drv_global_priv); in wpa_priv_cmd_register()
96 } else if (iface->driver->init) { in wpa_priv_cmd_register()
97 iface->drv_priv = iface->driver->init(iface, iface->ifname); in wpa_priv_cmd_register()
101 if (iface->drv_priv == NULL) { in wpa_priv_cmd_register()
107 "'%s'", iface->driver_name, iface->ifname); in wpa_priv_cmd_register()
109 os_memcpy(&iface->drv_addr, from, fromlen); in wpa_priv_cmd_register()
110 iface->drv_addr_len = fromlen; in wpa_priv_cmd_register()
111 iface->wpas_registered = 1; in wpa_priv_cmd_register()
113 if (iface->driver->set_param && in wpa_priv_cmd_register()
114 iface->driver->set_param(iface->drv_priv, NULL) < 0) { in wpa_priv_cmd_register()
120 static void wpa_priv_cmd_unregister(struct wpa_priv_interface *iface, in wpa_priv_cmd_unregister() argument
123 if (iface->drv_priv) { in wpa_priv_cmd_unregister()
124 if (iface->driver->deinit) in wpa_priv_cmd_unregister()
125 iface->driver->deinit(iface->drv_priv); in wpa_priv_cmd_unregister()
126 iface->drv_priv = NULL; in wpa_priv_cmd_unregister()
127 if (iface->drv_global_priv) { in wpa_priv_cmd_unregister()
128 iface->driver->global_deinit(iface->drv_global_priv); in wpa_priv_cmd_unregister()
129 iface->drv_global_priv = NULL; in wpa_priv_cmd_unregister()
131 iface->wpas_registered = 0; in wpa_priv_cmd_unregister()
136 static void wpa_priv_cmd_scan(struct wpa_priv_interface *iface, in wpa_priv_cmd_scan() argument
144 if (iface->drv_priv == NULL) in wpa_priv_cmd_scan()
176 if (iface->driver->scan2) in wpa_priv_cmd_scan()
177 iface->driver->scan2(iface->drv_priv, ¶ms); in wpa_priv_cmd_scan()
181 static void wpa_priv_get_scan_results2(struct wpa_priv_interface *iface, in wpa_priv_get_scan_results2() argument
190 res = iface->driver->get_scan_results2(iface->drv_priv); in wpa_priv_get_scan_results2()
214 sendto(iface->fd, buf, pos - buf, 0, (struct sockaddr *) from, fromlen); in wpa_priv_get_scan_results2()
223 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, fromlen); in wpa_priv_get_scan_results2()
227 static void wpa_priv_cmd_get_scan_results(struct wpa_priv_interface *iface, in wpa_priv_cmd_get_scan_results() argument
231 if (iface->drv_priv == NULL) in wpa_priv_cmd_get_scan_results()
234 if (iface->driver->get_scan_results2) in wpa_priv_cmd_get_scan_results()
235 wpa_priv_get_scan_results2(iface, from, fromlen); in wpa_priv_cmd_get_scan_results()
237 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, fromlen); in wpa_priv_cmd_get_scan_results()
241 static void wpa_priv_cmd_authenticate(struct wpa_priv_interface *iface, in wpa_priv_cmd_authenticate() argument
248 if (iface->drv_priv == NULL || iface->driver->authenticate == NULL) in wpa_priv_cmd_authenticate()
288 res = iface->driver->authenticate(iface->drv_priv, ¶ms); in wpa_priv_cmd_authenticate()
293 static void wpa_priv_cmd_associate(struct wpa_priv_interface *iface, in wpa_priv_cmd_associate() argument
301 if (iface->drv_priv == NULL || iface->driver->associate == NULL) in wpa_priv_cmd_associate()
336 res = iface->driver->associate(iface->drv_priv, ¶ms); in wpa_priv_cmd_associate()
341 static void wpa_priv_cmd_get_bssid(struct wpa_priv_interface *iface, in wpa_priv_cmd_get_bssid() argument
346 if (iface->drv_priv == NULL) in wpa_priv_cmd_get_bssid()
349 if (iface->driver->get_bssid == NULL || in wpa_priv_cmd_get_bssid()
350 iface->driver->get_bssid(iface->drv_priv, bssid) < 0) in wpa_priv_cmd_get_bssid()
353 sendto(iface->fd, bssid, ETH_ALEN, 0, (struct sockaddr *) from, in wpa_priv_cmd_get_bssid()
358 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, fromlen); in wpa_priv_cmd_get_bssid()
362 static void wpa_priv_cmd_get_ssid(struct wpa_priv_interface *iface, in wpa_priv_cmd_get_ssid() argument
368 if (iface->drv_priv == NULL) in wpa_priv_cmd_get_ssid()
371 if (iface->driver->get_ssid == NULL) in wpa_priv_cmd_get_ssid()
375 res = iface->driver->get_ssid(iface->drv_priv, &ssid[sizeof(int)]); in wpa_priv_cmd_get_ssid()
380 sendto(iface->fd, ssid, sizeof(ssid), 0, (struct sockaddr *) from, in wpa_priv_cmd_get_ssid()
385 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, fromlen); in wpa_priv_cmd_get_ssid()
389 static void wpa_priv_cmd_set_key(struct wpa_priv_interface *iface, in wpa_priv_cmd_set_key() argument
396 if (iface->drv_priv == NULL || iface->driver->set_key == NULL) in wpa_priv_cmd_set_key()
407 p.ifname = iface->ifname; in wpa_priv_cmd_set_key()
418 res = iface->driver->set_key(iface->drv_priv, &p); in wpa_priv_cmd_set_key()
423 static void wpa_priv_cmd_get_capa(struct wpa_priv_interface *iface, in wpa_priv_cmd_get_capa() argument
428 if (iface->drv_priv == NULL) in wpa_priv_cmd_get_capa()
431 if (iface->driver->get_capa == NULL || in wpa_priv_cmd_get_capa()
432 iface->driver->get_capa(iface->drv_priv, &capa) < 0) in wpa_priv_cmd_get_capa()
439 sendto(iface->fd, &capa, sizeof(capa), 0, (struct sockaddr *) from, in wpa_priv_cmd_get_capa()
444 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, fromlen); in wpa_priv_cmd_get_capa()
452 struct wpa_priv_interface *iface = l2_ctx->parent; in wpa_priv_l2_rx() local
464 msg.msg_name = &iface->l2_addr[l2_ctx->idx]; in wpa_priv_l2_rx()
465 msg.msg_namelen = iface->l2_addr_len[l2_ctx->idx]; in wpa_priv_l2_rx()
467 if (sendmsg(iface->fd, &msg, 0) < 0) { in wpa_priv_l2_rx()
480 static void wpa_priv_cmd_l2_register(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_register() argument
505 if (!iface->l2[idx]) in wpa_priv_cmd_l2_register()
513 os_memcpy(&iface->l2_addr[idx], from, fromlen); in wpa_priv_cmd_l2_register()
514 iface->l2_addr_len[idx] = fromlen; in wpa_priv_cmd_l2_register()
516 iface->l2_ctx[idx].idx = idx; in wpa_priv_cmd_l2_register()
517 iface->l2_ctx[idx].parent = iface; in wpa_priv_cmd_l2_register()
518 iface->l2[idx] = l2_packet_init(iface->ifname, NULL, proto, in wpa_priv_cmd_l2_register()
519 wpa_priv_l2_rx, &iface->l2_ctx[idx], in wpa_priv_cmd_l2_register()
521 if (!iface->l2[idx]) { in wpa_priv_cmd_l2_register()
527 if (l2_packet_get_own_addr(iface->l2[idx], own_addr) < 0) { in wpa_priv_cmd_l2_register()
530 l2_packet_deinit(iface->l2[idx]); in wpa_priv_cmd_l2_register()
531 iface->l2[idx] = NULL; in wpa_priv_cmd_l2_register()
535 res = sendto(iface->fd, own_addr, ETH_ALEN, 0, in wpa_priv_cmd_l2_register()
541 static void wpa_priv_cmd_l2_unregister(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_unregister() argument
548 if (iface->l2_addr_len[idx] == fromlen && in wpa_priv_cmd_l2_unregister()
549 os_memcmp(&iface->l2_addr[idx], from, fromlen) == 0) in wpa_priv_cmd_l2_unregister()
558 if (iface->l2[idx]) { in wpa_priv_cmd_l2_unregister()
559 l2_packet_deinit(iface->l2[idx]); in wpa_priv_cmd_l2_unregister()
560 iface->l2[idx] = NULL; in wpa_priv_cmd_l2_unregister()
565 static void wpa_priv_cmd_l2_notify_auth_start(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_notify_auth_start() argument
571 if (iface->l2[idx]) in wpa_priv_cmd_l2_notify_auth_start()
572 l2_packet_notify_auth_start(iface->l2[idx]); in wpa_priv_cmd_l2_notify_auth_start()
577 static void wpa_priv_cmd_l2_send(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_send() argument
587 if (iface->l2_addr_len[idx] == fromlen && in wpa_priv_cmd_l2_send()
588 os_memcmp(&iface->l2_addr[idx], from, fromlen) == 0) in wpa_priv_cmd_l2_send()
597 if (iface->l2[idx] == NULL) in wpa_priv_cmd_l2_send()
615 res = l2_packet_send(iface->l2[idx], dst_addr, proto, in wpa_priv_cmd_l2_send()
622 static void wpa_priv_cmd_set_country(struct wpa_priv_interface *iface, in wpa_priv_cmd_set_country() argument
625 if (iface->drv_priv == NULL || iface->driver->set_country == NULL || in wpa_priv_cmd_set_country()
629 iface->driver->set_country(iface->drv_priv, buf); in wpa_priv_cmd_set_country()
635 struct wpa_priv_interface *iface = eloop_ctx; in wpa_priv_receive() local
657 cmd, iface->ifname); in wpa_priv_receive()
663 wpa_priv_cmd_register(iface, &from, fromlen); in wpa_priv_receive()
666 wpa_priv_cmd_unregister(iface, &from); in wpa_priv_receive()
669 wpa_priv_cmd_scan(iface, cmd_buf, cmd_len); in wpa_priv_receive()
672 wpa_priv_cmd_get_scan_results(iface, &from, fromlen); in wpa_priv_receive()
675 wpa_priv_cmd_associate(iface, cmd_buf, cmd_len); in wpa_priv_receive()
678 wpa_priv_cmd_get_bssid(iface, &from, fromlen); in wpa_priv_receive()
681 wpa_priv_cmd_get_ssid(iface, &from, fromlen); in wpa_priv_receive()
684 wpa_priv_cmd_set_key(iface, cmd_buf, cmd_len); in wpa_priv_receive()
687 wpa_priv_cmd_get_capa(iface, &from, fromlen); in wpa_priv_receive()
690 wpa_priv_cmd_l2_register(iface, &from, fromlen, in wpa_priv_receive()
694 wpa_priv_cmd_l2_unregister(iface, &from, fromlen); in wpa_priv_receive()
697 wpa_priv_cmd_l2_notify_auth_start(iface, &from); in wpa_priv_receive()
700 wpa_priv_cmd_l2_send(iface, &from, fromlen, cmd_buf, cmd_len); in wpa_priv_receive()
707 wpa_priv_cmd_set_country(iface, pos); in wpa_priv_receive()
710 wpa_priv_cmd_authenticate(iface, cmd_buf, cmd_len); in wpa_priv_receive()
716 static void wpa_priv_interface_deinit(struct wpa_priv_interface *iface) in wpa_priv_interface_deinit() argument
720 if (iface->drv_priv) { in wpa_priv_interface_deinit()
721 if (iface->driver->deinit) in wpa_priv_interface_deinit()
722 iface->driver->deinit(iface->drv_priv); in wpa_priv_interface_deinit()
723 if (iface->drv_global_priv) in wpa_priv_interface_deinit()
724 iface->driver->global_deinit(iface->drv_global_priv); in wpa_priv_interface_deinit()
727 if (iface->fd >= 0) { in wpa_priv_interface_deinit()
728 eloop_unregister_read_sock(iface->fd); in wpa_priv_interface_deinit()
729 close(iface->fd); in wpa_priv_interface_deinit()
730 unlink(iface->sock_name); in wpa_priv_interface_deinit()
734 if (iface->l2[i]) in wpa_priv_interface_deinit()
735 l2_packet_deinit(iface->l2[i]); in wpa_priv_interface_deinit()
738 os_free(iface->ifname); in wpa_priv_interface_deinit()
739 os_free(iface->driver_name); in wpa_priv_interface_deinit()
740 os_free(iface->sock_name); in wpa_priv_interface_deinit()
741 os_free(iface); in wpa_priv_interface_deinit()
748 struct wpa_priv_interface *iface; in wpa_priv_interface_init() local
758 iface = os_zalloc(sizeof(*iface)); in wpa_priv_interface_init()
759 if (iface == NULL) in wpa_priv_interface_init()
761 iface->fd = -1; in wpa_priv_interface_init()
762 iface->ctx = ctx; in wpa_priv_interface_init()
765 iface->driver_name = dup_binstr(params, len); in wpa_priv_interface_init()
766 if (iface->driver_name == NULL) { in wpa_priv_interface_init()
767 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
772 if (os_strcmp(iface->driver_name, in wpa_priv_interface_init()
774 iface->driver = wpa_drivers[i]; in wpa_priv_interface_init()
778 if (iface->driver == NULL) { in wpa_priv_interface_init()
780 iface->driver_name); in wpa_priv_interface_init()
781 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
786 iface->ifname = os_strdup(pos); in wpa_priv_interface_init()
787 if (iface->ifname == NULL) { in wpa_priv_interface_init()
788 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
792 len = os_strlen(dir) + 1 + os_strlen(iface->ifname); in wpa_priv_interface_init()
793 iface->sock_name = os_malloc(len + 1); in wpa_priv_interface_init()
794 if (iface->sock_name == NULL) { in wpa_priv_interface_init()
795 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
799 os_snprintf(iface->sock_name, len + 1, "%s/%s", dir, iface->ifname); in wpa_priv_interface_init()
800 if (os_strlen(iface->sock_name) >= sizeof(addr.sun_path)) { in wpa_priv_interface_init()
801 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
805 iface->fd = socket(PF_UNIX, SOCK_DGRAM, 0); in wpa_priv_interface_init()
806 if (iface->fd < 0) { in wpa_priv_interface_init()
808 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
814 os_strlcpy(addr.sun_path, iface->sock_name, sizeof(addr.sun_path)); in wpa_priv_interface_init()
816 if (bind(iface->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { in wpa_priv_interface_init()
819 if (connect(iface->fd, (struct sockaddr *) &addr, in wpa_priv_interface_init()
824 if (unlink(iface->sock_name) < 0) { in wpa_priv_interface_init()
827 iface->sock_name, strerror(errno)); in wpa_priv_interface_init()
830 if (bind(iface->fd, (struct sockaddr *) &addr, in wpa_priv_interface_init()
838 "socket '%s'", iface->sock_name); in wpa_priv_interface_init()
843 "not used anymore", iface->sock_name); in wpa_priv_interface_init()
848 if (chmod(iface->sock_name, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { in wpa_priv_interface_init()
853 eloop_register_read_sock(iface->fd, wpa_priv_receive, iface, NULL); in wpa_priv_interface_init()
855 return iface; in wpa_priv_interface_init()
858 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
863 static int wpa_priv_send_event(struct wpa_priv_interface *iface, int event, in wpa_priv_send_event() argument
877 msg.msg_name = &iface->drv_addr; in wpa_priv_send_event()
878 msg.msg_namelen = iface->drv_addr_len; in wpa_priv_send_event()
880 if (sendmsg(iface->fd, &msg, 0) < 0) { in wpa_priv_send_event()
890 static void wpa_priv_send_auth(struct wpa_priv_interface *iface, in wpa_priv_send_auth() argument
914 wpa_priv_send_event(iface, PRIVSEP_EVENT_AUTH, buf, buflen); in wpa_priv_send_auth()
920 static void wpa_priv_send_assoc(struct wpa_priv_interface *iface, int event, in wpa_priv_send_assoc() argument
975 wpa_priv_send_event(iface, event, buf, buflen); in wpa_priv_send_assoc()
981 static void wpa_priv_send_interface_status(struct wpa_priv_interface *iface, in wpa_priv_send_interface_status() argument
1005 wpa_priv_send_event(iface, PRIVSEP_EVENT_INTERFACE_STATUS, in wpa_priv_send_interface_status()
1013 static void wpa_priv_send_ft_response(struct wpa_priv_interface *iface, in wpa_priv_send_ft_response() argument
1034 wpa_priv_send_event(iface, PRIVSEP_EVENT_FT_RESPONSE, buf, len); in wpa_priv_send_ft_response()
1044 struct wpa_priv_interface *iface = ctx; in wpa_supplicant_event() local
1048 if (!iface->wpas_registered) { in wpa_supplicant_event()
1056 wpa_priv_send_assoc(iface, PRIVSEP_EVENT_ASSOC, data); in wpa_supplicant_event()
1059 wpa_priv_send_event(iface, PRIVSEP_EVENT_DISASSOC, NULL, 0); in wpa_supplicant_event()
1064 wpa_priv_send_assoc(iface, PRIVSEP_EVENT_ASSOCINFO, data); in wpa_supplicant_event()
1069 wpa_priv_send_event(iface, PRIVSEP_EVENT_MICHAEL_MIC_FAILURE, in wpa_supplicant_event()
1074 wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_STARTED, NULL, in wpa_supplicant_event()
1078 wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_RESULTS, NULL, in wpa_supplicant_event()
1082 wpa_priv_send_interface_status(iface, data); in wpa_supplicant_event()
1087 wpa_priv_send_event(iface, PRIVSEP_EVENT_PMKID_CANDIDATE, in wpa_supplicant_event()
1092 wpa_priv_send_ft_response(iface, data); in wpa_supplicant_event()
1095 wpa_priv_send_auth(iface, data); in wpa_supplicant_event()
1109 struct wpa_priv_interface *iface; in wpa_supplicant_event_global() local
1114 for (iface = global->interfaces; iface; iface = iface->next) { in wpa_supplicant_event_global()
1115 if (os_strcmp(iface->ifname, data->interface_status.ifname) == in wpa_supplicant_event_global()
1119 if (iface && iface->driver->get_ifindex) { in wpa_supplicant_event_global()
1122 ifindex = iface->driver->get_ifindex(iface->drv_priv); in wpa_supplicant_event_global()
1126 iface->ifname, ifindex, in wpa_supplicant_event_global()
1131 if (iface) in wpa_supplicant_event_global()
1132 wpa_supplicant_event(iface, event, data); in wpa_supplicant_event_global()
1139 struct wpa_priv_interface *iface = ctx; in wpa_supplicant_rx_eapol() local
1155 msg.msg_name = &iface->drv_addr; in wpa_supplicant_rx_eapol()
1156 msg.msg_namelen = iface->drv_addr_len; in wpa_supplicant_rx_eapol()
1158 if (sendmsg(iface->fd, &msg, 0) < 0) in wpa_supplicant_rx_eapol()
1213 struct wpa_priv_interface *iface; in main() local
1260 iface = wpa_priv_interface_init(&global, ctrl_dir, argv[i]); in main()
1261 if (iface == NULL) in main()
1263 iface->next = global.interfaces; in main()
1264 global.interfaces = iface; in main()
1276 iface = global.interfaces; in main()
1277 while (iface) { in main()
1278 struct wpa_priv_interface *prev = iface; in main()
1279 iface = iface->next; in main()