From: Marek VavruĊĦa Date: Mon, 10 Aug 2015 12:56:16 +0000 (+0200) Subject: daemon/lua: packet gets :tc([val]) for TC bit X-Git-Tag: v1.0.0-beta1~59^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba2fa2bf87a64818e15a1068a2d78bdd5d94536a;p=thirdparty%2Fknot-resolver.git daemon/lua: packet gets :tc([val]) for TC bit --- diff --git a/daemon/lua/kres.lua b/daemon/lua/kres.lua index 60591819e..23e4bddf3 100644 --- a/daemon/lua/kres.lua +++ b/daemon/lua/kres.lua @@ -155,6 +155,8 @@ int kr_pkt_put(knot_pkt_t *pkt, const knot_dname_t *name, uint32_t ttl, ]] -- Metatype for packet +local bor = bit.bor +local band = bit.band local knot_pkt_t = ffi.typeof('knot_pkt_t') ffi.metatype( knot_pkt_t, { __index = { @@ -162,10 +164,12 @@ ffi.metatype( knot_pkt_t, { qclass = function(pkt) return knot.knot_pkt_qclass(pkt) end, qtype = function(pkt) return knot.knot_pkt_qtype(pkt) end, rcode = function (pkt, val) - if val then - pkt.wire[3] = bit.bor(bit.band(pkt.wire[3], 0xf0), val) - end - return bit.band(pkt.wire[3], 0x0f) + pkt.wire[3] = (val) and bor(band(pkt.wire[3], 0xf0), val) or pkt.wire[3] + return band(pkt.wire[3], 0x0f) + end, + tc = function (pkt, val) + pkt.wire[2] = bor(pkt.wire[2], (val) and 0x02 or 0x00) + return band(pkt.wire[2], 0x02) end, begin = function (pkt, section) return knot.knot_pkt_begin(pkt, section) end, put = function (pkt, owner, ttl, rclass, rtype, rdata)