Lines Matching refs:drv
58 static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len,
82 wpa_supplicant_event(drv->hapd, EVENT_RX_FROM_UNKNOWN, &event);
109 drv_event_eapol_rx(drv->hapd, sa, pos, left);
119 static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf,
136 wpa_supplicant_event(drv->hapd, EVENT_TX_STATUS, &event);
140 static void handle_frame(struct hostap_driver_data *drv, u8 *buf, size_t len)
172 handle_tx_callback(drv, buf, data_len, ver == 2 ? 1 : 0);
184 wpa_supplicant_event(drv->hapd, EVENT_RX_MGMT, &event);
191 handle_data(drv, buf, data_len, stype);
202 struct hostap_driver_data *drv = eloop_ctx;
212 handle_frame(drv, buf, len);
216 static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr)
221 drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
222 if (drv->sock < 0) {
228 if (eloop_register_read_sock(drv->sock, handle_read, drv, NULL)) {
234 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface);
235 if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
241 if (hostap_set_iface_flags(drv, 1)) {
251 if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
256 return linux_get_ifhwaddr(drv->sock, drv->iface, own_addr);
264 struct hostap_driver_data *drv = priv;
270 res = send(drv->sock, msg, len, 0);
281 struct hostap_driver_data *drv = priv;
311 res = hostap_send_mlme(drv, (u8 *) hdr, len, 0, 0, NULL, 0);
327 struct hostap_driver_data *drv = priv;
341 return hostapd_ioctl(drv, ¶m, sizeof(param));
347 struct hostap_driver_data *drv = priv;
351 os_snprintf(ifname, IFNAMSIZ, "%sap", drv->iface);
352 if (linux_set_iface_flags(drv->ioctl_sock, ifname, dev_up) < 0)
359 if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) {
373 struct hostap_driver_data *drv = priv;
377 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
381 if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) {
397 struct hostap_driver_data *drv = priv;
440 if (hostapd_ioctl(drv, param, blen)) {
453 struct hostap_driver_data *drv = priv;
472 if (hostapd_ioctl(drv, param, blen)) {
486 struct hostap_driver_data *drv = priv;
491 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
496 if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_PRISM2_PARAM, &iwr) < 0) {
508 struct hostap_driver_data *drv = priv;
512 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_IEEE_802_1X, enabled)) {
523 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_DECRYPT, 1) ||
524 hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_ENCRYPT, 1)) {
536 struct hostap_drvier_data *drv = priv;
538 return hostap_ioctl_prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED,
545 struct hostap_driver_data *drv = priv;
549 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
554 if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
566 struct hostap_driver_data *drv = priv;
571 return hostapd_ioctl(drv, ¶m, sizeof(param));
579 struct hostap_driver_data *drv = priv;
586 drv->iface, MAC2STR(addr));
619 struct hostap_driver_data *drv = priv;
646 return hostapd_ioctl(drv, ¶m, sizeof(param));
652 struct hostap_driver_data *drv = priv;
655 hostap_sta_set_flags(drv, addr, 0, 0, ~WPA_STA_AUTHORIZED);
660 if (hostapd_ioctl(drv, ¶m, sizeof(param))) {
670 struct hostap_driver_data *drv = priv;
676 if (hostapd_ioctl(drv, ¶m, sizeof(param))) {
686 struct hostap_driver_data *drv = priv;
692 if (hostapd_ioctl(drv, ¶m, sizeof(param))) {
700 static int hostapd_ioctl_set_generic_elem(struct hostap_driver_data *drv)
706 elem_len = drv->generic_ie_len + drv->wps_ie_len;
717 if (drv->generic_ie) {
718 os_memcpy(param->u.generic_elem.data, drv->generic_ie,
719 drv->generic_ie_len);
721 if (drv->wps_ie) {
722 os_memcpy(¶m->u.generic_elem.data[drv->generic_ie_len],
723 drv->wps_ie, drv->wps_ie_len);
727 res = hostapd_ioctl(drv, param, blen);
738 struct hostap_driver_data *drv = priv;
740 os_free(drv->generic_ie);
741 drv->generic_ie = NULL;
742 drv->generic_ie_len = 0;
744 drv->generic_ie = os_malloc(elem_len);
745 if (drv->generic_ie == NULL)
747 os_memcpy(drv->generic_ie, elem, elem_len);
748 drv->generic_ie_len = elem_len;
751 return hostapd_ioctl_set_generic_elem(drv);
759 struct hostap_driver_data *drv = priv;
767 os_free(drv->wps_ie);
768 drv->wps_ie = NULL;
769 drv->wps_ie_len = 0;
771 drv->wps_ie = os_malloc(wpabuf_len(proberesp));
772 if (drv->wps_ie == NULL)
774 os_memcpy(drv->wps_ie, wpabuf_head(proberesp),
776 drv->wps_ie_len = wpabuf_len(proberesp);
779 return hostapd_ioctl_set_generic_elem(drv);
784 hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv,
805 wpa_supplicant_event(drv->hapd,
816 static void hostapd_wireless_event_wireless(struct hostap_driver_data *drv,
835 if (drv->we_version > 18 &&
857 hostapd_wireless_event_wireless_custom(drv, buf);
871 struct hostap_driver_data *drv = ctx;
885 drv, ((char *) attr) + rta_len,
893 static int hostap_get_we_version(struct hostap_driver_data *drv)
900 drv->we_version = 0;
912 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
919 if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
931 drv->we_version = range->we_version_compiled;
939 static int hostap_wireless_event_init(struct hostap_driver_data *drv)
943 hostap_get_we_version(drv);
948 cfg->ctx = drv;
950 drv->netlink = netlink_init(cfg);
951 if (drv->netlink == NULL) {
963 struct hostap_driver_data *drv;
965 drv = os_zalloc(sizeof(struct hostap_driver_data));
966 if (drv == NULL) {
971 drv->hapd = hapd;
972 drv->ioctl_sock = drv->sock = -1;
973 memcpy(drv->iface, params->ifname, sizeof(drv->iface));
975 drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
976 if (drv->ioctl_sock < 0) {
979 os_free(drv);
983 if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) {
986 drv->iface);
987 close(drv->ioctl_sock);
988 os_free(drv);
992 if (hostap_init_sockets(drv, params->own_addr) ||
993 hostap_wireless_event_init(drv)) {
994 close(drv->ioctl_sock);
995 os_free(drv);
999 return drv;
1005 struct hostap_driver_data *drv = priv;
1007 netlink_deinit(drv->netlink);
1008 (void) hostap_set_iface_flags(drv, 0);
1009 (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0);
1010 (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0);
1012 if (drv->ioctl_sock >= 0)
1013 close(drv->ioctl_sock);
1015 if (drv->sock >= 0)
1016 close(drv->sock);
1018 os_free(drv->generic_ie);
1019 os_free(drv->wps_ie);
1021 free(drv);
1028 struct hostap_driver_data *drv = priv;
1048 return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN +
1055 struct hostap_driver_data *drv = priv;
1059 os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
1063 if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) {
1076 struct hostap_driver_data *drv = priv;
1086 return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN +