From: Jouni Malinen Date: Thu, 9 Aug 2012 19:20:45 +0000 (+0300) Subject: AOSP: unicode X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8451227fa47a6d743c54b66f568442ba942c270d;p=thirdparty%2Fhostap.git AOSP: unicode --- diff --git a/src/utils/common.c b/src/utils/common.c index 99861aeba..26fea1bfc 100644 --- a/src/utils/common.c +++ b/src/utils/common.c @@ -368,8 +368,10 @@ const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len) os_memcpy(ssid_txt, ssid, ssid_len); ssid_txt[ssid_len] = '\0'; for (pos = ssid_txt; *pos != '\0'; pos++) { +#ifndef WPA_UNICODE_SSID if ((u8) *pos < 32 || (u8) *pos >= 127) *pos = '_'; +#endif } return ssid_txt; } diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index a7c178480..f6e08023d 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -218,6 +218,26 @@ static char * wpa_config_write_str(const struct parse_data *data, return wpa_config_write_string((const u8 *) *src, len); } + +#ifdef WPA_UNICODE_SSID +static char * wpa_config_write_str_unicode(const struct parse_data *data, + struct wpa_ssid *ssid) +{ + size_t len; + char **src; + + src = (char **) (((u8 *) ssid) + (long) data->param1); + if (*src == NULL) + return NULL; + + if (data->param2) + len = *((size_t *) (((u8 *) ssid) + (long) data->param2)); + else + len = os_strlen(*src); + + return wpa_config_write_string_ascii((const u8 *) *src, len); +} +#endif #endif /* NO_CONFIG_WRITE */ @@ -1473,6 +1493,15 @@ static char * wpa_config_write_p2p_client_list(const struct parse_data *data, OFFSET(f), (void *) 0 #define _INTe(f) #f, wpa_config_parse_int, wpa_config_write_int, \ OFFSET(eap.f), (void *) 0 +#ifdef WPA_UNICODE_SSID +/* STR_* variants that do not force conversion to ASCII */ +#define _STR_UNICODE(f) #f, wpa_config_parse_str, wpa_config_write_str_unicode, OFFSET(f) +#define STR_UNICODE(f) _STR_UNICODE(f), NULL, NULL, NULL, 0 +#define _STR_LEN_UNICODE(f) _STR_UNICODE(f), OFFSET(f ## _len) +#define STR_LEN_UNICODE(f) _STR_LEN_UNICODE(f), NULL, NULL, 0 +#define _STR_RANGE_UNICODE(f, min, max) _STR_LEN_UNICODE(f), (void *) (min), (void *) (max) +#define STR_RANGE_UNICODE(f, min, max) _STR_RANGE_UNICODE(f, min, max), 0 +#endif #endif /* NO_CONFIG_WRITE */ /* INT: Define an integer variable */ @@ -1517,7 +1546,11 @@ static char * wpa_config_write_p2p_client_list(const struct parse_data *data, * functions. */ static const struct parse_data ssid_fields[] = { +#ifdef WPA_UNICODE_SSID + { STR_RANGE_UNICODE(ssid, 0, MAX_SSID_LEN) }, +#else { STR_RANGE(ssid, 0, MAX_SSID_LEN) }, +#endif { INT_RANGE(scan_ssid, 0, 1) }, { FUNC(bssid) }, { FUNC_KEY(psk) }, @@ -1602,6 +1635,15 @@ static const struct parse_data ssid_fields[] = { #endif /* CONFIG_HT_OVERRIDES */ }; +#ifdef WPA_UNICODE_SSID +#undef _STR_UNICODE +#undef STR_UNICODE +#undef _STR_LEN_UNICODE +#undef STR_LEN_UNICODE +#undef _STR_RANGE_UNICODE +#undef STR_RANGE_UNICODE +#endif + #undef OFFSET #undef _STR #undef STR