mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-02-26 19:52:06 +01:00
MEDIUM: samples: Use the "struct sample_data" in the "struct sample"
This patch remove the struct information stored both in the struct sample_data and in the striuct sample. Now, only thestruct sample_data contains data, and the struct sample use the struct sample_data for storing his own data.
This commit is contained in:
parent
503bb09873
commit
8c542cac07
@ -56,11 +56,11 @@ int smp_dup(struct sample *smp);
|
||||
static inline
|
||||
int sample_convert(struct sample *sample, int req_type)
|
||||
{
|
||||
if (!sample_casts[sample->type][req_type])
|
||||
if (!sample_casts[sample->data.type][req_type])
|
||||
return 0;
|
||||
if (sample_casts[sample->type][req_type] == c_none)
|
||||
if (sample_casts[sample->data.type][req_type] == c_none)
|
||||
return 1;
|
||||
return sample_casts[sample->type][req_type](sample);
|
||||
return sample_casts[sample->data.type][req_type](sample);
|
||||
}
|
||||
|
||||
#endif /* _PROTO_SAMPLE_H */
|
||||
|
||||
@ -242,11 +242,8 @@ struct meth {
|
||||
struct chunk str;
|
||||
};
|
||||
|
||||
/* a sample is a typed data extracted from a stream. It has a type, contents,
|
||||
* validity constraints, a context for use in iterative calls.
|
||||
*/
|
||||
struct sample {
|
||||
unsigned int flags; /* SMP_F_* */
|
||||
/* Used to store sample constant */
|
||||
struct sample_data {
|
||||
int type; /* SMP_T_* */
|
||||
union {
|
||||
long long int sint; /* used for signed 64bits integers */
|
||||
@ -255,6 +252,14 @@ struct sample {
|
||||
struct chunk str; /* used for char strings or buffers */
|
||||
struct meth meth; /* used for http method */
|
||||
} data; /* sample data */
|
||||
};
|
||||
|
||||
/* a sample is a typed data extracted from a stream. It has a type, contents,
|
||||
* validity constraints, a context for use in iterative calls.
|
||||
*/
|
||||
struct sample {
|
||||
unsigned int flags; /* SMP_F_* */
|
||||
struct sample_data data;
|
||||
union smp_ctx ctx;
|
||||
|
||||
/* Some sample analyzer (sample-fetch or converters) needs to
|
||||
@ -268,18 +273,6 @@ struct sample {
|
||||
unsigned int opt; /* fetch options (SMP_OPT_*) */
|
||||
};
|
||||
|
||||
/* Used to store sample constant */
|
||||
struct sample_data {
|
||||
int type; /* SMP_T_* */
|
||||
union {
|
||||
long long int sint; /* used for signed 64bits integers */
|
||||
struct in_addr ipv4; /* used for ipv4 addresses */
|
||||
struct in6_addr ipv6; /* used for ipv6 addresses */
|
||||
struct chunk str; /* used for char strings or buffers */
|
||||
struct meth meth; /* used for http method */
|
||||
} data; /* sample data */
|
||||
};
|
||||
|
||||
/* Descriptor for a sample conversion */
|
||||
struct sample_conv {
|
||||
const char *kw; /* configuration keyword */
|
||||
|
||||
@ -276,7 +276,7 @@ pat_match_auth(struct sample *smp, struct pattern_expr *expr, int fill)
|
||||
|
||||
/* Browse the userlist for searching user. */
|
||||
for (u = ul->users; u; u = u->next) {
|
||||
if (strcmp(smp->data.str.str, u->user) == 0)
|
||||
if (strcmp(smp->data.data.str.str, u->user) == 0)
|
||||
break;
|
||||
}
|
||||
if (!u)
|
||||
|
||||
@ -476,7 +476,7 @@ struct server *get_server_rch(struct stream *s)
|
||||
b_rew(s->req.buf, rewind = s->req.buf->o);
|
||||
|
||||
ret = fetch_rdp_cookie_name(s, &smp, px->hh_name, px->hh_len);
|
||||
len = smp.data.str.len;
|
||||
len = smp.data.data.str.len;
|
||||
|
||||
b_adv(s->req.buf, rewind);
|
||||
|
||||
@ -490,7 +490,7 @@ struct server *get_server_rch(struct stream *s)
|
||||
/* Found a the hh_name in the headers.
|
||||
* we will compute the hash based on this value ctx.val.
|
||||
*/
|
||||
hash = gen_hash(px, smp.data.str.str, len);
|
||||
hash = gen_hash(px, smp.data.data.str.str, len);
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
@ -1218,10 +1218,10 @@ int connect_server(struct stream *s)
|
||||
if (smp) {
|
||||
/* get write access to terminate with a zero */
|
||||
smp_dup(smp);
|
||||
if (smp->data.str.len >= smp->data.str.size)
|
||||
smp->data.str.len = smp->data.str.size - 1;
|
||||
smp->data.str.str[smp->data.str.len] = 0;
|
||||
ssl_sock_set_servername(srv_conn, smp->data.str.str);
|
||||
if (smp->data.data.str.len >= smp->data.data.str.size)
|
||||
smp->data.data.str.len = smp->data.data.str.size - 1;
|
||||
smp->data.data.str.str[smp->data.data.str.len] = 0;
|
||||
ssl_sock_set_servername(srv_conn, smp->data.data.str.str);
|
||||
srv_conn->flags |= CO_FL_PRIVATE;
|
||||
}
|
||||
}
|
||||
@ -1361,14 +1361,14 @@ int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit)
|
||||
memset(&smp, 0, sizeof(smp));
|
||||
|
||||
ret = fetch_rdp_cookie_name(s, &smp, s->be->rdp_cookie_name, s->be->rdp_cookie_len);
|
||||
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.str.len == 0)
|
||||
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.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(smp.data.str.str, &p, 10);
|
||||
addr.sin_addr.s_addr = strtoul(smp.data.data.str.str, &p, 10);
|
||||
if (*p != '.')
|
||||
goto no_cookie;
|
||||
p++;
|
||||
@ -1602,15 +1602,15 @@ smp_fetch_nbsrv(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
struct proxy *px;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
px = args->data.prx;
|
||||
|
||||
if (px->srv_act)
|
||||
smp->data.sint = px->srv_act;
|
||||
smp->data.data.sint = px->srv_act;
|
||||
else if (px->lbprm.fbck)
|
||||
smp->data.sint = 1;
|
||||
smp->data.data.sint = 1;
|
||||
else
|
||||
smp->data.sint = px->srv_bck;
|
||||
smp->data.data.sint = px->srv_bck;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1626,12 +1626,12 @@ smp_fetch_srv_is_up(const struct arg *args, struct sample *smp, const char *kw,
|
||||
struct server *srv = args->data.srv;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
if (!(srv->admin & SRV_ADMF_MAINT) &&
|
||||
(!(srv->check.state & CHK_ST_CONFIGURED) || (srv->state != SRV_ST_STOPPED)))
|
||||
smp->data.sint = 1;
|
||||
smp->data.data.sint = 1;
|
||||
else
|
||||
smp->data.sint = 0;
|
||||
smp->data.data.sint = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1645,8 +1645,8 @@ smp_fetch_connslots(const struct arg *args, struct sample *smp, const char *kw,
|
||||
struct server *iterator;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
for (iterator = args->data.prx->srv; iterator; iterator = iterator->next) {
|
||||
if (iterator->state == SRV_ST_STOPPED)
|
||||
@ -1654,11 +1654,11 @@ smp_fetch_connslots(const struct arg *args, struct sample *smp, const char *kw,
|
||||
|
||||
if (iterator->maxconn == 0 || iterator->maxqueue == 0) {
|
||||
/* configuration is stupid */
|
||||
smp->data.sint = -1; /* FIXME: stupid value! */
|
||||
smp->data.data.sint = -1; /* FIXME: stupid value! */
|
||||
return 1;
|
||||
}
|
||||
|
||||
smp->data.sint += (iterator->maxconn - iterator->cur_sess)
|
||||
smp->data.data.sint += (iterator->maxconn - iterator->cur_sess)
|
||||
+ (iterator->maxqueue - iterator->nbpend);
|
||||
}
|
||||
|
||||
@ -1670,8 +1670,8 @@ static int
|
||||
smp_fetch_be_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TXN;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = smp->strm->be->uuid;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = smp->strm->be->uuid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1682,8 +1682,8 @@ smp_fetch_srv_id(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
if (!objt_server(smp->strm->target))
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = objt_server(smp->strm->target)->puid;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = objt_server(smp->strm->target)->puid;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1696,8 +1696,8 @@ static int
|
||||
smp_fetch_be_sess_rate(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = read_freq_ctr(&args->data.prx->be_sess_per_sec);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = read_freq_ctr(&args->data.prx->be_sess_per_sec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1709,8 +1709,8 @@ static int
|
||||
smp_fetch_be_conn(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = args->data.prx->beconn;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = args->data.prx->beconn;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1722,8 +1722,8 @@ static int
|
||||
smp_fetch_queue_size(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = args->data.prx->totpend;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = args->data.prx->totpend;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1742,7 +1742,7 @@ smp_fetch_avg_queue_size(const struct arg *args, struct sample *smp, const char
|
||||
struct proxy *px;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
px = args->data.prx;
|
||||
|
||||
if (px->srv_act)
|
||||
@ -1753,9 +1753,9 @@ smp_fetch_avg_queue_size(const struct arg *args, struct sample *smp, const char
|
||||
nbsrv = px->srv_bck;
|
||||
|
||||
if (nbsrv > 0)
|
||||
smp->data.sint = (px->totpend + nbsrv - 1) / nbsrv;
|
||||
smp->data.data.sint = (px->totpend + nbsrv - 1) / nbsrv;
|
||||
else
|
||||
smp->data.sint = px->totpend * 2;
|
||||
smp->data.data.sint = px->totpend * 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1768,8 +1768,8 @@ static int
|
||||
smp_fetch_srv_conn(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = args->data.srv->cur_sess;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = args->data.srv->cur_sess;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1781,8 +1781,8 @@ static int
|
||||
smp_fetch_srv_sess_rate(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = read_freq_ctr(&args->data.srv->sess_per_sec);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = read_freq_ctr(&args->data.srv->sess_per_sec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -840,8 +840,8 @@ static int deflate_end(struct comp_ctx **comp_ctx)
|
||||
static int
|
||||
smp_fetch_res_comp(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = (smp->strm->comp_algo != NULL);
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = (smp->strm->comp_algo != NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -852,10 +852,10 @@ smp_fetch_res_comp_algo(const struct arg *args, struct sample *smp, const char *
|
||||
if (!smp->strm->comp_algo)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.str.str = smp->strm->comp_algo->cfg_name;
|
||||
smp->data.str.len = smp->strm->comp_algo->cfg_name_len;
|
||||
smp->data.data.str.str = smp->strm->comp_algo->cfg_name;
|
||||
smp->data.data.str.len = smp->strm->comp_algo->cfg_name_len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
8
src/da.c
8
src/da.c
@ -147,8 +147,8 @@ static int da_haproxy(const struct arg *args, struct sample *smp, void *private)
|
||||
tmp = get_trash_chunk();
|
||||
chunk_reset(tmp);
|
||||
|
||||
i = smp->data.str.len > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.str.len;
|
||||
memcpy(useragentbuf, smp->data.str.str, i - 1);
|
||||
i = smp->data.data.str.len > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.data.str.len;
|
||||
memcpy(useragentbuf, smp->data.data.str.str, i - 1);
|
||||
useragentbuf[i - 1] = 0;
|
||||
|
||||
useragent = (const char *)useragentbuf;
|
||||
@ -211,8 +211,8 @@ static int da_haproxy(const struct arg *args, struct sample *smp, void *private)
|
||||
tmp->str[tmp->len] = 0;
|
||||
}
|
||||
|
||||
smp->data.str.str = tmp->str;
|
||||
smp->data.str.len = strlen(tmp->str);
|
||||
smp->data.data.str.str = tmp->str;
|
||||
smp->data.data.str.len = strlen(tmp->str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5633,10 +5633,10 @@ static int stats_map_lookup(struct stream_interface *si)
|
||||
chunk_reset(&trash);
|
||||
|
||||
/* execute pattern matching */
|
||||
sample.type = SMP_T_STR;
|
||||
sample.data.type = SMP_T_STR;
|
||||
sample.flags |= SMP_F_CONST;
|
||||
sample.data.str.len = appctx->ctx.map.chunk.len;
|
||||
sample.data.str.str = appctx->ctx.map.chunk.str;
|
||||
sample.data.data.str.len = appctx->ctx.map.chunk.len;
|
||||
sample.data.data.str.str = appctx->ctx.map.chunk.str;
|
||||
if (appctx->ctx.map.expr->pat_head->match &&
|
||||
sample_convert(&sample, appctx->ctx.map.expr->pat_head->expect_type))
|
||||
pat = appctx->ctx.map.expr->pat_head->match(&sample, appctx->ctx.map.expr, 1);
|
||||
|
||||
@ -162,8 +162,8 @@ static int
|
||||
smp_fetch_fe_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_SESS;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = smp->sess->fe->uuid;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = smp->sess->fe->uuid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -175,8 +175,8 @@ static int
|
||||
smp_fetch_fe_sess_rate(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = read_freq_ctr(&args->data.prx->fe_sess_per_sec);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = read_freq_ctr(&args->data.prx->fe_sess_per_sec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -188,8 +188,8 @@ static int
|
||||
smp_fetch_fe_conn(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = args->data.prx->feconn;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = args->data.prx->feconn;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
62
src/hlua.c
62
src/hlua.c
@ -382,19 +382,19 @@ static int hlua_lua2arg(lua_State *L, int ud, struct arg *arg)
|
||||
*/
|
||||
static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
{
|
||||
switch (smp->type) {
|
||||
switch (smp->data.type) {
|
||||
case SMP_T_SINT:
|
||||
case SMP_T_BOOL:
|
||||
lua_pushinteger(L, smp->data.sint);
|
||||
lua_pushinteger(L, smp->data.data.sint);
|
||||
break;
|
||||
|
||||
case SMP_T_BIN:
|
||||
case SMP_T_STR:
|
||||
lua_pushlstring(L, smp->data.str.str, smp->data.str.len);
|
||||
lua_pushlstring(L, smp->data.data.str.str, smp->data.data.str.len);
|
||||
break;
|
||||
|
||||
case SMP_T_METH:
|
||||
switch (smp->data.meth.meth) {
|
||||
switch (smp->data.data.meth.meth) {
|
||||
case HTTP_METH_OPTIONS: lua_pushstring(L, "OPTIONS"); break;
|
||||
case HTTP_METH_GET: lua_pushstring(L, "GET"); break;
|
||||
case HTTP_METH_HEAD: lua_pushstring(L, "HEAD"); break;
|
||||
@ -404,7 +404,7 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
case HTTP_METH_TRACE: lua_pushstring(L, "TRACE"); break;
|
||||
case HTTP_METH_CONNECT: lua_pushstring(L, "CONNECT"); break;
|
||||
case HTTP_METH_OTHER:
|
||||
lua_pushlstring(L, smp->data.meth.str.str, smp->data.meth.str.len);
|
||||
lua_pushlstring(L, smp->data.data.meth.str.str, smp->data.data.meth.str.len);
|
||||
break;
|
||||
default:
|
||||
lua_pushnil(L);
|
||||
@ -415,9 +415,9 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
case SMP_T_IPV4:
|
||||
case SMP_T_IPV6:
|
||||
case SMP_T_ADDR: /* This type is never used to qualify a sample. */
|
||||
if (sample_casts[smp->type][SMP_T_STR] &&
|
||||
sample_casts[smp->type][SMP_T_STR](smp))
|
||||
lua_pushlstring(L, smp->data.str.str, smp->data.str.len);
|
||||
if (sample_casts[smp->data.type][SMP_T_STR] &&
|
||||
sample_casts[smp->data.type][SMP_T_STR](smp))
|
||||
lua_pushlstring(L, smp->data.data.str.str, smp->data.data.str.len);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
@ -434,15 +434,15 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
*/
|
||||
static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
|
||||
{
|
||||
switch (smp->type) {
|
||||
switch (smp->data.type) {
|
||||
|
||||
case SMP_T_BIN:
|
||||
case SMP_T_STR:
|
||||
lua_pushlstring(L, smp->data.str.str, smp->data.str.len);
|
||||
lua_pushlstring(L, smp->data.data.str.str, smp->data.data.str.len);
|
||||
break;
|
||||
|
||||
case SMP_T_METH:
|
||||
switch (smp->data.meth.meth) {
|
||||
switch (smp->data.data.meth.meth) {
|
||||
case HTTP_METH_OPTIONS: lua_pushstring(L, "OPTIONS"); break;
|
||||
case HTTP_METH_GET: lua_pushstring(L, "GET"); break;
|
||||
case HTTP_METH_HEAD: lua_pushstring(L, "HEAD"); break;
|
||||
@ -452,7 +452,7 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
|
||||
case HTTP_METH_TRACE: lua_pushstring(L, "TRACE"); break;
|
||||
case HTTP_METH_CONNECT: lua_pushstring(L, "CONNECT"); break;
|
||||
case HTTP_METH_OTHER:
|
||||
lua_pushlstring(L, smp->data.meth.str.str, smp->data.meth.str.len);
|
||||
lua_pushlstring(L, smp->data.data.meth.str.str, smp->data.data.meth.str.len);
|
||||
break;
|
||||
default:
|
||||
lua_pushstring(L, "");
|
||||
@ -465,9 +465,9 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
|
||||
case SMP_T_IPV4:
|
||||
case SMP_T_IPV6:
|
||||
case SMP_T_ADDR: /* This type is never used to qualify a sample. */
|
||||
if (sample_casts[smp->type][SMP_T_STR] &&
|
||||
sample_casts[smp->type][SMP_T_STR](smp))
|
||||
lua_pushlstring(L, smp->data.str.str, smp->data.str.len);
|
||||
if (sample_casts[smp->data.type][SMP_T_STR] &&
|
||||
sample_casts[smp->data.type][SMP_T_STR](smp))
|
||||
lua_pushlstring(L, smp->data.data.str.str, smp->data.data.str.len);
|
||||
else
|
||||
lua_pushstring(L, "");
|
||||
break;
|
||||
@ -487,20 +487,20 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp)
|
||||
switch (lua_type(L, ud)) {
|
||||
|
||||
case LUA_TNUMBER:
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = lua_tointeger(L, ud);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = lua_tointeger(L, ud);
|
||||
break;
|
||||
|
||||
|
||||
case LUA_TBOOLEAN:
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = lua_toboolean(L, ud);
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = lua_toboolean(L, ud);
|
||||
break;
|
||||
|
||||
case LUA_TSTRING:
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.str = (char *)lua_tolstring(L, ud, (size_t *)&smp->data.str.len);
|
||||
smp->data.data.str.str = (char *)lua_tolstring(L, ud, (size_t *)&smp->data.data.str.len);
|
||||
break;
|
||||
|
||||
case LUA_TUSERDATA:
|
||||
@ -509,8 +509,8 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp)
|
||||
case LUA_TFUNCTION:
|
||||
case LUA_TTHREAD:
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = 0;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -1369,13 +1369,13 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str)
|
||||
MAY_LJMP(check_args(L, 2, "lookup"));
|
||||
desc = MAY_LJMP(hlua_checkmap(L, 1));
|
||||
if (desc->pat.expect_type == SMP_T_SINT) {
|
||||
smp.type = SMP_T_SINT;
|
||||
smp.data.sint = MAY_LJMP(luaL_checkinteger(L, 2));
|
||||
smp.data.type = SMP_T_SINT;
|
||||
smp.data.data.sint = MAY_LJMP(luaL_checkinteger(L, 2));
|
||||
}
|
||||
else {
|
||||
smp.type = SMP_T_STR;
|
||||
smp.data.type = SMP_T_STR;
|
||||
smp.flags = SMP_F_CONST;
|
||||
smp.data.str.str = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.str.len));
|
||||
smp.data.data.str.str = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.data.str.len));
|
||||
}
|
||||
|
||||
pat = pattern_exec_match(&desc->pat, &smp, 1);
|
||||
@ -2867,13 +2867,13 @@ __LJMP static int hlua_run_sample_conv(lua_State *L)
|
||||
}
|
||||
|
||||
/* Apply expected cast. */
|
||||
if (!sample_casts[smp.type][conv->in_type]) {
|
||||
if (!sample_casts[smp.data.type][conv->in_type]) {
|
||||
hlua_pusherror(L, "invalid input argument: cannot cast '%s' to '%s'",
|
||||
smp_to_type[smp.type], smp_to_type[conv->in_type]);
|
||||
smp_to_type[smp.data.type], smp_to_type[conv->in_type]);
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
if (sample_casts[smp.type][conv->in_type] != c_none &&
|
||||
!sample_casts[smp.type][conv->in_type](&smp)) {
|
||||
if (sample_casts[smp.data.type][conv->in_type] != c_none &&
|
||||
!sample_casts[smp.data.type][conv->in_type](&smp)) {
|
||||
hlua_pusherror(L, "error during the input argument casting");
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
|
||||
@ -593,8 +593,8 @@ void bind_dump_kws(char **out)
|
||||
static int
|
||||
smp_fetch_dconn(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = smp->sess->listener->nbconn;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = smp->sess->listener->nbconn;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -602,8 +602,8 @@ smp_fetch_dconn(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
static int
|
||||
smp_fetch_so_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = smp->sess->listener->luid;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = smp->sess->listener->luid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -993,9 +993,9 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
key = sample_fetch_as_type(be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, tmp->expr, SMP_T_STR);
|
||||
if (tmp->options & LOG_OPT_HTTP)
|
||||
ret = encode_chunk(tmplog, dst + maxsize,
|
||||
'%', http_encode_map, key ? &key->data.str : &empty);
|
||||
'%', http_encode_map, key ? &key->data.data.str : &empty);
|
||||
else
|
||||
ret = lf_text_len(tmplog, key ? key->data.str.str : NULL, key ? key->data.str.len : 0, dst + maxsize - tmplog, tmp);
|
||||
ret = lf_text_len(tmplog, key ? key->data.data.str.str : NULL, key ? key->data.data.str.len : 0, dst + maxsize - tmplog, tmp);
|
||||
if (ret == 0)
|
||||
goto out;
|
||||
tmplog = ret;
|
||||
|
||||
24
src/map.c
24
src/map.c
@ -161,15 +161,15 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *pr
|
||||
if (pat) {
|
||||
/* Copy sample. */
|
||||
if (pat->data) {
|
||||
smp->type = pat->data->type;
|
||||
smp->data.type = pat->data->type;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
memcpy(&smp->data, &pat->data->data, sizeof(smp->data));
|
||||
memcpy(&smp->data.data, &pat->data->data, sizeof(smp->data.data));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return just int sample containing 1. */
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 1;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -181,24 +181,24 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *pr
|
||||
switch (desc->conv->out_type) {
|
||||
|
||||
case SMP_T_STR:
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str = arg_p[1].data.str;
|
||||
smp->data.data.str = arg_p[1].data.str;
|
||||
break;
|
||||
|
||||
case SMP_T_SINT:
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = arg_p[1].data.sint;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = arg_p[1].data.sint;
|
||||
break;
|
||||
|
||||
case SMP_T_IPV4:
|
||||
smp->type = SMP_T_IPV4;
|
||||
smp->data.ipv4 = arg_p[1].data.ipv4;
|
||||
smp->data.type = SMP_T_IPV4;
|
||||
smp->data.data.ipv4 = arg_p[1].data.ipv4;
|
||||
break;
|
||||
|
||||
case SMP_T_IPV6:
|
||||
smp->type = SMP_T_IPV6;
|
||||
smp->data.ipv6 = arg_p[1].data.ipv6;
|
||||
smp->data.type = SMP_T_IPV6;
|
||||
smp->data.data.ipv6 = arg_p[1].data.ipv6;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
126
src/pattern.c
126
src/pattern.c
@ -425,7 +425,7 @@ int pat_parse_ip(const char *text, struct pattern *pattern, int mflags, char **e
|
||||
/* always return false */
|
||||
struct pattern *pat_match_nothing(struct sample *smp, struct pattern_expr *expr, int fill)
|
||||
{
|
||||
if (smp->data.sint) {
|
||||
if (smp->data.data.sint) {
|
||||
if (fill) {
|
||||
static_pattern.data = NULL;
|
||||
static_pattern.ref = NULL;
|
||||
@ -454,12 +454,12 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
/* Lookup a string in the expression's pattern tree. */
|
||||
if (!eb_is_empty(&expr->pattern_tree)) {
|
||||
/* we may have to force a trailing zero on the test pattern */
|
||||
prev = smp->data.str.str[smp->data.str.len];
|
||||
prev = smp->data.data.str.str[smp->data.data.str.len];
|
||||
if (prev)
|
||||
smp->data.str.str[smp->data.str.len] = '\0';
|
||||
node = ebst_lookup(&expr->pattern_tree, smp->data.str.str);
|
||||
smp->data.data.str.str[smp->data.data.str.len] = '\0';
|
||||
node = ebst_lookup(&expr->pattern_tree, smp->data.data.str.str);
|
||||
if (prev)
|
||||
smp->data.str.str[smp->data.str.len] = prev;
|
||||
smp->data.data.str.str[smp->data.data.str.len] = prev;
|
||||
|
||||
if (node) {
|
||||
if (fill) {
|
||||
@ -478,7 +478,7 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
if (pat_lru_tree) {
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.str.str, smp->data.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.data.str.str, smp->data.data.str.len, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (lru && lru->domain)
|
||||
return lru->data;
|
||||
@ -487,12 +487,12 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len != smp->data.str.len)
|
||||
if (pattern->len != smp->data.data.str.len)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
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)) {
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.data.str.str, smp->data.data.str.len) == 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.data.str.str, smp->data.data.str.len) == 0)) {
|
||||
ret = pattern;
|
||||
break;
|
||||
}
|
||||
@ -515,7 +515,7 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
|
||||
if (pat_lru_tree) {
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.str.str, smp->data.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.data.str.str, smp->data.data.str.len, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (lru && lru->domain)
|
||||
return lru->data;
|
||||
@ -524,10 +524,10 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len != smp->data.str.len)
|
||||
if (pattern->len != smp->data.data.str.len)
|
||||
continue;
|
||||
|
||||
if (memcmp(pattern->ptr.str, smp->data.str.str, smp->data.str.len) == 0) {
|
||||
if (memcmp(pattern->ptr.str, smp->data.data.str.str, smp->data.data.str.len) == 0) {
|
||||
ret = pattern;
|
||||
break;
|
||||
}
|
||||
@ -552,7 +552,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
|
||||
if (pat_lru_tree) {
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.str.str, smp->data.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.data.str.str, smp->data.data.str.len, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (lru && lru->domain)
|
||||
return lru->data;
|
||||
@ -561,7 +561,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (regex_exec2(pattern->ptr.reg, smp->data.str.str, smp->data.str.len)) {
|
||||
if (regex_exec2(pattern->ptr.reg, smp->data.data.str.str, smp->data.data.str.len)) {
|
||||
ret = pattern;
|
||||
break;
|
||||
}
|
||||
@ -588,12 +588,12 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
/* Lookup a string in the expression's pattern tree. */
|
||||
if (!eb_is_empty(&expr->pattern_tree)) {
|
||||
/* we may have to force a trailing zero on the test pattern */
|
||||
prev = smp->data.str.str[smp->data.str.len];
|
||||
prev = smp->data.data.str.str[smp->data.data.str.len];
|
||||
if (prev)
|
||||
smp->data.str.str[smp->data.str.len] = '\0';
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree, smp->data.str.str);
|
||||
smp->data.data.str.str[smp->data.data.str.len] = '\0';
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree, smp->data.data.str.str);
|
||||
if (prev)
|
||||
smp->data.str.str[smp->data.str.len] = prev;
|
||||
smp->data.data.str.str[smp->data.data.str.len] = prev;
|
||||
|
||||
if (node) {
|
||||
if (fill) {
|
||||
@ -612,7 +612,7 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
if (pat_lru_tree) {
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.str.str, smp->data.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.data.str.str, smp->data.data.str.len, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (lru && lru->domain)
|
||||
return lru->data;
|
||||
@ -621,12 +621,12 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len > smp->data.str.len)
|
||||
if (pattern->len > smp->data.data.str.len)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
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))
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.data.str.str, pattern->len) != 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.data.str.str, pattern->len) != 0))
|
||||
continue;
|
||||
|
||||
ret = pattern;
|
||||
@ -651,7 +651,7 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
|
||||
if (pat_lru_tree) {
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.str.str, smp->data.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.data.str.str, smp->data.data.str.len, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (lru && lru->domain)
|
||||
return lru->data;
|
||||
@ -660,12 +660,12 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len > smp->data.str.len)
|
||||
if (pattern->len > smp->data.data.str.len)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
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))
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.data.str.str + smp->data.data.str.len - pattern->len, pattern->len) != 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.data.str.str + smp->data.data.str.len - pattern->len, pattern->len) != 0))
|
||||
continue;
|
||||
|
||||
ret = pattern;
|
||||
@ -694,7 +694,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
if (pat_lru_tree) {
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.str.str, smp->data.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.data.str.str, smp->data.data.str.len, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (lru && lru->domain)
|
||||
return lru->data;
|
||||
@ -703,13 +703,13 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len > smp->data.str.len)
|
||||
if (pattern->len > smp->data.data.str.len)
|
||||
continue;
|
||||
|
||||
end = smp->data.str.str + smp->data.str.len - pattern->len;
|
||||
end = smp->data.data.str.str + smp->data.data.str.len - pattern->len;
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
if (icase) {
|
||||
for (c = smp->data.str.str; c <= end; c++) {
|
||||
for (c = smp->data.data.str.str; c <= end; c++) {
|
||||
if (tolower(*c) != tolower(*pattern->ptr.str))
|
||||
continue;
|
||||
if (strncasecmp(pattern->ptr.str, c, pattern->len) == 0) {
|
||||
@ -718,7 +718,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (c = smp->data.str.str; c <= end; c++) {
|
||||
for (c = smp->data.data.str.str; c <= end; c++) {
|
||||
if (*c != *pattern->ptr.str)
|
||||
continue;
|
||||
if (strncmp(pattern->ptr.str, c, pattern->len) == 0) {
|
||||
@ -759,13 +759,13 @@ static int match_word(struct sample *smp, struct pattern *pattern, int mflags, u
|
||||
while (pl > 0 && is_delimiter(ps[pl - 1], delimiters))
|
||||
pl--;
|
||||
|
||||
if (pl > smp->data.str.len)
|
||||
if (pl > smp->data.data.str.len)
|
||||
return PAT_NOMATCH;
|
||||
|
||||
may_match = 1;
|
||||
icase = mflags & PAT_MF_IGNORE_CASE;
|
||||
end = smp->data.str.str + smp->data.str.len - pl;
|
||||
for (c = smp->data.str.str; c <= end; c++) {
|
||||
end = smp->data.data.str.str + smp->data.data.str.len - pl;
|
||||
for (c = smp->data.data.str.str; c <= end; c++) {
|
||||
if (is_delimiter(*c, delimiters)) {
|
||||
may_match = 1;
|
||||
continue;
|
||||
@ -832,8 +832,8 @@ struct pattern *pat_match_int(struct sample *smp, struct pattern_expr *expr, int
|
||||
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.sint) &&
|
||||
(!pattern->val.range.max_set || smp->data.sint <= pattern->val.range.max))
|
||||
if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.data.sint) &&
|
||||
(!pattern->val.range.max_set || smp->data.data.sint <= pattern->val.range.max))
|
||||
return pattern;
|
||||
}
|
||||
return NULL;
|
||||
@ -847,8 +847,8 @@ struct pattern *pat_match_len(struct sample *smp, struct pattern_expr *expr, int
|
||||
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
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))
|
||||
if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.data.str.len) &&
|
||||
(!pattern->val.range.max_set || smp->data.data.str.len <= pattern->val.range.max))
|
||||
return pattern;
|
||||
}
|
||||
return NULL;
|
||||
@ -865,11 +865,11 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
|
||||
struct pattern *pattern;
|
||||
|
||||
/* The input sample is IPv4. Try to match in the trees. */
|
||||
if (smp->type == SMP_T_IPV4) {
|
||||
if (smp->data.type == SMP_T_IPV4) {
|
||||
/* Lookup an IPv4 address in the expression's pattern tree using
|
||||
* the longest match method.
|
||||
*/
|
||||
s = &smp->data.ipv4;
|
||||
s = &smp->data.data.ipv4;
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree, &s->s_addr);
|
||||
if (node) {
|
||||
if (fill) {
|
||||
@ -891,7 +891,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
|
||||
*/
|
||||
memset(&tmp6, 0, 10);
|
||||
*(uint16_t*)&tmp6.s6_addr[10] = htons(0xffff);
|
||||
*(uint32_t*)&tmp6.s6_addr[12] = smp->data.ipv4.s_addr;
|
||||
*(uint32_t*)&tmp6.s6_addr[12] = smp->data.data.ipv4.s_addr;
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree_2, &tmp6);
|
||||
if (node) {
|
||||
if (fill) {
|
||||
@ -908,11 +908,11 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
|
||||
/* The input sample is IPv6. Try to match in the trees. */
|
||||
if (smp->type == SMP_T_IPV6) {
|
||||
if (smp->data.type == SMP_T_IPV6) {
|
||||
/* Lookup an IPv6 address in the expression's pattern tree using
|
||||
* the longest match method.
|
||||
*/
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree_2, &smp->data.ipv6);
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree_2, &smp->data.data.ipv6);
|
||||
if (node) {
|
||||
if (fill) {
|
||||
elt = ebmb_entry(node, struct pattern_tree, node);
|
||||
@ -932,16 +932,16 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
|
||||
* - ::0000:ip:v4 (old ipv4 mapped)
|
||||
* - 2002:ip:v4:: (6to4)
|
||||
*/
|
||||
if ((*(uint32_t*)&smp->data.ipv6.s6_addr[0] == 0 &&
|
||||
*(uint32_t*)&smp->data.ipv6.s6_addr[4] == 0 &&
|
||||
(*(uint32_t*)&smp->data.ipv6.s6_addr[8] == 0 ||
|
||||
*(uint32_t*)&smp->data.ipv6.s6_addr[8] == htonl(0xFFFF))) ||
|
||||
*(uint16_t*)&smp->data.ipv6.s6_addr[0] == htons(0x2002)) {
|
||||
if (*(uint32_t*)&smp->data.ipv6.s6_addr[0] == 0)
|
||||
v4 = *(uint32_t*)&smp->data.ipv6.s6_addr[12];
|
||||
if ((*(uint32_t*)&smp->data.data.ipv6.s6_addr[0] == 0 &&
|
||||
*(uint32_t*)&smp->data.data.ipv6.s6_addr[4] == 0 &&
|
||||
(*(uint32_t*)&smp->data.data.ipv6.s6_addr[8] == 0 ||
|
||||
*(uint32_t*)&smp->data.data.ipv6.s6_addr[8] == htonl(0xFFFF))) ||
|
||||
*(uint16_t*)&smp->data.data.ipv6.s6_addr[0] == htons(0x2002)) {
|
||||
if (*(uint32_t*)&smp->data.data.ipv6.s6_addr[0] == 0)
|
||||
v4 = *(uint32_t*)&smp->data.data.ipv6.s6_addr[12];
|
||||
else
|
||||
v4 = htonl((ntohs(*(uint16_t*)&smp->data.ipv6.s6_addr[2]) << 16) +
|
||||
ntohs(*(uint16_t*)&smp->data.ipv6.s6_addr[4]));
|
||||
v4 = htonl((ntohs(*(uint16_t*)&smp->data.data.ipv6.s6_addr[2]) << 16) +
|
||||
ntohs(*(uint16_t*)&smp->data.data.ipv6.s6_addr[4]));
|
||||
|
||||
/* Lookup an IPv4 address in the expression's pattern tree using the longest
|
||||
* match method.
|
||||
@ -968,25 +968,25 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
|
||||
pattern = &lst->pat;
|
||||
|
||||
/* The input sample is IPv4, use it as is. */
|
||||
if (smp->type == SMP_T_IPV4) {
|
||||
v4 = smp->data.ipv4.s_addr;
|
||||
if (smp->data.type == SMP_T_IPV4) {
|
||||
v4 = smp->data.data.ipv4.s_addr;
|
||||
}
|
||||
else if (smp->type == SMP_T_IPV6) {
|
||||
else if (smp->data.type == SMP_T_IPV6) {
|
||||
/* v4 match on a V6 sample. We want to check at least for
|
||||
* the following forms :
|
||||
* - ::ffff:ip:v4 (ipv4 mapped)
|
||||
* - ::0000:ip:v4 (old ipv4 mapped)
|
||||
* - 2002:ip:v4:: (6to4)
|
||||
*/
|
||||
if (*(uint32_t*)&smp->data.ipv6.s6_addr[0] == 0 &&
|
||||
*(uint32_t*)&smp->data.ipv6.s6_addr[4] == 0 &&
|
||||
(*(uint32_t*)&smp->data.ipv6.s6_addr[8] == 0 ||
|
||||
*(uint32_t*)&smp->data.ipv6.s6_addr[8] == htonl(0xFFFF))) {
|
||||
v4 = *(uint32_t*)&smp->data.ipv6.s6_addr[12];
|
||||
if (*(uint32_t*)&smp->data.data.ipv6.s6_addr[0] == 0 &&
|
||||
*(uint32_t*)&smp->data.data.ipv6.s6_addr[4] == 0 &&
|
||||
(*(uint32_t*)&smp->data.data.ipv6.s6_addr[8] == 0 ||
|
||||
*(uint32_t*)&smp->data.data.ipv6.s6_addr[8] == htonl(0xFFFF))) {
|
||||
v4 = *(uint32_t*)&smp->data.data.ipv6.s6_addr[12];
|
||||
}
|
||||
else if (*(uint16_t*)&smp->data.ipv6.s6_addr[0] == htons(0x2002)) {
|
||||
v4 = htonl((ntohs(*(uint16_t*)&smp->data.ipv6.s6_addr[2]) << 16) +
|
||||
ntohs(*(uint16_t*)&smp->data.ipv6.s6_addr[4]));
|
||||
else if (*(uint16_t*)&smp->data.data.ipv6.s6_addr[0] == htons(0x2002)) {
|
||||
v4 = htonl((ntohs(*(uint16_t*)&smp->data.data.ipv6.s6_addr[2]) << 16) +
|
||||
ntohs(*(uint16_t*)&smp->data.data.ipv6.s6_addr[4]));
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
@ -35,8 +35,8 @@ smp_fetch_wait_end(const struct arg *args, struct sample *smp, const char *kw, v
|
||||
smp->flags |= SMP_F_MAY_CHANGE;
|
||||
return 0;
|
||||
}
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = 1;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -50,8 +50,8 @@ smp_fetch_len(const struct arg *args, struct sample *smp, const char *kw, void *
|
||||
if (!chn->buf)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = chn->buf->i;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = chn->buf->i;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
|
||||
return 1;
|
||||
}
|
||||
@ -159,8 +159,8 @@ smp_fetch_req_ssl_ec_ext(const struct arg *args, struct sample *smp, const char
|
||||
|
||||
/* Elliptic curves extension */
|
||||
if (ext_type == 10) {
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = 1;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = 1;
|
||||
smp->flags = SMP_F_VOLATILE;
|
||||
return 1;
|
||||
}
|
||||
@ -224,8 +224,8 @@ smp_fetch_ssl_hello_type(const struct arg *args, struct sample *smp, const char
|
||||
goto not_ssl_hello;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = hs_type;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = hs_type;
|
||||
smp->flags = SMP_F_VOLATILE;
|
||||
|
||||
return 1;
|
||||
@ -338,8 +338,8 @@ smp_fetch_req_ssl_ver(const struct arg *args, struct sample *smp, const char *kw
|
||||
/* OK that's enough. We have at least the whole message, and we have
|
||||
* the protocol version.
|
||||
*/
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = version;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = version;
|
||||
smp->flags = SMP_F_VOLATILE;
|
||||
return 1;
|
||||
|
||||
@ -492,9 +492,9 @@ smp_fetch_ssl_hello_sni(const struct arg *args, struct sample *smp, const char *
|
||||
name_len = (data[7] << 8) + data[8];
|
||||
|
||||
if (name_type == 0) { /* hostname */
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = (char *)data + 9;
|
||||
smp->data.str.len = name_len;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = (char *)data + 9;
|
||||
smp->data.data.str.len = name_len;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
|
||||
return 1;
|
||||
}
|
||||
@ -528,7 +528,7 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
|
||||
bleft = s->req.buf->i;
|
||||
if (bleft <= 11)
|
||||
@ -580,8 +580,8 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
|
||||
}
|
||||
|
||||
/* data points to cookie value */
|
||||
smp->data.str.str = (char *)data;
|
||||
smp->data.str.len = 0;
|
||||
smp->data.data.str.str = (char *)data;
|
||||
smp->data.data.str.len = 0;
|
||||
|
||||
while (bleft > 0 && *data != '\r') {
|
||||
data++;
|
||||
@ -594,7 +594,7 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
|
||||
if (data[0] != '\r' || data[1] != '\n')
|
||||
goto not_cookie;
|
||||
|
||||
smp->data.str.len = (char *)data - smp->data.str.str;
|
||||
smp->data.data.str.len = (char *)data - smp->data.data.str.str;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
|
||||
return 1;
|
||||
|
||||
@ -628,8 +628,8 @@ smp_fetch_rdp_cookie_cnt(const struct arg *args, struct sample *smp, const char
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOLATILE;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = ret;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -680,9 +680,9 @@ smp_fetch_payload_lv(const struct arg *arg_p, struct sample *smp, const char *kw
|
||||
goto too_short;
|
||||
|
||||
/* init chunk as read only */
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
|
||||
chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size);
|
||||
chunk_initlen(&smp->data.data.str, chn->buf->p + buf_offset, 0, buf_size);
|
||||
return 1;
|
||||
|
||||
too_short:
|
||||
@ -712,9 +712,9 @@ smp_fetch_payload(const struct arg *arg_p, struct sample *smp, const char *kw, v
|
||||
goto too_short;
|
||||
|
||||
/* init chunk as read only */
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
|
||||
chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset));
|
||||
chunk_initlen(&smp->data.data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset));
|
||||
if (!buf_size && channel_may_recv(chn) && !channel_input_closed(chn))
|
||||
smp->flags |= SMP_F_MAY_CHANGE;
|
||||
|
||||
|
||||
314
src/proto_http.c
314
src/proto_http.c
@ -3682,13 +3682,13 @@ resume_execution:
|
||||
smp = sample_fetch_as_type(px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.act.p[0], SMP_T_ADDR);
|
||||
|
||||
if (smp) {
|
||||
if (smp->type == SMP_T_IPV4) {
|
||||
if (smp->data.type == SMP_T_IPV4) {
|
||||
((struct sockaddr_in *)&cli_conn->addr.from)->sin_family = AF_INET;
|
||||
((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr = smp->data.ipv4.s_addr;
|
||||
((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr = smp->data.data.ipv4.s_addr;
|
||||
((struct sockaddr_in *)&cli_conn->addr.from)->sin_port = 0;
|
||||
} else if (smp->type == SMP_T_IPV6) {
|
||||
} else if (smp->data.type == SMP_T_IPV6) {
|
||||
((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_family = AF_INET6;
|
||||
memcpy(&((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr, &smp->data.ipv6, sizeof(struct in6_addr));
|
||||
memcpy(&((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr, &smp->data.data.ipv6, sizeof(struct in6_addr));
|
||||
((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_port = 0;
|
||||
}
|
||||
}
|
||||
@ -9945,7 +9945,7 @@ smp_prefetch_http(struct proxy *px, struct stream *s, unsigned int opt,
|
||||
msg = &txn->req;
|
||||
|
||||
/* Check for a dependency on a request */
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
|
||||
if ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ) {
|
||||
/* If the buffer does not leave enough free space at the end,
|
||||
@ -9987,7 +9987,7 @@ smp_prefetch_http(struct proxy *px, struct stream *s, unsigned int opt,
|
||||
if (unlikely(s->req.buf->i + s->req.buf->p >
|
||||
s->req.buf->data + s->req.buf->size - global.tune.maxrewrite)) {
|
||||
msg->msg_state = HTTP_MSG_ERROR;
|
||||
smp->data.sint = 1;
|
||||
smp->data.data.sint = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -10014,7 +10014,7 @@ smp_prefetch_http(struct proxy *px, struct stream *s, unsigned int opt,
|
||||
}
|
||||
|
||||
/* everything's OK */
|
||||
smp->data.sint = 1;
|
||||
smp->data.data.sint = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -10068,15 +10068,15 @@ smp_fetch_meth(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
CHECK_HTTP_MESSAGE_FIRST_PERM();
|
||||
|
||||
meth = txn->meth;
|
||||
smp->type = SMP_T_METH;
|
||||
smp->data.meth.meth = meth;
|
||||
smp->data.type = SMP_T_METH;
|
||||
smp->data.data.meth.meth = meth;
|
||||
if (meth == HTTP_METH_OTHER) {
|
||||
if (txn->rsp.msg_state != HTTP_MSG_RPBEFORE)
|
||||
/* ensure the indexes are not affected */
|
||||
return 0;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.meth.str.len = txn->req.sl.rq.m_l;
|
||||
smp->data.meth.str.str = txn->req.chn->buf->p;
|
||||
smp->data.data.meth.str.len = txn->req.sl.rq.m_l;
|
||||
smp->data.data.meth.str.str = txn->req.chn->buf->p;
|
||||
}
|
||||
smp->flags |= SMP_F_VOL_1ST;
|
||||
return 1;
|
||||
@ -10094,19 +10094,19 @@ static struct pattern *pat_match_meth(struct sample *smp, struct pattern_expr *e
|
||||
|
||||
/* well-known method */
|
||||
if (pattern->val.i != HTTP_METH_OTHER) {
|
||||
if (smp->data.meth.meth == pattern->val.i)
|
||||
if (smp->data.data.meth.meth == pattern->val.i)
|
||||
return pattern;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Other method, we must compare the strings */
|
||||
if (pattern->len != smp->data.meth.str.len)
|
||||
if (pattern->len != smp->data.data.meth.str.len)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.meth.str.str, smp->data.meth.str.len) == 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.meth.str.str, smp->data.meth.str.len) == 0))
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.data.meth.str.str, smp->data.data.meth.str.len) == 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.data.meth.str.str, smp->data.data.meth.str.len) == 0))
|
||||
return pattern;
|
||||
}
|
||||
return NULL;
|
||||
@ -10128,9 +10128,9 @@ smp_fetch_rqver(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
if (len <= 0)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = ptr;
|
||||
smp->data.str.len = len;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = ptr;
|
||||
smp->data.data.str.len = len;
|
||||
|
||||
smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
|
||||
return 1;
|
||||
@ -10156,9 +10156,9 @@ smp_fetch_stver(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
if (len <= 0)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = ptr;
|
||||
smp->data.str.len = len;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = ptr;
|
||||
smp->data.data.str.len = len;
|
||||
|
||||
smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
|
||||
return 1;
|
||||
@ -10181,8 +10181,8 @@ smp_fetch_stcode(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
len = txn->rsp.sl.st.c_l;
|
||||
ptr = txn->rsp.chn->buf->p + txn->rsp.sl.st.c;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = __strl2ui(ptr, len);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = __strl2ui(ptr, len);
|
||||
smp->flags = SMP_F_VOL_1ST;
|
||||
return 1;
|
||||
}
|
||||
@ -10216,9 +10216,9 @@ smp_fetch_body(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
|
||||
if (block1 == len) {
|
||||
/* buffer is not wrapped (or empty) */
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.str.str = body;
|
||||
smp->data.str.len = len;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
smp->data.data.str.str = body;
|
||||
smp->data.data.str.len = len;
|
||||
smp->flags = SMP_F_VOL_TEST | SMP_F_CONST;
|
||||
}
|
||||
else {
|
||||
@ -10226,9 +10226,9 @@ smp_fetch_body(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
temp = get_trash_chunk();
|
||||
memcpy(temp->str, body, block1);
|
||||
memcpy(temp->str + block1, msg->chn->buf->data, len - block1);
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.str.str = temp->str;
|
||||
smp->data.str.len = len;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
smp->data.data.str.str = temp->str;
|
||||
smp->data.data.str.len = len;
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
}
|
||||
return 1;
|
||||
@ -10251,8 +10251,8 @@ smp_fetch_body_len(const struct arg *args, struct sample *smp, const char *kw, v
|
||||
else
|
||||
msg = &txn->rsp;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = http_body_bytes(msg);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = http_body_bytes(msg);
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
return 1;
|
||||
@ -10276,8 +10276,8 @@ smp_fetch_body_size(const struct arg *args, struct sample *smp, const char *kw,
|
||||
else
|
||||
msg = &txn->rsp;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = msg->body_len;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = msg->body_len;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
return 1;
|
||||
@ -10293,9 +10293,9 @@ smp_fetch_url(const struct arg *args, struct sample *smp, const char *kw, void *
|
||||
CHECK_HTTP_MESSAGE_FIRST();
|
||||
|
||||
txn = smp->strm->txn;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.len = txn->req.sl.rq.u_l;
|
||||
smp->data.str.str = txn->req.chn->buf->p + txn->req.sl.rq.u;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.len = txn->req.sl.rq.u_l;
|
||||
smp->data.data.str.str = txn->req.chn->buf->p + txn->req.sl.rq.u;
|
||||
smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
|
||||
return 1;
|
||||
}
|
||||
@ -10313,8 +10313,8 @@ smp_fetch_url_ip(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
if (((struct sockaddr_in *)&addr)->sin_family != AF_INET)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_IPV4;
|
||||
smp->data.ipv4 = ((struct sockaddr_in *)&addr)->sin_addr;
|
||||
smp->data.type = SMP_T_IPV4;
|
||||
smp->data.data.ipv4 = ((struct sockaddr_in *)&addr)->sin_addr;
|
||||
smp->flags = 0;
|
||||
return 1;
|
||||
}
|
||||
@ -10332,8 +10332,8 @@ smp_fetch_url_port(const struct arg *args, struct sample *smp, const char *kw, v
|
||||
if (((struct sockaddr_in *)&addr)->sin_family != AF_INET)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = ntohs(((struct sockaddr_in *)&addr)->sin_port);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = ntohs(((struct sockaddr_in *)&addr)->sin_port);
|
||||
smp->flags = 0;
|
||||
return 1;
|
||||
}
|
||||
@ -10389,9 +10389,9 @@ smp_fetch_fhdr(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
/* prepare to report multiple occurrences for ACL fetches */
|
||||
smp->flags |= SMP_F_NOT_LAST;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_VOL_HDR | SMP_F_CONST;
|
||||
if (http_get_fhdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.str.str, &smp->data.str.len))
|
||||
if (http_get_fhdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.data.str.str, &smp->data.data.str.len))
|
||||
return 1;
|
||||
|
||||
smp->flags &= ~SMP_F_NOT_LAST;
|
||||
@ -10427,8 +10427,8 @@ smp_fetch_fhdr_cnt(const struct arg *args, struct sample *smp, const char *kw, v
|
||||
while (http_find_full_header2(name, len, msg->chn->buf->p, idx, &ctx))
|
||||
cnt++;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = cnt;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = cnt;
|
||||
smp->flags = SMP_F_VOL_HDR;
|
||||
return 1;
|
||||
}
|
||||
@ -10460,9 +10460,9 @@ smp_fetch_hdr_names(const struct arg *args, struct sample *smp, const char *kw,
|
||||
temp->len += ctx.del;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = temp->str;
|
||||
smp->data.str.len = temp->len;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = temp->str;
|
||||
smp->data.data.str.len = temp->len;
|
||||
smp->flags = SMP_F_VOL_HDR;
|
||||
return 1;
|
||||
}
|
||||
@ -10517,9 +10517,9 @@ smp_fetch_hdr(const struct arg *args, struct sample *smp, const char *kw, void *
|
||||
/* prepare to report multiple occurrences for ACL fetches */
|
||||
smp->flags |= SMP_F_NOT_LAST;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_VOL_HDR | SMP_F_CONST;
|
||||
if (http_get_hdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.str.str, &smp->data.str.len))
|
||||
if (http_get_hdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.data.str.str, &smp->data.data.str.len))
|
||||
return 1;
|
||||
|
||||
smp->flags &= ~SMP_F_NOT_LAST;
|
||||
@ -10554,8 +10554,8 @@ smp_fetch_hdr_cnt(const struct arg *args, struct sample *smp, const char *kw, vo
|
||||
while (http_find_header2(name, len, msg->chn->buf->p, idx, &ctx))
|
||||
cnt++;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = cnt;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = cnt;
|
||||
smp->flags = SMP_F_VOL_HDR;
|
||||
return 1;
|
||||
}
|
||||
@ -10571,8 +10571,8 @@ smp_fetch_hdr_val(const struct arg *args, struct sample *smp, const char *kw, vo
|
||||
int ret = smp_fetch_hdr(args, smp, kw, private);
|
||||
|
||||
if (ret > 0) {
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = strl2ic(smp->data.str.str, smp->data.str.len);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = strl2ic(smp->data.data.str.str, smp->data.data.str.len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -10588,16 +10588,16 @@ smp_fetch_hdr_ip(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
int ret;
|
||||
|
||||
while ((ret = smp_fetch_hdr(args, smp, kw, private)) > 0) {
|
||||
if (url2ipv4((char *)smp->data.str.str, &smp->data.ipv4)) {
|
||||
smp->type = SMP_T_IPV4;
|
||||
if (url2ipv4((char *)smp->data.data.str.str, &smp->data.data.ipv4)) {
|
||||
smp->data.type = SMP_T_IPV4;
|
||||
break;
|
||||
} else {
|
||||
struct chunk *temp = get_trash_chunk();
|
||||
if (smp->data.str.len < temp->size - 1) {
|
||||
memcpy(temp->str, smp->data.str.str, smp->data.str.len);
|
||||
temp->str[smp->data.str.len] = '\0';
|
||||
if (inet_pton(AF_INET6, temp->str, &smp->data.ipv6)) {
|
||||
smp->type = SMP_T_IPV6;
|
||||
if (smp->data.data.str.len < temp->size - 1) {
|
||||
memcpy(temp->str, smp->data.data.str.str, smp->data.data.str.len);
|
||||
temp->str[smp->data.data.str.len] = '\0';
|
||||
if (inet_pton(AF_INET6, temp->str, &smp->data.data.ipv6)) {
|
||||
smp->data.type = SMP_T_IPV6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -10628,13 +10628,13 @@ smp_fetch_path(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
return 0;
|
||||
|
||||
/* OK, we got the '/' ! */
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = ptr;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = ptr;
|
||||
|
||||
while (ptr < end && *ptr != '?')
|
||||
ptr++;
|
||||
|
||||
smp->data.str.len = ptr - smp->data.str.str;
|
||||
smp->data.data.str.len = ptr - smp->data.data.str.str;
|
||||
smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
|
||||
return 1;
|
||||
}
|
||||
@ -10664,9 +10664,9 @@ smp_fetch_base(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
/* OK we have the header value in ctx.line+ctx.val for ctx.vlen bytes */
|
||||
temp = get_trash_chunk();
|
||||
memcpy(temp->str, ctx.line + ctx.val, ctx.vlen);
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = temp->str;
|
||||
smp->data.str.len = ctx.vlen;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = temp->str;
|
||||
smp->data.data.str.len = ctx.vlen;
|
||||
|
||||
/* now retrieve the path */
|
||||
end = txn->req.chn->buf->p + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
|
||||
@ -10677,8 +10677,8 @@ smp_fetch_base(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
for (ptr = beg; ptr < end && *ptr != '?'; ptr++);
|
||||
|
||||
if (beg < ptr && *beg == '/') {
|
||||
memcpy(smp->data.str.str + smp->data.str.len, beg, ptr - beg);
|
||||
smp->data.str.len += ptr - beg;
|
||||
memcpy(smp->data.data.str.str + smp->data.data.str.len, beg, ptr - beg);
|
||||
smp->data.data.str.len += ptr - beg;
|
||||
}
|
||||
|
||||
smp->flags = SMP_F_VOL_1ST;
|
||||
@ -10728,8 +10728,8 @@ smp_fetch_base32(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
}
|
||||
hash = full_hash(hash);
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = hash;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = hash;
|
||||
smp->flags = SMP_F_VOL_1ST;
|
||||
return 1;
|
||||
}
|
||||
@ -10754,7 +10754,7 @@ smp_fetch_base32_src(const struct arg *args, struct sample *smp, const char *kw,
|
||||
return 0;
|
||||
|
||||
temp = get_trash_chunk();
|
||||
*(unsigned int *)temp->str = htonl(smp->data.sint);
|
||||
*(unsigned int *)temp->str = htonl(smp->data.data.sint);
|
||||
temp->len += sizeof(unsigned int);
|
||||
|
||||
switch (cli_conn->addr.from.ss_family) {
|
||||
@ -10770,8 +10770,8 @@ smp_fetch_base32_src(const struct arg *args, struct sample *smp, const char *kw,
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->data.str = *temp;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.data.str = *temp;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -10797,9 +10797,9 @@ smp_fetch_query(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
return 0;
|
||||
} while (*ptr++ != '?');
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str.str = ptr;
|
||||
smp->data.str.len = end - ptr;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str.str = ptr;
|
||||
smp->data.data.str.len = end - ptr;
|
||||
smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
|
||||
return 1;
|
||||
}
|
||||
@ -10813,8 +10813,8 @@ smp_fetch_proto_http(const struct arg *args, struct sample *smp, const char *kw,
|
||||
|
||||
CHECK_HTTP_MESSAGE_FIRST_PERM();
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = 1;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -10822,8 +10822,8 @@ smp_fetch_proto_http(const struct arg *args, struct sample *smp, const char *kw,
|
||||
static int
|
||||
smp_fetch_http_first_req(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = !(smp->strm->txn->flags & TX_NOT_FIRST);
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = !(smp->strm->txn->flags & TX_NOT_FIRST);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -10840,8 +10840,8 @@ smp_fetch_http_auth(const struct arg *args, struct sample *smp, const char *kw,
|
||||
if (!get_http_auth(smp->strm))
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = check_user(args->data.usr, smp->strm->txn->auth.user,
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = check_user(args->data.usr, smp->strm->txn->auth.user,
|
||||
smp->strm->txn->auth.pass);
|
||||
return 1;
|
||||
}
|
||||
@ -10869,10 +10869,10 @@ smp_fetch_http_auth_grp(const struct arg *args, struct sample *smp, const char *
|
||||
/* pat_match_auth() will need the user list */
|
||||
smp->ctx.a[0] = args->data.usr;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.str.str = smp->strm->txn->auth.user;
|
||||
smp->data.str.len = strlen(smp->strm->txn->auth.user);
|
||||
smp->data.data.str.str = smp->strm->txn->auth.user;
|
||||
smp->data.data.str.len = strlen(smp->strm->txn->auth.user);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -10989,10 +10989,10 @@ smp_fetch_capture_header_req(const struct arg *args, struct sample *smp, const c
|
||||
if (idx > (fe->nb_req_cap - 1) || smp->strm->req_cap == NULL || smp->strm->req_cap[idx] == NULL)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.str = smp->strm->req_cap[idx];
|
||||
smp->data.str.len = strlen(smp->strm->req_cap[idx]);
|
||||
smp->data.data.str.str = smp->strm->req_cap[idx];
|
||||
smp->data.data.str.len = strlen(smp->strm->req_cap[idx]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -11014,10 +11014,10 @@ smp_fetch_capture_header_res(const struct arg *args, struct sample *smp, const c
|
||||
if (idx > (fe->nb_rsp_cap - 1) || smp->strm->res_cap == NULL || smp->strm->res_cap[idx] == NULL)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.str = smp->strm->res_cap[idx];
|
||||
smp->data.str.len = strlen(smp->strm->res_cap[idx]);
|
||||
smp->data.data.str.str = smp->strm->res_cap[idx];
|
||||
smp->data.data.str.len = strlen(smp->strm->res_cap[idx]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -11041,8 +11041,8 @@ smp_fetch_capture_req_method(const struct arg *args, struct sample *smp, const c
|
||||
temp = get_trash_chunk();
|
||||
temp->str = txn->uri;
|
||||
temp->len = ptr - txn->uri;
|
||||
smp->data.str = *temp;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str = *temp;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
|
||||
return 1;
|
||||
@ -11077,9 +11077,9 @@ smp_fetch_capture_req_uri(const struct arg *args, struct sample *smp, const char
|
||||
while (*ptr != ' ' && *ptr != '\0') /* find space after URI */
|
||||
ptr++;
|
||||
|
||||
smp->data.str = *temp;
|
||||
smp->data.str.len = ptr - temp->str;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str = *temp;
|
||||
smp->data.data.str.len = ptr - temp->str;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
|
||||
return 1;
|
||||
@ -11097,12 +11097,12 @@ smp_fetch_capture_req_ver(const struct arg *args, struct sample *smp, const char
|
||||
return 0;
|
||||
|
||||
if (txn->req.flags & HTTP_MSGF_VER_11)
|
||||
smp->data.str.str = "HTTP/1.1";
|
||||
smp->data.data.str.str = "HTTP/1.1";
|
||||
else
|
||||
smp->data.str.str = "HTTP/1.0";
|
||||
smp->data.data.str.str = "HTTP/1.0";
|
||||
|
||||
smp->data.str.len = 8;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str.len = 8;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
return 1;
|
||||
|
||||
@ -11120,12 +11120,12 @@ smp_fetch_capture_res_ver(const struct arg *args, struct sample *smp, const char
|
||||
return 0;
|
||||
|
||||
if (txn->rsp.flags & HTTP_MSGF_VER_11)
|
||||
smp->data.str.str = "HTTP/1.1";
|
||||
smp->data.data.str.str = "HTTP/1.1";
|
||||
else
|
||||
smp->data.str.str = "HTTP/1.0";
|
||||
smp->data.data.str.str = "HTTP/1.0";
|
||||
|
||||
smp->data.str.len = 8;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str.len = 8;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
return 1;
|
||||
|
||||
@ -11212,17 +11212,17 @@ int smp_fetch_cookie(const struct arg *args, struct sample *smp, const char *kw,
|
||||
smp->ctx.a[1] = smp->ctx.a[0] + ctx->vlen;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->ctx.a[0] = extract_cookie_value(smp->ctx.a[0], smp->ctx.a[1],
|
||||
args->data.str.str, args->data.str.len,
|
||||
(smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ,
|
||||
&smp->data.str.str,
|
||||
&smp->data.str.len);
|
||||
&smp->data.data.str.str,
|
||||
&smp->data.data.str.len);
|
||||
if (smp->ctx.a[0]) {
|
||||
found = 1;
|
||||
if (occ >= 0) {
|
||||
/* one value was returned into smp->data.str.{str,len} */
|
||||
/* one value was returned into smp->data.data.str.{str,len} */
|
||||
smp->flags |= SMP_F_NOT_LAST;
|
||||
return 1;
|
||||
}
|
||||
@ -11291,19 +11291,19 @@ smp_fetch_cookie_cnt(const struct arg *args, struct sample *smp, const char *kw,
|
||||
val_end = val_beg + ctx.vlen;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
while ((val_beg = extract_cookie_value(val_beg, val_end,
|
||||
args->data.str.str, args->data.str.len,
|
||||
(smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ,
|
||||
&smp->data.str.str,
|
||||
&smp->data.str.len))) {
|
||||
&smp->data.data.str.str,
|
||||
&smp->data.data.str.len))) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = cnt;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = cnt;
|
||||
smp->flags |= SMP_F_VOL_HDR;
|
||||
return 1;
|
||||
}
|
||||
@ -11317,8 +11317,8 @@ smp_fetch_cookie_val(const struct arg *args, struct sample *smp, const char *kw,
|
||||
int ret = smp_fetch_cookie(args, smp, kw, private);
|
||||
|
||||
if (ret > 0) {
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = strl2ic(smp->data.str.str, smp->data.str.len);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = strl2ic(smp->data.data.str.str, smp->data.data.str.len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -11563,7 +11563,7 @@ smp_fetch_param(char delim, const char *name, int name_len, const struct arg *ar
|
||||
/* Create sample. If the value is contiguous, return the pointer as CONST,
|
||||
* if the value is wrapped, copy-it in a buffer.
|
||||
*/
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
if (chunks[2] &&
|
||||
vstart >= chunks[0] && vstart <= chunks[1] &&
|
||||
vend >= chunks[2] && vend <= chunks[3]) {
|
||||
@ -11571,12 +11571,12 @@ smp_fetch_param(char delim, const char *name, int name_len, const struct arg *ar
|
||||
temp = get_trash_chunk();
|
||||
memcpy(temp->str, vstart, chunks[1] - vstart);
|
||||
memcpy(temp->str + ( chunks[1] - vstart ), chunks[2], vend - chunks[2]);
|
||||
smp->data.str.str = temp->str;
|
||||
smp->data.str.len = ( chunks[1] - vstart ) + ( vend - chunks[2] );
|
||||
smp->data.data.str.str = temp->str;
|
||||
smp->data.data.str.len = ( chunks[1] - vstart ) + ( vend - chunks[2] );
|
||||
} else {
|
||||
/* Contiguous case. */
|
||||
smp->data.str.str = (char *)vstart;
|
||||
smp->data.str.len = vend - vstart;
|
||||
smp->data.data.str.str = (char *)vstart;
|
||||
smp->data.data.str.len = vend - vstart;
|
||||
smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
|
||||
}
|
||||
|
||||
@ -11719,8 +11719,8 @@ smp_fetch_url_param_val(const struct arg *args, struct sample *smp, const char *
|
||||
int ret = smp_fetch_url_param(args, smp, kw, private);
|
||||
|
||||
if (ret > 0) {
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = strl2ic(smp->data.str.str, smp->data.str.len);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = strl2ic(smp->data.data.str.str, smp->data.data.str.len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -11771,8 +11771,8 @@ smp_fetch_url32(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
}
|
||||
hash = full_hash(hash);
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = hash;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = hash;
|
||||
smp->flags = SMP_F_VOL_1ST;
|
||||
return 1;
|
||||
}
|
||||
@ -11795,7 +11795,7 @@ smp_fetch_url32_src(const struct arg *args, struct sample *smp, const char *kw,
|
||||
return 0;
|
||||
|
||||
/* The returned hash is a 32 bytes integer. */
|
||||
hash = smp->data.sint;
|
||||
hash = smp->data.data.sint;
|
||||
|
||||
temp = get_trash_chunk();
|
||||
memcpy(temp->str + temp->len, &hash, sizeof(hash));
|
||||
@ -11814,8 +11814,8 @@ smp_fetch_url32_src(const struct arg *args, struct sample *smp, const char *kw,
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->data.str = *temp;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.data.str = *temp;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -11847,7 +11847,7 @@ static int sample_conv_http_date(const struct arg *args, struct sample *smp, voi
|
||||
struct chunk *temp;
|
||||
struct tm *tm;
|
||||
/* With high numbers, the date returned can be negative, the 55 bits mask prevent this. */
|
||||
time_t curr_date = smp->data.sint & 0x007fffffffffffffLL;
|
||||
time_t curr_date = smp->data.data.sint & 0x007fffffffffffffLL;
|
||||
|
||||
/* add offset */
|
||||
if (args && (args[0].type == ARGT_SINT))
|
||||
@ -11863,8 +11863,8 @@ static int sample_conv_http_date(const struct arg *args, struct sample *smp, voi
|
||||
day[tm->tm_wday], tm->tm_mday, mon[tm->tm_mon], 1900+tm->tm_year,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
smp->data.str = *temp;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str = *temp;
|
||||
smp->data.type = SMP_T_STR;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -11896,8 +11896,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 */
|
||||
static int sample_conv_q_prefered(const struct arg *args, struct sample *smp, void *private)
|
||||
{
|
||||
const char *al = smp->data.str.str;
|
||||
const char *end = al + smp->data.str.len;
|
||||
const char *al = smp->data.data.str.str;
|
||||
const char *end = al + smp->data.data.str.len;
|
||||
const char *token;
|
||||
int toklen;
|
||||
int qvalue;
|
||||
@ -11909,9 +11909,9 @@ static int sample_conv_q_prefered(const struct arg *args, struct sample *smp, vo
|
||||
* function will be peek in the constant configuration string.
|
||||
*/
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.size = 0;
|
||||
smp->data.str.str = "";
|
||||
smp->data.str.len = 0;
|
||||
smp->data.data.str.size = 0;
|
||||
smp->data.data.str.str = "";
|
||||
smp->data.data.str.len = 0;
|
||||
|
||||
/* Parse the accept language */
|
||||
while (1) {
|
||||
@ -12011,8 +12011,8 @@ process_value:
|
||||
* break the process.
|
||||
*/
|
||||
if (qvalue > best_q) {
|
||||
smp->data.str.str = (char *)w;
|
||||
smp->data.str.len = str - w;
|
||||
smp->data.data.str.str = (char *)w;
|
||||
smp->data.data.str.len = str - w;
|
||||
if (qvalue >= 1000)
|
||||
break;
|
||||
best_q = qvalue;
|
||||
@ -12031,13 +12031,13 @@ expect_comma:
|
||||
}
|
||||
|
||||
/* Set default value if required. */
|
||||
if (smp->data.str.len == 0 && args[1].type == ARGT_STR) {
|
||||
smp->data.str.str = args[1].data.str.str;
|
||||
smp->data.str.len = args[1].data.str.len;
|
||||
if (smp->data.data.str.len == 0 && args[1].type == ARGT_STR) {
|
||||
smp->data.data.str.str = args[1].data.str.str;
|
||||
smp->data.data.str.len = args[1].data.str.len;
|
||||
}
|
||||
|
||||
/* Return true only if a matching language was found. */
|
||||
return smp->data.str.len != 0;
|
||||
return smp->data.data.str.len != 0;
|
||||
}
|
||||
|
||||
/* This fetch url-decode any input string. */
|
||||
@ -12047,17 +12047,17 @@ static int sample_conv_url_dec(const struct arg *args, struct sample *smp, void
|
||||
* the end of the buffer, copy the string in other buffer
|
||||
* before decoding.
|
||||
*/
|
||||
if (smp->flags & SMP_F_CONST || smp->data.str.size <= smp->data.str.len) {
|
||||
if (smp->flags & SMP_F_CONST || smp->data.data.str.size <= smp->data.data.str.len) {
|
||||
struct chunk *str = get_trash_chunk();
|
||||
memcpy(str->str, smp->data.str.str, smp->data.str.len);
|
||||
smp->data.str.str = str->str;
|
||||
smp->data.str.size = str->size;
|
||||
memcpy(str->str, smp->data.data.str.str, smp->data.data.str.len);
|
||||
smp->data.data.str.str = str->str;
|
||||
smp->data.data.str.size = str->size;
|
||||
smp->flags &= ~SMP_F_CONST;
|
||||
}
|
||||
|
||||
/* Add final \0 required by url_decode(), and convert the input string. */
|
||||
smp->data.str.str[smp->data.str.len] = '\0';
|
||||
smp->data.str.len = url_decode(smp->data.str.str);
|
||||
smp->data.data.str.str[smp->data.data.str.len] = '\0';
|
||||
smp->data.data.str.len = url_decode(smp->data.data.str.str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -12091,12 +12091,12 @@ static int smp_conv_req_capture(const struct arg *args, struct sample *smp, void
|
||||
return 0;
|
||||
|
||||
/* Check length. */
|
||||
len = smp->data.str.len;
|
||||
len = smp->data.data.str.len;
|
||||
if (len > hdr->len)
|
||||
len = hdr->len;
|
||||
|
||||
/* Capture input data. */
|
||||
memcpy(smp->strm->req_cap[idx], smp->data.str.str, len);
|
||||
memcpy(smp->strm->req_cap[idx], smp->data.data.str.str, len);
|
||||
smp->strm->req_cap[idx][len] = '\0';
|
||||
|
||||
return 1;
|
||||
@ -12132,12 +12132,12 @@ static int smp_conv_res_capture(const struct arg *args, struct sample *smp, void
|
||||
return 0;
|
||||
|
||||
/* Check length. */
|
||||
len = smp->data.str.len;
|
||||
len = smp->data.data.str.len;
|
||||
if (len > hdr->len)
|
||||
len = hdr->len;
|
||||
|
||||
/* Capture input data. */
|
||||
memcpy(smp->strm->res_cap[idx], smp->data.str.str, len);
|
||||
memcpy(smp->strm->res_cap[idx], smp->data.data.str.str, len);
|
||||
smp->strm->res_cap[idx][len] = '\0';
|
||||
|
||||
return 1;
|
||||
@ -12334,11 +12334,11 @@ int http_action_req_capture(struct http_req_rule *rule, struct proxy *px, struct
|
||||
if (cap[h->index] == NULL) /* no more capture memory */
|
||||
return 1;
|
||||
|
||||
len = key->data.str.len;
|
||||
len = key->data.data.str.len;
|
||||
if (len > h->len)
|
||||
len = h->len;
|
||||
|
||||
memcpy(cap[h->index], key->data.str.str, len);
|
||||
memcpy(cap[h->index], key->data.data.str.str, len);
|
||||
cap[h->index][len] = 0;
|
||||
return 1;
|
||||
}
|
||||
@ -12377,11 +12377,11 @@ int http_action_req_capture_by_id(struct http_req_rule *rule, struct proxy *px,
|
||||
if (cap[h->index] == NULL) /* no more capture memory */
|
||||
return 1;
|
||||
|
||||
len = key->data.str.len;
|
||||
len = key->data.data.str.len;
|
||||
if (len > h->len)
|
||||
len = h->len;
|
||||
|
||||
memcpy(cap[h->index], key->data.str.str, len);
|
||||
memcpy(cap[h->index], key->data.data.str.str, len);
|
||||
cap[h->index][len] = 0;
|
||||
return 1;
|
||||
}
|
||||
@ -12546,11 +12546,11 @@ int http_action_res_capture_by_id(struct http_res_rule *rule, struct proxy *px,
|
||||
if (cap[h->index] == NULL) /* no more capture memory */
|
||||
return 1;
|
||||
|
||||
len = key->data.str.len;
|
||||
len = key->data.data.str.len;
|
||||
if (len > h->len)
|
||||
len = h->len;
|
||||
|
||||
memcpy(cap[h->index], key->data.str.str, len);
|
||||
memcpy(cap[h->index], key->data.data.str.str, len);
|
||||
cap[h->index][len] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1222,11 +1222,11 @@ resume_execution:
|
||||
if (cap[h->index] == NULL) /* no more capture memory */
|
||||
continue;
|
||||
|
||||
len = key->data.str.len;
|
||||
len = key->data.data.str.len;
|
||||
if (len > h->len)
|
||||
len = h->len;
|
||||
|
||||
memcpy(cap[h->index], key->data.str.str, len);
|
||||
memcpy(cap[h->index], key->data.data.str.str, len);
|
||||
cap[h->index][len] = 0;
|
||||
}
|
||||
else {
|
||||
@ -1999,12 +1999,12 @@ int smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, vo
|
||||
|
||||
switch (cli_conn->addr.from.ss_family) {
|
||||
case AF_INET:
|
||||
smp->data.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr;
|
||||
smp->type = SMP_T_IPV4;
|
||||
smp->data.data.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr;
|
||||
smp->data.type = SMP_T_IPV4;
|
||||
break;
|
||||
case AF_INET6:
|
||||
smp->data.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr;
|
||||
smp->type = SMP_T_IPV6;
|
||||
smp->data.data.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr;
|
||||
smp->data.type = SMP_T_IPV6;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -2023,8 +2023,8 @@ smp_fetch_sport(const struct arg *args, struct sample *smp, const char *k, void
|
||||
if (!cli_conn)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
if (!(smp->data.sint = get_host_port(&cli_conn->addr.from)))
|
||||
smp->data.type = SMP_T_SINT;
|
||||
if (!(smp->data.data.sint = get_host_port(&cli_conn->addr.from)))
|
||||
return 0;
|
||||
|
||||
smp->flags = 0;
|
||||
@ -2044,12 +2044,12 @@ smp_fetch_dst(const struct arg *args, struct sample *smp, const char *kw, void *
|
||||
|
||||
switch (cli_conn->addr.to.ss_family) {
|
||||
case AF_INET:
|
||||
smp->data.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr;
|
||||
smp->type = SMP_T_IPV4;
|
||||
smp->data.data.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr;
|
||||
smp->data.type = SMP_T_IPV4;
|
||||
break;
|
||||
case AF_INET6:
|
||||
smp->data.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_addr;
|
||||
smp->type = SMP_T_IPV6;
|
||||
smp->data.data.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_addr;
|
||||
smp->data.type = SMP_T_IPV6;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -2070,8 +2070,8 @@ smp_fetch_dport(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
|
||||
conn_get_to_addr(cli_conn);
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
if (!(smp->data.sint = get_host_port(&cli_conn->addr.to)))
|
||||
smp->data.type = SMP_T_SINT;
|
||||
if (!(smp->data.data.sint = get_host_port(&cli_conn->addr.to)))
|
||||
return 0;
|
||||
|
||||
smp->flags = 0;
|
||||
|
||||
462
src/sample.c
462
src/sample.c
File diff suppressed because it is too large
Load Diff
144
src/ssl_sock.c
144
src/ssl_sock.c
@ -3404,8 +3404,8 @@ smp_fetch_ssl_fc_has_crt(const struct arg *args, struct sample *smp, const char
|
||||
}
|
||||
|
||||
smp->flags = 0;
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = SSL_SOCK_ST_FL_VERIFY_DONE & conn->xprt_st ? 1 : 0;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = SSL_SOCK_ST_FL_VERIFY_DONE & conn->xprt_st ? 1 : 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3444,8 +3444,8 @@ smp_fetch_ssl_x_der(const struct arg *args, struct sample *smp, const char *kw,
|
||||
if (ssl_sock_crt2der(crt, smp_trash) <= 0)
|
||||
goto out;
|
||||
|
||||
smp->data.str = *smp_trash;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3488,8 +3488,8 @@ smp_fetch_ssl_x_serial(const struct arg *args, struct sample *smp, const char *k
|
||||
if (ssl_sock_get_serial(crt, smp_trash) <= 0)
|
||||
goto out;
|
||||
|
||||
smp->data.str = *smp_trash;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3532,8 +3532,8 @@ smp_fetch_ssl_x_sha1(const struct arg *args, struct sample *smp, const char *kw,
|
||||
digest = EVP_sha1();
|
||||
X509_digest(crt, digest, (unsigned char *)smp_trash->str, (unsigned int *)&smp_trash->len);
|
||||
|
||||
smp->data.str = *smp_trash;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3575,8 +3575,8 @@ smp_fetch_ssl_x_notafter(const struct arg *args, struct sample *smp, const char
|
||||
if (ssl_sock_get_time(X509_get_notAfter(crt), smp_trash) <= 0)
|
||||
goto out;
|
||||
|
||||
smp->data.str = *smp_trash;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3632,8 +3632,8 @@ smp_fetch_ssl_x_i_dn(const struct arg *args, struct sample *smp, const char *kw,
|
||||
else if (ssl_sock_get_dn_oneline(name, smp_trash) <= 0)
|
||||
goto out;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str = *smp_trash;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3675,8 +3675,8 @@ smp_fetch_ssl_x_notbefore(const struct arg *args, struct sample *smp, const char
|
||||
if (ssl_sock_get_time(X509_get_notBefore(crt), smp_trash) <= 0)
|
||||
goto out;
|
||||
|
||||
smp->data.str = *smp_trash;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3732,8 +3732,8 @@ smp_fetch_ssl_x_s_dn(const struct arg *args, struct sample *smp, const char *kw,
|
||||
else if (ssl_sock_get_dn_oneline(name, smp_trash) <= 0)
|
||||
goto out;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.str = *smp_trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.data.str = *smp_trash;
|
||||
ret = 1;
|
||||
out:
|
||||
/* SSL_get_peer_certificate, it increase X509 * ref count */
|
||||
@ -3764,8 +3764,8 @@ smp_fetch_ssl_c_used(const struct arg *args, struct sample *smp, const char *kw,
|
||||
X509_free(crt);
|
||||
}
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = (crt != NULL);
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = (crt != NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3796,11 +3796,11 @@ smp_fetch_ssl_x_version(const struct arg *args, struct sample *smp, const char *
|
||||
if (!crt)
|
||||
return 0;
|
||||
|
||||
smp->data.sint = (unsigned int)(1 + X509_get_version(crt));
|
||||
smp->data.data.sint = (unsigned int)(1 + X509_get_version(crt));
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3835,17 +3835,17 @@ smp_fetch_ssl_x_sig_alg(const struct arg *args, struct sample *smp, const char *
|
||||
|
||||
nid = OBJ_obj2nid((ASN1_OBJECT *)(crt->cert_info->signature->algorithm));
|
||||
|
||||
smp->data.str.str = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.str.str) {
|
||||
smp->data.data.str.str = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.data.str.str) {
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.len = strlen(smp->data.str.str);
|
||||
smp->data.data.str.len = strlen(smp->data.data.str.str);
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
@ -3883,17 +3883,17 @@ smp_fetch_ssl_x_key_alg(const struct arg *args, struct sample *smp, const char *
|
||||
|
||||
nid = OBJ_obj2nid((ASN1_OBJECT *)(crt->cert_info->key->algor->algorithm));
|
||||
|
||||
smp->data.str.str = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.str.str) {
|
||||
smp->data.data.str.str = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.data.str.str) {
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.len = strlen(smp->data.str.str);
|
||||
smp->data.data.str.len = strlen(smp->data.data.str.str);
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
|
||||
@ -3910,8 +3910,8 @@ smp_fetch_ssl_fc(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
int back_conn = (kw[4] == 'b') ? 1 : 0;
|
||||
struct connection *conn = objt_conn(smp->strm->si[back_conn].end);
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = (conn && conn->xprt == &ssl_sock);
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = (conn && conn->xprt == &ssl_sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3922,8 +3922,8 @@ smp_fetch_ssl_fc_has_sni(const struct arg *args, struct sample *smp, const char
|
||||
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
|
||||
struct connection *conn = objt_conn(smp->sess->origin);
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = (conn && conn->xprt == &ssl_sock) &&
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = (conn && conn->xprt == &ssl_sock) &&
|
||||
conn->xprt_ctx &&
|
||||
SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name) != NULL;
|
||||
return 1;
|
||||
@ -3938,8 +3938,8 @@ smp_fetch_ssl_fc_is_resumed(const struct arg *args, struct sample *smp, const ch
|
||||
{
|
||||
struct connection *conn = objt_conn(smp->sess->origin);
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = (conn && conn->xprt == &ssl_sock) &&
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = (conn && conn->xprt == &ssl_sock) &&
|
||||
conn->xprt_ctx &&
|
||||
SSL_session_reused(conn->xprt_ctx);
|
||||
return 1;
|
||||
@ -3961,13 +3961,13 @@ smp_fetch_ssl_fc_cipher(const struct arg *args, struct sample *smp, const char *
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.str.str = (char *)SSL_get_cipher_name(conn->xprt_ctx);
|
||||
if (!smp->data.str.str)
|
||||
smp->data.data.str.str = (char *)SSL_get_cipher_name(conn->xprt_ctx);
|
||||
if (!smp->data.data.str.str)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.str.len = strlen(smp->data.str.str);
|
||||
smp->data.data.str.len = strlen(smp->data.data.str.str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3993,8 +3993,8 @@ smp_fetch_ssl_fc_alg_keysize(const struct arg *args, struct sample *smp, const c
|
||||
if (!SSL_get_cipher_bits(conn->xprt_ctx, &sint))
|
||||
return 0;
|
||||
|
||||
smp->data.sint = sint;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.data.sint = sint;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -4015,11 +4015,11 @@ smp_fetch_ssl_fc_use_keysize(const struct arg *args, struct sample *smp, const c
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.sint = (unsigned int)SSL_get_cipher_bits(conn->xprt_ctx, NULL);
|
||||
if (!smp->data.sint)
|
||||
smp->data.data.sint = (unsigned int)SSL_get_cipher_bits(conn->xprt_ctx, NULL);
|
||||
if (!smp->data.data.sint)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -4031,17 +4031,17 @@ smp_fetch_ssl_fc_npn(const struct arg *args, struct sample *smp, const char *kw,
|
||||
struct connection *conn;
|
||||
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
|
||||
conn = objt_conn(smp->sess->origin);
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.str.str = NULL;
|
||||
smp->data.data.str.str = NULL;
|
||||
SSL_get0_next_proto_negotiated(conn->xprt_ctx,
|
||||
(const unsigned char **)&smp->data.str.str, (unsigned *)&smp->data.str.len);
|
||||
(const unsigned char **)&smp->data.data.str.str, (unsigned *)&smp->data.data.str.len);
|
||||
|
||||
if (!smp->data.str.str)
|
||||
if (!smp->data.data.str.str)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -4055,17 +4055,17 @@ smp_fetch_ssl_fc_alpn(const struct arg *args, struct sample *smp, const char *kw
|
||||
struct connection *conn;
|
||||
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
|
||||
conn = objt_conn(smp->sess->origin);
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.str.str = NULL;
|
||||
smp->data.data.str.str = NULL;
|
||||
SSL_get0_alpn_selected(conn->xprt_ctx,
|
||||
(const unsigned char **)&smp->data.str.str, (unsigned *)&smp->data.str.len);
|
||||
(const unsigned char **)&smp->data.data.str.str, (unsigned *)&smp->data.data.str.len);
|
||||
|
||||
if (!smp->data.str.str)
|
||||
if (!smp->data.data.str.str)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -4088,13 +4088,13 @@ smp_fetch_ssl_fc_protocol(const struct arg *args, struct sample *smp, const char
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.str.str = (char *)SSL_get_version(conn->xprt_ctx);
|
||||
if (!smp->data.str.str)
|
||||
smp->data.data.str.str = (char *)SSL_get_version(conn->xprt_ctx);
|
||||
if (!smp->data.data.str.str)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.str.len = strlen(smp->data.str.str);
|
||||
smp->data.data.str.len = strlen(smp->data.data.str.str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -4112,7 +4112,7 @@ smp_fetch_ssl_fc_session_id(const struct arg *args, struct sample *smp, const ch
|
||||
struct connection *conn;
|
||||
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
|
||||
conn = objt_conn(smp->strm->si[back_conn].end);
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
@ -4122,8 +4122,8 @@ smp_fetch_ssl_fc_session_id(const struct arg *args, struct sample *smp, const ch
|
||||
if (!ssl_sess)
|
||||
return 0;
|
||||
|
||||
smp->data.str.str = (char *)SSL_SESSION_get_id(ssl_sess, (unsigned int *)&smp->data.str.len);
|
||||
if (!smp->data.str.str || !smp->data.str.len)
|
||||
smp->data.data.str.str = (char *)SSL_SESSION_get_id(ssl_sess, (unsigned int *)&smp->data.data.str.len);
|
||||
if (!smp->data.data.str.str || !smp->data.data.str.len)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -4139,17 +4139,17 @@ smp_fetch_ssl_fc_sni(const struct arg *args, struct sample *smp, const char *kw,
|
||||
struct connection *conn;
|
||||
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->type = SMP_T_STR;
|
||||
smp->data.type = SMP_T_STR;
|
||||
|
||||
conn = objt_conn(smp->sess->origin);
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.str.str = (char *)SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name);
|
||||
if (!smp->data.str.str)
|
||||
smp->data.data.str.str = (char *)SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name);
|
||||
if (!smp->data.data.str.str)
|
||||
return 0;
|
||||
|
||||
smp->data.str.len = strlen(smp->data.str.str);
|
||||
smp->data.data.str.len = strlen(smp->data.data.str.str);
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
@ -4186,8 +4186,8 @@ smp_fetch_ssl_fc_unique_id(const struct arg *args, struct sample *smp, const cha
|
||||
return 0;
|
||||
|
||||
finished_trash->len = finished_len;
|
||||
smp->data.str = *finished_trash;
|
||||
smp->type = SMP_T_BIN;
|
||||
smp->data.data.str = *finished_trash;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
|
||||
return 1;
|
||||
#else
|
||||
@ -4210,8 +4210,8 @@ smp_fetch_ssl_c_ca_err(const struct arg *args, struct sample *smp, const char *k
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = (unsigned long long int)SSL_SOCK_ST_TO_CA_ERROR(conn->xprt_st);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = (unsigned long long int)SSL_SOCK_ST_TO_CA_ERROR(conn->xprt_st);
|
||||
smp->flags = 0;
|
||||
|
||||
return 1;
|
||||
@ -4232,8 +4232,8 @@ smp_fetch_ssl_c_ca_err_depth(const struct arg *args, struct sample *smp, const c
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = (long long int)SSL_SOCK_ST_TO_CAEDEPTH(conn->xprt_st);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = (long long int)SSL_SOCK_ST_TO_CAEDEPTH(conn->xprt_st);
|
||||
smp->flags = 0;
|
||||
|
||||
return 1;
|
||||
@ -4254,8 +4254,8 @@ smp_fetch_ssl_c_err(const struct arg *args, struct sample *smp, const char *kw,
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = (long long int)SSL_SOCK_ST_TO_CRTERROR(conn->xprt_st);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = (long long int)SSL_SOCK_ST_TO_CRTERROR(conn->xprt_st);
|
||||
smp->flags = 0;
|
||||
|
||||
return 1;
|
||||
@ -4279,8 +4279,8 @@ smp_fetch_ssl_c_verify(const struct arg *args, struct sample *smp, const char *k
|
||||
if (!conn->xprt_ctx)
|
||||
return 0;
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = (long long int)SSL_get_verify_result(conn->xprt_ctx);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = (long long int)SSL_get_verify_result(conn->xprt_ctx);
|
||||
smp->flags = 0;
|
||||
|
||||
return 1;
|
||||
|
||||
@ -458,65 +458,65 @@ int stktable_parse_type(char **args, int *myidx, unsigned long *type, size_t *ke
|
||||
|
||||
static void *k_int2int(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
kdata->integer = smp->data.sint;
|
||||
kdata->integer = smp->data.data.sint;
|
||||
return (void *)&kdata->integer;
|
||||
}
|
||||
|
||||
static void *k_ip2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (smp->type == SMP_T_IPV6) {
|
||||
v6tov4(&kdata->ip, &smp->data.ipv6);
|
||||
if (smp->data.type == SMP_T_IPV6) {
|
||||
v6tov4(&kdata->ip, &smp->data.data.ipv6);
|
||||
return (void *)&kdata->ip.s_addr;
|
||||
}
|
||||
else {
|
||||
return (void *)&smp->data.ipv4.s_addr;
|
||||
return (void *)&smp->data.data.ipv4.s_addr;
|
||||
}
|
||||
}
|
||||
|
||||
static void *k_ip2ipv6(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (smp->type == SMP_T_IPV6) {
|
||||
return (void *)&smp->data.ipv6.s6_addr;
|
||||
if (smp->data.type == SMP_T_IPV6) {
|
||||
return (void *)&smp->data.data.ipv6.s6_addr;
|
||||
}
|
||||
else {
|
||||
v4tov6(&kdata->ipv6, &smp->data.ipv4);
|
||||
v4tov6(&kdata->ipv6, &smp->data.data.ipv4);
|
||||
return (void *)&kdata->ipv6.s6_addr;
|
||||
}
|
||||
}
|
||||
|
||||
static void *k_ip2int(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (smp->type == SMP_T_IPV6) {
|
||||
if (!v6tov4(&kdata->ip, &smp->data.ipv6))
|
||||
if (smp->data.type == SMP_T_IPV6) {
|
||||
if (!v6tov4(&kdata->ip, &smp->data.data.ipv6))
|
||||
return NULL;
|
||||
kdata->integer = ntohl(kdata->ip.s_addr);
|
||||
}
|
||||
else {
|
||||
kdata->integer = ntohl(smp->data.ipv4.s_addr);
|
||||
kdata->integer = ntohl(smp->data.data.ipv4.s_addr);
|
||||
}
|
||||
return (void *)&kdata->integer;
|
||||
}
|
||||
|
||||
static void *k_int2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
kdata->ip.s_addr = htonl((unsigned int)smp->data.sint);
|
||||
kdata->ip.s_addr = htonl((unsigned int)smp->data.data.sint);
|
||||
return (void *)&kdata->ip.s_addr;
|
||||
}
|
||||
|
||||
static void *k_str2str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
*len = smp->data.str.len;
|
||||
return (void *)smp->data.str.str;
|
||||
*len = smp->data.data.str.len;
|
||||
return (void *)smp->data.data.str.str;
|
||||
}
|
||||
|
||||
static void *k_ip2str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (smp->type == SMP_T_IPV6) {
|
||||
if (!inet_ntop(AF_INET6, &smp->data.ipv6, kdata->buf, *len))
|
||||
if (smp->data.type == SMP_T_IPV6) {
|
||||
if (!inet_ntop(AF_INET6, &smp->data.data.ipv6, kdata->buf, *len))
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
if (!inet_ntop(AF_INET, &smp->data.ipv4, kdata->buf, *len))
|
||||
if (!inet_ntop(AF_INET, &smp->data.data.ipv4, kdata->buf, *len))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -526,15 +526,15 @@ static void *k_ip2str(struct sample *smp, union stktable_key_data *kdata, size_t
|
||||
|
||||
static void *k_ip2bin(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (smp->type == SMP_T_IPV4) {
|
||||
if (smp->data.type == SMP_T_IPV4) {
|
||||
if (*len > 4)
|
||||
*len = 4;
|
||||
memcpy(kdata->buf, &smp->data.ipv4, *len);
|
||||
memcpy(kdata->buf, &smp->data.data.ipv4, *len);
|
||||
}
|
||||
else if (smp->type == SMP_T_IPV6) {
|
||||
else if (smp->data.type == SMP_T_IPV6) {
|
||||
if (*len > 16)
|
||||
*len = 16;
|
||||
memcpy(kdata->buf, &smp->data.ipv6, *len);
|
||||
memcpy(kdata->buf, &smp->data.data.ipv6, *len);
|
||||
}
|
||||
else
|
||||
*len = 0;
|
||||
@ -548,8 +548,8 @@ static void *k_bin2str(struct sample *smp, union stktable_key_data *kdata, size_
|
||||
int max = *len;
|
||||
int size = 0;
|
||||
|
||||
while (ptr < smp->data.str.len && size <= max - 2) {
|
||||
c = smp->data.str.str[ptr++];
|
||||
while (ptr < smp->data.data.str.len && size <= max - 2) {
|
||||
c = smp->data.data.str.str[ptr++];
|
||||
kdata->buf[size++] = hextab[(c >> 4) & 0xF];
|
||||
kdata->buf[size++] = hextab[c & 0xF];
|
||||
}
|
||||
@ -561,7 +561,7 @@ static void *k_int2str(struct sample *smp, union stktable_key_data *kdata, size_
|
||||
{
|
||||
void *key;
|
||||
|
||||
key = (void *)lltoa_r(smp->data.sint, kdata->buf, *len);
|
||||
key = (void *)lltoa_r(smp->data.data.sint, kdata->buf, *len);
|
||||
if (!key)
|
||||
return NULL;
|
||||
|
||||
@ -571,7 +571,7 @@ static void *k_int2str(struct sample *smp, union stktable_key_data *kdata, size_
|
||||
|
||||
static void *k_str2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (!buf2ip(smp->data.str.str, smp->data.str.len, &kdata->ip))
|
||||
if (!buf2ip(smp->data.data.str.str, smp->data.data.str.len, &kdata->ip))
|
||||
return NULL;
|
||||
|
||||
return (void *)&kdata->ip.s_addr;
|
||||
@ -579,7 +579,7 @@ static void *k_str2ip(struct sample *smp, union stktable_key_data *kdata, size_t
|
||||
|
||||
static void *k_str2ipv6(struct sample *smp, union stktable_key_data *kdata, size_t *len)
|
||||
{
|
||||
if (!inet_pton(AF_INET6, smp->data.str.str, &kdata->ipv6))
|
||||
if (!inet_pton(AF_INET6, smp->data.data.str.str, &kdata->ipv6))
|
||||
return NULL;
|
||||
|
||||
return (void *)&kdata->ipv6.s6_addr;
|
||||
@ -590,8 +590,8 @@ static void *k_str2int(struct sample *smp, union stktable_key_data *kdata, size_
|
||||
int i;
|
||||
|
||||
kdata->integer = 0;
|
||||
for (i = 0; i < smp->data.str.len; i++) {
|
||||
uint32_t val = smp->data.str.str[i] - '0';
|
||||
for (i = 0; i < smp->data.data.str.len; i++) {
|
||||
uint32_t val = smp->data.data.str.str[i] - '0';
|
||||
|
||||
if (val > 9)
|
||||
break;
|
||||
@ -628,11 +628,11 @@ static sample_to_key_fct sample_to_key[SMP_TYPES][STKTABLE_TYPES] = {
|
||||
*/
|
||||
struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t)
|
||||
{
|
||||
if (!sample_to_key[smp->type][t->type])
|
||||
if (!sample_to_key[smp->data.type][t->type])
|
||||
return NULL;
|
||||
|
||||
static_table_key->key_len = t->key_size;
|
||||
static_table_key->key = sample_to_key[smp->type][t->type](smp, &static_table_key->data, &static_table_key->key_len);
|
||||
static_table_key->key = sample_to_key[smp->data.type][t->type](smp, &static_table_key->data, &static_table_key->key_len);
|
||||
|
||||
if (!static_table_key->key)
|
||||
return NULL;
|
||||
@ -643,7 +643,7 @@ struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t)
|
||||
if ((static_table_key->key_len < t->key_size) && (t->type != STKTABLE_TYPE_STRING)) {
|
||||
/* need padding with null */
|
||||
|
||||
/* assume static_table_key.key_len is less than sizeof(static_table_key.data.buf)
|
||||
/* assume static_table_key.key_len is less than sizeof(static_table_key.data.data.buf)
|
||||
cause t->key_size is necessary less than sizeof(static_table_key.data) */
|
||||
|
||||
if ((char *)static_table_key->key > (char *)&static_table_key->data &&
|
||||
@ -811,8 +811,8 @@ static int sample_conv_in_table(const struct arg *arg_p, struct sample *smp, voi
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = !!ts;
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = !!ts;
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
return 1;
|
||||
}
|
||||
@ -837,8 +837,8 @@ static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sampl
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -848,7 +848,7 @@ static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sampl
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
|
||||
t->data_arg[STKTABLE_DT_BYTES_IN_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -873,8 +873,8 @@ static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *sm
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -884,7 +884,7 @@ static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *sm
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, conn_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, conn_cnt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -908,8 +908,8 @@ static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *sm
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -919,7 +919,7 @@ static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *sm
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, conn_cur);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, conn_cur);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -943,8 +943,8 @@ static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *s
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -954,7 +954,7 @@ static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *s
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
|
||||
t->data_arg[STKTABLE_DT_CONN_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -979,8 +979,8 @@ static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct samp
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -990,7 +990,7 @@ static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct samp
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
|
||||
t->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -1015,8 +1015,8 @@ static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, v
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1026,7 +1026,7 @@ static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, v
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, gpc0);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, gpc0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1050,8 +1050,8 @@ static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *s
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1061,7 +1061,7 @@ static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *s
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
|
||||
t->data_arg[STKTABLE_DT_GPC0_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -1086,8 +1086,8 @@ static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1097,7 +1097,7 @@ static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, http_err_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, http_err_cnt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1121,8 +1121,8 @@ static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sampl
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1132,7 +1132,7 @@ static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sampl
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
|
||||
t->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -1157,8 +1157,8 @@ static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1168,7 +1168,7 @@ static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, http_req_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, http_req_cnt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1192,8 +1192,8 @@ static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sampl
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1203,7 +1203,7 @@ static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sampl
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
|
||||
t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -1228,8 +1228,8 @@ static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *s
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1239,7 +1239,7 @@ static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *s
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
|
||||
smp->data.data.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1263,8 +1263,8 @@ static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample *
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1274,7 +1274,7 @@ static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample *
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
|
||||
smp->data.data.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1298,8 +1298,8 @@ static int sample_conv_table_server_id(const struct arg *arg_p, struct sample *s
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1309,7 +1309,7 @@ static int sample_conv_table_server_id(const struct arg *arg_p, struct sample *s
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, server_id);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, server_id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1333,8 +1333,8 @@ static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *sm
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1344,7 +1344,7 @@ static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *sm
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = stktable_data_cast(ptr, sess_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, sess_cnt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1368,8 +1368,8 @@ static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *s
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (!ts) /* key not present */
|
||||
@ -1379,7 +1379,7 @@ static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *s
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
|
||||
t->data_arg[STKTABLE_DT_SESS_RATE].u);
|
||||
return 1;
|
||||
}
|
||||
@ -1403,12 +1403,12 @@ static int sample_conv_table_trackers(const struct arg *arg_p, struct sample *sm
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
ts = stktable_lookup_key(t, key);
|
||||
if (ts)
|
||||
smp->data.sint = ts->ref_cnt;
|
||||
smp->data.data.sint = ts->ref_cnt;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
124
src/stream.c
124
src/stream.c
@ -2671,8 +2671,8 @@ static int
|
||||
smp_fetch_sc_tracked(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.sint = !!smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw);
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.data.sint = !!smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2690,14 +2690,14 @@ smp_fetch_sc_get_gpc0(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, gpc0);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, gpc0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -2716,13 +2716,13 @@ smp_fetch_sc_gpc0_rate(const struct arg *args, struct sample *smp, const char *k
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_GPC0_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -2741,8 +2741,8 @@ smp_fetch_sc_inc_gpc0(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
if (stkctr_entry(stkctr) == NULL)
|
||||
stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw);
|
||||
@ -2757,12 +2757,12 @@ smp_fetch_sc_inc_gpc0(const struct arg *args, struct sample *smp, const char *kw
|
||||
if (ptr1) {
|
||||
update_freq_ctr_period(&stktable_data_cast(ptr1, gpc0_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_GPC0_RATE].u, 1);
|
||||
smp->data.sint = (&stktable_data_cast(ptr1, gpc0_rate))->curr_ctr;
|
||||
smp->data.data.sint = (&stktable_data_cast(ptr1, gpc0_rate))->curr_ctr;
|
||||
}
|
||||
|
||||
ptr2 = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0);
|
||||
if (ptr2)
|
||||
smp->data.sint = ++stktable_data_cast(ptr2, gpc0);
|
||||
smp->data.data.sint = ++stktable_data_cast(ptr2, gpc0);
|
||||
|
||||
/* If data was modified, we need to touch to re-schedule sync */
|
||||
if (ptr1 || ptr2)
|
||||
@ -2784,8 +2784,8 @@ smp_fetch_sc_clr_gpc0(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
|
||||
if (stkctr_entry(stkctr) == NULL)
|
||||
stkctr = smp_create_src_stkctr(smp->sess, smp->strm, args, kw);
|
||||
@ -2794,7 +2794,7 @@ smp_fetch_sc_clr_gpc0(const struct arg *args, struct sample *smp, const char *kw
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_GPC0);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, gpc0);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, gpc0);
|
||||
stktable_data_cast(ptr, gpc0) = 0;
|
||||
/* If data was modified, we need to touch to re-schedule sync */
|
||||
stktable_touch(stkctr->table, stkctr_entry(stkctr), 1);
|
||||
@ -2815,13 +2815,13 @@ smp_fetch_sc_conn_cnt(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_CNT);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, conn_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, conn_cnt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -2839,13 +2839,13 @@ smp_fetch_sc_conn_rate(const struct arg *args, struct sample *smp, const char *k
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_CONN_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -2881,8 +2881,8 @@ smp_fetch_src_updt_conn_cnt(const struct arg *args, struct sample *smp, const ch
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored in this table */
|
||||
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = ++stktable_data_cast(ptr, conn_cnt);
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = ++stktable_data_cast(ptr, conn_cnt);
|
||||
/* Touch was previously performed by stktable_update_key */
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
return 1;
|
||||
@ -2901,13 +2901,13 @@ smp_fetch_sc_conn_cur(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_CUR);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, conn_cur);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, conn_cur);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -2925,13 +2925,13 @@ smp_fetch_sc_sess_cnt(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_SESS_CNT);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, sess_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, sess_cnt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -2948,13 +2948,13 @@ smp_fetch_sc_sess_rate(const struct arg *args, struct sample *smp, const char *k
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_SESS_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_SESS_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -2973,13 +2973,13 @@ smp_fetch_sc_http_req_cnt(const struct arg *args, struct sample *smp, const char
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_REQ_CNT);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, http_req_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, http_req_cnt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -2997,13 +2997,13 @@ smp_fetch_sc_http_req_rate(const struct arg *args, struct sample *smp, const cha
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_REQ_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -3022,13 +3022,13 @@ smp_fetch_sc_http_err_cnt(const struct arg *args, struct sample *smp, const char
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_ERR_CNT);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, http_err_cnt);
|
||||
smp->data.data.sint = stktable_data_cast(ptr, http_err_cnt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -3046,13 +3046,13 @@ smp_fetch_sc_http_err_rate(const struct arg *args, struct sample *smp, const cha
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_HTTP_ERR_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -3071,13 +3071,13 @@ smp_fetch_sc_kbytes_in(const struct arg *args, struct sample *smp, const char *k
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_IN_CNT);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
|
||||
smp->data.data.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -3095,13 +3095,13 @@ smp_fetch_sc_bytes_in_rate(const struct arg *args, struct sample *smp, const cha
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_IN_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_BYTES_IN_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -3120,13 +3120,13 @@ smp_fetch_sc_kbytes_out(const struct arg *args, struct sample *smp, const char *
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_OUT_CNT);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
|
||||
smp->data.data.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -3144,13 +3144,13 @@ smp_fetch_sc_bytes_out_rate(const struct arg *args, struct sample *smp, const ch
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = 0;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = 0;
|
||||
if (stkctr_entry(stkctr) != NULL) {
|
||||
void *ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_BYTES_OUT_RATE);
|
||||
if (!ptr)
|
||||
return 0; /* parameter not stored */
|
||||
smp->data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
|
||||
smp->data.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate),
|
||||
stkctr->table->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u);
|
||||
}
|
||||
return 1;
|
||||
@ -3168,8 +3168,8 @@ smp_fetch_sc_trackers(const struct arg *args, struct sample *smp, const char *kw
|
||||
return 0;
|
||||
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = stkctr_entry(stkctr)->ref_cnt;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = stkctr_entry(stkctr)->ref_cnt;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3180,8 +3180,8 @@ static int
|
||||
smp_fetch_table_cnt(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = args->data.prx->table.current;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = args->data.prx->table.current;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3195,8 +3195,8 @@ smp_fetch_table_avl(const struct arg *args, struct sample *smp, const char *kw,
|
||||
|
||||
px = args->data.prx;
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_SINT;
|
||||
smp->data.sint = px->table.size - px->table.current;
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.data.sint = px->table.size - px->table.current;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
44
src/vars.c
44
src/vars.c
@ -249,9 +249,9 @@ static int smp_fetch_var(const struct arg *args, struct sample *smp, const char
|
||||
return 0;
|
||||
|
||||
/* Copy sample. */
|
||||
smp->type = var->data.type;
|
||||
smp->data.type = var->data.type;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
memcpy(&smp->data, &var->data.data, sizeof(smp->data));
|
||||
memcpy(&smp->data.data, &var->data.data, sizeof(smp->data.data));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -293,50 +293,50 @@ static int sample_store(struct vars *vars, const char *name, struct stream *strm
|
||||
}
|
||||
|
||||
/* Set type. */
|
||||
var->data.type = smp->type;
|
||||
var->data.type = smp->data.type;
|
||||
|
||||
/* Copy data. If the data needs memory, the function can fail. */
|
||||
switch (var->data.type) {
|
||||
case SMP_T_BOOL:
|
||||
case SMP_T_SINT:
|
||||
var->data.data.sint = smp->data.sint;
|
||||
var->data.data.sint = smp->data.data.sint;
|
||||
break;
|
||||
case SMP_T_IPV4:
|
||||
var->data.data.ipv4 = smp->data.ipv4;
|
||||
var->data.data.ipv4 = smp->data.data.ipv4;
|
||||
break;
|
||||
case SMP_T_IPV6:
|
||||
var->data.data.ipv6 = smp->data.ipv6;
|
||||
var->data.data.ipv6 = smp->data.data.ipv6;
|
||||
break;
|
||||
case SMP_T_STR:
|
||||
case SMP_T_BIN:
|
||||
if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.str.len)) {
|
||||
if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.data.str.len)) {
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.data.str.str = malloc(smp->data.str.len);
|
||||
var->data.data.str.str = malloc(smp->data.data.str.len);
|
||||
if (!var->data.data.str.str) {
|
||||
var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.str.len);
|
||||
var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.data.str.len);
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.data.str.len = smp->data.str.len;
|
||||
memcpy(var->data.data.str.str, smp->data.str.str, var->data.data.str.len);
|
||||
var->data.data.str.len = smp->data.data.str.len;
|
||||
memcpy(var->data.data.str.str, smp->data.data.str.str, var->data.data.str.len);
|
||||
break;
|
||||
case SMP_T_METH:
|
||||
if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.meth.str.len)) {
|
||||
if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.data.meth.str.len)) {
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.data.meth.str.str = malloc(smp->data.meth.str.len);
|
||||
var->data.data.meth.str.str = malloc(smp->data.data.meth.str.len);
|
||||
if (!var->data.data.meth.str.str) {
|
||||
var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.meth.str.len);
|
||||
var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.data.meth.str.len);
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.data.meth.meth = smp->data.meth.meth;
|
||||
var->data.data.meth.str.len = smp->data.meth.str.len;
|
||||
var->data.data.meth.str.size = smp->data.meth.str.len;
|
||||
memcpy(var->data.data.meth.str.str, smp->data.meth.str.str, var->data.data.meth.str.len);
|
||||
var->data.data.meth.meth = smp->data.data.meth.meth;
|
||||
var->data.data.meth.str.len = smp->data.data.meth.str.len;
|
||||
var->data.data.meth.str.size = smp->data.data.meth.str.len;
|
||||
memcpy(var->data.data.meth.str.str, smp->data.data.meth.str.str, var->data.data.meth.str.len);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -442,9 +442,9 @@ int vars_get_by_name(const char *name, size_t len, struct stream *strm, struct s
|
||||
return 0;
|
||||
|
||||
/* Copy sample. */
|
||||
smp->type = var->data.type;
|
||||
smp->data.type = var->data.type;
|
||||
smp->flags = SMP_F_CONST;
|
||||
memcpy(&smp->data, &var->data.data, sizeof(smp->data));
|
||||
memcpy(&smp->data.data, &var->data.data, sizeof(smp->data.data));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -476,9 +476,9 @@ int vars_get_by_desc(const struct var_desc *var_desc, struct stream *strm, struc
|
||||
return 0;
|
||||
|
||||
/* Copy sample. */
|
||||
smp->type = var->data.type;
|
||||
smp->data.type = var->data.type;
|
||||
smp->flags = SMP_F_CONST;
|
||||
memcpy(&smp->data, &var->data.data, sizeof(smp->data));
|
||||
memcpy(&smp->data.data, &var->data.data, sizeof(smp->data.data));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user