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 06464C001B0 for ; Mon, 14 Aug 2023 14:21:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FD528678A; Mon, 14 Aug 2023 16:21:44 +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="XSc4iOkr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82F50867F7; Mon, 14 Aug 2023 16:21:42 +0200 (CEST) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 97D0986679 for ; Mon, 14 Aug 2023 16:21:40 +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-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe1fc8768aso44128035e9.1 for ; Mon, 14 Aug 2023 07:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692022900; x=1692627700; 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=SKVSGukynCnAwWVjYN7cO0KWXoFtfuWcbFaILzoDXEM=; b=XSc4iOkrGMChRoc/yvB3pFrDEuSj0HYUt2s1aLHuVPvWM3Iwyxefd9ITp55A9pYgm8 zyDSOQMZ82MNbUzltst3ZckQyGIepFTT01W2gPHWnaTUx43Wg1PlsdnO7U9YiygRBhKh s+jdZ6l0TF+2U8vfQXn8ZYxeF+kzncUDBH9GfgfHRjAvwoUrG2w1gZyfuSsxtAaB2Awl s7LpUhoRW4uc3+/py/O9cSTEztcCGx5tf/droOUAT4bRA1fdYB72zk/+fBOe5QDObHN3 mtWRTNq9i7F+x8mTtI4ohuOcGaIQrJGUUy91IUE23z8WzRwOOkCIrCq4Wms9BDOM2aYL fZig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692022900; x=1692627700; 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=SKVSGukynCnAwWVjYN7cO0KWXoFtfuWcbFaILzoDXEM=; b=Y29FW6PoI7crN+wjc+aa474P6Rd8cXSQbpc3hz78TaUpo8nAV9lBUG2WEclB7fpwam sduIGz1x3CT+8EGu62T3gw0PTwNttLAsdxTntaLrWJO6HYpi0NG5zGVXAhi5K9HGok4u zwFY9FZp6skcN2e3jkJuh/JtnsWN15L4Ggw6AlpLjNvZ+118JMO1fSHKXJl6WC5o43U2 TU4YOhn75qoM2Ftx+ULfzqOEKIjQ50ECTeBNFZ6wzuHjZENFlQWm8rg8ilMT2o6obZfk WAKT51lxaYnq5T7lj8e+XetTTQdlXDjWhRBUAi6WjFJ0mM8M9llXYtMFF4rHVQiFasB7 QyPw== X-Gm-Message-State: AOJu0YzllNWKrMwPvDbJFuH45wXPez5S0/vtGcb8cuwFNd/VsK+d7CSL mNRLUHvwv3sJFRJZQDdt1Rvq2g== X-Google-Smtp-Source: AGHT+IFuj/RD3tbhmHvB/pJetJntSopXmJx61mAqU1GPBBuNO9fajVls6D/wRf69RNzPmS9RP+ez2A== X-Received: by 2002:a7b:cc85:0:b0:3fe:f99:1ba with SMTP id p5-20020a7bcc85000000b003fe0f9901bamr9100215wma.2.1692022900036; Mon, 14 Aug 2023 07:21:40 -0700 (PDT) Received: from hades (ppp089210246083.access.hol.gr. [89.210.246.83]) by smtp.gmail.com with ESMTPSA id p25-20020a7bcc99000000b003fe18d03188sm14451285wma.17.2023.08.14.07.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 07:21:39 -0700 (PDT) Date: Mon, 14 Aug 2023 17:21:37 +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: [PATCHv6 04/14] net/lwip: implement dhcp cmd Message-ID: References: <20230814133253.4150-1-maxim.uvarov@linaro.org> <20230814133253.4150-5-maxim.uvarov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230814133253.4150-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 On Mon, Aug 14, 2023 at 07:32:43PM +0600, Maxim Uvarov wrote: > Implement function for dhcp command with lwIP variant. Usage and output is > the same as the original command. This code called by compatibility code > between U-Boot and lwIP. Same as the dns command > > Signed-off-by: Maxim Uvarov > --- > include/net/lwip.h | 10 +++++++ > net/lwip/Makefile | 1 + > net/lwip/apps/dhcp/lwip-dhcp.c | 51 ++++++++++++++++++++++++++++++++++ > 3 files changed, 62 insertions(+) > create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c > > diff --git a/include/net/lwip.h b/include/net/lwip.h > index c83b5c8231..2f035280eb 100644 > --- a/include/net/lwip.h > +++ b/include/net/lwip.h > @@ -15,3 +15,13 @@ int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, > * Other value < 0, if error > */ > int ulwip_dns(char *name, char *varname); > + > +/* > +* This function creates the DHCP request to obtain IP address. If DHCP server Sphinx needs something more, please check the existing functions > +* returns file name, this file will be downloaded with tftp. After this > +* function you need to invoke the polling loop to process network communication. > +* > +* Return: 0 if success > +* Other value < 0, if error > +*/ > +int ulwip_dhcp(void); > diff --git a/net/lwip/Makefile b/net/lwip/Makefile > index 6d2c00605b..59323fb325 100644 > --- a/net/lwip/Makefile > + > +static struct dhcp dhcp; > + > +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); What's (1)? > + > + if (!netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP)) > + dhcp_set_struct(netif, &dhcp); > + > + err = dhcp_start(netif); > + if (err) > + printf("dhcp_start error %d\n", err); > + > + return err; > +} > -- > 2.30.2 > Thanks /Ilias