}
-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;
+ return -1;
- vn = os_realloc_array(bss->venue_name, bss->venue_name_count + 1,
- sizeof(struct hostapd_venue_name));
- if (vn == NULL)
+ ls = os_realloc_array(*array, *count + 1,
+ sizeof(struct hostapd_lang_string));
+ if (ls == NULL)
return -1;
- bss->venue_name = vn;
- vn = &bss->venue_name[bss->venue_name_count];
- bss->venue_name_count++;
+ *array = ls;
+ ls = &(*array)[*count];
+ (*count)++;
- os_memset(vn->lang, 0, sizeof(vn->lang));
- os_memcpy(vn->lang, pos, clen);
- vn->name_len = nlen;
- os_memcpy(vn->name, sep, nlen);
+ 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;
}
u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
};
-struct hostapd_venue_name {
+struct hostapd_lang_string {
u8 lang[3];
u8 name_len;
u8 name[252];
/* 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;
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);