void
cache_scan(void)
{
+ struct interface *iface;
struct cache_entry *s;
- avl_for_each_element(&entries, s, avl)
- dns_send_question(cur_iface, s->entry, TYPE_PTR);
+ vlist_for_each_element(&interfaces, iface, node)
+ avl_for_each_element(&entries, s, avl)
+ dns_send_question(iface, s->entry, TYPE_PTR);
}
static struct cache_entry*
-cache_entry(struct uloop_fd *u, char *entry, int hlen, int ttl)
+cache_entry(struct interface *iface, char *entry, int hlen, int ttl)
{
struct cache_entry *s;
char *entry_buf;
avl_insert(&entries, &s->avl);
if (!hlen)
- dns_send_question(cur_iface, entry, TYPE_PTR);
+ dns_send_question(iface, entry, TYPE_PTR);
return s;
}
}
void
-cache_answer(struct uloop_fd *u, uint8_t *base, int blen, char *name, struct dns_answer *a, uint8_t *rdata)
+cache_answer(struct interface *iface, uint8_t *base, int blen, char *name, struct dns_answer *a, uint8_t *rdata)
{
struct dns_srv_data *dsd = (struct dns_srv_data *) rdata;
struct cache_record *r;
void *rdata_ptr, *txt_ptr;
int host_len = 0;
+ static char rdata_buffer[MAX_DATA_LEN + 1];
+
if (!(a->class & CLASS_IN))
return;
nlen + 1 < rdlength && !strcmp(rdata_buffer + rdlength - nlen, name))
host_len = rdlength - nlen - 1;
- cache_entry(u, rdata_buffer, host_len, a->ttl);
+ cache_entry(iface, rdata_buffer, host_len, a->ttl);
return;
case TYPE_SRV:
break;
case TYPE_A:
- cache_entry(u, name, strlen(name), a->ttl);
+ cache_entry(iface, name, strlen(name), a->ttl);
if (a->rdlength != 4)
return;
dlen = 4;
break;
case TYPE_AAAA:
- cache_entry(u, name, strlen(name), a->ttl);
+ cache_entry(iface, name, strlen(name), a->ttl);
if (a->rdlength != 16)
return;
dlen = 16;