]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] acl: provide a reference to the expr to fetch()
authorWilly Tarreau <w@1wt.eu>
Sun, 10 Jun 2007 09:47:14 +0000 (11:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 10 Jun 2007 09:47:14 +0000 (11:47 +0200)
The fetch() functions may need to access the full expr to get
their args. Turn the void *arg into a struct acl_expr *expr.

include/types/acl.h
src/acl.c
src/client.c
src/proto_http.c

index 0eecd335f0efb24bfbe4cfccd13313ea0e4df80a..fe0ce5f64b8cf5304ddf1a178709a2126d1fba06 100644 (file)
@@ -130,10 +130,12 @@ struct session;
  * 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;
 };
index 2cd154ca0d84afb2c04d02af018b55ed4029f020..0cc924833032a9ee0495da82e1de82636e4930e3 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -659,7 +659,7 @@ int acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, v
                                /* 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 */
index 39d53221f1ad009543ec2b75ebc3cad4d040e492..3995b53d671ef46e38c2d0c5b5082adb80fe37ab 100644 (file)
@@ -454,7 +454,8 @@ int event_accept(int fd) {
 
 /* 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 @@ acl_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir, void *arg
 
 /* 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 @@ acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir, void *a
 
 /* 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 @@ acl_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir, void *arg
 
 /* 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 @@ acl_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir, void *a
 
 /* 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;
index 5f991e57a099a8aa188f249ca699e422d3206fe8..ea199d9b9a47d4ae5d08ba24e6f4c41df15a9f71 100644 (file)
@@ -5165,7 +5165,8 @@ static int acl_parse_meth(const char **text, struct acl_pattern *pattern, int *o
 }
 
 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_parse_ver(const char **text, struct acl_pattern *pattern, int *op
 }
 
 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 @@ acl_fetch_rqver(struct proxy *px, struct session *l4, void *l7, int dir, void *a
 }
 
 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 @@ acl_fetch_stver(struct proxy *px, struct session *l4, void *l7, int dir, void *a
 
 /* 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 @@ acl_fetch_stcode(struct proxy *px, struct session *l4, void *l7, int dir, void *
 
 /* 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;