summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2015-07-01 00:32:54 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2015-07-01 07:34:26 +0200
commit8bbc1064c78cdf658c837b996170b8eab8cbcb3d (patch)
tree954480a863641b745fb528928dd6ab1187a798aa /net
parent69957c548101c2c2a2e9cc5e588c610fb08d71a1 (diff)
downloadbarebox-8bbc1064c78cdf658c837b996170b8eab8cbcb3d.tar.gz
barebox-8bbc1064c78cdf658c837b996170b8eab8cbcb3d.tar.xz
dns: handle incoming packets in the separate dns_recv() function
The separation of incoming packets handling makes it much easier to run barebox dns client on top of picotcp network stack in the future. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r--net/dns.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/dns.c b/net/dns.c
index 0a8ce8b244..0e16ea2c9d 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -116,9 +116,8 @@ static int dns_send(char *name)
return ret;
}
-static void dns_handler(void *ctx, char *packet, unsigned len)
+static void dns_recv(struct header *header, unsigned len)
{
- struct header *header;
unsigned char *p, *e, *s;
u16 type;
int found, stop, dlen;
@@ -127,7 +126,6 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
debug("%s\n", __func__);
/* We sent 1 query. We want to see more that 1 answer. */
- header = (struct header *)net_eth_to_udp_payload(packet);
if (ntohs(header->nqueries) != 1)
return;
@@ -140,7 +138,7 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
/* Skip host name */
s = &header->data[0];
- e = packet + len;
+ e = ((uint8_t *)header) + len;
for (p = s; p < e && *p != '\0'; p++)
continue;
@@ -194,6 +192,13 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
}
}
+static void dns_handler(void *ctx, char *packet, unsigned len)
+{
+ (void)ctx;
+ dns_recv((struct header *)net_eth_to_udp_payload(packet),
+ net_eth_to_udplen(packet));
+}
+
IPaddr_t resolv(char *host)
{
IPaddr_t ip;