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 439C8C04A6A for ; Thu, 3 Aug 2023 09:32:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A2CD86903; Thu, 3 Aug 2023 11:32:52 +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="jWo+AXuh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 701AB86C07; Thu, 3 Aug 2023 11:32:50 +0200 (CEST) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 1BF1F86903 for ; Thu, 3 Aug 2023 11:32:48 +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-ej1-x632.google.com with SMTP id a640c23a62f3a-99c0cb7285fso96010666b.0 for ; Thu, 03 Aug 2023 02:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691055167; x=1691659967; 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=YXL5u2Q9iMvd9WDomtsXwznT+i/9H61vFr89tIljftA=; b=jWo+AXuhj7CkECb8hb8NQT6ZDxrxI426k+u4MPIabtV4kVngBRSwosdW3xwq71l+Wy qHxpXq+znJzJuI/9PVwd1PKR0o91qgVRyNjVOaT5CSr93KefqiQQ5EjCg8cpKPT0wLUl IHgWxs2+0rM46b9XVc45/7jaJqlmpVn8Np6tVdVBgNicJJ8+L2H+zm40fqslNPfhnTV6 ZZ23Vt8vC8TDENj9nazf0tNsmddQFTYhetQjAYFjxyJxyiFlEE+McByPuvUDmm3A4ZUF 7hY7uJabBoo/Aln/ZrNhgkqdlOxleK8/h+v+PbnvKYlZEydFMeW6wOsf5Cch/fujYI2F 80Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691055167; x=1691659967; 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=YXL5u2Q9iMvd9WDomtsXwznT+i/9H61vFr89tIljftA=; b=fxHm3DWqUb+LwatZaCrcsohIys0TBT3Ng1J7T0XNLC1CGyOePa73T7iJxLWzHTz/3v SxwJWZfEoVfXZQ98KOgikhniQTb9fhzOLrdyblTm93/Jc1fQxYINLa5NXTVeZL0KXMke hG/YUSKtQfC2GIBbWX2Tnjzyd0yUsV1GW3CzXrIwyCa5cT2K2NjfIPXOpqyyOzT/t2zV NRaTAi4DmiYrrazk/SnTGGGkfTD6amSbMv+RRakbraxZotpwugCk5ORyoLbK+9hCxENd qLPEBy3auQqf16GKCWw9feVMt31pHWGfr9aozjy7DHb+KTTYaq31OskwAvYRrSnnJd5P Ndgw== X-Gm-Message-State: ABy/qLbebJwPN0MQOAvjT8O+XmqGlbSe+m/imx++OGdwskvFMIADPmVe xs82/uSN4w2qCL21iQFMkQeUXg== X-Google-Smtp-Source: APBJJlF/vi6Uwxud/3gi86UrmCAE8XirCWfMM+4Y5XLB11CLI8GvwoFJpD+vwDOJBgVdjKExtBiOdQ== X-Received: by 2002:a17:906:2258:b0:982:8c28:c50d with SMTP id 24-20020a170906225800b009828c28c50dmr7177109ejr.58.1691055167605; Thu, 03 Aug 2023 02:32:47 -0700 (PDT) Received: from hades (ppp089210246083.access.hol.gr. [89.210.246.83]) by smtp.gmail.com with ESMTPSA id gq15-20020a170906e24f00b00992b510089asm10192441ejb.84.2023.08.03.02.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 02:32:47 -0700 (PDT) Date: Thu, 3 Aug 2023 12:32:45 +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 07/13] net/lwip: implement ping cmd Message-ID: References: <20230802140658.10319-1-maxim.uvarov@linaro.org> <20230802140658.10319-8-maxim.uvarov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230802140658.10319-8-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 Wed, Aug 02, 2023 at 08:06:52PM +0600, Maxim Uvarov wrote: > Signed-off-by: Maxim Uvarov > --- > lib/lwip/Makefile | 1 + > lib/lwip/apps/ping/Makefile | 11 ++++++++++ > lib/lwip/apps/ping/lwip_ping.c | 37 ++++++++++++++++++++++++++++++++++ > lib/lwip/apps/ping/lwip_ping.h | 24 ++++++++++++++++++++++ > lib/lwip/apps/ping/ping.h | 35 ++++++++++++++++++++++++++++++++ > 5 files changed, 108 insertions(+) > create mode 100644 lib/lwip/apps/ping/Makefile > create mode 100644 lib/lwip/apps/ping/lwip_ping.c > create mode 100644 lib/lwip/apps/ping/lwip_ping.h > create mode 100644 lib/lwip/apps/ping/ping.h > > diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile > index ec6b728c8e..87ed99a230 100644 > --- a/lib/lwip/Makefile > +++ b/lib/lwip/Makefile > @@ -67,5 +67,6 @@ 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 > +obj-$(CONFIG_CMD_PING) += apps/ping/ > obj-$(CONFIG_CMD_TFTPBOOT) += apps/tftp/ > obj-$(CONFIG_CMD_WGET) += apps/http/ > diff --git a/lib/lwip/apps/ping/Makefile b/lib/lwip/apps/ping/Makefile > new file mode 100644 > index 0000000000..0d0a811336 > --- /dev/null > +++ b/lib/lwip/apps/ping/Makefile > @@ -0,0 +1,11 @@ > +ccflags-y += -I$(srctree)/lib/lwip/port/include > +ccflags-y += -I$(srctree)/lib/lwip/lwip-external/src/include -I$(srctree)/lib/lwip > +ccflags-y += -I$(obj) > + > +.PHONY: $(obj)/ping.c > +$(obj)/ping.o: $(obj)/ping.c > +$(obj)/ping.c: > + cp $(srctree)/lib/lwip/lwip-external/contrib/apps/ping/ping.c $(obj)/ping.c > + > +obj-$(CONFIG_CMD_PING) += ping.o > +obj-$(CONFIG_CMD_PING) += lwip_ping.o > diff --git a/lib/lwip/apps/ping/lwip_ping.c b/lib/lwip/apps/ping/lwip_ping.c > new file mode 100644 > index 0000000000..40658ab6fd > --- /dev/null > +++ b/lib/lwip/apps/ping/lwip_ping.c > @@ -0,0 +1,37 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +/* > + * (C) Copyright 2023 Linaro Ltd. > + */ > + > +#include "lwip/opt.h" > +#include "lwip/ip_addr.h" > +#include "ping.h" > + > +#include > + > +static ip_addr_t ip_target; > + > +static int ulwip_ping_tmo(void) > +{ > + > + printf("ping failed; host %s is not alive\n", ipaddr_ntoa(&ip_target)); > + return 0; Shouldnt this return != 0? Also why do we need this? Looking at ping_raw_init() it ets timeout and print fail messages > +} > + > +int lwip_ping_init(char *ping_addr) > +{ > + int err; > + > + err = ipaddr_aton(ping_addr, &ip_target); > + if (err == 0) { > + printf("wrong ping addr string \"%s\" \n", ping_addr); > + return -1; > + } > + > + ulwip_set_tmo(ulwip_ping_tmo); > + > + ping_init(&ip_target); > + > + return 0; > +} > diff --git a/lib/lwip/apps/ping/lwip_ping.h b/lib/lwip/apps/ping/lwip_ping.h > new file mode 100644 > index 0000000000..7f08095427 > --- /dev/null > +++ b/lib/lwip/apps/ping/lwip_ping.h > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > + > +/* > + * (C) Copyright 2023 Linaro Ltd. > + */ > + > +#ifndef LWIP_PING_H > +#define LWIP_PING_H > + > +#include > + > +/** > + * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used > + */ Is there any support for sockets in the current series? IOW if someome sets this to 1 will it work? If not get rid of it completely > +#ifndef PING_USE_SOCKETS > +#define PING_USE_SOCKETS 0 > +#endif > + > +int lwip_ping_init(char *ping_addr); > + > +void ping_raw_init(void); > +void ping_send_now(void); > + > +#endif /* LWIP_PING_H */ > diff --git a/lib/lwip/apps/ping/ping.h b/lib/lwip/apps/ping/ping.h > new file mode 100644 > index 0000000000..0dd4bd78c7 > --- /dev/null > +++ b/lib/lwip/apps/ping/ping.h > @@ -0,0 +1,35 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#include "../../../lwip/ulwip.h" Again, find a away to include this normally, without all the ../../ uglyness > + > +#include "lwip/prot/ip4.h" > + > +#define ip4_print_parts(a, b, c, d) \ > + printf("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d); > + > +#define ip4_print(ipaddr) \ > + ip4_print_parts(\ > + (u16_t)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \ > + (u16_t)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \ > + (u16_t)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \ > + (u16_t)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0)) > + > + > +#define LWIP_DEBUG 1 /* ping_time is under ifdef*/ > +#define PING_RESULT(cond) { \ > + if (cond == 1) { \ > + printf("host "); \ > + ip4_print(addr); \ > + printf(" is alive\n"); \ > + printf(" %"U32_F" ms\n", (sys_now() - ping_time)); \ > + ulwip_exit(0); \ > + } else { \ > + printf("ping failed; host "); \ > + ip4_print(addr); \ > + printf(" is not alive\n"); \ > + ulwip_exit(-1); \ > + } \ > + } while (0); > + > +#include "lwip/ip_addr.h" > +void ping_init(const ip_addr_t *ping_addr); > -- > 2.30.2 > Thanks /Ilias