From: Petr Špaček Date: Fri, 21 Jun 2019 11:30:16 +0000 (+0200) Subject: daemon/lua: add ability to read DO bit from packet X-Git-Tag: v4.1.0~7^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84f02a5706500fab1d975da7fa5bb4d181a8d6b2;p=thirdparty%2Fknot-resolver.git daemon/lua: add ability to read DO bit from packet --- diff --git a/daemon/lua/kres-gen.lua b/daemon/lua/kres-gen.lua index 1d867682e..aecd4cff5 100644 --- a/daemon/lua/kres-gen.lua +++ b/daemon/lua/kres-gen.lua @@ -341,6 +341,7 @@ void kr_pkt_make_auth_header(knot_pkt_t *); int kr_pkt_put(knot_pkt_t *, const knot_dname_t *, uint32_t, uint16_t, uint16_t, const uint8_t *, uint16_t); int kr_pkt_recycle(knot_pkt_t *); int kr_pkt_clear_payload(knot_pkt_t *); +uint16_t kr_pkt_has_dnssec(const knot_pkt_t *); uint16_t kr_pkt_qclass(const knot_pkt_t *); uint16_t kr_pkt_qtype(const knot_pkt_t *); char *kr_pkt_text(const knot_pkt_t *); diff --git a/daemon/lua/kres-gen.sh b/daemon/lua/kres-gen.sh index 92be8d733..f0738e43d 100755 --- a/daemon/lua/kres-gen.sh +++ b/daemon/lua/kres-gen.sh @@ -187,6 +187,7 @@ ${CDEFS} ${LIBKRES} functions <<-EOF kr_pkt_put kr_pkt_recycle kr_pkt_clear_payload + kr_pkt_has_dnssec kr_pkt_qclass kr_pkt_qtype kr_pkt_text diff --git a/daemon/lua/kres.lua b/daemon/lua/kres.lua index 22fd8fa2a..2fc21503f 100644 --- a/daemon/lua/kres.lua +++ b/daemon/lua/kres.lua @@ -548,6 +548,12 @@ ffi.metatype( knot_pkt_t, { cd = function (pkt, val) return pkt_bit(pkt, 3, 0x10, val) end, ad = function (pkt, val) return pkt_bit(pkt, 3, 0x20, val) end, ra = function (pkt, val) return pkt_bit(pkt, 3, 0x80, val) end, + -- "do" is a reserved word in Lua; only getter + dobit = function(pkt, val) + assert(val == nil, 'dobit is getter only') + assert(ffi.istype(knot_pkt_t, pkt)) + return C.kr_pkt_has_dnssec(pkt) + end, -- Question qname = function(pkt) assert(ffi.istype(knot_pkt_t, pkt)) diff --git a/lib/utils.c b/lib/utils.c index 0200b144c..0725083ff 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1081,6 +1081,10 @@ void kr_rrset_init(knot_rrset_t *rrset, knot_dname_t *owner, assert(rrset); knot_rrset_init(rrset, owner, type, rclass, ttl); } +uint16_t kr_pkt_has_dnssec(const knot_pkt_t *pkt) +{ + return knot_pkt_has_dnssec(pkt); +} uint16_t kr_pkt_qclass(const knot_pkt_t *pkt) { return knot_pkt_qclass(pkt); diff --git a/lib/utils.h b/lib/utils.h index 7b8079c75..40ebfade3 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -528,6 +528,7 @@ const char *kr_strptime_diff(const char *format, const char *time1_str, /* Trivial non-inline wrappers, to be used in lua. */ KR_EXPORT void kr_rrset_init(knot_rrset_t *rrset, knot_dname_t *owner, uint16_t type, uint16_t rclass, uint32_t ttl); +KR_EXPORT uint16_t kr_pkt_has_dnssec(const knot_pkt_t *pkt); KR_EXPORT uint16_t kr_pkt_qclass(const knot_pkt_t *pkt); KR_EXPORT uint16_t kr_pkt_qtype(const knot_pkt_t *pkt); KR_EXPORT uint32_t kr_rrsig_sig_inception(const knot_rdata_t *rdata);