-> action-rule string; see kr_view_insert_action()
*/
-#define KEY_RULESET_MAXLEN 16 /**< max. len of ruleset ID + 1(for kind) */
-static /*const*/ char RULESET_DEFAULT[] = "d";
+/*const*/ char RULESET_DEFAULT[] = "d";
static const uint8_t KEY_EXACT_MATCH[1] = "e";
static const uint8_t KEY_ZONELIKE_A [1] = "a";
static const uint8_t KEY_VIEW_SRC4[1] = "4";
static const uint8_t KEY_VIEW_SRC6[1] = "6";
-/** The first byte of zone-like apex value is its type. */
-typedef uint8_t val_zla_type_t;
-enum {
- /** Empty zone. No data in DB value after this byte. */
- VAL_ZLAT_EMPTY = 1,
- /** Forced NXDOMAIN. */
- VAL_ZLAT_NXDOMAIN,
- /** Forced NODATA. Does not apply on exact name (e.g. it's similar to DNAME) */
- VAL_ZLAT_NODATA,
- /** Redirect: anything beneath has the same data as apex (except NS+SOA). */
- VAL_ZLAT_REDIRECT,
-};
-
static int answer_exact_match(struct kr_query *qry, knot_pkt_t *pkt, uint16_t type,
const uint8_t *data, const uint8_t *data_bound);
-/** When constructing a key, it's convenient that the dname_lf ends on a fixed offset.
- * Convention: the end here is before the final '\0' byte (if any). */
-#define KEY_DNAME_END_OFFSET (KEY_RULESET_MAXLEN + KNOT_DNAME_MAXLEN)
-#define KEY_MAXLEN (KEY_DNAME_END_OFFSET + 64) //TODO: most of 64 is unused ATM
-
/** Add name lookup format on the fixed end-position inside key_data.
*
* Note: key_data[KEY_DNAME_END_OFFSET] = '\0' even though
}
-static knot_db_val_t local_data_key(const knot_rrset_t *rrs, uint8_t key_data[KEY_MAXLEN],
+knot_db_val_t local_data_key(const knot_rrset_t *rrs, uint8_t key_data[KEY_MAXLEN],
const char *ruleset_name)
{
knot_db_val_t key;
// Construct the DB key.
uint8_t key_data[KEY_MAXLEN];
knot_db_val_t key = local_data_key(rrs, key_data, RULESET_DEFAULT);
-
+ return local_data_ins(key, rrs, sig_rds, tags);
+}
+int local_data_ins(knot_db_val_t key, const knot_rrset_t *rrs,
+ const knot_rdataset_t *sig_rds, kr_rule_tags_t tags)
+{
// Allocate the data in DB.
const int rr_ssize = rdataset_dematerialize_size(&rrs->rrs);
const int to_alloc = sizeof(tags) + sizeof(rrs->ttl) + rr_ssize
*/
#pragma once
-#define RULE_TTL_DEFAULT ((uint16_t)10800)
+#include "lib/rules/api.h"
+
+#define RULE_TTL_DEFAULT ((uint32_t)10800)
/** Insert all the default rules. in ./defaults.c */
int rules_defaults_insert(void);
+/** Singleton struct used by the code in ./. */
+struct kr_rules;
+extern struct kr_rules *the_rules;
+
+#define KEY_RULESET_MAXLEN 16 /**< max. len of ruleset ID + 1(for kind) */
+/** When constructing a key, it's convenient that the dname_lf ends on a fixed offset.
+ * Convention: the end here is before the final '\0' byte (if any). */
+#define KEY_DNAME_END_OFFSET (KEY_RULESET_MAXLEN + KNOT_DNAME_MAXLEN)
+#define KEY_MAXLEN (KEY_DNAME_END_OFFSET + 64) //TODO: most of 64 is unused ATM
+
+/** Construct key for local_data_ins(). It's stored in `key_data`. */
+knot_db_val_t local_data_key(const knot_rrset_t *rrs, uint8_t key_data[KEY_MAXLEN],
+ const char *ruleset_name);
+/** Same as kr_rule_local_data_ins() but with precomputed `key`. */
+int local_data_ins(knot_db_val_t key, const knot_rrset_t *rrs,
+ const knot_rdataset_t *sig_rds, kr_rule_tags_t tags);
+
+
+/** The first byte of zone-like apex value is its type. */
+typedef uint8_t val_zla_type_t;
+enum {
+ /** Empty zone. No data in DB value after this byte.
+ *
+ * TODO: add
+ * - TTL (most likely, optional, 4B)
+ * - SOA rdata (maybe, optional, remainder of DB value)
+ * Same for _NXDOMAIN and _NODATA, too.
+ */
+ VAL_ZLAT_EMPTY = 1,
+ /** Forced NXDOMAIN. */
+ VAL_ZLAT_NXDOMAIN,
+ /** Forced NODATA. Does not apply on exact name (e.g. it's similar to DNAME) */
+ VAL_ZLAT_NODATA,
+ /** Redirect: anything beneath has the same data as apex (except NS+SOA). */
+ VAL_ZLAT_REDIRECT,
+};
+
+extern /*const*/ char RULESET_DEFAULT[];
+
+