Lines Matching defs:hapd
48 static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
52 static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
64 dst->next = hapd->ctrl_dst;
65 hapd->ctrl_dst = dst;
73 static int hostapd_ctrl_iface_detach(struct hostapd_data *hapd,
79 dst = hapd->ctrl_dst;
86 hapd->ctrl_dst = dst->next;
103 static int hostapd_ctrl_iface_level(struct hostapd_data *hapd,
112 dst = hapd->ctrl_dst;
131 static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
142 sta = ap_get_sta(hapd, addr);
148 sta = ap_sta_add(hapd, addr);
152 hostapd_new_assoc_sta(hapd, sta, 0);
159 static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd,
171 ieee802_11_send_sa_query_req(hapd, addr, trans_id);
180 static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
205 return hostapd_wps_add_pin(hapd, addr, txt, pin, timeout);
210 struct hostapd_data *hapd, char *cmd, char *buf, size_t buflen)
255 static int hostapd_ctrl_iface_wps_nfc_tag_read(struct hostapd_data *hapd,
275 ret = hostapd_wps_nfc_tag_read(hapd, buf);
282 static int hostapd_ctrl_iface_wps_nfc_config_token(struct hostapd_data *hapd,
297 buf = hostapd_wps_nfc_config_token(hapd, ndef);
312 static int hostapd_ctrl_iface_wps_nfc_token_gen(struct hostapd_data *hapd,
319 buf = hostapd_wps_nfc_token_gen(hapd, ndef);
334 static int hostapd_ctrl_iface_wps_nfc_token(struct hostapd_data *hapd,
339 return hostapd_ctrl_iface_wps_nfc_token_gen(hapd, reply,
343 return hostapd_ctrl_iface_wps_nfc_token_gen(hapd, reply,
347 return hostapd_wps_nfc_token_enable(hapd);
350 hostapd_wps_nfc_token_disable(hapd);
358 static int hostapd_ctrl_iface_nfc_get_handover_sel(struct hostapd_data *hapd,
380 buf = hostapd_wps_nfc_hs_cr(hapd, ndef);
397 static int hostapd_ctrl_iface_nfc_report_handover(struct hostapd_data *hapd,
412 static int hostapd_ctrl_iface_wps_ap_pin(struct hostapd_data *hapd, char *txt,
424 hostapd_wps_ap_pin_disable(hapd);
431 pin_txt = hostapd_wps_ap_pin_random(hapd, timeout);
438 pin_txt = hostapd_wps_ap_pin_get(hapd);
456 if (hostapd_wps_ap_pin_set(hapd, pin, timeout) < 0)
465 static int hostapd_ctrl_iface_wps_config(struct hostapd_data *hapd, char *txt)
488 return hostapd_wps_config_ap(hapd, ssid, auth, encr, key);
509 static int hostapd_ctrl_iface_wps_get_status(struct hostapd_data *hapd,
519 pbc_status_str(hapd->wps_stats.pbc_status));
526 (hapd->wps_stats.status == WPS_STATUS_SUCCESS ?
528 (hapd->wps_stats.status == WPS_STATUS_FAILURE ?
536 if(hapd->wps_stats.status == WPS_STATUS_FAILURE &&
537 hapd->wps_stats.failure_reason > 0) {
540 wps_ei_str(hapd->wps_stats.failure_reason));
547 if (hapd->wps_stats.status) {
549 MAC2STR(hapd->wps_stats.peer_addr));
564 static int hostapd_ctrl_iface_disassoc_imminent(struct hostapd_data *hapd,
583 os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
584 os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
596 if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
606 static int hostapd_ctrl_iface_ess_disassoc(struct hostapd_data *hapd,
640 os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
641 os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
658 if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
674 wpa_auth_pmksa_remove(hapd->wpa_auth, addr);
676 sta = ap_get_sta(hapd, addr);
684 beacon_int = hapd->iconf->beacon_int;
693 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
696 ap_handle_timer, hapd, sta);
705 static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
716 MAC2STR(hapd->own_addr),
717 wpa_ssid_txt(hapd->conf->ssid.ssid,
718 hapd->conf->ssid.ssid_len));
725 hapd->conf->wps_state == 0 ? "disabled" :
726 (hapd->conf->wps_state == 1 ? "not configured" :
732 if (hapdhapd->conf->wpa &&
733 hapd->conf->ssid.wpa_passphrase) {
735 hapd->conf->ssid.wpa_passphrase);
741 if (hapd->conf->wps_state && hapd->conf->wpa &&
742 hapd->conf->ssid.wpa_psk &&
743 hapd->conf->ssid.wpa_psk->group) {
746 hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
754 if (hapd->conf->wpa && hapd->conf->wpa_key_mgmt) {
760 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) {
766 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
773 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_PSK) {
779 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
787 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
793 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
807 if (hapd->conf->wpa) {
809 wpa_cipher_txt(hapd->conf->wpa_group));
815 if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->rsn_pairwise) {
821 ret = wpa_write_ciphers(pos, end, hapd->conf->rsn_pairwise,
833 if ((hapd->conf->wpa & WPA_PROTO_WPA) && hapd->conf->wpa_pairwise) {
839 ret = wpa_write_ciphers(pos, end, hapd->conf->rsn_pairwise,
855 static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
881 hostapd_wps_update_ie(hapd);
894 hapd->gas_frag_limit = val;
897 ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
904 static int hostapd_ctrl_iface_get(struct hostapd_data *hapd, char *cmd,
955 struct hostapd_data *hapd = eloop_ctx;
993 reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
995 res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
1003 res = ieee802_1x_get_mib(hapd, reply + reply_len,
1012 res = radius_client_get_mib(hapd->radius,
1022 reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
1025 reply_len = hostapd_ctrl_iface_sta(hapd, buf + 4, reply,
1028 reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
1031 if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
1034 if (hostapd_ctrl_iface_detach(hapd, &from, fromlen))
1037 if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
1041 if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
1044 if (hostapd_ctrl_iface_deauthenticate(hapd, buf + 15))
1047 if (hostapd_ctrl_iface_disassociate(hapd, buf + 13))
1052 if (hostapd_ctrl_iface_sa_query(hapd, buf + 9))
1058 if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
1062 hapd, buf + 14, reply, reply_size);
1064 if (hostapd_wps_button_pushed(hapd, NULL))
1067 if (hostapd_wps_cancel(hapd))
1070 reply_len = hostapd_ctrl_iface_wps_ap_pin(hapd, buf + 11,
1073 if (hostapd_ctrl_iface_wps_config(hapd, buf + 11) < 0)
1076 reply_len = hostapd_ctrl_iface_wps_get_status(hapd, reply,
1080 if (hostapd_ctrl_iface_wps_nfc_tag_read(hapd, buf + 17))
1084 hapd, buf + 21, reply, reply_size);
1087 hapd, buf + 14, reply, reply_size);
1090 hapd, buf + 21, reply, reply_size);
1092 if (hostapd_ctrl_iface_nfc_report_handover(hapd, buf + 20))
1098 if (hostapd_ctrl_iface_disassoc_imminent(hapd, buf + 18))
1101 if (hostapd_ctrl_iface_ess_disassoc(hapd, buf + 13))
1105 reply_len = hostapd_ctrl_iface_get_config(hapd, reply,
1108 if (hostapd_ctrl_iface_set(hapd, buf + 4))
1111 reply_len = hostapd_ctrl_iface_get(hapd, buf + 4, reply,
1114 if (hostapd_ctrl_iface_enable(hapd->iface))
1117 if (hostapd_ctrl_iface_reload(hapd->iface))
1120 if (hostapd_ctrl_iface_disable(hapd->iface))
1136 static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
1141 if (hapd->conf->ctrl_interface == NULL)
1144 len = os_strlen(hapd->conf->ctrl_interface) +
1145 os_strlen(hapd->conf->iface) + 2;
1151 hapd->conf->ctrl_interface, hapd->conf->iface);
1160 struct hostapd_data *hapd = ctx;
1161 if (hapd == NULL)
1163 hostapd_ctrl_iface_send(hapd, level, txt, len);
1167 int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
1173 if (hapd->ctrl_sock > -1) {
1178 if (hapd->conf->ctrl_interface == NULL)
1181 if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
1191 if (hapd->conf->ctrl_interface_gid_set &&
1192 chown(hapd->conf->ctrl_interface, -1,
1193 hapd->conf->ctrl_interface_gid) < 0) {
1198 if (!hapd->conf->ctrl_interface_gid_set &&
1199 hapd->iface->interfaces->ctrl_iface_group &&
1200 chown(hapd->conf->ctrl_interface, -1,
1201 hapd->iface->interfaces->ctrl_iface_group) < 0) {
1214 if (chmod(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
1221 if (os_strlen(hapd->conf->ctrl_interface) + 1 +
1222 os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
1236 fname = hostapd_ctrl_iface_path(hapd);
1272 if (hapd->conf->ctrl_interface_gid_set &&
1273 chown(fname, -1, hapd->conf->ctrl_interface_gid) < 0) {
1278 if (!hapd->conf->ctrl_interface_gid_set &&
1279 hapd->iface->interfaces->ctrl_iface_group &&
1280 chown(fname, -1, hapd->iface->interfaces->ctrl_iface_group) < 0) {
1291 hapd->ctrl_sock = s;
1292 eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
1294 hapd->msg_ctx = hapd;
1310 void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
1314 if (hapd->ctrl_sock > -1) {
1316 eloop_unregister_read_sock(hapd->ctrl_sock);
1317 close(hapd->ctrl_sock);
1318 hapd->ctrl_sock = -1;
1319 fname = hostapd_ctrl_iface_path(hapd);
1324 if (hapd
1325 rmdir(hapd->conf->ctrl_interface) < 0) {
1333 hapd->conf->ctrl_interface,
1339 dst = hapd->ctrl_dst;
1576 static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
1585 dst = hapd->ctrl_dst;
1586 if (hapd->ctrl_sock < 0 || dst == NULL)
1607 if (sendmsg(hapd->ctrl_sock, &msg, 0) < 0) {
1615 hapd, &dst->addr,