dst = (int *) (((u8 *) config) + (long) data->param1);
*dst = atoi(pos);
wpa_printf(MSG_DEBUG, "%s=%d", data->name, *dst);
+
+ if (data->param2 && *dst < (long) data->param2) {
+ wpa_printf(MSG_ERROR, "Line %d: too small %s (value=%d "
+ "min_value=%ld)", line, data->name, *dst,
+ (long) data->param2);
+ *dst = (long) data->param2;
+ return -1;
+ }
+
+ if (data->param3 && *dst > (long) data->param3) {
+ wpa_printf(MSG_ERROR, "Line %d: too large %s (value=%d "
+ "max_value=%ld)", line, data->name, *dst,
+ (long) data->param3);
+ *dst = (long) data->param3;
+ return -1;
+ }
+
return 0;
}
}
-static int wpa_config_process_eapol_version(
- const struct global_parse_data *data, struct wpa_config *config,
- int line, const char *pos)
-{
- config->eapol_version = atoi(pos);
- if (config->eapol_version < 1 || config->eapol_version > 2) {
- wpa_printf(MSG_ERROR, "Line %d: Invalid EAPOL version (%d): "
- "'%s'.", line, config->eapol_version, pos);
- return -1;
- }
- wpa_printf(MSG_DEBUG, "eapol_version=%d", config->eapol_version);
- return 0;
-}
-
-
static int wpa_config_process_load_dynamic_eap(
const struct global_parse_data *data, struct wpa_config *config,
int line, const char *so)
#define FUNC(f) #f, wpa_config_process_ ## f, OFFSET(f), NULL, NULL
#define FUNC_NO_VAR(f) #f, wpa_config_process_ ## f, NULL, NULL, NULL
-#define INT(f) #f, wpa_config_parse_int, OFFSET(f), NULL, NULL
+#define _INT(f) #f, wpa_config_parse_int, OFFSET(f)
+#define INT(f) _INT(f), NULL, NULL
+#define INT_RANGE(f, min, max) _INT(f), (void *) min, (void *) max
#define _STR(f) #f, wpa_config_parse_str, OFFSET(f)
#define STR(f) _STR(f), NULL, NULL
#define STR_RANGE(f, min, max) _STR(f), (void *) min, (void *) max
{ STR(ctrl_interface) },
{ STR(ctrl_interface_group) } /* deprecated */,
#endif /* CONFIG_CTRL_IFACE */
- { FUNC(eapol_version) },
+ { INT_RANGE(eapol_version, 1, 2) },
{ INT(ap_scan) },
{ INT(fast_reauth) },
#ifdef EAP_TLS_OPENSSL
{ STR_RANGE(serial_number, 0, 32) },
{ STR(device_type) },
{ FUNC(os_version) },
+ { INT_RANGE(wps_cred_processing, 0, 2) },
#endif /* CONFIG_WPS */
{ FUNC(country) }
};
#undef FUNC
+#undef _INT
#undef INT
+#undef INT_RANGE
#undef _STR
#undef STR
#undef STR_RANGE
if (config->update_config)
fprintf(f, "update_config=%d\n", config->update_config);
#ifdef CONFIG_WPS
- if (is_nil_uuid(config->uuid)) {
+ if (!is_nil_uuid(config->uuid)) {
char buf[40];
uuid_bin2str(config->uuid, buf, sizeof(buf));
fprintf(f, "uuid=%s\n", buf);
fprintf(f, "serial_number=%s\n", config->serial_number);
if (config->device_type)
fprintf(f, "device_type=%s\n", config->device_type);
- if (config->os_version)
+ if (WPA_GET_BE32(config->os_version))
fprintf(f, "os_version=%08x\n",
WPA_GET_BE32(config->os_version));
+ if (config->wps_cred_processing)
+ fprintf(f, "wps_cred_processing=%d\n",
+ config->wps_cred_processing);
#endif /* CONFIG_WPS */
if (config->country[0] && config->country[1]) {
fprintf(f, "country=%c%c\n",