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 @@ ...@@ -50,6 +50,7 @@
/***********************************************************************/ /***********************************************************************/
struct VCL_conf; struct VCL_conf;
struct vrt_acl;
struct busyobj; struct busyobj;
struct director; struct director;
struct http; struct http;
...@@ -67,6 +68,7 @@ struct ws; ...@@ -67,6 +68,7 @@ struct ws;
* (alphabetic order) * (alphabetic order)
*/ */
typedef const struct vrt_acl * VCL_ACL;
typedef const struct director * VCL_BACKEND; typedef const struct director * VCL_BACKEND;
typedef const struct vmod_priv * VCL_BLOB; typedef const struct vmod_priv * VCL_BLOB;
typedef unsigned VCL_BOOL; typedef unsigned VCL_BOOL;
...@@ -237,6 +239,14 @@ struct vrt_ref { ...@@ -237,6 +239,14 @@ struct vrt_ref {
/* ACL related */ /* ACL related */
#define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */ #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); void VRT_acl_log(VRT_CTX, const char *msg);
/* req related */ /* req related */
......
...@@ -351,7 +351,7 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) ...@@ -351,7 +351,7 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon)
struct token *t; struct token *t;
struct inifin *ifp; struct inifin *ifp;
Fh(tl, 0, "\nstatic int\n"); Fh(tl, 0, "\nstatic int __match_proto__(acl_f)\n");
Fh(tl, 0, Fh(tl, 0,
"match_acl_%s_%s(VRT_CTX, const VCL_IP p)\n", "match_acl_%s_%s(VRT_CTX, const VCL_IP p)\n",
anon ? "anon" : "named", acln); anon ? "anon" : "named", acln);
...@@ -443,6 +443,15 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) ...@@ -443,6 +443,15 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon)
if (!anon) if (!anon)
Fh(tl, 0, "\tVRT_acl_log(ctx, \"NO_MATCH %s\");\n", acln); Fh(tl, 0, "\tVRT_acl_log(ctx, \"NO_MATCH %s\");\n", acln);
Fh(tl, 0, "\treturn (0);\n}\n"); 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 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