From 136f9d34a9bd31a956eead8d01e61900d45069a7 Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER Date: Wed, 19 Aug 2015 09:07:19 +0200 Subject: [PATCH] MINOR: samples: rename union from "data" to "u" The union name "data" is a little bit heavy while we read the source code because we can read "data.data.sint". The rename from "data" to "u" makes the read easiest like "data.u.sint". --- include/types/sample.h | 2 +- src/auth.c | 2 +- src/backend.c | 50 +++--- src/compression.c | 6 +- src/da.c | 8 +- src/dumpstats.c | 4 +- src/frontend.c | 6 +- src/hlua.c | 32 ++-- src/listener.c | 4 +- src/log.c | 4 +- src/map.c | 24 +-- src/pattern.c | 118 +++++++------- src/payload.c | 26 ++-- src/proto_http.c | 222 +++++++++++++-------------- src/proto_tcp.c | 16 +- src/sample.c | 340 ++++++++++++++++++++--------------------- src/ssl_sock.c | 88 +++++------ src/stick_table.c | 114 +++++++------- src/stream.c | 80 +++++----- src/vars.c | 64 ++++---- 20 files changed, 605 insertions(+), 605 deletions(-) diff --git a/include/types/sample.h b/include/types/sample.h index 6d30943e5..1ec9eedf2 100644 --- a/include/types/sample.h +++ b/include/types/sample.h @@ -253,7 +253,7 @@ union sample_value { /* Used to store sample constant */ struct sample_data { int type; /* SMP_T_* */ - union sample_value data; /* sample data */ + union sample_value u; /* sample data */ }; /* a sample is a typed data extracted from a stream. It has a type, contents, diff --git a/src/auth.c b/src/auth.c index 7f6ad0aa1..9a988a160 100644 --- a/src/auth.c +++ b/src/auth.c @@ -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.data.str.str, u->user) == 0) + if (strcmp(smp->data.u.str.str, u->user) == 0) break; } if (!u) diff --git a/src/backend.c b/src/backend.c index adfd38824..39efd172f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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.data.str.len; + len = smp.data.u.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.data.str.str, len); + hash = gen_hash(px, smp.data.u.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.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); + if (smp->data.u.str.len >= smp->data.u.str.size) + smp->data.u.str.len = smp->data.u.str.size - 1; + smp->data.u.str.str[smp->data.u.str.len] = 0; + ssl_sock_set_servername(srv_conn, smp->data.u.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.data.str.len == 0) + if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.u.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 and should return */ - addr.sin_addr.s_addr = strtoul(smp.data.data.str.str, &p, 10); + addr.sin_addr.s_addr = strtoul(smp.data.u.str.str, &p, 10); if (*p != '.') goto no_cookie; p++; @@ -1606,11 +1606,11 @@ smp_fetch_nbsrv(const struct arg *args, struct sample *smp, const char *kw, void px = args->data.prx; if (px->srv_act) - smp->data.data.sint = px->srv_act; + smp->data.u.sint = px->srv_act; else if (px->lbprm.fbck) - smp->data.data.sint = 1; + smp->data.u.sint = 1; else - smp->data.data.sint = px->srv_bck; + smp->data.u.sint = px->srv_bck; return 1; } @@ -1629,9 +1629,9 @@ smp_fetch_srv_is_up(const struct arg *args, struct sample *smp, const char *kw, 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.data.sint = 1; + smp->data.u.sint = 1; else - smp->data.data.sint = 0; + smp->data.u.sint = 0; return 1; } @@ -1646,7 +1646,7 @@ smp_fetch_connslots(const struct arg *args, struct sample *smp, const char *kw, smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = -1; /* FIXME: stupid value! */ + smp->data.u.sint = -1; /* FIXME: stupid value! */ return 1; } - smp->data.data.sint += (iterator->maxconn - iterator->cur_sess) + smp->data.u.sint += (iterator->maxconn - iterator->cur_sess) + (iterator->maxqueue - iterator->nbpend); } @@ -1671,7 +1671,7 @@ smp_fetch_be_id(const struct arg *args, struct sample *smp, const char *kw, void { smp->flags = SMP_F_VOL_TXN; smp->data.type = SMP_T_SINT; - smp->data.data.sint = smp->strm->be->uuid; + smp->data.u.sint = smp->strm->be->uuid; return 1; } @@ -1683,7 +1683,7 @@ smp_fetch_srv_id(const struct arg *args, struct sample *smp, const char *kw, voi return 0; smp->data.type = SMP_T_SINT; - smp->data.data.sint = objt_server(smp->strm->target)->puid; + smp->data.u.sint = objt_server(smp->strm->target)->puid; return 1; } @@ -1697,7 +1697,7 @@ smp_fetch_be_sess_rate(const struct arg *args, struct sample *smp, const char *k { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = read_freq_ctr(&args->data.prx->be_sess_per_sec); + smp->data.u.sint = read_freq_ctr(&args->data.prx->be_sess_per_sec); return 1; } @@ -1710,7 +1710,7 @@ smp_fetch_be_conn(const struct arg *args, struct sample *smp, const char *kw, vo { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = args->data.prx->beconn; + smp->data.u.sint = args->data.prx->beconn; return 1; } @@ -1723,7 +1723,7 @@ smp_fetch_queue_size(const struct arg *args, struct sample *smp, const char *kw, { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = args->data.prx->totpend; + smp->data.u.sint = args->data.prx->totpend; return 1; } @@ -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.data.sint = (px->totpend + nbsrv - 1) / nbsrv; + smp->data.u.sint = (px->totpend + nbsrv - 1) / nbsrv; else - smp->data.data.sint = px->totpend * 2; + smp->data.u.sint = px->totpend * 2; return 1; } @@ -1769,7 +1769,7 @@ smp_fetch_srv_conn(const struct arg *args, struct sample *smp, const char *kw, v { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = args->data.srv->cur_sess; + smp->data.u.sint = args->data.srv->cur_sess; return 1; } @@ -1782,7 +1782,7 @@ smp_fetch_srv_sess_rate(const struct arg *args, struct sample *smp, const char * { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = read_freq_ctr(&args->data.srv->sess_per_sec); + smp->data.u.sint = read_freq_ctr(&args->data.srv->sess_per_sec); return 1; } diff --git a/src/compression.c b/src/compression.c index eddf944c4..97f1fd7fc 100644 --- a/src/compression.c +++ b/src/compression.c @@ -841,7 +841,7 @@ static int smp_fetch_res_comp(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = (smp->strm->comp_algo != NULL); + smp->data.u.sint = (smp->strm->comp_algo != NULL); return 1; } @@ -854,8 +854,8 @@ smp_fetch_res_comp_algo(const struct arg *args, struct sample *smp, const char * smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; - smp->data.data.str.str = smp->strm->comp_algo->cfg_name; - smp->data.data.str.len = smp->strm->comp_algo->cfg_name_len; + smp->data.u.str.str = smp->strm->comp_algo->cfg_name; + smp->data.u.str.len = smp->strm->comp_algo->cfg_name_len; return 1; } diff --git a/src/da.c b/src/da.c index a2e78c6d8..7f507ead4 100644 --- a/src/da.c +++ b/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.data.str.len > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.data.str.len; - memcpy(useragentbuf, smp->data.data.str.str, i - 1); + i = smp->data.u.str.len > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.u.str.len; + memcpy(useragentbuf, smp->data.u.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.data.str.str = tmp->str; - smp->data.data.str.len = strlen(tmp->str); + smp->data.u.str.str = tmp->str; + smp->data.u.str.len = strlen(tmp->str); return 1; } diff --git a/src/dumpstats.c b/src/dumpstats.c index 2d091af8c..d1c48859e 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -5635,8 +5635,8 @@ static int stats_map_lookup(struct stream_interface *si) /* execute pattern matching */ sample.data.type = SMP_T_STR; sample.flags |= SMP_F_CONST; - sample.data.data.str.len = appctx->ctx.map.chunk.len; - sample.data.data.str.str = appctx->ctx.map.chunk.str; + sample.data.u.str.len = appctx->ctx.map.chunk.len; + sample.data.u.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); diff --git a/src/frontend.c b/src/frontend.c index 9e64b3822..74ec0ab6e 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -163,7 +163,7 @@ smp_fetch_fe_id(const struct arg *args, struct sample *smp, const char *kw, void { smp->flags = SMP_F_VOL_SESS; smp->data.type = SMP_T_SINT; - smp->data.data.sint = smp->sess->fe->uuid; + smp->data.u.sint = smp->sess->fe->uuid; return 1; } @@ -176,7 +176,7 @@ smp_fetch_fe_sess_rate(const struct arg *args, struct sample *smp, const char *k { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = read_freq_ctr(&args->data.prx->fe_sess_per_sec); + smp->data.u.sint = read_freq_ctr(&args->data.prx->fe_sess_per_sec); return 1; } @@ -189,7 +189,7 @@ smp_fetch_fe_conn(const struct arg *args, struct sample *smp, const char *kw, vo { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = args->data.prx->feconn; + smp->data.u.sint = args->data.prx->feconn; return 1; } diff --git a/src/hlua.c b/src/hlua.c index c38e582d0..3dc6f3f3b 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -385,16 +385,16 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp) switch (smp->data.type) { case SMP_T_SINT: case SMP_T_BOOL: - lua_pushinteger(L, smp->data.data.sint); + lua_pushinteger(L, smp->data.u.sint); break; case SMP_T_BIN: case SMP_T_STR: - lua_pushlstring(L, smp->data.data.str.str, smp->data.data.str.len); + lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len); break; case SMP_T_METH: - switch (smp->data.data.meth.meth) { + switch (smp->data.u.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.data.meth.str.str, smp->data.data.meth.str.len); + lua_pushlstring(L, smp->data.u.meth.str.str, smp->data.u.meth.str.len); break; default: lua_pushnil(L); @@ -417,7 +417,7 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp) case SMP_T_ADDR: /* This type is never used to qualify a sample. */ 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); + lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len); else lua_pushnil(L); break; @@ -438,11 +438,11 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp) case SMP_T_BIN: case SMP_T_STR: - lua_pushlstring(L, smp->data.data.str.str, smp->data.data.str.len); + lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len); break; case SMP_T_METH: - switch (smp->data.data.meth.meth) { + switch (smp->data.u.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.data.meth.str.str, smp->data.data.meth.str.len); + lua_pushlstring(L, smp->data.u.meth.str.str, smp->data.u.meth.str.len); break; default: lua_pushstring(L, ""); @@ -467,7 +467,7 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp) case SMP_T_ADDR: /* This type is never used to qualify a sample. */ 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); + lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len); else lua_pushstring(L, ""); break; @@ -488,19 +488,19 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp) case LUA_TNUMBER: smp->data.type = SMP_T_SINT; - smp->data.data.sint = lua_tointeger(L, ud); + smp->data.u.sint = lua_tointeger(L, ud); break; case LUA_TBOOLEAN: smp->data.type = SMP_T_BOOL; - smp->data.data.sint = lua_toboolean(L, ud); + smp->data.u.sint = lua_toboolean(L, ud); break; case LUA_TSTRING: smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str.str = (char *)lua_tolstring(L, ud, (size_t *)&smp->data.data.str.len); + smp->data.u.str.str = (char *)lua_tolstring(L, ud, (size_t *)&smp->data.u.str.len); break; case LUA_TUSERDATA: @@ -510,7 +510,7 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp) case LUA_TTHREAD: case LUA_TLIGHTUSERDATA: smp->data.type = SMP_T_BOOL; - smp->data.data.sint = 0; + smp->data.u.sint = 0; break; } return 1; @@ -1370,12 +1370,12 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str) desc = MAY_LJMP(hlua_checkmap(L, 1)); if (desc->pat.expect_type == SMP_T_SINT) { smp.data.type = SMP_T_SINT; - smp.data.data.sint = MAY_LJMP(luaL_checkinteger(L, 2)); + smp.data.u.sint = MAY_LJMP(luaL_checkinteger(L, 2)); } else { smp.data.type = SMP_T_STR; smp.flags = SMP_F_CONST; - smp.data.data.str.str = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.data.str.len)); + smp.data.u.str.str = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.u.str.len)); } pat = pattern_exec_match(&desc->pat, &smp, 1); @@ -1388,7 +1388,7 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str) } /* The Lua pattern must return a string, so we can't check the returned type */ - lua_pushlstring(L, pat->data->data.str.str, pat->data->data.str.len); + lua_pushlstring(L, pat->data->u.str.str, pat->data->u.str.len); return 1; } diff --git a/src/listener.c b/src/listener.c index a2d1890e1..3759c78f8 100644 --- a/src/listener.c +++ b/src/listener.c @@ -594,7 +594,7 @@ static int smp_fetch_dconn(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = smp->sess->listener->nbconn; + smp->data.u.sint = smp->sess->listener->nbconn; return 1; } @@ -603,7 +603,7 @@ static int smp_fetch_so_id(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = smp->sess->listener->luid; + smp->data.u.sint = smp->sess->listener->luid; return 1; } diff --git a/src/log.c b/src/log.c index 2a2d09ba2..ef7005aed 100644 --- a/src/log.c +++ b/src/log.c @@ -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.data.str : &empty); + '%', http_encode_map, key ? &key->data.u.str : &empty); else - ret = lf_text_len(tmplog, key ? key->data.data.str.str : NULL, key ? key->data.data.str.len : 0, dst + maxsize - tmplog, tmp); + ret = lf_text_len(tmplog, key ? key->data.u.str.str : NULL, key ? key->data.u.str.len : 0, dst + maxsize - tmplog, tmp); if (ret == 0) goto out; tmplog = ret; diff --git a/src/map.c b/src/map.c index 2a8f95c73..73e057ed6 100644 --- a/src/map.c +++ b/src/map.c @@ -29,7 +29,7 @@ */ int map_parse_ip(const char *text, struct sample_data *data) { - if (!buf2ip(text, strlen(text), &data->data.ipv4)) + if (!buf2ip(text, strlen(text), &data->u.ipv4)) return 0; data->type = SMP_T_IPV4; return 1; @@ -40,7 +40,7 @@ int map_parse_ip(const char *text, struct sample_data *data) */ int map_parse_ip6(const char *text, struct sample_data *data) { - if (!buf2ip6(text, strlen(text), &data->data.ipv6)) + if (!buf2ip6(text, strlen(text), &data->u.ipv6)) return 0; data->type = SMP_T_IPV6; return 1; @@ -54,9 +54,9 @@ int map_parse_ip6(const char *text, struct sample_data *data) */ int map_parse_str(const char *text, struct sample_data *data) { - data->data.str.str = (char *)text; - data->data.str.len = strlen(text); - data->data.str.size = data->data.str.len + 1; + data->u.str.str = (char *)text; + data->u.str.len = strlen(text); + data->u.str.size = data->u.str.len + 1; data->type = SMP_T_STR; return 1; } @@ -68,7 +68,7 @@ int map_parse_str(const char *text, struct sample_data *data) int map_parse_int(const char *text, struct sample_data *data) { data->type = SMP_T_SINT; - data->data.sint = read_int64(&text, text + strlen(text)); + data->u.sint = read_int64(&text, text + strlen(text)); if (*text != '\0') return 0; return 1; @@ -163,13 +163,13 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *pr if (pat->data) { smp->data.type = pat->data->type; smp->flags |= SMP_F_CONST; - memcpy(&smp->data.data, &pat->data->data, sizeof(smp->data.data)); + memcpy(&smp->data.u, &pat->data->u, sizeof(smp->data.u)); return 1; } /* Return just int sample containing 1. */ smp->data.type = SMP_T_SINT; - smp->data.data.sint = 1; + smp->data.u.sint = 1; return 1; } @@ -183,22 +183,22 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *pr case SMP_T_STR: smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str = arg_p[1].data.str; + smp->data.u.str = arg_p[1].data.str; break; case SMP_T_SINT: smp->data.type = SMP_T_SINT; - smp->data.data.sint = arg_p[1].data.sint; + smp->data.u.sint = arg_p[1].data.sint; break; case SMP_T_IPV4: smp->data.type = SMP_T_IPV4; - smp->data.data.ipv4 = arg_p[1].data.ipv4; + smp->data.u.ipv4 = arg_p[1].data.ipv4; break; case SMP_T_IPV6: smp->data.type = SMP_T_IPV6; - smp->data.data.ipv6 = arg_p[1].data.ipv6; + smp->data.u.ipv6 = arg_p[1].data.ipv6; break; } diff --git a/src/pattern.c b/src/pattern.c index d91286e5d..07e1a524d 100644 --- a/src/pattern.c +++ b/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.data.sint) { + if (smp->data.u.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.data.str.str[smp->data.data.str.len]; + prev = smp->data.u.str.str[smp->data.u.str.len]; if (prev) - smp->data.data.str.str[smp->data.data.str.len] = '\0'; - node = ebst_lookup(&expr->pattern_tree, smp->data.data.str.str); + smp->data.u.str.str[smp->data.u.str.len] = '\0'; + node = ebst_lookup(&expr->pattern_tree, smp->data.u.str.str); if (prev) - smp->data.data.str.str[smp->data.data.str.len] = prev; + smp->data.u.str.str[smp->data.u.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.data.str.str, smp->data.data.str.len, seed), + lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.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.data.str.len) + if (pattern->len != smp->data.u.str.len) continue; icase = expr->mflags & PAT_MF_IGNORE_CASE; - 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)) { + if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.str, smp->data.u.str.len) == 0) || + (!icase && strncmp(pattern->ptr.str, smp->data.u.str.str, smp->data.u.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.data.str.str, smp->data.data.str.len, seed), + lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.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.data.str.len) + if (pattern->len != smp->data.u.str.len) continue; - if (memcmp(pattern->ptr.str, smp->data.data.str.str, smp->data.data.str.len) == 0) { + if (memcmp(pattern->ptr.str, smp->data.u.str.str, smp->data.u.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.data.str.str, smp->data.data.str.len, seed), + lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.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.data.str.str, smp->data.data.str.len)) { + if (regex_exec2(pattern->ptr.reg, smp->data.u.str.str, smp->data.u.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.data.str.str[smp->data.data.str.len]; + prev = smp->data.u.str.str[smp->data.u.str.len]; if (prev) - smp->data.data.str.str[smp->data.data.str.len] = '\0'; - node = ebmb_lookup_longest(&expr->pattern_tree, smp->data.data.str.str); + smp->data.u.str.str[smp->data.u.str.len] = '\0'; + node = ebmb_lookup_longest(&expr->pattern_tree, smp->data.u.str.str); if (prev) - smp->data.data.str.str[smp->data.data.str.len] = prev; + smp->data.u.str.str[smp->data.u.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.data.str.str, smp->data.data.str.len, seed), + lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.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.data.str.len) + if (pattern->len > smp->data.u.str.len) continue; icase = expr->mflags & PAT_MF_IGNORE_CASE; - 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)) + if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.str, pattern->len) != 0) || + (!icase && strncmp(pattern->ptr.str, smp->data.u.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.data.str.str, smp->data.data.str.len, seed), + lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.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.data.str.len) + if (pattern->len > smp->data.u.str.len) continue; icase = expr->mflags & PAT_MF_IGNORE_CASE; - 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)) + if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.str + smp->data.u.str.len - pattern->len, pattern->len) != 0) || + (!icase && strncmp(pattern->ptr.str, smp->data.u.str.str + smp->data.u.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.data.str.str, smp->data.data.str.len, seed), + lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.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.data.str.len) + if (pattern->len > smp->data.u.str.len) continue; - end = smp->data.data.str.str + smp->data.data.str.len - pattern->len; + end = smp->data.u.str.str + smp->data.u.str.len - pattern->len; icase = expr->mflags & PAT_MF_IGNORE_CASE; if (icase) { - for (c = smp->data.data.str.str; c <= end; c++) { + for (c = smp->data.u.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.data.str.str; c <= end; c++) { + for (c = smp->data.u.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.data.str.len) + if (pl > smp->data.u.str.len) return PAT_NOMATCH; may_match = 1; icase = mflags & PAT_MF_IGNORE_CASE; - end = smp->data.data.str.str + smp->data.data.str.len - pl; - for (c = smp->data.data.str.str; c <= end; c++) { + end = smp->data.u.str.str + smp->data.u.str.len - pl; + for (c = smp->data.u.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.data.sint) && - (!pattern->val.range.max_set || smp->data.data.sint <= pattern->val.range.max)) + if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.u.sint) && + (!pattern->val.range.max_set || smp->data.u.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.data.str.len) && - (!pattern->val.range.max_set || smp->data.data.str.len <= pattern->val.range.max)) + if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.u.str.len) && + (!pattern->val.range.max_set || smp->data.u.str.len <= pattern->val.range.max)) return pattern; } return NULL; @@ -869,7 +869,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int /* Lookup an IPv4 address in the expression's pattern tree using * the longest match method. */ - s = &smp->data.data.ipv4; + s = &smp->data.u.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.data.ipv4.s_addr; + *(uint32_t*)&tmp6.s6_addr[12] = smp->data.u.ipv4.s_addr; node = ebmb_lookup_longest(&expr->pattern_tree_2, &tmp6); if (node) { if (fill) { @@ -912,7 +912,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int /* 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.data.ipv6); + node = ebmb_lookup_longest(&expr->pattern_tree_2, &smp->data.u.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.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]; + if ((*(uint32_t*)&smp->data.u.ipv6.s6_addr[0] == 0 && + *(uint32_t*)&smp->data.u.ipv6.s6_addr[4] == 0 && + (*(uint32_t*)&smp->data.u.ipv6.s6_addr[8] == 0 || + *(uint32_t*)&smp->data.u.ipv6.s6_addr[8] == htonl(0xFFFF))) || + *(uint16_t*)&smp->data.u.ipv6.s6_addr[0] == htons(0x2002)) { + if (*(uint32_t*)&smp->data.u.ipv6.s6_addr[0] == 0) + v4 = *(uint32_t*)&smp->data.u.ipv6.s6_addr[12]; else - v4 = htonl((ntohs(*(uint16_t*)&smp->data.data.ipv6.s6_addr[2]) << 16) + - ntohs(*(uint16_t*)&smp->data.data.ipv6.s6_addr[4])); + v4 = htonl((ntohs(*(uint16_t*)&smp->data.u.ipv6.s6_addr[2]) << 16) + + ntohs(*(uint16_t*)&smp->data.u.ipv6.s6_addr[4])); /* Lookup an IPv4 address in the expression's pattern tree using the longest * match method. @@ -969,7 +969,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int /* The input sample is IPv4, use it as is. */ if (smp->data.type == SMP_T_IPV4) { - v4 = smp->data.data.ipv4.s_addr; + v4 = smp->data.u.ipv4.s_addr; } else if (smp->data.type == SMP_T_IPV6) { /* v4 match on a V6 sample. We want to check at least for @@ -978,15 +978,15 @@ 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.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]; + if (*(uint32_t*)&smp->data.u.ipv6.s6_addr[0] == 0 && + *(uint32_t*)&smp->data.u.ipv6.s6_addr[4] == 0 && + (*(uint32_t*)&smp->data.u.ipv6.s6_addr[8] == 0 || + *(uint32_t*)&smp->data.u.ipv6.s6_addr[8] == htonl(0xFFFF))) { + v4 = *(uint32_t*)&smp->data.u.ipv6.s6_addr[12]; } - 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 if (*(uint16_t*)&smp->data.u.ipv6.s6_addr[0] == htons(0x2002)) { + v4 = htonl((ntohs(*(uint16_t*)&smp->data.u.ipv6.s6_addr[2]) << 16) + + ntohs(*(uint16_t*)&smp->data.u.ipv6.s6_addr[4])); } else continue; diff --git a/src/payload.c b/src/payload.c index 4c140d05d..378927a7d 100644 --- a/src/payload.c +++ b/src/payload.c @@ -36,7 +36,7 @@ smp_fetch_wait_end(const struct arg *args, struct sample *smp, const char *kw, v return 0; } smp->data.type = SMP_T_BOOL; - smp->data.data.sint = 1; + smp->data.u.sint = 1; return 1; } @@ -51,7 +51,7 @@ smp_fetch_len(const struct arg *args, struct sample *smp, const char *kw, void * return 0; smp->data.type = SMP_T_SINT; - smp->data.data.sint = chn->buf->i; + smp->data.u.sint = chn->buf->i; smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE; return 1; } @@ -160,7 +160,7 @@ smp_fetch_req_ssl_ec_ext(const struct arg *args, struct sample *smp, const char /* Elliptic curves extension */ if (ext_type == 10) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = 1; + smp->data.u.sint = 1; smp->flags = SMP_F_VOLATILE; return 1; } @@ -225,7 +225,7 @@ smp_fetch_ssl_hello_type(const struct arg *args, struct sample *smp, const char } smp->data.type = SMP_T_SINT; - smp->data.data.sint = hs_type; + smp->data.u.sint = hs_type; smp->flags = SMP_F_VOLATILE; return 1; @@ -339,7 +339,7 @@ smp_fetch_req_ssl_ver(const struct arg *args, struct sample *smp, const char *kw * the protocol version. */ smp->data.type = SMP_T_SINT; - smp->data.data.sint = version; + smp->data.u.sint = version; smp->flags = SMP_F_VOLATILE; return 1; @@ -493,8 +493,8 @@ smp_fetch_ssl_hello_sni(const struct arg *args, struct sample *smp, const char * if (name_type == 0) { /* hostname */ smp->data.type = SMP_T_STR; - smp->data.data.str.str = (char *)data + 9; - smp->data.data.str.len = name_len; + smp->data.u.str.str = (char *)data + 9; + smp->data.u.str.len = name_len; smp->flags = SMP_F_VOLATILE | SMP_F_CONST; return 1; } @@ -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.data.str.str = (char *)data; - smp->data.data.str.len = 0; + smp->data.u.str.str = (char *)data; + smp->data.u.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.data.str.len = (char *)data - smp->data.data.str.str; + smp->data.u.str.len = (char *)data - smp->data.u.str.str; smp->flags = SMP_F_VOLATILE | SMP_F_CONST; return 1; @@ -629,7 +629,7 @@ smp_fetch_rdp_cookie_cnt(const struct arg *args, struct sample *smp, const char smp->flags = SMP_F_VOLATILE; smp->data.type = SMP_T_SINT; - smp->data.data.sint = ret; + smp->data.u.sint = ret; return 1; } @@ -682,7 +682,7 @@ smp_fetch_payload_lv(const struct arg *arg_p, struct sample *smp, const char *kw /* init chunk as read only */ smp->data.type = SMP_T_BIN; smp->flags = SMP_F_VOLATILE | SMP_F_CONST; - chunk_initlen(&smp->data.data.str, chn->buf->p + buf_offset, 0, buf_size); + chunk_initlen(&smp->data.u.str, chn->buf->p + buf_offset, 0, buf_size); return 1; too_short: @@ -714,7 +714,7 @@ smp_fetch_payload(const struct arg *arg_p, struct sample *smp, const char *kw, v /* init chunk as read only */ smp->data.type = SMP_T_BIN; smp->flags = SMP_F_VOLATILE | SMP_F_CONST; - chunk_initlen(&smp->data.data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset)); + chunk_initlen(&smp->data.u.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; diff --git a/src/proto_http.c b/src/proto_http.c index 848e870f6..ca125243d 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3684,11 +3684,11 @@ resume_execution: if (smp) { 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.data.ipv4.s_addr; + ((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr = smp->data.u.ipv4.s_addr; ((struct sockaddr_in *)&cli_conn->addr.from)->sin_port = 0; } 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.data.ipv6, sizeof(struct in6_addr)); + memcpy(&((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr, &smp->data.u.ipv6, sizeof(struct in6_addr)); ((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_port = 0; } } @@ -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.data.sint = 1; + smp->data.u.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.data.sint = 1; + smp->data.u.sint = 1; return 1; } @@ -10069,14 +10069,14 @@ smp_fetch_meth(const struct arg *args, struct sample *smp, const char *kw, void meth = txn->meth; smp->data.type = SMP_T_METH; - smp->data.data.meth.meth = meth; + smp->data.u.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.data.meth.str.len = txn->req.sl.rq.m_l; - smp->data.data.meth.str.str = txn->req.chn->buf->p; + smp->data.u.meth.str.len = txn->req.sl.rq.m_l; + smp->data.u.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.data.meth.meth == pattern->val.i) + if (smp->data.u.meth.meth == pattern->val.i) return pattern; else continue; } /* Other method, we must compare the strings */ - if (pattern->len != smp->data.data.meth.str.len) + if (pattern->len != smp->data.u.meth.str.len) continue; icase = expr->mflags & PAT_MF_IGNORE_CASE; - 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)) + if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.meth.str.str, smp->data.u.meth.str.len) == 0) || + (!icase && strncmp(pattern->ptr.str, smp->data.u.meth.str.str, smp->data.u.meth.str.len) == 0)) return pattern; } return NULL; @@ -10129,8 +10129,8 @@ smp_fetch_rqver(const struct arg *args, struct sample *smp, const char *kw, void return 0; smp->data.type = SMP_T_STR; - smp->data.data.str.str = ptr; - smp->data.data.str.len = len; + smp->data.u.str.str = ptr; + smp->data.u.str.len = len; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; return 1; @@ -10157,8 +10157,8 @@ smp_fetch_stver(const struct arg *args, struct sample *smp, const char *kw, void return 0; smp->data.type = SMP_T_STR; - smp->data.data.str.str = ptr; - smp->data.data.str.len = len; + smp->data.u.str.str = ptr; + smp->data.u.str.len = len; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; return 1; @@ -10182,7 +10182,7 @@ smp_fetch_stcode(const struct arg *args, struct sample *smp, const char *kw, voi ptr = txn->rsp.chn->buf->p + txn->rsp.sl.st.c; smp->data.type = SMP_T_SINT; - smp->data.data.sint = __strl2ui(ptr, len); + smp->data.u.sint = __strl2ui(ptr, len); smp->flags = SMP_F_VOL_1ST; return 1; } @@ -10217,8 +10217,8 @@ smp_fetch_body(const struct arg *args, struct sample *smp, const char *kw, void if (block1 == len) { /* buffer is not wrapped (or empty) */ smp->data.type = SMP_T_BIN; - smp->data.data.str.str = body; - smp->data.data.str.len = len; + smp->data.u.str.str = body; + smp->data.u.str.len = len; smp->flags = SMP_F_VOL_TEST | SMP_F_CONST; } else { @@ -10227,8 +10227,8 @@ smp_fetch_body(const struct arg *args, struct sample *smp, const char *kw, void memcpy(temp->str, body, block1); memcpy(temp->str + block1, msg->chn->buf->data, len - block1); smp->data.type = SMP_T_BIN; - smp->data.data.str.str = temp->str; - smp->data.data.str.len = len; + smp->data.u.str.str = temp->str; + smp->data.u.str.len = len; smp->flags = SMP_F_VOL_TEST; } return 1; @@ -10252,7 +10252,7 @@ smp_fetch_body_len(const struct arg *args, struct sample *smp, const char *kw, v msg = &txn->rsp; smp->data.type = SMP_T_SINT; - smp->data.data.sint = http_body_bytes(msg); + smp->data.u.sint = http_body_bytes(msg); smp->flags = SMP_F_VOL_TEST; return 1; @@ -10277,7 +10277,7 @@ smp_fetch_body_size(const struct arg *args, struct sample *smp, const char *kw, msg = &txn->rsp; smp->data.type = SMP_T_SINT; - smp->data.data.sint = msg->body_len; + smp->data.u.sint = msg->body_len; smp->flags = SMP_F_VOL_TEST; return 1; @@ -10294,8 +10294,8 @@ smp_fetch_url(const struct arg *args, struct sample *smp, const char *kw, void * txn = smp->strm->txn; 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->data.u.str.len = txn->req.sl.rq.u_l; + smp->data.u.str.str = txn->req.chn->buf->p + txn->req.sl.rq.u; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; return 1; } @@ -10314,7 +10314,7 @@ smp_fetch_url_ip(const struct arg *args, struct sample *smp, const char *kw, voi return 0; smp->data.type = SMP_T_IPV4; - smp->data.data.ipv4 = ((struct sockaddr_in *)&addr)->sin_addr; + smp->data.u.ipv4 = ((struct sockaddr_in *)&addr)->sin_addr; smp->flags = 0; return 1; } @@ -10333,7 +10333,7 @@ smp_fetch_url_port(const struct arg *args, struct sample *smp, const char *kw, v return 0; smp->data.type = SMP_T_SINT; - smp->data.data.sint = ntohs(((struct sockaddr_in *)&addr)->sin_port); + smp->data.u.sint = ntohs(((struct sockaddr_in *)&addr)->sin_port); smp->flags = 0; return 1; } @@ -10391,7 +10391,7 @@ smp_fetch_fhdr(const struct arg *args, struct sample *smp, const char *kw, void 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.data.str.str, &smp->data.data.str.len)) + if (http_get_fhdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.u.str.str, &smp->data.u.str.len)) return 1; smp->flags &= ~SMP_F_NOT_LAST; @@ -10428,7 +10428,7 @@ smp_fetch_fhdr_cnt(const struct arg *args, struct sample *smp, const char *kw, v cnt++; smp->data.type = SMP_T_SINT; - smp->data.data.sint = cnt; + smp->data.u.sint = cnt; smp->flags = SMP_F_VOL_HDR; return 1; } @@ -10461,8 +10461,8 @@ smp_fetch_hdr_names(const struct arg *args, struct sample *smp, const char *kw, } smp->data.type = SMP_T_STR; - smp->data.data.str.str = temp->str; - smp->data.data.str.len = temp->len; + smp->data.u.str.str = temp->str; + smp->data.u.str.len = temp->len; smp->flags = SMP_F_VOL_HDR; return 1; } @@ -10519,7 +10519,7 @@ smp_fetch_hdr(const struct arg *args, struct sample *smp, const char *kw, void * 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.data.str.str, &smp->data.data.str.len)) + if (http_get_hdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.u.str.str, &smp->data.u.str.len)) return 1; smp->flags &= ~SMP_F_NOT_LAST; @@ -10555,7 +10555,7 @@ smp_fetch_hdr_cnt(const struct arg *args, struct sample *smp, const char *kw, vo cnt++; smp->data.type = SMP_T_SINT; - smp->data.data.sint = cnt; + smp->data.u.sint = cnt; smp->flags = SMP_F_VOL_HDR; return 1; } @@ -10572,7 +10572,7 @@ smp_fetch_hdr_val(const struct arg *args, struct sample *smp, const char *kw, vo if (ret > 0) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = strl2ic(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = strl2ic(smp->data.u.str.str, smp->data.u.str.len); } return ret; @@ -10588,15 +10588,15 @@ 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.data.str.str, &smp->data.data.ipv4)) { + if (url2ipv4((char *)smp->data.u.str.str, &smp->data.u.ipv4)) { smp->data.type = SMP_T_IPV4; break; } else { struct chunk *temp = get_trash_chunk(); - 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)) { + if (smp->data.u.str.len < temp->size - 1) { + memcpy(temp->str, smp->data.u.str.str, smp->data.u.str.len); + temp->str[smp->data.u.str.len] = '\0'; + if (inet_pton(AF_INET6, temp->str, &smp->data.u.ipv6)) { smp->data.type = SMP_T_IPV6; break; } @@ -10629,12 +10629,12 @@ smp_fetch_path(const struct arg *args, struct sample *smp, const char *kw, void /* OK, we got the '/' ! */ smp->data.type = SMP_T_STR; - smp->data.data.str.str = ptr; + smp->data.u.str.str = ptr; while (ptr < end && *ptr != '?') ptr++; - smp->data.data.str.len = ptr - smp->data.data.str.str; + smp->data.u.str.len = ptr - smp->data.u.str.str; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; return 1; } @@ -10665,8 +10665,8 @@ smp_fetch_base(const struct arg *args, struct sample *smp, const char *kw, void temp = get_trash_chunk(); memcpy(temp->str, ctx.line + ctx.val, ctx.vlen); smp->data.type = SMP_T_STR; - smp->data.data.str.str = temp->str; - smp->data.data.str.len = ctx.vlen; + smp->data.u.str.str = temp->str; + smp->data.u.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.data.str.str + smp->data.data.str.len, beg, ptr - beg); - smp->data.data.str.len += ptr - beg; + memcpy(smp->data.u.str.str + smp->data.u.str.len, beg, ptr - beg); + smp->data.u.str.len += ptr - beg; } smp->flags = SMP_F_VOL_1ST; @@ -10729,7 +10729,7 @@ smp_fetch_base32(const struct arg *args, struct sample *smp, const char *kw, voi hash = full_hash(hash); smp->data.type = SMP_T_SINT; - smp->data.data.sint = hash; + smp->data.u.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.data.sint); + *(unsigned int *)temp->str = htonl(smp->data.u.sint); temp->len += sizeof(unsigned int); switch (cli_conn->addr.from.ss_family) { @@ -10770,7 +10770,7 @@ smp_fetch_base32_src(const struct arg *args, struct sample *smp, const char *kw, return 0; } - smp->data.data.str = *temp; + smp->data.u.str = *temp; smp->data.type = SMP_T_BIN; return 1; } @@ -10798,8 +10798,8 @@ smp_fetch_query(const struct arg *args, struct sample *smp, const char *kw, void } while (*ptr++ != '?'); smp->data.type = SMP_T_STR; - smp->data.data.str.str = ptr; - smp->data.data.str.len = end - ptr; + smp->data.u.str.str = ptr; + smp->data.u.str.len = end - ptr; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; return 1; } @@ -10814,7 +10814,7 @@ smp_fetch_proto_http(const struct arg *args, struct sample *smp, const char *kw, CHECK_HTTP_MESSAGE_FIRST_PERM(); smp->data.type = SMP_T_BOOL; - smp->data.data.sint = 1; + smp->data.u.sint = 1; return 1; } @@ -10823,7 +10823,7 @@ static int smp_fetch_http_first_req(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = !(smp->strm->txn->flags & TX_NOT_FIRST); + smp->data.u.sint = !(smp->strm->txn->flags & TX_NOT_FIRST); return 1; } @@ -10841,7 +10841,7 @@ smp_fetch_http_auth(const struct arg *args, struct sample *smp, const char *kw, return 0; smp->data.type = SMP_T_BOOL; - smp->data.data.sint = check_user(args->data.usr, smp->strm->txn->auth.user, + smp->data.u.sint = check_user(args->data.usr, smp->strm->txn->auth.user, smp->strm->txn->auth.pass); return 1; } @@ -10871,8 +10871,8 @@ smp_fetch_http_auth_grp(const struct arg *args, struct sample *smp, const char * smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; - smp->data.data.str.str = smp->strm->txn->auth.user; - smp->data.data.str.len = strlen(smp->strm->txn->auth.user); + smp->data.u.str.str = smp->strm->txn->auth.user; + smp->data.u.str.len = strlen(smp->strm->txn->auth.user); return 1; } @@ -10991,8 +10991,8 @@ smp_fetch_capture_header_req(const struct arg *args, struct sample *smp, const c smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str.str = smp->strm->req_cap[idx]; - smp->data.data.str.len = strlen(smp->strm->req_cap[idx]); + smp->data.u.str.str = smp->strm->req_cap[idx]; + smp->data.u.str.len = strlen(smp->strm->req_cap[idx]); return 1; } @@ -11016,8 +11016,8 @@ smp_fetch_capture_header_res(const struct arg *args, struct sample *smp, const c smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str.str = smp->strm->res_cap[idx]; - smp->data.data.str.len = strlen(smp->strm->res_cap[idx]); + smp->data.u.str.str = smp->strm->res_cap[idx]; + smp->data.u.str.len = strlen(smp->strm->res_cap[idx]); return 1; } @@ -11041,7 +11041,7 @@ 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.data.str = *temp; + smp->data.u.str = *temp; smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; @@ -11077,8 +11077,8 @@ 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.data.str = *temp; - smp->data.data.str.len = ptr - temp->str; + smp->data.u.str = *temp; + smp->data.u.str.len = ptr - temp->str; smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; @@ -11097,11 +11097,11 @@ 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.data.str.str = "HTTP/1.1"; + smp->data.u.str.str = "HTTP/1.1"; else - smp->data.data.str.str = "HTTP/1.0"; + smp->data.u.str.str = "HTTP/1.0"; - smp->data.data.str.len = 8; + smp->data.u.str.len = 8; smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; return 1; @@ -11120,11 +11120,11 @@ 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.data.str.str = "HTTP/1.1"; + smp->data.u.str.str = "HTTP/1.1"; else - smp->data.data.str.str = "HTTP/1.0"; + smp->data.u.str.str = "HTTP/1.0"; - smp->data.data.str.len = 8; + smp->data.u.str.len = 8; smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; return 1; @@ -11217,12 +11217,12 @@ int smp_fetch_cookie(const struct arg *args, struct sample *smp, const char *kw, 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.data.str.str, - &smp->data.data.str.len); + &smp->data.u.str.str, + &smp->data.u.str.len); if (smp->ctx.a[0]) { found = 1; if (occ >= 0) { - /* one value was returned into smp->data.data.str.{str,len} */ + /* one value was returned into smp->data.u.str.{str,len} */ smp->flags |= SMP_F_NOT_LAST; return 1; } @@ -11296,14 +11296,14 @@ smp_fetch_cookie_cnt(const struct arg *args, struct sample *smp, const char *kw, 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.data.str.str, - &smp->data.data.str.len))) { + &smp->data.u.str.str, + &smp->data.u.str.len))) { cnt++; } } smp->data.type = SMP_T_SINT; - smp->data.data.sint = cnt; + smp->data.u.sint = cnt; smp->flags |= SMP_F_VOL_HDR; return 1; } @@ -11318,7 +11318,7 @@ smp_fetch_cookie_val(const struct arg *args, struct sample *smp, const char *kw, if (ret > 0) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = strl2ic(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = strl2ic(smp->data.u.str.str, smp->data.u.str.len); } return ret; @@ -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.data.str.str = temp->str; - smp->data.data.str.len = ( chunks[1] - vstart ) + ( vend - chunks[2] ); + smp->data.u.str.str = temp->str; + smp->data.u.str.len = ( chunks[1] - vstart ) + ( vend - chunks[2] ); } else { /* Contiguous case. */ - smp->data.data.str.str = (char *)vstart; - smp->data.data.str.len = vend - vstart; + smp->data.u.str.str = (char *)vstart; + smp->data.u.str.len = vend - vstart; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; } @@ -11720,7 +11720,7 @@ smp_fetch_url_param_val(const struct arg *args, struct sample *smp, const char * if (ret > 0) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = strl2ic(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = strl2ic(smp->data.u.str.str, smp->data.u.str.len); } return ret; @@ -11772,7 +11772,7 @@ smp_fetch_url32(const struct arg *args, struct sample *smp, const char *kw, void hash = full_hash(hash); smp->data.type = SMP_T_SINT; - smp->data.data.sint = hash; + smp->data.u.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.data.sint; + hash = smp->data.u.sint; temp = get_trash_chunk(); memcpy(temp->str + temp->len, &hash, sizeof(hash)); @@ -11814,7 +11814,7 @@ smp_fetch_url32_src(const struct arg *args, struct sample *smp, const char *kw, return 0; } - smp->data.data.str = *temp; + smp->data.u.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.data.sint & 0x007fffffffffffffLL; + time_t curr_date = smp->data.u.sint & 0x007fffffffffffffLL; /* add offset */ if (args && (args[0].type == ARGT_SINT)) @@ -11863,7 +11863,7 @@ 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.data.str = *temp; + smp->data.u.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.data.str.str; - const char *end = al + smp->data.data.str.len; + const char *al = smp->data.u.str.str; + const char *end = al + smp->data.u.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.data.str.size = 0; - smp->data.data.str.str = ""; - smp->data.data.str.len = 0; + smp->data.u.str.size = 0; + smp->data.u.str.str = ""; + smp->data.u.str.len = 0; /* Parse the accept language */ while (1) { @@ -12011,8 +12011,8 @@ process_value: * break the process. */ if (qvalue > best_q) { - smp->data.data.str.str = (char *)w; - smp->data.data.str.len = str - w; + smp->data.u.str.str = (char *)w; + smp->data.u.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.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; + if (smp->data.u.str.len == 0 && args[1].type == ARGT_STR) { + smp->data.u.str.str = args[1].data.str.str; + smp->data.u.str.len = args[1].data.str.len; } /* Return true only if a matching language was found. */ - return smp->data.data.str.len != 0; + return smp->data.u.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.data.str.size <= smp->data.data.str.len) { + if (smp->flags & SMP_F_CONST || smp->data.u.str.size <= smp->data.u.str.len) { struct chunk *str = get_trash_chunk(); - 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; + memcpy(str->str, smp->data.u.str.str, smp->data.u.str.len); + smp->data.u.str.str = str->str; + smp->data.u.str.size = str->size; smp->flags &= ~SMP_F_CONST; } /* Add final \0 required by url_decode(), and convert the input string. */ - smp->data.data.str.str[smp->data.data.str.len] = '\0'; - smp->data.data.str.len = url_decode(smp->data.data.str.str); + smp->data.u.str.str[smp->data.u.str.len] = '\0'; + smp->data.u.str.len = url_decode(smp->data.u.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.data.str.len; + len = smp->data.u.str.len; if (len > hdr->len) len = hdr->len; /* Capture input data. */ - memcpy(smp->strm->req_cap[idx], smp->data.data.str.str, len); + memcpy(smp->strm->req_cap[idx], smp->data.u.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.data.str.len; + len = smp->data.u.str.len; if (len > hdr->len) len = hdr->len; /* Capture input data. */ - memcpy(smp->strm->res_cap[idx], smp->data.data.str.str, len); + memcpy(smp->strm->res_cap[idx], smp->data.u.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.data.str.len; + len = key->data.u.str.len; if (len > h->len) len = h->len; - memcpy(cap[h->index], key->data.data.str.str, len); + memcpy(cap[h->index], key->data.u.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.data.str.len; + len = key->data.u.str.len; if (len > h->len) len = h->len; - memcpy(cap[h->index], key->data.data.str.str, len); + memcpy(cap[h->index], key->data.u.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.data.str.len; + len = key->data.u.str.len; if (len > h->len) len = h->len; - memcpy(cap[h->index], key->data.data.str.str, len); + memcpy(cap[h->index], key->data.u.str.str, len); cap[h->index][len] = 0; return 1; } diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 29d68c365..e4d0a5140 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -1222,11 +1222,11 @@ resume_execution: if (cap[h->index] == NULL) /* no more capture memory */ continue; - len = key->data.data.str.len; + len = key->data.u.str.len; if (len > h->len) len = h->len; - memcpy(cap[h->index], key->data.data.str.str, len); + memcpy(cap[h->index], key->data.u.str.str, len); cap[h->index][len] = 0; } else { @@ -1999,11 +1999,11 @@ 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.data.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr; + smp->data.u.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr; smp->data.type = SMP_T_IPV4; break; case AF_INET6: - smp->data.data.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr; + smp->data.u.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_addr; smp->data.type = SMP_T_IPV6; break; default: @@ -2024,7 +2024,7 @@ smp_fetch_sport(const struct arg *args, struct sample *smp, const char *k, void return 0; smp->data.type = SMP_T_SINT; - if (!(smp->data.data.sint = get_host_port(&cli_conn->addr.from))) + if (!(smp->data.u.sint = get_host_port(&cli_conn->addr.from))) return 0; smp->flags = 0; @@ -2044,11 +2044,11 @@ 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.data.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr; + smp->data.u.ipv4 = ((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr; smp->data.type = SMP_T_IPV4; break; case AF_INET6: - smp->data.data.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_addr; + smp->data.u.ipv6 = ((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_addr; smp->data.type = SMP_T_IPV6; break; default: @@ -2071,7 +2071,7 @@ smp_fetch_dport(const struct arg *args, struct sample *smp, const char *kw, void conn_get_to_addr(cli_conn); smp->data.type = SMP_T_SINT; - if (!(smp->data.data.sint = get_host_port(&cli_conn->addr.to))) + if (!(smp->data.u.sint = get_host_port(&cli_conn->addr.to))) return 0; smp->flags = 0; diff --git a/src/sample.c b/src/sample.c index 9a5737619..c1d5bb5d4 100644 --- a/src/sample.c +++ b/src/sample.c @@ -499,7 +499,7 @@ struct sample_conv *find_sample_conv(const char *kw, int len) static int c_ip2int(struct sample *smp) { - smp->data.data.sint = ntohl(smp->data.data.ipv4.s_addr); + smp->data.u.sint = ntohl(smp->data.u.ipv4.s_addr); smp->data.type = SMP_T_SINT; return 1; } @@ -508,11 +508,11 @@ static int c_ip2str(struct sample *smp) { struct chunk *trash = get_trash_chunk(); - if (!inet_ntop(AF_INET, (void *)&smp->data.data.ipv4, trash->str, trash->size)) + if (!inet_ntop(AF_INET, (void *)&smp->data.u.ipv4, trash->str, trash->size)) return 0; trash->len = strlen(trash->str); - smp->data.data.str = *trash; + smp->data.u.str = *trash; smp->data.type = SMP_T_STR; smp->flags &= ~SMP_F_CONST; @@ -521,14 +521,14 @@ static int c_ip2str(struct sample *smp) static int c_ip2ipv6(struct sample *smp) { - v4tov6(&smp->data.data.ipv6, &smp->data.data.ipv4); + v4tov6(&smp->data.u.ipv6, &smp->data.u.ipv4); smp->data.type = SMP_T_IPV6; return 1; } static int c_ipv62ip(struct sample *smp) { - if (!v6tov4(&smp->data.data.ipv4, &smp->data.data.ipv6)) + if (!v6tov4(&smp->data.u.ipv4, &smp->data.u.ipv6)) return 0; smp->data.type = SMP_T_IPV6; return 1; @@ -538,11 +538,11 @@ static int c_ipv62str(struct sample *smp) { struct chunk *trash = get_trash_chunk(); - if (!inet_ntop(AF_INET6, (void *)&smp->data.data.ipv6, trash->str, trash->size)) + if (!inet_ntop(AF_INET6, (void *)&smp->data.u.ipv6, trash->str, trash->size)) return 0; trash->len = strlen(trash->str); - smp->data.data.str = *trash; + smp->data.u.str = *trash; smp->data.type = SMP_T_STR; smp->flags &= ~SMP_F_CONST; return 1; @@ -551,29 +551,29 @@ static int c_ipv62str(struct sample *smp) /* static int c_ipv62ip(struct sample *smp) { - return v6tov4(&smp->data.data.ipv4, &smp->data.data.ipv6); + return v6tov4(&smp->data.u.ipv4, &smp->data.u.ipv6); } */ static int c_int2ip(struct sample *smp) { - smp->data.data.ipv4.s_addr = htonl((unsigned int)smp->data.data.sint); + smp->data.u.ipv4.s_addr = htonl((unsigned int)smp->data.u.sint); smp->data.type = SMP_T_IPV4; return 1; } static int c_int2ipv6(struct sample *smp) { - smp->data.data.ipv4.s_addr = htonl((unsigned int)smp->data.data.sint); - v4tov6(&smp->data.data.ipv6, &smp->data.data.ipv4); + smp->data.u.ipv4.s_addr = htonl((unsigned int)smp->data.u.sint); + v4tov6(&smp->data.u.ipv6, &smp->data.u.ipv4); smp->data.type = SMP_T_IPV6; return 1; } static int c_str2addr(struct sample *smp) { - if (!buf2ip(smp->data.data.str.str, smp->data.data.str.len, &smp->data.data.ipv4)) { - if (!buf2ip6(smp->data.data.str.str, smp->data.data.str.len, &smp->data.data.ipv6)) + if (!buf2ip(smp->data.u.str.str, smp->data.u.str.len, &smp->data.u.ipv4)) { + if (!buf2ip6(smp->data.u.str.str, smp->data.u.str.len, &smp->data.u.ipv6)) return 0; smp->data.type = SMP_T_IPV6; smp->flags &= ~SMP_F_CONST; @@ -586,7 +586,7 @@ static int c_str2addr(struct sample *smp) static int c_str2ip(struct sample *smp) { - if (!buf2ip(smp->data.data.str.str, smp->data.data.str.len, &smp->data.data.ipv4)) + if (!buf2ip(smp->data.u.str.str, smp->data.u.str.len, &smp->data.u.ipv4)) return 0; smp->data.type = SMP_T_IPV4; smp->flags &= ~SMP_F_CONST; @@ -595,7 +595,7 @@ static int c_str2ip(struct sample *smp) static int c_str2ipv6(struct sample *smp) { - if (!buf2ip6(smp->data.data.str.str, smp->data.data.str.len, &smp->data.data.ipv6)) + if (!buf2ip6(smp->data.u.str.str, smp->data.u.str.len, &smp->data.u.ipv6)) return 0; smp->data.type = SMP_T_IPV6; smp->flags &= ~SMP_F_CONST; @@ -610,9 +610,9 @@ static int c_bin2str(struct sample *smp) { int i; - for (i = 0; i < smp->data.data.str.len; i++) { - if (!smp->data.data.str.str[i]) { - smp->data.data.str.len = i; + for (i = 0; i < smp->data.u.str.len; i++) { + if (!smp->data.u.str.str[i]) { + smp->data.u.str.len = i; break; } } @@ -624,14 +624,14 @@ static int c_int2str(struct sample *smp) struct chunk *trash = get_trash_chunk(); char *pos; - pos = lltoa_r(smp->data.data.sint, trash->str, trash->size); + pos = lltoa_r(smp->data.u.sint, trash->str, trash->size); if (!pos) return 0; trash->size = trash->size - (pos - trash->str); trash->str = pos; trash->len = strlen(pos); - smp->data.data.str = *trash; + smp->data.u.str = *trash; smp->data.type = SMP_T_STR; smp->flags &= ~SMP_F_CONST; return 1; @@ -660,9 +660,9 @@ int smp_dup(struct sample *smp) case SMP_T_BIN: /* Duplicate data. */ trash = get_trash_chunk(); - trash->len = smp->data.data.str.len < trash->size ? smp->data.data.str.len : trash->size; - memcpy(trash->str, smp->data.data.str.str, trash->len); - smp->data.data.str = *trash; + trash->len = smp->data.u.str.len < trash->size ? smp->data.u.str.len : trash->size; + memcpy(trash->str, smp->data.u.str.str, trash->len); + smp->data.u.str = *trash; break; default: /* Other cases are unexpected. */ @@ -684,13 +684,13 @@ static int c_str2int(struct sample *smp) const char *str; const char *end; - if (smp->data.data.str.len == 0) + if (smp->data.u.str.len == 0) return 0; - str = smp->data.data.str.str; - end = smp->data.data.str.str + smp->data.data.str.len; + str = smp->data.u.str.str; + end = smp->data.u.str.str + smp->data.u.str.len; - smp->data.data.sint = read_int64(&str, end); + smp->data.u.sint = read_int64(&str, end); smp->data.type = SMP_T_SINT; smp->flags &= ~SMP_F_CONST; return 1; @@ -701,15 +701,15 @@ static int c_str2meth(struct sample *smp) enum http_meth_t meth; int len; - meth = find_http_meth(smp->data.data.str.str, smp->data.data.str.len); + meth = find_http_meth(smp->data.u.str.str, smp->data.u.str.len); if (meth == HTTP_METH_OTHER) { - len = smp->data.data.str.len; - smp->data.data.meth.str.str = smp->data.data.str.str; - smp->data.data.meth.str.len = len; + len = smp->data.u.str.len; + smp->data.u.meth.str.str = smp->data.u.str.str; + smp->data.u.meth.str.len = len; } else smp->flags &= ~SMP_F_CONST; - smp->data.data.meth.meth = meth; + smp->data.u.meth.meth = meth; smp->data.type = SMP_T_METH; return 1; } @@ -719,18 +719,18 @@ static int c_meth2str(struct sample *smp) int len; enum http_meth_t meth; - if (smp->data.data.meth.meth == HTTP_METH_OTHER) { + if (smp->data.u.meth.meth == HTTP_METH_OTHER) { /* The method is unknown. Copy the original pointer. */ - len = smp->data.data.meth.str.len; - smp->data.data.str.str = smp->data.data.meth.str.str; - smp->data.data.str.len = len; + len = smp->data.u.meth.str.len; + smp->data.u.str.str = smp->data.u.meth.str.str; + smp->data.u.str.len = len; smp->data.type = SMP_T_STR; } - else if (smp->data.data.meth.meth < HTTP_METH_OTHER) { + else if (smp->data.u.meth.meth < HTTP_METH_OTHER) { /* The method is known, copy the pointer containing the string. */ - meth = smp->data.data.meth.meth; - smp->data.data.str.str = http_known_methods[meth].name; - smp->data.data.str.len = http_known_methods[meth].len; + meth = smp->data.u.meth.meth; + smp->data.u.str.str = http_known_methods[meth].name; + smp->data.u.str.len = http_known_methods[meth].len; smp->flags |= SMP_F_CONST; smp->data.type = SMP_T_STR; } @@ -747,16 +747,16 @@ static int c_addr2bin(struct sample *smp) if (smp->data.type == SMP_T_IPV4) { chk->len = 4; - memcpy(chk->str, &smp->data.data.ipv4, chk->len); + memcpy(chk->str, &smp->data.u.ipv4, chk->len); } else if (smp->data.type == SMP_T_IPV6) { chk->len = 16; - memcpy(chk->str, &smp->data.data.ipv6, chk->len); + memcpy(chk->str, &smp->data.u.ipv6, chk->len); } else return 0; - smp->data.data.str = *chk; + smp->data.u.str = *chk; smp->data.type = SMP_T_BIN; return 1; } @@ -765,10 +765,10 @@ static int c_int2bin(struct sample *smp) { struct chunk *chk = get_trash_chunk(); - *(unsigned long long int *)chk->str = htonll(smp->data.data.sint); + *(unsigned long long int *)chk->str = htonll(smp->data.u.sint); chk->len = 8; - smp->data.data.str = *chk; + smp->data.u.str = *chk; smp->data.type = SMP_T_BIN; return 1; } @@ -1397,9 +1397,9 @@ static int sample_conv_debug(const struct arg *arg_p, struct sample *smp, void * else { /* Display the displayable chars*. */ fprintf(stderr, "<"); - for (i = 0; i < tmp.data.data.str.len; i++) { - if (isprint(tmp.data.data.str.str[i])) - fputc(tmp.data.data.str.str[i], stderr); + for (i = 0; i < tmp.data.u.str.len; i++) { + if (isprint(tmp.data.u.str.str[i])) + fputc(tmp.data.u.str.str[i], stderr); else fputc('.', stderr); } @@ -1417,12 +1417,12 @@ static int sample_conv_bin2base64(const struct arg *arg_p, struct sample *smp, v int b64_len; trash->len = 0; - b64_len = a2base64(smp->data.data.str.str, smp->data.data.str.len, trash->str, trash->size); + b64_len = a2base64(smp->data.u.str.str, smp->data.u.str.len, trash->str, trash->size); if (b64_len < 0) return 0; trash->len = b64_len; - smp->data.data.str = *trash; + smp->data.u.str = *trash; smp->data.type = SMP_T_STR; smp->flags &= ~SMP_F_CONST; return 1; @@ -1435,12 +1435,12 @@ static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp, void int ptr = 0; trash->len = 0; - while (ptr < smp->data.data.str.len && trash->len <= trash->size - 2) { - c = smp->data.data.str.str[ptr++]; + while (ptr < smp->data.u.str.len && trash->len <= trash->size - 2) { + c = smp->data.u.str.str[ptr++]; trash->str[trash->len++] = hextab[(c >> 4) & 0xF]; trash->str[trash->len++] = hextab[c & 0xF]; } - smp->data.data.str = *trash; + smp->data.u.str = *trash; smp->data.type = SMP_T_STR; smp->flags &= ~SMP_F_CONST; return 1; @@ -1449,9 +1449,9 @@ static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp, void /* hashes the binary input into a 32-bit unsigned int */ static int sample_conv_djb2(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = hash_djb2(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = hash_djb2(smp->data.u.str.str, smp->data.u.str.len); if (arg_p && arg_p->data.sint) - smp->data.data.sint = full_hash(smp->data.data.sint); + smp->data.u.sint = full_hash(smp->data.u.sint); smp->data.type = SMP_T_SINT; return 1; } @@ -1463,12 +1463,12 @@ static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp, vo if (!smp_dup(smp)) return 0; - if (!smp->data.data.str.size) + if (!smp->data.u.str.size) return 0; - for (i = 0; i < smp->data.data.str.len; i++) { - if ((smp->data.data.str.str[i] >= 'A') && (smp->data.data.str.str[i] <= 'Z')) - smp->data.data.str.str[i] += 'a' - 'A'; + for (i = 0; i < smp->data.u.str.len; i++) { + if ((smp->data.u.str.str[i] >= 'A') && (smp->data.u.str.str[i] <= 'Z')) + smp->data.u.str.str[i] += 'a' - 'A'; } return 1; } @@ -1480,12 +1480,12 @@ static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp, vo if (!smp_dup(smp)) return 0; - if (!smp->data.data.str.size) + if (!smp->data.u.str.size) return 0; - for (i = 0; i < smp->data.data.str.len; i++) { - if ((smp->data.data.str.str[i] >= 'a') && (smp->data.data.str.str[i] <= 'z')) - smp->data.data.str.str[i] += 'A' - 'a'; + for (i = 0; i < smp->data.u.str.len; i++) { + if ((smp->data.u.str.str[i] >= 'a') && (smp->data.u.str.str[i] <= 'z')) + smp->data.u.str.str[i] += 'A' - 'a'; } return 1; } @@ -1493,7 +1493,7 @@ static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp, vo /* takes the netmask in arg_p */ static int sample_conv_ipmask(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.ipv4.s_addr &= arg_p->data.ipv4.s_addr; + smp->data.u.ipv4.s_addr &= arg_p->data.ipv4.s_addr; smp->data.type = SMP_T_IPV4; return 1; } @@ -1506,7 +1506,7 @@ static int sample_conv_ltime(const struct arg *args, struct sample *smp, void *p { struct chunk *temp; /* With high numbers, the date returned can be negative, the 55 bits mask prevent this. */ - time_t curr_date = smp->data.data.sint & 0x007fffffffffffffLL; + time_t curr_date = smp->data.u.sint & 0x007fffffffffffffLL; struct tm *tm; /* add offset */ @@ -1518,7 +1518,7 @@ static int sample_conv_ltime(const struct arg *args, struct sample *smp, void *p return 0; temp = get_trash_chunk(); temp->len = strftime(temp->str, temp->size, args[0].data.str.str, tm); - smp->data.data.str = *temp; + smp->data.u.str = *temp; smp->data.type = SMP_T_STR; return 1; } @@ -1526,9 +1526,9 @@ static int sample_conv_ltime(const struct arg *args, struct sample *smp, void *p /* hashes the binary input into a 32-bit unsigned int */ static int sample_conv_sdbm(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = hash_sdbm(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = hash_sdbm(smp->data.u.str.str, smp->data.u.str.len); if (arg_p && arg_p->data.sint) - smp->data.data.sint = full_hash(smp->data.data.sint); + smp->data.u.sint = full_hash(smp->data.u.sint); smp->data.type = SMP_T_SINT; return 1; } @@ -1541,7 +1541,7 @@ static int sample_conv_utime(const struct arg *args, struct sample *smp, void *p { struct chunk *temp; /* With high numbers, the date returned can be negative, the 55 bits mask prevent this. */ - time_t curr_date = smp->data.data.sint & 0x007fffffffffffffLL; + time_t curr_date = smp->data.u.sint & 0x007fffffffffffffLL; struct tm *tm; /* add offset */ @@ -1553,7 +1553,7 @@ static int sample_conv_utime(const struct arg *args, struct sample *smp, void *p return 0; temp = get_trash_chunk(); temp->len = strftime(temp->str, temp->size, args[0].data.str.str, tm); - smp->data.data.str = *temp; + smp->data.u.str = *temp; smp->data.type = SMP_T_STR; return 1; } @@ -1561,9 +1561,9 @@ static int sample_conv_utime(const struct arg *args, struct sample *smp, void *p /* hashes the binary input into a 32-bit unsigned int */ static int sample_conv_wt6(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = hash_wt6(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = hash_wt6(smp->data.u.str.str, smp->data.u.str.len); if (arg_p && arg_p->data.sint) - smp->data.data.sint = full_hash(smp->data.data.sint); + smp->data.u.sint = full_hash(smp->data.u.sint); smp->data.type = SMP_T_SINT; return 1; } @@ -1571,9 +1571,9 @@ static int sample_conv_wt6(const struct arg *arg_p, struct sample *smp, void *pr /* hashes the binary input into a 32-bit unsigned int */ static int sample_conv_crc32(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = hash_crc32(smp->data.data.str.str, smp->data.data.str.len); + smp->data.u.sint = hash_crc32(smp->data.u.str.str, smp->data.u.str.len); if (arg_p && arg_p->data.sint) - smp->data.data.sint = full_hash(smp->data.data.sint); + smp->data.u.sint = full_hash(smp->data.u.sint); smp->data.type = SMP_T_SINT; return 1; } @@ -1666,8 +1666,8 @@ static int sample_conv_json(const struct arg *arg_p, struct sample *smp, void *p temp = get_trash_chunk(); temp->len = 0; - p = smp->data.data.str.str; - while (p < smp->data.data.str.str + smp->data.data.str.len) { + p = smp->data.u.str.str; + while (p < smp->data.u.str.str + smp->data.u.str.len) { if (input_type == IT_ASCII) { /* Read input as ASCII. */ @@ -1676,7 +1676,7 @@ static int sample_conv_json(const struct arg *arg_p, struct sample *smp, void *p } else { /* Read input as UTF8. */ - ret = utf8_next(p, smp->data.data.str.len - ( p - smp->data.data.str.str ), &c); + ret = utf8_next(p, smp->data.u.str.len - ( p - smp->data.u.str.str ), &c); p += utf8_return_length(ret); if (input_type == IT_UTF8 && utf8_return_code(ret) != UTF8_CODE_OK) @@ -1754,7 +1754,7 @@ static int sample_conv_json(const struct arg *arg_p, struct sample *smp, void *p } smp->flags &= ~SMP_F_CONST; - smp->data.data.str = *temp; + smp->data.u.str = *temp; smp->data.type = SMP_T_STR; return 1; @@ -1765,18 +1765,18 @@ static int sample_conv_json(const struct arg *arg_p, struct sample *smp, void *p * Optional second arg is the length to truncate */ static int sample_conv_bytes(const struct arg *arg_p, struct sample *smp, void *private) { - if (smp->data.data.str.len <= arg_p[0].data.sint) { - smp->data.data.str.len = 0; + if (smp->data.u.str.len <= arg_p[0].data.sint) { + smp->data.u.str.len = 0; return 1; } - if (smp->data.data.str.size) - smp->data.data.str.size -= arg_p[0].data.sint; - smp->data.data.str.len -= arg_p[0].data.sint; - smp->data.data.str.str += arg_p[0].data.sint; + if (smp->data.u.str.size) + smp->data.u.str.size -= arg_p[0].data.sint; + smp->data.u.str.len -= arg_p[0].data.sint; + smp->data.u.str.str += arg_p[0].data.sint; - if ((arg_p[1].type == ARGT_SINT) && (arg_p[1].data.sint < smp->data.data.str.len)) - smp->data.data.str.len = arg_p[1].data.sint; + if ((arg_p[1].type == ARGT_SINT) && (arg_p[1].data.sint < smp->data.u.str.len)) + smp->data.u.str.len = arg_p[1].data.sint; return 1; } @@ -1830,8 +1830,8 @@ static int sample_conv_field(const struct arg *arg_p, struct sample *smp, void * return 0; field = 1; - end = start = smp->data.data.str.str; - while (end - smp->data.data.str.str < smp->data.data.str.len) { + end = start = smp->data.u.str.str; + while (end - smp->data.u.str.str < smp->data.u.str.len) { for (i = 0 ; i < arg_p[1].data.str.len ; i++) { if (*end == arg_p[1].data.str.str[i]) { @@ -1847,22 +1847,22 @@ static int sample_conv_field(const struct arg *arg_p, struct sample *smp, void * /* Field not found */ if (field != arg_p[0].data.sint) { - smp->data.data.str.len = 0; + smp->data.u.str.len = 0; return 1; } found: - smp->data.data.str.len = end - start; + smp->data.u.str.len = end - start; /* If ret string is len 0, no need to change pointers or to update size */ - if (!smp->data.data.str.len) + if (!smp->data.u.str.len) return 1; - smp->data.data.str.str = start; + smp->data.u.str.str = start; /* Compute remaining size if needed - Note: smp->data.data.str.size cannot be set to 0 */ - if (smp->data.data.str.size) - smp->data.data.str.size -= start - smp->data.data.str.str; + Note: smp->data.u.str.size cannot be set to 0 */ + if (smp->data.u.str.size) + smp->data.u.str.size -= start - smp->data.u.str.str; return 1; } @@ -1882,8 +1882,8 @@ static int sample_conv_word(const struct arg *arg_p, struct sample *smp, void *p word = 0; inword = 0; - end = start = smp->data.data.str.str; - while (end - smp->data.data.str.str < smp->data.data.str.len) { + end = start = smp->data.u.str.str; + while (end - smp->data.u.str.str < smp->data.u.str.len) { issep = 0; for (i = 0 ; i < arg_p[1].data.str.len ; i++) { if (*end == arg_p[1].data.str.str[i]) { @@ -1908,22 +1908,22 @@ static int sample_conv_word(const struct arg *arg_p, struct sample *smp, void *p /* Field not found */ if (word != arg_p[0].data.sint) { - smp->data.data.str.len = 0; + smp->data.u.str.len = 0; return 1; } found: - smp->data.data.str.len = end - start; + smp->data.u.str.len = end - start; /* If ret string is len 0, no need to change pointers or to update size */ - if (!smp->data.data.str.len) + if (!smp->data.u.str.len) return 1; - smp->data.data.str.str = start; + smp->data.u.str.str = start; /* Compute remaining size if needed - Note: smp->data.data.str.size cannot be set to 0 */ - if (smp->data.data.str.size) - smp->data.data.str.size -= start - smp->data.data.str.str; + Note: smp->data.u.str.size cannot be set to 0 */ + if (smp->data.u.str.size) + smp->data.u.str.size -= start - smp->data.u.str.str; return 1; } @@ -1974,8 +1974,8 @@ static int sample_conv_regsub(const struct arg *arg_p, struct sample *smp, void int flag, max; int found; - start = smp->data.data.str.str; - end = start + smp->data.data.str.len; + start = smp->data.u.str.str; + end = start + smp->data.u.str.len; flag = 0; while (1) { @@ -2030,7 +2030,7 @@ static int sample_conv_regsub(const struct arg *arg_p, struct sample *smp, void flag |= REG_NOTBOL; } - smp->data.data.str = *trash; + smp->data.u.str = *trash; return 1; } @@ -2071,7 +2071,7 @@ static inline int sample_conv_var2smp(const struct arg *arg, struct stream *strm switch (arg->type) { case ARGT_SINT: smp->data.type = SMP_T_SINT; - smp->data.data.sint = arg->data.sint; + smp->data.u.sint = arg->data.sint; return 1; case ARGT_VAR: if (!vars_get_by_desc(&arg->data.var, strm, smp)) @@ -2091,7 +2091,7 @@ static inline int sample_conv_var2smp(const struct arg *arg, struct stream *strm */ static int sample_conv_binary_cpl(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = ~smp->data.data.sint; + smp->data.u.sint = ~smp->data.u.sint; return 1; } @@ -2104,7 +2104,7 @@ static int sample_conv_binary_and(const struct arg *arg_p, struct sample *smp, v if (!sample_conv_var2smp(arg_p, smp->strm, &tmp)) return 0; - smp->data.data.sint &= tmp.data.data.sint; + smp->data.u.sint &= tmp.data.u.sint; return 1; } @@ -2117,7 +2117,7 @@ static int sample_conv_binary_or(const struct arg *arg_p, struct sample *smp, vo if (!sample_conv_var2smp(arg_p, smp->strm, &tmp)) return 0; - smp->data.data.sint |= tmp.data.data.sint; + smp->data.u.sint |= tmp.data.u.sint; return 1; } @@ -2130,7 +2130,7 @@ static int sample_conv_binary_xor(const struct arg *arg_p, struct sample *smp, v if (!sample_conv_var2smp(arg_p, smp->strm, &tmp)) return 0; - smp->data.data.sint ^= tmp.data.data.sint; + smp->data.u.sint ^= tmp.data.u.sint; return 1; } @@ -2169,7 +2169,7 @@ static int sample_conv_arith_add(const struct arg *arg_p, struct sample *smp, vo if (!sample_conv_var2smp(arg_p, smp->strm, &tmp)) return 0; - smp->data.data.sint = arith_add(smp->data.data.sint, tmp.data.data.sint); + smp->data.u.sint = arith_add(smp->data.u.sint, tmp.data.u.sint); return 1; } @@ -2188,17 +2188,17 @@ static int sample_conv_arith_sub(const struct arg *arg_p, * than abs(LLONG_MAX). So, the following code use LLONG_MAX in place * of -LLONG_MIN and correct the result. */ - if (tmp.data.data.sint == LLONG_MIN) { - smp->data.data.sint = arith_add(smp->data.data.sint, LLONG_MAX); - if (smp->data.data.sint < LLONG_MAX) - smp->data.data.sint++; + if (tmp.data.u.sint == LLONG_MIN) { + smp->data.u.sint = arith_add(smp->data.u.sint, LLONG_MAX); + if (smp->data.u.sint < LLONG_MAX) + smp->data.u.sint++; return 1; } /* standard substraction: we use the "add" function and negate * the second operand. */ - smp->data.data.sint = arith_add(smp->data.data.sint, -tmp.data.data.sint); + smp->data.u.sint = arith_add(smp->data.u.sint, -tmp.data.u.sint); return 1; } @@ -2217,32 +2217,32 @@ static int sample_conv_arith_mul(const struct arg *arg_p, return 0; /* prevent divide by 0 during the check */ - if (!smp->data.data.sint || !tmp.data.data.sint) { - smp->data.data.sint = 0; + if (!smp->data.u.sint || !tmp.data.u.sint) { + smp->data.u.sint = 0; return 1; } /* The multiply between LLONG_MIN and -1 returns a * "floting point exception". */ - if (smp->data.data.sint == LLONG_MIN && tmp.data.data.sint == -1) { - smp->data.data.sint = LLONG_MAX; + if (smp->data.u.sint == LLONG_MIN && tmp.data.u.sint == -1) { + smp->data.u.sint = LLONG_MAX; return 1; } /* execute standard multiplication. */ - c = smp->data.data.sint * tmp.data.data.sint; + c = smp->data.u.sint * tmp.data.u.sint; /* check for overflow and makes capped multiply. */ - if (smp->data.data.sint != c / tmp.data.data.sint) { - if ((smp->data.data.sint < 0) == (tmp.data.data.sint < 0)) { - smp->data.data.sint = LLONG_MAX; + if (smp->data.u.sint != c / tmp.data.u.sint) { + if ((smp->data.u.sint < 0) == (tmp.data.u.sint < 0)) { + smp->data.u.sint = LLONG_MAX; return 1; } - smp->data.data.sint = LLONG_MIN; + smp->data.u.sint = LLONG_MIN; return 1; } - smp->data.data.sint = c; + smp->data.u.sint = c; return 1; } @@ -2259,18 +2259,18 @@ static int sample_conv_arith_div(const struct arg *arg_p, if (!sample_conv_var2smp(arg_p, smp->strm, &tmp)) return 0; - if (tmp.data.data.sint) { + if (tmp.data.u.sint) { /* The divide between LLONG_MIN and -1 returns a * "floting point exception". */ - if (smp->data.data.sint == LLONG_MIN && tmp.data.data.sint == -1) { - smp->data.data.sint = LLONG_MAX; + if (smp->data.u.sint == LLONG_MIN && tmp.data.u.sint == -1) { + smp->data.u.sint = LLONG_MAX; return 1; } - smp->data.data.sint /= tmp.data.data.sint; + smp->data.u.sint /= tmp.data.u.sint; return 1; } - smp->data.data.sint = LLONG_MAX; + smp->data.u.sint = LLONG_MAX; return 1; } @@ -2286,18 +2286,18 @@ static int sample_conv_arith_mod(const struct arg *arg_p, if (!sample_conv_var2smp(arg_p, smp->strm, &tmp)) return 0; - if (tmp.data.data.sint) { + if (tmp.data.u.sint) { /* The divide between LLONG_MIN and -1 returns a * "floting point exception". */ - if (smp->data.data.sint == LLONG_MIN && tmp.data.data.sint == -1) { - smp->data.data.sint = 0; + if (smp->data.u.sint == LLONG_MIN && tmp.data.u.sint == -1) { + smp->data.u.sint = 0; return 1; } - smp->data.data.sint %= tmp.data.data.sint; + smp->data.u.sint %= tmp.data.u.sint; return 1; } - smp->data.data.sint = 0; + smp->data.u.sint = 0; return 1; } @@ -2307,10 +2307,10 @@ static int sample_conv_arith_mod(const struct arg *arg_p, static int sample_conv_arith_neg(const struct arg *arg_p, struct sample *smp, void *private) { - if (smp->data.data.sint == LLONG_MIN) - smp->data.data.sint = LLONG_MAX; + if (smp->data.u.sint == LLONG_MIN) + smp->data.u.sint = LLONG_MAX; else - smp->data.data.sint = -smp->data.data.sint; + smp->data.u.sint = -smp->data.u.sint; return 1; } @@ -2320,7 +2320,7 @@ static int sample_conv_arith_neg(const struct arg *arg_p, static int sample_conv_arith_bool(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = !!smp->data.data.sint; + smp->data.u.sint = !!smp->data.u.sint; smp->data.type = SMP_T_BOOL; return 1; } @@ -2331,7 +2331,7 @@ static int sample_conv_arith_bool(const struct arg *arg_p, static int sample_conv_arith_not(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = !smp->data.data.sint; + smp->data.u.sint = !smp->data.u.sint; smp->data.type = SMP_T_BOOL; return 1; } @@ -2342,7 +2342,7 @@ static int sample_conv_arith_not(const struct arg *arg_p, static int sample_conv_arith_odd(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = smp->data.data.sint & 1; + smp->data.u.sint = smp->data.u.sint & 1; smp->data.type = SMP_T_BOOL; return 1; } @@ -2353,7 +2353,7 @@ static int sample_conv_arith_odd(const struct arg *arg_p, static int sample_conv_arith_even(const struct arg *arg_p, struct sample *smp, void *private) { - smp->data.data.sint = !(smp->data.data.sint & 1); + smp->data.u.sint = !(smp->data.u.sint & 1); smp->data.type = SMP_T_BOOL; return 1; } @@ -2367,7 +2367,7 @@ static int smp_fetch_true(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = 1; + smp->data.u.sint = 1; return 1; } @@ -2376,7 +2376,7 @@ static int smp_fetch_false(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = 0; + smp->data.u.sint = 0; return 1; } @@ -2395,8 +2395,8 @@ smp_fetch_env(const struct arg *args, struct sample *smp, const char *kw, void * smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; - smp->data.data.str.str = env; - smp->data.data.str.len = strlen(env); + smp->data.u.str.str = env; + smp->data.u.str.len = strlen(env); return 1; } @@ -2406,11 +2406,11 @@ smp_fetch_env(const struct arg *args, struct sample *smp, const char *kw, void * static int smp_fetch_date(const struct arg *args, struct sample *smp, const char *kw, void *private) { - smp->data.data.sint = date.tv_sec; + smp->data.u.sint = date.tv_sec; /* add offset */ if (args && args[0].type == ARGT_SINT) - smp->data.data.sint += args[0].data.sint; + smp->data.u.sint += args[0].data.sint; smp->data.type = SMP_T_SINT; smp->flags |= SMP_F_VOL_TEST | SMP_F_MAY_CHANGE; @@ -2422,7 +2422,7 @@ static int smp_fetch_nbproc(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = global.nbproc; + smp->data.u.sint = global.nbproc; return 1; } @@ -2431,7 +2431,7 @@ static int smp_fetch_proc(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = relative_pid; + smp->data.u.sint = relative_pid; return 1; } @@ -2441,11 +2441,11 @@ smp_fetch_proc(const struct arg *args, struct sample *smp, const char *kw, void static int smp_fetch_rand(const struct arg *args, struct sample *smp, const char *kw, void *private) { - smp->data.data.sint = random(); + smp->data.u.sint = random(); /* reduce if needed. Don't do a modulo, use all bits! */ if (args && args[0].type == ARGT_SINT) - smp->data.data.sint = (smp->data.data.sint * args[0].data.sint) / ((u64)RAND_MAX+1); + smp->data.u.sint = (smp->data.u.sint * args[0].data.sint) / ((u64)RAND_MAX+1); smp->data.type = SMP_T_SINT; smp->flags |= SMP_F_VOL_TEST | SMP_F_MAY_CHANGE; @@ -2457,7 +2457,7 @@ static int smp_fetch_stopping(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = stopping; + smp->data.u.sint = stopping; return 1; } @@ -2465,8 +2465,8 @@ static int smp_fetch_const_str(const struct arg *args, struct sample *smp, const { smp->flags |= SMP_F_CONST; smp->data.type = SMP_T_STR; - smp->data.data.str.str = args[0].data.str.str; - smp->data.data.str.len = args[0].data.str.len; + smp->data.u.str.str = args[0].data.str.str; + smp->data.u.str.len = args[0].data.str.len; return 1; } @@ -2491,28 +2491,28 @@ static int smp_check_const_bool(struct arg *args, char **err) static int smp_fetch_const_bool(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_BOOL; - smp->data.data.sint = args[0].data.sint; + smp->data.u.sint = args[0].data.sint; return 1; } static int smp_fetch_const_int(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_SINT; - smp->data.data.sint = args[0].data.sint; + smp->data.u.sint = args[0].data.sint; return 1; } static int smp_fetch_const_ipv4(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_IPV4; - smp->data.data.ipv4 = args[0].data.ipv4; + smp->data.u.ipv4 = args[0].data.ipv4; return 1; } static int smp_fetch_const_ipv6(const struct arg *args, struct sample *smp, const char *kw, void *private) { smp->data.type = SMP_T_IPV6; - smp->data.data.ipv6 = args[0].data.ipv6; + smp->data.u.ipv6 = args[0].data.ipv6; return 1; } @@ -2533,8 +2533,8 @@ static int smp_fetch_const_bin(const struct arg *args, struct sample *smp, const { smp->flags |= SMP_F_CONST; smp->data.type = SMP_T_BIN; - smp->data.data.str.str = args[0].data.str.str; - smp->data.data.str.len = args[0].data.str.len; + smp->data.u.str.str = args[0].data.str.str; + smp->data.u.str.len = args[0].data.str.len; return 1; } @@ -2568,14 +2568,14 @@ static int smp_fetch_const_meth(const struct arg *args, struct sample *smp, cons smp->data.type = SMP_T_METH; if (args[0].type == ARGT_SINT) { smp->flags &= ~SMP_F_CONST; - smp->data.data.meth.meth = args[0].data.sint; - smp->data.data.meth.str.str = ""; - smp->data.data.meth.str.len = 0; + smp->data.u.meth.meth = args[0].data.sint; + smp->data.u.meth.str.str = ""; + smp->data.u.meth.str.len = 0; } else { smp->flags |= SMP_F_CONST; - smp->data.data.meth.meth = HTTP_METH_OTHER; - smp->data.data.meth.str.str = args[0].data.str.str; - smp->data.data.meth.str.len = args[0].data.str.len; + smp->data.u.meth.meth = HTTP_METH_OTHER; + smp->data.u.meth.str.str = args[0].data.str.str; + smp->data.u.meth.str.len = args[0].data.str.len; } return 1; } diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 120ea3d82..a91738cb8 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -3405,7 +3405,7 @@ smp_fetch_ssl_fc_has_crt(const struct arg *args, struct sample *smp, const char smp->flags = 0; smp->data.type = SMP_T_BOOL; - smp->data.data.sint = SSL_SOCK_ST_FL_VERIFY_DONE & conn->xprt_st ? 1 : 0; + smp->data.u.sint = SSL_SOCK_ST_FL_VERIFY_DONE & conn->xprt_st ? 1 : 0; return 1; } @@ -3444,7 +3444,7 @@ 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.data.str = *smp_trash; + smp->data.u.str = *smp_trash; smp->data.type = SMP_T_BIN; ret = 1; out: @@ -3488,7 +3488,7 @@ 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.data.str = *smp_trash; + smp->data.u.str = *smp_trash; smp->data.type = SMP_T_BIN; ret = 1; out: @@ -3532,7 +3532,7 @@ 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.data.str = *smp_trash; + smp->data.u.str = *smp_trash; smp->data.type = SMP_T_BIN; ret = 1; out: @@ -3575,7 +3575,7 @@ 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.data.str = *smp_trash; + smp->data.u.str = *smp_trash; smp->data.type = SMP_T_STR; ret = 1; out: @@ -3633,7 +3633,7 @@ smp_fetch_ssl_x_i_dn(const struct arg *args, struct sample *smp, const char *kw, goto out; smp->data.type = SMP_T_STR; - smp->data.data.str = *smp_trash; + smp->data.u.str = *smp_trash; ret = 1; out: /* SSL_get_peer_certificate, it increase X509 * ref count */ @@ -3675,7 +3675,7 @@ 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.data.str = *smp_trash; + smp->data.u.str = *smp_trash; smp->data.type = SMP_T_STR; ret = 1; out: @@ -3733,7 +3733,7 @@ smp_fetch_ssl_x_s_dn(const struct arg *args, struct sample *smp, const char *kw, goto out; smp->data.type = SMP_T_STR; - smp->data.data.str = *smp_trash; + smp->data.u.str = *smp_trash; ret = 1; out: /* SSL_get_peer_certificate, it increase X509 * ref count */ @@ -3765,7 +3765,7 @@ smp_fetch_ssl_c_used(const struct arg *args, struct sample *smp, const char *kw, } smp->data.type = SMP_T_BOOL; - smp->data.data.sint = (crt != NULL); + smp->data.u.sint = (crt != NULL); return 1; } @@ -3796,7 +3796,7 @@ smp_fetch_ssl_x_version(const struct arg *args, struct sample *smp, const char * if (!crt) return 0; - smp->data.data.sint = (unsigned int)(1 + X509_get_version(crt)); + smp->data.u.sint = (unsigned int)(1 + X509_get_version(crt)); /* SSL_get_peer_certificate increase X509 * ref count */ if (cert_peer) X509_free(crt); @@ -3835,8 +3835,8 @@ 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.data.str.str = (char *)OBJ_nid2sn(nid); - if (!smp->data.data.str.str) { + smp->data.u.str.str = (char *)OBJ_nid2sn(nid); + if (!smp->data.u.str.str) { /* SSL_get_peer_certificate increase X509 * ref count */ if (cert_peer) X509_free(crt); @@ -3845,7 +3845,7 @@ smp_fetch_ssl_x_sig_alg(const struct arg *args, struct sample *smp, const char * smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str.len = strlen(smp->data.data.str.str); + smp->data.u.str.len = strlen(smp->data.u.str.str); /* SSL_get_peer_certificate increase X509 * ref count */ if (cert_peer) X509_free(crt); @@ -3883,8 +3883,8 @@ 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.data.str.str = (char *)OBJ_nid2sn(nid); - if (!smp->data.data.str.str) { + smp->data.u.str.str = (char *)OBJ_nid2sn(nid); + if (!smp->data.u.str.str) { /* SSL_get_peer_certificate increase X509 * ref count */ if (cert_peer) X509_free(crt); @@ -3893,7 +3893,7 @@ smp_fetch_ssl_x_key_alg(const struct arg *args, struct sample *smp, const char * smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str.len = strlen(smp->data.data.str.str); + smp->data.u.str.len = strlen(smp->data.u.str.str); if (cert_peer) X509_free(crt); @@ -3911,7 +3911,7 @@ smp_fetch_ssl_fc(const struct arg *args, struct sample *smp, const char *kw, voi struct connection *conn = objt_conn(smp->strm->si[back_conn].end); smp->data.type = SMP_T_BOOL; - smp->data.data.sint = (conn && conn->xprt == &ssl_sock); + smp->data.u.sint = (conn && conn->xprt == &ssl_sock); return 1; } @@ -3923,7 +3923,7 @@ smp_fetch_ssl_fc_has_sni(const struct arg *args, struct sample *smp, const char struct connection *conn = objt_conn(smp->sess->origin); smp->data.type = SMP_T_BOOL; - smp->data.data.sint = (conn && conn->xprt == &ssl_sock) && + smp->data.u.sint = (conn && conn->xprt == &ssl_sock) && conn->xprt_ctx && SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name) != NULL; return 1; @@ -3939,7 +3939,7 @@ smp_fetch_ssl_fc_is_resumed(const struct arg *args, struct sample *smp, const ch struct connection *conn = objt_conn(smp->sess->origin); smp->data.type = SMP_T_BOOL; - smp->data.data.sint = (conn && conn->xprt == &ssl_sock) && + smp->data.u.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.data.str.str = (char *)SSL_get_cipher_name(conn->xprt_ctx); - if (!smp->data.data.str.str) + smp->data.u.str.str = (char *)SSL_get_cipher_name(conn->xprt_ctx); + if (!smp->data.u.str.str) return 0; smp->data.type = SMP_T_STR; smp->flags |= SMP_F_CONST; - smp->data.data.str.len = strlen(smp->data.data.str.str); + smp->data.u.str.len = strlen(smp->data.u.str.str); return 1; } @@ -3993,7 +3993,7 @@ 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.data.sint = sint; + smp->data.u.sint = sint; smp->data.type = SMP_T_SINT; return 1; @@ -4015,8 +4015,8 @@ 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.data.sint = (unsigned int)SSL_get_cipher_bits(conn->xprt_ctx, NULL); - if (!smp->data.data.sint) + smp->data.u.sint = (unsigned int)SSL_get_cipher_bits(conn->xprt_ctx, NULL); + if (!smp->data.u.sint) return 0; smp->data.type = SMP_T_SINT; @@ -4037,11 +4037,11 @@ smp_fetch_ssl_fc_npn(const struct arg *args, struct sample *smp, const char *kw, if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock) return 0; - smp->data.data.str.str = NULL; + smp->data.u.str.str = NULL; SSL_get0_next_proto_negotiated(conn->xprt_ctx, - (const unsigned char **)&smp->data.data.str.str, (unsigned *)&smp->data.data.str.len); + (const unsigned char **)&smp->data.u.str.str, (unsigned *)&smp->data.u.str.len); - if (!smp->data.data.str.str) + if (!smp->data.u.str.str) return 0; return 1; @@ -4061,11 +4061,11 @@ smp_fetch_ssl_fc_alpn(const struct arg *args, struct sample *smp, const char *kw if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock) return 0; - smp->data.data.str.str = NULL; + smp->data.u.str.str = NULL; SSL_get0_alpn_selected(conn->xprt_ctx, - (const unsigned char **)&smp->data.data.str.str, (unsigned *)&smp->data.data.str.len); + (const unsigned char **)&smp->data.u.str.str, (unsigned *)&smp->data.u.str.len); - if (!smp->data.data.str.str) + if (!smp->data.u.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.data.str.str = (char *)SSL_get_version(conn->xprt_ctx); - if (!smp->data.data.str.str) + smp->data.u.str.str = (char *)SSL_get_version(conn->xprt_ctx); + if (!smp->data.u.str.str) return 0; smp->data.type = SMP_T_STR; smp->flags = SMP_F_CONST; - smp->data.data.str.len = strlen(smp->data.data.str.str); + smp->data.u.str.len = strlen(smp->data.u.str.str); return 1; } @@ -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.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) + smp->data.u.str.str = (char *)SSL_SESSION_get_id(ssl_sess, (unsigned int *)&smp->data.u.str.len); + if (!smp->data.u.str.str || !smp->data.u.str.len) return 0; return 1; @@ -4145,11 +4145,11 @@ smp_fetch_ssl_fc_sni(const struct arg *args, struct sample *smp, const char *kw, if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock) return 0; - smp->data.data.str.str = (char *)SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name); - if (!smp->data.data.str.str) + smp->data.u.str.str = (char *)SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name); + if (!smp->data.u.str.str) return 0; - smp->data.data.str.len = strlen(smp->data.data.str.str); + smp->data.u.str.len = strlen(smp->data.u.str.str); return 1; #else return 0; @@ -4186,7 +4186,7 @@ smp_fetch_ssl_fc_unique_id(const struct arg *args, struct sample *smp, const cha return 0; finished_trash->len = finished_len; - smp->data.data.str = *finished_trash; + smp->data.u.str = *finished_trash; smp->data.type = SMP_T_BIN; return 1; @@ -4211,7 +4211,7 @@ smp_fetch_ssl_c_ca_err(const struct arg *args, struct sample *smp, const char *k } smp->data.type = SMP_T_SINT; - smp->data.data.sint = (unsigned long long int)SSL_SOCK_ST_TO_CA_ERROR(conn->xprt_st); + smp->data.u.sint = (unsigned long long int)SSL_SOCK_ST_TO_CA_ERROR(conn->xprt_st); smp->flags = 0; return 1; @@ -4233,7 +4233,7 @@ smp_fetch_ssl_c_ca_err_depth(const struct arg *args, struct sample *smp, const c } smp->data.type = SMP_T_SINT; - smp->data.data.sint = (long long int)SSL_SOCK_ST_TO_CAEDEPTH(conn->xprt_st); + smp->data.u.sint = (long long int)SSL_SOCK_ST_TO_CAEDEPTH(conn->xprt_st); smp->flags = 0; return 1; @@ -4255,7 +4255,7 @@ smp_fetch_ssl_c_err(const struct arg *args, struct sample *smp, const char *kw, } smp->data.type = SMP_T_SINT; - smp->data.data.sint = (long long int)SSL_SOCK_ST_TO_CRTERROR(conn->xprt_st); + smp->data.u.sint = (long long int)SSL_SOCK_ST_TO_CRTERROR(conn->xprt_st); smp->flags = 0; return 1; @@ -4280,7 +4280,7 @@ smp_fetch_ssl_c_verify(const struct arg *args, struct sample *smp, const char *k return 0; smp->data.type = SMP_T_SINT; - smp->data.data.sint = (long long int)SSL_get_verify_result(conn->xprt_ctx); + smp->data.u.sint = (long long int)SSL_get_verify_result(conn->xprt_ctx); smp->flags = 0; return 1; diff --git a/src/stick_table.c b/src/stick_table.c index 7559bc6d9..f8cc123bd 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -458,28 +458,28 @@ 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.data.sint; + kdata->integer = smp->data.u.sint; return (void *)&kdata->integer; } static void *k_ip2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len) { if (smp->data.type == SMP_T_IPV6) { - v6tov4(&kdata->ip, &smp->data.data.ipv6); + v6tov4(&kdata->ip, &smp->data.u.ipv6); return (void *)&kdata->ip.s_addr; } else { - return (void *)&smp->data.data.ipv4.s_addr; + return (void *)&smp->data.u.ipv4.s_addr; } } static void *k_ip2ipv6(struct sample *smp, union stktable_key_data *kdata, size_t *len) { if (smp->data.type == SMP_T_IPV6) { - return (void *)&smp->data.data.ipv6.s6_addr; + return (void *)&smp->data.u.ipv6.s6_addr; } else { - v4tov6(&kdata->ipv6, &smp->data.data.ipv4); + v4tov6(&kdata->ipv6, &smp->data.u.ipv4); return (void *)&kdata->ipv6.s6_addr; } } @@ -487,36 +487,36 @@ static void *k_ip2ipv6(struct sample *smp, union stktable_key_data *kdata, size_ static void *k_ip2int(struct sample *smp, union stktable_key_data *kdata, size_t *len) { if (smp->data.type == SMP_T_IPV6) { - if (!v6tov4(&kdata->ip, &smp->data.data.ipv6)) + if (!v6tov4(&kdata->ip, &smp->data.u.ipv6)) return NULL; kdata->integer = ntohl(kdata->ip.s_addr); } else { - kdata->integer = ntohl(smp->data.data.ipv4.s_addr); + kdata->integer = ntohl(smp->data.u.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.data.sint); + kdata->ip.s_addr = htonl((unsigned int)smp->data.u.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.data.str.len; - return (void *)smp->data.data.str.str; + *len = smp->data.u.str.len; + return (void *)smp->data.u.str.str; } static void *k_ip2str(struct sample *smp, union stktable_key_data *kdata, size_t *len) { if (smp->data.type == SMP_T_IPV6) { - if (!inet_ntop(AF_INET6, &smp->data.data.ipv6, kdata->buf, *len)) + if (!inet_ntop(AF_INET6, &smp->data.u.ipv6, kdata->buf, *len)) return NULL; } else { - if (!inet_ntop(AF_INET, &smp->data.data.ipv4, kdata->buf, *len)) + if (!inet_ntop(AF_INET, &smp->data.u.ipv4, kdata->buf, *len)) return NULL; } @@ -529,12 +529,12 @@ static void *k_ip2bin(struct sample *smp, union stktable_key_data *kdata, size_t if (smp->data.type == SMP_T_IPV4) { if (*len > 4) *len = 4; - memcpy(kdata->buf, &smp->data.data.ipv4, *len); + memcpy(kdata->buf, &smp->data.u.ipv4, *len); } else if (smp->data.type == SMP_T_IPV6) { if (*len > 16) *len = 16; - memcpy(kdata->buf, &smp->data.data.ipv6, *len); + memcpy(kdata->buf, &smp->data.u.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.data.str.len && size <= max - 2) { - c = smp->data.data.str.str[ptr++]; + while (ptr < smp->data.u.str.len && size <= max - 2) { + c = smp->data.u.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.data.sint, kdata->buf, *len); + key = (void *)lltoa_r(smp->data.u.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.data.str.str, smp->data.data.str.len, &kdata->ip)) + if (!buf2ip(smp->data.u.str.str, smp->data.u.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.data.str.str, &kdata->ipv6)) + if (!inet_pton(AF_INET6, smp->data.u.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.data.str.len; i++) { - uint32_t val = smp->data.data.str.str[i] - '0'; + for (i = 0; i < smp->data.u.str.len; i++) { + uint32_t val = smp->data.u.str.str[i] - '0'; if (val > 9) break; @@ -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.data.buf) + /* assume static_table_key.key_len is less than sizeof(static_table_key.data.u.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 && @@ -812,7 +812,7 @@ static int sample_conv_in_table(const struct arg *arg_p, struct sample *smp, voi ts = stktable_lookup_key(t, key); smp->data.type = SMP_T_BOOL; - smp->data.data.sint = !!ts; + smp->data.u.sint = !!ts; smp->flags = SMP_F_VOL_TEST; return 1; } @@ -838,7 +838,7 @@ static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sampl smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate), t->data_arg[STKTABLE_DT_BYTES_IN_RATE].u); return 1; } @@ -874,7 +874,7 @@ static int sample_conv_table_conn_cnt(const struct arg *arg_p, struct sample *sm smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, conn_cnt); + smp->data.u.sint = stktable_data_cast(ptr, conn_cnt); return 1; } @@ -909,7 +909,7 @@ static int sample_conv_table_conn_cur(const struct arg *arg_p, struct sample *sm smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, conn_cur); + smp->data.u.sint = stktable_data_cast(ptr, conn_cur); return 1; } @@ -944,7 +944,7 @@ static int sample_conv_table_conn_rate(const struct arg *arg_p, struct sample *s smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate), t->data_arg[STKTABLE_DT_CONN_RATE].u); return 1; } @@ -980,7 +980,7 @@ static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct samp smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate), t->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u); return 1; } @@ -1016,7 +1016,7 @@ static int sample_conv_table_gpc0(const struct arg *arg_p, struct sample *smp, v smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, gpc0); + smp->data.u.sint = stktable_data_cast(ptr, gpc0); return 1; } @@ -1051,7 +1051,7 @@ static int sample_conv_table_gpc0_rate(const struct arg *arg_p, struct sample *s smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate), t->data_arg[STKTABLE_DT_GPC0_RATE].u); return 1; } @@ -1087,7 +1087,7 @@ static int sample_conv_table_http_err_cnt(const struct arg *arg_p, struct sample smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, http_err_cnt); + smp->data.u.sint = stktable_data_cast(ptr, http_err_cnt); return 1; } @@ -1122,7 +1122,7 @@ static int sample_conv_table_http_err_rate(const struct arg *arg_p, struct sampl smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate), t->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u); return 1; } @@ -1158,7 +1158,7 @@ static int sample_conv_table_http_req_cnt(const struct arg *arg_p, struct sample smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, http_req_cnt); + smp->data.u.sint = stktable_data_cast(ptr, http_req_cnt); return 1; } @@ -1193,7 +1193,7 @@ static int sample_conv_table_http_req_rate(const struct arg *arg_p, struct sampl smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u); return 1; } @@ -1229,7 +1229,7 @@ static int sample_conv_table_kbytes_in(const struct arg *arg_p, struct sample *s smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10; + smp->data.u.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10; return 1; } @@ -1264,7 +1264,7 @@ static int sample_conv_table_kbytes_out(const struct arg *arg_p, struct sample * smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10; + smp->data.u.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10; return 1; } @@ -1299,7 +1299,7 @@ static int sample_conv_table_server_id(const struct arg *arg_p, struct sample *s smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, server_id); + smp->data.u.sint = stktable_data_cast(ptr, server_id); return 1; } @@ -1334,7 +1334,7 @@ static int sample_conv_table_sess_cnt(const struct arg *arg_p, struct sample *sm smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, sess_cnt); + smp->data.u.sint = stktable_data_cast(ptr, sess_cnt); return 1; } @@ -1369,7 +1369,7 @@ static int sample_conv_table_sess_rate(const struct arg *arg_p, struct sample *s smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate), t->data_arg[STKTABLE_DT_SESS_RATE].u); return 1; } @@ -1404,11 +1404,11 @@ static int sample_conv_table_trackers(const struct arg *arg_p, struct sample *sm smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.sint = 0; ts = stktable_lookup_key(t, key); if (ts) - smp->data.data.sint = ts->ref_cnt; + smp->data.u.sint = ts->ref_cnt; return 1; } diff --git a/src/stream.c b/src/stream.c index acb602af1..5280e372f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2672,7 +2672,7 @@ smp_fetch_sc_tracked(const struct arg *args, struct sample *smp, const char *kw, { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_BOOL; - smp->data.data.sint = !!smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw); + smp->data.u.sint = !!smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw); return 1; } @@ -2691,13 +2691,13 @@ smp_fetch_sc_get_gpc0(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, gpc0); + smp->data.u.sint = stktable_data_cast(ptr, gpc0); } return 1; } @@ -2717,12 +2717,12 @@ smp_fetch_sc_gpc0_rate(const struct arg *args, struct sample *smp, const char *k smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, gpc0_rate), stkctr->table->data_arg[STKTABLE_DT_GPC0_RATE].u); } return 1; @@ -2742,7 +2742,7 @@ smp_fetch_sc_inc_gpc0(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = (&stktable_data_cast(ptr1, gpc0_rate))->curr_ctr; + smp->data.u.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.data.sint = ++stktable_data_cast(ptr2, gpc0); + smp->data.u.sint = ++stktable_data_cast(ptr2, gpc0); /* If data was modified, we need to touch to re-schedule sync */ if (ptr1 || ptr2) @@ -2785,7 +2785,7 @@ smp_fetch_sc_clr_gpc0(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, gpc0); + smp->data.u.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); @@ -2816,12 +2816,12 @@ smp_fetch_sc_conn_cnt(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, conn_cnt); + smp->data.u.sint = stktable_data_cast(ptr, conn_cnt); } return 1; } @@ -2840,12 +2840,12 @@ smp_fetch_sc_conn_rate(const struct arg *args, struct sample *smp, const char *k smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, conn_rate), stkctr->table->data_arg[STKTABLE_DT_CONN_RATE].u); } return 1; @@ -2882,7 +2882,7 @@ smp_fetch_src_updt_conn_cnt(const struct arg *args, struct sample *smp, const ch return 0; /* parameter not stored in this table */ smp->data.type = SMP_T_SINT; - smp->data.data.sint = ++stktable_data_cast(ptr, conn_cnt); + smp->data.u.sint = ++stktable_data_cast(ptr, conn_cnt); /* Touch was previously performed by stktable_update_key */ smp->flags = SMP_F_VOL_TEST; return 1; @@ -2902,12 +2902,12 @@ smp_fetch_sc_conn_cur(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, conn_cur); + smp->data.u.sint = stktable_data_cast(ptr, conn_cur); } return 1; } @@ -2926,12 +2926,12 @@ smp_fetch_sc_sess_cnt(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, sess_cnt); + smp->data.u.sint = stktable_data_cast(ptr, sess_cnt); } return 1; } @@ -2949,12 +2949,12 @@ smp_fetch_sc_sess_rate(const struct arg *args, struct sample *smp, const char *k smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, sess_rate), stkctr->table->data_arg[STKTABLE_DT_SESS_RATE].u); } return 1; @@ -2974,12 +2974,12 @@ smp_fetch_sc_http_req_cnt(const struct arg *args, struct sample *smp, const char smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, http_req_cnt); + smp->data.u.sint = stktable_data_cast(ptr, http_req_cnt); } return 1; } @@ -2998,12 +2998,12 @@ smp_fetch_sc_http_req_rate(const struct arg *args, struct sample *smp, const cha smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), stkctr->table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u); } return 1; @@ -3023,12 +3023,12 @@ smp_fetch_sc_http_err_cnt(const struct arg *args, struct sample *smp, const char smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, http_err_cnt); + smp->data.u.sint = stktable_data_cast(ptr, http_err_cnt); } return 1; } @@ -3047,12 +3047,12 @@ smp_fetch_sc_http_err_rate(const struct arg *args, struct sample *smp, const cha smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate), stkctr->table->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u); } return 1; @@ -3072,12 +3072,12 @@ smp_fetch_sc_kbytes_in(const struct arg *args, struct sample *smp, const char *k smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10; + smp->data.u.sint = stktable_data_cast(ptr, bytes_in_cnt) >> 10; } return 1; } @@ -3096,12 +3096,12 @@ smp_fetch_sc_bytes_in_rate(const struct arg *args, struct sample *smp, const cha smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_in_rate), stkctr->table->data_arg[STKTABLE_DT_BYTES_IN_RATE].u); } return 1; @@ -3121,12 +3121,12 @@ smp_fetch_sc_kbytes_out(const struct arg *args, struct sample *smp, const char * smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10; + smp->data.u.sint = stktable_data_cast(ptr, bytes_out_cnt) >> 10; } return 1; } @@ -3145,12 +3145,12 @@ smp_fetch_sc_bytes_out_rate(const struct arg *args, struct sample *smp, const ch smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = 0; + smp->data.u.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.data.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate), + smp->data.u.sint = read_freq_ctr_period(&stktable_data_cast(ptr, bytes_out_rate), stkctr->table->data_arg[STKTABLE_DT_BYTES_OUT_RATE].u); } return 1; @@ -3169,7 +3169,7 @@ smp_fetch_sc_trackers(const struct arg *args, struct sample *smp, const char *kw smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = stkctr_entry(stkctr)->ref_cnt; + smp->data.u.sint = stkctr_entry(stkctr)->ref_cnt; return 1; } @@ -3181,7 +3181,7 @@ smp_fetch_table_cnt(const struct arg *args, struct sample *smp, const char *kw, { smp->flags = SMP_F_VOL_TEST; smp->data.type = SMP_T_SINT; - smp->data.data.sint = args->data.prx->table.current; + smp->data.u.sint = args->data.prx->table.current; return 1; } @@ -3196,7 +3196,7 @@ 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->data.type = SMP_T_SINT; - smp->data.data.sint = px->table.size - px->table.current; + smp->data.u.sint = px->table.size - px->table.current; return 1; } diff --git a/src/vars.c b/src/vars.c index a09de3706..ed30846bf 100644 --- a/src/vars.c +++ b/src/vars.c @@ -83,12 +83,12 @@ void vars_prune(struct vars *vars, struct stream *strm) list_for_each_entry_safe(var, tmp, &vars->head, l) { if (var->data.type == SMP_T_STR || var->data.type == SMP_T_BIN) { - free(var->data.data.str.str); - size += var->data.data.str.len; + free(var->data.u.str.str); + size += var->data.u.str.len; } else if (var->data.type == SMP_T_METH) { - free(var->data.data.meth.str.str); - size += var->data.data.meth.str.len; + free(var->data.u.meth.str.str); + size += var->data.u.meth.str.len; } LIST_DEL(&var->l); pool_free2(var_pool, var); @@ -108,12 +108,12 @@ void vars_prune_per_sess(struct vars *vars) list_for_each_entry_safe(var, tmp, &vars->head, l) { if (var->data.type == SMP_T_STR || var->data.type == SMP_T_BIN) { - free(var->data.data.str.str); - size += var->data.data.str.len; + free(var->data.u.str.str); + size += var->data.u.str.len; } else if (var->data.type == SMP_T_METH) { - free(var->data.data.meth.str.str); - size += var->data.data.meth.str.len; + free(var->data.u.meth.str.str); + size += var->data.u.meth.str.len; } LIST_DEL(&var->l); pool_free2(var_pool, var); @@ -251,7 +251,7 @@ static int smp_fetch_var(const struct arg *args, struct sample *smp, const char /* Copy sample. */ smp->data.type = var->data.type; smp->flags |= SMP_F_CONST; - memcpy(&smp->data.data, &var->data.data, sizeof(smp->data.data)); + memcpy(&smp->data.u, &var->data.u, sizeof(smp->data.u)); return 1; } @@ -271,12 +271,12 @@ static int sample_store(struct vars *vars, const char *name, struct stream *strm /* free its used memory. */ if (var->data.type == SMP_T_STR || var->data.type == SMP_T_BIN) { - free(var->data.data.str.str); - var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -var->data.data.str.len); + free(var->data.u.str.str); + var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -var->data.u.str.len); } else if (var->data.type == SMP_T_METH) { - free(var->data.data.meth.str.str); - var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -var->data.data.meth.str.len); + free(var->data.u.meth.str.str); + var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -var->data.u.meth.str.len); } } else { @@ -299,44 +299,44 @@ static int sample_store(struct vars *vars, const char *name, struct stream *strm switch (var->data.type) { case SMP_T_BOOL: case SMP_T_SINT: - var->data.data.sint = smp->data.data.sint; + var->data.u.sint = smp->data.u.sint; break; case SMP_T_IPV4: - var->data.data.ipv4 = smp->data.data.ipv4; + var->data.u.ipv4 = smp->data.u.ipv4; break; case SMP_T_IPV6: - var->data.data.ipv6 = smp->data.data.ipv6; + var->data.u.ipv6 = smp->data.u.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.data.str.len)) { + if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.u.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.data.str.len); - if (!var->data.data.str.str) { - var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.data.str.len); + var->data.u.str.str = malloc(smp->data.u.str.len); + if (!var->data.u.str.str) { + var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.u.str.len); var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */ return 0; } - 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); + var->data.u.str.len = smp->data.u.str.len; + memcpy(var->data.u.str.str, smp->data.u.str.str, var->data.u.str.len); break; case SMP_T_METH: - if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.data.meth.str.len)) { + if (!var_accounting_add(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, smp->data.u.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.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.data.meth.str.len); + var->data.u.meth.str.str = malloc(smp->data.u.meth.str.len); + if (!var->data.u.meth.str.str) { + var_accounting_diff(vars, &strm->sess->vars, &strm->vars_txn, &strm->vars_reqres, -smp->data.u.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.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); + var->data.u.meth.meth = smp->data.u.meth.meth; + var->data.u.meth.str.len = smp->data.u.meth.str.len; + var->data.u.meth.str.size = smp->data.u.meth.str.len; + memcpy(var->data.u.meth.str.str, smp->data.u.meth.str.str, var->data.u.meth.str.len); break; } return 1; @@ -444,7 +444,7 @@ int vars_get_by_name(const char *name, size_t len, struct stream *strm, struct s /* Copy sample. */ smp->data.type = var->data.type; smp->flags = SMP_F_CONST; - memcpy(&smp->data.data, &var->data.data, sizeof(smp->data.data)); + memcpy(&smp->data.u, &var->data.u, sizeof(smp->data.u)); return 1; } @@ -478,7 +478,7 @@ int vars_get_by_desc(const struct var_desc *var_desc, struct stream *strm, struc /* Copy sample. */ smp->data.type = var->data.type; smp->flags = SMP_F_CONST; - memcpy(&smp->data.data, &var->data.data, sizeof(smp->data.data)); + memcpy(&smp->data.u, &var->data.u, sizeof(smp->data.u)); return 1; }