Register many xlat expansions including the expr expansion. More...
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/md5.h>
#include <freeradius-devel/sha1.h>
#include <freeradius-devel/base64.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h>
#include <ctype.h>
#include "rlm_expr.h"
Go to the source code of this file.
Data Structures | |
struct | expr_map_t |
struct | rlm_expr_t |
Typedefs | |
typedef struct expr_map_t | expr_map_t |
typedef enum expr_token_t | expr_token_t |
typedef USES_APPLE_DEPRECATED_API struct rlm_expr_t | rlm_expr_t |
Enumerations | |
enum | expr_token_t { TOKEN_NONE = 0, TOKEN_INTEGER, TOKEN_AND, TOKEN_OR, TOKEN_LSHIFT, TOKEN_RSHIFT, TOKEN_ADD, TOKEN_SUBTRACT, TOKEN_DIVIDE, TOKEN_REMAINDER, TOKEN_MULTIPLY, TOKEN_POWER, TOKEN_LAST } |
Functions | |
static ssize_t | base64_to_hex_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Convert base64 to hex. More... | |
static ssize_t | base64_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Encode string or attribute as base64. More... | |
static bool | calc_result (REQUEST *request, int64_t lhs, expr_token_t op, int64_t rhs, int64_t *answer) |
static ssize_t | escape_xlat (char **out, size_t outlen, void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
Equivalent to the old safe_characters functionality in rlm_sql but with utf8 support. More... | |
static ssize_t | explode_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Split an attribute into multiple new attributes based on a delimiter. More... | |
static ssize_t | expr_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
static int64_t | fr_pow (int64_t base, int64_t exp) |
Calculate powers. More... | |
static bool | get_expression (REQUEST *request, char const **string, int64_t *answer, expr_token_t prev) |
static bool | get_number (REQUEST *request, char const **string, int64_t *answer) |
static bool | get_operator (REQUEST *request, char const **string, expr_token_t *op) |
static ssize_t | hmac_md5_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Calculate any digest supported by OpenSSL EVP_MD. More... | |
static ssize_t | hmac_sha1_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Generate the HMAC-SHA1 of a string or attribute. More... | |
static ssize_t | lc_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
Convert a string to lowercase. More... | |
static ssize_t | lpad_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
left pad a string More... | |
static ssize_t | md5_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Calculate the MD5 hash of a string or attribute. More... | |
static int | mod_bootstrap (CONF_SECTION *conf, void *instance) |
static ssize_t | next_time_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Calculate number of seconds until the next n hour(s), day(s), week(s), year(s). More... | |
static ssize_t | pairs_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Encode attributes as a series of string attribute/value pairs. More... | |
static bool | parse_pad (REQUEST *request, char const *fmt, vp_tmpl_t **pvpt, size_t *plength, char *fill) |
static ssize_t | rand_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
Generate a random integer value. More... | |
static ssize_t | randstr_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
Generate a string of random chars. More... | |
static ssize_t | rpad_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
right pad a string More... | |
static ssize_t | sha1_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
Calculate the SHA1 hash of a string or attribute. More... | |
static ssize_t | uc_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
Convert a string to uppercase. More... | |
static ssize_t | unescape_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
Equivalent to the old safe_characters functionality in rlm_sql. More... | |
static ssize_t | urlquote_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, UNUSED REQUEST *request, char const *fmt) |
URLencode special characters. More... | |
static ssize_t | urlunquote_xlat (char **out, size_t outlen, UNUSED void const *mod_inst, UNUSED void const *xlat_inst, REQUEST *request, char const *fmt) |
URLdecode special characters. More... | |
Variables | |
static char const | hextab [] = "0123456789abcdef" |
static expr_map_t | map [] |
static const CONF_PARSER | module_config [] |
static int | precedence [TOKEN_LAST+1] |
static char | randstr_otp [] = "469ACGHJKLMNPQRUVWXYabdfhijkprstuvwxyz" |
static char | randstr_punc [] = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" |
static char | randstr_salt [] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz/." |
module_t | rlm_expr |
Register many xlat expansions including the expr expansion.
Definition in file rlm_expr.c.
struct expr_map_t |
Definition at line 164 of file rlm_expr.c.
Data Fields | ||
---|---|---|
char | op | |
expr_token_t | token |
struct rlm_expr_t |
Definition at line 46 of file rlm_expr.c.
Data Fields | ||
---|---|---|
char const * | allowed_chars | |
char const * | xlat_name |
typedef struct expr_map_t expr_map_t |
typedef enum expr_token_t expr_token_t |
typedef USES_APPLE_DEPRECATED_API struct rlm_expr_t rlm_expr_t |
enum expr_token_t |
Enumerator | |
---|---|
TOKEN_NONE | |
TOKEN_INTEGER | |
TOKEN_AND | |
TOKEN_OR | |
TOKEN_LSHIFT | |
TOKEN_RSHIFT | |
TOKEN_ADD | |
TOKEN_SUBTRACT | |
TOKEN_DIVIDE | |
TOKEN_REMAINDER | |
TOKEN_MULTIPLY | |
TOKEN_POWER | |
TOKEN_LAST |
Definition at line 136 of file rlm_expr.c.
|
static |
Convert base64 to hex.
Example: "%{base64tohex:Zm9v}" == "666f6f"
Definition at line 1226 of file rlm_expr.c.
|
static |
Encode string or attribute as base64.
Example: "%{base64:foo}" == "Zm9v"
Definition at line 1198 of file rlm_expr.c.
|
static |
Definition at line 315 of file rlm_expr.c.
|
static |
Equivalent to the old safe_characters functionality in rlm_sql but with utf8 support.
Example: "%{escape:<img>foo.jpg</img>}" == "=60img=62foo.jpg=60/img=62"
Definition at line 775 of file rlm_expr.c.
|
static |
Split an attribute into multiple new attributes based on a delimiter.
Example: "%{explode:&ref <delim>}"
Definition at line 1256 of file rlm_expr.c.
|
static |
Definition at line 489 of file rlm_expr.c.
|
static |
Calculate powers.
base | a 32bit signed integer. |
exp | amount to raise base by. |
Definition at line 79 of file rlm_expr.c.
|
static |
Definition at line 426 of file rlm_expr.c.
|
static |
Definition at line 184 of file rlm_expr.c.
|
static |
|
static |
Calculate any digest supported by OpenSSL EVP_MD.
Example: "%{sha256:foo}" == "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" Generate the HMAC-MD5 of a string or attribute
Example: "%{hmacmd5:foo bar}" == "Zm9v"
Definition at line 1046 of file rlm_expr.c.
|
static |
Generate the HMAC-SHA1 of a string or attribute.
Example: "%{hmacsha1:foo bar}" == "Zm9v"
Definition at line 1093 of file rlm_expr.c.
|
static |
Convert a string to lowercase.
Example: "%{tolower:Bar}" == "bar"
Probably only works for ASCII
Definition at line 883 of file rlm_expr.c.
|
static |
left pad a string
%{lpad:&Attribute-Name length 'x'}
Definition at line 1542 of file rlm_expr.c.
|
static |
Calculate the MD5 hash of a string or attribute.
Example: "%{md5:foo}" == "acbd18db4cc2f85cedef654fccc4a4d8"
Definition at line 933 of file rlm_expr.c.
|
static |
|
static |
Calculate number of seconds until the next n hour(s), day(s), week(s), year(s).
For example, if it were 16:18 %{nexttime:1h} would expand to 2520.
The envisaged usage for this function is to limit sessions so that they don't cross billing periods. The output of the xlat should be combined with %{rand:} to create some jitter, unless the desired effect is every subscriber on the network re-authenticating at the same time.
Definition at line 1393 of file rlm_expr.c.
|
static |
Encode attributes as a series of string attribute/value pairs.
This is intended to serialize one or more attributes as a comma delimited string.
Example: "%{pairs:request:}" == "User-Name = 'foo', User-Password = 'bar'"
Definition at line 1143 of file rlm_expr.c.
|
static |
Definition at line 1464 of file rlm_expr.c.
|
static |
Generate a random integer value.
Definition at line 514 of file rlm_expr.c.
|
static |
Generate a string of random chars.
Build strings of random chars, useful for generating tokens and passcodes Format similar to String::Random.
Definition at line 540 of file rlm_expr.c.
|
static |
right pad a string
%{rpad:&Attribute-Name length 'x'}
Definition at line 1582 of file rlm_expr.c.
|
static |
Calculate the SHA1 hash of a string or attribute.
Example: "%{sha1:foo}" == "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
Definition at line 965 of file rlm_expr.c.
|
static |
Convert a string to uppercase.
Example: "%{toupper:Foo}" == "FOO"
Probably only works for ASCII
Definition at line 909 of file rlm_expr.c.
|
static |
Equivalent to the old safe_characters functionality in rlm_sql.
Example: "%{unescape:=60img=62foo.jpg=60/img=62}" == "<img>foo.jpg</img>"
Definition at line 842 of file rlm_expr.c.
|
static |
URLencode special characters.
Example: "%{urlquote:http://example.org/}" == "http%3A%47%47example.org%47"
Definition at line 688 of file rlm_expr.c.
|
static |
URLdecode special characters.
Example: "%{urlunquote:http%%3A%%47%%47example.org%%47}" == "http://example.org/"
Remember to escape % with %% in strings, else xlat will try to parse it.
Definition at line 737 of file rlm_expr.c.
|
static |
Definition at line 68 of file rlm_expr.c.
|
static |
Definition at line 169 of file rlm_expr.c.
|
static |
Definition at line 51 of file rlm_expr.c.
|
static |
Definition at line 157 of file rlm_expr.c.
|
static |
Definition at line 66 of file rlm_expr.c.
|
static |
Definition at line 59 of file rlm_expr.c.
|
static |
Definition at line 60 of file rlm_expr.c.
module_t rlm_expr |
Definition at line 1682 of file rlm_expr.c.