[MINOR] acl: provide a reference to the expr to fetch()
The fetch() functions may need to access the full expr to get
their args. Turn the void *arg into a struct acl_expr *expr.
diff --git a/include/types/acl.h b/include/types/acl.h
index 0eecd33..fe0ce5f 100644
--- a/include/types/acl.h
+++ b/include/types/acl.h
@@ -130,10 +130,12 @@
* successive calls.
*/
+struct acl_expr;
struct acl_keyword {
const char *kw;
int (*parse)(const char **text, struct acl_pattern *pattern, int *opaque);
- int (*fetch)(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test);
+ int (*fetch)(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test);
int (*match)(struct acl_test *test, struct acl_pattern *pattern);
int use_cnt;
};
diff --git a/src/acl.c b/src/acl.c
index 2cd154c..0cc9248 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -659,7 +659,7 @@
/* we need to reset context and flags */
memset(&test, 0, sizeof(test));
fetch_next:
- if (!expr->kw->fetch(px, l4, l7, dir, expr->arg.str, &test))
+ if (!expr->kw->fetch(px, l4, l7, dir, expr, &test))
continue;
/* apply all tests to this value */
diff --git a/src/client.c b/src/client.c
index 39d5322..3995b53 100644
--- a/src/client.c
+++ b/src/client.c
@@ -454,7 +454,8 @@
/* set test->ptr to point to the source IPv4/IPv6 address and test->i to the family */
static int
-acl_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
test->i = l4->cli_addr.ss_family;
if (test->i == AF_INET)
@@ -468,7 +469,8 @@
/* set test->i to the connexion's source port */
static int
-acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
if (l4->cli_addr.ss_family == AF_INET)
test->i = ntohs(((struct sockaddr_in *)&l4->cli_addr)->sin_port);
@@ -481,7 +483,8 @@
/* set test->ptr to point to the frontend's IPv4/IPv6 address and test->i to the family */
static int
-acl_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
if (!(l4->flags & SN_FRT_ADDR_SET))
get_frt_addr(l4);
@@ -498,7 +501,8 @@
/* set test->i to the frontend connexion's destination port */
static int
-acl_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
if (!(l4->flags & SN_FRT_ADDR_SET))
get_frt_addr(l4);
@@ -513,7 +517,8 @@
/* set test->i to the number of connexions to the proxy */
static int
-acl_fetch_dconn(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_dconn(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
test->i = px->feconn;
return 1;
diff --git a/src/proto_http.c b/src/proto_http.c
index 5f991e5..ea199d9 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -5165,7 +5165,8 @@
}
static int
-acl_fetch_meth(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_meth(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
int meth;
struct http_txn *txn = l7;
@@ -5209,7 +5210,8 @@
}
static int
-acl_fetch_rqver(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_rqver(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
struct http_txn *txn = l7;
char *ptr;
@@ -5230,7 +5232,8 @@
}
static int
-acl_fetch_stver(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_stver(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
struct http_txn *txn = l7;
char *ptr;
@@ -5252,7 +5255,8 @@
/* 3. Check on Status Code. We manipulate integers here. */
static int
-acl_fetch_stcode(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_stcode(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
struct http_txn *txn = l7;
char *ptr;
@@ -5268,7 +5272,8 @@
/* 4. Check on URL/URI. A pointer to the URI is stored. */
static int
-acl_fetch_url(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
+acl_fetch_url(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
{
struct http_txn *txn = l7;