int h2:5, m2:6; /* 0..24:0..60. Use 24:0 for all day. */
};
-/* The acl will be linked to from the proxy where it is declared */
+/* This describes one ACL pattern, which might be a single value or a tree of
+ * values. All patterns for a single ACL expression are linked together. Some
+ * of them might have a type (eg: IP). Right now, the types are shared with
+ * the samples, though it is possible that in the future this will change to
+ * accommodate for other types (eg: meth, regex). Unsigned and constant types
+ * are preferred when there is a doubt.
+ */
struct acl_pattern {
struct list list; /* chaining */
+ int type; /* type of the ACL pattern (SMP_T_*) */
union {
int i; /* integer value */
struct {
int flags; /* expr or pattern flags. */
};
-/*
- * ACL keyword: Associates keywords with parsers, methods to retrieve the value and testers.
- */
-
/* some dummy declarations to silent the compiler */
struct proxy;
struct session;
+/*
+ * ACL keyword: Associates keywords with parsers, methods to retrieve the value and testers.
+ */
/*
* NOTE:
* The 'parse' function is called to parse words in the configuration. It must
struct eb_root pattern_tree; /* may be used for lookup in large datasets */
};
+/* The acl will be linked to from the proxy where it is declared */
struct acl {
struct list list; /* chaining */
char *name; /* acl name */
{
struct in_addr *s;
- if (smp->type != SMP_T_IPV4)
+ if (smp->type != SMP_T_IPV4 || pattern->type != SMP_T_IPV4)
return ACL_PAT_FAIL;
s = &smp->data.ipv4;
int len;
len = strlen(*text);
+ pattern->type = SMP_T_CSTR;
if (pattern->flags & ACL_PAT_F_TREE_OK) {
/* we're allowed to put the data in a tree whose root is pointed
for (i = 0; *text[i]; i++)
len += strlen(text[i])+1;
+ pattern->type = SMP_T_CSTR;
pattern->ptr.str = s = calloc(1, len);
if (!pattern->ptr.str) {
if (err)
unsigned int j, last, skip = 0;
const char *ptr = *text;
-
+ pattern->type = SMP_T_UINT;
while (!isdigit((unsigned char)*ptr)) {
switch (get_std_op(ptr)) {
case STD_OP_EQ: *opaque = 0; break;
/* Parse an IP address and an optional mask in the form addr[/mask].
* The addr may either be an IPv4 address or a hostname. The mask
* may either be a dotted mask or a number of bits. Returns 1 if OK,
- * otherwise 0.
+ * otherwise 0. NOTE: IP address patterns are typed (IPV4/IPV6).
*/
int acl_parse_ip(const char **text, struct acl_pattern *pattern, int *opaque, char **err)
{
if (pattern->flags & ACL_PAT_F_TREE_OK)
tree = pattern->val.tree;
+ pattern->type = SMP_T_IPV4;
if (str2net(*text, &pattern->val.ipv4.addr, &pattern->val.ipv4.mask)) {
unsigned int mask = ntohl(pattern->val.ipv4.mask.s_addr);
struct ebmb_node *node;
pattern->val.tree = &expr->pattern_tree;
}
+ pattern->type = SMP_TYPES; /* unspecified type by default */
if (!aclkw->parse(args, pattern, &opaque, err))
goto out_free_pattern;
}
pattern->flags = patflags;
+ pattern->type = SMP_TYPES; /* unspecified type */
ret = aclkw->parse(args, pattern, &opaque, err);
if (!ret)
goto out_free_pattern;