]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add new macros for calling the next send function and overriding reply codes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 15 Sep 2021 17:05:49 +0000 (12:05 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 15 Sep 2021 17:05:49 +0000 (12:05 -0500)
src/lib/server/process.h
src/process/radius/base.c

index 0fd86bc75ee74fc9464efc70e8a808ac7badaded..d2be7b7459f886cc3281ee39751812f34faea4d6 100644 (file)
@@ -117,11 +117,26 @@ static fr_process_state_t const process_state[];
 #define RESUME_NO_RCTX(_x) static inline unlang_action_t resume_ ## _x(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, UNUSED void *rctx)
 #define RESUME_NO_MCTX(_x) static inline unlang_action_t resume_ ## _x(rlm_rcode_t *p_result, UNUSED module_ctx_t const *mctx, request_t *request, UNUSED void *rctx)
 
-
+/** Call a named recv function directly
+ */
 #define CALL_RECV(_x) recv_ ## _x(p_result, mctx, request);
+
+/** Call a named send function directly
+ */
 #define CALL_SEND(_x) send_ ## _x(p_result, mctx, request, rctx)
+
+/** Call a named resume function directly
+ */
 #define CALL_RESUME(_x) resume_ ## _x(p_result, mctx, request, rctx)
 
+/** Set the current reply code, and call the send function for that state
+ */
+#define CALL_SEND_TYPE(_x) process_state[(request->reply->code = _x)].send(p_result, mctx, request, rctx)
+
+/** Call the send function for the current state
+ */
+#define CALL_SEND_STATE(_state) state->send(p_result, mctx, request, rctx)
+
 RECV(generic)
 {
        CONF_SECTION                    *cs;
index 6bc6a3640072f853492e5dc8261f2ec8ec846c99..d3aa79316f49edf28541a39fae12abb6c2ed43e5 100644 (file)
@@ -357,6 +357,7 @@ static void CC_HINT(format (printf, 4, 5)) auth_message(process_radius_auth_t co
 RECV(access_request)
 {
        process_radius_t const          *inst = talloc_get_type_abort_const(mctx->instance, process_radius_t);
+       void                            *rctx = NULL;
 
        /*
         *      Only reject if the state has already been thawed.
@@ -364,8 +365,7 @@ RECV(access_request)
         *      for us, and we're just proxying upstream.
         */
        if (fr_state_to_request(inst->auth.state_tree, request) < 0) {
-               request->reply->code = FR_RADIUS_CODE_ACCESS_REJECT;
-               return CALL_SEND(generic);
+               return CALL_SEND_TYPE(FR_RADIUS_CODE_ACCESS_REJECT);
        }
 
        return CALL_RECV(generic);
@@ -399,9 +399,7 @@ RESUME(access_request)
 
        send_reply:
                fr_assert(state->send != NULL);
-               return unlang_module_yield_to_section(p_result, request,
-                                                     cs, state->rcode, state->send,
-                                                     NULL, NULL);
+               return CALL_SEND_STATE(state);
        }
 
        /*
@@ -608,8 +606,7 @@ RESUME(access_challenge)
         *      If this fails, don't respond to the request.
         */
        if (fr_request_to_state(inst->auth.state_tree, request) < 0) {
-               request->reply->code = FR_RADIUS_CODE_DO_NOT_RESPOND;
-               return CALL_SEND(generic);
+               return CALL_SEND_TYPE(FR_RADIUS_CODE_DO_NOT_RESPOND);
        }
 
        fr_assert(request->reply->code == FR_RADIUS_CODE_ACCESS_CHALLENGE);
@@ -679,9 +676,7 @@ RESUME(accounting_request)
 
        send_reply:
                fr_assert(state->send != NULL);
-               return unlang_module_yield_to_section(p_result, request,
-                                                     cs, state->rcode, state->send,
-                                                     NULL, rctx);
+               return CALL_SEND_STATE(state);
        }
 
        /*