P2P: Add global configuration parameters for P2P

This commit is contained in:
Jouni Malinen 2010-07-18 14:30:24 -07:00 committed by Jouni Malinen
parent 2c5d725c65
commit e3768e7c94
4 changed files with 85 additions and 0 deletions

View file

@ -1688,6 +1688,8 @@ void wpa_config_free(struct wpa_config *config)
struct wpa_config_blob *blob, *prevblob;
#endif /* CONFIG_NO_CONFIG_BLOBS */
struct wpa_ssid *ssid, *prev = NULL;
int i;
ssid = config->ssid;
while (ssid) {
prev = ssid;
@ -1717,7 +1719,10 @@ void wpa_config_free(struct wpa_config *config)
os_free(config->model_number);
os_free(config->serial_number);
os_free(config->device_type);
for (i = 0; i < MAX_SEC_DEVICE_TYPES; i++)
os_free(config->sec_device_type[i]);
os_free(config->config_methods);
os_free(config->p2p_ssid_postfix);
os_free(config->pssid);
os_free(config);
}
@ -2132,6 +2137,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
config->eapol_version = DEFAULT_EAPOL_VERSION;
config->ap_scan = DEFAULT_AP_SCAN;
config->fast_reauth = DEFAULT_FAST_REAUTH;
config->p2p_go_intent = DEFAULT_P2P_GO_INTENT;
config->bss_max_count = DEFAULT_BSS_MAX_COUNT;
if (ctrl_interface)
@ -2309,6 +2315,29 @@ static int wpa_config_process_os_version(const struct global_parse_data *data,
#endif /* CONFIG_WPS */
#ifdef CONFIG_P2P
static int wpa_config_process_sec_device_type(
const struct global_parse_data *data,
struct wpa_config *config, int line, const char *pos)
{
int idx;
for (idx = 0; idx < MAX_SEC_DEVICE_TYPES; idx++)
if (config->sec_device_type[idx] == NULL)
break;
if (idx == MAX_SEC_DEVICE_TYPES) {
wpa_printf(MSG_ERROR, "Line %d: too many sec_device_type "
"items", line);
return -1;
}
config->sec_device_type[idx] = os_strdup(pos);
if (config->sec_device_type[idx] == NULL)
return -1;
return 0;
}
#endif /* CONFIG_P2P */
#ifdef OFFSET
#undef OFFSET
@ -2356,6 +2385,16 @@ static const struct global_parse_data global_fields[] = {
{ STR(config_methods), CFG_CHANGED_CONFIG_METHODS },
{ INT_RANGE(wps_cred_processing, 0, 2), 0 },
#endif /* CONFIG_WPS */
#ifdef CONFIG_P2P
{ FUNC(sec_device_type), CFG_CHANGED_SEC_DEVICE_TYPE },
{ INT(p2p_listen_reg_class), 0 },
{ INT(p2p_listen_channel), 0 },
{ INT(p2p_oper_reg_class), 0 },
{ INT(p2p_oper_channel), 0 },
{ INT_RANGE(p2p_go_intent, 0, 15), 0 },
{ STR(p2p_ssid_postfix), CFG_CHANGED_P2P_SSID_POSTFIX },
{ INT_RANGE(persistent_reconnect, 0, 1), 0 },
#endif /* CONFIG_P2P */
{ FUNC(country), CFG_CHANGED_COUNTRY },
{ INT(bss_max_count), 0 },
{ INT_RANGE(filter_ssids, 0, 1), 0 }

View file

@ -22,6 +22,7 @@
#define DEFAULT_AP_SCAN 1
#endif /* CONFIG_NO_SCAN_PROCESSING */
#define DEFAULT_FAST_REAUTH 1
#define DEFAULT_P2P_GO_INTENT 7
#define DEFAULT_BSS_MAX_COUNT 200
#include "config_ssid.h"
@ -33,6 +34,8 @@
#define CFG_CHANGED_OS_VERSION BIT(3)
#define CFG_CHANGED_UUID BIT(4)
#define CFG_CHANGED_COUNTRY BIT(5)
#define CFG_CHANGED_SEC_DEVICE_TYPE BIT(6)
#define CFG_CHANGED_P2P_SSID_POSTFIX BIT(7)
/**
* struct wpa_config - wpa_supplicant configuration data
@ -343,6 +346,21 @@ struct wpa_config {
*/
int wps_cred_processing;
#define MAX_SEC_DEVICE_TYPES 5
/**
* sec_device_type - Secondary Device Types (P2P)
* See device_type for the format used with these.
*/
char *sec_device_type[MAX_SEC_DEVICE_TYPES];
int p2p_listen_reg_class;
int p2p_listen_channel;
int p2p_oper_reg_class;
int p2p_oper_channel;
int p2p_go_intent;
char *p2p_ssid_postfix;
int persistent_reconnect;
/**
* bss_max_count - Maximum number of BSS entries to keep in memory
*/

View file

@ -654,6 +654,26 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
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);
#endif /* CONFIG_P2P */
if (config->country[0] && config->country[1]) {
fprintf(f, "country=%c%c\n",
config->country[0], config->country[1]);

View file

@ -256,6 +256,10 @@ static int wpa_config_read_global(struct wpa_config *config, HKEY hk)
wpa_config_read_reg_dword(hk, TEXT("wps_cred_processing"),
&config->wps_cred_processing);
#endif /* CONFIG_WPS */
#ifdef CONFIG_P2P
config->p2p_ssid_postfix = wpa_config_read_reg_string(
hk, TEXT("p2p_ssid_postfix"));
#endif /* CONFIG_P2P */
wpa_config_read_reg_dword(hk, TEXT("bss_max_count"),
(int *) &config->bss_max_count);
@ -587,6 +591,10 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk)
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);
#endif /* CONFIG_P2P */
wpa_config_write_reg_dword(hk, TEXT("bss_max_count"),
config->bss_max_count,