[PATCH 2/2] Add timeout option in hostapd.conf for eap_sim_db
Frederic Leroy
frederic.leroy
Mon Sep 21 02:30:15 PDT 2015
Makes eap_sim_db timeout configurable.
Signed-off-by: Frederic Leroy <frederic.leroy at b-com.com>
---
hostapd/config_file.c | 2 ++
src/ap/ap_config.c | 1 +
src/ap/ap_config.h | 1 +
src/ap/authsrv.c | 3 ++-
src/eap_server/eap_sim_db.c | 6 ++++--
src/eap_server/eap_sim_db.h | 5 +----
src/radius/radius_server.h | 7 +++++++
7 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 82ac61d..d7e276b 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2092,6 +2092,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
bss->openssl_ciphers = os_strdup(pos);
} else if (os_strcmp(buf, "fragment_size") == 0) {
bss->fragment_size = atoi(pos);
+ } else if (os_strcmp(buf, "eap_sim_db_timeout") == 0) {
+ bss->eap_sim_db_timeout = atoi(pos);
#ifdef EAP_SERVER_FAST
} else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
os_free(bss->pac_opaque_encr_key);
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 75804a0..b25a7ab 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -63,6 +63,7 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
bss->dtim_period = 2;
bss->radius_server_auth_port = 1812;
+ bss->eap_sim_db_timeout = 1;
bss->ap_max_inactivity = AP_MAX_INACTIVITY;
bss->eapol_version = EAPOL_VERSION;
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index de470a9..2398d09 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -231,6 +231,7 @@ struct hostapd_bss_config {
struct hostapd_eap_user *eap_user;
char *eap_user_sqlite;
char *eap_sim_db;
+ int eap_sim_db_timeout;
int eap_server_erp; /* Whether ERP is enabled on internal EAP server */
struct hostapd_ip_addr own_ip_addr;
char *nas_identifier;
diff --git a/src/ap/authsrv.c b/src/ap/authsrv.c
index 934dcfc..a18cc17 100644
--- a/src/ap/authsrv.c
+++ b/src/ap/authsrv.c
@@ -104,6 +104,7 @@ static int hostapd_setup_radius_srv(struct hostapd_data *hapd)
srv.acct_port = conf->radius_server_acct_port;
srv.conf_ctx = hapd;
srv.eap_sim_db_priv = hapd->eap_sim_db_priv;
+ srv.eap_sim_db_timeout = hapd->conf->eap_sim_db_timeout;
srv.ssl_ctx = hapd->ssl_ctx;
srv.msg_ctx = hapd->msg_ctx;
srv.pac_opaque_encr_key = conf->pac_opaque_encr_key;
@@ -192,7 +193,7 @@ int authsrv_init(struct hostapd_data *hapd)
#ifdef EAP_SIM_DB
if (hapd->conf->eap_sim_db) {
hapd->eap_sim_db_priv =
- eap_sim_db_init(hapd->conf->eap_sim_db,
+ eap_sim_db_init(hapd->conf->eap_sim_db, hapd->conf->eap_sim_db_timeout,
hostapd_sim_db_cb, hapd);
if (hapd->eap_sim_db_priv == NULL) {
wpa_printf(MSG_ERROR, "Failed to initialize EAP-SIM "
diff --git a/src/eap_server/eap_sim_db.c b/src/eap_server/eap_sim_db.c
index 2714166..c5cf043 100644
--- a/src/eap_server/eap_sim_db.c
+++ b/src/eap_server/eap_sim_db.c
@@ -66,6 +66,7 @@ struct eap_sim_db_data {
struct eap_sim_pseudonym *pseudonyms;
struct eap_sim_reauth *reauths;
struct eap_sim_db_pending *pending;
+ int eap_sim_db_timeout;
#ifdef CONFIG_SQLITE
sqlite3 *sqlite_db;
char db_tmp_identity[100];
@@ -695,7 +696,7 @@ static void eap_sim_db_close_socket(struct eap_sim_db_data *data)
* Returns: Pointer to a private data structure or %NULL on failure
*/
struct eap_sim_db_data *
-eap_sim_db_init(const char *config,
+eap_sim_db_init(const char *config, int db_timeout,
void (*get_complete_cb)(void *ctx, void *session_ctx),
void *ctx)
{
@@ -709,6 +710,7 @@ eap_sim_db_init(const char *config,
data->sock = -1;
data->get_complete_cb = get_complete_cb;
data->ctx = ctx;
+ data->eap_sim_db_timeout = db_timeout;
data->fname = os_strdup(config);
if (data->fname == NULL)
goto fail;
@@ -859,7 +861,7 @@ static void eap_sim_db_expire_pending(struct eap_sim_db_data *data, struct eap_s
/* TODO: add limit for maximum length for pending list; remove latest
* (i.e., last) entry from the list if the limit is reached; could also
* use timeout to expire pending entries */
- eloop_register_timeout(EAP_SIM_DB_QUERY_TIMEOUT_SEC, EAP_SIM_DB_QUERY_TIMEOUT_USEC, eap_sim_db_query_timeout, entry, data);
+ eloop_register_timeout(data->eap_sim_db_timeout, 0, eap_sim_db_query_timeout, entry, data);
}
diff --git a/src/eap_server/eap_sim_db.h b/src/eap_server/eap_sim_db.h
index 6098c84..46bf0dd 100644
--- a/src/eap_server/eap_sim_db.h
+++ b/src/eap_server/eap_sim_db.h
@@ -31,7 +31,7 @@ enum eap_sim_db_method {
struct eap_sim_db_data;
struct eap_sim_db_data *
-eap_sim_db_init(const char *config,
+eap_sim_db_init(const char *config, int db_timeout,
void (*get_complete_cb)(void *ctx, void *session_ctx),
void *ctx);
@@ -45,9 +45,6 @@ int eap_sim_db_get_gsm_triplets(struct eap_sim_db_data *data,
#define EAP_SIM_DB_FAILURE -1
#define EAP_SIM_DB_PENDING -2
-#define EAP_SIM_DB_QUERY_TIMEOUT_SEC 1
-#define EAP_SIM_DB_QUERY_TIMEOUT_USEC 0
-
char * eap_sim_db_get_next_pseudonym(struct eap_sim_db_data *data,
enum eap_sim_db_method method);
diff --git a/src/radius/radius_server.h b/src/radius/radius_server.h
index 7a25802..dd15b49 100644
--- a/src/radius/radius_server.h
+++ b/src/radius/radius_server.h
@@ -60,6 +60,13 @@ struct radius_server_conf {
void *eap_sim_db_priv;
/**
+ * eap_sim_db_timeout - EAP-SIM/AKA database timeout
+ *
+ * timeout for database queries
+ */
+ int eap_sim_db_timeout;
+
+ /**
* ssl_ctx - TLS context
*
* This is passed to the EAP server implementation as a callback
--
2.1.4
More information about the Hostap
mailing list