propagate sockaddr and port form the receive function to the parser
authorJohn Crispin <blogic@openwrt.org>
Thu, 4 Sep 2014 15:42:21 +0000 (17:42 +0200)
committerJohn Crispin <blogic@openwrt.org>
Thu, 4 Sep 2014 15:42:21 +0000 (17:42 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
dns.c
dns.h
interface.c

diff --git a/dns.c b/dns.c
index d8c152948b86cf3e42479385f709e9ca9035ad51..df855ebdeb189f86393de41eb0efef65da12765f 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -347,7 +347,7 @@ parse_question(struct interface *iface, char *name, struct dns_question *q)
 }
 
 void
-dns_handle_packet(struct interface *iface, uint8_t *buffer, int len, int unicast)
+dns_handle_packet(struct interface *iface, struct sockaddr *s, uint16_t port, uint8_t *buffer, int len)
 {
        struct dns_header *h;
        uint8_t *b = buffer;
diff --git a/dns.h b/dns.h
index 92f4c08a05815a82f2552cc4bc77b49f86c9b8dd..f5bfef26c8aa073dbabe7b61f88ebeec912f387c 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -15,6 +15,7 @@
 #define _DNS_H__
 
 #include <stdint.h>
+#include <arpa/inet.h>
 
 #define FLAG_RESPONSE          0x8000
 #define FLAG_AUTHORATIVE       0x0400
@@ -75,6 +76,6 @@ void dns_init_answer(void);
 void dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
 void dns_send_answer(struct interface *iface, const char *answer);
 const char* dns_type_string(uint16_t type);
-void dns_handle_packet(struct interface *iface, uint8_t *buf, int len, int unicast);
+void dns_handle_packet(struct interface *iface, struct sockaddr *s, uint16_t port, uint8_t *buf, int len);
 
 #endif
index a4daa244add550d386fa9a745974d47aa106db6d..d26ed08ba9f54b5cea39b52134e4c448dc91e855 100644 (file)
@@ -213,7 +213,7 @@ read_socket4(struct uloop_fd *u, unsigned int events)
        if (inp->ipi_ifindex != iface->ifindex)
                fprintf(stderr, "invalid iface index %d != %d\n", ifindex, iface->ifindex);
        else
-               dns_handle_packet(iface, buffer, len, 0);
+               dns_handle_packet(iface, (struct sockaddr *) &from, from.sin_port, buffer, len);
 }
 
 static void
@@ -288,7 +288,7 @@ read_socket6(struct uloop_fd *u, unsigned int events)
        if (inp->ipi6_ifindex != iface->ifindex)
                fprintf(stderr, "invalid iface index %d != %d\n", ifindex, iface->ifindex);
        else
-               dns_handle_packet(iface, buffer, len, 0);
+               dns_handle_packet(iface, (struct sockaddr *) &from, from.sin6_port, buffer, len);
 }
 
 static int