Integrated SSH daemon authenticating against FSUTILS_PASSWD, with an
ECDSA P-256 host key and an NSH session over a PTY per connection. Built
from the upstream Dropbear tarball (pinned commit) and patched for
NuttX, using Dropbear's bundled libtomcrypt for all crypto. setsid()
(apache/nuttx#19184) and link() now come from NuttX, not local stubs.
Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Prior to this change, if an empty folder existed instead of the
actual libwebsockets source, the build would fail. This commit
checks for an actual file instead, avoid such kind of errors.
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
libwebsockets can be built without TLS support. To allow this, it
was necessary to create a specific Kconfig option that enables TLS
support if OPENSSL_MBEDTLS_WRAPPER is enabled. Otherwise, TLS is
not supported (but libwebsockets can still be used with plain ws://
connections).
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
Extend the allocation-failure check to httpd_strdup(), the thttpd-local wrapper that has the same failure contract as strdup().
This is logically separable from the direct strdup()/asprintf() fixes: it prevents using hs->hostname before checking whether the wrapped string allocation succeeded, and releases the partially allocated server state on failure.
The scope intentionally does not extend to malloc(), calloc(), or other raw allocators because #1727 specifically calls out strdup()/asprintf(), and covering all allocation APIs would make this PR much broader.
Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
Add missing failure handling for direct strdup() and asprintf() calls where the allocated result is consumed locally before any NULL/error check.
This keeps the scope to the functions named in #1727 and avoids changing pass-through return sites where callers already receive NULL on allocation failure.
Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed. Drop them to keep the timekeeping math readable.
In the same spirit, this commit also normalises the printf-style format
specifiers and casts used to print tv_sec / tv_nsec / tv_usec values.
The prior code was a mix of "%d"/"%u"/"%ld"/"%lu"/"%lld" with matching
(int)/(unsigned long)/(long long) casts; some formats truncated time_t
on 32-bit hosts, others mismatched signedness or width. Replace all
such cases with the portable POSIX-recommended forms:
- tv_sec (time_t, signed, impl-defined width) -> %jd + (intmax_t)
- tv_nsec (long, signed) -> %ld (no cast)
- tv_usec (suseconds_t / long) -> %ld (no cast)
Also drop two stale `(FAR const time_t *)&ts.tv_sec` casts that are
unnecessary now that ts.tv_sec is plain time_t.
Arithmetic-cleanup files (existing scope):
- benchmarks/cyclictest/cyclictest.c: timediff_us()
- benchmarks/sd_bench/sd_bench_main.c: get_time_delta_us()
- examples/oneshot/oneshot_main.c: maxus computation
- examples/watchdog/watchdog_main.c: current_time_ms (x2)
- industry/nxmodbus/nxmb_internal.h: nxmb_util_clock_ms()
- netutils/ntpclient/ntpclient.c: timespec2ntp()
- netutils/ptpd/ptpd.c: ptp_adjtime()
- system/dd/dd_main.c: elapsed accounting
- testing/drivers/drivertest/drivertest_posix_timer.c:
get_timestamp()
- testing/drivers/sd_stress/sd_stress_main.c:get_time_delta()
- testing/sched/getprime/getprime_main.c: elapsed accounting
- testing/sched/pthread_mutex_perf/pthread_mutex_perf.c:
timespec_avg()
Printf-format-fix files (new in this revision):
- examples/adjtime/adjtime_main.c
- examples/charger/charger_main.c
- examples/netpkt/netpkt_ethercat.c
- fsutils/mkfatfs/mkfatfs.c
- graphics/tiff/tiff_initialize.c
- netutils/ptpd/ptpd.c
- nshlib/nsh_timcmds.c
- system/coredump/coredump.c
- system/ptpd/ptpd_main.c
- testing/drivers/drivertest/drivertest_oneshot.c
- testing/mm/kasantest/kasantest.c
- testing/ostest/semtimed.c
- testing/sched/pthread_mutex_perf/pthread_mutex_perf.c
- testing/sched/timerjitter/timerjitter.c
- testing/testsuites/kernel/time/cases/clock_test_clock01.c
- testing/testsuites/kernel/time/cases/clock_test_smoke.c
No behavioural change.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Refactor netlib_check_ipconnectivity() to use gateway/router ping instead
of DNS server ping for network connectivity checks. Add IPv6 support.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Update the column ruler and field labels in route_ipv6_entry comment
to match the actual output: lowercase to uppercase, remove colons.
Consistent with Nuttx definition
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Align with the upstream nuttx change that drops the sclock_t alias now
that clock_t is itself a signed 64-bit type (int64_t). Beyond the pure
sclock_t -> clock_t rename, this commit also removes the
now-unnecessary (time_t)-1 / (time_t)0 / (off_t)-1 casts that were
papering over the previously-unsigned time_t.
Files touched:
- examples/alarm/alarm_main.c: sclock_t -> clock_t
- netutils/dhcpd/dhcpd.c: sclock_t -> clock_t
- netutils/ftpd/ftpd.c: sclock_t -> clock_t
- netutils/thttpd/libhttpd.c,
netutils/thttpd/tdate_parse.c: drop (time_t)-1 / (time_t)0 /
(off_t)-1 sentinel casts
- system/resmonitor/filldisk.c,
system/zmodem/zm_receive.c: sclock_t -> clock_t
- testing/ostest/wdog.c: sclock_t -> clock_t (the bulk
of the rename, 30 sites)
- testing/testsuites/kernel/syscall/cases/{clock_nanosleep_test,
fsync_test,time_test}.c: drop (time_t)-1 casts in the
new signed-time_t world
No behavioural change.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
NuttX always uses a 64-bit system clock now (time_t/clock_t are
always 64-bit). Remove the obsolete CONFIG_SYSTEM_TIME64 #ifdef
branches and Kconfig dependency.
- examples/dronecan: drop SYSTEM_TIME64 dependency
- examples/netlink_route: always use PRIx64
- netutils/netinit: always use the 1-hour LONG_TIME_SEC
- netutils/ptpd: always pack the 48-bit seconds field and apply
the 64-bit overflow guard in timespec_delta_ns()
- testing/ostest/semtimed: always validate tv_sec >= 0
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
The matching nuttx commit removes CONFIG_HAVE_LONG_LONG; clean up the
remaining users in nuttx-apps so that "long long" is always assumed:
- examples/noteprintf, examples/nxscope:
unconditionally exercise the %lld / long long branch.
- fsutils/mkfatfs/configfat.c:
drop the 32-bit fall-back paths in mkfatfs_nfatsect12/16/32;
always use uint64_t for the FAT-size arithmetic.
- logging/nxscope/nxscope_chan.c:
drop the CONFIG_HAVE_LONG_LONG guard around the 64-bit
sample helpers.
- netutils/ftpd, netutils/ntpclient:
always emit the 64-bit format strings.
- testing/fs/fstest/fstest_main.c:
drop the parallel 32-bit verification path; keep only the
64-bit (long long) random pattern generator.
- system/zmodem/host/nuttx/compiler.h:
remove the host-side CONFIG_HAVE_LONG_LONG stub macro.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Use the DHCP-learned NTP server list as the default ntpc server source when DHCP option 42 is available.
Fall back to CONFIG_NETUTILS_NTPCLIENT_SERVER only when DHCP does not provide any NTP servers, and restart ntpc when the DHCP-provided server list changes.
Signed-off-by: Jerry Ma <masc2008@gmail.com>
Request DHCP option 42 and store the returned IPv4 NTP server
addresses in struct dhcpc_state for later consumers.
Signed-off-by: Jerry Ma <masc2008@gmail.com>
Replace app-side includes of <debug.h> with <nuttx/debug.h> to use the
header from the NuttX tree explicitly after the header move.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Fix mismatch on apps directory naming when it is cloned under 'nuttx-apps' instead of 'apps'.
Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
Modified CMakeLists.txt, Kconfig, and Makefile to change the cJSON download URL to include 'refs/tags/' for proper version fetching. This ensures compatibility with GitHub's archive download requirements.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
Modified the CMakeLists.txt and Makefile to ensure the correct format for downloading the cJSON tarball from GitHub by including 'refs/tags/' in the URL. This change addresses issues with fetching the correct version of the library.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
removes redundant type casts in ARP-related network library functions.
The casts from req.arp_dev (already a char array) to (FAR char *)
are unnecessary and can be safely removed.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
When using AF_RPMSG (-r option), rexecd was setting the rp_name
to the raw port number, while rexec was using htons(port). This
caused a mismatch where rexec couldn't connect to rexecd.
This commit fixes the issue by applying htons() to REXECD_PORT
when setting rp_name in the AF_RPMSG case, making it consistent
with the rexec client implementation.
Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Fix cast from pointer to integer of different size to ensure
proper type conversion and avoid compilation warnings.
Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
Add missing header files in netutils and lsan modules to fix
implicit function declarations and improve compilation compatibility.
Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
BARE is a simple binary representation for structured application data.
cbare, the BARE implementation ported by this commit, is an I/O agnostic
C implementation of the BARE message encoding.
Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
NNG depends on options that, if not enabled, makes compilation or
runtime crashes. Noting these options in help helps to find out which
are such options.
Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
standardize the implementation of ping6 to better comply with socket
permissions on certain systems.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
tests only supports tests in non-encrypted mode. when we open tests
compilation in other modes, there will be many compilation warning
with mismatched parameter types, and it will not run correctly.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
In some scenarios, dynamic memory allocation is not allowed, so it is modified to a static allocation method.
Signed-off-by: gaohedong <gaohedong@xiaomi.com>
Improve the behavior of the ARP table so that the manually configured
ARP table has the highest priority, can only be manually modified to
other values, otherwise will never change again, and will not time out.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
The ping socket creation method is changed from SOCK_DGRAM to SOCK_RAW,
because SOCK_DGRAM may not have permission in some environments (e.g. Docker).
Also add checksum calculation when send, and perform IP header processing when receive.
Signed-off-by: daichuan <daichuan@xiaomi.com>
Fix dependency issue when signals are partially or fully enabled
Co-authored-by: guoshichao <guoshichao@xiaomi.com>
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
Add netlib_check_httpconnectivity() to verify HTTP service connectivity by sending GET request and validating status code.
Signed-off-by: meijian <meijian@xiaomi.com>
Fix a issue of vlan pcp config.
`vconfig add eth0 10` will create eth0.10 with VID=10 and no PCP(0)
`vconfig add eth0 10 3` will create eth0.10 with VID=10 and PCP=3
Signed-off-by: gaohedong <gaohedong@xiaomi.com>
Fix various coding style issues including:
- Case statement formatting
- Include placement and ordering
- Whitespace issues
- Long line formatting
- Bracket alignment
Affected modules:
- audioutils, examples, include
- netutils, system
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Before attempting to sample via NTP, network connectivity should be checked to avoid frequent sampling that could cause network error logs to overflow.
Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
We add devname in ping_info_s, but not initializeed, cause
data abort as value in stack possible not NULL.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
We possible want to use iperf to test rpmsg socket etc.
Fix error when enable iperf and no IPv4
```
arm-none-eabi-ld: warning: ~/nuttx/nuttx has a LOAD segment with RWX permissions
arm-none-eabi-ld: ~/nuttx/staging/libapps.a(iperf_main.c.~.apps.netutils.iperf_1.o): in function `iperf_main':
~/apps/netutils/iperf/iperf_main.c:248:(.text.iperf_main+0x330): undefined reference to `inet_ntoa_r'
arm-none-eabi-ld: ~/apps/netutils/iperf/iperf_main.c:240:(.text.iperf_main+0x354): undefined reference to `netlib_get_ipv4addr'
arm-none-eabi-ld: ~/nuttx/staging/libapps.a(iperf.c.~.apps.netutils.iperf_1.o): in function `iperf_print_addr':
~/apps/netutils/iperf/iperf.c:226:(.text.iperf_print_addr+0x3c): undefined reference to `inet_ntoa'
```
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
The system checks connectivity with the input IP address; if no IP address is provided, it defaults to checking DNS server connectivity.
Signed-off-by: meijian <meijian@xiaomi.com>
The previous method of terminating the dhcp daemon via a global variable has been removed; instead, the `kill pid` command is used. Also, because the original `dhcp_start` method creates tasks via `task_create`, which is not supported in kernel mode, `dhcp_start` is not compiled in kernel mode. The daemon can be started in kernel mode using `dhcpd xxx &`.
Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
The current gPTP stack does not support path delay correction of the Switch.
This patch adds the path delay correction field in the Header.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>