static int p2p_parse_wps_ie(const struct wpabuf *buf, struct p2p_message *msg) { struct wps_parse_attr attr; wpa_printf(MSG_DEBUG, "P2P: Parsing WPS IE"); if (wps_parse_msg(buf, &attr)) return -1; if (attr.dev_name && attr.dev_name_len < sizeof(msg->device_name) && !msg->device_name[0]) os_memcpy(msg->device_name, attr.dev_name, attr.dev_name_len); if (attr.config_methods) { msg->wps_config_methods = WPA_GET_BE16(attr.config_methods); wpa_printf(MSG_DEBUG, "P2P: Config Methods (WPS): 0x%x", msg->wps_config_methods); } if (attr.dev_password_id) { msg->dev_password_id = WPA_GET_BE16(attr.dev_password_id); wpa_printf(MSG_DEBUG, "P2P: Device Password ID: %d", msg->dev_password_id); } if (attr.primary_dev_type) { char devtype[WPS_DEV_TYPE_BUFSIZE]; msg->wps_pri_dev_type = attr.primary_dev_type; wpa_printf(MSG_DEBUG, "P2P: Primary Device Type (WPS): %s", wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype, sizeof(devtype))); } return 0; }
static int p2p_parse_wps_ie(const struct wpabuf *buf, struct p2p_message *msg) { struct wps_parse_attr attr; int i; wpa_printf(MSG_DEBUG, "P2P: Parsing WPS IE"); if (wps_parse_msg(buf, &attr)) return -1; if (attr.dev_name && attr.dev_name_len < sizeof(msg->device_name) && !msg->device_name[0]) os_memcpy(msg->device_name, attr.dev_name, attr.dev_name_len); if (attr.config_methods) { msg->wps_config_methods = WPA_GET_BE16(attr.config_methods); wpa_printf(MSG_DEBUG, "P2P: Config Methods (WPS): 0x%x", msg->wps_config_methods); } if (attr.dev_password_id) { msg->dev_password_id = WPA_GET_BE16(attr.dev_password_id); wpa_printf(MSG_DEBUG, "P2P: Device Password ID: %d", msg->dev_password_id); msg->dev_password_id_present = 1; } if (attr.primary_dev_type) { char devtype[WPS_DEV_TYPE_BUFSIZE]; msg->wps_pri_dev_type = attr.primary_dev_type; wpa_printf(MSG_DEBUG, "P2P: Primary Device Type (WPS): %s", wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype, sizeof(devtype))); } if (attr.sec_dev_type_list) { msg->wps_sec_dev_type_list = attr.sec_dev_type_list; msg->wps_sec_dev_type_list_len = attr.sec_dev_type_list_len; } for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) { msg->wps_vendor_ext[i] = attr.vendor_ext[i]; msg->wps_vendor_ext_len[i] = attr.vendor_ext_len[i]; } msg->manufacturer = attr.manufacturer; msg->manufacturer_len = attr.manufacturer_len; msg->model_name = attr.model_name; msg->model_name_len = attr.model_name_len; msg->model_number = attr.model_number; msg->model_number_len = attr.model_number_len; msg->serial_number = attr.serial_number; msg->serial_number_len = attr.serial_number_len; msg->oob_dev_password = attr.oob_dev_password; msg->oob_dev_password_len = attr.oob_dev_password_len; return 0; }
static void hostapd_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, const struct wps_device_data *dev) { struct hostapd_data *hapd = ctx; char uuid[40], txt[400]; int len; char devtype[WPS_DEV_TYPE_BUFSIZE]; if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) return; wpa_printf(MSG_DEBUG, "WPS: PIN needed for E-UUID %s", uuid); len = os_snprintf(txt, sizeof(txt), WPS_EVENT_PIN_NEEDED "%s " MACSTR " [%s|%s|%s|%s|%s|%s]", uuid, MAC2STR(dev->mac_addr), dev->device_name, dev->manufacturer, dev->model_name, dev->model_number, dev->serial_number, wps_dev_type_bin2str(dev->pri_dev_type, devtype, sizeof(devtype))); if (len > 0 && len < (int) sizeof(txt)) wpa_msg(hapd->msg_ctx, MSG_INFO, "%s", txt); if (hapd->conf->wps_pin_requests) { FILE *f; struct os_time t; f = fopen(hapd->conf->wps_pin_requests, "a"); if (f == NULL) return; os_get_time(&t); fprintf(f, "%ld\t%s\t" MACSTR "\t%s\t%s\t%s\t%s\t%s" "\t%s\n", t.sec, uuid, MAC2STR(dev->mac_addr), dev->device_name, dev->manufacturer, dev->model_name, dev->model_number, dev->serial_number, wps_dev_type_bin2str(dev->pri_dev_type, devtype, sizeof(devtype))); fclose(f); } }
static int wps_process_primary_dev_type(struct wps_device_data *dev, const u8 *dev_type) { char devtype[WPS_DEV_TYPE_BUFSIZE]; if (dev_type == NULL) { wpa_printf(MSG_DEBUG, "WPS: No Primary Device Type received"); return -1; } os_memcpy(dev->pri_dev_type, dev_type, WPS_DEV_TYPE_LEN); wpa_printf(MSG_DEBUG, "WPS: Primary Device Type: %s", wps_dev_type_bin2str(dev->pri_dev_type, devtype, sizeof(devtype))); return 0; }
static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, const struct wps_device_data *dev) { char uuid[40], txt[400]; int len; char devtype[WPS_DEV_TYPE_BUFSIZE]; if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) return; wpa_printf(MSG_DEBUG, "WPS: PIN needed for UUID-E %s", uuid); len = os_snprintf(txt, sizeof(txt), "WPS-EVENT-PIN-NEEDED %s " MACSTR " [%s|%s|%s|%s|%s|%s]", uuid, MAC2STR(dev->mac_addr), dev->device_name, dev->manufacturer, dev->model_name, dev->model_number, dev->serial_number, wps_dev_type_bin2str(dev->pri_dev_type, devtype, sizeof(devtype))); if (len > 0 && len < (int) sizeof(txt)) wpa_printf(MSG_INFO, "%s", txt); }
static void hostapd_wps_enrollee_seen_cb(void *ctx, const u8 *addr, const u8 *uuid_e, const u8 *pri_dev_type, u16 config_methods, u16 dev_password_id, u8 request_type, const char *dev_name) { struct hostapd_data *hapd = ctx; char uuid[40]; char devtype[WPS_DEV_TYPE_BUFSIZE]; if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) return; if (dev_name == NULL) dev_name = ""; wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, WPS_EVENT_ENROLLEE_SEEN MACSTR " %s %s 0x%x %u %u [%s]", MAC2STR(addr), uuid, wps_dev_type_bin2str(pri_dev_type, devtype, sizeof(devtype)), config_methods, dev_password_id, request_type, dev_name); }
static void wpa_supplicant_wps_event_er_ap_add(struct wpa_supplicant *wpa_s, struct wps_event_er_ap *ap) { char uuid_str[100]; char dev_type[WPS_DEV_TYPE_BUFSIZE]; uuid_bin2str(ap->uuid, uuid_str, sizeof(uuid_str)); if (ap->pri_dev_type) wps_dev_type_bin2str(ap->pri_dev_type, dev_type, sizeof(dev_type)); else dev_type[0] = '\0'; wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_ADD "%s " MACSTR " pri_dev_type=%s wps_state=%d |%s|%s|%s|%s|%s|%s|", uuid_str, MAC2STR(ap->mac_addr), dev_type, ap->wps_state, ap->friendly_name ? ap->friendly_name : "", ap->manufacturer ? ap->manufacturer : "", ap->model_description ? ap->model_description : "", ap->model_name ? ap->model_name : "", ap->manufacturer_url ? ap->manufacturer_url : "", ap->model_url ? ap->model_url : ""); }
static void wpa_supplicant_wps_event_er_enrollee_add( struct wpa_supplicant *wpa_s, struct wps_event_er_enrollee *enrollee) { char uuid_str[100]; char dev_type[WPS_DEV_TYPE_BUFSIZE]; uuid_bin2str(enrollee->uuid, uuid_str, sizeof(uuid_str)); if (enrollee->pri_dev_type) wps_dev_type_bin2str(enrollee->pri_dev_type, dev_type, sizeof(dev_type)); else dev_type[0] = '\0'; wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_ENROLLEE_ADD "%s " MACSTR " M1=%d config_methods=0x%x dev_passwd_id=%d pri_dev_type=%s " "|%s|%s|%s|%s|%s|", uuid_str, MAC2STR(enrollee->mac_addr), enrollee->m1_received, enrollee->config_methods, enrollee->dev_passwd_id, dev_type, enrollee->dev_name ? enrollee->dev_name : "", enrollee->manufacturer ? enrollee->manufacturer : "", enrollee->model_name ? enrollee->model_name : "", enrollee->model_number ? enrollee->model_number : "", enrollee->serial_number ? enrollee->serial_number : ""); }
static void wpa_config_write_global(FILE *f, struct wpa_config *config) { #ifdef CONFIG_CTRL_IFACE if (config->ctrl_interface) fprintf(f, "ctrl_interface=%s\n", config->ctrl_interface); if (config->ctrl_interface_group) fprintf(f, "ctrl_interface_group=%s\n", config->ctrl_interface_group); #endif /* CONFIG_CTRL_IFACE */ if (config->eapol_version != DEFAULT_EAPOL_VERSION) fprintf(f, "eapol_version=%d\n", config->eapol_version); if (config->ap_scan != DEFAULT_AP_SCAN) fprintf(f, "ap_scan=%d\n", config->ap_scan); if (config->fast_reauth != DEFAULT_FAST_REAUTH) fprintf(f, "fast_reauth=%d\n", config->fast_reauth); if (config->opensc_engine_path) fprintf(f, "opensc_engine_path=%s\n", config->opensc_engine_path); if (config->pkcs11_engine_path) fprintf(f, "pkcs11_engine_path=%s\n", config->pkcs11_engine_path); if (config->pkcs11_module_path) fprintf(f, "pkcs11_module_path=%s\n", config->pkcs11_module_path); if (config->driver_param) fprintf(f, "driver_param=%s\n", config->driver_param); if (config->dot11RSNAConfigPMKLifetime) fprintf(f, "dot11RSNAConfigPMKLifetime=%d\n", config->dot11RSNAConfigPMKLifetime); if (config->dot11RSNAConfigPMKReauthThreshold) fprintf(f, "dot11RSNAConfigPMKReauthThreshold=%d\n", config->dot11RSNAConfigPMKReauthThreshold); if (config->dot11RSNAConfigSATimeout) fprintf(f, "dot11RSNAConfigSATimeout=%d\n", config->dot11RSNAConfigSATimeout); if (config->update_config) fprintf(f, "update_config=%d\n", config->update_config); #ifdef CONFIG_WPS if (!is_nil_uuid(config->uuid)) { char buf[40]; uuid_bin2str(config->uuid, buf, sizeof(buf)); fprintf(f, "uuid=%s\n", buf); } if (config->device_name) fprintf(f, "device_name=%s\n", config->device_name); if (config->manufacturer) fprintf(f, "manufacturer=%s\n", config->manufacturer); if (config->model_name) fprintf(f, "model_name=%s\n", config->model_name); if (config->model_number) fprintf(f, "model_number=%s\n", config->model_number); if (config->serial_number) fprintf(f, "serial_number=%s\n", config->serial_number); { char _buf[WPS_DEV_TYPE_BUFSIZE], *buf; buf = wps_dev_type_bin2str(config->device_type, _buf, sizeof(_buf)); if (os_strcmp(buf, "0-00000000-0") != 0) fprintf(f, "device_type=%s\n", buf); } if (WPA_GET_BE32(config->os_version)) fprintf(f, "os_version=%08x\n", WPA_GET_BE32(config->os_version)); if (config->config_methods) fprintf(f, "config_methods=%s\n", config->config_methods); if (config->wps_cred_processing) fprintf(f, "wps_cred_processing=%d\n", config->wps_cred_processing); #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P if (config->p2p_listen_reg_class) fprintf(f, "p2p_listen_reg_class=%u\n", config->p2p_listen_reg_class); if (config->p2p_listen_channel) fprintf(f, "p2p_listen_channel=%u\n", config->p2p_listen_channel); if (config->p2p_oper_reg_class) fprintf(f, "p2p_oper_reg_class=%u\n", config->p2p_oper_reg_class); if (config->p2p_oper_channel) fprintf(f, "p2p_oper_channel=%u\n", config->p2p_oper_channel); if (config->p2p_go_intent != DEFAULT_P2P_GO_INTENT) fprintf(f, "p2p_go_intent=%u\n", config->p2p_go_intent); if (config->p2p_ssid_postfix) fprintf(f, "p2p_ssid_postfix=%s\n", config->p2p_ssid_postfix); if (config->persistent_reconnect) fprintf(f, "persistent_reconnect=%u\n", config->persistent_reconnect); if (config->p2p_intra_bss != DEFAULT_P2P_INTRA_BSS) fprintf(f, "p2p_intra_bss=%u\n", config->p2p_intra_bss); if (config->p2p_group_idle) fprintf(f, "p2p_group_idle=%u\n", config->p2p_group_idle); #endif /* CONFIG_P2P */ if (config->country[0] && config->country[1]) { fprintf(f, "country=%c%c\n", config->country[0], config->country[1]); } #ifdef CONFIG_EAP_SIM_AKA if (config->software_sim) fprintf(f, "software_sim=%d\n", config->software_sim); #endif if (config->bss_max_count != DEFAULT_BSS_MAX_COUNT) fprintf(f, "bss_max_count=%u\n", config->bss_max_count); if (config->bss_expiration_age != DEFAULT_BSS_EXPIRATION_AGE) fprintf(f, "bss_expiration_age=%u\n", config->bss_expiration_age); if (config->bss_expiration_scan_count != DEFAULT_BSS_EXPIRATION_SCAN_COUNT) fprintf(f, "bss_expiration_scan_count=%u\n", config->bss_expiration_scan_count); if (config->filter_ssids) fprintf(f, "filter_ssids=%d\n", config->filter_ssids); if (config->max_num_sta != DEFAULT_MAX_NUM_STA) fprintf(f, "max_num_sta=%u\n", config->max_num_sta); if (config->disassoc_low_ack) fprintf(f, "disassoc_low_ack=%u\n", config->disassoc_low_ack); #ifdef CONFIG_INTERWORKING if (config->home_realm) fprintf(f, "home_realm=%s\n", config->home_realm); if (config->home_username) fprintf(f, "home_username=%s\n", config->home_username); if (config->home_password) fprintf(f, "home_password=%s\n", config->home_password); if (config->home_ca_cert) fprintf(f, "home_ca_cert=%s\n", config->home_ca_cert); if (config->home_imsi) fprintf(f, "home_imsi=%s\n", config->home_imsi); if (config->home_milenage) fprintf(f, "home_milenage=%s\n", config->home_milenage); if (config->interworking) fprintf(f, "interworking=%u\n", config->interworking); if (!is_zero_ether_addr(config->hessid)) fprintf(f, "hessid=" MACSTR "\n", MAC2STR(config->hessid)); if (config->access_network_type != DEFAULT_ACCESS_NETWORK_TYPE) fprintf(f, "access_network_type=%d\n", config->access_network_type); #endif /* CONFIG_INTERWORKING */ }
static int wpa_config_write_global(struct wpa_config *config, HKEY hk) { #ifdef CONFIG_CTRL_IFACE wpa_config_write_reg_string(hk, "ctrl_interface", config->ctrl_interface); #endif /* CONFIG_CTRL_IFACE */ wpa_config_write_reg_dword(hk, TEXT("eapol_version"), config->eapol_version, DEFAULT_EAPOL_VERSION); wpa_config_write_reg_dword(hk, TEXT("ap_scan"), config->ap_scan, DEFAULT_AP_SCAN); wpa_config_write_reg_dword(hk, TEXT("fast_reauth"), config->fast_reauth, DEFAULT_FAST_REAUTH); wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigPMKLifetime"), config->dot11RSNAConfigPMKLifetime, 0); wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigPMKReauthThreshold"), config->dot11RSNAConfigPMKReauthThreshold, 0); wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigSATimeout"), config->dot11RSNAConfigSATimeout, 0); wpa_config_write_reg_dword(hk, TEXT("update_config"), config->update_config, 0); #ifdef CONFIG_WPS if (!is_nil_uuid(config->uuid)) { char buf[40]; uuid_bin2str(config->uuid, buf, sizeof(buf)); wpa_config_write_reg_string(hk, "uuid", buf); } wpa_config_write_reg_string(hk, "device_name", config->device_name); wpa_config_write_reg_string(hk, "manufacturer", config->manufacturer); wpa_config_write_reg_string(hk, "model_name", config->model_name); wpa_config_write_reg_string(hk, "model_number", config->model_number); wpa_config_write_reg_string(hk, "serial_number", config->serial_number); { char _buf[WPS_DEV_TYPE_BUFSIZE], *buf; buf = wps_dev_type_bin2str(config->device_type, _buf, sizeof(_buf)); wpa_config_write_reg_string(hk, "device_type", buf); } wpa_config_write_reg_string(hk, "config_methods", config->config_methods); if (WPA_GET_BE32(config->os_version)) { char vbuf[10]; os_snprintf(vbuf, sizeof(vbuf), "%08x", WPA_GET_BE32(config->os_version)); wpa_config_write_reg_string(hk, "os_version", vbuf); } wpa_config_write_reg_dword(hk, TEXT("wps_cred_processing"), config->wps_cred_processing, 0); #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P wpa_config_write_reg_string(hk, "p2p_ssid_postfix", config->p2p_ssid_postfix); wpa_config_write_reg_dword(hk, TEXT("p2p_group_idle"), config->p2p_group_idle, 0); #endif /* CONFIG_P2P */ wpa_config_write_reg_dword(hk, TEXT("bss_max_count"), config->bss_max_count, DEFAULT_BSS_MAX_COUNT); wpa_config_write_reg_dword(hk, TEXT("filter_ssids"), config->filter_ssids, 0); wpa_config_write_reg_dword(hk, TEXT("max_num_sta"), config->max_num_sta, DEFAULT_MAX_NUM_STA); wpa_config_write_reg_dword(hk, TEXT("disassoc_low_ack"), config->disassoc_low_ack, 0); wpa_config_write_reg_dword(hk, TEXT("sched_scan_num_short_intervals"), config->sched_scan_num_short_intervals, DEFAULT_SCHED_SCAN_NUM_SHORT_INTERVALS); wpa_config_write_reg_dword(hk, TEXT("sched_scan_short_interval"), config->sched_scan_short_interval, DEFAULT_SCHED_SCAN_SHORT_INTERVAL); wpa_config_write_reg_dword(hk, TEXT("sched_scan_long_interval"), config->sched_scan_long_interval, DEFAULT_SCHED_SCAN_LONG_INTERVAL); wpa_config_write_reg_dword(hk, TEXT("okc"), config->okc, 0); wpa_config_write_reg_dword(hk, TEXT("pmf"), config->pmf, 0); return 0; }
static void wpa_config_write_global(FILE *f, struct wpa_config *config) { #ifdef CONFIG_CTRL_IFACE if (config->ctrl_interface) fprintf(f, "ctrl_interface=%s\n", config->ctrl_interface); if (config->ctrl_interface_group) fprintf(f, "ctrl_interface_group=%s\n", config->ctrl_interface_group); #endif /* CONFIG_CTRL_IFACE */ if (config->eapol_version != DEFAULT_EAPOL_VERSION) fprintf(f, "eapol_version=%d\n", config->eapol_version); if (config->ap_scan != DEFAULT_AP_SCAN) fprintf(f, "ap_scan=%d\n", config->ap_scan); if (config->disable_scan_offload) fprintf(f, "disable_scan_offload=%d\n", config->disable_scan_offload); if (config->fast_reauth != DEFAULT_FAST_REAUTH) fprintf(f, "fast_reauth=%d\n", config->fast_reauth); if (config->opensc_engine_path) fprintf(f, "opensc_engine_path=%s\n", config->opensc_engine_path); if (config->pkcs11_engine_path) fprintf(f, "pkcs11_engine_path=%s\n", config->pkcs11_engine_path); if (config->pkcs11_module_path) fprintf(f, "pkcs11_module_path=%s\n", config->pkcs11_module_path); if (config->pcsc_reader) fprintf(f, "pcsc_reader=%s\n", config->pcsc_reader); if (config->pcsc_pin) fprintf(f, "pcsc_pin=%s\n", config->pcsc_pin); if (config->driver_param) fprintf(f, "driver_param=%s\n", config->driver_param); if (config->dot11RSNAConfigPMKLifetime) fprintf(f, "dot11RSNAConfigPMKLifetime=%d\n", config->dot11RSNAConfigPMKLifetime); if (config->dot11RSNAConfigPMKReauthThreshold) fprintf(f, "dot11RSNAConfigPMKReauthThreshold=%d\n", config->dot11RSNAConfigPMKReauthThreshold); if (config->dot11RSNAConfigSATimeout) fprintf(f, "dot11RSNAConfigSATimeout=%d\n", config->dot11RSNAConfigSATimeout); if (config->update_config) fprintf(f, "update_config=%d\n", config->update_config); #ifdef CONFIG_WPS if (!is_nil_uuid(config->uuid)) { char buf[40]; uuid_bin2str(config->uuid, buf, sizeof(buf)); fprintf(f, "uuid=%s\n", buf); } if (config->device_name) fprintf(f, "device_name=%s\n", config->device_name); if (config->manufacturer) fprintf(f, "manufacturer=%s\n", config->manufacturer); if (config->model_name) fprintf(f, "model_name=%s\n", config->model_name); if (config->model_number) fprintf(f, "model_number=%s\n", config->model_number); if (config->serial_number) fprintf(f, "serial_number=%s\n", config->serial_number); { char _buf[WPS_DEV_TYPE_BUFSIZE], *buf; buf = wps_dev_type_bin2str(config->device_type, _buf, sizeof(_buf)); if (os_strcmp(buf, "0-00000000-0") != 0) fprintf(f, "device_type=%s\n", buf); } if (WPA_GET_BE32(config->os_version)) fprintf(f, "os_version=%08x\n", WPA_GET_BE32(config->os_version)); if (config->config_methods) fprintf(f, "config_methods=%s\n", config->config_methods); if (config->wps_cred_processing) fprintf(f, "wps_cred_processing=%d\n", config->wps_cred_processing); if (config->wps_vendor_ext_m1) { int i, len = wpabuf_len(config->wps_vendor_ext_m1); const u8 *p = wpabuf_head_u8(config->wps_vendor_ext_m1); if (len > 0) { fprintf(f, "wps_vendor_ext_m1="); for (i = 0; i < len; i++) fprintf(f, "%02x", *p++); fprintf(f, "\n"); } } #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P if (config->p2p_listen_reg_class) fprintf(f, "p2p_listen_reg_class=%u\n", config->p2p_listen_reg_class); if (config->p2p_listen_channel) fprintf(f, "p2p_listen_channel=%u\n", config->p2p_listen_channel); if (config->p2p_oper_reg_class) fprintf(f, "p2p_oper_reg_class=%u\n", config->p2p_oper_reg_class); if (config->p2p_oper_channel) fprintf(f, "p2p_oper_channel=%u\n", config->p2p_oper_channel); if (config->p2p_go_intent != DEFAULT_P2P_GO_INTENT) fprintf(f, "p2p_go_intent=%u\n", config->p2p_go_intent); if (config->p2p_ssid_postfix) fprintf(f, "p2p_ssid_postfix=%s\n", config->p2p_ssid_postfix); if (config->persistent_reconnect) fprintf(f, "persistent_reconnect=%u\n", config->persistent_reconnect); if (config->p2p_intra_bss != DEFAULT_P2P_INTRA_BSS) fprintf(f, "p2p_intra_bss=%u\n", config->p2p_intra_bss); if (config->p2p_group_idle) fprintf(f, "p2p_group_idle=%u\n", config->p2p_group_idle); if (config->p2p_pref_chan) { unsigned int i; fprintf(f, "p2p_pref_chan="); for (i = 0; i < config->num_p2p_pref_chan; i++) { fprintf(f, "%s%u:%u", i > 0 ? "," : "", config->p2p_pref_chan[i].op_class, config->p2p_pref_chan[i].chan); } fprintf(f, "\n"); } if (config->p2p_no_go_freq.num) { char *val = freq_range_list_str(&config->p2p_no_go_freq); if (val) { fprintf(f, "p2p_no_go_freq=%s\n", val); os_free(val); } } if (config->p2p_add_cli_chan) fprintf(f, "p2p_add_cli_chan=%d\n", config->p2p_add_cli_chan); if (config->p2p_go_ht40) fprintf(f, "p2p_go_ht40=%u\n", config->p2p_go_ht40); if (config->p2p_go_vht) fprintf(f, "p2p_go_vht=%u\n", config->p2p_go_vht); if (config->p2p_disabled) fprintf(f, "p2p_disabled=%u\n", config->p2p_disabled); if (config->p2p_no_group_iface) fprintf(f, "p2p_no_group_iface=%u\n", config->p2p_no_group_iface); if (config->p2p_ignore_shared_freq) fprintf(f, "p2p_ignore_shared_freq=%u\n", config->p2p_ignore_shared_freq); #endif /* CONFIG_P2P */ if (config->country[0] && config->country[1]) { fprintf(f, "country=%c%c\n", config->country[0], config->country[1]); } if (config->bss_max_count != DEFAULT_BSS_MAX_COUNT) fprintf(f, "bss_max_count=%u\n", config->bss_max_count); if (config->bss_expiration_age != DEFAULT_BSS_EXPIRATION_AGE) fprintf(f, "bss_expiration_age=%u\n", config->bss_expiration_age); if (config->bss_expiration_scan_count != DEFAULT_BSS_EXPIRATION_SCAN_COUNT) fprintf(f, "bss_expiration_scan_count=%u\n", config->bss_expiration_scan_count); if (config->filter_ssids) fprintf(f, "filter_ssids=%d\n", config->filter_ssids); if (config->max_num_sta != DEFAULT_MAX_NUM_STA) fprintf(f, "max_num_sta=%u\n", config->max_num_sta); if (config->disassoc_low_ack) fprintf(f, "disassoc_low_ack=%u\n", config->disassoc_low_ack); #ifdef CONFIG_HS20 if (config->hs20) fprintf(f, "hs20=1\n"); #endif /* CONFIG_HS20 */ #ifdef CONFIG_INTERWORKING if (config->interworking) fprintf(f, "interworking=%u\n", config->interworking); if (!is_zero_ether_addr(config->hessid)) fprintf(f, "hessid=" MACSTR "\n", MAC2STR(config->hessid)); if (config->access_network_type != DEFAULT_ACCESS_NETWORK_TYPE) fprintf(f, "access_network_type=%d\n", config->access_network_type); #endif /* CONFIG_INTERWORKING */ if (config->pbc_in_m1) fprintf(f, "pbc_in_m1=%u\n", config->pbc_in_m1); if (config->wps_nfc_pw_from_config) { if (config->wps_nfc_dev_pw_id) fprintf(f, "wps_nfc_dev_pw_id=%d\n", config->wps_nfc_dev_pw_id); write_global_bin(f, "wps_nfc_dh_pubkey", config->wps_nfc_dh_pubkey); write_global_bin(f, "wps_nfc_dh_privkey", config->wps_nfc_dh_privkey); write_global_bin(f, "wps_nfc_dev_pw", config->wps_nfc_dev_pw); } if (config->ext_password_backend) fprintf(f, "ext_password_backend=%s\n", config->ext_password_backend); if (config->p2p_go_max_inactivity != DEFAULT_P2P_GO_MAX_INACTIVITY) fprintf(f, "p2p_go_max_inactivity=%d\n", config->p2p_go_max_inactivity); if (config->auto_interworking) fprintf(f, "auto_interworking=%d\n", config->auto_interworking); if (config->okc) fprintf(f, "okc=%d\n", config->okc); if (config->pmf) fprintf(f, "pmf=%d\n", config->pmf); if (config->dtim_period) fprintf(f, "dtim_period=%d\n", config->dtim_period); if (config->beacon_int) fprintf(f, "beacon_int=%d\n", config->beacon_int); if (config->sae_groups) { int i; fprintf(f, "sae_groups="); for (i = 0; config->sae_groups[i] >= 0; i++) { fprintf(f, "%s%d", i > 0 ? " " : "", config->sae_groups[i]); } fprintf(f, "\n"); } if (config->ap_vendor_elements) { int i, len = wpabuf_len(config->ap_vendor_elements); const u8 *p = wpabuf_head_u8(config->ap_vendor_elements); if (len > 0) { fprintf(f, "ap_vendor_elements="); for (i = 0; i < len; i++) fprintf(f, "%02x", *p++); fprintf(f, "\n"); } } if (config->ignore_old_scan_res) fprintf(f, "ignore_old_scan_res=%d\n", config->ignore_old_scan_res); if (config->freq_list && config->freq_list[0]) { int i; fprintf(f, "freq_list="); for (i = 0; config->freq_list[i]; i++) { fprintf(f, "%s%u", i > 0 ? " " : "", config->freq_list[i]); } fprintf(f, "\n"); } if (config->scan_cur_freq != DEFAULT_SCAN_CUR_FREQ) fprintf(f, "scan_cur_freq=%d\n", config->scan_cur_freq); if (config->sched_scan_interval) fprintf(f, "sched_scan_interval=%u\n", config->sched_scan_interval); if (config->external_sim) fprintf(f, "external_sim=%d\n", config->external_sim); if (config->tdls_external_control) fprintf(f, "tdls_external_control=%d\n", config->tdls_external_control); }
int wps_attr_text(struct wpabuf *data, char *buf, char *end) { struct wps_parse_attr attr; char *pos = buf; int ret; if (wps_parse_msg(data, &attr) < 0) return -1; if (attr.wps_state) { if (*attr.wps_state == WPS_STATE_NOT_CONFIGURED) ret = os_snprintf(pos, end - pos, "wps_state=unconfigured\n"); else if (*attr.wps_state == WPS_STATE_CONFIGURED) ret = os_snprintf(pos, end - pos, "wps_state=configured\n"); else ret = 0; if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.ap_setup_locked && *attr.ap_setup_locked) { ret = os_snprintf(pos, end - pos, "wps_ap_setup_locked=1\n"); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.selected_registrar && *attr.selected_registrar) { ret = os_snprintf(pos, end - pos, "wps_selected_registrar=1\n"); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.dev_password_id) { ret = os_snprintf(pos, end - pos, "wps_device_password_id=%u\n", WPA_GET_BE16(attr.dev_password_id)); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.sel_reg_config_methods) { ret = os_snprintf(pos, end - pos, "wps_selected_registrar_config_methods=" "0x%04x\n", WPA_GET_BE16(attr.sel_reg_config_methods)); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.primary_dev_type) { char devtype[WPS_DEV_TYPE_BUFSIZE]; ret = os_snprintf(pos, end - pos, "wps_primary_device_type=%s\n", wps_dev_type_bin2str(attr.primary_dev_type, devtype, sizeof(devtype))); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.dev_name) { char *str = os_malloc(attr.dev_name_len + 1); size_t i; if (str == NULL) return pos - buf; for (i = 0; i < attr.dev_name_len; i++) { if (attr.dev_name[i] == 0 || is_ctrl_char(attr.dev_name[i])) str[i] = '_'; else str[i] = attr.dev_name[i]; } str[i] = '\0'; ret = os_snprintf(pos, end - pos, "wps_device_name=%s\n", str); os_free(str); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } if (attr.config_methods) { ret = os_snprintf(pos, end - pos, "wps_config_methods=0x%04x\n", WPA_GET_BE16(attr.config_methods)); if (os_snprintf_error(end - pos, ret)) return pos - buf; pos += ret; } return pos - buf; }
static void wpa_config_write_global(FILE *f, struct wpa_config *config) { #ifdef CONFIG_CTRL_IFACE if (config->ctrl_interface) fprintf(f, "ctrl_interface=%s\n", config->ctrl_interface); if (config->ctrl_interface_group) fprintf(f, "ctrl_interface_group=%s\n", config->ctrl_interface_group); #endif /* CONFIG_CTRL_IFACE */ if (config->eapol_version != DEFAULT_EAPOL_VERSION) fprintf(f, "eapol_version=%d\n", config->eapol_version); if (config->ap_scan != DEFAULT_AP_SCAN) fprintf(f, "ap_scan=%d\n", config->ap_scan); if (config->fast_reauth != DEFAULT_FAST_REAUTH) fprintf(f, "fast_reauth=%d\n", config->fast_reauth); if (config->opensc_engine_path) fprintf(f, "opensc_engine_path=%s\n", config->opensc_engine_path); if (config->pkcs11_engine_path) fprintf(f, "pkcs11_engine_path=%s\n", config->pkcs11_engine_path); if (config->pkcs11_module_path) fprintf(f, "pkcs11_module_path=%s\n", config->pkcs11_module_path); if (config->driver_param) fprintf(f, "driver_param=%s\n", config->driver_param); if (config->dot11RSNAConfigPMKLifetime) fprintf(f, "dot11RSNAConfigPMKLifetime=%d\n", config->dot11RSNAConfigPMKLifetime); if (config->dot11RSNAConfigPMKReauthThreshold) fprintf(f, "dot11RSNAConfigPMKReauthThreshold=%d\n", config->dot11RSNAConfigPMKReauthThreshold); if (config->dot11RSNAConfigSATimeout) fprintf(f, "dot11RSNAConfigSATimeout=%d\n", config->dot11RSNAConfigSATimeout); if (config->update_config) fprintf(f, "update_config=%d\n", config->update_config); #ifdef CONFIG_WPS if (!is_nil_uuid(config->uuid)) { char buf[40]; uuid_bin2str(config->uuid, buf, sizeof(buf)); fprintf(f, "uuid=%s\n", buf); } if (config->device_name) fprintf(f, "device_name=%s\n", config->device_name); if (config->manufacturer) fprintf(f, "manufacturer=%s\n", config->manufacturer); if (config->model_name) fprintf(f, "model_name=%s\n", config->model_name); if (config->model_number) fprintf(f, "model_number=%s\n", config->model_number); if (config->serial_number) fprintf(f, "serial_number=%s\n", config->serial_number); { char _buf[WPS_DEV_TYPE_BUFSIZE], *buf; buf = wps_dev_type_bin2str(config->device_type, _buf, sizeof(_buf)); fprintf(f, "device_type=%s\n", buf); } if (WPA_GET_BE32(config->os_version)) fprintf(f, "os_version=%08x\n", WPA_GET_BE32(config->os_version)); if (config->config_methods) fprintf(f, "config_methods=%s\n", config->config_methods); if (config->wps_cred_processing) fprintf(f, "wps_cred_processing=%d\n", config->wps_cred_processing); #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P if (config->p2p_listen_reg_class) fprintf(f, "p2p_listen_reg_class=%u\n", config->p2p_listen_reg_class); if (config->p2p_listen_channel) fprintf(f, "p2p_listen_channel=%u\n", config->p2p_listen_channel); if (config->p2p_oper_reg_class) fprintf(f, "p2p_oper_reg_class=%u\n", config->p2p_oper_reg_class); if (config->p2p_oper_channel) fprintf(f, "p2p_oper_channel=%u\n", config->p2p_oper_channel); if (config->p2p_go_intent != DEFAULT_P2P_GO_INTENT) fprintf(f, "p2p_go_intent=%u\n", config->p2p_go_intent); if (config->p2p_ssid_postfix) fprintf(f, "p2p_ssid_postfix=%s\n", config->p2p_ssid_postfix); if (config->persistent_reconnect) fprintf(f, "persistent_reconnect=%u\n", config->persistent_reconnect); if (config->p2p_intra_bss != DEFAULT_P2P_INTRA_BSS) fprintf(f, "p2p_intra_bss=%u\n", config->p2p_intra_bss); if (config->p2p_group_idle) fprintf(f, "p2p_group_idle=%u\n", config->p2p_group_idle); #endif /* CONFIG_P2P */ if (config->country[0] && config->country[1]) { fprintf(f, "country=%c%c\n", config->country[0], config->country[1]); } if (config->bss_max_count != DEFAULT_BSS_MAX_COUNT) fprintf(f, "bss_max_count=%u\n", config->bss_max_count); if (config->filter_ssids) fprintf(f, "filter_ssids=%d\n", config->filter_ssids); if (config->max_num_sta != DEFAULT_MAX_NUM_STA) fprintf(f, "max_num_sta=%u\n", config->max_num_sta); if (config->disassoc_low_ack) fprintf(f, "disassoc_low_ack=%u\n", config->disassoc_low_ack); }
/** * p2p_attr_text - Build text format description of P2P IE attributes * @data: P2P IE contents * @buf: Buffer for returning text * @end: Pointer to the end of the buf area * Returns: Number of octets written to the buffer or -1 on faikure * * This function can be used to parse P2P IE contents into text format * field=value lines. */ int p2p_attr_text(struct wpabuf *data, char *buf, char *end) { struct p2p_message msg; char *pos = buf; int ret; os_memset(&msg, 0, sizeof(msg)); if (p2p_parse_p2p_ie(data, &msg)) return -1; if (msg.capability) { ret = os_snprintf(pos, end - pos, "p2p_dev_capab=0x%x\n" "p2p_group_capab=0x%x\n", msg.capability[0], msg.capability[1]); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; } if (msg.pri_dev_type) { char devtype[WPS_DEV_TYPE_BUFSIZE]; ret = os_snprintf(pos, end - pos, "p2p_primary_device_type=%s\n", wps_dev_type_bin2str(msg.pri_dev_type, devtype, sizeof(devtype))); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; } ret = os_snprintf(pos, end - pos, "p2p_device_name=%s\n", msg.device_name); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; if (msg.p2p_device_addr) { ret = os_snprintf(pos, end - pos, "p2p_device_addr=" MACSTR "\n", MAC2STR(msg.p2p_device_addr)); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; } ret = os_snprintf(pos, end - pos, "p2p_config_methods=0x%x\n", msg.config_methods); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; ret = p2p_group_info_text(msg.group_info, msg.group_info_len, pos, end); if (ret < 0) return pos - buf; pos += ret; return pos - buf; }
static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf, char *end) { char *pos = buf; int ret; struct p2p_group_info info; unsigned int i; if (p2p_group_info_parse(gi, gi_len, &info) < 0) return 0; for (i = 0; i < info.num_clients; i++) { struct p2p_client_info *cli; char name[33]; char devtype[WPS_DEV_TYPE_BUFSIZE]; u8 s; int count; cli = &info.client[i]; ret = os_snprintf(pos, end - pos, "p2p_group_client: " "dev=" MACSTR " iface=" MACSTR, MAC2STR(cli->p2p_device_addr), MAC2STR(cli->p2p_interface_addr)); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; ret = os_snprintf(pos, end - pos, " dev_capab=0x%x config_methods=0x%x " "dev_type=%s", cli->dev_capab, cli->config_methods, wps_dev_type_bin2str(cli->pri_dev_type, devtype, sizeof(devtype))); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; for (s = 0; s < cli->num_sec_dev_types; s++) { ret = os_snprintf(pos, end - pos, " dev_type=%s", wps_dev_type_bin2str( &cli->sec_dev_types[s * 8], devtype, sizeof(devtype))); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; } os_memcpy(name, cli->dev_name, cli->dev_name_len); name[cli->dev_name_len] = '\0'; count = (int) cli->dev_name_len - 1; while (count >= 0) { if (name[count] > 0 && name[count] < 32) name[count] = '_'; count--; } ret = os_snprintf(pos, end - pos, " dev_name='%s'\n", name); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; } return pos - buf; }
static int p2p_parse_attribute(u8 id, const u8 *data, u16 len, struct p2p_message *msg) { const u8 *pos; size_t i, nlen; char devtype[WPS_DEV_TYPE_BUFSIZE]; switch (id) { case P2P_ATTR_CAPABILITY: if (len < 2) { wpa_printf(MSG_DEBUG, "P2P: Too short Capability " "attribute (length %d)", len); return -1; } msg->capability = data; wpa_printf(MSG_DEBUG, "P2P: * Device Capability %02x " "Group Capability %02x", data[0], data[1]); break; case P2P_ATTR_DEVICE_ID: if (len < ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short Device ID " "attribute (length %d)", len); return -1; } msg->device_id = data; wpa_printf(MSG_DEBUG, "P2P: * Device ID " MACSTR, MAC2STR(msg->device_id)); break; case P2P_ATTR_GROUP_OWNER_INTENT: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short GO Intent " "attribute (length %d)", len); return -1; } msg->go_intent = data; wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u " "Tie breaker %u", data[0] >> 1, data[0] & 0x01); break; case P2P_ATTR_STATUS: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Status " "attribute (length %d)", len); return -1; } msg->status = data; wpa_printf(MSG_DEBUG, "P2P: * Status: %d", data[0]); break; case P2P_ATTR_LISTEN_CHANNEL: if (len == 0) { wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: Ignore " "null channel"); break; } if (len < 5) { wpa_printf(MSG_DEBUG, "P2P: Too short Listen Channel " "attribute (length %d)", len); return -1; } msg->listen_channel = data; wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: " "Country %c%c(0x%02x) Regulatory " "Class %d Channel Number %d", data[0], data[1], data[2], data[3], data[4]); break; case P2P_ATTR_OPERATING_CHANNEL: if (len == 0) { wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: " "Ignore null channel"); break; } if (len < 5) { wpa_printf(MSG_DEBUG, "P2P: Too short Operating " "Channel attribute (length %d)", len); return -1; } msg->operating_channel = data; wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: " "Country %c%c(0x%02x) Regulatory " "Class %d Channel Number %d", data[0], data[1], data[2], data[3], data[4]); break; case P2P_ATTR_CHANNEL_LIST: if (len < 3) { wpa_printf(MSG_DEBUG, "P2P: Too short Channel List " "attribute (length %d)", len); return -1; } msg->channel_list = data; msg->channel_list_len = len; wpa_printf(MSG_DEBUG, "P2P: * Channel List: Country String " "'%c%c(0x%02x)'", data[0], data[1], data[2]); wpa_hexdump(MSG_MSGDUMP, "P2P: Channel List", msg->channel_list, msg->channel_list_len); break; case P2P_ATTR_GROUP_INFO: msg->group_info = data; msg->group_info_len = len; wpa_printf(MSG_DEBUG, "P2P: * Group Info"); break; case P2P_ATTR_DEVICE_INFO: if (len < ETH_ALEN + 2 + 8 + 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Device Info " "attribute (length %d)", len); return -1; } msg->p2p_device_info = data; msg->p2p_device_info_len = len; pos = data; msg->p2p_device_addr = pos; pos += ETH_ALEN; msg->config_methods = WPA_GET_BE16(pos); pos += 2; msg->pri_dev_type = pos; pos += 8; msg->num_sec_dev_types = *pos++; if (msg->num_sec_dev_types * 8 > data + len - pos) { wpa_printf(MSG_DEBUG, "P2P: Device Info underflow"); return -1; } pos += msg->num_sec_dev_types * 8; if (data + len - pos < 4) { wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name " "length %d", (int) (data + len - pos)); return -1; } if (WPA_GET_BE16(pos) != ATTR_DEV_NAME) { wpa_hexdump(MSG_DEBUG, "P2P: Unexpected Device Name " "header", pos, 4); return -1; } pos += 2; nlen = WPA_GET_BE16(pos); pos += 2; if (data + len - pos < (int) nlen || nlen > 32) { wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name " "length %d (buf len %d)", (int) nlen, (int) (data + len - pos)); return -1; } os_memcpy(msg->device_name, pos, nlen); msg->device_name[nlen] = '\0'; for (i = 0; i < nlen; i++) { if (msg->device_name[i] == '\0') break; if (msg->device_name[i] > 0 && msg->device_name[i] < 32) msg->device_name[i] = '_'; } wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR " primary device type %s device name '%s' " "config methods 0x%x", MAC2STR(msg->p2p_device_addr), wps_dev_type_bin2str(msg->pri_dev_type, devtype, sizeof(devtype)), msg->device_name, msg->config_methods); break; case P2P_ATTR_CONFIGURATION_TIMEOUT: if (len < 2) { wpa_printf(MSG_DEBUG, "P2P: Too short Configuration " "Timeout attribute (length %d)", len); return -1; } msg->config_timeout = data; wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout"); break; case P2P_ATTR_INTENDED_INTERFACE_ADDR: if (len < ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short Intended P2P " "Interface Address attribute (length %d)", len); return -1; } msg->intended_addr = data; wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address: " MACSTR, MAC2STR(msg->intended_addr)); break; case P2P_ATTR_GROUP_BSSID: if (len < ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short P2P Group BSSID " "attribute (length %d)", len); return -1; } msg->group_bssid = data; wpa_printf(MSG_DEBUG, "P2P: * P2P Group BSSID: " MACSTR, MAC2STR(msg->group_bssid)); break; case P2P_ATTR_GROUP_ID: if (len < ETH_ALEN || len > ETH_ALEN + 32) { wpa_printf(MSG_DEBUG, "P2P: Invalid P2P Group ID " "attribute length %d", len); return -1; } msg->group_id = data; msg->group_id_len = len; wpa_printf(MSG_DEBUG, "P2P: * P2P Group ID: Device Address " MACSTR, MAC2STR(msg->group_id)); wpa_hexdump_ascii(MSG_DEBUG, "P2P: * P2P Group ID: SSID", msg->group_id + ETH_ALEN, msg->group_id_len - ETH_ALEN); break; case P2P_ATTR_INVITATION_FLAGS: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Invitation " "Flag attribute (length %d)", len); return -1; } msg->invitation_flags = data; wpa_printf(MSG_DEBUG, "P2P: * Invitation Flags: bitmap 0x%x", data[0]); break; case P2P_ATTR_MANAGEABILITY: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Manageability " "attribute (length %d)", len); return -1; } msg->manageability = data; wpa_printf(MSG_DEBUG, "P2P: * Manageability: bitmap 0x%x", data[0]); break; case P2P_ATTR_NOTICE_OF_ABSENCE: if (len < 2) { wpa_printf(MSG_DEBUG, "P2P: Too short Notice of " "Absence attribute (length %d)", len); return -1; } msg->noa = data; msg->noa_len = len; wpa_printf(MSG_DEBUG, "P2P: * Notice of Absence"); break; case P2P_ATTR_EXT_LISTEN_TIMING: if (len < 4) { wpa_printf(MSG_DEBUG, "P2P: Too short Extended Listen " "Timing attribute (length %d)", len); return -1; } msg->ext_listen_timing = data; wpa_printf(MSG_DEBUG, "P2P: * Extended Listen Timing " "(period %u msec interval %u msec)", WPA_GET_LE16(msg->ext_listen_timing), WPA_GET_LE16(msg->ext_listen_timing + 2)); break; case P2P_ATTR_MINOR_REASON_CODE: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Minor Reason " "Code attribute (length %d)", len); return -1; } msg->minor_reason_code = data; wpa_printf(MSG_DEBUG, "P2P: * Minor Reason Code: %u", *msg->minor_reason_code); break; default: wpa_printf(MSG_DEBUG, "P2P: Skipped unknown attribute %d " "(length %d)", id, len); break; } return 0; }
static void wpa_config_write_global(FILE *f, struct wpa_config *config) { #ifdef CONFIG_CTRL_IFACE if (config->ctrl_interface) fprintf(f, "ctrl_interface=%s\n", config->ctrl_interface); if (config->ctrl_interface_group) fprintf(f, "ctrl_interface_group=%s\n", config->ctrl_interface_group); #endif /* CONFIG_CTRL_IFACE */ if (config->eapol_version != DEFAULT_EAPOL_VERSION) fprintf(f, "eapol_version=%d\n", config->eapol_version); if (config->ap_scan != DEFAULT_AP_SCAN) fprintf(f, "ap_scan=%d\n", config->ap_scan); if (config->disable_scan_offload) fprintf(f, "disable_scan_offload=%d\n", config->disable_scan_offload); if (config->fast_reauth != DEFAULT_FAST_REAUTH) fprintf(f, "fast_reauth=%d\n", config->fast_reauth); if (config->opensc_engine_path) fprintf(f, "opensc_engine_path=%s\n", config->opensc_engine_path); if (config->pkcs11_engine_path) fprintf(f, "pkcs11_engine_path=%s\n", config->pkcs11_engine_path); if (config->pkcs11_module_path) fprintf(f, "pkcs11_module_path=%s\n", config->pkcs11_module_path); if (config->openssl_ciphers) fprintf(f, "openssl_ciphers=%s\n", config->openssl_ciphers); if (config->pcsc_reader) fprintf(f, "pcsc_reader=%s\n", config->pcsc_reader); if (config->pcsc_pin) fprintf(f, "pcsc_pin=%s\n", config->pcsc_pin); if (config->driver_param) fprintf(f, "driver_param=%s\n", config->driver_param); if (config->dot11RSNAConfigPMKLifetime) fprintf(f, "dot11RSNAConfigPMKLifetime=%u\n", config->dot11RSNAConfigPMKLifetime); if (config->dot11RSNAConfigPMKReauthThreshold) fprintf(f, "dot11RSNAConfigPMKReauthThreshold=%u\n", config->dot11RSNAConfigPMKReauthThreshold); if (config->dot11RSNAConfigSATimeout) fprintf(f, "dot11RSNAConfigSATimeout=%u\n", config->dot11RSNAConfigSATimeout); if (config->update_config) fprintf(f, "update_config=%d\n", config->update_config); #ifdef CONFIG_WPS if (!is_nil_uuid(config->uuid)) { char buf[40]; uuid_bin2str(config->uuid, buf, sizeof(buf)); fprintf(f, "uuid=%s\n", buf); } if (config->device_name) fprintf(f, "device_name=%s\n", config->device_name); if (config->manufacturer) fprintf(f, "manufacturer=%s\n", config->manufacturer); if (config->model_name) fprintf(f, "model_name=%s\n", config->model_name); if (config->model_number) fprintf(f, "model_number=%s\n", config->model_number); if (config->serial_number) fprintf(f, "serial_number=%s\n", config->serial_number); { char _buf[WPS_DEV_TYPE_BUFSIZE], *buf; buf = wps_dev_type_bin2str(config->device_type, _buf, sizeof(_buf)); if (os_strcmp(buf, "0-00000000-0") != 0) fprintf(f, "device_type=%s\n", buf); } if (WPA_GET_BE32(config->os_version)) fprintf(f, "os_version=%08x\n", WPA_GET_BE32(config->os_version)); if (config->config_methods) fprintf(f, "config_methods=%s\n", config->config_methods); if (config->wps_cred_processing) fprintf(f, "wps_cred_processing=%d\n", config->wps_cred_processing); if (config->wps_vendor_ext_m1) { int i, len = wpabuf_len(config->wps_vendor_ext_m1); const u8 *p = wpabuf_head_u8(config->wps_vendor_ext_m1); if (len > 0) { fprintf(f, "wps_vendor_ext_m1="); for (i = 0; i < len; i++) fprintf(f, "%02x", *p++); fprintf(f, "\n"); } } #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P if (config->p2p_listen_reg_class) fprintf(f, "p2p_listen_reg_class=%d\n", config->p2p_listen_reg_class); if (config->p2p_listen_channel) fprintf(f, "p2p_listen_channel=%d\n", config->p2p_listen_channel); if (config->p2p_oper_reg_class) fprintf(f, "p2p_oper_reg_class=%d\n", config->p2p_oper_reg_class); if (config->p2p_oper_channel) fprintf(f, "p2p_oper_channel=%d\n", config->p2p_oper_channel); if (config->p2p_go_intent != DEFAULT_P2P_GO_INTENT) fprintf(f, "p2p_go_intent=%d\n", config->p2p_go_intent); if (config->p2p_ssid_postfix) fprintf(f, "p2p_ssid_postfix=%s\n", config->p2p_ssid_postfix); if (config->persistent_reconnect) fprintf(f, "persistent_reconnect=%d\n", config->persistent_reconnect); if (config->p2p_intra_bss != DEFAULT_P2P_INTRA_BSS) fprintf(f, "p2p_intra_bss=%d\n", config->p2p_intra_bss); if (config->p2p_group_idle) fprintf(f, "p2p_group_idle=%d\n", config->p2p_group_idle); if (config->p2p_passphrase_len) fprintf(f, "p2p_passphrase_len=%u\n", config->p2p_passphrase_len); if (config->p2p_pref_chan) { unsigned int i; fprintf(f, "p2p_pref_chan="); for (i = 0; i < config->num_p2p_pref_chan; i++) { fprintf(f, "%s%u:%u", i > 0 ? "," : "", config->p2p_pref_chan[i].op_class, config->p2p_pref_chan[i].chan); } fprintf(f, "\n"); } if (config->p2p_no_go_freq.num) { char *val = freq_range_list_str(&config->p2p_no_go_freq); if (val) { fprintf(f, "p2p_no_go_freq=%s\n", val); os_free(val); } } if (config->p2p_add_cli_chan) fprintf(f, "p2p_add_cli_chan=%d\n", config->p2p_add_cli_chan); if (config->p2p_optimize_listen_chan != DEFAULT_P2P_OPTIMIZE_LISTEN_CHAN) fprintf(f, "p2p_optimize_listen_chan=%d\n", config->p2p_optimize_listen_chan); if (config->p2p_go_ht40) fprintf(f, "p2p_go_ht40=%d\n", config->p2p_go_ht40); if (config->p2p_go_vht) fprintf(f, "p2p_go_vht=%d\n", config->p2p_go_vht); if (config->p2p_go_ctwindow != DEFAULT_P2P_GO_CTWINDOW) fprintf(f, "p2p_go_ctwindow=%d\n", config->p2p_go_ctwindow); if (config->p2p_disabled) fprintf(f, "p2p_disabled=%d\n", config->p2p_disabled); if (config->p2p_no_group_iface) fprintf(f, "p2p_no_group_iface=%d\n", config->p2p_no_group_iface); if (config->p2p_ignore_shared_freq) fprintf(f, "p2p_ignore_shared_freq=%d\n", config->p2p_ignore_shared_freq); if (config->p2p_cli_probe) fprintf(f, "p2p_cli_probe=%d\n", config->p2p_cli_probe); if (config->p2p_go_freq_change_policy != DEFAULT_P2P_GO_FREQ_MOVE) fprintf(f, "p2p_go_freq_change_policy=%u\n", config->p2p_go_freq_change_policy); if (WPA_GET_BE32(config->ip_addr_go)) fprintf(f, "ip_addr_go=%u.%u.%u.%u\n", config->ip_addr_go[0], config->ip_addr_go[1], config->ip_addr_go[2], config->ip_addr_go[3]); if (WPA_GET_BE32(config->ip_addr_mask)) fprintf(f, "ip_addr_mask=%u.%u.%u.%u\n", config->ip_addr_mask[0], config->ip_addr_mask[1], config->ip_addr_mask[2], config->ip_addr_mask[3]); if (WPA_GET_BE32(config->ip_addr_start)) fprintf(f, "ip_addr_start=%u.%u.%u.%u\n", config->ip_addr_start[0], config->ip_addr_start[1], config->ip_addr_start[2], config->ip_addr_start[3]); if (WPA_GET_BE32(config->ip_addr_end)) fprintf(f, "ip_addr_end=%u.%u.%u.%u\n", config->ip_addr_end[0], config->ip_addr_end[1], config->ip_addr_end[2], config->ip_addr_end[3]); #endif /* CONFIG_P2P */ if (config->country[0] && config->country[1]) { fprintf(f, "country=%c%c\n", config->country[0], config->country[1]); } if (config->bss_max_count != DEFAULT_BSS_MAX_COUNT) fprintf(f, "bss_max_count=%u\n", config->bss_max_count); if (config->bss_expiration_age != DEFAULT_BSS_EXPIRATION_AGE) fprintf(f, "bss_expiration_age=%u\n", config->bss_expiration_age); if (config->bss_expiration_scan_count != DEFAULT_BSS_EXPIRATION_SCAN_COUNT) fprintf(f, "bss_expiration_scan_count=%u\n", config->bss_expiration_scan_count); if (config->filter_ssids) fprintf(f, "filter_ssids=%d\n", config->filter_ssids); if (config->max_num_sta != DEFAULT_MAX_NUM_STA) fprintf(f, "max_num_sta=%u\n", config->max_num_sta); if (config->disassoc_low_ack) fprintf(f, "disassoc_low_ack=%d\n", config->disassoc_low_ack); #ifdef CONFIG_HS20 if (config->hs20) fprintf(f, "hs20=1\n"); #endif /* CONFIG_HS20 */ #ifdef CONFIG_INTERWORKING if (config->interworking) fprintf(f, "interworking=%d\n", config->interworking); if (!is_zero_ether_addr(config->hessid)) fprintf(f, "hessid=" MACSTR "\n", MAC2STR(config->hessid)); if (config->access_network_type != DEFAULT_ACCESS_NETWORK_TYPE) fprintf(f, "access_network_type=%d\n", config->access_network_type); #endif /* CONFIG_INTERWORKING */ if (config->pbc_in_m1) fprintf(f, "pbc_in_m1=%d\n", config->pbc_in_m1); if (config->wps_nfc_pw_from_config) { if (config->wps_nfc_dev_pw_id) fprintf(f, "wps_nfc_dev_pw_id=%d\n", config->wps_nfc_dev_pw_id); write_global_bin(f, "wps_nfc_dh_pubkey", config->wps_nfc_dh_pubkey); write_global_bin(f, "wps_nfc_dh_privkey", config->wps_nfc_dh_privkey); write_global_bin(f, "wps_nfc_dev_pw", config->wps_nfc_dev_pw); } if (config->ext_password_backend) fprintf(f, "ext_password_backend=%s\n", config->ext_password_backend); if (config->p2p_go_max_inactivity != DEFAULT_P2P_GO_MAX_INACTIVITY) fprintf(f, "p2p_go_max_inactivity=%d\n", config->p2p_go_max_inactivity); if (config->auto_interworking) fprintf(f, "auto_interworking=%d\n", config->auto_interworking); if (config->okc) fprintf(f, "okc=%d\n", config->okc); if (config->pmf) fprintf(f, "pmf=%d\n", config->pmf); if (config->dtim_period) fprintf(f, "dtim_period=%d\n", config->dtim_period); if (config->beacon_int) fprintf(f, "beacon_int=%d\n", config->beacon_int); if (config->sae_groups) { int i; fprintf(f, "sae_groups="); for (i = 0; config->sae_groups[i] >= 0; i++) { fprintf(f, "%s%d", i > 0 ? " " : "", config->sae_groups[i]); } fprintf(f, "\n"); } if (config->ap_vendor_elements) { int i, len = wpabuf_len(config->ap_vendor_elements); const u8 *p = wpabuf_head_u8(config->ap_vendor_elements); if (len > 0) { fprintf(f, "ap_vendor_elements="); for (i = 0; i < len; i++) fprintf(f, "%02x", *p++); fprintf(f, "\n"); } } if (config->probe_req_ie) { int i, len = wpabuf_len(config->probe_req_ie); const u8 *p = wpabuf_head_u8(config->probe_req_ie); if (len > 0) { fprintf(f, "probe_req_ie="); for (i = 0; i < len; i++) fprintf(f, "%02x", *p++); fprintf(f, "\n"); } } if (config->assoc_req_ie) { int i, len = wpabuf_len(config->assoc_req_ie); const u8 *p = wpabuf_head_u8(config->assoc_req_ie); if (len > 0) { fprintf(f, "assoc_req_ie="); for (i = 0; i < len; i++) fprintf(f, "%02x", *p++); fprintf(f, "\n"); } } if (config->ignore_old_scan_res) fprintf(f, "ignore_old_scan_res=%d\n", config->ignore_old_scan_res); if (config->freq_list && config->freq_list[0]) { int i; fprintf(f, "freq_list="); for (i = 0; config->freq_list[i]; i++) { fprintf(f, "%s%d", i > 0 ? " " : "", config->freq_list[i]); } fprintf(f, "\n"); } if (config->scan_cur_freq != DEFAULT_SCAN_CUR_FREQ) fprintf(f, "scan_cur_freq=%d\n", config->scan_cur_freq); if (config->chan_width != DEFAULT_CHAN_WIDTH) fprintf(f, "chan_width=%d\n", config->chan_width); if (config->sched_scan_interval) fprintf(f, "sched_scan_interval=%u\n", config->sched_scan_interval); if (config->external_sim) fprintf(f, "external_sim=%d\n", config->external_sim); if (config->tdls_external_control) fprintf(f, "tdls_external_control=%d\n", config->tdls_external_control); if (config->wowlan_triggers) fprintf(f, "wowlan_triggers=%s\n", config->wowlan_triggers); if (config->bgscan) fprintf(f, "bgscan=\"%s\"\n", config->bgscan); if (config->p2p_search_delay != DEFAULT_P2P_SEARCH_DELAY) fprintf(f, "p2p_search_delay=%u\n", config->p2p_search_delay); if (config->mac_addr) fprintf(f, "mac_addr=%d\n", config->mac_addr); if (config->rand_addr_lifetime != DEFAULT_RAND_ADDR_LIFETIME) fprintf(f, "rand_addr_lifetime=%u\n", config->rand_addr_lifetime); if (config->preassoc_mac_addr) fprintf(f, "preassoc_mac_addr=%d\n", config->preassoc_mac_addr); if (config->key_mgmt_offload != DEFAULT_KEY_MGMT_OFFLOAD) fprintf(f, "key_mgmt_offload=%d\n", config->key_mgmt_offload); if (config->user_mpm != DEFAULT_USER_MPM) fprintf(f, "user_mpm=%d\n", config->user_mpm); if (config->max_peer_links != DEFAULT_MAX_PEER_LINKS) fprintf(f, "max_peer_links=%d\n", config->max_peer_links); if (config->cert_in_cb != DEFAULT_CERT_IN_CB) fprintf(f, "cert_in_cb=%d\n", config->cert_in_cb); if (config->mesh_max_inactivity != DEFAULT_MESH_MAX_INACTIVITY) fprintf(f, "mesh_max_inactivity=%d\n", config->mesh_max_inactivity); if (config->dot11RSNASAERetransPeriod != DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD) fprintf(f, "dot11RSNASAERetransPeriod=%d\n", config->dot11RSNASAERetransPeriod); if (config->passive_scan) fprintf(f, "passive_scan=%d\n", config->passive_scan); if (config->reassoc_same_bss_optim) fprintf(f, "reassoc_same_bss_optim=%d\n", config->reassoc_same_bss_optim); if (config->wps_priority) fprintf(f, "wps_priority=%d\n", config->wps_priority); if (config->wpa_rsc_relaxation != DEFAULT_WPA_RSC_RELAXATION) fprintf(f, "wpa_rsc_relaxation=%d\n", config->wpa_rsc_relaxation); if (config->sched_scan_plans) fprintf(f, "sched_scan_plans=%s\n", config->sched_scan_plans); #ifdef CONFIG_MBO if (config->non_pref_chan) fprintf(f, "non_pref_chan=%s\n", config->non_pref_chan); if (config->mbo_cell_capa != DEFAULT_MBO_CELL_CAPA) fprintf(f, "mbo_cell_capa=%u\n", config->mbo_cell_capa); #endif /* CONFIG_MBO */ }
static int p2p_parse_attribute(u8 id, const u8 *data, u16 len, struct p2p_message *msg) { const u8 *pos; u16 nlen; char devtype[WPS_DEV_TYPE_BUFSIZE]; switch (id) { case P2P_ATTR_CAPABILITY: if (len < 2) { wpa_printf(MSG_DEBUG, "P2P: Too short Capability " "attribute (length %d)", len); return -1; } msg->capability = data; wpa_printf(MSG_DEBUG, "P2P: * Device Capability %02x " "Group Capability %02x", data[0], data[1]); break; case P2P_ATTR_DEVICE_ID: if (len < ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short Device ID " "attribute (length %d)", len); return -1; } msg->device_id = data; wpa_printf(MSG_DEBUG, "P2P: * Device ID " MACSTR, MAC2STR(msg->device_id)); break; case P2P_ATTR_GROUP_OWNER_INTENT: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short GO Intent " "attribute (length %d)", len); return -1; } msg->go_intent = data; wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u " "Tie breaker %u", data[0] >> 1, data[0] & 0x01); break; case P2P_ATTR_STATUS: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Status " "attribute (length %d)", len); return -1; } msg->status = data; wpa_printf(MSG_DEBUG, "P2P: * Status: %d", data[0]); break; case P2P_ATTR_LISTEN_CHANNEL: if (len == 0) { wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: Ignore " "null channel"); break; } if (len < 5) { wpa_printf(MSG_DEBUG, "P2P: Too short Listen Channel " "attribute (length %d)", len); return -1; } msg->listen_channel = data; wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: " "Country %c%c(0x%02x) Regulatory " "Class %d Channel Number %d", data[0], data[1], data[2], data[3], data[4]); break; case P2P_ATTR_OPERATING_CHANNEL: if (len == 0) { wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: " "Ignore null channel"); break; } if (len < 5) { wpa_printf(MSG_DEBUG, "P2P: Too short Operating " "Channel attribute (length %d)", len); return -1; } msg->operating_channel = data; wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: " "Country %c%c(0x%02x) Regulatory " "Class %d Channel Number %d", data[0], data[1], data[2], data[3], data[4]); break; case P2P_ATTR_CHANNEL_LIST: if (len < 3) { wpa_printf(MSG_DEBUG, "P2P: Too short Channel List " "attribute (length %d)", len); return -1; } msg->channel_list = data; msg->channel_list_len = len; wpa_printf(MSG_DEBUG, "P2P: * Channel List: Country String " "'%c%c(0x%02x)'", data[0], data[1], data[2]); wpa_hexdump(MSG_MSGDUMP, "P2P: Channel List", msg->channel_list, msg->channel_list_len); break; case P2P_ATTR_GROUP_INFO: msg->group_info = data; msg->group_info_len = len; wpa_printf(MSG_DEBUG, "P2P: * Group Info"); break; case P2P_ATTR_DEVICE_INFO: if (len < ETH_ALEN + 2 + 8 + 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Device Info " "attribute (length %d)", len); return -1; } msg->p2p_device_info = data; msg->p2p_device_info_len = len; pos = data; msg->p2p_device_addr = pos; pos += ETH_ALEN; msg->config_methods = WPA_GET_BE16(pos); pos += 2; msg->pri_dev_type = pos; pos += 8; msg->num_sec_dev_types = *pos++; if (msg->num_sec_dev_types * 8 > data + len - pos) { wpa_printf(MSG_DEBUG, "P2P: Device Info underflow"); return -1; } pos += msg->num_sec_dev_types * 8; if (data + len - pos < 4) { wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name " "length %d", (int) (data + len - pos)); return -1; } if (WPA_GET_BE16(pos) != ATTR_DEV_NAME) { wpa_hexdump(MSG_DEBUG, "P2P: Unexpected Device Name " "header", pos, 4); return -1; } pos += 2; nlen = WPA_GET_BE16(pos); pos += 2; if (nlen > data + len - pos || nlen > WPS_DEV_NAME_MAX_LEN) { wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name " "length %u (buf len %d)", nlen, (int) (data + len - pos)); return -1; } p2p_copy_filter_devname(msg->device_name, sizeof(msg->device_name), pos, nlen); wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR " primary device type %s device name '%s' " "config methods 0x%x", MAC2STR(msg->p2p_device_addr), wps_dev_type_bin2str(msg->pri_dev_type, devtype, sizeof(devtype)), msg->device_name, msg->config_methods); break; case P2P_ATTR_CONFIGURATION_TIMEOUT: if (len < 2) { wpa_printf(MSG_DEBUG, "P2P: Too short Configuration " "Timeout attribute (length %d)", len); return -1; } msg->config_timeout = data; wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout"); break; case P2P_ATTR_INTENDED_INTERFACE_ADDR: if (len < ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short Intended P2P " "Interface Address attribute (length %d)", len); return -1; } msg->intended_addr = data; wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address: " MACSTR, MAC2STR(msg->intended_addr)); break; case P2P_ATTR_GROUP_BSSID: if (len < ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short P2P Group BSSID " "attribute (length %d)", len); return -1; } msg->group_bssid = data; wpa_printf(MSG_DEBUG, "P2P: * P2P Group BSSID: " MACSTR, MAC2STR(msg->group_bssid)); break; case P2P_ATTR_GROUP_ID: if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) { wpa_printf(MSG_DEBUG, "P2P: Invalid P2P Group ID " "attribute length %d", len); return -1; } msg->group_id = data; msg->group_id_len = len; wpa_printf(MSG_DEBUG, "P2P: * P2P Group ID: Device Address " MACSTR, MAC2STR(msg->group_id)); wpa_hexdump_ascii(MSG_DEBUG, "P2P: * P2P Group ID: SSID", msg->group_id + ETH_ALEN, msg->group_id_len - ETH_ALEN); break; case P2P_ATTR_INVITATION_FLAGS: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Invitation " "Flag attribute (length %d)", len); return -1; } msg->invitation_flags = data; wpa_printf(MSG_DEBUG, "P2P: * Invitation Flags: bitmap 0x%x", data[0]); break; case P2P_ATTR_MANAGEABILITY: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Manageability " "attribute (length %d)", len); return -1; } msg->manageability = data; wpa_printf(MSG_DEBUG, "P2P: * Manageability: bitmap 0x%x", data[0]); break; case P2P_ATTR_NOTICE_OF_ABSENCE: if (len < 2) { wpa_printf(MSG_DEBUG, "P2P: Too short Notice of " "Absence attribute (length %d)", len); return -1; } msg->noa = data; msg->noa_len = len; wpa_printf(MSG_DEBUG, "P2P: * Notice of Absence"); break; case P2P_ATTR_EXT_LISTEN_TIMING: if (len < 4) { wpa_printf(MSG_DEBUG, "P2P: Too short Extended Listen " "Timing attribute (length %d)", len); return -1; } msg->ext_listen_timing = data; wpa_printf(MSG_DEBUG, "P2P: * Extended Listen Timing " "(period %u msec interval %u msec)", WPA_GET_LE16(msg->ext_listen_timing), WPA_GET_LE16(msg->ext_listen_timing + 2)); break; case P2P_ATTR_MINOR_REASON_CODE: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Minor Reason " "Code attribute (length %d)", len); return -1; } msg->minor_reason_code = data; wpa_printf(MSG_DEBUG, "P2P: * Minor Reason Code: %u", *msg->minor_reason_code); break; case P2P_ATTR_OOB_GO_NEG_CHANNEL: if (len < 6) { wpa_printf(MSG_DEBUG, "P2P: Too short OOB GO Neg " "Channel attribute (length %d)", len); return -1; } msg->oob_go_neg_channel = data; wpa_printf(MSG_DEBUG, "P2P: * OOB GO Neg Channel: " "Country %c%c(0x%02x) Operating Class %d " "Channel Number %d Role %d", data[0], data[1], data[2], data[3], data[4], data[5]); break; case P2P_ATTR_SERVICE_HASH: if (len < P2PS_HASH_LEN) { wpa_printf(MSG_DEBUG, "P2P: Too short Service Hash (length %u)", len); return -1; } msg->service_hash_count = len / P2PS_HASH_LEN; msg->service_hash = data; wpa_hexdump(MSG_DEBUG, "P2P: * Service Hash(s)", data, len); break; case P2P_ATTR_SESSION_INFORMATION_DATA: msg->session_info = data; msg->session_info_len = len; wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %u bytes - %p", len, data); break; case P2P_ATTR_CONNECTION_CAPABILITY: if (len < 1) { wpa_printf(MSG_DEBUG, "P2P: Too short Connection Capability (length %u)", len); return -1; } msg->conn_cap = data; wpa_printf(MSG_DEBUG, "P2P: * Connection Capability: 0x%x", *msg->conn_cap); break; case P2P_ATTR_ADVERTISEMENT_ID: if (len < 10) { wpa_printf(MSG_DEBUG, "P2P: Too short Advertisement ID (length %u)", len); return -1; } msg->adv_id = data; msg->adv_mac = &data[sizeof(u32)]; wpa_printf(MSG_DEBUG, "P2P: * Advertisement ID %x", WPA_GET_LE32(data)); break; case P2P_ATTR_ADVERTISED_SERVICE: if (len < 8) { wpa_printf(MSG_DEBUG, "P2P: Too short Service Instance (length %u)", len); return -1; } msg->adv_service_instance = data; msg->adv_service_instance_len = len; if (len <= 255 + 8) { char str[256]; u8 namelen; namelen = data[6]; if (namelen > len - 7) break; os_memcpy(str, &data[7], namelen); str[namelen] = '\0'; wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %x-%s", WPA_GET_LE32(data), str); } else { wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %p", data); } break; case P2P_ATTR_SESSION_ID: if (len < sizeof(u32) + ETH_ALEN) { wpa_printf(MSG_DEBUG, "P2P: Too short Session ID Info (length %u)", len); return -1; } msg->session_id = data; msg->session_mac = &data[sizeof(u32)]; wpa_printf(MSG_DEBUG, "P2P: * Session ID: %x " MACSTR, WPA_GET_LE32(data), MAC2STR(msg->session_mac)); break; case P2P_ATTR_FEATURE_CAPABILITY: if (!len) { wpa_printf(MSG_DEBUG, "P2P: Too short Feature Capability (length %u)", len); return -1; } msg->feature_cap = data; msg->feature_cap_len = len; wpa_printf(MSG_DEBUG, "P2P: * Feature Cap (length=%u)", len); break; case P2P_ATTR_PERSISTENT_GROUP: { if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) { wpa_printf(MSG_DEBUG, "P2P: Invalid Persistent Group Info (length %u)", len); return -1; } msg->persistent_dev = data; msg->persistent_ssid_len = len - ETH_ALEN; msg->persistent_ssid = &data[ETH_ALEN]; wpa_printf(MSG_DEBUG, "P2P: * Persistent Group: " MACSTR " %s", MAC2STR(msg->persistent_dev), wpa_ssid_txt(msg->persistent_ssid, msg->persistent_ssid_len)); break; } default: wpa_printf(MSG_DEBUG, "P2P: Skipped unknown attribute %d " "(length %d)", id, len); break; } return 0; }