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: [PATCHv6 07/14] net/lwip: implement ping cmd
Date: Wed, 16 Aug 2023 11:42:20 +0300 [thread overview]
Message-ID: <ZNyL7ACbL1g8e4Cz@hades> (raw)
In-Reply-To: <20230814133253.4150-8-maxim.uvarov@linaro.org>
On Mon, Aug 14, 2023 at 07:32:46PM +0600, Maxim Uvarov wrote:
> * can return immediately if previous request was cached or it might require
> @@ -38,3 +39,28 @@ int ulwip_dhcp(void);
> * !0 if error
> */
> int ulwip_wget(ulong addr, char *url);
> +
> +/**
> + * ulwip_tftp() - load file with tftp
> + *
> + * Load file with tftp to specific address
> + *
> + * @param addr - address to store downloaded file
> + * @param filename - file name on remote tftp server to download
Please fix function comments properly
> + *
> + *
> + * @return 0 if success, !0 if error
> + */
> +int ulwip_tftp(ulong addr, const char *filename);
> +
> +/*
> +* This function creates the ping for address provided in parameters.
> +* After this function you need to invoke the polling
> +* loop to process network communication.
> +*
> +*
> +* @ping_addr start address to download result
> +* Return: 0 for success
> +* !0 if error
> +*/
> +int ulwip_ping(char *ping_addr);
> diff --git a/net/lwip/Makefile b/net/lwip/Makefile
> index 4c6df94807..8b3e843426 100644
> --- a/net/lwip/Makefile
> +++ b/net/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/net/lwip/apps/ping/Makefile b/net/lwip/apps/ping/Makefile
> new file mode 100644
> index 0000000000..dc63feb7b5
> --- /dev/null
> +++ b/net/lwip/apps/ping/Makefile
> @@ -0,0 +1,11 @@
> +ccflags-y += -I$(srctree)/net/lwip/port/include
> +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip
> +ccflags-y += -I$(obj)
> +
> +.PHONY: $(obj)/ping.c
> +$(obj)/ping.o: $(obj)/ping.c
> +$(obj)/ping.c:
> + cp $(srctree)/net/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/net/lwip/apps/ping/lwip_ping.c b/net/lwip/apps/ping/lwip_ping.c
> new file mode 100644
> index 0000000000..611fcaf591
> --- /dev/null
> +++ b/net/lwip/apps/ping/lwip_ping.c
> @@ -0,0 +1,37 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * (C) Copyright 2023 Linaro Ltd. <maxim.uvarov@linaro.org>
> + */
> +
> +#include "lwip/opt.h"
> +#include "lwip/ip_addr.h"
> +#include "ping.h"
> +#include "lwip_ping.h"
> +
> +static ip_addr_t ip_target;
> +
> +static int ulwip_ping_tmo(void)
> +{
> +
> + log_err("ping failed; host %s is not alive\n", ipaddr_ntoa(&ip_target));
> + return 1;
> +}
> +
> +int ulwip_ping(char *ping_addr)
> +{
> + int err;
> +
> + err = ipaddr_aton(ping_addr, &ip_target);
> + if (!err) {
> + log_err("wrong ping addr string \"%s\" \n", ping_addr);
Invalid ip address is enough
> + return -1;
> + }
> +
> + ulwip_set_tmo(ulwip_ping_tmo);
> +
> + ping_init(&ip_target);
> + ping_send_now();
> +
> + return 0;
> +}
> diff --git a/net/lwip/apps/ping/lwip_ping.h b/net/lwip/apps/ping/lwip_ping.h
> new file mode 100644
> index 0000000000..0374f07d9e
> --- /dev/null
> +++ b/net/lwip/apps/ping/lwip_ping.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +
> +/*
> + * (C) Copyright 2023 Linaro Ltd. <maxim.uvarov@linaro.org>
> + */
> +
> +#ifndef LWIP_PING_H
> +#define LWIP_PING_H
> +
> +#include <lwip/ip_addr.h>
> +
> +void ping_raw_init(void);
> +void ping_send_now(void);
> +
> +#endif /* LWIP_PING_H */
> diff --git a/net/lwip/apps/ping/ping.h b/net/lwip/apps/ping/ping.h
> new file mode 100644
> index 0000000000..006a18c658
> --- /dev/null
> +++ b/net/lwip/apps/ping/ping.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#include <net/ulwip.h>
> +#include "lwip/ip_addr.h"
> +
> +#define LWIP_DEBUG 1 /* ping_time is under ifdef*/
> +#define PING_RESULT(cond) { \
> + if (cond == 1) { \
> + printf("host %s a alive\n", ipaddr_ntoa(addr)); \
> + printf(" %"U32_F" ms\n", (sys_now() - ping_time)); \
> + ulwip_exit(0); \
> + } else { \
> + printf("ping failed; host %s in not alive\n",\
> + ipaddr_ntoa(addr)); \
> + ulwip_exit(-1); \
> + } \
> + } while (0);
On the previous patch you are defining a function to do something similar
(httpc_result()). We need to be consistent on this. Can we define a
common function for all failures? Certianly don't define a macro here and
a function elsewhere
> +
> +void ping_init(const ip_addr_t *ping_addr);
> --
> 2.30.2
>
Thanks
/Ilias
next prev parent reply other threads:[~2023-08-16 8:42 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 13:32 [PATCHv6 00/14] net/lwip: add lwip library for the network stack Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 01/14] net/lwip: add doc/develop/net_lwip.rst Maxim Uvarov
2023-08-14 14:10 ` Ilias Apalodimas
2023-08-14 13:32 ` [PATCHv6 02/14] net/lwip: integrate lwIP library Maxim Uvarov
2023-08-14 14:13 ` Ilias Apalodimas
2023-08-14 13:32 ` [PATCHv6 03/14] net/lwip: implement dns cmd Maxim Uvarov
2023-08-14 14:19 ` Ilias Apalodimas
2023-08-14 15:15 ` Maxim Uvarov
2023-08-15 12:42 ` Maxim Uvarov
2023-08-15 14:42 ` Tom Rini
2023-08-16 10:26 ` Ilias Apalodimas
2023-08-16 11:01 ` Maxim Uvarov
2023-08-16 11:54 ` Ilias Apalodimas
2023-08-16 12:24 ` Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 04/14] net/lwip: implement dhcp cmd Maxim Uvarov
2023-08-14 14:21 ` Ilias Apalodimas
2023-08-14 15:18 ` Maxim Uvarov
2023-08-14 15:29 ` Tom Rini
2023-08-17 13:46 ` Maxim Uvarov
2023-08-17 14:04 ` Peter Robinson
2023-08-17 14:55 ` Maxim Uvarov
2023-08-17 15:10 ` Tom Rini
2023-08-18 9:39 ` Maxim Uvarov
2023-08-18 11:14 ` Peter Robinson
2023-08-18 14:24 ` Tom Rini
2023-08-14 13:32 ` [PATCHv6 05/14] net/lwip: implement tftp cmd Maxim Uvarov
2023-08-14 14:25 ` Ilias Apalodimas
2023-08-14 18:54 ` Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 06/14] net/lwip: implement wget cmd Maxim Uvarov
2023-08-16 8:38 ` Ilias Apalodimas
2023-08-14 13:32 ` [PATCHv6 07/14] net/lwip: implement ping cmd Maxim Uvarov
2023-08-16 8:42 ` Ilias Apalodimas [this message]
2023-08-16 9:09 ` Maxim Uvarov
2023-08-16 14:39 ` Simon Glass
2023-08-16 20:15 ` Maxim Uvarov
2023-08-18 3:10 ` Simon Glass
2023-08-18 9:27 ` Maxim Uvarov
2023-08-22 18:56 ` Simon Glass
2023-08-14 13:32 ` [PATCHv6 08/14] net/lwip: add lwIP configuration Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 09/14] net/lwip: implement lwIP port to U-Boot Maxim Uvarov
2023-08-16 9:01 ` Ilias Apalodimas
2023-08-18 12:53 ` Maxim Uvarov
2023-08-18 18:21 ` Simon Goldschmidt
2023-08-14 13:32 ` [PATCHv6 10/14] net/lwip: update .gitignore with lwIP Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 11/14] net/lwip: connection between cmd and lwip apps Maxim Uvarov
2023-08-16 9:12 ` Ilias Apalodimas
2023-08-14 13:32 ` [PATCHv6 12/14] net/lwip: replace original net commands with lwip Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 13/14] net/lwip: split net.h to net.h, arp.h and eth.h Maxim Uvarov
2023-08-14 13:32 ` [PATCHv6 14/14] net/lwip: drop old net/wget 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=ZNyL7ACbL1g8e4Cz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.