Lines Matching refs:drv
58 static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len, in handle_data() argument
82 wpa_supplicant_event(drv->hapd, EVENT_RX_FROM_UNKNOWN, &event); in handle_data()
109 drv_event_eapol_rx(drv->hapd, sa, pos, left); in handle_data()
119 static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf, in handle_tx_callback() argument
136 wpa_supplicant_event(drv->hapd, EVENT_TX_STATUS, &event); in handle_tx_callback()
140 static void handle_frame(struct hostap_driver_data *drv, u8 *buf, size_t len) in handle_frame() argument
172 handle_tx_callback(drv, buf, data_len, ver == 2 ? 1 : 0); in handle_frame()
184 wpa_supplicant_event(drv->hapd, EVENT_RX_MGMT, &event); in handle_frame()
191 handle_data(drv, buf, data_len, stype); in handle_frame()
202 struct hostap_driver_data *drv = eloop_ctx; in handle_read() local
212 handle_frame(drv, buf, len); in handle_read()
216 static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr) in hostap_init_sockets() argument
221 drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); in hostap_init_sockets()
222 if (drv->sock < 0) { in hostap_init_sockets()
228 if (eloop_register_read_sock(drv->sock, handle_read, drv, NULL)) { in hostap_init_sockets()
235 drv->iface) >= (int) sizeof(ifr.ifr_name)) { in hostap_init_sockets()
239 if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) { in hostap_init_sockets()
245 if (hostap_set_iface_flags(drv, 1)) { in hostap_init_sockets()
255 if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { in hostap_init_sockets()
260 return linux_get_ifhwaddr(drv->sock, drv->iface, own_addr); in hostap_init_sockets()
269 struct hostap_driver_data *drv = priv; in hostap_send_mlme() local
275 res = send(drv->sock, msg, len, 0); in hostap_send_mlme()
286 struct hostap_driver_data *drv = priv; in hostap_send_eapol() local
316 res = hostap_send_mlme(drv, (u8 *) hdr, len, 0, 0, NULL, 0, 0, 0); in hostap_send_eapol()
332 struct hostap_driver_data *drv = priv; in hostap_sta_set_flags() local
346 return hostapd_ioctl(drv, ¶m, sizeof(param)); in hostap_sta_set_flags()
352 struct hostap_driver_data *drv = priv; in hostap_set_iface_flags() local
356 if (os_snprintf(ifname, IFNAMSIZ, "%sap", drv->iface) >= IFNAMSIZ) { in hostap_set_iface_flags()
360 if (linux_set_iface_flags(drv->ioctl_sock, ifname, dev_up) < 0) in hostap_set_iface_flags()
367 if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) { in hostap_set_iface_flags()
381 struct hostap_driver_data *drv = priv; in hostapd_ioctl() local
385 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostapd_ioctl()
389 if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) { in hostapd_ioctl()
402 struct hostap_driver_data *drv = priv; in wpa_driver_hostap_set_key() local
451 if (hostapd_ioctl(drv, param, blen)) { in wpa_driver_hostap_set_key()
464 struct hostap_driver_data *drv = priv; in hostap_get_seqnum() local
483 if (hostapd_ioctl(drv, param, blen)) { in hostap_get_seqnum()
497 struct hostap_driver_data *drv = priv; in hostap_ioctl_prism2param() local
502 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_ioctl_prism2param()
507 if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_PRISM2_PARAM, &iwr) < 0) { in hostap_ioctl_prism2param()
519 struct hostap_driver_data *drv = priv; in hostap_set_ieee8021x() local
523 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_IEEE_802_1X, enabled)) { in hostap_set_ieee8021x()
534 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_DECRYPT, 1) || in hostap_set_ieee8021x()
535 hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_ENCRYPT, 1)) { in hostap_set_ieee8021x()
547 struct hostap_drvier_data *drv = priv; in hostap_set_privacy() local
549 return hostap_ioctl_prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED, in hostap_set_privacy()
556 struct hostap_driver_data *drv = priv; in hostap_set_ssid() local
560 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_set_ssid()
565 if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) { in hostap_set_ssid()
577 struct hostap_driver_data *drv = priv; in hostap_flush() local
582 return hostapd_ioctl(drv, ¶m, sizeof(param)); in hostap_flush()
590 struct hostap_driver_data *drv = priv; in hostap_read_sta_data() local
597 drv->iface, MAC2STR(addr)); in hostap_read_sta_data()
630 struct hostap_driver_data *drv = priv; in hostap_sta_add() local
657 return hostapd_ioctl(drv, ¶m, sizeof(param)); in hostap_sta_add()
663 struct hostap_driver_data *drv = priv; in hostap_sta_remove() local
666 hostap_sta_set_flags(drv, addr, 0, 0, ~WPA_STA_AUTHORIZED); in hostap_sta_remove()
671 if (hostapd_ioctl(drv, ¶m, sizeof(param))) { in hostap_sta_remove()
681 struct hostap_driver_data *drv = priv; in hostap_get_inact_sec() local
687 if (hostapd_ioctl(drv, ¶m, sizeof(param))) { in hostap_get_inact_sec()
697 struct hostap_driver_data *drv = priv; in hostap_sta_clear_stats() local
703 if (hostapd_ioctl(drv, ¶m, sizeof(param))) { in hostap_sta_clear_stats()
711 static int hostapd_ioctl_set_generic_elem(struct hostap_driver_data *drv) in hostapd_ioctl_set_generic_elem() argument
717 elem_len = drv->generic_ie_len + drv->wps_ie_len; in hostapd_ioctl_set_generic_elem()
728 if (drv->generic_ie) { in hostapd_ioctl_set_generic_elem()
729 os_memcpy(param->u.generic_elem.data, drv->generic_ie, in hostapd_ioctl_set_generic_elem()
730 drv->generic_ie_len); in hostapd_ioctl_set_generic_elem()
732 if (drv->wps_ie) { in hostapd_ioctl_set_generic_elem()
733 os_memcpy(¶m->u.generic_elem.data[drv->generic_ie_len], in hostapd_ioctl_set_generic_elem()
734 drv->wps_ie, drv->wps_ie_len); in hostapd_ioctl_set_generic_elem()
738 res = hostapd_ioctl(drv, param, blen); in hostapd_ioctl_set_generic_elem()
749 struct hostap_driver_data *drv = priv; in hostap_set_generic_elem() local
751 os_free(drv->generic_ie); in hostap_set_generic_elem()
752 drv->generic_ie = NULL; in hostap_set_generic_elem()
753 drv->generic_ie_len = 0; in hostap_set_generic_elem()
755 drv->generic_ie = os_memdup(elem, elem_len); in hostap_set_generic_elem()
756 if (drv->generic_ie == NULL) in hostap_set_generic_elem()
758 drv->generic_ie_len = elem_len; in hostap_set_generic_elem()
761 return hostapd_ioctl_set_generic_elem(drv); in hostap_set_generic_elem()
769 struct hostap_driver_data *drv = priv; in hostap_set_ap_wps_ie() local
777 os_free(drv->wps_ie); in hostap_set_ap_wps_ie()
778 drv->wps_ie = NULL; in hostap_set_ap_wps_ie()
779 drv->wps_ie_len = 0; in hostap_set_ap_wps_ie()
781 drv->wps_ie = os_memdup(wpabuf_head(proberesp), in hostap_set_ap_wps_ie()
783 if (drv->wps_ie == NULL) in hostap_set_ap_wps_ie()
785 drv->wps_ie_len = wpabuf_len(proberesp); in hostap_set_ap_wps_ie()
788 return hostapd_ioctl_set_generic_elem(drv); in hostap_set_ap_wps_ie()
793 hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv, in hostapd_wireless_event_wireless_custom() argument
814 wpa_supplicant_event(drv->hapd, in hostapd_wireless_event_wireless_custom()
825 static void hostapd_wireless_event_wireless(struct hostap_driver_data *drv, in hostapd_wireless_event_wireless() argument
844 if (drv->we_version > 18 && in hostapd_wireless_event_wireless()
866 hostapd_wireless_event_wireless_custom(drv, buf); in hostapd_wireless_event_wireless()
880 struct hostap_driver_data *drv = ctx; in hostapd_wireless_event_rtm_newlink() local
894 drv, ((char *) attr) + rta_len, in hostapd_wireless_event_rtm_newlink()
902 static int hostap_get_we_version(struct hostap_driver_data *drv) in hostap_get_we_version() argument
909 drv->we_version = 0; in hostap_get_we_version()
921 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_get_we_version()
928 if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) { in hostap_get_we_version()
940 drv->we_version = range->we_version_compiled; in hostap_get_we_version()
948 static int hostap_wireless_event_init(struct hostap_driver_data *drv) in hostap_wireless_event_init() argument
952 hostap_get_we_version(drv); in hostap_wireless_event_init()
957 cfg->ctx = drv; in hostap_wireless_event_init()
959 drv->netlink = netlink_init(cfg); in hostap_wireless_event_init()
960 if (drv->netlink == NULL) { in hostap_wireless_event_init()
972 struct hostap_driver_data *drv; in hostap_init() local
974 drv = os_zalloc(sizeof(struct hostap_driver_data)); in hostap_init()
975 if (drv == NULL) { in hostap_init()
980 drv->hapd = hapd; in hostap_init()
981 drv->ioctl_sock = drv->sock = -1; in hostap_init()
982 memcpy(drv->iface, params->ifname, sizeof(drv->iface)); in hostap_init()
984 drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); in hostap_init()
985 if (drv->ioctl_sock < 0) { in hostap_init()
988 os_free(drv); in hostap_init()
992 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) { in hostap_init()
995 drv->iface); in hostap_init()
996 close(drv->ioctl_sock); in hostap_init()
997 os_free(drv); in hostap_init()
1001 if (hostap_init_sockets(drv, params->own_addr) || in hostap_init()
1002 hostap_wireless_event_init(drv)) { in hostap_init()
1003 close(drv->ioctl_sock); in hostap_init()
1004 os_free(drv); in hostap_init()
1008 return drv; in hostap_init()
1014 struct hostap_driver_data *drv = priv; in hostap_driver_deinit() local
1016 netlink_deinit(drv->netlink); in hostap_driver_deinit()
1017 (void) hostap_set_iface_flags(drv, 0); in hostap_driver_deinit()
1018 (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0); in hostap_driver_deinit()
1019 (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0); in hostap_driver_deinit()
1021 if (drv->ioctl_sock >= 0) in hostap_driver_deinit()
1022 close(drv->ioctl_sock); in hostap_driver_deinit()
1024 if (drv->sock >= 0) in hostap_driver_deinit()
1025 close(drv->sock); in hostap_driver_deinit()
1027 os_free(drv->generic_ie); in hostap_driver_deinit()
1028 os_free(drv->wps_ie); in hostap_driver_deinit()
1030 free(drv); in hostap_driver_deinit()
1037 struct hostap_driver_data *drv = priv; in hostap_sta_deauth() local
1057 return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + in hostap_sta_deauth()
1064 struct hostap_driver_data *drv = priv; in hostap_set_freq() local
1068 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_set_freq()
1072 if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) { in hostap_set_freq()
1085 struct hostap_driver_data *drv = priv; in hostap_sta_disassoc() local
1095 return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + in hostap_sta_disassoc()