mbox series

[v3,00/13] sntp for NET_LWIP

Message ID 20250617100720.2544758-1-jerome.forissier@linaro.org
Headers show
Series sntp for NET_LWIP | expand

Message

Jerome Forissier June 17, 2025, 10:03 a.m. UTC
Implement the sntp command with lwIP (CONFIG_NET_LWIP=y). SNTP is
supported as an app in lib/lwip/lwip/src/apps/sntp/sntp.c so this is
mainly about adding that file to the build and writing do_sntp() to use
the sntp_*() API and run the receive & timer loop. There is a patch to
extract a small bit of common code from net/sntp.c to avoid duplication.
The QEMU arm64 lwIP defconfig is updated to provide the sntp command by
default for convenience.
I could not test the case when the NTP server IP is provided by DHCP. If
someone has access right away to such a configuration and in case it
does not work, please let me know.

Changes in v3:
- Remove doc/README.SNTP and create proper documentation for the command
  in doc/usage/cmd/sntp.rst
- Remove #if CONFIG_IS_ENABLED(WGET_CACERT) guard in include/net-lwip.h
- Move files from net/lwip to cmd/lwip before splitting cmd/net-lwip.c

Changes in v2:
- Move the network commands from net/lwip to cmd/lwip. Some commands
  such as dns and ping can be moved entirely, others such as dhcp, tftp
  and wget need to remain partly in net/lwip because the protocol may be
  used even when the command is not enabled.
- ping, sntp: accept host names in addtion to IP addresses
- Update doc/README.sntp

Jerome Forissier (13):
  lwip: remove net/lwip/eth_internal.h
  lwip: move net/lwip/dns.c to cmd/lwip
  lwip: move net/lwip/ping.c to cmd/lwip
  lwip: split cmd/net-lwip.c into one file per command
  lwip: split net/lwip/wget.c
  lwip: dns: do not return CMD_RET_FAILURE on successful resolution
  lwip: dns: do not print IP address when a variable is specified
  lwip: add net_lwip_dns_resolve()
  lwip: ping: accept host name when CONFIG_CMD_DNS=y
  net: extract function net_sntp_set_rtc() from sntp_handler()
  lwip: add sntp command
  doc: add doc/cmd/sntp.rst and remove doc/README.SNTP
  configs: qemu_arm64_lwip_defconfig: enable CMD_SNTP

 MAINTAINERS                       |   1 +
 cmd/Kconfig                       |  13 +-
 cmd/Makefile                      |   2 +-
 cmd/lwip/Makefile                 |   6 +
 cmd/lwip/dhcp.c                   |   9 ++
 {net => cmd}/lwip/dns.c           |  12 +-
 {net => cmd}/lwip/ping.c          |   5 +-
 cmd/lwip/sntp.c                   | 133 ++++++++++++++++++
 cmd/lwip/tftp.c                   |   9 ++
 cmd/lwip/wget.c                   | 221 ++++++++++++++++++++++++++++++
 cmd/net-lwip.c                    |  50 -------
 configs/qemu_arm64_lwip_defconfig |   1 +
 doc/README.SNTP                   |  17 ---
 doc/usage/cmd/sntp.rst            |  72 ++++++++++
 doc/usage/index.rst               |   1 +
 include/net-common.h              |  13 ++
 include/net-lwip.h                |  15 ++
 lib/lwip/Makefile                 |   1 +
 lib/lwip/u-boot/arch/cc.h         |   4 +
 lib/lwip/u-boot/lwipopts.h        |   4 +
 net/lwip/Makefile                 |   2 -
 net/lwip/eth_internal.h           |  35 -----
 net/lwip/net-lwip.c               |  39 ++++++
 net/lwip/wget.c                   | 202 +--------------------------
 net/net-common.c                  |  23 ++++
 net/sntp.c                        |  23 +---
 26 files changed, 578 insertions(+), 335 deletions(-)
 create mode 100644 cmd/lwip/Makefile
 create mode 100644 cmd/lwip/dhcp.c
 rename {net => cmd}/lwip/dns.c (90%)
 rename {net => cmd}/lwip/ping.c (95%)
 create mode 100644 cmd/lwip/sntp.c
 create mode 100644 cmd/lwip/tftp.c
 create mode 100644 cmd/lwip/wget.c
 delete mode 100644 cmd/net-lwip.c
 delete mode 100644 doc/README.SNTP
 create mode 100644 doc/usage/cmd/sntp.rst
 delete mode 100644 net/lwip/eth_internal.h