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 07/13] net/lwip: implement ping cmd
Date: Thu, 3 Aug 2023 12:32:45 +0300 [thread overview]
Message-ID: <ZMt0PXqaPkyz/4SQ@hades> (raw)
In-Reply-To: <20230802140658.10319-8-maxim.uvarov@linaro.org>
On Wed, Aug 02, 2023 at 08:06:52PM +0600, Maxim Uvarov wrote:
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
> 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. <maxim.uvarov@linaro.org>
> + */
> +
> +#include "lwip/opt.h"
> +#include "lwip/ip_addr.h"
> +#include "ping.h"
> +
> +#include <ulwip.h>
> +
> +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. <maxim.uvarov@linaro.org>
> + */
> +
> +#ifndef LWIP_PING_H
> +#define LWIP_PING_H
> +
> +#include <lwip/ip_addr.h>
> +
> +/**
> + * 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
next prev parent reply other threads:[~2023-08-03 9:32 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
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 [this message]
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=ZMt0PXqaPkyz/4SQ@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.