MEDIUM: pattern: integrate pattern_data into sample and use sample everywhere
Now there is no more reference to union pattern_data. All pattern fetch and
conversion functions now make use of the common sample type. Note: none of
them adjust the type right now so it's important to do it next otherwise
we would risk sharing such functions with ACLs and seeing them fail.
diff --git a/include/types/pattern.h b/include/types/pattern.h
index 1ac1cc3..d4d3838 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -61,15 +61,6 @@
#define PATTERN_FETCH_RTR 2
-/* pattern result data */
-union pattern_data {
- unsigned int uint; /* used for unsigned 32bits integers and booleans */
- int sint; /* used for signed 32bits integers */
- struct in_addr ipv4; /* used for ipv4 addresses */
- struct in6_addr ipv6; /* used for ipv6 addresses */
- struct chunk str; /* used for char strings or buffers */
-};
-
/* a sample context might be used by any sample fetch function in order to
* store information needed across multiple calls (eg: restart point for a
* next occurrence). By definition it may store up to 8 pointers, or any
@@ -89,7 +80,13 @@
struct sample {
unsigned int flags; /* SMP_F_* */
int type; /* SMP_T_* */
- union pattern_data data;
+ union {
+ unsigned int uint; /* used for unsigned 32bits integers and booleans */
+ int sint; /* used for signed 32bits integers */
+ struct in_addr ipv4; /* used for ipv4 addresses */
+ struct in6_addr ipv6; /* used for ipv6 addresses */
+ struct chunk str; /* used for char strings or buffers */
+ } data; /* sample data */
union smp_ctx ctx;
};
@@ -97,7 +94,7 @@
struct pattern_conv {
const char *kw; /* configuration keyword */
int (*process)(const struct arg *arg_p,
- union pattern_data *data); /* process function */
+ struct sample *smp); /* process function */
unsigned int arg_mask; /* arguments (ARG*()) */
int (*val_args)(struct arg *arg_p,
char **err_msg); /* argument validation function */
@@ -119,7 +116,7 @@
struct session *l4,
void *l7,
int dir, const struct arg *arg_p,
- union pattern_data *data); /* fetch processing function */
+ struct sample *smp); /* fetch processing function */
unsigned int arg_mask; /* arguments (ARG*()) */
int (*val_args)(struct arg *arg_p,
char **err_msg); /* argument validation function */
diff --git a/src/pattern.c b/src/pattern.c
index 10e1365..f851331 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -120,74 +120,74 @@
/* Pattern casts functions */
/******************************************************************/
-static int c_ip2int(union pattern_data *data)
+static int c_ip2int(struct sample *smp)
{
- data->uint = ntohl(data->ipv4.s_addr);
+ smp->data.uint = ntohl(smp->data.ipv4.s_addr);
return 1;
}
-static int c_ip2str(union pattern_data *data)
+static int c_ip2str(struct sample *smp)
{
struct chunk *trash = get_trash_chunk();
- if (!inet_ntop(AF_INET, (void *)&data->ipv4, trash->str, trash->size))
+ if (!inet_ntop(AF_INET, (void *)&smp->data.ipv4, trash->str, trash->size))
return 0;
trash->len = strlen(trash->str);
- data->str = *trash;
+ smp->data.str = *trash;
return 1;
}
-static int c_ip2ipv6(union pattern_data *data)
+static int c_ip2ipv6(struct sample *smp)
{
- v4tov6(&data->ipv6, &data->ipv4);
+ v4tov6(&smp->data.ipv6, &smp->data.ipv4);
return 1;
}
-static int c_ipv62str(union pattern_data *data)
+static int c_ipv62str(struct sample *smp)
{
struct chunk *trash = get_trash_chunk();
- if (!inet_ntop(AF_INET6, (void *)&data->ipv6, trash->str, trash->size))
+ if (!inet_ntop(AF_INET6, (void *)&smp->data.ipv6, trash->str, trash->size))
return 0;
trash->len = strlen(trash->str);
- data->str = *trash;
+ smp->data.str = *trash;
return 1;
}
/*
-static int c_ipv62ip(union pattern_data *data)
+static int c_ipv62ip(struct sample *smp)
{
- return v6tov4(&data->ipv4, &data->ipv6);
+ return v6tov4(&smp->data.ipv4, &smp->data.ipv6);
}
*/
-static int c_int2ip(union pattern_data *data)
+static int c_int2ip(struct sample *smp)
{
- data->ipv4.s_addr = htonl(data->uint);
+ smp->data.ipv4.s_addr = htonl(smp->data.uint);
return 1;
}
-static int c_str2ip(union pattern_data *data)
+static int c_str2ip(struct sample *smp)
{
- if (!buf2ip(data->str.str, data->str.len, &data->ipv4))
+ if (!buf2ip(smp->data.str.str, smp->data.str.len, &smp->data.ipv4))
return 0;
return 1;
}
-static int c_str2ipv6(union pattern_data *data)
+static int c_str2ipv6(struct sample *smp)
{
- return inet_pton(AF_INET6, data->str.str, &data->ipv6);
+ return inet_pton(AF_INET6, smp->data.str.str, &smp->data.ipv6);
}
-static int c_int2str(union pattern_data *data)
+static int c_int2str(struct sample *smp)
{
struct chunk *trash = get_trash_chunk();
char *pos;
- pos = ultoa_r(data->uint, trash->str, trash->size);
+ pos = ultoa_r(smp->data.uint, trash->str, trash->size);
if (!pos)
return 0;
@@ -195,33 +195,33 @@
trash->size = trash->size - (pos - trash->str);
trash->str = pos;
trash->len = strlen(pos);
- data->str = *trash;
+ smp->data.str = *trash;
return 1;
}
-static int c_datadup(union pattern_data *data)
+static int c_datadup(struct sample *smp)
{
struct chunk *trash = get_trash_chunk();
- trash->len = data->str.len < trash->size ? data->str.len : trash->size;
- memcpy(trash->str, data->str.str, trash->len);
- data->str = *trash;
+ trash->len = smp->data.str.len < trash->size ? smp->data.str.len : trash->size;
+ memcpy(trash->str, smp->data.str.str, trash->len);
+ smp->data.str = *trash;
return 1;
}
-static int c_none(union pattern_data *data)
+static int c_none(struct sample *smp)
{
return 1;
}
-static int c_str2int(union pattern_data *data)
+static int c_str2int(struct sample *smp)
{
int i;
uint32_t ret = 0;
- for (i = 0; i < data->str.len; i++) {
- uint32_t val = data->str.str[i] - '0';
+ for (i = 0; i < smp->data.str.len; i++) {
+ uint32_t val = smp->data.str.str[i] - '0';
if (val > 9)
break;
@@ -229,7 +229,7 @@
ret = ret * 10 + val;
}
- data->uint = ret;
+ smp->data.uint = ret;
return 1;
}
@@ -239,7 +239,7 @@
/* NULL pointer used for impossible pattern casts */
/*****************************************************************/
-typedef int (*pattern_cast_fct)(union pattern_data *data);
+typedef int (*pattern_cast_fct)(struct sample *smp);
static pattern_cast_fct pattern_casts[SMP_TYPES][SMP_TYPES] = {
/* to: BOOL UINT SINT IPV4 IPV6 STR BIN CSTR CBIN */
/* from: BOOL */ { c_none, c_none, c_none, NULL, NULL, NULL, NULL, NULL, NULL },
@@ -475,17 +475,18 @@
if (p == NULL)
p = &temp_smp;
- if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, &p->data))
+ p->flags = 0;
+ if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, p))
return NULL;
p->type = expr->fetch->out_type;
list_for_each_entry(conv_expr, &expr->conv_exprs, list) {
- if (!pattern_casts[p->type][conv_expr->conv->in_type](&p->data))
+ if (!pattern_casts[p->type][conv_expr->conv->in_type](p))
return NULL;
p->type = conv_expr->conv->in_type;
- if (!conv_expr->conv->process(conv_expr->arg_p, &p->data))
+ if (!conv_expr->conv->process(conv_expr->arg_p, p))
return NULL;
p->type = conv_expr->conv->out_type;
@@ -497,38 +498,38 @@
/* Pattern format convert functions */
/*****************************************************************/
-static int pattern_conv_str2lower(const struct arg *arg_p, union pattern_data *data)
+static int pattern_conv_str2lower(const struct arg *arg_p, struct sample *smp)
{
int i;
- if (!data->str.size)
+ if (!smp->data.str.size)
return 0;
- for (i = 0; i < data->str.len; i++) {
- if ((data->str.str[i] >= 'A') && (data->str.str[i] <= 'Z'))
- data->str.str[i] += 'a' - 'A';
+ for (i = 0; i < smp->data.str.len; i++) {
+ if ((smp->data.str.str[i] >= 'A') && (smp->data.str.str[i] <= 'Z'))
+ smp->data.str.str[i] += 'a' - 'A';
}
return 1;
}
-static int pattern_conv_str2upper(const struct arg *arg_p, union pattern_data *data)
+static int pattern_conv_str2upper(const struct arg *arg_p, struct sample *smp)
{
int i;
- if (!data->str.size)
+ if (!smp->data.str.size)
return 0;
- for (i = 0; i < data->str.len; i++) {
- if ((data->str.str[i] >= 'a') && (data->str.str[i] <= 'z'))
- data->str.str[i] += 'A' - 'a';
+ for (i = 0; i < smp->data.str.len; i++) {
+ if ((smp->data.str.str[i] >= 'a') && (smp->data.str.str[i] <= 'z'))
+ smp->data.str.str[i] += 'A' - 'a';
}
return 1;
}
/* takes the netmask in arg_p */
-static int pattern_conv_ipmask(const struct arg *arg_p, union pattern_data *data)
+static int pattern_conv_ipmask(const struct arg *arg_p, struct sample *smp)
{
- data->ipv4.s_addr &= arg_p->data.ipv4.s_addr;
+ smp->data.ipv4.s_addr &= arg_p->data.ipv4.s_addr;
return 1;
}
diff --git a/src/proto_http.c b/src/proto_http.c
index f3db682..4d504b0 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -8348,12 +8348,12 @@
/* Returns the last occurrence of specified header. */
static int
pattern_fetch_hdr(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
struct http_txn *txn = l7;
return http_get_hdr(&txn->req, arg_p->data.str.str, arg_p->data.str.len, &txn->hdr_idx,
- -1, NULL, &data->str.str, &data->str.len);
+ -1, NULL, &smp->data.str.str, &smp->data.str.len);
}
/*
@@ -8443,7 +8443,7 @@
static int
pattern_fetch_url_param(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
struct http_txn *txn = l7;
struct http_msg *msg = &txn->req;
@@ -8455,8 +8455,8 @@
&url_param_value, &url_param_value_l))
return 0;
- data->str.str = url_param_value;
- data->str.len = url_param_value_l;
+ smp->data.str.str = url_param_value;
+ smp->data.str.len = url_param_value_l;
return 1;
}
@@ -8496,7 +8496,7 @@
static int
pattern_fetch_cookie(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
struct http_txn *txn = l7;
struct http_msg *msg = &txn->req;
@@ -8508,8 +8508,8 @@
arg_p->data.str.str, arg_p->data.str.len, 1,
&cookie_value, &cookie_value_l);
if (found) {
- data->str.str = cookie_value;
- data->str.len = cookie_value_l;
+ smp->data.str.str = cookie_value;
+ smp->data.str.len = cookie_value_l;
}
return found;
@@ -8518,7 +8518,7 @@
static int
pattern_fetch_set_cookie(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
struct http_txn *txn = l7;
struct http_msg *msg = &txn->rsp;
@@ -8530,8 +8530,8 @@
arg_p->data.str.str, arg_p->data.str.len, 1,
&cookie_value, &cookie_value_l);
if (found) {
- data->str.str = cookie_value;
- data->str.len = cookie_value_l;
+ smp->data.str.str = cookie_value;
+ smp->data.str.len = cookie_value_l;
}
return found;
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index dc32a9f..6b2101a 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1276,24 +1276,24 @@
/* extract the connection's source ipv4 address */
static int
pattern_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
if (l4->si[0].addr.from.ss_family != AF_INET )
return 0;
- data->ipv4.s_addr = ((struct sockaddr_in *)&l4->si[0].addr.from)->sin_addr.s_addr;
+ smp->data.ipv4.s_addr = ((struct sockaddr_in *)&l4->si[0].addr.from)->sin_addr.s_addr;
return 1;
}
/* extract the connection's source ipv6 address */
static int
pattern_fetch_src6(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
if (l4->si[0].addr.from.ss_family != AF_INET6)
return 0;
- memcpy(data->ipv6.s6_addr, ((struct sockaddr_in6 *)&l4->si[0].addr.from)->sin6_addr.s6_addr, sizeof(data->ipv6.s6_addr));
+ memcpy(smp->data.ipv6.s6_addr, ((struct sockaddr_in6 *)&l4->si[0].addr.from)->sin6_addr.s6_addr, sizeof(smp->data.ipv6.s6_addr));
return 1;
}
@@ -1339,28 +1339,28 @@
/* extract the connection's destination ipv4 address */
static int
pattern_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
stream_sock_get_to_addr(&l4->si[0]);
if (l4->si[0].addr.to.ss_family != AF_INET)
return 0;
- data->ipv4.s_addr = ((struct sockaddr_in *)&l4->si[0].addr.to)->sin_addr.s_addr;
+ smp->data.ipv4.s_addr = ((struct sockaddr_in *)&l4->si[0].addr.to)->sin_addr.s_addr;
return 1;
}
/* extract the connection's destination ipv6 address */
static int
pattern_fetch_dst6(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
stream_sock_get_to_addr(&l4->si[0]);
if (l4->si[0].addr.to.ss_family != AF_INET6)
return 0;
- memcpy(data->ipv6.s6_addr, ((struct sockaddr_in6 *)&l4->si[0].addr.to)->sin6_addr.s6_addr, sizeof(data->ipv6.s6_addr));
+ memcpy(smp->data.ipv6.s6_addr, ((struct sockaddr_in6 *)&l4->si[0].addr.to)->sin6_addr.s6_addr, sizeof(smp->data.ipv6.s6_addr));
return 1;
}
@@ -1381,11 +1381,11 @@
static int
pattern_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg, union pattern_data *data)
+ const struct arg *arg, struct sample *smp)
{
stream_sock_get_to_addr(&l4->si[0]);
- if (!(data->uint = get_host_port(&l4->si[0].addr.to)))
+ if (!(smp->data.uint = get_host_port(&l4->si[0].addr.to)))
return 0;
return 1;
@@ -1393,7 +1393,7 @@
static int
pattern_fetch_payloadlv(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
int len_offset = arg_p[0].data.uint;
int len_size = arg_p[1].data.uint;
@@ -1435,14 +1435,14 @@
return 0;
/* init chunk as read only */
- chunk_initlen(&data->str, b->p + buf_offset, 0, buf_size);
+ chunk_initlen(&smp->data.str, b->p + buf_offset, 0, buf_size);
return 1;
}
static int
pattern_fetch_payload(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
int buf_offset = arg_p[0].data.uint;
int buf_size = arg_p[1].data.uint;
@@ -1460,25 +1460,24 @@
return 0;
/* init chunk as read only */
- chunk_initlen(&data->str, b->p + buf_offset, 0, buf_size);
+ chunk_initlen(&smp->data.str, b->p + buf_offset, 0, buf_size);
return 1;
}
static int
pattern_fetch_rdp_cookie(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, union pattern_data *data)
+ const struct arg *arg_p, struct sample *smp)
{
int ret;
struct acl_expr expr;
- struct sample smp;
struct arg args[2];
if (!l4)
return 0;
memset(&expr, 0, sizeof(expr));
- memset(&smp, 0, sizeof(smp));
+ memset(smp, 0, sizeof(*smp));
args[0].type = ARGT_STR;
args[0].data.str.str = arg_p[0].data.str.str;
@@ -1487,11 +1486,9 @@
expr.args = args;
- ret = acl_fetch_rdp_cookie(px, l4, NULL, ACL_DIR_REQ, &expr, &smp);
- if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.str.len == 0)
+ ret = acl_fetch_rdp_cookie(px, l4, NULL, ACL_DIR_REQ, &expr, smp);
+ if (ret == 0 || (smp->flags & SMP_F_MAY_CHANGE) || smp->data.str.len == 0)
return 0;
-
- data->str = smp.data.str;
return 1;
}
diff --git a/src/stick_table.c b/src/stick_table.c
index 6574f0e..08a84f2 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -448,76 +448,76 @@
/* typed pattern to typed table key functions */
/*****************************************************************/
-static void *k_int2int(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_int2int(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- return (void *)&pdata->uint;
+ return (void *)&smp->data.uint;
}
-static void *k_ip2ip(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ip2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- return (void *)&pdata->ipv4.s_addr;
+ return (void *)&smp->data.ipv4.s_addr;
}
-static void *k_ip2ipv6(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ip2ipv6(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- v4tov6(&kdata->ipv6, &pdata->ipv4);
+ v4tov6(&kdata->ipv6, &smp->data.ipv4);
return (void *)&kdata->ipv6.s6_addr;
}
-static void *k_ipv62ipv6(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ipv62ipv6(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- return (void *)&pdata->ipv6.s6_addr;
+ return (void *)&smp->data.ipv6.s6_addr;
}
/*
-static void *k_ipv62ip(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ipv62ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- v6tov4(&kdata->ip, &pdata->ipv6);
+ v6tov4(&kdata->ip, &smp->data.ipv6);
return (void *)&kdata->ip.s_addr;
}
*/
-static void *k_ip2int(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ip2int(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- kdata->integer = ntohl(pdata->ipv4.s_addr);
+ kdata->integer = ntohl(smp->data.ipv4.s_addr);
return (void *)&kdata->integer;
}
-static void *k_int2ip(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_int2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- kdata->ip.s_addr = htonl(pdata->uint);
+ kdata->ip.s_addr = htonl(smp->data.uint);
return (void *)&kdata->ip.s_addr;
}
-static void *k_str2str(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_str2str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- *len = pdata->str.len;
- return (void *)pdata->str.str;
+ *len = smp->data.str.len;
+ return (void *)smp->data.str.str;
}
-static void *k_ip2str(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ip2str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- if (!inet_ntop(AF_INET, &pdata->ipv4, kdata->buf, sizeof(kdata->buf)))
+ if (!inet_ntop(AF_INET, &smp->data.ipv4, kdata->buf, sizeof(kdata->buf)))
return NULL;
*len = strlen((const char *)kdata->buf);
return (void *)kdata->buf;
}
-static void *k_ipv62str(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_ipv62str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- if (!inet_ntop(AF_INET6, &pdata->ipv6, kdata->buf, sizeof(kdata->buf)))
+ if (!inet_ntop(AF_INET6, &smp->data.ipv6, kdata->buf, sizeof(kdata->buf)))
return NULL;
*len = strlen((const char *)kdata->buf);
return (void *)kdata->buf;
}
-static void *k_int2str(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_int2str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
void *key;
- key = (void *)ultoa_r(pdata->uint, kdata->buf, sizeof(kdata->buf));
+ key = (void *)ultoa_r(smp->data.uint, kdata->buf, sizeof(kdata->buf));
if (!key)
return NULL;
@@ -525,29 +525,29 @@
return key;
}
-static void *k_str2ip(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_str2ip(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- if (!buf2ip(pdata->str.str, pdata->str.len, &kdata->ip))
+ if (!buf2ip(smp->data.str.str, smp->data.str.len, &kdata->ip))
return NULL;
return (void *)&kdata->ip.s_addr;
}
-static void *k_str2ipv6(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_str2ipv6(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
- if (!inet_pton(AF_INET6, pdata->str.str, &kdata->ipv6))
+ if (!inet_pton(AF_INET6, smp->data.str.str, &kdata->ipv6))
return NULL;
return (void *)&kdata->ipv6.s6_addr;
}
-static void *k_str2int(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len)
+static void *k_str2int(struct sample *smp, union stktable_key_data *kdata, size_t *len)
{
int i;
kdata->integer = 0;
- for (i = 0; i < pdata->str.len; i++) {
- uint32_t val = pdata->str.str[i] - '0';
+ for (i = 0; i < smp->data.str.len; i++) {
+ uint32_t val = smp->data.str.str[i] - '0';
if (val > 9)
break;
@@ -569,7 +569,7 @@
* relevant and could cause confusion in configuration.
*/
-typedef void *(*pattern_to_key_fct)(union pattern_data *pdata, union stktable_key_data *kdata, size_t *len);
+typedef void *(*pattern_to_key_fct)(struct sample *smp, union stktable_key_data *kdata, size_t *len);
static pattern_to_key_fct pattern_to_key[SMP_TYPES][STKTABLE_TYPES] = {
/* table type: IP IPV6 INTEGER STRING BINARY */
/* patt. type: BOOL */ { NULL, NULL, k_int2int, k_int2str, NULL },
@@ -593,14 +593,14 @@
struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct session *l4, void *l7, int dir,
struct pattern_expr *expr)
{
- struct sample *ptrn;
+ struct sample *smp;
- ptrn = pattern_process(px, l4, l7, dir, expr, NULL);
- if (!ptrn)
+ smp = pattern_process(px, l4, l7, dir, expr, NULL);
+ if (!smp)
return NULL;
static_table_key.key_len = t->key_size;
- static_table_key.key = pattern_to_key[ptrn->type][t->type](&ptrn->data, &static_table_key.data, &static_table_key.key_len);
+ static_table_key.key = pattern_to_key[smp->type][t->type](smp, &static_table_key.data, &static_table_key.key_len);
if (!static_table_key.key)
return NULL;