return 0;
}
-void cache_cleanup(void)
+void cache_cleanup(struct interface *iface)
{
struct cache_record *r, *p;
struct cache_service *s, *t;
- avl_for_each_element_safe(&records, r, avl, p)
- cache_record_free(r);
-
avl_for_each_element_safe(&services, s, avl, t)
- cache_service_free(s);
+ if (!iface || iface == s->iface)
+ cache_service_free(s);
+
+ avl_for_each_element_safe(&records, r, avl, p)
+ if (!iface || iface == r->iface)
+ cache_record_free(r);
}
void
s->avl.key = s->entry = strcpy(entry_buf, entry);
s->time = time(NULL);
s->ttl = ttl;
+ s->iface = iface;
if (hlen)
s->host = strncpy(host_buf, s->entry, hlen);
r->port = port;
r->rdlength = dlen;
r->time = time(NULL);
+ r->iface = iface;
if (tlen)
r->txt = memcpy(txt_ptr, rdata_buffer, tlen);
#include <libubox/blob.h>
#include "dns.h"
+#include "interface.h"
struct cache_service {
struct avl_node avl;
const char *host;
uint32_t ttl;
time_t time;
+ struct interface *iface;
};
struct cache_record {
const uint8_t *rdata;
uint16_t rdlength;
time_t time;
+ struct interface *iface;
};
extern struct avl_tree services;
int cache_init(void);
void cache_scan(void);
-void cache_cleanup(void);
+void cache_cleanup(struct interface *iface);
void cache_answer(struct interface *iface, uint8_t *base, int blen,
char *name, struct dns_answer *a, uint8_t *rdata, int flush);
int cache_host_is_known(char *record);