From: John Crispin Date: Thu, 4 Sep 2014 15:42:21 +0000 (+0200) Subject: propagate sockaddr and port form the receive function to the parser X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fmdnsd.git;a=commitdiff_plain;h=e340a84950686428ecc7f46dbe28eba5c39a9095 propagate sockaddr and port form the receive function to the parser Signed-off-by: John Crispin --- diff --git a/dns.c b/dns.c index d8c1529..df855eb 100644 --- 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 92f4c08..f5bfef2 100644 --- a/dns.h +++ b/dns.h @@ -15,6 +15,7 @@ #define _DNS_H__ #include +#include #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 diff --git a/interface.c b/interface.c index a4daa24..d26ed08 100644 --- a/interface.c +++ b/interface.c @@ -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