+static void post_response(flxServer *s, flxRecord *r, gint iface, const flxAddress *a) {
+}
+
+static void handle_query_key(flxServer *s, flxKey *k, gint iface, const flxAddress *a) {
+ flxEntry *e;
+
+ g_assert(s);
+ g_assert(k);
+ g_assert(a);
+
+ for (e = g_hash_table_lookup(s->rrset_by_name, k); e; e = e->next_by_name) {
+
+ if ((e->interface <= 0 || e->interface == iface) &&
+ (e->protocol == AF_UNSPEC || e->protocol == a->family))
+ post_response(s, e->record, iface, a);
+ }
+}
+
+static void handle_query(flxServer *s, flxDnsPacket *p, gint iface, const flxAddress *a) {
+ guint n;
+
+ g_assert(s);
+ g_assert(p);
+ g_assert(a);
+
+ for (n = flx_dns_packet_get_field(p, DNS_FIELD_QDCOUNT); n > 0; n --) {
+
+ flxKey *key;
+
+ if (!(key = flx_dns_packet_consume_query(p))) {
+ g_warning("Packet too short");
+ return;
+ }
+
+ handle_query_key(s, key, iface, a);
+ flx_key_unref(key);
+ }
+}
+
+static void add_response_to_cache(flxCache *c, flxDnsPacket *p, const flxAddress *a) {
+ guint n;
+
+ g_assert(c);
+ g_assert(p);
+ g_assert(a);
+ for (n = flx_dns_packet_get_field(p, DNS_FIELD_ANCOUNT); n > 0; n--) {
+
+ flxRecord *rr;
+ gboolean cache_flush = FALSE;
+
+ if (!(rr = flx_dns_packet_consume_rr(p, &cache_flush))) {
+ g_warning("Packet too short");
+ return;
+ }
+
+ flx_cache_update(c, rr, cache_flush, a);
+ flx_record_unref(rr);
+ }
+}
+