* [PATCH] dns: handle incoming packets in the separate dns_recv() function
@ 2015-06-30 21:32 Antony Pavlov
2015-07-01 5:34 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Antony Pavlov @ 2015-06-30 21:32 UTC (permalink / raw)
To: barebox
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>
---
net/dns.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/dns.c b/net/dns.c
index 0a8ce8b..0e16ea2 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;
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] dns: handle incoming packets in the separate dns_recv() function
2015-06-30 21:32 [PATCH] dns: handle incoming packets in the separate dns_recv() function Antony Pavlov
@ 2015-07-01 5:34 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-07-01 5:34 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Wed, Jul 01, 2015 at 12:32:54AM +0300, Antony Pavlov wrote:
> 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>
> ---
> net/dns.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-01 5:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-30 21:32 [PATCH] dns: handle incoming packets in the separate dns_recv() function Antony Pavlov
2015-07-01 5:34 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox