summaryrefslogtreecommitdiff
path: root/lib/gnutls_db.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-08-29 12:58:39 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-08-29 12:58:39 +0000
commit5cb018a2c17e92dfb50e5bc1c03ccc080f6be87b (patch)
tree61f4f6ab841f1656b6c46205cc063befdaac7dc8 /lib/gnutls_db.c
parent38c90cd3ff90327d5767b192be1a940ca22af406 (diff)
downloadgnutls-5cb018a2c17e92dfb50e5bc1c03ccc080f6be87b.tar.gz
Renamed all the constructed types to have more consisten names, and some other minor improvements.
Diffstat (limited to 'lib/gnutls_db.c')
-rw-r--r--lib/gnutls_db.c106
1 files changed, 53 insertions, 53 deletions
diff --git a/lib/gnutls_db.c b/lib/gnutls_db.c
index 14e1238439..770d935e82 100644
--- a/lib/gnutls_db.c
+++ b/lib/gnutls_db.c
@@ -32,7 +32,7 @@
/**
* gnutls_db_set_retrieve_function - Sets the function that will be used to get data
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
* @retr_func: is the function.
*
* Sets the function that will be used to retrieve data from the resumed
@@ -45,13 +45,13 @@
* has been called.
*
**/
-void gnutls_db_set_retrieve_function( GNUTLS_STATE state, GNUTLS_DB_RETR_FUNC retr_func) {
- state->gnutls_internals.db_retrieve_func = retr_func;
+void gnutls_db_set_retrieve_function( gnutls_session session, gnutls_db_retr_func retr_func) {
+ session->internals.db_retrieve_func = retr_func;
}
/**
* gnutls_db_set_remove_function - Sets the function that will be used to remove data
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
* @rem_func: is the function.
*
* Sets the function that will be used to remove data from the resumed
@@ -63,13 +63,13 @@ void gnutls_db_set_retrieve_function( GNUTLS_STATE state, GNUTLS_DB_RETR_FUNC re
* has been called.
*
**/
-void gnutls_db_set_remove_function( GNUTLS_STATE state, GNUTLS_DB_REMOVE_FUNC rem_func) {
- state->gnutls_internals.db_remove_func = rem_func;
+void gnutls_db_set_remove_function( gnutls_session session, gnutls_db_remove_func rem_func) {
+ session->internals.db_remove_func = rem_func;
}
/**
* gnutls_db_set_store_function - Sets the function that will be used to put data
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
* @store_func: is the function
*
* Sets the function that will be used to store data from the resumed
@@ -81,50 +81,50 @@ void gnutls_db_set_remove_function( GNUTLS_STATE state, GNUTLS_DB_REMOVE_FUNC re
* has been called.
*
**/
-void gnutls_db_set_store_function( GNUTLS_STATE state, GNUTLS_DB_STORE_FUNC store_func) {
- state->gnutls_internals.db_store_func = store_func;
+void gnutls_db_set_store_function( gnutls_session session, gnutls_db_store_func store_func) {
+ session->internals.db_store_func = store_func;
}
/**
* gnutls_db_set_ptr - Sets a pointer to be sent to db functions
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
* @ptr: is the pointer
*
* Sets the pointer that will be sent to db store, retrieve and delete functions, as
* the first argument. Should only be called if not using the gdbm backend.
*
**/
-void gnutls_db_set_ptr( GNUTLS_STATE state, void* ptr) {
- state->gnutls_internals.db_ptr = ptr;
+void gnutls_db_set_ptr( gnutls_session session, void* ptr) {
+ session->internals.db_ptr = ptr;
}
/**
* gnutls_db_get_ptr - Returns the pointer which is sent to db functions
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
*
* Returns the pointer that will be sent to db store, retrieve and delete functions, as
* the first argument. Should only be used if not using the default (gdbm) backend.
*
**/
-void* gnutls_db_get_ptr( GNUTLS_STATE state) {
- return state->gnutls_internals.db_ptr;
+void* gnutls_db_get_ptr( gnutls_session session) {
+ return session->internals.db_ptr;
}
/**
* gnutls_db_set_cache_expiration - Sets the expiration time for resumed sessions.
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
* @seconds: is the number of seconds.
*
* Sets the expiration time for resumed sessions. The default is 3600 (one hour)
* at the time writing this.
**/
-void gnutls_db_set_cache_expiration( GNUTLS_STATE state, int seconds) {
- state->gnutls_internals.expire_time = seconds;
+void gnutls_db_set_cache_expiration( gnutls_session session, int seconds) {
+ session->internals.expire_time = seconds;
}
/**
* gnutls_db_check_entry - checks if the given db entry has expired
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
* @session_entry: is the session data (not key)
*
* This function returns GNUTLS_E_EXPIRED, if the database entry
@@ -133,13 +133,13 @@ void gnutls_db_set_cache_expiration( GNUTLS_STATE state, int seconds) {
* backend.
*
**/
-int gnutls_db_check_entry( GNUTLS_STATE state, gnutls_datum session_entry) {
+int gnutls_db_check_entry( gnutls_session session, gnutls_datum session_entry) {
time_t timestamp;
timestamp = time(0);
if (session_entry.data != NULL)
- if ( timestamp - ((SecurityParameters*)(session_entry.data))->timestamp <= state->gnutls_internals.expire_time || ((SecurityParameters*)(session_entry.data))->timestamp > timestamp|| ((SecurityParameters*)(session_entry.data))->timestamp == 0)
+ if ( timestamp - ((SecurityParameters*)(session_entry.data))->timestamp <= session->internals.expire_time || ((SecurityParameters*)(session_entry.data))->timestamp > timestamp|| ((SecurityParameters*)(session_entry.data))->timestamp == 0)
return GNUTLS_E_EXPIRED;
return 0;
@@ -148,24 +148,24 @@ time_t timestamp;
/* The format of storing data is:
* (forget it). Check gnutls_session_pack.c
*/
-int _gnutls_server_register_current_session( GNUTLS_STATE state)
+int _gnutls_server_register_current_session( gnutls_session session)
{
-gnutls_datum key = { state->security_parameters.session_id, state->security_parameters.session_id_size };
+gnutls_datum key = { session->security_parameters.session_id, session->security_parameters.session_id_size };
gnutls_datum content;
int ret = 0;
- if (state->gnutls_internals.resumable==RESUME_FALSE) {
+ if (session->internals.resumable==RESUME_FALSE) {
gnutls_assert();
return GNUTLS_E_INVALID_SESSION;
}
- if (state->security_parameters.session_id==NULL || state->security_parameters.session_id_size==0) {
+ if (session->security_parameters.session_id==NULL || session->security_parameters.session_id_size==0) {
gnutls_assert();
return GNUTLS_E_INVALID_SESSION;
}
/* allocate space for data */
- content.size = _gnutls_session_size( state);
+ content.size = _gnutls_session_size( session);
if (content.size < 0) {
gnutls_assert();
return content.size;
@@ -178,14 +178,14 @@ int ret = 0;
}
/* copy data */
- ret = _gnutls_session_pack( state, &content);
+ ret = _gnutls_session_pack( session, &content);
if (ret < 0) {
gnutls_free( content.data);
gnutls_assert();
return ret;
}
- ret = _gnutls_store_session( state, key, content);
+ ret = _gnutls_store_session( session, key, content);
gnutls_free( content.data);
@@ -195,26 +195,26 @@ int ret = 0;
/* Checks if both db_store and db_retrieve functions have
* been set up.
*/
-static int _gnutls_db_func_is_ok( GNUTLS_STATE state) {
- if (state->gnutls_internals.db_store_func!=NULL &&
- state->gnutls_internals.db_retrieve_func!=NULL &&
- state->gnutls_internals.db_remove_func!=NULL) return 0;
+static int _gnutls_db_func_is_ok( gnutls_session session) {
+ if (session->internals.db_store_func!=NULL &&
+ session->internals.db_retrieve_func!=NULL &&
+ session->internals.db_remove_func!=NULL) return 0;
else return GNUTLS_E_DB_ERROR;
}
-int _gnutls_server_restore_session( GNUTLS_STATE state, uint8* session_id, int session_id_size)
+int _gnutls_server_restore_session( gnutls_session session, uint8* session_id, int session_id_size)
{
gnutls_datum data;
gnutls_datum key = { session_id, session_id_size };
int ret;
- if (_gnutls_db_func_is_ok(state)!=0) {
+ if (_gnutls_db_func_is_ok(session)!=0) {
gnutls_assert();
return GNUTLS_E_INVALID_SESSION;
}
- data = _gnutls_retrieve_session( state, key);
+ data = _gnutls_retrieve_session( session, key);
if (data.data==NULL) {
gnutls_assert();
@@ -222,7 +222,7 @@ int ret;
}
/* expiration check is performed inside */
- ret = gnutls_session_set_data( state, data.data, data.size);
+ ret = gnutls_session_set_data( session, data.data, data.size);
if (ret < 0) {
gnutls_assert();
}
@@ -234,26 +234,26 @@ int ret;
return 0;
}
-int _gnutls_db_remove_session( GNUTLS_STATE state, uint8* session_id, int session_id_size)
+int _gnutls_db_remove_session( gnutls_session session, uint8* session_id, int session_id_size)
{
gnutls_datum key = { session_id, session_id_size };
- return _gnutls_remove_session( state, key);
+ return _gnutls_remove_session( session, key);
}
/* Stores session data to the db backend.
*/
-int _gnutls_store_session( GNUTLS_STATE state, gnutls_datum session_id, gnutls_datum session_data)
+int _gnutls_store_session( gnutls_session session, gnutls_datum session_id, gnutls_datum session_data)
{
int ret = 0;
- if (state->gnutls_internals.resumable==RESUME_FALSE) {
+ if (session->internals.resumable==RESUME_FALSE) {
gnutls_assert();
return GNUTLS_E_INVALID_SESSION;
}
- if (_gnutls_db_func_is_ok(state)!=0) {
+ if (_gnutls_db_func_is_ok(session)!=0) {
return GNUTLS_E_DB_ERROR;
}
@@ -268,8 +268,8 @@ int ret = 0;
}
/* if we can't read why bother writing? */
- if (state->gnutls_internals.db_store_func!=NULL)
- ret = state->gnutls_internals.db_store_func( state->gnutls_internals.db_ptr, session_id, session_data);
+ if (session->internals.db_store_func!=NULL)
+ ret = session->internals.db_store_func( session->internals.db_ptr, session_id, session_data);
return (ret == 0 ? ret : GNUTLS_E_DB_ERROR);
@@ -277,7 +277,7 @@ int ret = 0;
/* Retrieves session data from the db backend.
*/
-gnutls_datum _gnutls_retrieve_session( GNUTLS_STATE state, gnutls_datum session_id)
+gnutls_datum _gnutls_retrieve_session( gnutls_session session, gnutls_datum session_id)
{
gnutls_datum ret = { NULL, 0 };
@@ -286,8 +286,8 @@ gnutls_datum ret = { NULL, 0 };
return ret;
}
- if (state->gnutls_internals.db_retrieve_func!=NULL)
- ret = state->gnutls_internals.db_retrieve_func( state->gnutls_internals.db_ptr, session_id);
+ if (session->internals.db_retrieve_func!=NULL)
+ ret = session->internals.db_retrieve_func( session->internals.db_ptr, session_id);
return ret;
@@ -295,11 +295,11 @@ gnutls_datum ret = { NULL, 0 };
/* Removes session data from the db backend.
*/
-int _gnutls_remove_session( GNUTLS_STATE state, gnutls_datum session_id)
+int _gnutls_remove_session( gnutls_session session, gnutls_datum session_id)
{
int ret = 0;
- if (_gnutls_db_func_is_ok(state)!=0) {
+ if (_gnutls_db_func_is_ok(session)!=0) {
return GNUTLS_E_DB_ERROR;
}
@@ -307,8 +307,8 @@ int ret = 0;
return GNUTLS_E_INVALID_SESSION;
/* if we can't read why bother writing? */
- if (state->gnutls_internals.db_remove_func!=NULL)
- ret = state->gnutls_internals.db_remove_func( state->gnutls_internals.db_ptr, session_id);
+ if (session->internals.db_remove_func!=NULL)
+ ret = session->internals.db_remove_func( session->internals.db_ptr, session_id);
return (ret == 0 ? ret : GNUTLS_E_DB_ERROR);
@@ -317,7 +317,7 @@ int ret = 0;
/**
* gnutls_db_remove_session - This function will remove the current session data from the database
- * @state: is a &GNUTLS_STATE structure.
+ * @session: is a &gnutls_session structure.
*
* This function will remove the current session data from the session
* database. This will prevent future handshakes reusing these session
@@ -327,9 +327,9 @@ int ret = 0;
* Normally gnutls_deinit() will remove abnormally terminated sessions.
*
**/
-void gnutls_db_remove_session(GNUTLS_STATE state) {
+void gnutls_db_remove_session(gnutls_session session) {
/* if the session has failed abnormally it has
* to be removed from the db
*/
- _gnutls_db_remove_session( state, state->security_parameters.session_id, state->security_parameters.session_id_size);
+ _gnutls_db_remove_session( session, session->security_parameters.session_id, session->security_parameters.session_id_size);
}