The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Allocates an IPv4 address from pools stored in SQL. More...
#include <rlm_sql.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/radius/radius.h>
#include <freeradius-devel/unlang/function.h>
#include <ctype.h>
Go to the source code of this file.
Data Structures | |
struct | ippool_alloc_call_env_t |
Call environment used by module alloc method. More... | |
struct | ippool_alloc_ctx_t |
Resume context for IP allocation. More... | |
struct | ippool_common_call_env_t |
Call environment used by all other module methods. More... | |
struct | ippool_common_ctx_t |
Resume context for IP update / release. More... | |
struct | rlm_sqlippool_t |
Macros | |
#define | LOG_PREFIX inst->name |
#define | QUERY_ESCAPE |
#define | REPEAT_MOD_ALLOC_RESUME if (unlang_function_repeat_set(request, mod_alloc_resume) < 0) RETURN_MODULE_FAIL |
#define | RESERVE_CONNECTION(_handle, _sql, _request) |
#define | SUBMIT_QUERY(_query_str, _new_status, _type, _function) |
Enumerations | |
enum | ippool_alloc_status_t { IPPOOL_ALLOC_BEGIN_RUN , IPPOOL_ALLOC_EXISTING , IPPOOL_ALLOC_EXISTING_RUN , IPPOOL_ALLOC_REQUESTED , IPPOOL_ALLOC_REQUESTED_RUN , IPPOOL_ALLOC_FIND , IPPOOL_ALLOC_FIND_RUN , IPPOOL_ALLOC_NO_ADDRESS , IPPOOL_ALLOC_POOL_CHECK , IPPOOL_ALLOC_POOL_CHECK_RUN , IPPOOL_ALLOC_MAKE_PAIR , IPPOOL_ALLOC_UPDATE , IPPOOL_ALLOC_UPDATE_RUN , IPPOOL_ALLOC_COMMIT_RUN } |
Current step in IP allocation state machine. More... | |
Functions | |
static int | _sql_escape_uxtx_free (void *uctx) |
static int | call_env_parse (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule) |
Custom parser for sqlippool call env. More... | |
static unlang_action_t | mod_alloc (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
Initiate the allocation of an IP address from the pool. More... | |
static unlang_action_t | mod_alloc_resume (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
Resume function called after each IP allocation query is expanded. More... | |
static unlang_action_t | mod_common (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
Common function used by module methods which perform an optional "free" then "update". More... | |
static unlang_action_t | mod_common_free_resume (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
Resume function called after mod_common "free" query has completed. More... | |
static unlang_action_t | mod_common_update_resume (rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx) |
Resume function called after mod_common "update" query has completed. More... | |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static void * | sql_escape_uctx_alloc (request_t *request, void const *uctx) |
static int | sqlippool_alloc_ctx_free (ippool_alloc_ctx_t *to_free) |
Release SQL pool connections when alloc context is freed. More... | |
static int | sqlippool_box_escape (fr_value_box_t *vb, void *uctx) |
Call SQL module box_escape_func to escape tainted values. More... | |
static int | sqlippool_common_ctx_free (ippool_common_ctx_t *to_free) |
Return connection to pool when mod_common context is freed. More... | |
static int | sqlippool_result_process (char *out, int outlen, fr_sql_query_t *query_ctx) |
Variables | |
static conf_parser_t | module_config [] |
module_rlm_t | rlm_sqlippool |
static const call_env_method_t | sqlippool_alloc_method_env |
static const call_env_method_t | sqlippool_bulk_release_method_env |
static const call_env_method_t | sqlippool_mark_method_env |
static const call_env_method_t | sqlippool_release_method_env |
static const call_env_method_t | sqlippool_update_method_env |
Allocates an IPv4 address from pools stored in SQL.
Definition in file rlm_sqlippool.c.
struct ippool_alloc_call_env_t |
Call environment used by module alloc method.
Definition at line 49 of file rlm_sqlippool.c.
Data Fields | ||
---|---|---|
fr_value_box_t | allocated_address | Existing value for allocated IP. |
tmpl_t * | allocated_address_attr | Attribute to populate with allocated IP. |
fr_value_box_t | begin | SQL query to begin transaction. |
fr_value_box_t | commit | SQL query to commit transaction. |
tmpl_t * | existing | tmpl to expand as query for finding the existing IP. |
tmpl_t * | find | tmpl to expand as query for finding an unused IP. |
tmpl_t * | pool_check | tmpl to expand as query for checking for existence of the pool. |
fr_value_box_t | pool_name | Name of pool address will be allocated from. |
tmpl_t * | pool_name_tmpl | Tmpl used to expand pool_name. |
tmpl_t * | requested | tmpl to expand as query for finding the requested IP. |
fr_value_box_t | requested_address | IP address being requested by client. |
tmpl_t * | update | tmpl to expand as query for updating the found IP. |
struct ippool_alloc_ctx_t |
Resume context for IP allocation.
Definition at line 92 of file rlm_sqlippool.c.
Data Fields | ||
---|---|---|
ippool_alloc_call_env_t * | env | Call environment for the allocation. |
rlm_sql_handle_t * | handle | SQL handle being used for queries. |
fr_value_box_t * | query | Current query being run. |
fr_sql_query_t * | query_ctx | Query context for allocation queries. |
rlm_rcode_t | rcode | Result code to return after running "commit". |
request_t * | request | Current request. |
rlm_sql_t const * | sql | SQL module instance. |
ippool_alloc_status_t | status | Status of the allocation. |
trunk_t * | trunk | Trunk connection for queries. |
fr_value_box_list_t | values | Where to put the expanded queries ready for execution. |
struct ippool_common_call_env_t |
Call environment used by all other module methods.
Definition at line 66 of file rlm_sqlippool.c.
Data Fields | ||
---|---|---|
fr_value_box_t | free | SQL query to clear other offered IPs. Only used in "update" method. |
fr_value_box_t | update | SQL query to update an IP record. |
struct ippool_common_ctx_t |
Resume context for IP update / release.
Definition at line 107 of file rlm_sqlippool.c.
Data Fields | ||
---|---|---|
ippool_common_call_env_t * | env | Call environment for the update. |
rlm_sql_handle_t * | handle | SQL handle being used for queries. |
fr_sql_query_t * | query_ctx | Query context for allocation queries. |
request_t * | request | Current request. |
rlm_sql_t const * | sql | SQL module instance. |
struct rlm_sqlippool_t |
Definition at line 40 of file rlm_sqlippool.c.
Data Fields | ||
---|---|---|
char const * | name | |
rlm_sql_t const * | sql | |
char const * | sql_name |
Definition at line 28 of file rlm_sqlippool.c.
#define QUERY_ESCAPE |
Definition at line 722 of file rlm_sqlippool.c.
#define REPEAT_MOD_ALLOC_RESUME if (unlang_function_repeat_set(request, mod_alloc_resume) < 0) RETURN_MODULE_FAIL |
Definition at line 242 of file rlm_sqlippool.c.
#define RESERVE_CONNECTION | ( | _handle, | |
_sql, | |||
_request | |||
) |
Definition at line 145 of file rlm_sqlippool.c.
#define SUBMIT_QUERY | ( | _query_str, | |
_new_status, | |||
_type, | |||
_function | |||
) |
Definition at line 243 of file rlm_sqlippool.c.
Current step in IP allocation state machine.
Definition at line 73 of file rlm_sqlippool.c.
|
static |
Definition at line 121 of file rlm_sqlippool.c.
|
static |
Custom parser for sqlippool call env.
Needed as the escape function needs to reference the correct instance of the SQL module since escaping functions are dependent on the driver used by a given module instance.
Definition at line 689 of file rlm_sqlippool.c.
|
static |
Initiate the allocation of an IP address from the pool.
Based on configured queries and attributes which exist, determines the first query tmpl to expand.
p_result | Result of the allocation (if it fails). |
mctx | Module context. |
request | Current request. |
Definition at line 505 of file rlm_sqlippool.c.
|
static |
Resume function called after each IP allocation query is expanded.
Executes the query and, if appropriate, pushes the next tmpl for expansion
Following the final (successful) query, the destination attribute is populated.
p_result | Result of IP allocation. |
priority | Unused. |
request | Current request. |
uctx | Current allocation context. |
Definition at line 265 of file rlm_sqlippool.c.
|
static |
Common function used by module methods which perform an optional "free" then "update".
Definition at line 630 of file rlm_sqlippool.c.
|
static |
Resume function called after mod_common "free" query has completed.
Definition at line 589 of file rlm_sqlippool.c.
|
static |
Resume function called after mod_common "update" query has completed.
Definition at line 564 of file rlm_sqlippool.c.
|
static |
|
static |
Definition at line 126 of file rlm_sqlippool.c.
|
static |
Release SQL pool connections when alloc context is freed.
Definition at line 235 of file rlm_sqlippool.c.
|
static |
Call SQL module box_escape_func to escape tainted values.
Definition at line 677 of file rlm_sqlippool.c.
|
static |
Return connection to pool when mod_common context is freed.
Definition at line 618 of file rlm_sqlippool.c.
|
static |
Definition at line 157 of file rlm_sqlippool.c.
|
static |
Definition at line 115 of file rlm_sqlippool.c.
module_rlm_t rlm_sqlippool |
Definition at line 807 of file rlm_sqlippool.c.
|
static |
Definition at line 728 of file rlm_sqlippool.c.
|
static |
Definition at line 779 of file rlm_sqlippool.c.
|
static |
Definition at line 788 of file rlm_sqlippool.c.
|
static |
Definition at line 770 of file rlm_sqlippool.c.
|
static |
Definition at line 759 of file rlm_sqlippool.c.