]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/utils: removed obsoleted functions
authorMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 27 Apr 2018 06:20:14 +0000 (23:20 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 7 Sep 2018 17:45:21 +0000 (10:45 -0700)
Header flags can now be set from Lua, as well as packet payload clearing.

daemon/lua/kres-gen.sh
lib/utils.c
lib/utils.h
modules/policy/policy.lua
modules/renumber/renumber.lua

index a7161904610b2b5ecda81d3659cc1df37538c28d..108d65a3e9f95051614adc6f5c44f0393f986e4e 100755 (executable)
@@ -153,7 +153,6 @@ EOF
 # Utils
        kr_rand_uint
        kr_make_query
-       kr_pkt_make_auth_header
        kr_pkt_put
        kr_pkt_recycle
        kr_pkt_clear_payload
index dac35b548febd67dfecc8be3eac87ef58ed8238f..fbd28faeec53c11c451182f974e3f4bcd42aee2c 100644 (file)
@@ -319,13 +319,6 @@ int kr_pkt_put(knot_pkt_t *pkt, const knot_dname_t *name, uint32_t ttl,
        return knot_pkt_put(pkt, 0, &rr, KNOT_PF_FREE);
 }
 
-void kr_pkt_make_auth_header(knot_pkt_t *pkt)
-{
-       assert(pkt && pkt->wire);
-       knot_wire_clear_ad(pkt->wire);
-       knot_wire_set_aa(pkt->wire);
-}
-
 const char *kr_inaddr(const struct sockaddr *addr)
 {
        if (!addr) {
index d5806c284793f1faae0f0236454fa3523f2ccc8c..ef2465c575f97df6253f296d2bb9664057df7304 100644 (file)
@@ -216,10 +216,6 @@ KR_EXPORT
 int kr_pkt_put(knot_pkt_t *pkt, const knot_dname_t *name, uint32_t ttl,
                uint16_t rclass, uint16_t rtype, const uint8_t *rdata, uint16_t rdlen);
 
-/** Set packet header suitable for authoritative answer. (for policy module) */
-KR_EXPORT
-void kr_pkt_make_auth_header(knot_pkt_t *pkt);
-
 /** Simple storage for IPx address or AF_UNSPEC. */
 union inaddr {
        struct sockaddr ip;
index 638d00bfe35174ed16e5ce96bae46c54aefa15cd..3ef919a5d2a3d714d0ea6db047712318a8250a87 100644 (file)
@@ -293,10 +293,10 @@ end
 local dname_localhost = todname('localhost.')
 
 -- Rule for localhost. zone; see RFC6303, sec. 3
-local function localhost(_, req)
-       local qry = req:current()
+local function localhost(_, req, qry)
        local answer = req.answer
-       ffi.C.kr_pkt_make_auth_header(answer)
+       answer:ad(false)
+       answer:aa(true)
 
        local is_exact = ffi.C.knot_dname_is_equal(qry.sname, dname_localhost)
 
@@ -353,7 +353,8 @@ local function localhost_reversed(_, req)
                end
        end
 
-       ffi.C.kr_pkt_make_auth_header(answer)
+       answer:ad(false)
+       answer:aa(true)
        answer:rcode(kres.rcode.NOERROR)
        answer:begin(kres.section.ANSWER)
        if is_exact and qry.stype == kres.type.PTR then
@@ -471,7 +472,8 @@ function policy.DENY_MSG(msg)
        return function (_, req)
                -- Write authority information
                local answer = req.answer
-               ffi.C.kr_pkt_make_auth_header(answer)
+               answer:ad(false)
+               answer:aa(true)
                answer:rcode(kres.rcode.NXDOMAIN)
                answer:begin(kres.section.AUTHORITY)
                mkauth_soa(answer, answer:qname())
index ca77b9475b1ab3eb92fa449794794e44d2788f38..6eeca4b3ea0f3eae082df74dc3e48bc59f65d936 100644 (file)
@@ -85,13 +85,8 @@ local function rule()
                -- If not rewritten, chain action
                if not changed then return end
                -- Replace section if renumbering
-               local qname = pkt:qname()
-               local qclass = pkt:qclass()
-               local qtype = pkt:qtype()
-               pkt:recycle()
-               pkt:question(qname, qclass, qtype)
-               for i = 1, ancount do
-                       local rr = records[i]
+               pkt:clear_payload()
+               for _, rr in ipairs(records) do
                        -- Strip signatures as rewritten data cannot be validated
                        if rr.type ~= kres.type.RRSIG then
                                pkt:put(rr.owner, rr.ttl, rr.class, rr.type, rr.rdata)