MEDIUM: acl/pattern: use the same direction scheme
Patterns were using a bitmask to indicate if request or response was desired
in fetch functions and keywords. ACLs were using a bitmask in fetch keywords
and a single bit in fetch functions. ACLs were also using an ACL_PARTIAL bit
in fetch functions indicating that a non-final fetch was performed, which was
an abuse of the existing direction flag.
The change now consists in using :
- a capabilities field for fetch keywords => SMP_CAP_REQ/RES to indicate
if a keyword supports requests, responses, both, etc...
- an option field for fetch functions to indicate what the caller expects
(request/response, final/non-final)
The ACL_PARTIAL bit was reversed to get SMP_OPT_FINAL as it's more explicit
to know we're working on a final buffer than on a non-final one.
ACL_DIR_* were removed, as well as PATTERN_FETCH_*. L4 fetches were improved
to support being called on responses too since they're still available.
The <dir> field of all fetch functions was changed to <opt> which is now
unsigned.
The patch is large but mostly made of cosmetic changes to accomodate this, as
almost no logic change happened.
diff --git a/include/types/acl.h b/include/types/acl.h
index 564c4bb..cff3ae2 100644
--- a/include/types/acl.h
+++ b/include/types/acl.h
@@ -71,14 +71,6 @@
ACL_COND_UNLESS, /* negative condition (after 'unless') */
};
-/* ACLs can be evaluated on requests and on responses, and on partial or complete data */
-enum {
- ACL_DIR_REQ = 0, /* ACL evaluated on request */
- ACL_DIR_RTR = (1 << 0), /* ACL evaluated on response */
- ACL_DIR_MASK = (ACL_DIR_REQ | ACL_DIR_RTR),
- ACL_PARTIAL = (1 << 1), /* partial data, return MISS if data are missing */
-};
-
/* possible flags for expressions or patterns */
enum {
ACL_PAT_F_IGNORE_CASE = 1 << 0, /* ignore case */
@@ -238,7 +230,7 @@
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,
+ int (*fetch)(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp);
int (*match)(struct sample *smp, struct acl_pattern *pattern);
unsigned int requires; /* bit mask of all ACL_USE_* required to evaluate this keyword */