basic support for the cache flush bit
authorJohn Crispin <blogic@openwrt.org>
Thu, 4 Sep 2014 18:26:43 +0000 (20:26 +0200)
committerJohn Crispin <blogic@openwrt.org>
Thu, 4 Sep 2014 18:28:46 +0000 (20:28 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
cache.c
cache.h
dns.c
dns.h

diff --git a/cache.c b/cache.c
index 6240e2f2c8ee80a9fe7751853cd3ef61c6022d11..af6cbbafb341435d53d98134800d53690aeb7716 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -216,7 +216,7 @@ cache_host_is_known(char *record)
 }
 
 void
-cache_answer(struct interface *iface, 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, int flush)
 {
        struct dns_srv_data *dsd = (struct dns_srv_data *) rdata;
        struct cache_record *r;
@@ -227,9 +227,6 @@ cache_answer(struct interface *iface, uint8_t *base, int blen, char *name, struc
        int host_len = 0;
        static char *rdata_buffer = (char *) mdns_buf;
 
-       if (!(a->class & CLASS_IN))
-               return;
-
        nlen = strlen(name);
 
        switch (a->type) {
diff --git a/cache.h b/cache.h
index b4433eb9424a81fb3693528aac641845041a429b..df3593f3df55fd9363f6b85b564d3723cbbbe788 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -48,7 +48,7 @@ int cache_init(void);
 void cache_scan(void);
 void cache_cleanup(void);
 void cache_answer(struct interface *iface, uint8_t *base, int blen,
-                 char *name, struct dns_answer *a, uint8_t *rdata);
+                 char *name, struct dns_answer *a, uint8_t *rdata, int flush);
 int cache_host_is_known(char *record);
 char *cache_lookup_name(const char *key);
 void cache_dump_records(struct blob_buf *buf, const char *name);
diff --git a/dns.c b/dns.c
index 3f6ecbe3988614105d402564acce04fe5acb08ee..c5323e5e93c449af5ff38913dc8ec5c6a6a18687 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -299,6 +299,9 @@ parse_answer(struct interface *iface, uint8_t *buffer, int len, uint8_t **b, int
                return -1;
        }
 
+       if ((a->class & ~CLASS_FLUSH) != CLASS_IN)
+               return -1;
+
        rdata = *b;
        if (a->rdlength > *rlen) {
                fprintf(stderr, "dropping: bad question\n");
@@ -309,7 +312,7 @@ parse_answer(struct interface *iface, uint8_t *buffer, int len, uint8_t **b, int
        *b += a->rdlength;
 
        if (cache)
-               cache_answer(iface, buffer, len, name, a, rdata);
+               cache_answer(iface, buffer, len, name, a, rdata, a->class & CLASS_FLUSH);
 
        return 0;
 }
diff --git a/dns.h b/dns.h
index 47727ddb667e8142e1fac6507c0ab49144e6c449..791159f7b7a5b571006809a27aeb64807b5f0257 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -33,6 +33,7 @@
 #define MCAST_ADDR6            "ff02::fb"
 #define MCAST_PORT             5353
 
+#define CLASS_FLUSH            0x8000
 #define CLASS_UNICAST          0x8000
 #define CLASS_IN               0x0001