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 | rlm_sqlippool_t |
Macros | |
#define | DO_AFFECTED(_x, _affected) |
#define | DO_PART(_x) |
#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, _pool, _request) |
Enumerations | |
enum | ippool_alloc_status_t { IPPOOL_ALLOC_EXISTING , IPPOOL_ALLOC_REQUESTED , IPPOOL_ALLOC_FIND , IPPOOL_ALLOC_POOL_CHECK , IPPOOL_ALLOC_UPDATE } |
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, UNUSED char const *section_name1, UNUSED char const *section_name2, void const *data, 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 int | mod_bootstrap (module_inst_ctx_t const *mctx) |
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 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_command (char const *query, rlm_sql_handle_t **handle, rlm_sql_t const *sql, request_t *request) |
Perform a single sqlippool query. More... | |
static int | sqlippool_query1 (char *out, int outlen, char const *query, rlm_sql_handle_t **handle, rlm_sql_t const *sql, request_t *request) |
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 83 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. |
request_t * | request | Current request. |
rlm_sql_t const * | sql | SQL module instance. |
ippool_alloc_status_t | status | Status of the allocation. |
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 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 |
#define DO_AFFECTED | ( | _x, | |
_affected | |||
) |
Definition at line 167 of file rlm_sqlippool.c.
#define DO_PART | ( | _x | ) |
Definition at line 164 of file rlm_sqlippool.c.
Definition at line 28 of file rlm_sqlippool.c.
#define QUERY_ESCAPE |
Definition at line 626 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 277 of file rlm_sqlippool.c.
#define RESERVE_CONNECTION | ( | _handle, | |
_pool, | |||
_request | |||
) |
Definition at line 170 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 98 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 593 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 475 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 291 of file rlm_sqlippool.c.
|
static |
Definition at line 226 of file rlm_sqlippool.c.
|
static |
Common function used by module methods which perform an optional "free" then "update".
Definition at line 550 of file rlm_sqlippool.c.
|
static |
|
static |
Definition at line 103 of file rlm_sqlippool.c.
|
static |
Release SQL pool connections when alloc context is freed.
Definition at line 270 of file rlm_sqlippool.c.
|
static |
Call SQL module box_escape_func to escape tainted values.
Definition at line 581 of file rlm_sqlippool.c.
|
static |
Perform a single sqlippool query.
Mostly wrapper around sql_query which returns the number of affected rows.
[in] | query | sql query to execute. |
[in] | handle | sql connection handle. |
[in] | sql | Instance of rlm_sql. |
[in] | request | Current request. |
Definition at line 131 of file rlm_sqlippool.c.
|
static |
Definition at line 180 of file rlm_sqlippool.c.
|
static |
Definition at line 92 of file rlm_sqlippool.c.
module_rlm_t rlm_sqlippool |
Definition at line 709 of file rlm_sqlippool.c.
|
static |
Definition at line 632 of file rlm_sqlippool.c.
|
static |
Definition at line 681 of file rlm_sqlippool.c.
|
static |
Definition at line 690 of file rlm_sqlippool.c.
|
static |
Definition at line 672 of file rlm_sqlippool.c.
|
static |
Definition at line 661 of file rlm_sqlippool.c.