Example #1
0
File: ap.c Project: pocketbook/801
int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
				 size_t buflen, int verbose)
{
	char *pos = buf, *end = buf + buflen;
	int ret;
	struct hostapd_bss_config *conf;

	if (wpa_s->ap_iface == NULL)
		return -1;

	conf = wpa_s->ap_iface->bss[0]->conf;
	if (conf->wpa == 0)
		return 0;

	ret = os_snprintf(pos, end - pos,
			  "pairwise_cipher=%s\n"
			  "group_cipher=%s\n"
			  "key_mgmt=%s\n",
			  wpa_cipher_txt(conf->rsn_pairwise),
			  wpa_cipher_txt(conf->wpa_group),
			  wpa_key_mgmt_txt(conf->wpa_key_mgmt,
					   conf->wpa));
	if (ret < 0 || ret >= end - pos)
		return pos - buf;
	pos += ret;
	return pos - buf;
}
static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
					    const char *params,
					    char *buf, size_t buflen)
{
	char *pos, *end;
	int res, verbose;

	verbose = strcmp(params, "-VERBOSE") == 0;
	pos = buf;
	end = buf + buflen;
	pos += snprintf(pos, end - pos, "bssid=" MACSTR "\n",
			MAC2STR(wpa_s->bssid));
	if (wpa_s->current_ssid) {
		pos += snprintf(pos, end - pos, "ssid=%s\n",
				wpa_ssid_txt(wpa_s->current_ssid->ssid,
					     wpa_s->current_ssid->ssid_len));
	}
	pos += snprintf(pos, end - pos,
			"pairwise_cipher=%s\n"
			"group_cipher=%s\n"
			"key_mgmt=%s\n"
			"wpa_state=%s\n",
			wpa_cipher_txt(wpa_s->pairwise_cipher),
			wpa_cipher_txt(wpa_s->group_cipher),
			wpa_key_mgmt_txt(wpa_s->key_mgmt, wpa_s->proto),
			wpa_state_txt(wpa_s->wpa_state));

	res = eapol_sm_get_status(wpa_s->eapol, pos, end - pos, verbose);
	if (res >= 0)
		pos += res;

	if (wpa_s->preauth_eapol) {
		pos += snprintf(pos, end - pos, "Pre-authentication "
				"EAPOL state machines:\n");
		res = eapol_sm_get_status(wpa_s->preauth_eapol,
					  pos, end - pos, verbose);
		if (res >= 0)
			pos += res;
	}

	return pos - buf;
}