From: Alan T. DeKok Date: Thu, 22 Jan 2026 21:28:10 +0000 (-0500) Subject: rename fr_state_() functions for consistency X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=120a50366138caacc60729d419bfc05bf49e7f14;p=thirdparty%2Ffreeradius-server.git rename fr_state_() functions for consistency --- diff --git a/src/lib/eap/base.c b/src/lib/eap/base.c index 89b8b01b8ab..f585d255a11 100644 --- a/src/lib/eap/base.c +++ b/src/lib/eap/base.c @@ -436,7 +436,7 @@ unlang_action_t eap_virtual_server(request_t *request, eap_session_t *eap_sessio /* * Re-present the previously stored child's session state if there is one */ - fr_state_restore_to_child(request, eap_session->identity, REQUEST_DATA_EAP_SESSION); + fr_state_restore_from_parent(request, eap_session->identity, REQUEST_DATA_EAP_SESSION); if (fr_pair_prepend_by_da(request->request_ctx, &vp, &request->request_pairs, attr_packet_type) < 0) return UNLANG_ACTION_FAIL; diff --git a/src/lib/server/state.c b/src/lib/server/state.c index 996e0c783f0..5e16d6f44dd 100644 --- a/src/lib/server/state.c +++ b/src/lib/server/state.c @@ -27,12 +27,12 @@ * entry holds data that should be available during the complete lifecycle * of the authentication attempt. * - * When a request is complete, #fr_request_to_state is called to transfer + * When a request is complete, #fr_state_store is called to transfer * ownership of the state fr_pair_ts and state_ctx (which the fr_pair_ts * are allocated in) to a #fr_state_entry_t. This #fr_state_entry_t holds the * value of the State attribute, that will be send out in the response. * - * When the next request is received, #fr_state_to_request is called to transfer + * When the next request is received, #fr_state_restore is called to transfer * the fr_pair_ts and state ctx to the new request. * * The ownership of the state_ctx and state fr_pair_ts is transferred as below: @@ -619,7 +619,7 @@ void fr_state_discard(fr_state_tree_t *state, request_t *request) PTHREAD_MUTEX_UNLOCK(&state->mutex); /* - * If fr_state_to_request was never called, this ensures + * If fr_state_restore was never called, this ensures * the state owned by entry is freed, otherwise this is * mostly a NOOP, other than freeing the memory held by * the entry. @@ -627,7 +627,7 @@ void fr_state_discard(fr_state_tree_t *state, request_t *request) TALLOC_FREE(entry); /* - * If fr_state_to_request was called, then the request + * If fr_state_restore was called, then the request * holds the existing state data. We need to destroy it, * and return the request to the state it was in when * it was first allocated, just in case a user does something @@ -656,7 +656,7 @@ void fr_state_discard(fr_state_tree_t *state, request_t *request) * - 0 on success (state restored) * - -1 if a state entry has already been thawed by a another request. */ -int fr_state_to_request(fr_state_tree_t *state, request_t *request) +int fr_state_restore(fr_state_tree_t *state, request_t *request) { fr_state_entry_t *entry; fr_pair_t *vp; @@ -733,7 +733,7 @@ int fr_state_to_request(fr_state_tree_t *state, request_t *request) * * Also creates a new state entry. */ -int fr_request_to_state(fr_state_tree_t *state, request_t *request) +int fr_state_store(fr_state_tree_t *state, request_t *request) { fr_state_entry_t *entry, *old; fr_dlist_head_t data; @@ -854,7 +854,7 @@ void fr_state_store_in_parent(request_t *child, void const *unique_ptr, int uniq * or other facility that spawned the subrequest. * @param[in] unique_int Further identification. */ -void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int unique_int) +void fr_state_restore_from_parent(request_t *child, void const *unique_ptr, int unique_int) { state_child_entry_t *child_entry; request_t *request = child; /* Stupid logging */ diff --git a/src/lib/server/state.h b/src/lib/server/state.h index 95d54edebf1..a25e8d49ce7 100644 --- a/src/lib/server/state.h +++ b/src/lib/server/state.h @@ -51,11 +51,11 @@ fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da, f void fr_state_discard(fr_state_tree_t *state, request_t *request); -int fr_state_to_request(fr_state_tree_t *state, request_t *request); -int fr_request_to_state(fr_state_tree_t *state, request_t *request); +int fr_state_restore(fr_state_tree_t *state, request_t *request); +int fr_state_store(fr_state_tree_t *state, request_t *request); void fr_state_store_in_parent(request_t *request, void const *unique_ptr, int unique_int); -void fr_state_restore_to_child(request_t *child, void const *unique_ptr, int unique_int); +void fr_state_restore_from_parent(request_t *child, void const *unique_ptr, int unique_int); void fr_state_discard_child(request_t *parent, void const *unique_ptr, int unique_int); /* diff --git a/src/lib/unlang/parallel.c b/src/lib/unlang/parallel.c index 05b0d28fec3..f227fd82c81 100644 --- a/src/lib/unlang/parallel.c +++ b/src/lib/unlang/parallel.c @@ -357,7 +357,7 @@ static unlang_action_t unlang_parallel(unlang_result_t *p_result, request_t *req * into the child. */ if (state->children[i].config.session_unique_ptr) { - fr_state_restore_to_child(state->children[i].request, + fr_state_restore_from_parent(state->children[i].request, state->children[i].config.session_unique_ptr, state->children[i].num); } diff --git a/src/lib/unlang/subrequest.c b/src/lib/unlang/subrequest.c index 154e10d8139..acb069c7de6 100644 --- a/src/lib/unlang/subrequest.c +++ b/src/lib/unlang/subrequest.c @@ -371,7 +371,7 @@ unlang_action_t unlang_subrequest_child_run(UNUSED unlang_result_t *p_result, UN * Ensure we restore the session state information * into the child. */ - if (cr->config.session_unique_ptr) fr_state_restore_to_child(child, + if (cr->config.session_unique_ptr) fr_state_restore_from_parent(child, cr->config.session_unique_ptr, cr->num); /* diff --git a/src/process/radius/base.c b/src/process/radius/base.c index e82f39d231c..b271ba25d9b 100644 --- a/src/process/radius/base.c +++ b/src/process/radius/base.c @@ -309,7 +309,7 @@ RECV(access_request) { process_radius_t const *inst = talloc_get_type_abort_const(mctx->mi->data, process_radius_t); - if (fr_state_to_request(inst->auth.state_tree, request) < 0) { + if (fr_state_restore(inst->auth.state_tree, request) < 0) { return CALL_SEND_TYPE(FR_RADIUS_CODE_ACCESS_REJECT); } @@ -575,7 +575,7 @@ RESUME(access_challenge) * * If this fails, don't respond to the request. */ - if (!request->parent && fr_request_to_state(inst->auth.state_tree, request) < 0) { + if (!request->parent && fr_state_store(inst->auth.state_tree, request) < 0) { return CALL_SEND_TYPE(FR_RADIUS_CODE_DO_NOT_RESPOND); } diff --git a/src/process/tacacs/base.c b/src/process/tacacs/base.c index a28dffef5c7..a82692eb56b 100644 --- a/src/process/tacacs/base.c +++ b/src/process/tacacs/base.c @@ -730,7 +730,7 @@ send_reply: * Cache the session state context. */ if ((state_create(request->reply_ctx, &request->reply_pairs, request, true) < 0) || - (fr_request_to_state(inst->auth.state_tree, request) < 0)) { + (fr_state_store(inst->auth.state_tree, request) < 0)) { return CALL_SEND_TYPE(FR_TACACS_CODE_AUTH_ERROR); } @@ -743,7 +743,7 @@ RECV(auth_cont) process_tacacs_session_t *session; if ((state_create(request->request_ctx, &request->request_pairs, request, false) < 0) || - (fr_state_to_request(inst->auth.state_tree, request) < 0)) { + (fr_state_restore(inst->auth.state_tree, request) < 0)) { return CALL_SEND_TYPE(FR_TACACS_CODE_AUTH_ERROR); } @@ -810,7 +810,7 @@ RECV(auth_cont_abort) process_tacacs_t const *inst = talloc_get_type_abort_const(mctx->mi->data, process_tacacs_t); if ((state_create(request->request_ctx, &request->request_pairs, request, false) < 0) || - (fr_state_to_request(inst->auth.state_tree, request) < 0)) { + (fr_state_restore(inst->auth.state_tree, request) < 0)) { return CALL_SEND_TYPE(FR_TACACS_CODE_AUTH_ERROR); } diff --git a/src/process/ttls/base.c b/src/process/ttls/base.c index 95ab527838e..b8c360dffe7 100644 --- a/src/process/ttls/base.c +++ b/src/process/ttls/base.c @@ -418,7 +418,7 @@ RESUME(access_challenge) * * If this fails, don't respond to the request. */ - if (fr_request_to_state(inst->auth.state_tree, request) < 0) { + if (fr_state_store(inst->auth.state_tree, request) < 0) { request->reply->code = FR_RADIUS_CODE_DO_NOT_RESPOND; UPDATE_STATE_CS(reply); return CALL_SEND_STATE(state);