From b93c8509cc4e748d441676f59577e346cea5db29 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 16 Dec 2012 20:46:51 +0200 Subject: [PATCH] Add support for advertising UTF-8 SSID extended capability This field can be used to indicate that UTF-8 encoding is used in the SSID field. Signed-hostap: Jouni Malinen --- hostapd/config_file.c | 2 ++ hostapd/hostapd.conf | 3 +++ src/ap/ap_config.h | 3 ++- src/ap/ieee802_11_shared.c | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 70a114db6..1b5c730ae 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -1780,6 +1780,8 @@ static int hostapd_config_fill(struct hostapd_config *conf, bss->ssid.ssid_set = 1; } os_free(str); + } else if (os_strcmp(buf, "utf8_ssid") == 0) { + bss->ssid.utf8_ssid = atoi(pos) > 0; } else if (os_strcmp(buf, "macaddr_acl") == 0) { bss->macaddr_acl = atoi(pos); if (bss->macaddr_acl != ACCEPT_UNLESS_DENIED && diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index ad81f06e3..58717acba 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -90,6 +90,9 @@ ssid=test #ssid2=74657374 #ssid2=P"hello\nthere" +# UTF-8 SSID: Whether the SSID is to be interpreted using UTF-8 encoding +#utf8_ssid=1 + # Country code (ISO/IEC 3166-1). Used to set regulatory domain. # Set as needed to indicate country in which device is operating. # This can limit available channels and transmit power. diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index ec6db3a6e..bc04307dd 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -51,7 +51,8 @@ typedef enum hostap_security_policy { struct hostapd_ssid { u8 ssid[HOSTAPD_MAX_SSID_LEN]; size_t ssid_len; - int ssid_set; + unsigned int ssid_set:1; + unsigned int utf8_ssid:1; char vlan[IFNAMSIZ + 1]; secpolicy security_policy; diff --git a/src/ap/ieee802_11_shared.c b/src/ap/ieee802_11_shared.c index 9d07d6516..72c127616 100644 --- a/src/ap/ieee802_11_shared.c +++ b/src/ap/ieee802_11_shared.c @@ -175,6 +175,8 @@ u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid) len = 4; if (len < 3 && hapd->conf->wnm_sleep_mode) len = 3; + if (len < 7 && hapd->conf->ssid.utf8_ssid) + len = 7; if (len == 0) return eid; @@ -206,6 +208,18 @@ u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid) *pos |= 0x80; /* Bit 39 - TDLS Channel Switching Prohibited */ pos++; + if (len < 6) + return pos; + *pos = 0x00; + pos++; + + if (len < 7) + return pos; + *pos = 0x00; + if (hapd->conf->ssid.utf8_ssid) + *pos |= 0x01; /* Bit 48 - UTF-8 SSID */ + pos++; + return pos; }