Commit c4c50274 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune Committed by Lasse Karstensen

Introduce a new ACL type for VMODs

parent b16b6733
......@@ -50,6 +50,7 @@
/***********************************************************************/
struct VCL_conf;
struct vrt_acl;
struct busyobj;
struct director;
struct http;
......@@ -67,6 +68,7 @@ struct ws;
* (alphabetic order)
*/
typedef const struct vrt_acl * VCL_ACL;
typedef const struct director * VCL_BACKEND;
typedef const struct vmod_priv * VCL_BLOB;
typedef unsigned VCL_BOOL;
......@@ -237,6 +239,14 @@ struct vrt_ref {
/* ACL related */
#define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */
typedef int acl_f (VRT_CTX, VCL_IP);
struct vrt_acl {
unsigned magic;
#define VRT_ACL_MAGIC 0x78329d96
acl_f *match;
};
void VRT_acl_log(VRT_CTX, const char *msg);
/* req related */
......
......@@ -351,7 +351,7 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon)
struct token *t;
struct inifin *ifp;
Fh(tl, 0, "\nstatic int\n");
Fh(tl, 0, "\nstatic int __match_proto__(acl_f)\n");
Fh(tl, 0,
"match_acl_%s_%s(VRT_CTX, const VCL_IP p)\n",
anon ? "anon" : "named", acln);
......@@ -443,6 +443,15 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon)
if (!anon)
Fh(tl, 0, "\tVRT_acl_log(ctx, \"NO_MATCH %s\");\n", acln);
Fh(tl, 0, "\treturn (0);\n}\n");
if (anon)
return;
/* Emit the struct that will be referenced */
Fh(tl, 0, "\nconst struct vrt_acl vrt_acl_named_%s = {\n", acln);
Fh(tl, 0, "\t.magic = VRT_ACL_MAGIC,\n");
Fh(tl, 0, "\t.match = &match_acl_named_%s,\n", acln);
Fh(tl, 0, "};\n\n");
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment