[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-devel] [PATCHv5 03/13] net/lwip: implement dns cmd
From: |
Simon Glass |
Subject: |
Re: [lwip-devel] [PATCHv5 03/13] net/lwip: implement dns cmd |
Date: |
Wed, 2 Aug 2023 15:31:31 -0600 |
Hi Maxim,
On Wed, 2 Aug 2023 at 08:09, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
> lib/lwip/Makefile | 2 ++
> lib/lwip/apps/dns/lwip-dns.c | 46 ++++++++++++++++++++++++++++++++++++
> lib/lwip/apps/dns/lwip-dns.h | 3 +++
> 3 files changed, 51 insertions(+)
> create mode 100644 lib/lwip/apps/dns/lwip-dns.c
> create mode 100644 lib/lwip/apps/dns/lwip-dns.h
>
> diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile
> index 35f34d7afa..2815662093 100644
> --- a/lib/lwip/Makefile
> +++ b/lib/lwip/Makefile
> @@ -64,3 +64,5 @@ obj-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o
>
> obj-$(CONFIG_NET) += port/if.o
> obj-$(CONFIG_NET) += port/sys-arch.o
> +
> +obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o
> diff --git a/lib/lwip/apps/dns/lwip-dns.c b/lib/lwip/apps/dns/lwip-dns.c
> new file mode 100644
> index 0000000000..04fd53bfcb
> --- /dev/null
> +++ b/lib/lwip/apps/dns/lwip-dns.c
> @@ -0,0 +1,46 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * (C) Copyright 2023 Linaro Ltd. <maxim.uvarov@linaro.org>
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <console.h>
> +
> +#include <lwip/dns.h>
> +#include <lwip/ip_addr.h>
> +
> +#include "../../../lwip/ulwip.h"
Can those headers go in include/ so we don't have this problem?
> +
> +static void dns_found_cb(const char *name, const ip_addr_t *ipaddr, void
> *callback_arg)
> +{
> + char *varname = (char *)callback_arg;
> +
> + if (varname)
> + env_set(varname, ip4addr_ntoa(ipaddr));
> +
> + printf("resolved %s to %s\n", name, ip4addr_ntoa(ipaddr));
> + ulwip_exit(0);
> +}
> +
> +int ulwip_dns(char *name, char *varname)
> +{
> + int err;
> + ip_addr_t ipaddr; /* not used */
> + ip_addr_t dns1;
> + ip_addr_t dns2;
> +
> + ipaddr_aton(env_get("dnsip"), &dns1);
> + ipaddr_aton(env_get("dnsip2"), &dns2);
> +
> + dns_init();
> + dns_setserver(0, &dns1);
> + dns_setserver(1, &dns2);
> +
> + err = dns_gethostbyname(name, &ipaddr, dns_found_cb, varname);
> + if (err == ERR_OK)
> + dns_found_cb(name, &ipaddr, varname);
> +
> + return err;
> +}
> diff --git a/lib/lwip/apps/dns/lwip-dns.h b/lib/lwip/apps/dns/lwip-dns.h
> new file mode 100644
> index 0000000000..c59f99e099
> --- /dev/null
> +++ b/lib/lwip/apps/dns/lwip-dns.h
> @@ -0,0 +1,3 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +
> +int ulwip_dns(char *name, char *varname);
Please comment all exported functions.
> --
> 2.30.2
>
Regards,
Simon
- [lwip-devel] [PATCHv5 00/13] net/lwip: add lwip library for the network stack, Maxim Uvarov, 2023/08/02
- [lwip-devel] [PATCHv5 01/13] net/lwip: add doc/develop/net_lwip.rst, Maxim Uvarov, 2023/08/02
- [lwip-devel] [PATCHv5 02/13] net/lwip: integrate lwip library, Maxim Uvarov, 2023/08/02
- [lwip-devel] [PATCHv5 03/13] net/lwip: implement dns cmd, Maxim Uvarov, 2023/08/02
- Re: [lwip-devel] [PATCHv5 03/13] net/lwip: implement dns cmd,
Simon Glass <=
- [lwip-devel] [PATCHv5 04/13] net/lwip: implement dhcp cmd, Maxim Uvarov, 2023/08/02
- [lwip-devel] [PATCHv5 05/13] net/lwip: implement tftp cmd, Maxim Uvarov, 2023/08/02
- [lwip-devel] [PATCHv5 06/13] net/lwip: implement wget cmd, Maxim Uvarov, 2023/08/02