2 * WPA Supplicant / Configuration parser and common functions
3 * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
20 #include "eap_peer/eap.h"
24 #if !defined(CONFIG_CTRL_IFACE) && defined(CONFIG_NO_CONFIG_WRITE)
25 #define NO_CONFIG_WRITE
29 * Structure for network configuration parsing. This data is used to implement
30 * a generic parser for each network block variable. The table of configuration
31 * variables is defined below in this file (ssid_fields[]).
34 /* Configuration variable name */
37 /* Parser function for this variable */
38 int (*parser)(const struct parse_data *data, struct wpa_ssid *ssid,
39 int line, const char *value);
41 #ifndef NO_CONFIG_WRITE
42 /* Writer function (i.e., to get the variable in text format from
43 * internal presentation). */
44 char * (*writer)(const struct parse_data *data, struct wpa_ssid *ssid);
45 #endif /* NO_CONFIG_WRITE */
47 /* Variable specific parameters for the parser. */
48 void *param1, *param2, *param3, *param4;
50 /* 0 = this variable can be included in debug output and ctrl_iface
51 * 1 = this variable contains key/private data and it must not be
52 * included in debug output unless explicitly requested. In
53 * addition, this variable will not be readable through the
60 static char * wpa_config_parse_string(const char *value, size_t *len)
65 pos = os_strrchr(value, '"');
66 if (pos == NULL || pos[1] != '\0')
69 *len = os_strlen(value);
70 return os_strdup(value);
73 size_t tlen, hlen = os_strlen(value);
77 str = os_malloc(tlen + 1);
80 if (hexstr2bin(value, str, tlen)) {
91 static int wpa_config_parse_str(const struct parse_data *data,
92 struct wpa_ssid *ssid,
93 int line, const char *value)
95 size_t res_len, *dst_len;
98 tmp = wpa_config_parse_string(value, &res_len);
100 wpa_printf(MSG_ERROR, "Line %d: failed to parse %s '%s'.",
102 data->key_data ? "[KEY DATA REMOVED]" : value);
106 if (data->key_data) {
107 wpa_hexdump_ascii_key(MSG_MSGDUMP, data->name,
108 (u8 *) tmp, res_len);
110 wpa_hexdump_ascii(MSG_MSGDUMP, data->name,
111 (u8 *) tmp, res_len);
114 if (data->param3 && res_len < (size_t) data->param3) {
115 wpa_printf(MSG_ERROR, "Line %d: too short %s (len=%lu "
116 "min_len=%ld)", line, data->name,
117 (unsigned long) res_len, (long) data->param3);
122 if (data->param4 && res_len > (size_t) data->param4) {
123 wpa_printf(MSG_ERROR, "Line %d: too long %s (len=%lu "
124 "max_len=%ld)", line, data->name,
125 (unsigned long) res_len, (long) data->param4);
130 dst = (char **) (((u8 *) ssid) + (long) data->param1);
131 dst_len = (size_t *) (((u8 *) ssid) + (long) data->param2);
141 #ifndef NO_CONFIG_WRITE
142 static int is_hex(const u8 *data, size_t len)
146 for (i = 0; i < len; i++) {
147 if (data[i] < 32 || data[i] >= 127)
154 static char * wpa_config_write_string_ascii(const u8 *value, size_t len)
158 buf = os_malloc(len + 3);
162 os_memcpy(buf + 1, value, len);
170 static char * wpa_config_write_string_hex(const u8 *value, size_t len)
174 buf = os_zalloc(2 * len + 1);
177 wpa_snprintf_hex(buf, 2 * len + 1, value, len);
183 static char * wpa_config_write_string(const u8 *value, size_t len)
188 if (is_hex(value, len))
189 return wpa_config_write_string_hex(value, len);
191 return wpa_config_write_string_ascii(value, len);
195 static char * wpa_config_write_str(const struct parse_data *data,
196 struct wpa_ssid *ssid)
201 src = (char **) (((u8 *) ssid) + (long) data->param1);
206 len = *((size_t *) (((u8 *) ssid) + (long) data->param2));
208 len = os_strlen(*src);
210 return wpa_config_write_string((const u8 *) *src, len);
212 #endif /* NO_CONFIG_WRITE */
215 static int wpa_config_parse_int(const struct parse_data *data,
216 struct wpa_ssid *ssid,
217 int line, const char *value)
221 dst = (int *) (((u8 *) ssid) + (long) data->param1);
223 wpa_printf(MSG_MSGDUMP, "%s=%d (0x%x)", data->name, *dst, *dst);
225 if (data->param3 && *dst < (long) data->param3) {
226 wpa_printf(MSG_ERROR, "Line %d: too small %s (value=%d "
227 "min_value=%ld)", line, data->name, *dst,
228 (long) data->param3);
229 *dst = (long) data->param3;
233 if (data->param4 && *dst > (long) data->param4) {
234 wpa_printf(MSG_ERROR, "Line %d: too large %s (value=%d "
235 "max_value=%ld)", line, data->name, *dst,
236 (long) data->param4);
237 *dst = (long) data->param4;
245 #ifndef NO_CONFIG_WRITE
246 static char * wpa_config_write_int(const struct parse_data *data,
247 struct wpa_ssid *ssid)
252 src = (int *) (((u8 *) ssid) + (long) data->param1);
254 value = os_malloc(20);
257 res = os_snprintf(value, 20, "%d", *src);
258 if (res < 0 || res >= 20) {
262 value[20 - 1] = '\0';
265 #endif /* NO_CONFIG_WRITE */
268 static int wpa_config_parse_bssid(const struct parse_data *data,
269 struct wpa_ssid *ssid, int line,
272 if (hwaddr_aton(value, ssid->bssid)) {
273 wpa_printf(MSG_ERROR, "Line %d: Invalid BSSID '%s'.",
278 wpa_hexdump(MSG_MSGDUMP, "BSSID", ssid->bssid, ETH_ALEN);
283 #ifndef NO_CONFIG_WRITE
284 static char * wpa_config_write_bssid(const struct parse_data *data,
285 struct wpa_ssid *ssid)
290 if (!ssid->bssid_set)
293 value = os_malloc(20);
296 res = os_snprintf(value, 20, MACSTR, MAC2STR(ssid->bssid));
297 if (res < 0 || res >= 20) {
301 value[20 - 1] = '\0';
304 #endif /* NO_CONFIG_WRITE */
307 static int wpa_config_parse_psk(const struct parse_data *data,
308 struct wpa_ssid *ssid, int line,
312 #ifndef CONFIG_NO_PBKDF2
317 pos = os_strrchr(value, '"');
321 len = os_strlen(value);
322 if (len < 8 || len > 63) {
323 wpa_printf(MSG_ERROR, "Line %d: Invalid passphrase "
324 "length %lu (expected: 8..63) '%s'.",
325 line, (unsigned long) len, value);
328 wpa_hexdump_ascii_key(MSG_MSGDUMP, "PSK (ASCII passphrase)",
330 if (ssid->passphrase && os_strlen(ssid->passphrase) == len &&
331 os_memcmp(ssid->passphrase, value, len) == 0)
334 os_free(ssid->passphrase);
335 ssid->passphrase = os_malloc(len + 1);
336 if (ssid->passphrase == NULL)
338 os_memcpy(ssid->passphrase, value, len);
339 ssid->passphrase[len] = '\0';
341 #else /* CONFIG_NO_PBKDF2 */
342 wpa_printf(MSG_ERROR, "Line %d: ASCII passphrase not "
345 #endif /* CONFIG_NO_PBKDF2 */
348 if (hexstr2bin(value, ssid->psk, PMK_LEN) ||
349 value[PMK_LEN * 2] != '\0') {
350 wpa_printf(MSG_ERROR, "Line %d: Invalid PSK '%s'.",
355 os_free(ssid->passphrase);
356 ssid->passphrase = NULL;
359 wpa_hexdump_key(MSG_MSGDUMP, "PSK", ssid->psk, PMK_LEN);
364 #ifndef NO_CONFIG_WRITE
365 static char * wpa_config_write_psk(const struct parse_data *data,
366 struct wpa_ssid *ssid)
368 if (ssid->passphrase)
369 return wpa_config_write_string_ascii(
370 (const u8 *) ssid->passphrase,
371 os_strlen(ssid->passphrase));
374 return wpa_config_write_string_hex(ssid->psk, PMK_LEN);
378 #endif /* NO_CONFIG_WRITE */
381 static int wpa_config_parse_proto(const struct parse_data *data,
382 struct wpa_ssid *ssid, int line,
385 int val = 0, last, errors = 0;
386 char *start, *end, *buf;
388 buf = os_strdup(value);
393 while (*start != '\0') {
394 while (*start == ' ' || *start == '\t')
399 while (*end != ' ' && *end != '\t' && *end != '\0')
403 if (os_strcmp(start, "WPA") == 0)
404 val |= WPA_PROTO_WPA;
405 else if (os_strcmp(start, "RSN") == 0 ||
406 os_strcmp(start, "WPA2") == 0)
407 val |= WPA_PROTO_RSN;
409 wpa_printf(MSG_ERROR, "Line %d: invalid proto '%s'",
421 wpa_printf(MSG_ERROR,
422 "Line %d: no proto values configured.", line);
426 wpa_printf(MSG_MSGDUMP, "proto: 0x%x", val);
428 return errors ? -1 : 0;
432 #ifndef NO_CONFIG_WRITE
433 static char * wpa_config_write_proto(const struct parse_data *data,
434 struct wpa_ssid *ssid)
437 char *buf, *pos, *end;
439 pos = buf = os_zalloc(10);
444 if (ssid->proto & WPA_PROTO_WPA) {
445 ret = os_snprintf(pos, end - pos, "%sWPA", first ? "" : " ");
446 if (ret < 0 || ret >= end - pos)
452 if (ssid->proto & WPA_PROTO_RSN) {
453 ret = os_snprintf(pos, end - pos, "%sRSN", first ? "" : " ");
454 if (ret < 0 || ret >= end - pos)
462 #endif /* NO_CONFIG_WRITE */
465 static int wpa_config_parse_key_mgmt(const struct parse_data *data,
466 struct wpa_ssid *ssid, int line,
469 int val = 0, last, errors = 0;
470 char *start, *end, *buf;
472 buf = os_strdup(value);
477 while (*start != '\0') {
478 while (*start == ' ' || *start == '\t')
483 while (*end != ' ' && *end != '\t' && *end != '\0')
487 if (os_strcmp(start, "WPA-PSK") == 0)
488 val |= WPA_KEY_MGMT_PSK;
489 else if (os_strcmp(start, "WPA-EAP") == 0)
490 val |= WPA_KEY_MGMT_IEEE8021X;
491 else if (os_strcmp(start, "IEEE8021X") == 0)
492 val |= WPA_KEY_MGMT_IEEE8021X_NO_WPA;
493 else if (os_strcmp(start, "NONE") == 0)
494 val |= WPA_KEY_MGMT_NONE;
495 else if (os_strcmp(start, "WPA-NONE") == 0)
496 val |= WPA_KEY_MGMT_WPA_NONE;
497 #ifdef CONFIG_IEEE80211R
498 else if (os_strcmp(start, "FT-PSK") == 0)
499 val |= WPA_KEY_MGMT_FT_PSK;
500 else if (os_strcmp(start, "FT-EAP") == 0)
501 val |= WPA_KEY_MGMT_FT_IEEE8021X;
502 #endif /* CONFIG_IEEE80211R */
503 #ifdef CONFIG_IEEE80211W
504 else if (os_strcmp(start, "WPA-PSK-SHA256") == 0)
505 val |= WPA_KEY_MGMT_PSK_SHA256;
506 else if (os_strcmp(start, "WPA-EAP-SHA256") == 0)
507 val |= WPA_KEY_MGMT_IEEE8021X_SHA256;
508 #endif /* CONFIG_IEEE80211W */
510 wpa_printf(MSG_ERROR, "Line %d: invalid key_mgmt '%s'",
522 wpa_printf(MSG_ERROR,
523 "Line %d: no key_mgmt values configured.", line);
527 wpa_printf(MSG_MSGDUMP, "key_mgmt: 0x%x", val);
528 ssid->key_mgmt = val;
529 return errors ? -1 : 0;
533 #ifndef NO_CONFIG_WRITE
534 static char * wpa_config_write_key_mgmt(const struct parse_data *data,
535 struct wpa_ssid *ssid)
537 char *buf, *pos, *end;
540 pos = buf = os_zalloc(50);
545 if (ssid->key_mgmt & WPA_KEY_MGMT_PSK) {
546 ret = os_snprintf(pos, end - pos, "%sWPA-PSK",
547 pos == buf ? "" : " ");
548 if (ret < 0 || ret >= end - pos) {
555 if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
556 ret = os_snprintf(pos, end - pos, "%sWPA-EAP",
557 pos == buf ? "" : " ");
558 if (ret < 0 || ret >= end - pos) {
565 if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
566 ret = os_snprintf(pos, end - pos, "%sIEEE8021X",
567 pos == buf ? "" : " ");
568 if (ret < 0 || ret >= end - pos) {
575 if (ssid->key_mgmt & WPA_KEY_MGMT_NONE) {
576 ret = os_snprintf(pos, end - pos, "%sNONE",
577 pos == buf ? "" : " ");
578 if (ret < 0 || ret >= end - pos) {
585 if (ssid->key_mgmt & WPA_KEY_MGMT_WPA_NONE) {
586 ret = os_snprintf(pos, end - pos, "%sWPA-NONE",
587 pos == buf ? "" : " ");
588 if (ret < 0 || ret >= end - pos) {
595 #ifdef CONFIG_IEEE80211R
596 if (ssid->key_mgmt & WPA_KEY_MGMT_FT_PSK)
597 pos += os_snprintf(pos, end - pos, "%sFT-PSK",
598 pos == buf ? "" : " ");
600 if (ssid->key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X)
601 pos += os_snprintf(pos, end - pos, "%sFT-EAP",
602 pos == buf ? "" : " ");
603 #endif /* CONFIG_IEEE80211R */
605 #ifdef CONFIG_IEEE80211W
606 if (ssid->key_mgmt & WPA_KEY_MGMT_PSK_SHA256)
607 pos += os_snprintf(pos, end - pos, "%sWPA-PSK-SHA256",
608 pos == buf ? "" : " ");
610 if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256)
611 pos += os_snprintf(pos, end - pos, "%sWPA-EAP-SHA256",
612 pos == buf ? "" : " ");
613 #endif /* CONFIG_IEEE80211W */
617 #endif /* NO_CONFIG_WRITE */
620 static int wpa_config_parse_cipher(int line, const char *value)
623 char *start, *end, *buf;
625 buf = os_strdup(value);
630 while (*start != '\0') {
631 while (*start == ' ' || *start == '\t')
636 while (*end != ' ' && *end != '\t' && *end != '\0')
640 if (os_strcmp(start, "CCMP") == 0)
641 val |= WPA_CIPHER_CCMP;
642 else if (os_strcmp(start, "TKIP") == 0)
643 val |= WPA_CIPHER_TKIP;
644 else if (os_strcmp(start, "WEP104") == 0)
645 val |= WPA_CIPHER_WEP104;
646 else if (os_strcmp(start, "WEP40") == 0)
647 val |= WPA_CIPHER_WEP40;
648 else if (os_strcmp(start, "NONE") == 0)
649 val |= WPA_CIPHER_NONE;
651 wpa_printf(MSG_ERROR, "Line %d: invalid cipher '%s'.",
664 wpa_printf(MSG_ERROR, "Line %d: no cipher values configured.",
672 #ifndef NO_CONFIG_WRITE
673 static char * wpa_config_write_cipher(int cipher)
675 char *buf, *pos, *end;
678 pos = buf = os_zalloc(50);
683 if (cipher & WPA_CIPHER_CCMP) {
684 ret = os_snprintf(pos, end - pos, "%sCCMP",
685 pos == buf ? "" : " ");
686 if (ret < 0 || ret >= end - pos) {
693 if (cipher & WPA_CIPHER_TKIP) {
694 ret = os_snprintf(pos, end - pos, "%sTKIP",
695 pos == buf ? "" : " ");
696 if (ret < 0 || ret >= end - pos) {
703 if (cipher & WPA_CIPHER_WEP104) {
704 ret = os_snprintf(pos, end - pos, "%sWEP104",
705 pos == buf ? "" : " ");
706 if (ret < 0 || ret >= end - pos) {
713 if (cipher & WPA_CIPHER_WEP40) {
714 ret = os_snprintf(pos, end - pos, "%sWEP40",
715 pos == buf ? "" : " ");
716 if (ret < 0 || ret >= end - pos) {
723 if (cipher & WPA_CIPHER_NONE) {
724 ret = os_snprintf(pos, end - pos, "%sNONE",
725 pos == buf ? "" : " ");
726 if (ret < 0 || ret >= end - pos) {
735 #endif /* NO_CONFIG_WRITE */
738 static int wpa_config_parse_pairwise(const struct parse_data *data,
739 struct wpa_ssid *ssid, int line,
743 val = wpa_config_parse_cipher(line, value);
746 if (val & ~(WPA_CIPHER_CCMP | WPA_CIPHER_TKIP | WPA_CIPHER_NONE)) {
747 wpa_printf(MSG_ERROR, "Line %d: not allowed pairwise cipher "
748 "(0x%x).", line, val);
752 wpa_printf(MSG_MSGDUMP, "pairwise: 0x%x", val);
753 ssid->pairwise_cipher = val;
758 #ifndef NO_CONFIG_WRITE
759 static char * wpa_config_write_pairwise(const struct parse_data *data,
760 struct wpa_ssid *ssid)
762 return wpa_config_write_cipher(ssid->pairwise_cipher);
764 #endif /* NO_CONFIG_WRITE */
767 static int wpa_config_parse_group(const struct parse_data *data,
768 struct wpa_ssid *ssid, int line,
772 val = wpa_config_parse_cipher(line, value);
775 if (val & ~(WPA_CIPHER_CCMP | WPA_CIPHER_TKIP | WPA_CIPHER_WEP104 |
777 wpa_printf(MSG_ERROR, "Line %d: not allowed group cipher "
778 "(0x%x).", line, val);
782 wpa_printf(MSG_MSGDUMP, "group: 0x%x", val);
783 ssid->group_cipher = val;
788 #ifndef NO_CONFIG_WRITE
789 static char * wpa_config_write_group(const struct parse_data *data,
790 struct wpa_ssid *ssid)
792 return wpa_config_write_cipher(ssid->group_cipher);
794 #endif /* NO_CONFIG_WRITE */
797 static int wpa_config_parse_auth_alg(const struct parse_data *data,
798 struct wpa_ssid *ssid, int line,
801 int val = 0, last, errors = 0;
802 char *start, *end, *buf;
804 buf = os_strdup(value);
809 while (*start != '\0') {
810 while (*start == ' ' || *start == '\t')
815 while (*end != ' ' && *end != '\t' && *end != '\0')
819 if (os_strcmp(start, "OPEN") == 0)
820 val |= WPA_AUTH_ALG_OPEN;
821 else if (os_strcmp(start, "SHARED") == 0)
822 val |= WPA_AUTH_ALG_SHARED;
823 else if (os_strcmp(start, "LEAP") == 0)
824 val |= WPA_AUTH_ALG_LEAP;
826 wpa_printf(MSG_ERROR, "Line %d: invalid auth_alg '%s'",
838 wpa_printf(MSG_ERROR,
839 "Line %d: no auth_alg values configured.", line);
843 wpa_printf(MSG_MSGDUMP, "auth_alg: 0x%x", val);
844 ssid->auth_alg = val;
845 return errors ? -1 : 0;
849 #ifndef NO_CONFIG_WRITE
850 static char * wpa_config_write_auth_alg(const struct parse_data *data,
851 struct wpa_ssid *ssid)
853 char *buf, *pos, *end;
856 pos = buf = os_zalloc(30);
861 if (ssid->auth_alg & WPA_AUTH_ALG_OPEN) {
862 ret = os_snprintf(pos, end - pos, "%sOPEN",
863 pos == buf ? "" : " ");
864 if (ret < 0 || ret >= end - pos) {
871 if (ssid->auth_alg & WPA_AUTH_ALG_SHARED) {
872 ret = os_snprintf(pos, end - pos, "%sSHARED",
873 pos == buf ? "" : " ");
874 if (ret < 0 || ret >= end - pos) {
881 if (ssid->auth_alg & WPA_AUTH_ALG_LEAP) {
882 ret = os_snprintf(pos, end - pos, "%sLEAP",
883 pos == buf ? "" : " ");
884 if (ret < 0 || ret >= end - pos) {
893 #endif /* NO_CONFIG_WRITE */
896 #ifdef IEEE8021X_EAPOL
897 static int wpa_config_parse_eap(const struct parse_data *data,
898 struct wpa_ssid *ssid, int line,
901 int last, errors = 0;
902 char *start, *end, *buf;
903 struct eap_method_type *methods = NULL, *tmp;
904 size_t num_methods = 0;
906 buf = os_strdup(value);
911 while (*start != '\0') {
912 while (*start == ' ' || *start == '\t')
917 while (*end != ' ' && *end != '\t' && *end != '\0')
922 methods = os_realloc(methods,
923 (num_methods + 1) * sizeof(*methods));
924 if (methods == NULL) {
929 methods[num_methods].method = eap_peer_get_type(
930 start, &methods[num_methods].vendor);
931 if (methods[num_methods].vendor == EAP_VENDOR_IETF &&
932 methods[num_methods].method == EAP_TYPE_NONE) {
933 wpa_printf(MSG_ERROR, "Line %d: unknown EAP method "
934 "'%s'", line, start);
935 wpa_printf(MSG_ERROR, "You may need to add support for"
936 " this EAP method during wpa_supplicant\n"
937 "build time configuration.\n"
938 "See README for more information.");
940 } else if (methods[num_methods].vendor == EAP_VENDOR_IETF &&
941 methods[num_methods].method == EAP_TYPE_LEAP)
953 methods = os_realloc(methods, (num_methods + 1) * sizeof(*methods));
954 if (methods == NULL) {
958 methods[num_methods].vendor = EAP_VENDOR_IETF;
959 methods[num_methods].method = EAP_TYPE_NONE;
962 wpa_hexdump(MSG_MSGDUMP, "eap methods",
963 (u8 *) methods, num_methods * sizeof(*methods));
964 ssid->eap.eap_methods = methods;
965 return errors ? -1 : 0;
969 static char * wpa_config_write_eap(const struct parse_data *data,
970 struct wpa_ssid *ssid)
973 char *buf, *pos, *end;
974 const struct eap_method_type *eap_methods = ssid->eap.eap_methods;
977 if (eap_methods == NULL)
980 pos = buf = os_zalloc(100);
985 for (i = 0; eap_methods[i].vendor != EAP_VENDOR_IETF ||
986 eap_methods[i].method != EAP_TYPE_NONE; i++) {
987 name = eap_get_name(eap_methods[i].vendor,
988 eap_methods[i].method);
990 ret = os_snprintf(pos, end - pos, "%s%s",
991 pos == buf ? "" : " ", name);
992 if (ret < 0 || ret >= end - pos)
1004 static int wpa_config_parse_password(const struct parse_data *data,
1005 struct wpa_ssid *ssid, int line,
1010 if (os_strncmp(value, "hash:", 5) != 0) {
1014 tmp = wpa_config_parse_string(value, &res_len);
1016 wpa_printf(MSG_ERROR, "Line %d: failed to parse "
1020 wpa_hexdump_ascii(MSG_MSGDUMP, data->name,
1021 (u8 *) tmp, res_len);
1023 os_free(ssid->eap.password);
1024 ssid->eap.password = (u8 *) tmp;
1025 ssid->eap.password_len = res_len;
1026 ssid->eap.flags &= ~EAP_CONFIG_FLAGS_PASSWORD_NTHASH;
1032 /* NtPasswordHash: hash:<32 hex digits> */
1033 if (os_strlen(value + 5) != 2 * 16) {
1034 wpa_printf(MSG_ERROR, "Line %d: Invalid password hash length "
1035 "(expected 32 hex digits)", line);
1039 hash = os_malloc(16);
1043 if (hexstr2bin(value + 5, hash, 16)) {
1045 wpa_printf(MSG_ERROR, "Line %d: Invalid password hash", line);
1049 wpa_hexdump_key(MSG_MSGDUMP, data->name, hash, 16);
1051 os_free(ssid->eap.password);
1052 ssid->eap.password = hash;
1053 ssid->eap.password_len = 16;
1054 ssid->eap.flags |= EAP_CONFIG_FLAGS_PASSWORD_NTHASH;
1060 static char * wpa_config_write_password(const struct parse_data *data,
1061 struct wpa_ssid *ssid)
1065 if (ssid->eap.password == NULL)
1068 if (!(ssid->eap.flags & EAP_CONFIG_FLAGS_PASSWORD_NTHASH)) {
1069 return wpa_config_write_string(
1070 ssid->eap.password, ssid->eap.password_len);
1073 buf = os_malloc(5 + 32 + 1);
1077 os_memcpy(buf, "hash:", 5);
1078 wpa_snprintf_hex(buf + 5, 32 + 1, ssid->eap.password, 16);
1082 #endif /* IEEE8021X_EAPOL */
1085 static int wpa_config_parse_wep_key(u8 *key, size_t *len, int line,
1086 const char *value, int idx)
1088 char *buf, title[20];
1091 buf = wpa_config_parse_string(value, len);
1093 wpa_printf(MSG_ERROR, "Line %d: Invalid WEP key %d '%s'.",
1097 if (*len > MAX_WEP_KEY_LEN) {
1098 wpa_printf(MSG_ERROR, "Line %d: Too long WEP key %d '%s'.",
1103 os_memcpy(key, buf, *len);
1105 res = os_snprintf(title, sizeof(title), "wep_key%d", idx);
1106 if (res >= 0 && (size_t) res < sizeof(title))
1107 wpa_hexdump_key(MSG_MSGDUMP, title, key, *len);
1112 static int wpa_config_parse_wep_key0(const struct parse_data *data,
1113 struct wpa_ssid *ssid, int line,
1116 return wpa_config_parse_wep_key(ssid->wep_key[0],
1117 &ssid->wep_key_len[0], line,
1122 static int wpa_config_parse_wep_key1(const struct parse_data *data,
1123 struct wpa_ssid *ssid, int line,
1126 return wpa_config_parse_wep_key(ssid->wep_key[1],
1127 &ssid->wep_key_len[1], line,
1132 static int wpa_config_parse_wep_key2(const struct parse_data *data,
1133 struct wpa_ssid *ssid, int line,
1136 return wpa_config_parse_wep_key(ssid->wep_key[2],
1137 &ssid->wep_key_len[2], line,
1142 static int wpa_config_parse_wep_key3(const struct parse_data *data,
1143 struct wpa_ssid *ssid, int line,
1146 return wpa_config_parse_wep_key(ssid->wep_key[3],
1147 &ssid->wep_key_len[3], line,
1152 #ifndef NO_CONFIG_WRITE
1153 static char * wpa_config_write_wep_key(struct wpa_ssid *ssid, int idx)
1155 if (ssid->wep_key_len[idx] == 0)
1157 return wpa_config_write_string(ssid->wep_key[idx],
1158 ssid->wep_key_len[idx]);
1162 static char * wpa_config_write_wep_key0(const struct parse_data *data,
1163 struct wpa_ssid *ssid)
1165 return wpa_config_write_wep_key(ssid, 0);
1169 static char * wpa_config_write_wep_key1(const struct parse_data *data,
1170 struct wpa_ssid *ssid)
1172 return wpa_config_write_wep_key(ssid, 1);
1176 static char * wpa_config_write_wep_key2(const struct parse_data *data,
1177 struct wpa_ssid *ssid)
1179 return wpa_config_write_wep_key(ssid, 2);
1183 static char * wpa_config_write_wep_key3(const struct parse_data *data,
1184 struct wpa_ssid *ssid)
1186 return wpa_config_write_wep_key(ssid, 3);
1188 #endif /* NO_CONFIG_WRITE */
1191 /* Helper macros for network block parser */
1196 /* OFFSET: Get offset of a variable within the wpa_ssid structure */
1197 #define OFFSET(v) ((void *) &((struct wpa_ssid *) 0)->v)
1199 /* STR: Define a string variable for an ASCII string; f = field name */
1200 #ifdef NO_CONFIG_WRITE
1201 #define _STR(f) #f, wpa_config_parse_str, OFFSET(f)
1202 #define _STRe(f) #f, wpa_config_parse_str, OFFSET(eap.f)
1203 #else /* NO_CONFIG_WRITE */
1204 #define _STR(f) #f, wpa_config_parse_str, wpa_config_write_str, OFFSET(f)
1205 #define _STRe(f) #f, wpa_config_parse_str, wpa_config_write_str, OFFSET(eap.f)
1206 #endif /* NO_CONFIG_WRITE */
1207 #define STR(f) _STR(f), NULL, NULL, NULL, 0
1208 #define STRe(f) _STRe(f), NULL, NULL, NULL, 0
1209 #define STR_KEY(f) _STR(f), NULL, NULL, NULL, 1
1210 #define STR_KEYe(f) _STRe(f), NULL, NULL, NULL, 1
1212 /* STR_LEN: Define a string variable with a separate variable for storing the
1213 * data length. Unlike STR(), this can be used to store arbitrary binary data
1214 * (i.e., even nul termination character). */
1215 #define _STR_LEN(f) _STR(f), OFFSET(f ## _len)
1216 #define _STR_LENe(f) _STRe(f), OFFSET(eap.f ## _len)
1217 #define STR_LEN(f) _STR_LEN(f), NULL, NULL, 0
1218 #define STR_LENe(f) _STR_LENe(f), NULL, NULL, 0
1219 #define STR_LEN_KEY(f) _STR_LEN(f), NULL, NULL, 1
1221 /* STR_RANGE: Like STR_LEN(), but with minimum and maximum allowed length
1222 * explicitly specified. */
1223 #define _STR_RANGE(f, min, max) _STR_LEN(f), (void *) (min), (void *) (max)
1224 #define STR_RANGE(f, min, max) _STR_RANGE(f, min, max), 0
1225 #define STR_RANGE_KEY(f, min, max) _STR_RANGE(f, min, max), 1
1227 #ifdef NO_CONFIG_WRITE
1228 #define _INT(f) #f, wpa_config_parse_int, OFFSET(f), (void *) 0
1229 #define _INTe(f) #f, wpa_config_parse_int, OFFSET(eap.f), (void *) 0
1230 #else /* NO_CONFIG_WRITE */
1231 #define _INT(f) #f, wpa_config_parse_int, wpa_config_write_int, \
1232 OFFSET(f), (void *) 0
1233 #define _INTe(f) #f, wpa_config_parse_int, wpa_config_write_int, \
1234 OFFSET(eap.f), (void *) 0
1235 #endif /* NO_CONFIG_WRITE */
1237 /* INT: Define an integer variable */
1238 #define INT(f) _INT(f), NULL, NULL, 0
1239 #define INTe(f) _INTe(f), NULL, NULL, 0
1241 /* INT_RANGE: Define an integer variable with allowed value range */
1242 #define INT_RANGE(f, min, max) _INT(f), (void *) (min), (void *) (max), 0
1244 /* FUNC: Define a configuration variable that uses a custom function for
1245 * parsing and writing the value. */
1246 #ifdef NO_CONFIG_WRITE
1247 #define _FUNC(f) #f, wpa_config_parse_ ## f, NULL, NULL, NULL, NULL
1248 #else /* NO_CONFIG_WRITE */
1249 #define _FUNC(f) #f, wpa_config_parse_ ## f, wpa_config_write_ ## f, \
1250 NULL, NULL, NULL, NULL
1251 #endif /* NO_CONFIG_WRITE */
1252 #define FUNC(f) _FUNC(f), 0
1253 #define FUNC_KEY(f) _FUNC(f), 1
1256 * Table of network configuration variables. This table is used to parse each
1257 * network configuration variable, e.g., each line in wpa_supplicant.conf file
1258 * that is inside a network block.
1260 * This table is generated using the helper macros defined above and with
1261 * generous help from the C pre-processor. The field name is stored as a string
1262 * into .name and for STR and INT types, the offset of the target buffer within
1263 * struct wpa_ssid is stored in .param1. .param2 (if not NULL) is similar
1264 * offset to the field containing the length of the configuration variable.
1265 * .param3 and .param4 can be used to mark the allowed range (length for STR
1266 * and value for INT).
1268 * For each configuration line in wpa_supplicant.conf, the parser goes through
1269 * this table and select the entry that matches with the field name. The parser
1270 * function (.parser) is then called to parse the actual value of the field.
1272 * This kind of mechanism makes it easy to add new configuration parameters,
1273 * since only one line needs to be added into this table and into the
1274 * struct wpa_ssid definition if the new variable is either a string or
1275 * integer. More complex types will need to use their own parser and writer
1278 static const struct parse_data ssid_fields[] = {
1279 { STR_RANGE(ssid, 0, MAX_SSID_LEN) },
1280 { INT_RANGE(scan_ssid, 0, 1) },
1288 #ifdef IEEE8021X_EAPOL
1290 { STR_LENe(identity) },
1291 { STR_LENe(anonymous_identity) },
1295 { STRe(client_cert) },
1296 { STRe(private_key) },
1297 { STR_KEYe(private_key_passwd) },
1299 { STRe(subject_match) },
1300 { STRe(altsubject_match) },
1303 { STRe(client_cert2) },
1304 { STRe(private_key2) },
1305 { STR_KEYe(private_key2_passwd) },
1307 { STRe(subject_match2) },
1308 { STRe(altsubject_match2) },
1313 { STRe(engine_id) },
1316 { STRe(ca_cert_id) },
1319 { STRe(ca_cert2_id) },
1321 { INT(eapol_flags) },
1322 #endif /* IEEE8021X_EAPOL */
1323 { FUNC_KEY(wep_key0) },
1324 { FUNC_KEY(wep_key1) },
1325 { FUNC_KEY(wep_key2) },
1326 { FUNC_KEY(wep_key3) },
1327 { INT(wep_tx_keyidx) },
1329 #ifdef IEEE8021X_EAPOL
1330 { INT(eap_workaround) },
1332 { INTe(fragment_size) },
1333 #endif /* IEEE8021X_EAPOL */
1334 { INT_RANGE(mode, 0, 1) },
1335 { INT_RANGE(proactive_key_caching, 0, 1) },
1336 { INT_RANGE(disabled, 0, 1) },
1338 #ifdef CONFIG_IEEE80211W
1339 { INT_RANGE(ieee80211w, 0, 2) },
1340 #endif /* CONFIG_IEEE80211W */
1341 { INT_RANGE(peerkey, 0, 1) },
1342 { INT_RANGE(mixed_cell, 0, 1) },
1343 { INT_RANGE(frequency, 0, 10000) }
1355 #undef STR_RANGE_KEY
1362 #define NUM_SSID_FIELDS (sizeof(ssid_fields) / sizeof(ssid_fields[0]))
1366 * wpa_config_add_prio_network - Add a network to priority lists
1367 * @config: Configuration data from wpa_config_read()
1368 * @ssid: Pointer to the network configuration to be added to the list
1369 * Returns: 0 on success, -1 on failure
1371 * This function is used to add a network block to the priority list of
1372 * networks. This must be called for each network when reading in the full
1373 * configuration. In addition, this can be used indirectly when updating
1374 * priorities by calling wpa_config_update_prio_list().
1376 int wpa_config_add_prio_network(struct wpa_config *config,
1377 struct wpa_ssid *ssid)
1380 struct wpa_ssid *prev, **nlist;
1383 * Add to an existing priority list if one is available for the
1384 * configured priority level for this network.
1386 for (prio = 0; prio < config->num_prio; prio++) {
1387 prev = config->pssid[prio];
1388 if (prev->priority == ssid->priority) {
1396 /* First network for this priority - add a new priority list */
1397 nlist = os_realloc(config->pssid,
1398 (config->num_prio + 1) * sizeof(struct wpa_ssid *));
1402 for (prio = 0; prio < config->num_prio; prio++) {
1403 if (nlist[prio]->priority < ssid->priority)
1407 os_memmove(&nlist[prio + 1], &nlist[prio],
1408 (config->num_prio - prio) * sizeof(struct wpa_ssid *));
1412 config->pssid = nlist;
1419 * wpa_config_update_prio_list - Update network priority list
1420 * @config: Configuration data from wpa_config_read()
1421 * Returns: 0 on success, -1 on failure
1423 * This function is called to update the priority list of networks in the
1424 * configuration when a network is being added or removed. This is also called
1425 * if a priority for a network is changed.
1427 static int wpa_config_update_prio_list(struct wpa_config *config)
1429 struct wpa_ssid *ssid;
1432 os_free(config->pssid);
1433 config->pssid = NULL;
1434 config->num_prio = 0;
1436 ssid = config->ssid;
1439 if (wpa_config_add_prio_network(config, ssid) < 0)
1448 #ifdef IEEE8021X_EAPOL
1449 static void eap_peer_config_free(struct eap_peer_config *eap)
1451 os_free(eap->eap_methods);
1452 os_free(eap->identity);
1453 os_free(eap->anonymous_identity);
1454 os_free(eap->password);
1455 os_free(eap->ca_cert);
1456 os_free(eap->ca_path);
1457 os_free(eap->client_cert);
1458 os_free(eap->private_key);
1459 os_free(eap->private_key_passwd);
1460 os_free(eap->dh_file);
1461 os_free(eap->subject_match);
1462 os_free(eap->altsubject_match);
1463 os_free(eap->ca_cert2);
1464 os_free(eap->ca_path2);
1465 os_free(eap->client_cert2);
1466 os_free(eap->private_key2);
1467 os_free(eap->private_key2_passwd);
1468 os_free(eap->dh_file2);
1469 os_free(eap->subject_match2);
1470 os_free(eap->altsubject_match2);
1471 os_free(eap->phase1);
1472 os_free(eap->phase2);
1475 os_free(eap->engine_id);
1476 os_free(eap->key_id);
1477 os_free(eap->cert_id);
1478 os_free(eap->ca_cert_id);
1479 os_free(eap->key2_id);
1480 os_free(eap->cert2_id);
1481 os_free(eap->ca_cert2_id);
1483 os_free(eap->pending_req_otp);
1484 os_free(eap->pac_file);
1485 os_free(eap->new_password);
1487 #endif /* IEEE8021X_EAPOL */
1491 * wpa_config_free_ssid - Free network/ssid configuration data
1492 * @ssid: Configuration data for the network
1494 * This function frees all resources allocated for the network configuration
1497 void wpa_config_free_ssid(struct wpa_ssid *ssid)
1499 os_free(ssid->ssid);
1500 os_free(ssid->passphrase);
1501 #ifdef IEEE8021X_EAPOL
1502 eap_peer_config_free(&ssid->eap);
1503 #endif /* IEEE8021X_EAPOL */
1504 os_free(ssid->id_str);
1510 * wpa_config_free - Free configuration data
1511 * @config: Configuration data from wpa_config_read()
1513 * This function frees all resources allocated for the configuration data by
1514 * wpa_config_read().
1516 void wpa_config_free(struct wpa_config *config)
1518 #ifndef CONFIG_NO_CONFIG_BLOBS
1519 struct wpa_config_blob *blob, *prevblob;
1520 #endif /* CONFIG_NO_CONFIG_BLOBS */
1521 struct wpa_ssid *ssid, *prev = NULL;
1522 ssid = config->ssid;
1526 wpa_config_free_ssid(prev);
1529 #ifndef CONFIG_NO_CONFIG_BLOBS
1530 blob = config->blobs;
1535 wpa_config_free_blob(prevblob);
1537 #endif /* CONFIG_NO_CONFIG_BLOBS */
1539 os_free(config->ctrl_interface);
1540 os_free(config->ctrl_interface_group);
1541 #ifdef EAP_TLS_OPENSSL
1542 os_free(config->opensc_engine_path);
1543 os_free(config->pkcs11_engine_path);
1544 os_free(config->pkcs11_module_path);
1545 #endif /* EAP_TLS_OPENSSL */
1546 os_free(config->driver_param);
1547 os_free(config->pssid);
1553 * wpa_config_get_network - Get configured network based on id
1554 * @config: Configuration data from wpa_config_read()
1555 * @id: Unique network id to search for
1556 * Returns: Network configuration or %NULL if not found
1558 struct wpa_ssid * wpa_config_get_network(struct wpa_config *config, int id)
1560 struct wpa_ssid *ssid;
1562 ssid = config->ssid;
1574 * wpa_config_add_network - Add a new network with empty configuration
1575 * @config: Configuration data from wpa_config_read()
1576 * Returns: The new network configuration or %NULL if operation failed
1578 struct wpa_ssid * wpa_config_add_network(struct wpa_config *config)
1581 struct wpa_ssid *ssid, *last = NULL;
1584 ssid = config->ssid;
1593 ssid = os_zalloc(sizeof(*ssid));
1600 config->ssid = ssid;
1602 wpa_config_update_prio_list(config);
1609 * wpa_config_remove_network - Remove a configured network based on id
1610 * @config: Configuration data from wpa_config_read()
1611 * @id: Unique network id to search for
1612 * Returns: 0 on success, or -1 if the network was not found
1614 int wpa_config_remove_network(struct wpa_config *config, int id)
1616 struct wpa_ssid *ssid, *prev = NULL;
1618 ssid = config->ssid;
1630 prev->next = ssid->next;
1632 config->ssid = ssid->next;
1634 wpa_config_update_prio_list(config);
1635 wpa_config_free_ssid(ssid);
1641 * wpa_config_set_network_defaults - Set network default values
1642 * @ssid: Pointer to network configuration data
1644 void wpa_config_set_network_defaults(struct wpa_ssid *ssid)
1646 ssid->proto = DEFAULT_PROTO;
1647 ssid->pairwise_cipher = DEFAULT_PAIRWISE;
1648 ssid->group_cipher = DEFAULT_GROUP;
1649 ssid->key_mgmt = DEFAULT_KEY_MGMT;
1650 #ifdef IEEE8021X_EAPOL
1651 ssid->eapol_flags = DEFAULT_EAPOL_FLAGS;
1652 ssid->eap_workaround = DEFAULT_EAP_WORKAROUND;
1653 ssid->eap.fragment_size = DEFAULT_FRAGMENT_SIZE;
1654 #endif /* IEEE8021X_EAPOL */
1659 * wpa_config_set - Set a variable in network configuration
1660 * @ssid: Pointer to network configuration data
1661 * @var: Variable name, e.g., "ssid"
1662 * @value: Variable value
1663 * @line: Line number in configuration file or 0 if not used
1664 * Returns: 0 on success, -1 on failure
1666 * This function can be used to set network configuration variables based on
1667 * both the configuration file and management interface input. The value
1668 * parameter must be in the same format as the text-based configuration file is
1669 * using. For example, strings are using double quotation marks.
1671 int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
1677 if (ssid == NULL || var == NULL || value == NULL)
1680 for (i = 0; i < NUM_SSID_FIELDS; i++) {
1681 const struct parse_data *field = &ssid_fields[i];
1682 if (os_strcmp(var, field->name) != 0)
1685 if (field->parser(field, ssid, line, value)) {
1687 wpa_printf(MSG_ERROR, "Line %d: failed to "
1688 "parse %s '%s'.", line, var, value);
1694 if (i == NUM_SSID_FIELDS) {
1696 wpa_printf(MSG_ERROR, "Line %d: unknown network field "
1697 "'%s'.", line, var);
1706 #ifndef NO_CONFIG_WRITE
1708 * wpa_config_get - Get a variable in network configuration
1709 * @ssid: Pointer to network configuration data
1710 * @var: Variable name, e.g., "ssid"
1711 * Returns: Value of the variable or %NULL on failure
1713 * This function can be used to get network configuration variables. The
1714 * returned value is a copy of the configuration variable in text format, i.e,.
1715 * the same format that the text-based configuration file and wpa_config_set()
1716 * are using for the value. The caller is responsible for freeing the returned
1719 char * wpa_config_get(struct wpa_ssid *ssid, const char *var)
1723 if (ssid == NULL || var == NULL)
1726 for (i = 0; i < NUM_SSID_FIELDS; i++) {
1727 const struct parse_data *field = &ssid_fields[i];
1728 if (os_strcmp(var, field->name) == 0)
1729 return field->writer(field, ssid);
1737 * wpa_config_get_no_key - Get a variable in network configuration (no keys)
1738 * @ssid: Pointer to network configuration data
1739 * @var: Variable name, e.g., "ssid"
1740 * Returns: Value of the variable or %NULL on failure
1742 * This function can be used to get network configuration variable like
1743 * wpa_config_get(). The only difference is that this functions does not expose
1744 * key/password material from the configuration. In case a key/password field
1745 * is requested, the returned value is an empty string or %NULL if the variable
1746 * is not set or "*" if the variable is set (regardless of its value). The
1747 * returned value is a copy of the configuration variable in text format, i.e,.
1748 * the same format that the text-based configuration file and wpa_config_set()
1749 * are using for the value. The caller is responsible for freeing the returned
1752 char * wpa_config_get_no_key(struct wpa_ssid *ssid, const char *var)
1756 if (ssid == NULL || var == NULL)
1759 for (i = 0; i < NUM_SSID_FIELDS; i++) {
1760 const struct parse_data *field = &ssid_fields[i];
1761 if (os_strcmp(var, field->name) == 0) {
1762 char *res = field->writer(field, ssid);
1763 if (field->key_data) {
1764 if (res && res[0]) {
1765 wpa_printf(MSG_DEBUG, "Do not allow "
1766 "key_data field to be "
1769 return os_strdup("*");
1781 #endif /* NO_CONFIG_WRITE */
1785 * wpa_config_update_psk - Update WPA PSK based on passphrase and SSID
1786 * @ssid: Pointer to network configuration data
1788 * This function must be called to update WPA PSK when either SSID or the
1789 * passphrase has changed for the network configuration.
1791 void wpa_config_update_psk(struct wpa_ssid *ssid)
1793 #ifndef CONFIG_NO_PBKDF2
1794 pbkdf2_sha1(ssid->passphrase,
1795 (char *) ssid->ssid, ssid->ssid_len, 4096,
1796 ssid->psk, PMK_LEN);
1797 wpa_hexdump_key(MSG_MSGDUMP, "PSK (from passphrase)",
1798 ssid->psk, PMK_LEN);
1800 #endif /* CONFIG_NO_PBKDF2 */
1804 #ifndef CONFIG_NO_CONFIG_BLOBS
1806 * wpa_config_get_blob - Get a named configuration blob
1807 * @config: Configuration data from wpa_config_read()
1808 * @name: Name of the blob
1809 * Returns: Pointer to blob data or %NULL if not found
1811 const struct wpa_config_blob * wpa_config_get_blob(struct wpa_config *config,
1814 struct wpa_config_blob *blob = config->blobs;
1817 if (os_strcmp(blob->name, name) == 0)
1826 * wpa_config_set_blob - Set or add a named configuration blob
1827 * @config: Configuration data from wpa_config_read()
1828 * @blob: New value for the blob
1830 * Adds a new configuration blob or replaces the current value of an existing
1833 void wpa_config_set_blob(struct wpa_config *config,
1834 struct wpa_config_blob *blob)
1836 wpa_config_remove_blob(config, blob->name);
1837 blob->next = config->blobs;
1838 config->blobs = blob;
1843 * wpa_config_free_blob - Free blob data
1844 * @blob: Pointer to blob to be freed
1846 void wpa_config_free_blob(struct wpa_config_blob *blob)
1849 os_free(blob->name);
1850 os_free(blob->data);
1857 * wpa_config_remove_blob - Remove a named configuration blob
1858 * @config: Configuration data from wpa_config_read()
1859 * @name: Name of the blob to remove
1860 * Returns: 0 if blob was removed or -1 if blob was not found
1862 int wpa_config_remove_blob(struct wpa_config *config, const char *name)
1864 struct wpa_config_blob *pos = config->blobs, *prev = NULL;
1867 if (os_strcmp(pos->name, name) == 0) {
1869 prev->next = pos->next;
1871 config->blobs = pos->next;
1872 wpa_config_free_blob(pos);
1881 #endif /* CONFIG_NO_CONFIG_BLOBS */
1885 * wpa_config_alloc_empty - Allocate an empty configuration
1886 * @ctrl_interface: Control interface parameters, e.g., path to UNIX domain
1888 * @driver_param: Driver parameters
1889 * Returns: Pointer to allocated configuration data or %NULL on failure
1891 struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
1892 const char *driver_param)
1894 struct wpa_config *config;
1896 config = os_zalloc(sizeof(*config));
1899 config->eapol_version = DEFAULT_EAPOL_VERSION;
1900 config->ap_scan = DEFAULT_AP_SCAN;
1901 config->fast_reauth = DEFAULT_FAST_REAUTH;
1904 config->ctrl_interface = os_strdup(ctrl_interface);
1906 config->driver_param = os_strdup(driver_param);
1912 #ifndef CONFIG_NO_STDOUT_DEBUG
1914 * wpa_config_debug_dump_networks - Debug dump of configured networks
1915 * @config: Configuration data from wpa_config_read()
1917 void wpa_config_debug_dump_networks(struct wpa_config *config)
1920 struct wpa_ssid *ssid;
1922 for (prio = 0; prio < config->num_prio; prio++) {
1923 ssid = config->pssid[prio];
1924 wpa_printf(MSG_DEBUG, "Priority group %d",
1927 wpa_printf(MSG_DEBUG, " id=%d ssid='%s'",
1929 wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
1934 #endif /* CONFIG_NO_STDOUT_DEBUG */