void fr_state_get_vps(REQUEST *request, RADIUS_PACKET *packet);
bool fr_state_put_vps(REQUEST *request, RADIUS_PACKET *original, RADIUS_PACKET *packet);
-void *fr_state_find_data(fr_state_t *state, REQUEST *request, RADIUS_PACKET *packet);
-void *fr_state_get_data(fr_state_t *state, REQUEST *request, RADIUS_PACKET *packet);
-bool fr_state_put_data(fr_state_t *state, REQUEST *request, RADIUS_PACKET *original, RADIUS_PACKET *packet,
- void *data, void (*free_data)(void *));
-
#ifdef __cplusplus
}
#endif
VERIFY_REQUEST(request);
return true;
}
-
-/*
- * Find the opaque data associated with a State attribute.
- * Leave the data in the entry.
- */
-void *fr_state_find_data(fr_state_t *state, REQUEST *request, RADIUS_PACKET *packet)
-{
- void *data;
- state_entry_t *entry;
-
- if (!state) return false;
-
- PTHREAD_MUTEX_LOCK(&state->mutex);
- entry = fr_state_find(state, request->server, packet);
- if (!entry) {
- PTHREAD_MUTEX_UNLOCK(&state->mutex);
- return NULL;
- }
-
- data = entry->opaque;
- PTHREAD_MUTEX_UNLOCK(&state->mutex);
-
- return data;
-}
-
-
-/*
- * Get the opaque data associated with a State attribute.
- * and remove the data from the entry.
- */
-void *fr_state_get_data(fr_state_t *state, REQUEST *request, RADIUS_PACKET *packet)
-{
- void *data;
- state_entry_t *entry;
-
- if (!state) return NULL;
-
- PTHREAD_MUTEX_LOCK(&state->mutex);
- entry = fr_state_find(state, request->server, packet);
- if (!entry) {
- PTHREAD_MUTEX_UNLOCK(&state->mutex);
- return NULL;
- }
-
- data = entry->opaque;
- entry->opaque = NULL;
- PTHREAD_MUTEX_UNLOCK(&state->mutex);
-
- return data;
-}
-
-
-/*
- * Get the opaque data associated with a State attribute.
- * and remove the data from the entry.
- */
-bool fr_state_put_data(fr_state_t *state, REQUEST *request, RADIUS_PACKET *original, RADIUS_PACKET *packet,
- void *data, void (*free_data)(void *))
-{
- state_entry_t *entry, *old;
-
- if (!state) return false;
-
- PTHREAD_MUTEX_LOCK(&state->mutex);
-
- if (original) {
- old = fr_state_find(state, request->server, original);
- } else {
- old = NULL;
- }
-
- /*
- * Create a new entry and add it to the list.
- */
- entry = fr_state_entry_create(state, request, packet, old);
- if (!entry) {
- PTHREAD_MUTEX_UNLOCK(&state->mutex);
- return false;
- }
-
- /*
- * If we're moving the data, ensure that we delete it
- * from the old state.
- */
- if (old && (old->opaque == data)) {
- old->opaque = NULL;
- }
-
- entry->opaque = data;
- entry->free_opaque = free_data;
-
- PTHREAD_MUTEX_UNLOCK(&state->mutex);
- return true;
-}