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()
234 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface); in hostap_init_sockets()
235 if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) { in hostap_init_sockets()
241 if (hostap_set_iface_flags(drv, 1)) { in hostap_init_sockets()
251 if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { in hostap_init_sockets()
256 return linux_get_ifhwaddr(drv->sock, drv->iface, own_addr); in hostap_init_sockets()
264 struct hostap_driver_data *drv = priv; in hostap_send_mlme() local
270 res = send(drv->sock, msg, len, 0); in hostap_send_mlme()
281 struct hostap_driver_data *drv = priv; in hostap_send_eapol() local
311 res = hostap_send_mlme(drv, (u8 *) hdr, len, 0, 0, NULL, 0); in hostap_send_eapol()
327 struct hostap_driver_data *drv = priv; in hostap_sta_set_flags() local
341 return hostapd_ioctl(drv, &param, sizeof(param)); in hostap_sta_set_flags()
347 struct hostap_driver_data *drv = priv; in hostap_set_iface_flags() local
351 os_snprintf(ifname, IFNAMSIZ, "%sap", drv->iface); in hostap_set_iface_flags()
352 if (linux_set_iface_flags(drv->ioctl_sock, ifname, dev_up) < 0) in hostap_set_iface_flags()
359 if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) { in hostap_set_iface_flags()
373 struct hostap_driver_data *drv = priv; in hostapd_ioctl() local
377 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostapd_ioctl()
381 if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) { in hostapd_ioctl()
397 struct hostap_driver_data *drv = priv; in wpa_driver_hostap_set_key() local
440 if (hostapd_ioctl(drv, param, blen)) { in wpa_driver_hostap_set_key()
453 struct hostap_driver_data *drv = priv; in hostap_get_seqnum() local
472 if (hostapd_ioctl(drv, param, blen)) { in hostap_get_seqnum()
486 struct hostap_driver_data *drv = priv; in hostap_ioctl_prism2param() local
491 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_ioctl_prism2param()
496 if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_PRISM2_PARAM, &iwr) < 0) { in hostap_ioctl_prism2param()
508 struct hostap_driver_data *drv = priv; in hostap_set_ieee8021x() local
512 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_IEEE_802_1X, enabled)) { in hostap_set_ieee8021x()
523 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_DECRYPT, 1) || in hostap_set_ieee8021x()
524 hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_ENCRYPT, 1)) { in hostap_set_ieee8021x()
536 struct hostap_drvier_data *drv = priv; in hostap_set_privacy() local
538 return hostap_ioctl_prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED, in hostap_set_privacy()
545 struct hostap_driver_data *drv = priv; in hostap_set_ssid() local
549 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_set_ssid()
554 if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) { in hostap_set_ssid()
566 struct hostap_driver_data *drv = priv; in hostap_flush() local
571 return hostapd_ioctl(drv, &param, sizeof(param)); in hostap_flush()
579 struct hostap_driver_data *drv = priv; in hostap_read_sta_data() local
586 drv->iface, MAC2STR(addr)); in hostap_read_sta_data()
619 struct hostap_driver_data *drv = priv; in hostap_sta_add() local
646 return hostapd_ioctl(drv, &param, sizeof(param)); in hostap_sta_add()
652 struct hostap_driver_data *drv = priv; in hostap_sta_remove() local
655 hostap_sta_set_flags(drv, addr, 0, 0, ~WPA_STA_AUTHORIZED); in hostap_sta_remove()
660 if (hostapd_ioctl(drv, &param, sizeof(param))) { in hostap_sta_remove()
670 struct hostap_driver_data *drv = priv; in hostap_get_inact_sec() local
676 if (hostapd_ioctl(drv, &param, sizeof(param))) { in hostap_get_inact_sec()
686 struct hostap_driver_data *drv = priv; in hostap_sta_clear_stats() local
692 if (hostapd_ioctl(drv, &param, sizeof(param))) { in hostap_sta_clear_stats()
700 static int hostapd_ioctl_set_generic_elem(struct hostap_driver_data *drv) in hostapd_ioctl_set_generic_elem() argument
706 elem_len = drv->generic_ie_len + drv->wps_ie_len; in hostapd_ioctl_set_generic_elem()
717 if (drv->generic_ie) { in hostapd_ioctl_set_generic_elem()
718 os_memcpy(param->u.generic_elem.data, drv->generic_ie, in hostapd_ioctl_set_generic_elem()
719 drv->generic_ie_len); in hostapd_ioctl_set_generic_elem()
721 if (drv->wps_ie) { in hostapd_ioctl_set_generic_elem()
722 os_memcpy(&param->u.generic_elem.data[drv->generic_ie_len], in hostapd_ioctl_set_generic_elem()
723 drv->wps_ie, drv->wps_ie_len); in hostapd_ioctl_set_generic_elem()
727 res = hostapd_ioctl(drv, param, blen); in hostapd_ioctl_set_generic_elem()
738 struct hostap_driver_data *drv = priv; in hostap_set_generic_elem() local
740 os_free(drv->generic_ie); in hostap_set_generic_elem()
741 drv->generic_ie = NULL; in hostap_set_generic_elem()
742 drv->generic_ie_len = 0; in hostap_set_generic_elem()
744 drv->generic_ie = os_malloc(elem_len); in hostap_set_generic_elem()
745 if (drv->generic_ie == NULL) in hostap_set_generic_elem()
747 os_memcpy(drv->generic_ie, elem, elem_len); in hostap_set_generic_elem()
748 drv->generic_ie_len = elem_len; in hostap_set_generic_elem()
751 return hostapd_ioctl_set_generic_elem(drv); in hostap_set_generic_elem()
759 struct hostap_driver_data *drv = priv; in hostap_set_ap_wps_ie() local
767 os_free(drv->wps_ie); in hostap_set_ap_wps_ie()
768 drv->wps_ie = NULL; in hostap_set_ap_wps_ie()
769 drv->wps_ie_len = 0; in hostap_set_ap_wps_ie()
771 drv->wps_ie = os_malloc(wpabuf_len(proberesp)); in hostap_set_ap_wps_ie()
772 if (drv->wps_ie == NULL) in hostap_set_ap_wps_ie()
774 os_memcpy(drv->wps_ie, wpabuf_head(proberesp), in hostap_set_ap_wps_ie()
776 drv->wps_ie_len = wpabuf_len(proberesp); in hostap_set_ap_wps_ie()
779 return hostapd_ioctl_set_generic_elem(drv); in hostap_set_ap_wps_ie()
784 hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv, in hostapd_wireless_event_wireless_custom() argument
805 wpa_supplicant_event(drv->hapd, in hostapd_wireless_event_wireless_custom()
816 static void hostapd_wireless_event_wireless(struct hostap_driver_data *drv, in hostapd_wireless_event_wireless() argument
835 if (drv->we_version > 18 && in hostapd_wireless_event_wireless()
857 hostapd_wireless_event_wireless_custom(drv, buf); in hostapd_wireless_event_wireless()
871 struct hostap_driver_data *drv = ctx; in hostapd_wireless_event_rtm_newlink() local
885 drv, ((char *) attr) + rta_len, in hostapd_wireless_event_rtm_newlink()
893 static int hostap_get_we_version(struct hostap_driver_data *drv) in hostap_get_we_version() argument
900 drv->we_version = 0; in hostap_get_we_version()
912 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_get_we_version()
919 if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) { in hostap_get_we_version()
931 drv->we_version = range->we_version_compiled; in hostap_get_we_version()
939 static int hostap_wireless_event_init(struct hostap_driver_data *drv) in hostap_wireless_event_init() argument
943 hostap_get_we_version(drv); in hostap_wireless_event_init()
948 cfg->ctx = drv; in hostap_wireless_event_init()
950 drv->netlink = netlink_init(cfg); in hostap_wireless_event_init()
951 if (drv->netlink == NULL) { in hostap_wireless_event_init()
963 struct hostap_driver_data *drv; in hostap_init() local
965 drv = os_zalloc(sizeof(struct hostap_driver_data)); in hostap_init()
966 if (drv == NULL) { in hostap_init()
971 drv->hapd = hapd; in hostap_init()
972 drv->ioctl_sock = drv->sock = -1; in hostap_init()
973 memcpy(drv->iface, params->ifname, sizeof(drv->iface)); in hostap_init()
975 drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); in hostap_init()
976 if (drv->ioctl_sock < 0) { in hostap_init()
979 os_free(drv); in hostap_init()
983 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) { in hostap_init()
986 drv->iface); in hostap_init()
987 close(drv->ioctl_sock); in hostap_init()
988 os_free(drv); in hostap_init()
992 if (hostap_init_sockets(drv, params->own_addr) || in hostap_init()
993 hostap_wireless_event_init(drv)) { in hostap_init()
994 close(drv->ioctl_sock); in hostap_init()
995 os_free(drv); in hostap_init()
999 return drv; in hostap_init()
1005 struct hostap_driver_data *drv = priv; in hostap_driver_deinit() local
1007 netlink_deinit(drv->netlink); in hostap_driver_deinit()
1008 (void) hostap_set_iface_flags(drv, 0); in hostap_driver_deinit()
1009 (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0); in hostap_driver_deinit()
1010 (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0); in hostap_driver_deinit()
1012 if (drv->ioctl_sock >= 0) in hostap_driver_deinit()
1013 close(drv->ioctl_sock); in hostap_driver_deinit()
1015 if (drv->sock >= 0) in hostap_driver_deinit()
1016 close(drv->sock); in hostap_driver_deinit()
1018 os_free(drv->generic_ie); in hostap_driver_deinit()
1019 os_free(drv->wps_ie); in hostap_driver_deinit()
1021 free(drv); in hostap_driver_deinit()
1028 struct hostap_driver_data *drv = priv; in hostap_sta_deauth() local
1048 return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + in hostap_sta_deauth()
1055 struct hostap_driver_data *drv = priv; in hostap_set_freq() local
1059 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ); in hostap_set_freq()
1063 if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) { in hostap_set_freq()
1076 struct hostap_driver_data *drv = priv; in hostap_sta_disassoc() local
1086 return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + in hostap_sta_disassoc()