P2P: Use a single define for max number of vendor extensions

This commit is contained in:
Jouni Malinen 2011-03-19 12:20:10 +02:00
parent 6f2c060711
commit 10c5d2a593
5 changed files with 14 additions and 17 deletions

View File

@ -523,12 +523,12 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
msg.wps_sec_dev_type_list_len;
}
for (i = 0; i < P2P_MAX_PEER_WPS_VENDOR_EXT; i++) {
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
wpabuf_free(dev->info.wps_vendor_ext[i]);
dev->info.wps_vendor_ext[i] = NULL;
}
for (i = 0; i < P2P_MAX_PEER_WPS_VENDOR_EXT; i++) {
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
if (msg.wps_vendor_ext[i] == NULL)
break;
dev->info.wps_vendor_ext[i] = wpabuf_alloc_copy(
@ -590,7 +590,7 @@ static void p2p_device_free(struct p2p_data *p2p, struct p2p_device *dev)
p2p->cfg->dev_lost(p2p->cfg->cb_ctx, dev->info.p2p_device_addr);
for (i = 0; i < P2P_MAX_PEER_WPS_VENDOR_EXT; i++) {
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
wpabuf_free(dev->info.wps_vendor_ext[i]);
dev->info.wps_vendor_ext[i] = NULL;
}
@ -2046,7 +2046,7 @@ void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p)
{
int i;
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXTENSIONS; i++) {
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
wpabuf_free(p2p->wps_vendor_ext[i]);
p2p->wps_vendor_ext[i] = NULL;
}
@ -2061,11 +2061,11 @@ int p2p_add_wps_vendor_extension(struct p2p_data *p2p,
if (vendor_ext == NULL)
return -1;
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXTENSIONS; i++) {
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
if (p2p->wps_vendor_ext[i] == NULL)
break;
}
if (i >= P2P_MAX_WPS_VENDOR_EXTENSIONS)
if (i >= P2P_MAX_WPS_VENDOR_EXT)
return -1;
p2p->wps_vendor_ext[i] = wpabuf_dup(vendor_ext);

View File

@ -138,9 +138,10 @@ enum p2p_scan_type {
P2P_SCAN_SOCIAL_PLUS_ONE
};
#define P2P_MAX_WPS_VENDOR_EXT 10
/**
* struct p2p_peer_info - P2P peer information
*/
struct p2p_peer_info {
/**
@ -186,8 +187,7 @@ struct p2p_peer_info {
*/
size_t wps_sec_dev_type_list_len;
#define P2P_MAX_PEER_WPS_VENDOR_EXT 10
struct wpabuf *wps_vendor_ext[P2P_MAX_PEER_WPS_VENDOR_EXT];
struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
};
/**

View File

@ -397,7 +397,7 @@ void p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, u16 pw_id,
}
/* Add the WPS vendor extensions */
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXTENSIONS; i++) {
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
if (p2p->wps_vendor_ext[i] == NULL)
break;
if (wpabuf_tailroom(buf) <

View File

@ -385,11 +385,10 @@ struct p2p_data {
int best_freq_5;
int best_freq_overall;
#define P2P_MAX_WPS_VENDOR_EXTENSIONS 10
/**
* wps_vendor_ext - WPS Vendor Extensions to add
*/
struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXTENSIONS];
struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
};
/**
@ -445,8 +444,8 @@ struct p2p_message {
const u8 *wps_pri_dev_type;
const u8 *wps_sec_dev_type_list;
size_t wps_sec_dev_type_list_len;
const u8 *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXTENSIONS];
size_t wps_vendor_ext_len[P2P_MAX_WPS_VENDOR_EXTENSIONS];
const u8 *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
size_t wps_vendor_ext_len[P2P_MAX_WPS_VENDOR_EXT];
/* DS Parameter Set IE */
const u8 *ds_params;

View File

@ -359,9 +359,7 @@ static int p2p_parse_wps_ie(const struct wpabuf *buf, struct p2p_message *msg)
msg->wps_sec_dev_type_list_len = attr.sec_dev_type_list_len;
}
for (i = 0; i < P2P_MAX_PEER_WPS_VENDOR_EXT; i++) {
if (i >= P2P_MAX_WPS_VENDOR_EXTENSIONS)
break;
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];
}