Zephyr: add POSIX API support

Changes:
- Remove duplicate OBSERVE_PERSIST configuration block

Improve example build:

- Make virtual environment activation optional in Makefile
- Remove --fresh flag unsupported in newer west versions
- Copy mbedTLS config header to workspace include directory
- Add TARGET check for mbedTLS before configuring include directories
- Add mbedTLS linking to coap-3 target

Add POSIX API support:

- Enable CONFIG_POSIX_API=y in examples/zephyr
- Replace direct Linux/Windows system calls with Zephyr POSIX API
equivalents
- Add Zephyr's sys_rand_get() to coap_prng_default()
- Define missing network macros (IN_MULTICAST, IN6_IS_ADDR_MULTICAST,
etc.)
- Add FIONBIO and OPTVAL_T/OPTVAL_GT macro definitions for Zephyr
- Add native Zephyr timing functions to replace missing mbedTLS timing
support
- Fix fd_set mapping using zephyr/net/socket_select.h
- Exclude strnlen redefinition conflicts for Zephyr
- Add proper IPv6 packet info and address mapped definitions

(Patch) Add DNS resolution and net setup to example client:
- Enable CONFIG_DNS_RESOLVER for hostname resolution
- Add Linux networking setup instructions for native_sim board
- Configure static IP gateway and DNS server (8.8.8.8)
- Add DHCP vs static IP configuration documentation
Co-authored-by: mrdeep1
This commit is contained in:
fj-blanco authored and Jon Shallow committed 2025-06-26 15:23:23 +01:00
1 parent cf45e84be2
commit 4fa3dfa0c7
16 files changed
+194 -29

No files matched your search

+17 -2
View File
@@ -3,7 +3,8 @@ CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
#CONFIG_NET_DHCPV4=y
CONFIG_POSIX_API=y
CONFIG_DNS_RESOLVER=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
@@ -28,10 +29,24 @@ CONFIG_NET_SHELL=y
CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_NEED_IPV6=y
CONFIG_NET_CONFIG_NEED_IPV4=y
#
# Either set DHCP or static addresses
#
# DHCP
#CONFIG_NET_DHCPV4=y
#CONFIG_NET_DHCPV6=y
# Static IP & DNS
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8:53"
CONFIG_NET_L2_ETHERNET=y