mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: converters: give the session pointer as converter argument
Some usages of the converters need to know the attached session. The Lua needs the session for retrieving his running context. This patch adds the "session" as an argument of the converters prototype.
This commit is contained in:
parent
1edc971919
commit
68a556e282
@ -260,8 +260,9 @@ struct sample_storage {
|
|||||||
/* Descriptor for a sample conversion */
|
/* Descriptor for a sample conversion */
|
||||||
struct sample_conv {
|
struct sample_conv {
|
||||||
const char *kw; /* configuration keyword */
|
const char *kw; /* configuration keyword */
|
||||||
int (*process)(const struct arg *arg_p,
|
int (*process)(struct session *session,
|
||||||
struct sample *smp,
|
const struct arg *arg_p,
|
||||||
|
struct sample *smp,
|
||||||
void *private); /* process function */
|
void *private); /* process function */
|
||||||
unsigned int arg_mask; /* arguments (ARG*()) */
|
unsigned int arg_mask; /* arguments (ARG*()) */
|
||||||
int (*val_args)(struct arg *arg_p,
|
int (*val_args)(struct arg *arg_p,
|
||||||
|
@ -184,7 +184,8 @@ static int sample_load_map(struct arg *arg, struct sample_conv *conv,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_map(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct map_descriptor *desc;
|
struct map_descriptor *desc;
|
||||||
struct pattern *pat;
|
struct pattern *pat;
|
||||||
|
@ -11377,7 +11377,8 @@ static int val_hdr(struct arg *arg, char **err_msg)
|
|||||||
* adds an optional offset found in args[0] and emits a string representing
|
* adds an optional offset found in args[0] and emits a string representing
|
||||||
* the date in RFC-1123/5322 format.
|
* the date in RFC-1123/5322 format.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_http_date(const struct arg *args, struct sample *smp, void *private)
|
static int sample_conv_http_date(struct session *session, const struct arg *args,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
const char day[7][4] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
|
const char day[7][4] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
|
||||||
const char mon[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
const char mon[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||||
@ -11428,7 +11429,8 @@ static inline int language_range_match(const char *range, int range_len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Arguments: The list of expected value, the number of parts returned and the separator */
|
/* Arguments: The list of expected value, the number of parts returned and the separator */
|
||||||
static int sample_conv_q_prefered(const struct arg *args, struct sample *smp, void *private)
|
static int sample_conv_q_prefered(struct session *session, const struct arg *args,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
const char *al = smp->data.str.str;
|
const char *al = smp->data.str.str;
|
||||||
const char *end = al + smp->data.str.len;
|
const char *end = al + smp->data.str.len;
|
||||||
|
92
src/sample.c
92
src/sample.c
@ -967,7 +967,7 @@ struct sample *sample_process(struct proxy *px, struct session *l4, void *l7,
|
|||||||
|
|
||||||
/* OK cast succeeded */
|
/* OK cast succeeded */
|
||||||
|
|
||||||
if (!conv_expr->conv->process(conv_expr->arg_p, p, conv_expr->conv->private))
|
if (!conv_expr->conv->process(l4, conv_expr->arg_p, p, conv_expr->conv->private))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
@ -1275,7 +1275,8 @@ struct sample *sample_fetch_string(struct proxy *px, struct session *l4, void *l
|
|||||||
/* These functions set the data type on return. */
|
/* These functions set the data type on return. */
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
|
||||||
static int sample_conv_bin2base64(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_bin2base64(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct chunk *trash = get_trash_chunk();
|
struct chunk *trash = get_trash_chunk();
|
||||||
int b64_len;
|
int b64_len;
|
||||||
@ -1292,7 +1293,8 @@ static int sample_conv_bin2base64(const struct arg *arg_p, struct sample *smp, v
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_bin2hex(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct chunk *trash = get_trash_chunk();
|
struct chunk *trash = get_trash_chunk();
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@ -1311,7 +1313,8 @@ static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* hashes the binary input into a 32-bit unsigned int */
|
/* hashes the binary input into a 32-bit unsigned int */
|
||||||
static int sample_conv_djb2(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_djb2(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = hash_djb2(smp->data.str.str, smp->data.str.len);
|
smp->data.uint = hash_djb2(smp->data.str.str, smp->data.str.len);
|
||||||
if (arg_p && arg_p->data.uint)
|
if (arg_p && arg_p->data.uint)
|
||||||
@ -1320,7 +1323,8 @@ static int sample_conv_djb2(const struct arg *arg_p, struct sample *smp, void *p
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_str2lower(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1337,7 +1341,8 @@ static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_str2upper(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1355,7 +1360,8 @@ static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* takes the netmask in arg_p */
|
/* takes the netmask in arg_p */
|
||||||
static int sample_conv_ipmask(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_ipmask(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.ipv4.s_addr &= arg_p->data.ipv4.s_addr;
|
smp->data.ipv4.s_addr &= arg_p->data.ipv4.s_addr;
|
||||||
smp->type = SMP_T_IPV4;
|
smp->type = SMP_T_IPV4;
|
||||||
@ -1366,7 +1372,8 @@ static int sample_conv_ipmask(const struct arg *arg_p, struct sample *smp, void
|
|||||||
* adds an optional offset found in args[1] and emits a string representing
|
* adds an optional offset found in args[1] and emits a string representing
|
||||||
* the local time in the format specified in args[1] using strftime().
|
* the local time in the format specified in args[1] using strftime().
|
||||||
*/
|
*/
|
||||||
static int sample_conv_ltime(const struct arg *args, struct sample *smp, void *private)
|
static int sample_conv_ltime(struct session *session, const struct arg *args,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct chunk *temp;
|
struct chunk *temp;
|
||||||
time_t curr_date = smp->data.uint;
|
time_t curr_date = smp->data.uint;
|
||||||
@ -1383,7 +1390,8 @@ static int sample_conv_ltime(const struct arg *args, struct sample *smp, void *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* hashes the binary input into a 32-bit unsigned int */
|
/* hashes the binary input into a 32-bit unsigned int */
|
||||||
static int sample_conv_sdbm(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_sdbm(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = hash_sdbm(smp->data.str.str, smp->data.str.len);
|
smp->data.uint = hash_sdbm(smp->data.str.str, smp->data.str.len);
|
||||||
if (arg_p && arg_p->data.uint)
|
if (arg_p && arg_p->data.uint)
|
||||||
@ -1396,7 +1404,8 @@ static int sample_conv_sdbm(const struct arg *arg_p, struct sample *smp, void *p
|
|||||||
* adds an optional offset found in args[1] and emits a string representing
|
* adds an optional offset found in args[1] and emits a string representing
|
||||||
* the UTC date in the format specified in args[1] using strftime().
|
* the UTC date in the format specified in args[1] using strftime().
|
||||||
*/
|
*/
|
||||||
static int sample_conv_utime(const struct arg *args, struct sample *smp, void *private)
|
static int sample_conv_utime(struct session *session, const struct arg *args,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct chunk *temp;
|
struct chunk *temp;
|
||||||
time_t curr_date = smp->data.uint;
|
time_t curr_date = smp->data.uint;
|
||||||
@ -1413,7 +1422,8 @@ static int sample_conv_utime(const struct arg *args, struct sample *smp, void *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* hashes the binary input into a 32-bit unsigned int */
|
/* hashes the binary input into a 32-bit unsigned int */
|
||||||
static int sample_conv_wt6(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_wt6(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = hash_wt6(smp->data.str.str, smp->data.str.len);
|
smp->data.uint = hash_wt6(smp->data.str.str, smp->data.str.len);
|
||||||
if (arg_p && arg_p->data.uint)
|
if (arg_p && arg_p->data.uint)
|
||||||
@ -1423,7 +1433,8 @@ static int sample_conv_wt6(const struct arg *arg_p, struct sample *smp, void *pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* hashes the binary input into a 32-bit unsigned int */
|
/* hashes the binary input into a 32-bit unsigned int */
|
||||||
static int sample_conv_crc32(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_crc32(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = hash_crc32(smp->data.str.str, smp->data.str.len);
|
smp->data.uint = hash_crc32(smp->data.str.str, smp->data.str.len);
|
||||||
if (arg_p && arg_p->data.uint)
|
if (arg_p && arg_p->data.uint)
|
||||||
@ -1503,7 +1514,8 @@ static int sample_conv_json_check(struct arg *arg, struct sample_conv *conv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample_conv_json(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_json(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct chunk *temp;
|
struct chunk *temp;
|
||||||
char _str[7]; /* \u + 4 hex digit + null char for sprintf. */
|
char _str[7]; /* \u + 4 hex digit + null char for sprintf. */
|
||||||
@ -1617,7 +1629,8 @@ static int sample_conv_json(const struct arg *arg_p, struct sample *smp, void *p
|
|||||||
/* This sample function is designed to extract some bytes from an input buffer.
|
/* This sample function is designed to extract some bytes from an input buffer.
|
||||||
* First arg is the offset.
|
* First arg is the offset.
|
||||||
* Optional second arg is the length to truncate */
|
* Optional second arg is the length to truncate */
|
||||||
static int sample_conv_bytes(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_bytes(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
if (smp->data.str.len <= arg_p[0].data.uint) {
|
if (smp->data.str.len <= arg_p[0].data.uint) {
|
||||||
smp->data.str.len = 0;
|
smp->data.str.len = 0;
|
||||||
@ -1674,7 +1687,8 @@ static int sample_conv_field_check(struct arg *args, struct sample_conv *conv,
|
|||||||
* First arg is the index of the field (start at 1)
|
* First arg is the index of the field (start at 1)
|
||||||
* Second arg is a char list of separators (type string)
|
* Second arg is a char list of separators (type string)
|
||||||
*/
|
*/
|
||||||
static int sample_conv_field(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_field(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
unsigned int field;
|
unsigned int field;
|
||||||
char *start, *end;
|
char *start, *end;
|
||||||
@ -1725,7 +1739,8 @@ found:
|
|||||||
* First arg is the index of the word (start at 1)
|
* First arg is the index of the word (start at 1)
|
||||||
* Second arg is a char list of words separators (type string)
|
* Second arg is a char list of words separators (type string)
|
||||||
*/
|
*/
|
||||||
static int sample_conv_word(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_word(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
unsigned int word;
|
unsigned int word;
|
||||||
char *start, *end;
|
char *start, *end;
|
||||||
@ -1819,7 +1834,8 @@ static int sample_conv_regsub_check(struct arg *args, struct sample_conv *conv,
|
|||||||
* location until nothing matches anymore. First arg is the regex to apply to
|
* location until nothing matches anymore. First arg is the regex to apply to
|
||||||
* the input string, second arg is the replacement expression.
|
* the input string, second arg is the replacement expression.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_regsub(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_regsub(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
char *start, *end;
|
char *start, *end;
|
||||||
struct my_regex *reg = arg_p[0].data.reg;
|
struct my_regex *reg = arg_p[0].data.reg;
|
||||||
@ -1891,7 +1907,8 @@ static int sample_conv_regsub(const struct arg *arg_p, struct sample *smp, void
|
|||||||
/* Takes a UINT on input, applies a binary twos complement and returns the UINT
|
/* Takes a UINT on input, applies a binary twos complement and returns the UINT
|
||||||
* result.
|
* result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_binary_cpl(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_binary_cpl(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = ~smp->data.uint;
|
smp->data.uint = ~smp->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1900,7 +1917,8 @@ static int sample_conv_binary_cpl(const struct arg *arg_p, struct sample *smp, v
|
|||||||
/* Takes a UINT on input, applies a binary "and" with the UINT in arg_p, and
|
/* Takes a UINT on input, applies a binary "and" with the UINT in arg_p, and
|
||||||
* returns the UINT result.
|
* returns the UINT result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_binary_and(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_binary_and(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint &= arg_p->data.uint;
|
smp->data.uint &= arg_p->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1909,7 +1927,8 @@ static int sample_conv_binary_and(const struct arg *arg_p, struct sample *smp, v
|
|||||||
/* Takes a UINT on input, applies a binary "or" with the UINT in arg_p, and
|
/* Takes a UINT on input, applies a binary "or" with the UINT in arg_p, and
|
||||||
* returns the UINT result.
|
* returns the UINT result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_binary_or(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_binary_or(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint |= arg_p->data.uint;
|
smp->data.uint |= arg_p->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1918,7 +1937,8 @@ static int sample_conv_binary_or(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes a UINT on input, applies a binary "xor" with the UINT in arg_p, and
|
/* Takes a UINT on input, applies a binary "xor" with the UINT in arg_p, and
|
||||||
* returns the UINT result.
|
* returns the UINT result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_binary_xor(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_binary_xor(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint ^= arg_p->data.uint;
|
smp->data.uint ^= arg_p->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1927,7 +1947,8 @@ static int sample_conv_binary_xor(const struct arg *arg_p, struct sample *smp, v
|
|||||||
/* Takes a UINT on input, applies an arithmetic "add" with the UINT in arg_p,
|
/* Takes a UINT on input, applies an arithmetic "add" with the UINT in arg_p,
|
||||||
* and returns the UINT result.
|
* and returns the UINT result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_add(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_add(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint += arg_p->data.uint;
|
smp->data.uint += arg_p->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1936,7 +1957,8 @@ static int sample_conv_arith_add(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes a UINT on input, applies an arithmetic "sub" with the UINT in arg_p,
|
/* Takes a UINT on input, applies an arithmetic "sub" with the UINT in arg_p,
|
||||||
* and returns the UINT result.
|
* and returns the UINT result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_sub(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_sub(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint -= arg_p->data.uint;
|
smp->data.uint -= arg_p->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1945,7 +1967,8 @@ static int sample_conv_arith_sub(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes a UINT on input, applies an arithmetic "mul" with the UINT in arg_p,
|
/* Takes a UINT on input, applies an arithmetic "mul" with the UINT in arg_p,
|
||||||
* and returns the UINT result.
|
* and returns the UINT result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_mul(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_mul(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint *= arg_p->data.uint;
|
smp->data.uint *= arg_p->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1955,7 +1978,8 @@ static int sample_conv_arith_mul(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
* and returns the UINT result. If arg_p makes the result overflow, then the
|
* and returns the UINT result. If arg_p makes the result overflow, then the
|
||||||
* largest possible quantity is returned.
|
* largest possible quantity is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_div(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_div(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
if (arg_p->data.uint)
|
if (arg_p->data.uint)
|
||||||
smp->data.uint /= arg_p->data.uint;
|
smp->data.uint /= arg_p->data.uint;
|
||||||
@ -1968,7 +1992,8 @@ static int sample_conv_arith_div(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
* and returns the UINT result. If arg_p makes the result overflow, then zero
|
* and returns the UINT result. If arg_p makes the result overflow, then zero
|
||||||
* is returned.
|
* is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_mod(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_mod(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
if (arg_p->data.uint)
|
if (arg_p->data.uint)
|
||||||
smp->data.uint %= arg_p->data.uint;
|
smp->data.uint %= arg_p->data.uint;
|
||||||
@ -1980,7 +2005,8 @@ static int sample_conv_arith_mod(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes an UINT on input, applies an arithmetic "neg" and returns the UINT
|
/* Takes an UINT on input, applies an arithmetic "neg" and returns the UINT
|
||||||
* result.
|
* result.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_neg(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_neg(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = -smp->data.uint;
|
smp->data.uint = -smp->data.uint;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1989,7 +2015,8 @@ static int sample_conv_arith_neg(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes a UINT on input, returns true is the value is non-null, otherwise
|
/* Takes a UINT on input, returns true is the value is non-null, otherwise
|
||||||
* false. The output is a BOOL.
|
* false. The output is a BOOL.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_bool(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_bool(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = !!smp->data.uint;
|
smp->data.uint = !!smp->data.uint;
|
||||||
smp->type = SMP_T_BOOL;
|
smp->type = SMP_T_BOOL;
|
||||||
@ -1999,7 +2026,8 @@ static int sample_conv_arith_bool(const struct arg *arg_p, struct sample *smp, v
|
|||||||
/* Takes a UINT on input, returns false is the value is non-null, otherwise
|
/* Takes a UINT on input, returns false is the value is non-null, otherwise
|
||||||
* truee. The output is a BOOL.
|
* truee. The output is a BOOL.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_not(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_not(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = !smp->data.uint;
|
smp->data.uint = !smp->data.uint;
|
||||||
smp->type = SMP_T_BOOL;
|
smp->type = SMP_T_BOOL;
|
||||||
@ -2009,7 +2037,8 @@ static int sample_conv_arith_not(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes a UINT on input, returns true is the value is odd, otherwise false.
|
/* Takes a UINT on input, returns true is the value is odd, otherwise false.
|
||||||
* The output is a BOOL.
|
* The output is a BOOL.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_odd(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_odd(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = smp->data.uint & 1;
|
smp->data.uint = smp->data.uint & 1;
|
||||||
smp->type = SMP_T_BOOL;
|
smp->type = SMP_T_BOOL;
|
||||||
@ -2019,7 +2048,8 @@ static int sample_conv_arith_odd(const struct arg *arg_p, struct sample *smp, vo
|
|||||||
/* Takes a UINT on input, returns true is the value is even, otherwise false.
|
/* Takes a UINT on input, returns true is the value is even, otherwise false.
|
||||||
* The output is a BOOL.
|
* The output is a BOOL.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_arith_even(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_arith_even(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
smp->data.uint = !(smp->data.uint & 1);
|
smp->data.uint = !(smp->data.uint & 1);
|
||||||
smp->type = SMP_T_BOOL;
|
smp->type = SMP_T_BOOL;
|
||||||
|
@ -809,7 +809,8 @@ struct proxy *find_stktable(const char *name)
|
|||||||
* the table's type. This is a double conversion, but in the future we might
|
* the table's type. This is a double conversion, but in the future we might
|
||||||
* support automatic input types to perform the cast on the fly.
|
* support automatic input types to perform the cast on the fly.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_in_table(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_in_table(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -835,7 +836,8 @@ static int sample_conv_in_table(const struct arg *arg_p, struct sample *smp, voi
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_bytes_in_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -871,7 +873,8 @@ static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sampl
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_conn_cnt(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -906,7 +909,8 @@ static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *sm
|
|||||||
* can be easily performed. If the inspected parameter is not stored in the
|
* can be easily performed. If the inspected parameter is not stored in the
|
||||||
* table, <not found> is returned.
|
* table, <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_conn_cur(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -941,7 +945,8 @@ static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *sm
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_conn_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -977,7 +982,8 @@ static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *s
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_bytes_out_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1013,7 +1019,8 @@ static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct samp
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_gpc0(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1048,7 +1055,8 @@ static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, v
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_gpc0_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1084,7 +1092,8 @@ static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *s
|
|||||||
* comparisons can be easily performed. If the inspected parameter is not stored
|
* comparisons can be easily performed. If the inspected parameter is not stored
|
||||||
* in the table, <not found> is returned.
|
* in the table, <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_http_err_cnt(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1119,7 +1128,8 @@ static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_http_err_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1155,7 +1165,8 @@ static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sampl
|
|||||||
* can be easily performed. If the inspected parameter is not stored in the
|
* can be easily performed. If the inspected parameter is not stored in the
|
||||||
* table, <not found> is returned.
|
* table, <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_http_req_cnt(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1190,7 +1201,8 @@ static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample
|
|||||||
* performed. If the inspected parameter is not stored in the table, <not found>
|
* performed. If the inspected parameter is not stored in the table, <not found>
|
||||||
* is returned.
|
* is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_http_req_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1226,7 +1238,8 @@ static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sampl
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_kbytes_in(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1261,7 +1274,8 @@ static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *s
|
|||||||
* be easily performed. If the inspected parameter is not stored in the table,
|
* be easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_kbytes_out(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1296,7 +1310,8 @@ static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample *
|
|||||||
* easily performed. If the inspected parameter is not stored in the table,
|
* easily performed. If the inspected parameter is not stored in the table,
|
||||||
* <not found> is returned.
|
* <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_server_id(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_server_id(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1331,7 +1346,8 @@ static int sample_conv_table_server_id(const struct arg *arg_p, struct sample *s
|
|||||||
* can be easily performed. If the inspected parameter is not stored in the
|
* can be easily performed. If the inspected parameter is not stored in the
|
||||||
* table, <not found> is returned.
|
* table, <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_sess_cnt(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1366,7 +1382,8 @@ static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *sm
|
|||||||
* performed. If the inspected parameter is not stored in the table, <not found>
|
* performed. If the inspected parameter is not stored in the table, <not found>
|
||||||
* is returned.
|
* is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_sess_rate(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
@ -1402,7 +1419,8 @@ static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *s
|
|||||||
* comparisons can be easily performed. If the inspected parameter is not
|
* comparisons can be easily performed. If the inspected parameter is not
|
||||||
* stored in the table, <not found> is returned.
|
* stored in the table, <not found> is returned.
|
||||||
*/
|
*/
|
||||||
static int sample_conv_table_trackers(const struct arg *arg_p, struct sample *smp, void *private)
|
static int sample_conv_table_trackers(struct session *session, const struct arg *arg_p,
|
||||||
|
struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
struct stktable *t;
|
struct stktable *t;
|
||||||
struct stktable_key *key;
|
struct stktable_key *key;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user