return (char *)&key_buf[ret] - key;
}
-int kr_rrmap_add(map_t *stash, const knot_rrset_t *rr, uint8_t rank, knot_mm_t *pool)
-{
- if (!stash || !rr) {
- return kr_error(EINVAL);
- }
-
- /* Stash key = {[1] flags, [1-255] owner, [5] type, [1] \x00 } */
- char key[KR_RRKEY_LEN];
- uint8_t extra_flags = 0;
- uint16_t rrtype = kr_rrset_type_maysig(rr);
- /* Stash RRSIGs in a special cache, flag them and set type to its covering RR.
- * This way it the stash won't merge RRSIGs together. */
- if (rr->type == KNOT_RRTYPE_RRSIG) {
- extra_flags |= KEY_FLAG_RRSIG;
- }
- int ret = kr_rrkey(key, rr->owner, rrtype, rank);
- if (ret <= 0) {
- return kr_error(EILSEQ);
- }
- key[0] |= extra_flags;
-
- /* Check if already exists */
- knot_rrset_t *stashed = map_get(stash, key);
- if (!stashed) {
- stashed = knot_rrset_copy(rr, pool);
- if (!stashed) {
- return kr_error(ENOMEM);
- }
- return map_set(stash, key, stashed);
- }
- /* Merge rdataset */
- return knot_rdataset_merge(&stashed->rrs, &rr->rrs, pool);
-}
-
/** Return whether two RRsets match, i.e. would form the same set; see ranked_rr_array_t */
static inline bool rrsets_match(const knot_rrset_t *rr1, const knot_rrset_t *rr2)
{
KR_EXPORT
int kr_rrkey(char *key, const knot_dname_t *owner, uint16_t type, uint8_t rank);
-/** @internal Merges RRSets with matching owner name and type together.
- * @note RRSIG RRSets are merged according the type covered fields.
- * @return 0 or an error
- */
-int kr_rrmap_add(map_t *stash, const knot_rrset_t *rr, uint8_t rank, 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,