Interworking: Use generic language,string parser
Replace the Venue Name specific data structure and parser with a generic mechanism that can be used with other fields that use the same format. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
4065a3092b
commit
1792e58dbb
3 changed files with 31 additions and 24 deletions
|
@ -1289,45 +1289,52 @@ static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
|
|||
}
|
||||
|
||||
|
||||
static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
|
||||
int line)
|
||||
static int parse_lang_string(struct hostapd_lang_string **array,
|
||||
unsigned int *count, char *pos)
|
||||
{
|
||||
char *sep;
|
||||
size_t clen, nlen;
|
||||
struct hostapd_venue_name *vn;
|
||||
struct hostapd_lang_string *ls;
|
||||
|
||||
sep = os_strchr(pos, ':');
|
||||
if (sep == NULL)
|
||||
goto fail;
|
||||
return -1;
|
||||
*sep++ = '\0';
|
||||
|
||||
clen = os_strlen(pos);
|
||||
if (clen < 2)
|
||||
goto fail;
|
||||
return -1;
|
||||
nlen = os_strlen(sep);
|
||||
if (nlen > 252)
|
||||
goto fail;
|
||||
|
||||
vn = os_realloc_array(bss->venue_name, bss->venue_name_count + 1,
|
||||
sizeof(struct hostapd_venue_name));
|
||||
if (vn == NULL)
|
||||
return -1;
|
||||
|
||||
bss->venue_name = vn;
|
||||
vn = &bss->venue_name[bss->venue_name_count];
|
||||
bss->venue_name_count++;
|
||||
ls = os_realloc_array(*array, *count + 1,
|
||||
sizeof(struct hostapd_lang_string));
|
||||
if (ls == NULL)
|
||||
return -1;
|
||||
|
||||
os_memset(vn->lang, 0, sizeof(vn->lang));
|
||||
os_memcpy(vn->lang, pos, clen);
|
||||
vn->name_len = nlen;
|
||||
os_memcpy(vn->name, sep, nlen);
|
||||
*array = ls;
|
||||
ls = &(*array)[*count];
|
||||
(*count)++;
|
||||
|
||||
os_memset(ls->lang, 0, sizeof(ls->lang));
|
||||
os_memcpy(ls->lang, pos, clen);
|
||||
ls->name_len = nlen;
|
||||
os_memcpy(ls->name, sep, nlen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fail:
|
||||
wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'",
|
||||
line, pos);
|
||||
return -1;
|
||||
|
||||
static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
|
||||
int line)
|
||||
{
|
||||
if (parse_lang_string(&bss->venue_name, &bss->venue_name_count, pos)) {
|
||||
wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'",
|
||||
line, pos);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ struct hostapd_roaming_consortium {
|
|||
u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
|
||||
};
|
||||
|
||||
struct hostapd_venue_name {
|
||||
struct hostapd_lang_string {
|
||||
u8 lang[3];
|
||||
u8 name_len;
|
||||
u8 name[252];
|
||||
|
@ -386,7 +386,7 @@ struct hostapd_bss_config {
|
|||
|
||||
/* IEEE 802.11u - Venue Name duples */
|
||||
unsigned int venue_name_count;
|
||||
struct hostapd_venue_name *venue_name;
|
||||
struct hostapd_lang_string *venue_name;
|
||||
|
||||
/* IEEE 802.11u - Network Authentication Type */
|
||||
u8 *network_auth_type;
|
||||
|
|
|
@ -182,7 +182,7 @@ static void anqp_add_venue_name(struct hostapd_data *hapd, struct wpabuf *buf)
|
|||
wpabuf_put_u8(buf, hapd->conf->venue_group);
|
||||
wpabuf_put_u8(buf, hapd->conf->venue_type);
|
||||
for (i = 0; i < hapd->conf->venue_name_count; i++) {
|
||||
struct hostapd_venue_name *vn;
|
||||
struct hostapd_lang_string *vn;
|
||||
vn = &hapd->conf->venue_name[i];
|
||||
wpabuf_put_u8(buf, 3 + vn->name_len);
|
||||
wpabuf_put_data(buf, vn->lang, 3);
|
||||
|
|
Loading…
Reference in a new issue