#include <types/pattern.h>
#include <types/stick_table.h>
-extern struct pattern temp_pattern;
-
struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err_size);
struct pattern *pattern_process(struct proxy *px, struct session *l4,
void *l7, int dir, struct pattern_expr *expr,
acl_fetch_true(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
+ smp->type = SMP_T_BOOL;
smp->flags |= SMP_F_SET_RES_PASS;
return 1;
}
smp->flags |= SMP_F_MAY_CHANGE;
return 0;
}
+ smp->type = SMP_T_BOOL;
smp->flags |= SMP_F_SET_RES_PASS;
return 1;
}
acl_fetch_false(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
+ smp->type = SMP_T_BOOL;
smp->flags |= SMP_F_SET_RES_FAIL;
return 1;
}
if (!l4 || !l4->req)
return 0;
- temp_pattern.data.uint = l4->req->i;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = l4->req->i;
smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
return 1;
}
goto not_ssl_hello;
}
- temp_pattern.data.uint = hs_type;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = hs_type;
smp->flags = SMP_F_VOLATILE;
return 1;
/* OK that's enough. We have at least the whole message, and we have
* the protocol version.
*/
- temp_pattern.data.uint = version;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = version;
smp->flags = SMP_F_VOLATILE;
return 1;
name_len = (data[7] << 8) + data[8];
if (name_type == 0) { /* hostname */
- temp_pattern.data.str.str = (char *)data + 9;
- temp_pattern.data.str.len = name_len;
+ smp->type = SMP_T_CSTR;
+ smp->data.str.str = (char *)data + 9;
+ smp->data.str.len = name_len;
smp->flags = SMP_F_VOLATILE;
return 1;
}
return 0;
smp->flags = 0;
+ smp->type = SMP_T_CSTR;
bleft = l4->req->i;
if (bleft <= 11)
}
/* data points to cookie value */
- temp_pattern.data.str.str = (char *)data;
- temp_pattern.data.str.len = 0;
+ smp->data.str.str = (char *)data;
+ smp->data.str.len = 0;
while (bleft > 0 && *data != '\r') {
data++;
if (data[0] != '\r' || data[1] != '\n')
goto not_cookie;
- temp_pattern.data.str.len = (char *)data - temp_pattern.data.str.str;
+ smp->data.str.len = (char *)data - smp->data.str.str;
smp->flags = SMP_F_VOLATILE;
return 1;
ret = acl_fetch_rdp_cookie(px, l4, l7, dir, expr, smp);
- temp_pattern.data.str.str = NULL;
- temp_pattern.data.str.len = 0;
-
if (smp->flags & SMP_F_MAY_CHANGE)
return 0;
smp->flags = SMP_F_VOLATILE;
- temp_pattern.data.uint = ret;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = ret;
return 1;
}
{
int icase;
- if (pattern->len != temp_pattern.data.str.len)
+ if (pattern->len != smp->data.str.len)
return ACL_PAT_FAIL;
icase = pattern->flags & ACL_PAT_F_IGNORE_CASE;
- if ((icase && strncasecmp(pattern->ptr.str, temp_pattern.data.str.str, temp_pattern.data.str.len) == 0) ||
- (!icase && strncmp(pattern->ptr.str, temp_pattern.data.str.str, temp_pattern.data.str.len) == 0))
+ if ((icase && strncasecmp(pattern->ptr.str, smp->data.str.str, smp->data.str.len) == 0) ||
+ (!icase && strncmp(pattern->ptr.str, smp->data.str.str, smp->data.str.len) == 0))
return ACL_PAT_PASS;
return ACL_PAT_FAIL;
}
char prev;
/* we may have to force a trailing zero on the test pattern */
- prev = temp_pattern.data.str.str[temp_pattern.data.str.len];
+ prev = smp->data.str.str[smp->data.str.len];
if (prev)
- temp_pattern.data.str.str[temp_pattern.data.str.len] = '\0';
- node = ebst_lookup(&expr->pattern_tree, temp_pattern.data.str.str);
+ smp->data.str.str[smp->data.str.len] = '\0';
+ node = ebst_lookup(&expr->pattern_tree, smp->data.str.str);
if (prev)
- temp_pattern.data.str.str[temp_pattern.data.str.len] = prev;
+ smp->data.str.str[smp->data.str.len] = prev;
return node;
}
if (unlikely(smp->flags & SMP_F_READ_ONLY)) {
char *new_str;
- new_str = calloc(1, temp_pattern.data.str.len + 1);
+ new_str = calloc(1, smp->data.str.len + 1);
if (!new_str)
return ACL_PAT_FAIL;
- memcpy(new_str, temp_pattern.data.str.str, temp_pattern.data.str.len);
- new_str[temp_pattern.data.str.len] = 0;
+ memcpy(new_str, smp->data.str.str, smp->data.str.len);
+ new_str[smp->data.str.len] = 0;
if (smp->flags & SMP_F_MUST_FREE)
- free(temp_pattern.data.str.str);
- temp_pattern.data.str.str = new_str;
+ free(smp->data.str.str);
+ smp->data.str.str = new_str;
smp->flags |= SMP_F_MUST_FREE;
smp->flags &= ~SMP_F_READ_ONLY;
}
- old_char = temp_pattern.data.str.str[temp_pattern.data.str.len];
- temp_pattern.data.str.str[temp_pattern.data.str.len] = 0;
+ old_char = smp->data.str.str[smp->data.str.len];
+ smp->data.str.str[smp->data.str.len] = 0;
- if (regexec(pattern->ptr.reg, temp_pattern.data.str.str, 0, NULL, 0) == 0)
+ if (regexec(pattern->ptr.reg, smp->data.str.str, 0, NULL, 0) == 0)
ret = ACL_PAT_PASS;
else
ret = ACL_PAT_FAIL;
- temp_pattern.data.str.str[temp_pattern.data.str.len] = old_char;
+ smp->data.str.str[smp->data.str.len] = old_char;
return ret;
}
{
int icase;
- if (pattern->len > temp_pattern.data.str.len)
+ if (pattern->len > smp->data.str.len)
return ACL_PAT_FAIL;
icase = pattern->flags & ACL_PAT_F_IGNORE_CASE;
- if ((icase && strncasecmp(pattern->ptr.str, temp_pattern.data.str.str, pattern->len) != 0) ||
- (!icase && strncmp(pattern->ptr.str, temp_pattern.data.str.str, pattern->len) != 0))
+ if ((icase && strncasecmp(pattern->ptr.str, smp->data.str.str, pattern->len) != 0) ||
+ (!icase && strncmp(pattern->ptr.str, smp->data.str.str, pattern->len) != 0))
return ACL_PAT_FAIL;
return ACL_PAT_PASS;
}
{
int icase;
- if (pattern->len > temp_pattern.data.str.len)
+ if (pattern->len > smp->data.str.len)
return ACL_PAT_FAIL;
icase = pattern->flags & ACL_PAT_F_IGNORE_CASE;
- if ((icase && strncasecmp(pattern->ptr.str, temp_pattern.data.str.str + temp_pattern.data.str.len - pattern->len, pattern->len) != 0) ||
- (!icase && strncmp(pattern->ptr.str, temp_pattern.data.str.str + temp_pattern.data.str.len - pattern->len, pattern->len) != 0))
+ if ((icase && strncasecmp(pattern->ptr.str, smp->data.str.str + smp->data.str.len - pattern->len, pattern->len) != 0) ||
+ (!icase && strncmp(pattern->ptr.str, smp->data.str.str + smp->data.str.len - pattern->len, pattern->len) != 0))
return ACL_PAT_FAIL;
return ACL_PAT_PASS;
}
char *end;
char *c;
- if (pattern->len > temp_pattern.data.str.len)
+ if (pattern->len > smp->data.str.len)
return ACL_PAT_FAIL;
- end = temp_pattern.data.str.str + temp_pattern.data.str.len - pattern->len;
+ end = smp->data.str.str + smp->data.str.len - pattern->len;
icase = pattern->flags & ACL_PAT_F_IGNORE_CASE;
if (icase) {
- for (c = temp_pattern.data.str.str; c <= end; c++) {
+ for (c = smp->data.str.str; c <= end; c++) {
if (tolower(*c) != tolower(*pattern->ptr.str))
continue;
if (strncasecmp(pattern->ptr.str, c, pattern->len) == 0)
return ACL_PAT_PASS;
}
} else {
- for (c = temp_pattern.data.str.str; c <= end; c++) {
+ for (c = smp->data.str.str; c <= end; c++) {
if (*c != *pattern->ptr.str)
continue;
if (strncmp(pattern->ptr.str, c, pattern->len) == 0)
while (pl > 0 && is_delimiter(ps[pl - 1], delimiters))
pl--;
- if (pl > temp_pattern.data.str.len)
+ if (pl > smp->data.str.len)
return ACL_PAT_FAIL;
may_match = 1;
icase = pattern->flags & ACL_PAT_F_IGNORE_CASE;
- end = temp_pattern.data.str.str + temp_pattern.data.str.len - pl;
- for (c = temp_pattern.data.str.str; c <= end; c++) {
+ end = smp->data.str.str + smp->data.str.len - pl;
+ for (c = smp->data.str.str; c <= end; c++) {
if (is_delimiter(*c, delimiters)) {
may_match = 1;
continue;
/* Checks that the integer in <test> is included between min and max */
int acl_match_int(struct sample *smp, struct acl_pattern *pattern)
{
- if ((!pattern->val.range.min_set || pattern->val.range.min <= temp_pattern.data.uint) &&
- (!pattern->val.range.max_set || temp_pattern.data.uint <= pattern->val.range.max))
+ if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.uint) &&
+ (!pattern->val.range.max_set || smp->data.uint <= pattern->val.range.max))
return ACL_PAT_PASS;
return ACL_PAT_FAIL;
}
/* Checks that the length of the pattern in <test> is included between min and max */
int acl_match_len(struct sample *smp, struct acl_pattern *pattern)
{
- if ((!pattern->val.range.min_set || pattern->val.range.min <= temp_pattern.data.str.len) &&
- (!pattern->val.range.max_set || temp_pattern.data.str.len <= pattern->val.range.max))
+ if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.str.len) &&
+ (!pattern->val.range.max_set || smp->data.str.len <= pattern->val.range.max))
return ACL_PAT_PASS;
return ACL_PAT_FAIL;
}
{
struct in_addr *s;
- if (temp_pattern.type != SMP_T_IPV4)
+ if (smp->type != SMP_T_IPV4)
return ACL_PAT_FAIL;
- s = &temp_pattern.data.ipv4;
+ s = &smp->data.ipv4;
if (((s->s_addr ^ pattern->val.ipv4.addr.s_addr) & pattern->val.ipv4.mask.s_addr) == 0)
return ACL_PAT_PASS;
return ACL_PAT_FAIL;
{
struct in_addr *s;
- if (temp_pattern.type != SMP_T_IPV4)
+ if (smp->type != SMP_T_IPV4)
return ACL_PAT_FAIL;
- s = &temp_pattern.data.ipv4;
+ s = &smp->data.ipv4;
return ebmb_lookup_longest(&expr->pattern_tree, &s->s_addr);
}
/* now we may have some cleanup to do */
if (smp.flags & SMP_F_MUST_FREE) {
- free(temp_pattern.data.str.str);
- temp_pattern.data.str.len = 0;
+ free(smp.data.str.str);
+ smp.data.str.len = 0;
}
/* we're ORing these terms, so a single PASS is enough */
expr.args = args;
ret = acl_fetch_rdp_cookie(px, s, NULL, ACL_DIR_REQ, &expr, &smp);
- len = temp_pattern.data.str.len;
+ len = smp.data.str.len;
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || len == 0)
return NULL;
/* Found a the hh_name in the headers.
* we will compute the hash based on this value ctx.val.
*/
- p = temp_pattern.data.str.str;
+ p = smp.data.str.str;
while (len) {
hash = *p + (hash << 6) + (hash << 16) - hash;
len--;
expr.args = args;
ret = acl_fetch_rdp_cookie(px, s, NULL, ACL_DIR_REQ, &expr, &smp);
- if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || temp_pattern.data.str.len == 0)
+ if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.str.len == 0)
goto no_cookie;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
/* Considering an rdp cookie detected using acl, str ended with <cr><lf> and should return */
- addr.sin_addr.s_addr = strtoul(temp_pattern.data.str.str, &p, 10);
+ addr.sin_addr.s_addr = strtoul(smp.data.str.str, &p, 10);
if (*p != '.')
goto no_cookie;
p++;
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
+ smp->type = SMP_T_UINT;
px = expr->args->data.prx;
if (px->srv_act)
- temp_pattern.data.uint = px->srv_act;
+ smp->data.uint = px->srv_act;
else if (px->lbprm.fbck)
- temp_pattern.data.uint = 1;
+ smp->data.uint = 1;
else
- temp_pattern.data.uint = px->srv_bck;
+ smp->data.uint = px->srv_bck;
return 1;
}
struct server *srv = expr->args->data.srv;
smp->flags = SMP_F_VOL_TEST;
+ smp->type = SMP_T_BOOL;
if (!(srv->state & SRV_MAINTAIN) &&
(!(srv->state & SRV_CHECKED) || (srv->state & SRV_RUNNING)))
smp->flags |= SMP_F_SET_RES_PASS;
struct server *iterator;
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
for (iterator = expr->args->data.prx->srv; iterator; iterator = iterator->next) {
if ((iterator->state & SRV_RUNNING) == 0)
if (iterator->maxconn == 0 || iterator->maxqueue == 0) {
/* configuration is stupid */
- temp_pattern.data.uint = -1; /* FIXME: stupid value! */
+ smp->data.uint = -1; /* FIXME: stupid value! */
return 1;
}
- temp_pattern.data.uint += (iterator->maxconn - iterator->cur_sess)
+ smp->data.uint += (iterator->maxconn - iterator->cur_sess)
+ (iterator->maxqueue - iterator->nbpend);
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_READ_ONLY;
- temp_pattern.data.uint = l4->be->uuid;
-
+ smp->flags = SMP_F_VOL_TXN;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = l4->be->uuid;
return 1;
}
return 0;
smp->flags = SMP_F_READ_ONLY;
- temp_pattern.data.uint = target_srv(&l4->target)->puid;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = target_srv(&l4->target)->puid;
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = read_freq_ctr(&expr->args->data.prx->be_sess_per_sec);
+ smp->type = SMP_T_UINT;
+ smp->data.uint = read_freq_ctr(&expr->args->data.prx->be_sess_per_sec);
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = expr->args->data.prx->beconn;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = expr->args->data.prx->beconn;
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = expr->args->data.prx->totpend;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = expr->args->data.prx->totpend;
return 1;
}
int nbsrv;
smp->flags = SMP_F_VOL_TEST;
+ smp->type = SMP_T_UINT;
px = expr->args->data.prx;
if (px->srv_act)
nbsrv = px->srv_bck;
if (nbsrv > 0)
- temp_pattern.data.uint = (px->totpend + nbsrv - 1) / nbsrv;
+ smp->data.uint = (px->totpend + nbsrv - 1) / nbsrv;
else
- temp_pattern.data.uint = px->totpend * 2;
+ smp->data.uint = px->totpend * 2;
return 1;
}
acl_fetch_srv_conn(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- temp_pattern.data.uint = expr->args->data.srv->cur_sess;
+ smp->flags = SMP_F_VOL_TEST;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = expr->args->data.srv->cur_sess;
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_READ_ONLY;
- temp_pattern.data.uint = l4->fe->uuid;
+ smp->flags = SMP_F_VOL_SESS;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = l4->fe->uuid;
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = read_freq_ctr(&expr->args->data.prx->fe_sess_per_sec);
+ smp->type = SMP_T_UINT;
+ smp->data.uint = read_freq_ctr(&expr->args->data.prx->fe_sess_per_sec);
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = expr->args->data.prx->feconn;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = expr->args->data.prx->feconn;
return 1;
}
#include <proto/buffers.h>
#include <common/standard.h>
-/* static structure used on pattern_process if <p> is NULL*/
-struct pattern temp_pattern = { };
+/* static structure used on pattern_process if <p> is NULL */
+static struct pattern temp_pattern;
/* trash chunk used for pattern conversions */
static struct chunk trash_chunk;
return 0;
/* Check for a dependency on a request */
+ smp->type = SMP_T_BOOL;
if (expr->kw->requires & ACL_USE_L7REQ_ANY) {
if (unlikely(!s->req))
CHECK_HTTP_MESSAGE_FIRST();
meth = txn->meth;
- temp_pattern.data.str.len = meth;
- temp_pattern.data.str.str = NULL;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = meth;
if (meth == HTTP_METH_OTHER) {
if (txn->rsp.msg_state != HTTP_MSG_RPBEFORE)
/* ensure the indexes are not affected */
return 0;
- temp_pattern.data.str.len = txn->req.sl.rq.m_l;
- temp_pattern.data.str.str = txn->req.buf->p + txn->req.sol;
+ smp->type = SMP_T_CSTR;
+ smp->data.str.len = txn->req.sl.rq.m_l;
+ smp->data.str.str = txn->req.buf->p + txn->req.sol;
}
smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
return 1;
int icase;
- if (temp_pattern.data.str.str == NULL) {
+ if (smp->type == SMP_T_UINT) {
/* well-known method */
- if (temp_pattern.data.str.len == pattern->val.i)
+ if (smp->data.uint == pattern->val.i)
return ACL_PAT_PASS;
return ACL_PAT_FAIL;
}
return ACL_PAT_FAIL;
/* Other method, we must compare the strings */
- if (pattern->len != temp_pattern.data.str.len)
+ if (pattern->len != smp->data.str.len)
return ACL_PAT_FAIL;
icase = pattern->flags & ACL_PAT_F_IGNORE_CASE;
- if ((icase && strncasecmp(pattern->ptr.str, temp_pattern.data.str.str, temp_pattern.data.str.len) != 0) ||
- (!icase && strncmp(pattern->ptr.str, temp_pattern.data.str.str, temp_pattern.data.str.len) != 0))
+ if ((icase && strncasecmp(pattern->ptr.str, smp->data.str.str, smp->data.str.len) != 0) ||
+ (!icase && strncmp(pattern->ptr.str, smp->data.str.str, smp->data.str.len) != 0))
return ACL_PAT_FAIL;
return ACL_PAT_PASS;
}
if (len <= 0)
return 0;
- temp_pattern.data.str.str = ptr;
- temp_pattern.data.str.len = len;
+ smp->type = SMP_T_CSTR;
+ smp->data.str.str = ptr;
+ smp->data.str.len = len;
smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
return 1;
if (len <= 0)
return 0;
- temp_pattern.data.str.str = ptr;
- temp_pattern.data.str.len = len;
+ smp->type = SMP_T_CSTR;
+ smp->data.str.str = ptr;
+ smp->data.str.len = len;
smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
return 1;
len = txn->rsp.sl.st.c_l;
ptr = txn->rsp.buf->p + txn->rsp.sol + txn->rsp.sl.st.c;
- temp_pattern.data.uint = __strl2ui(ptr, len);
+ smp->type = SMP_T_UINT;
+ smp->data.uint = __strl2ui(ptr, len);
smp->flags = SMP_F_VOL_1ST;
return 1;
}
CHECK_HTTP_MESSAGE_FIRST();
- temp_pattern.data.str.len = txn->req.sl.rq.u_l;
- temp_pattern.data.str.str = txn->req.buf->p + txn->req.sol + txn->req.sl.rq.u;
-
- /* we do not need to set READ_ONLY because the data is in a buffer */
+ smp->type = SMP_T_CSTR;
+ smp->data.str.len = txn->req.sl.rq.u_l;
+ smp->data.str.str = txn->req.buf->p + txn->req.sol + txn->req.sl.rq.u;
smp->flags = SMP_F_VOL_1ST;
return 1;
}
url2sa(txn->req.buf->p + txn->req.sol + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->req->cons->addr.to);
if (((struct sockaddr_in *)&l4->req->cons->addr.to)->sin_family != AF_INET)
return 0;
- temp_pattern.type = SMP_T_IPV4;
- temp_pattern.data.ipv4 = ((struct sockaddr_in *)&l4->req->cons->addr.to)->sin_addr;
+ smp->type = SMP_T_IPV4;
+ smp->data.ipv4 = ((struct sockaddr_in *)&l4->req->cons->addr.to)->sin_addr;
/*
* If we are parsing url in frontend space, we prepare backend stage
/* Same optimization as url_ip */
url2sa(txn->req.buf->p + txn->req.sol + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->req->cons->addr.to);
- temp_pattern.data.uint = ntohs(((struct sockaddr_in *)&l4->req->cons->addr.to)->sin_port);
+ smp->type = SMP_T_UINT;
+ smp->data.uint = ntohs(((struct sockaddr_in *)&l4->req->cons->addr.to)->sin_port);
if (px->options & PR_O_HTTP_PROXY)
l4->flags |= SN_ADDR_SET;
if (http_find_header2(expr->args->data.str.str, expr->args->data.str.len, msg->buf->p + msg->sol, idx, ctx)) {
smp->flags |= SMP_F_NOT_LAST;
smp->flags |= SMP_F_VOL_HDR;
- temp_pattern.data.str.str = (char *)ctx->line + ctx->val;
- temp_pattern.data.str.len = ctx->vlen;
+ smp->type = SMP_T_CSTR;
+ smp->data.str.str = (char *)ctx->line + ctx->val;
+ smp->data.str.len = ctx->vlen;
return 1;
}
while (http_find_header2(expr->args->data.str.str, expr->args->data.str.len, msg->buf->p + msg->sol, idx, &ctx))
cnt++;
- temp_pattern.data.uint = cnt;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = cnt;
smp->flags = SMP_F_VOL_HDR;
return 1;
}
{
int ret = acl_fetch_hdr(px, l4, l7, dir, expr, smp);
- if (ret > 0)
- temp_pattern.data.uint = strl2ic(temp_pattern.data.str.str, temp_pattern.data.str.len);
+ if (ret > 0) {
+ smp->type = SMP_T_UINT;
+ smp->data.uint = strl2ic(smp->data.str.str, smp->data.str.len);
+ }
return ret;
}
int ret;
while ((ret = acl_fetch_hdr(px, l4, l7, dir, expr, smp)) > 0) {
- temp_pattern.type = SMP_T_IPV4;
- if (url2ipv4((char *)temp_pattern.data.str.str, &temp_pattern.data.ipv4))
+ smp->type = SMP_T_IPV4;
+ if (url2ipv4((char *)smp->data.str.str, &smp->data.ipv4))
break;
/* if the header doesn't match an IP address, fetch next one */
}
return 0;
/* OK, we got the '/' ! */
- temp_pattern.data.str.str = ptr;
+ smp->type = SMP_T_CSTR;
+ smp->data.str.str = ptr;
while (ptr < end && *ptr != '?')
ptr++;
- temp_pattern.data.str.len = ptr - temp_pattern.data.str.str;
+ smp->data.str.len = ptr - smp->data.str.str;
/* we do not need to set READ_ONLY because the data is in a buffer */
smp->flags = SMP_F_VOL_1ST;
CHECK_HTTP_MESSAGE_FIRST();
+ smp->type = SMP_T_BOOL;
smp->flags |= SMP_F_SET_RES_PASS;
return 1;
}
if (!s)
return 0;
+ smp->type = SMP_T_BOOL;
if (s->txn.flags & TX_NOT_FIRST)
smp->flags |= SMP_F_SET_RES_FAIL;
else
if (!get_http_auth(l4))
return 0;
+ smp->type = SMP_T_BOOL;
if (check_user(expr->args->data.usr, 0, l4->txn.auth.user, l4->txn.auth.pass))
smp->flags |= SMP_F_SET_RES_PASS;
else
smp->ctx.a[1] = smp->ctx.a[0] + ctx->vlen;
}
+ smp->type = SMP_T_CSTR;
smp->ctx.a[0] = extract_cookie_value(smp->ctx.a[0], smp->ctx.a[1],
expr->args->data.str.str, expr->args->data.str.len,
(dir & ACL_DIR_MASK) == ACL_DIR_REQ,
- &temp_pattern.data.str.str,
- &temp_pattern.data.str.len);
+ &smp->data.str.str,
+ &smp->data.str.len);
if (smp->ctx.a[0]) {
- /* one value was returned into temp_pattern.data.str.{str,len} */
+ /* one value was returned into smp->data.str.{str,len} */
smp->flags |= SMP_F_NOT_LAST;
smp->flags |= SMP_F_VOL_HDR;
return 1;
val_end = val_beg + ctx.vlen;
}
+ smp->type = SMP_T_CSTR;
while ((val_beg = extract_cookie_value(val_beg, val_end,
expr->args->data.str.str, expr->args->data.str.len,
(dir & ACL_DIR_MASK) == ACL_DIR_REQ,
- &temp_pattern.data.str.str,
- &temp_pattern.data.str.len))) {
+ &smp->data.str.str,
+ &smp->data.str.len))) {
cnt++;
}
}
- temp_pattern.data.uint = cnt;
+ smp->data.uint = cnt;
smp->flags |= SMP_F_VOL_HDR;
return 1;
}
{
switch (l4->si[0].addr.from.ss_family) {
case AF_INET:
- temp_pattern.data.ipv4 = ((struct sockaddr_in *)&l4->si[0].addr.from)->sin_addr;
- temp_pattern.type = SMP_T_IPV4;
+ smp->data.ipv4 = ((struct sockaddr_in *)&l4->si[0].addr.from)->sin_addr;
+ smp->type = SMP_T_IPV4;
break;
case AF_INET6:
- temp_pattern.data.ipv6 = ((struct sockaddr_in6 *)(&l4->si[0].addr.from))->sin6_addr;
- temp_pattern.type = SMP_T_IPV6;
+ smp->data.ipv6 = ((struct sockaddr_in6 *)(&l4->si[0].addr.from))->sin6_addr;
+ smp->type = SMP_T_IPV6;
break;
default:
return 0;
acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- if (!(temp_pattern.data.uint = get_host_port(&l4->si[0].addr.from)))
+ smp->type = SMP_T_UINT;
+ if (!(smp->data.uint = get_host_port(&l4->si[0].addr.from)))
return 0;
smp->flags = 0;
switch (l4->si[0].addr.to.ss_family) {
case AF_INET:
- temp_pattern.data.ipv4 = ((struct sockaddr_in *)&l4->si[0].addr.to)->sin_addr;
- temp_pattern.type = SMP_T_IPV4;
+ smp->data.ipv4 = ((struct sockaddr_in *)&l4->si[0].addr.to)->sin_addr;
+ smp->type = SMP_T_IPV4;
break;
case AF_INET6:
- temp_pattern.data.ipv6 = ((struct sockaddr_in6 *)(&l4->si[0].addr.to))->sin6_addr;
- temp_pattern.type = SMP_T_IPV6;
+ smp->data.ipv6 = ((struct sockaddr_in6 *)(&l4->si[0].addr.to))->sin6_addr;
+ smp->type = SMP_T_IPV6;
break;
default:
return 0;
{
stream_sock_get_to_addr(&l4->si[0]);
- if (!(temp_pattern.data.uint = get_host_port(&l4->si[0].addr.to)))
+ smp->type = SMP_T_UINT;
+ if (!(smp->data.uint = get_host_port(&l4->si[0].addr.to)))
return 0;
smp->flags = 0;
expr.args = args;
ret = acl_fetch_rdp_cookie(px, l4, NULL, ACL_DIR_REQ, &expr, &smp);
- if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || temp_pattern.data.str.len == 0)
+ if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.str.len == 0)
return 0;
- data->str = temp_pattern.data.str;
+ data->str = smp.data.str;
return 1;
}
acl_fetch_dconn(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- temp_pattern.data.uint = l4->listener->nbconn;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = l4->listener->nbconn;
return 1;
}
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_READ_ONLY;
- temp_pattern.data.uint = l4->listener->luid;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = l4->listener->luid;
return 1;
}
acl_fetch_get_gpc0(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_GPC0);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, gpc0);
+ smp->data.uint = stktable_data_cast(ptr, gpc0);
}
return 1;
}
acl_fetch_inc_gpc0(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_GPC0);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = ++stktable_data_cast(ptr, gpc0);
+ smp->data.uint = ++stktable_data_cast(ptr, gpc0);
}
return 1;
}
acl_fetch_clr_gpc0(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_GPC0);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, gpc0);
+ smp->data.uint = stktable_data_cast(ptr, gpc0);
stktable_data_cast(ptr, gpc0) = 0;
}
return 1;
acl_fetch_conn_cnt(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_CONN_CNT);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, conn_cnt);
+ smp->data.uint = stktable_data_cast(ptr, conn_cnt);
}
return 1;
}
acl_fetch_conn_rate(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_CONN_RATE);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
+ smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
table->data_arg[STKTABLE_DT_CONN_RATE].u);
}
return 1;
if (!ptr)
return 0; /* parameter not stored in this table */
- temp_pattern.data.uint = ++stktable_data_cast(ptr, conn_cnt);
+ smp->type = SMP_T_UINT;
+ smp->data.uint = ++stktable_data_cast(ptr, conn_cnt);
smp->flags = SMP_F_VOL_TEST;
return 1;
}
acl_fetch_conn_cur(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_CONN_CUR);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, conn_cur);
+ smp->data.uint = stktable_data_cast(ptr, conn_cur);
}
return 1;
}
acl_fetch_sess_cnt(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_SESS_CNT);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, sess_cnt);
+ smp->data.uint = stktable_data_cast(ptr, sess_cnt);
}
return 1;
}
acl_fetch_sess_rate(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_SESS_RATE);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
+ smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
table->data_arg[STKTABLE_DT_SESS_RATE].u);
}
return 1;
acl_fetch_http_req_cnt(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_HTTP_REQ_CNT);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, http_req_cnt);
+ smp->data.uint = stktable_data_cast(ptr, http_req_cnt);
}
return 1;
}
acl_fetch_http_req_rate(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_HTTP_REQ_RATE);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
+ smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u);
}
return 1;
acl_fetch_http_err_cnt(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_HTTP_ERR_CNT);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, http_err_cnt);
+ smp->data.uint = stktable_data_cast(ptr, http_err_cnt);
}
return 1;
}
acl_fetch_http_err_rate(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_HTTP_ERR_RATE);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
+ smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
table->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u);
}
return 1;
acl_fetch_kbytes_in(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_BYTES_IN_CNT);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
+ smp->data.uint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
}
return 1;
}
acl_fetch_bytes_in_rate(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_BYTES_IN_RATE);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
+ smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
table->data_arg[STKTABLE_DT_BYTES_IN_RATE].u);
}
return 1;
acl_fetch_kbytes_out(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_BYTES_OUT_CNT);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
+ smp->data.uint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
}
return 1;
}
acl_fetch_bytes_out_rate(struct stktable *table, struct sample *smp, struct stksess *ts)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = 0;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = 0;
if (ts != NULL) {
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_BYTES_OUT_RATE);
if (!ptr)
return 0; /* parameter not stored */
- temp_pattern.data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
+ smp->data.uint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
table->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u);
}
return 1;
struct acl_expr *expr, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = expr->args->data.prx->table.current;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = expr->args->data.prx->table.current;
return 1;
}
{
px = expr->args->data.prx;
smp->flags = SMP_F_VOL_TEST;
- temp_pattern.data.uint = px->table.size - px->table.current;
+ smp->type = SMP_T_UINT;
+ smp->data.uint = px->table.size - px->table.current;
return 1;
}