From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B245C001DF for ; Thu, 3 Aug 2023 06:26:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A5A398680E; Thu, 3 Aug 2023 08:26:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="stJBobby"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4826867F7; Thu, 3 Aug 2023 08:26:07 +0200 (CEST) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8A389862B9 for ; Thu, 3 Aug 2023 08:26:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-522bd411679so646194a12.0 for ; Wed, 02 Aug 2023 23:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691043965; x=1691648765; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0PlWZsXj3F3fGwtAsU3keVn/20d/8QWj6zSDmnuO1q8=; b=stJBobbyZJy+eiqCayPQLm+Ld/L0MptW7TnA0onD7ihLdPM/51ZC4UlZTbB84RO8Pr QmhV2uPGNmcx9L+Is6aUxzicJmbihYNpOXjd2sU7OmqA2ynmxMQKuohjIFJ9CvL7GF5M irsmMS+MzGeAJdhWzvi71FIHUfw3ezzbZgfmkG9Xntpwv4Pck6LkoirIDlN1eSae8AvY gJFOSUvISKhP47Uc9mpBeFi7zqbTREEAsXoceWDLGaJ47qOf33X7MmUV75WYJrGkVfhl DsVSzkuF7sWQTZypRUkC3s/S/ZNfFiBOdDAAvrwWon/PMPab8tVQiF53KsLU1G6XPxAG bTiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691043965; x=1691648765; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0PlWZsXj3F3fGwtAsU3keVn/20d/8QWj6zSDmnuO1q8=; b=fiSaBAWG23cJ18LuiO/DV1QlsbwU0IaxT7ibcPHu9EOrjDJMn/Rpv/X6Ibz9nwNDO/ v1ftw6rvVmmU6gVFYDr6Nuz9ptUfkEHzhfI3nGP9I3ChYYnQzwCEnQ9njU3udKdyM/mB 04cT8b6gSALRGw24D90AtDmRJi7zthZLMXDC+QBrR3fYaNLdxXcEFxzpH0P6B7StVoIa 7EXGigJzHIURhBO5kHIYWEKznyMdFOWkDpgsjxwa2WbHxAQaVEYjntE0hzgpxJ8HwdQd CpvepX/EBMx1SsYxTtWuK7fFGfzKLlELILxZBdW9Ge0hoZwPtaDvbq9K+qj4xbajosHb BxZg== X-Gm-Message-State: ABy/qLaLxD47dl5f2Yt8AGOqvi2BFPZZAPQztVYV7IvOXJec399gET97 5Ony3cwC3dWJzlc5yDi3yYVimw== X-Google-Smtp-Source: APBJJlFUHlk4DSMUHIdHIZIWThechsRlUoKKB4+lc5Nr9mbfVetg5ZKSGEmHwCiIUX0DM66z003MKA== X-Received: by 2002:a17:907:2ce9:b0:99b:507d:dc05 with SMTP id hz9-20020a1709072ce900b0099b507ddc05mr7037761ejc.16.1691043965095; Wed, 02 Aug 2023 23:26:05 -0700 (PDT) Received: from hades (ppp089210246083.access.hol.gr. [89.210.246.83]) by smtp.gmail.com with ESMTPSA id m17-20020a170906849100b00992d70f8078sm10044004ejx.106.2023.08.02.23.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 23:26:04 -0700 (PDT) Date: Thu, 3 Aug 2023 09:26:02 +0300 From: Ilias Apalodimas To: Maxim Uvarov 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 Message-ID: References: <20230802140658.10319-1-maxim.uvarov@linaro.org> <20230802140658.10319-5-maxim.uvarov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230802140658.10319-5-maxim.uvarov@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 > --- > 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. > + */ > + > +#include > +#include > +#include > + > +#include > +#include > + > +#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 >