]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add functions to set and get current request from Python thread state
authorNick Porter <nick@portercomputing.co.uk>
Wed, 16 Apr 2025 10:35:53 +0000 (11:35 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 21 Apr 2025 11:30:21 +0000 (12:30 +0100)
src/modules/rlm_python/rlm_python.c

index 007beacb685ed6b4fbac15e19fddf77f8efa49ff..f6b518ac3d5a35bd22fa5ad1c1831913b1476d7c 100644 (file)
@@ -297,6 +297,32 @@ static rlm_python_t const *rlm_python_get_inst(void)
        return p_state->inst;
 }
 
+/** Return the request associated with the current thread state
+ *
+ */
+static request_t *rlm_python_get_request(void)
+{
+       py_freeradius_state_t const *p_state;
+
+       p_state = rlm_python_state_obj();
+       if (unlikely(!p_state)) return NULL;
+
+       return p_state->request;
+}
+
+/** Set the request associated with the current thread state
+ *
+ */
+static void rlm_python_set_request(request_t *request)
+{
+       py_freeradius_state_t *p_state;
+
+       p_state = rlm_python_state_obj();
+       if (unlikely(!p_state)) return;
+
+       p_state->request = request;
+}
+
 /** Allow fr_log to be called from python
  *
  */