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 d8c1529..df855eb 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -347,7 +347,7 @@ parse_question(struct interface *iface, char *name, struct dns_question *q)
 }
 
 void
 }
 
 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;
 {
        struct dns_header *h;
        uint8_t *b = buffer;
diff --git a/dns.h b/dns.h
index 92f4c08..f5bfef2 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -15,6 +15,7 @@
 #define _DNS_H__
 
 #include <stdint.h>
 #define _DNS_H__
 
 #include <stdint.h>
+#include <arpa/inet.h>
 
 #define FLAG_RESPONSE          0x8000
 #define FLAG_AUTHORATIVE       0x0400
 
 #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_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
 
 #endif
index a4daa24..d26ed08 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
        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
 }
 
 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
        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
 }
 
 static int