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
395 if (iface->drv_priv == NULL || iface->driver->set_key == NULL) in wpa_priv_cmd_set_key()
405 res = iface->driver->set_key(iface->ifname, iface->drv_priv, in wpa_priv_cmd_set_key()
417 static void wpa_priv_cmd_get_capa(struct wpa_priv_interface *iface, in wpa_priv_cmd_get_capa() argument
422 if (iface->drv_priv == NULL) in wpa_priv_cmd_get_capa()
425 if (iface->driver->get_capa == NULL || in wpa_priv_cmd_get_capa()
426 iface->driver->get_capa(iface->drv_priv, &capa) < 0) in wpa_priv_cmd_get_capa()
433 sendto(iface->fd, &capa, sizeof(capa), 0, (struct sockaddr *) from, in wpa_priv_cmd_get_capa()
438 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, fromlen); in wpa_priv_cmd_get_capa()
446 struct wpa_priv_interface *iface = l2_ctx->parent; in wpa_priv_l2_rx() local
458 msg.msg_name = &iface->l2_addr[l2_ctx->idx]; in wpa_priv_l2_rx()
459 msg.msg_namelen = iface->l2_addr_len[l2_ctx->idx]; in wpa_priv_l2_rx()
461 if (sendmsg(iface->fd, &msg, 0) < 0) { in wpa_priv_l2_rx()
474 static void wpa_priv_cmd_l2_register(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_register() argument
499 if (!iface->l2[idx]) in wpa_priv_cmd_l2_register()
507 os_memcpy(&iface->l2_addr[idx], from, fromlen); in wpa_priv_cmd_l2_register()
508 iface->l2_addr_len[idx] = fromlen; in wpa_priv_cmd_l2_register()
510 iface->l2_ctx[idx].idx = idx; in wpa_priv_cmd_l2_register()
511 iface->l2_ctx[idx].parent = iface; in wpa_priv_cmd_l2_register()
512 iface->l2[idx] = l2_packet_init(iface->ifname, NULL, proto, in wpa_priv_cmd_l2_register()
513 wpa_priv_l2_rx, &iface->l2_ctx[idx], in wpa_priv_cmd_l2_register()
515 if (!iface->l2[idx]) { in wpa_priv_cmd_l2_register()
521 if (l2_packet_get_own_addr(iface->l2[idx], own_addr) < 0) { in wpa_priv_cmd_l2_register()
524 l2_packet_deinit(iface->l2[idx]); in wpa_priv_cmd_l2_register()
525 iface->l2[idx] = NULL; in wpa_priv_cmd_l2_register()
529 res = sendto(iface->fd, own_addr, ETH_ALEN, 0, in wpa_priv_cmd_l2_register()
535 static void wpa_priv_cmd_l2_unregister(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_unregister() argument
542 if (iface->l2_addr_len[idx] == fromlen && in wpa_priv_cmd_l2_unregister()
543 os_memcmp(&iface->l2_addr[idx], from, fromlen) == 0) in wpa_priv_cmd_l2_unregister()
552 if (iface->l2[idx]) { in wpa_priv_cmd_l2_unregister()
553 l2_packet_deinit(iface->l2[idx]); in wpa_priv_cmd_l2_unregister()
554 iface->l2[idx] = NULL; in wpa_priv_cmd_l2_unregister()
559 static void wpa_priv_cmd_l2_notify_auth_start(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_notify_auth_start() argument
565 if (iface->l2[idx]) in wpa_priv_cmd_l2_notify_auth_start()
566 l2_packet_notify_auth_start(iface->l2[idx]); in wpa_priv_cmd_l2_notify_auth_start()
571 static void wpa_priv_cmd_l2_send(struct wpa_priv_interface *iface, in wpa_priv_cmd_l2_send() argument
581 if (iface->l2_addr_len[idx] == fromlen && in wpa_priv_cmd_l2_send()
582 os_memcmp(&iface->l2_addr[idx], from, fromlen) == 0) in wpa_priv_cmd_l2_send()
591 if (iface->l2[idx] == NULL) in wpa_priv_cmd_l2_send()
609 res = l2_packet_send(iface->l2[idx], dst_addr, proto, in wpa_priv_cmd_l2_send()
615 static void wpa_priv_cmd_set_country(struct wpa_priv_interface *iface, in wpa_priv_cmd_set_country() argument
618 if (iface->drv_priv == NULL || iface->driver->set_country == NULL || in wpa_priv_cmd_set_country()
622 iface->driver->set_country(iface->drv_priv, buf); in wpa_priv_cmd_set_country()
628 struct wpa_priv_interface *iface = eloop_ctx; in wpa_priv_receive() local
650 cmd, iface->ifname); in wpa_priv_receive()
656 wpa_priv_cmd_register(iface, &from, fromlen); in wpa_priv_receive()
659 wpa_priv_cmd_unregister(iface, &from); in wpa_priv_receive()
662 wpa_priv_cmd_scan(iface, cmd_buf, cmd_len); in wpa_priv_receive()
665 wpa_priv_cmd_get_scan_results(iface, &from, fromlen); in wpa_priv_receive()
668 wpa_priv_cmd_associate(iface, cmd_buf, cmd_len); in wpa_priv_receive()
671 wpa_priv_cmd_get_bssid(iface, &from, fromlen); in wpa_priv_receive()
674 wpa_priv_cmd_get_ssid(iface, &from, fromlen); in wpa_priv_receive()
677 wpa_priv_cmd_set_key(iface, cmd_buf, cmd_len); in wpa_priv_receive()
680 wpa_priv_cmd_get_capa(iface, &from, fromlen); in wpa_priv_receive()
683 wpa_priv_cmd_l2_register(iface, &from, fromlen, in wpa_priv_receive()
687 wpa_priv_cmd_l2_unregister(iface, &from, fromlen); in wpa_priv_receive()
690 wpa_priv_cmd_l2_notify_auth_start(iface, &from); in wpa_priv_receive()
693 wpa_priv_cmd_l2_send(iface, &from, fromlen, cmd_buf, cmd_len); in wpa_priv_receive()
700 wpa_priv_cmd_set_country(iface, pos); in wpa_priv_receive()
703 wpa_priv_cmd_authenticate(iface, cmd_buf, cmd_len); in wpa_priv_receive()
709 static void wpa_priv_interface_deinit(struct wpa_priv_interface *iface) in wpa_priv_interface_deinit() argument
713 if (iface->drv_priv) { in wpa_priv_interface_deinit()
714 if (iface->driver->deinit) in wpa_priv_interface_deinit()
715 iface->driver->deinit(iface->drv_priv); in wpa_priv_interface_deinit()
716 if (iface->drv_global_priv) in wpa_priv_interface_deinit()
717 iface->driver->global_deinit(iface->drv_global_priv); in wpa_priv_interface_deinit()
720 if (iface->fd >= 0) { in wpa_priv_interface_deinit()
721 eloop_unregister_read_sock(iface->fd); in wpa_priv_interface_deinit()
722 close(iface->fd); in wpa_priv_interface_deinit()
723 unlink(iface->sock_name); in wpa_priv_interface_deinit()
727 if (iface->l2[i]) in wpa_priv_interface_deinit()
728 l2_packet_deinit(iface->l2[i]); in wpa_priv_interface_deinit()
731 os_free(iface->ifname); in wpa_priv_interface_deinit()
732 os_free(iface->driver_name); in wpa_priv_interface_deinit()
733 os_free(iface->sock_name); in wpa_priv_interface_deinit()
734 os_free(iface); in wpa_priv_interface_deinit()
741 struct wpa_priv_interface *iface; in wpa_priv_interface_init() local
751 iface = os_zalloc(sizeof(*iface)); in wpa_priv_interface_init()
752 if (iface == NULL) in wpa_priv_interface_init()
754 iface->fd = -1; in wpa_priv_interface_init()
755 iface->ctx = ctx; in wpa_priv_interface_init()
758 iface->driver_name = dup_binstr(params, len); in wpa_priv_interface_init()
759 if (iface->driver_name == NULL) { in wpa_priv_interface_init()
760 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
765 if (os_strcmp(iface->driver_name, in wpa_priv_interface_init()
767 iface->driver = wpa_drivers[i]; in wpa_priv_interface_init()
771 if (iface->driver == NULL) { in wpa_priv_interface_init()
773 iface->driver_name); in wpa_priv_interface_init()
774 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
779 iface->ifname = os_strdup(pos); in wpa_priv_interface_init()
780 if (iface->ifname == NULL) { in wpa_priv_interface_init()
781 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
785 len = os_strlen(dir) + 1 + os_strlen(iface->ifname); in wpa_priv_interface_init()
786 iface->sock_name = os_malloc(len + 1); in wpa_priv_interface_init()
787 if (iface->sock_name == NULL) { in wpa_priv_interface_init()
788 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
792 os_snprintf(iface->sock_name, len + 1, "%s/%s", dir, iface->ifname); in wpa_priv_interface_init()
793 if (os_strlen(iface->sock_name) >= sizeof(addr.sun_path)) { in wpa_priv_interface_init()
794 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
798 iface->fd = socket(PF_UNIX, SOCK_DGRAM, 0); in wpa_priv_interface_init()
799 if (iface->fd < 0) { in wpa_priv_interface_init()
801 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
807 os_strlcpy(addr.sun_path, iface->sock_name, sizeof(addr.sun_path)); in wpa_priv_interface_init()
809 if (bind(iface->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { in wpa_priv_interface_init()
812 if (connect(iface->fd, (struct sockaddr *) &addr, in wpa_priv_interface_init()
817 if (unlink(iface->sock_name) < 0) { in wpa_priv_interface_init()
820 iface->sock_name, strerror(errno)); in wpa_priv_interface_init()
823 if (bind(iface->fd, (struct sockaddr *) &addr, in wpa_priv_interface_init()
831 "socket '%s'", iface->sock_name); in wpa_priv_interface_init()
836 "not used anymore", iface->sock_name); in wpa_priv_interface_init()
841 if (chmod(iface->sock_name, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { in wpa_priv_interface_init()
846 eloop_register_read_sock(iface->fd, wpa_priv_receive, iface, NULL); in wpa_priv_interface_init()
848 return iface; in wpa_priv_interface_init()
851 wpa_priv_interface_deinit(iface); in wpa_priv_interface_init()
856 static int wpa_priv_send_event(struct wpa_priv_interface *iface, int event, in wpa_priv_send_event() argument
870 msg.msg_name = &iface->drv_addr; in wpa_priv_send_event()
871 msg.msg_namelen = iface->drv_addr_len; in wpa_priv_send_event()
873 if (sendmsg(iface->fd, &msg, 0) < 0) { in wpa_priv_send_event()
883 static void wpa_priv_send_auth(struct wpa_priv_interface *iface, in wpa_priv_send_auth() argument
907 wpa_priv_send_event(iface, PRIVSEP_EVENT_AUTH, buf, buflen); in wpa_priv_send_auth()
913 static void wpa_priv_send_assoc(struct wpa_priv_interface *iface, int event, in wpa_priv_send_assoc() argument
968 wpa_priv_send_event(iface, event, buf, buflen); in wpa_priv_send_assoc()
974 static void wpa_priv_send_interface_status(struct wpa_priv_interface *iface, in wpa_priv_send_interface_status() argument
998 wpa_priv_send_event(iface, PRIVSEP_EVENT_INTERFACE_STATUS, in wpa_priv_send_interface_status()
1006 static void wpa_priv_send_ft_response(struct wpa_priv_interface *iface, in wpa_priv_send_ft_response() argument
1027 wpa_priv_send_event(iface, PRIVSEP_EVENT_FT_RESPONSE, buf, len); in wpa_priv_send_ft_response()
1037 struct wpa_priv_interface *iface = ctx; in wpa_supplicant_event() local
1041 if (!iface->wpas_registered) { in wpa_supplicant_event()
1049 wpa_priv_send_assoc(iface, PRIVSEP_EVENT_ASSOC, data); in wpa_supplicant_event()
1052 wpa_priv_send_event(iface, PRIVSEP_EVENT_DISASSOC, NULL, 0); in wpa_supplicant_event()
1057 wpa_priv_send_assoc(iface, PRIVSEP_EVENT_ASSOCINFO, data); in wpa_supplicant_event()
1062 wpa_priv_send_event(iface, PRIVSEP_EVENT_MICHAEL_MIC_FAILURE, in wpa_supplicant_event()
1067 wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_STARTED, NULL, in wpa_supplicant_event()
1071 wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_RESULTS, NULL, in wpa_supplicant_event()
1075 wpa_priv_send_interface_status(iface, data); in wpa_supplicant_event()
1080 wpa_priv_send_event(iface, PRIVSEP_EVENT_PMKID_CANDIDATE, in wpa_supplicant_event()
1085 wpa_priv_send_ft_response(iface, data); in wpa_supplicant_event()
1088 wpa_priv_send_auth(iface, data); in wpa_supplicant_event()
1102 struct wpa_priv_interface *iface; in wpa_supplicant_event_global() local
1107 for (iface = global->interfaces; iface; iface = iface->next) { in wpa_supplicant_event_global()
1108 if (os_strcmp(iface->ifname, data->interface_status.ifname) == in wpa_supplicant_event_global()
1112 if (iface && iface->driver->get_ifindex) { in wpa_supplicant_event_global()
1115 ifindex = iface->driver->get_ifindex(iface->drv_priv); in wpa_supplicant_event_global()
1119 iface->ifname, ifindex, in wpa_supplicant_event_global()
1124 if (iface) in wpa_supplicant_event_global()
1125 wpa_supplicant_event(iface, event, data); in wpa_supplicant_event_global()
1132 struct wpa_priv_interface *iface = ctx; in wpa_supplicant_rx_eapol() local
1148 msg.msg_name = &iface->drv_addr; in wpa_supplicant_rx_eapol()
1149 msg.msg_namelen = iface->drv_addr_len; in wpa_supplicant_rx_eapol()
1151 if (sendmsg(iface->fd, &msg, 0) < 0) in wpa_supplicant_rx_eapol()
1205 struct wpa_priv_interface *iface; in main() local
1252 iface = wpa_priv_interface_init(&global, ctrl_dir, argv[i]); in main()
1253 if (iface == NULL) in main()
1255 iface->next = global.interfaces; in main()
1256 global.interfaces = iface; in main()
1268 iface = global.interfaces; in main()
1269 while (iface) { in main()
1270 struct wpa_priv_interface *prev = iface; in main()
1271 iface = iface->next; in main()