From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Maxim Uvarov <maxim.uvarov@linaro.org>
Cc: u-boot@lists.denx.de, pbrobinson@redhat.com,
joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com,
goldsimon@gmx.de, lwip-devel@nongnu.org
Subject: Re: [PATCHv5 04/13] net/lwip: implement dhcp cmd
Date: Thu, 3 Aug 2023 09:26:02 +0300 [thread overview]
Message-ID: <ZMtIejM1KnXjsLsq@hades> (raw)
In-Reply-To: <20230802140658.10319-5-maxim.uvarov@linaro.org>
Hi Maxim,
The split looks a lot easier to review!
On Wed, Aug 02, 2023 at 08:06:49PM +0600, Maxim Uvarov wrote:
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
> lib/lwip/Makefile | 1 +
> lib/lwip/apps/dhcp/lwip-dhcp.c | 53 ++++++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
> create mode 100644 lib/lwip/apps/dhcp/lwip-dhcp.c
>
> diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile
> index 2815662093..a3521a9d18 100644
> --- a/lib/lwip/Makefile
> +++ b/lib/lwip/Makefile
> @@ -65,4 +65,5 @@ obj-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o
> obj-$(CONFIG_NET) += port/if.o
> obj-$(CONFIG_NET) += port/sys-arch.o
>
> +obj-$(CONFIG_CMD_DHCP) += apps/dhcp/lwip-dhcp.o
> obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o
> diff --git a/lib/lwip/apps/dhcp/lwip-dhcp.c b/lib/lwip/apps/dhcp/lwip-dhcp.c
> new file mode 100644
> index 0000000000..9fda43db9f
> --- /dev/null
> +++ b/lib/lwip/apps/dhcp/lwip-dhcp.c
> @@ -0,0 +1,53 @@
> +// 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/dhcp.h>
> +#include <lwip/prot/dhcp.h>
> +
> +#include "../../../lwip/ulwip.h"
I think we had similar comments on the previous version, you need to get
rid of this '../../../'
> +
> +static struct dhcp dhcp;
> +static bool dhcp_is_set;
> +
> +static int ulwip_dhcp_tmo(void)
> +{
> + switch (dhcp.state) {
> + case DHCP_STATE_BOUND:
> + env_set("bootfile", dhcp.boot_file_name);
> + env_set("ipaddr", ip4addr_ntoa(&dhcp.offered_ip_addr));
> + env_set("netmask", ip4addr_ntoa(&dhcp.offered_sn_mask));
> + env_set("serverip", ip4addr_ntoa(&dhcp.server_ip_addr));
> + printf("DHCP client bound to address %s\n", ip4addr_ntoa(&dhcp.offered_ip_addr));
> + break;
> + default:
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +int ulwip_dhcp(void)
> +{
> + int err;
> + struct netif *netif;
> +
> + ulwip_set_tmo(ulwip_dhcp_tmo);
> + netif = netif_get_by_index(1);
> +
> + if (!dhcp_is_set) {
Why do we need dhcp_is_set? Can't we check using netif_get_client_data()?
> + dhcp_set_struct(netif, &dhcp);
> + dhcp_is_set = true;
> + }
> + err = dhcp_start(netif);
> + if (err)
> + printf("dhcp_start error %d\n", err);
> +
> + return err;
> +}
> --
> 2.30.2
>
next prev parent reply other threads:[~2023-08-03 6:26 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 14:06 [PATCHv5 00/13] net/lwip: add lwip library for the network stack Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 01/13] net/lwip: add doc/develop/net_lwip.rst Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-02 14:06 ` [PATCHv5 02/13] net/lwip: integrate lwip library Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-03 14:18 ` Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 03/13] net/lwip: implement dns cmd Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-02 14:06 ` [PATCHv5 04/13] net/lwip: implement dhcp cmd Maxim Uvarov
2023-08-03 6:26 ` Ilias Apalodimas [this message]
2023-08-03 14:34 ` Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 05/13] net/lwip: implement tftp cmd Maxim Uvarov
2023-08-03 6:42 ` Ilias Apalodimas
2023-08-10 11:28 ` Maxim Uvarov
2023-08-10 19:23 ` Simon Goldschmidt
2023-08-02 14:06 ` [PATCHv5 06/13] net/lwip: implement wget cmd Maxim Uvarov
2023-08-03 6:48 ` Ilias Apalodimas
2023-08-03 14:59 ` Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 07/13] net/lwip: implement ping cmd Maxim Uvarov
2023-08-03 9:32 ` Ilias Apalodimas
2023-08-03 15:25 ` Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 08/13] net/lwip: add lwip configuration configuration Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 09/13] net/lwip: implement lwip port to u-boot Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-03 16:21 ` Maxim Uvarov
2023-08-08 10:07 ` Maxim Uvarov
2023-08-08 17:54 ` Simon Glass
2023-08-02 14:06 ` [PATCHv5 10/13] net/lwip: update .gitignore with lwip Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-03 6:01 ` Ilias Apalodimas
2023-08-02 14:06 ` [PATCHv5 11/13] net/lwip: connection between cmd and lwip apps Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-03 8:56 ` Ilias Apalodimas
2023-08-08 12:19 ` Maxim Uvarov
2023-08-08 18:12 ` Ilias Apalodimas
2023-08-09 19:29 ` Maxim Uvarov
2023-08-02 14:06 ` [PATCHv5 12/13] net/lwip: replace original net commands with lwip Maxim Uvarov
2023-08-02 21:31 ` Simon Glass
2023-08-08 14:05 ` Maxim Uvarov
2023-08-08 17:54 ` Simon Glass
2023-08-02 14:06 ` [PATCHv5 13/13] net/lwip: drop old net/wget Maxim Uvarov
2023-08-02 14:19 ` Maxim Uvarov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZMtIejM1KnXjsLsq@hades \
--to=ilias.apalodimas@linaro.org \
--cc=goldsimon@gmx.de \
--cc=joe.hershberger@ni.com \
--cc=lwip-devel@nongnu.org \
--cc=maxim.uvarov@linaro.org \
--cc=pbrobinson@redhat.com \
--cc=rfried.dev@gmail.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox