If CNAME chain occurs CNAME is placed before AAAA.
int has_tls;
knot_mm_t pool;
};
+enum kr_rank {KR_RANK_INITIAL, KR_RANK_OMIT, KR_RANK_INDET, KR_RANK_BOGUS, KR_RANK_MISMATCH, KR_RANK_MISSING, KR_RANK_INSECURE = 8, KR_RANK_AUTH = 16, KR_RANK_SECURE = 32};
struct knot_rrset {
knot_dname_t *_owner;
uint16_t type;
struct timeval timestamp;
struct kr_zonecut zone_cut;
struct kr_nsrep ns;
+ struct kr_layer_pickle *deferred;
+ uint32_t uid;
/* ^hidden stub^ */
char _stub[];
};
int kr_bitcmp(const char *, const char *, int);
int kr_family_len(int);
struct sockaddr *kr_straddr_socket(const char *, int);
-int kr_rrarray_add(rr_array_t *, const knot_rrset_t *, knot_mm_t *);
+int kr_ranked_rrarray_add(ranked_rr_array_t *, const knot_rrset_t *, uint8_t, _Bool, uint32_t, knot_mm_t *);
knot_rrset_t *kr_ta_get(map_t *, const knot_dname_t *);
int kr_ta_add(map_t *, const knot_dname_t *, uint16_t, uint32_t, const uint8_t *, uint16_t);
int kr_ta_del(map_t *, const knot_dname_t *);
kr_qarray_t
struct kr_rplan
struct kr_request
+ enum kr_rank
EOF
genResType() {
genResType "struct kr_nsrep" | sed '/union/,$ d'
printf "\t/* beware: hidden stub */\n};\n"
-genResType "struct kr_query" | sed '/struct kr_layer_pickle/,$ d'
+genResType "struct kr_query" | sed '/uint32_t forward_flags/,$ d'
printf "\t/* ^hidden stub^ */\n\tchar _stub[];\n};\n"
genResType "struct kr_context" | sed '/struct kr_cache/,$ d'
kr_bitcmp
kr_family_len
kr_straddr_socket
- kr_rrarray_add
+ kr_ranked_rrarray_add
# Trust anchors
kr_ta_get
kr_ta_add
int kr_rrarray_add(rr_array_t *array, const knot_rrset_t *rr, knot_mm_t *pool);
/** @internal Add RRSet copy to ranked RR array. */
+KR_EXPORT
int kr_ranked_rrarray_add(ranked_rr_array_t *array, const knot_rrset_t *rr,
uint8_t rank, bool to_wire, uint32_t qry_uid, knot_mm_t *pool);
-- Synthetic AAAA from marked A responses
local answer = pkt:section(kres.section.ANSWER)
if bit.band(qry.flags, MARK_DNS64) ~= 0 then -- Marked request
- for i = 1, #answer do
- local rr = answer[i]
- -- Synthesise AAAA from A
- if rr.type == kres.type.A then
- ffi.copy(addr_buf, mod.proxy, 16)
- ffi.copy(addr_buf + 12, rr.rdata, 4)
- req.answer:put(rr.owner, rr.ttl, rr.class, kres.type.AAAA, ffi.string(addr_buf, 16))
+ local section = ffi.C.knot_pkt_section(pkt, kres.section.ANSWER)
+ for i = 1, section.count do
+ local orig = ffi.C.knot_pkt_rr(section, i - 1)
+ if orig.type == kres.type.A then
+ local rrs = ffi.typeof('knot_rrset_t')()
+ ffi.C.knot_rrset_init_empty(rrs)
+ rrs._owner = ffi.cast('char *', orig:owner()) -- explicit cast needed here
+ rrs.type = kres.type.AAAA
+ rrs.rclass = orig.rclass
+ for k = 1, orig.rrs.rr_count do
+ local rdata = orig:rdata( k - 1 )
+ ffi.copy(addr_buf, mod.proxy, 16)
+ ffi.copy(addr_buf + 12, rdata, 4)
+ ffi.C.knot_rrset_add_rdata(rrs, ffi.string(addr_buf, 16), 16, orig:ttl(), req.pool)
+ end
+ ffi.C.kr_ranked_rrarray_add(
+ req.answ_selected,
+ rrs,
+ ffi.C.KR_RANK_OMIT,
+ true,
+ qry.uid,
+ req.pool)
end
end
else -- Observe AAAA NODATA responses