summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2022-07-03 15:15:40 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2023-06-12 10:32:28 +0200
commit15013db53a59f9c19d887d9efadd429ee222a0b8 (patch)
tree5db964c1bd0a1ece40086f024552615dbfe9e1b6 /daemon
parentlib/cache: add a "<" search in addition to "<=" (diff)
downloadknot-resolver-15013db53a59f9c19d887d9efadd429ee222a0b8.tar.xz
knot-resolver-15013db53a59f9c19d887d9efadd429ee222a0b8.zip
lib/rules: add basic view capability
Example: assert(require('ffi').C.kr_view_insert_action( '127.0.0.0/24', 'policy.DENY_MSG("message")' ) == 0)
Diffstat (limited to 'daemon')
-rw-r--r--daemon/lua/kres-gen-30.lua6
-rw-r--r--daemon/lua/kres-gen-31.lua6
-rw-r--r--daemon/lua/kres-gen-32.lua6
-rwxr-xr-xdaemon/lua/kres-gen.sh6
4 files changed, 23 insertions, 1 deletions
diff --git a/daemon/lua/kres-gen-30.lua b/daemon/lua/kres-gen-30.lua
index 96874891..1e4a2880 100644
--- a/daemon/lua/kres-gen-30.lua
+++ b/daemon/lua/kres-gen-30.lua
@@ -30,6 +30,10 @@ typedef struct {
uint32_t size;
knot_rdata_t *rdata;
} knot_rdataset_t;
+typedef struct knot_db_val {
+ void *data;
+ size_t len;
+} knot_db_val_t;
typedef struct knot_mm {
void *ctx, *alloc, *free;
@@ -461,6 +465,8 @@ int kr_cache_remove(struct kr_cache *, const knot_dname_t *, uint16_t);
int kr_cache_remove_subtree(struct kr_cache *, const knot_dname_t *, _Bool, int);
int kr_cache_commit(struct kr_cache *);
uint32_t packet_ttl(const knot_pkt_t *);
+int kr_view_insert_action(const char *, const char *);
+int kr_view_select_action(const struct kr_request *, knot_db_val_t *);
typedef struct {
int sock_type;
_Bool tls;
diff --git a/daemon/lua/kres-gen-31.lua b/daemon/lua/kres-gen-31.lua
index c07888e9..810560dd 100644
--- a/daemon/lua/kres-gen-31.lua
+++ b/daemon/lua/kres-gen-31.lua
@@ -30,6 +30,10 @@ typedef struct {
uint32_t size;
knot_rdata_t *rdata;
} knot_rdataset_t;
+typedef struct knot_db_val {
+ void *data;
+ size_t len;
+} knot_db_val_t;
typedef struct knot_mm {
void *ctx, *alloc, *free;
@@ -461,6 +465,8 @@ int kr_cache_remove(struct kr_cache *, const knot_dname_t *, uint16_t);
int kr_cache_remove_subtree(struct kr_cache *, const knot_dname_t *, _Bool, int);
int kr_cache_commit(struct kr_cache *);
uint32_t packet_ttl(const knot_pkt_t *);
+int kr_view_insert_action(const char *, const char *);
+int kr_view_select_action(const struct kr_request *, knot_db_val_t *);
typedef struct {
int sock_type;
_Bool tls;
diff --git a/daemon/lua/kres-gen-32.lua b/daemon/lua/kres-gen-32.lua
index d63fe666..84156d05 100644
--- a/daemon/lua/kres-gen-32.lua
+++ b/daemon/lua/kres-gen-32.lua
@@ -30,6 +30,10 @@ typedef struct {
uint32_t size;
knot_rdata_t *rdata;
} knot_rdataset_t;
+typedef struct knot_db_val {
+ void *data;
+ size_t len;
+} knot_db_val_t;
typedef struct knot_mm {
void *ctx, *alloc, *free;
@@ -472,6 +476,8 @@ int kr_cache_remove(struct kr_cache *, const knot_dname_t *, uint16_t);
int kr_cache_remove_subtree(struct kr_cache *, const knot_dname_t *, _Bool, int);
int kr_cache_commit(struct kr_cache *);
uint32_t packet_ttl(const knot_pkt_t *);
+int kr_view_insert_action(const char *, const char *);
+int kr_view_select_action(const struct kr_request *, knot_db_val_t *);
typedef struct {
int sock_type;
_Bool tls;
diff --git a/daemon/lua/kres-gen.sh b/daemon/lua/kres-gen.sh
index 3d6fcfaf..b56a8a38 100755
--- a/daemon/lua/kres-gen.sh
+++ b/daemon/lua/kres-gen.sh
@@ -69,12 +69,13 @@ struct kr_cdb_api {};
struct lru {};
"
-${CDEFS} ${LIBKRES} types <<-EOF
+${CDEFS} libknot types <<-EOF
knot_section_t
knot_rrinfo_t
knot_dname_t
knot_rdata_t
knot_rdataset_t
+ knot_db_val_t
EOF
# The generator doesn't work well with typedefs of functions.
@@ -283,6 +284,9 @@ ${CDEFS} ${LIBKRES} functions <<-EOF
kr_cache_commit
# FIXME: perhaps rename this exported symbol
packet_ttl
+# New policy
+ kr_view_insert_action
+ kr_view_select_action
EOF