samples: net: Change to use CONFIG_POSIX_API

Change the sample applications that use network socket API to
use the POSIX_API config because the NET_SOCKETS_POSIX_NAMES is
deprecated. Convert also the zsock_ API calls to plain BSD
socket API calls when applicable.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-03-08 07:55:29 +02:00 committed by David Leach
parent 0512e7ffae
commit 5c3fa85bc8
51 changed files with 85 additions and 121 deletions

View file

@ -1,6 +1,8 @@
# Copyright (c) 2023 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0
CONFIG_POSIX_API=y
# Networking
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=y

View file

@ -138,7 +138,7 @@ int sample_echo_packet(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint16_t
printk("Opening UDP socket\n");
socket_fd = zsock_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
socket_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (socket_fd < 0) {
printk("Failed to open socket (%d)\n", errno);
return -1;
@ -161,8 +161,8 @@ int sample_echo_packet(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint16_t
printk("Sending echo packet\n");
send_start_ms = k_uptime_get_32();
ret = zsock_sendto(socket_fd, sample_test_packet, sizeof(sample_test_packet), 0,
ai_addr, ai_addrlen);
ret = sendto(socket_fd, sample_test_packet, sizeof(sample_test_packet), 0,
ai_addr, ai_addrlen);
if (ret < sizeof(sample_test_packet)) {
printk("Failed to send sample test packet\n");
@ -170,7 +170,7 @@ int sample_echo_packet(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint16_t
}
printk("Receiving echoed packet\n");
ret = zsock_recv(socket_fd, sample_recv_buffer, sizeof(sample_recv_buffer), 0);
ret = recv(socket_fd, sample_recv_buffer, sizeof(sample_recv_buffer), 0);
if (ret != sizeof(sample_test_packet)) {
if (ret == -1) {
printk("Failed to receive echoed sample test packet (%d)\n", errno);
@ -202,7 +202,7 @@ int sample_echo_packet(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint16_t
printk("Close UDP socket\n");
ret = zsock_close(socket_fd);
ret = close(socket_fd);
if (ret < 0) {
printk("Failed to close socket\n");
return -1;
@ -224,7 +224,7 @@ int sample_transmit_packets(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint
printk("Opening UDP socket\n");
socket_fd = zsock_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
socket_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (socket_fd < 0) {
printk("Failed to open socket\n");
return -1;
@ -237,8 +237,8 @@ int sample_transmit_packets(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint
printk("Sending %u packets\n", SAMPLE_TEST_TRANSMIT_PACKETS);
send_start_ms = k_uptime_get_32();
for (uint32_t i = 0; i < SAMPLE_TEST_TRANSMIT_PACKETS; i++) {
ret = zsock_sendto(socket_fd, sample_test_packet, sizeof(sample_test_packet), 0,
ai_addr, ai_addrlen);
ret = sendto(socket_fd, sample_test_packet, sizeof(sample_test_packet), 0,
ai_addr, ai_addrlen);
if (ret < sizeof(sample_test_packet)) {
printk("Failed to send sample test packet\n");
@ -250,7 +250,7 @@ int sample_transmit_packets(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint
send_end_ms = k_uptime_get_32();
printk("Awaiting response from server\n");
ret = zsock_recv(socket_fd, sample_recv_buffer, sizeof(sample_recv_buffer), 0);
ret = recv(socket_fd, sample_recv_buffer, sizeof(sample_recv_buffer), 0);
if (ret != 2) {
printk("Invalid response\n");
return -1;
@ -266,7 +266,7 @@ int sample_transmit_packets(struct sockaddr *ai_addr, socklen_t ai_addrlen, uint
(send_end_ms - send_start_ms));
printk("Close UDP socket\n");
ret = zsock_close(socket_fd);
ret = close(socket_fd);
if (ret < 0) {
printk("Failed to close socket\n");
return -1;

View file

@ -14,6 +14,7 @@ CONFIG_REQUIRES_FULL_LIBC=y
CONFIG_SNTP=y
CONFIG_JSON_LIBRARY=y
CONFIG_POSIX_CLOCK=y
CONFIG_POSIX_API=y
# DNS
CONFIG_DNS_RESOLVER=y

View file

@ -364,7 +364,7 @@ void aws_client_loop(void)
{
int rc;
int timeout;
struct zsock_pollfd fds;
struct pollfd fds;
aws_client_setup();
@ -374,13 +374,13 @@ void aws_client_loop(void)
}
fds.fd = client_ctx.transport.tcp.sock;
fds.events = ZSOCK_POLLIN;
fds.events = POLLIN;
for (;;) {
timeout = mqtt_keepalive_time_left(&client_ctx);
rc = zsock_poll(&fds, 1u, timeout);
rc = poll(&fds, 1u, timeout);
if (rc >= 0) {
if (fds.revents & ZSOCK_POLLIN) {
if (fds.revents & POLLIN) {
rc = mqtt_input(&client_ctx);
if (rc != 0) {
LOG_ERR("Failed to read MQTT input: %d", rc);
@ -388,7 +388,7 @@ void aws_client_loop(void)
}
}
if (fds.revents & (ZSOCK_POLLHUP | ZSOCK_POLLERR)) {
if (fds.revents & (POLLHUP | POLLERR)) {
LOG_ERR("Socket closed/error");
break;
}
@ -417,7 +417,7 @@ void aws_client_loop(void)
cleanup:
mqtt_disconnect(&client_ctx);
zsock_close(fds.fd);
close(fds.fd);
fds.fd = -1;
}
@ -444,9 +444,9 @@ int sntp_sync_time(void)
static int resolve_broker_addr(struct sockaddr_in *broker)
{
int ret;
struct zsock_addrinfo *ai = NULL;
struct addrinfo *ai = NULL;
const struct zsock_addrinfo hints = {
const struct addrinfo hints = {
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
.ai_protocol = 0,
@ -454,19 +454,19 @@ static int resolve_broker_addr(struct sockaddr_in *broker)
char port_string[6] = {0};
sprintf(port_string, "%d", AWS_BROKER_PORT);
ret = zsock_getaddrinfo(CONFIG_AWS_ENDPOINT, port_string, &hints, &ai);
ret = getaddrinfo(CONFIG_AWS_ENDPOINT, port_string, &hints, &ai);
if (ret == 0) {
char addr_str[INET_ADDRSTRLEN];
memcpy(broker, ai->ai_addr, MIN(ai->ai_addrlen, sizeof(struct sockaddr_storage)));
zsock_inet_ntop(AF_INET, &broker->sin_addr, addr_str, sizeof(addr_str));
inet_ntop(AF_INET, &broker->sin_addr, addr_str, sizeof(addr_str));
LOG_INF("Resolved: %s:%u", addr_str, htons(broker->sin_port));
} else {
LOG_ERR("failed to resolve hostname err = %d (errno = %d)", ret, errno);
}
zsock_freeaddrinfo(ai);
freeaddrinfo(ai);
return ret;
}

View file

@ -1,4 +1,5 @@
CONFIG_NETWORKING=y
CONFIG_POSIX_API=y
# Disable IPv6 support
CONFIG_NET_IPV6=n

View file

@ -34,7 +34,7 @@ static struct sockaddr socks5_proxy;
#endif
/* Socket Poll */
static struct zsock_pollfd fds[1];
static struct pollfd fds[1];
static int nfds;
static bool mqtt_connected;
@ -50,8 +50,8 @@ static struct net_mgmt_event_callback l4_mgmt_cb;
#endif
#if defined(CONFIG_DNS_RESOLVER)
static struct zsock_addrinfo hints;
static struct zsock_addrinfo *haddr;
static struct addrinfo hints;
static struct addrinfo *haddr;
#endif
static K_SEM_DEFINE(mqtt_start, 0, 1);
@ -91,7 +91,7 @@ static void prepare_fds(struct mqtt_client *client)
fds[0].fd = client->transport.tls.sock;
}
fds[0].events = ZSOCK_POLLIN;
fds[0].events = POLLIN;
nfds = 1;
}
@ -108,7 +108,7 @@ static int wait(int timeout)
return rc;
}
rc = zsock_poll(fds, nfds, timeout);
rc = poll(fds, nfds, timeout);
if (rc < 0) {
LOG_ERR("poll error: %d", errno);
return -errno;
@ -128,7 +128,7 @@ static void broker_init(void)
net_ipaddr_copy(&broker4->sin_addr,
&net_sin(haddr->ai_addr)->sin_addr);
#else
zsock_inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
#endif
#if defined(CONFIG_SOCKS)
@ -136,7 +136,7 @@ static void broker_init(void)
proxy4->sin_family = AF_INET;
proxy4->sin_port = htons(SOCKS5_PROXY_PORT);
zsock_inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
#endif
}
@ -398,8 +398,8 @@ static int get_mqtt_broker_addrinfo(void)
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
rc = zsock_getaddrinfo(CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME, "8883",
&hints, &haddr);
rc = getaddrinfo(CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME, "8883",
&hints, &haddr);
if (rc == 0) {
LOG_INF("DNS resolved for %s:%d",
CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME,

View file

@ -6,6 +6,8 @@ CONFIG_MAIN_STACK_SIZE=4096
# HEAP size (512 bytes) are enough to run DNS.
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=4096
CONFIG_POSIX_API=y
# Networking config
CONFIG_NETWORKING=y
CONFIG_NET_IPV4=y
@ -15,7 +17,6 @@ CONFIG_NET_SHELL=y
# Sockets
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
# Network driver config

View file

@ -42,7 +42,7 @@ CONFIG_NET_DSA_LOG_LEVEL_INF=y
# Support for lan1..3 as RAW_SOCKETS
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_PACKET=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
# How many traffic classes to enable
CONFIG_NET_TC_TX_COUNT=6

View file

@ -40,4 +40,4 @@ CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y

View file

@ -9,6 +9,7 @@ CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_PRINTK=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_POSIX_API=y
# Enable IPv6 support
CONFIG_NET_IPV6=n

View file

@ -50,7 +50,7 @@ static APP_BMEM struct sockaddr_storage broker;
static APP_BMEM struct sockaddr socks5_proxy;
#endif
static APP_BMEM struct zsock_pollfd fds[1];
static APP_BMEM struct pollfd fds[1];
static APP_BMEM int nfds;
static APP_BMEM bool connected;
@ -116,7 +116,7 @@ static void prepare_fds(struct mqtt_client *client)
}
#endif
fds[0].events = ZSOCK_POLLIN;
fds[0].events = POLLIN;
nfds = 1;
}
@ -130,7 +130,7 @@ static int wait(int timeout)
int ret = 0;
if (nfds > 0) {
ret = zsock_poll(fds, nfds, timeout);
ret = poll(fds, nfds, timeout);
if (ret < 0) {
LOG_ERR("poll error: %d", errno);
}
@ -269,27 +269,27 @@ static void broker_init(void)
broker6->sin6_family = AF_INET6;
broker6->sin6_port = htons(SERVER_PORT);
zsock_inet_pton(AF_INET6, SERVER_ADDR, &broker6->sin6_addr);
inet_pton(AF_INET6, SERVER_ADDR, &broker6->sin6_addr);
#if defined(CONFIG_SOCKS)
struct sockaddr_in6 *proxy6 = (struct sockaddr_in6 *)&socks5_proxy;
proxy6->sin6_family = AF_INET6;
proxy6->sin6_port = htons(SOCKS5_PROXY_PORT);
zsock_inet_pton(AF_INET6, SOCKS5_PROXY_ADDR, &proxy6->sin6_addr);
inet_pton(AF_INET6, SOCKS5_PROXY_ADDR, &proxy6->sin6_addr);
#endif
#else
struct sockaddr_in *broker4 = (struct sockaddr_in *)&broker;
broker4->sin_family = AF_INET;
broker4->sin_port = htons(SERVER_PORT);
zsock_inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
inet_pton(AF_INET, SERVER_ADDR, &broker4->sin_addr);
#if defined(CONFIG_SOCKS)
struct sockaddr_in *proxy4 = (struct sockaddr_in *)&socks5_proxy;
proxy4->sin_family = AF_INET;
proxy4->sin_port = htons(SOCKS5_PROXY_PORT);
zsock_inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
inet_pton(AF_INET, SOCKS5_PROXY_ADDR, &proxy4->sin_addr);
#endif
#endif
}

View file

@ -4,7 +4,7 @@ CONFIG_NET_UDP=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_POSIX_MAX_FDS=6
CONFIG_NET_CONNECTION_MANAGER=y

View file

@ -115,8 +115,8 @@ static void process_thread(void)
LOG_DBG("Parsing MQTT host IP " CONFIG_NET_SAMPLE_MQTT_SN_GATEWAY_IP);
gateway.sin_family = AF_INET;
gateway.sin_port = htons(CONFIG_NET_SAMPLE_MQTT_SN_GATEWAY_PORT);
err = zsock_inet_pton(AF_INET, CONFIG_NET_SAMPLE_MQTT_SN_GATEWAY_IP, &gateway.sin_addr);
__ASSERT(err == 1, "zsock_inet_pton() failed %d", err);
err = inet_pton(AF_INET, CONFIG_NET_SAMPLE_MQTT_SN_GATEWAY_IP, &gateway.sin_addr);
__ASSERT(err == 1, "inet_pton() failed %d", err);
LOG_INF("Waiting for connection...");
LOG_HEXDUMP_DBG(&gateway, sizeof(gateway), "gateway");

View file

@ -10,7 +10,7 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_NET_CONTEXT_RCVTIMEO=y
CONFIG_NET_CONTEXT_SNDTIMEO=y

View file

@ -12,11 +12,6 @@ common:
tests:
sample.net.sockets.big_http_download:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.big_http_download.posix:
filter: not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y
sample.net.sockets.big_http_download.ci:
extra_args: OVERLAY_CONFIG=overlay-ci.conf

View file

@ -7,7 +7,7 @@ CONFIG_NET_DRIVERS=y
CONFIG_NET_CANBUS=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_CAN=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_NET_IPV6=n
CONFIG_NET_IPV4=n

View file

@ -5,8 +5,8 @@ CONFIG_NET_IPV6=y
CONFIG_NET_UDP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
CONFIG_POSIX_API=y
CONFIG_COAP=y

View file

@ -5,7 +5,7 @@ CONFIG_NET_UDP=y
# Socket
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_NET_SOCKETS_POLL_MAX=4
# CoAP

View file

@ -7,7 +7,7 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
# Network driver config
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -13,11 +13,6 @@ common:
tests:
sample.net.sockets.dumb_http_server:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.dumb_http_server.posix:
filter: not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y
sample.net.sockets.dumb_http_server.netusb:
depends_on: usb_device

View file

@ -3,6 +3,7 @@ CONFIG_TEST_RANDOM_GENERATOR=y
# POSIX options
CONFIG_POSIX_MAX_FDS=20
CONFIG_POSIX_API=y
# Networking config
CONFIG_NETWORKING=y
@ -11,7 +12,6 @@ CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_UDP=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_MAX_CONN=20
CONFIG_NET_MAX_CONTEXTS=20
CONFIG_NET_STATISTICS=y

View file

@ -12,5 +12,5 @@ common:
tests:
sample.net.sockets.dumb_http_server_mt:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
- CONFIG_POSIX_API=y
platform_exclude: esp32s2_saola

View file

@ -1,5 +1,6 @@
# General config
CONFIG_MAIN_STACK_SIZE=1200
CONFIG_POSIX_API=y
# Networking config
CONFIG_NETWORKING=y
@ -7,7 +8,6 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_IPV4_MAPPING_TO_IPV6=y
# Network driver config

View file

@ -8,9 +8,10 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=5
CONFIG_POSIX_API=y
# Network driver config
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -11,9 +11,4 @@ common:
tests:
sample.net.sockets.echo_async:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.echo_async.posix:
filter: not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y

View file

@ -9,7 +9,6 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=5
# Network driver config

View file

@ -11,8 +11,4 @@ common:
tests:
sample.net.sockets.echo_async_select:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.echo_async_select.posix:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y

View file

@ -25,6 +25,7 @@
#else
#include <fcntl.h>
#include <zephyr/posix/sys/select.h>
#include <zephyr/net/socket.h>
#include <zephyr/kernel.h>

View file

@ -5,10 +5,11 @@ CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_POSIX_API=y
# Kernel options
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_ENTROPY_GENERATOR=y

View file

@ -5,7 +5,7 @@ CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_POSIX_MAX_FDS=6
CONFIG_NET_CONNECTION_MANAGER=y

View file

@ -9,7 +9,6 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_IPV4_MAPPING_TO_IPV6=y
CONFIG_POSIX_MAX_FDS=10
CONFIG_NET_MAX_CONN=5

View file

@ -7,8 +7,8 @@ CONFIG_NET_SHELL=y
# Sockets
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
CONFIG_POSIX_API=y
# Network driver config
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -8,7 +8,8 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_SERVER_IP_ADDRESSES=y

View file

@ -10,19 +10,12 @@ common:
- socket
tests:
sample.net.sockets.http_get:
harness: net
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
# Forcibly defines CONFIG_POSIX_API, which is incompatible with
# CONFIG_NET_SOCKETS_POSIX_NAMES.
sample.net.sockets.http_get.posix:
filter: not CONFIG_NET_SOCKETS_OFFLOAD and not CONFIG_NATIVE_LIBC
harness: net
platform_exclude:
- cc3220sf_launchxl
- cc3235sf_launchxl
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y
sample.net.sockets.http_get.offload.simplelink:
platform_allow: cc3220sf_launchxl

View file

@ -7,7 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#if !defined(__ZEPHYR__) || defined(CONFIG_POSIX_API)
#if !defined(__ZEPHYR__)
#include <netinet/in.h>
#include <sys/socket.h>

View file

@ -5,7 +5,7 @@ CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_POSIX_MAX_FDS=6
CONFIG_NET_SOCKETS_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y

View file

@ -6,7 +6,7 @@ CONFIG_NET_IPV6=n
CONFIG_NET_IPV4=n
CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_POSIX_MAX_FDS=6
CONFIG_NET_CONTEXT_RCVTIMEO=y
CONFIG_NET_MGMT=y

View file

@ -1,5 +1,6 @@
# General config
CONFIG_REQUIRES_FULL_LIBC=y
CONFIG_POSIX_API=y
# Networking config
CONFIG_NETWORKING=y

View file

@ -9,21 +9,3 @@ tests:
platform_allow:
- qemu_x86
- native_sim
sample.net.sockets.sntp_client.posix_names:
platform_allow:
- qemu_x86
- native_sim
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.sntp_client.posix:
platform_allow:
- qemu_x86
- native_sim
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y
sample.net.sockets.sntp_client.native_posix:
platform_allow: native_posix
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=n

View file

@ -9,9 +9,7 @@
LOG_MODULE_REGISTER(net_sntp_client_sample, LOG_LEVEL_DBG);
#include <zephyr/net/sntp.h>
#ifdef CONFIG_POSIX_API
#include <arpa/inet.h>
#endif
#include "config.h"
@ -31,7 +29,7 @@ int main(void)
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(SNTP_PORT);
zsock_inet_pton(AF_INET, SERVER_ADDR, &addr.sin_addr);
inet_pton(AF_INET, SERVER_ADDR, &addr.sin_addr);
rv = sntp_init(&ctx, (struct sockaddr *) &addr,
sizeof(struct sockaddr_in));
@ -58,7 +56,7 @@ int main(void)
memset(&addr6, 0, sizeof(addr6));
addr6.sin6_family = AF_INET6;
addr6.sin6_port = htons(SNTP_PORT);
zsock_inet_pton(AF_INET6, SERVER_ADDR6, &addr6.sin6_addr);
inet_pton(AF_INET6, SERVER_ADDR6, &addr6.sin6_addr);
rv = sntp_init(&ctx, (struct sockaddr *) &addr6,
sizeof(struct sockaddr_in6));

View file

@ -3,7 +3,7 @@ CONFIG_REQUIRES_FULL_LIBC=y
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y

View file

@ -5,7 +5,7 @@ CONFIG_NET_TCP=n
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_API=y
CONFIG_NET_CONTEXT_PRIORITY=y
CONFIG_NET_CONTEXT_TXTIME=y
CONFIG_NET_TC_TX_COUNT=7

View file

@ -8,7 +8,6 @@ CONFIG_NET_STATISTICS=y
# Sockets
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
# Network driver config
@ -42,3 +41,4 @@ CONFIG_NET_LOG=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=1500
CONFIG_POSIX_API=y

View file

@ -18,3 +18,4 @@ CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_DNS_RESOLVER=n
CONFIG_TFTP_LIB=y
CONFIG_POSIX_API=y

View file

@ -37,13 +37,13 @@ static void tftp_event_callback(const struct tftp_evt *evt)
static int tftp_init(const char *hostname)
{
struct sockaddr remote_addr;
struct zsock_addrinfo *res, hints = {0};
struct addrinfo *res, hints = {0};
int ret;
/* Setup TFTP server address */
hints.ai_socktype = SOCK_DGRAM;
ret = zsock_getaddrinfo(hostname, CONFIG_TFTP_APP_PORT, &hints, &res);
ret = getaddrinfo(hostname, CONFIG_TFTP_APP_PORT, &hints, &res);
if (ret != 0) {
LOG_ERR("Unable to resolve address");
/* DNS error codes don't align with normal errors */
@ -51,7 +51,7 @@ static int tftp_init(const char *hostname)
}
memcpy(&remote_addr, res->ai_addr, sizeof(remote_addr));
zsock_freeaddrinfo(res);
freeaddrinfo(res);
/* Save sockaddr into TFTP client handler */
memcpy(&client.server, &remote_addr, sizeof(client.server));

View file

@ -19,9 +19,9 @@ CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
CONFIG_NET_MAX_CONTEXTS=5
CONFIG_NET_TC_TX_COUNT=1
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=9
CONFIG_POSIX_MAX_FDS=8
CONFIG_POSIX_API=y
CONFIG_INIT_STACKS=y
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -9,8 +9,8 @@ CONFIG_NET_UDP=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.1"
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_POSIX_API=y

View file

@ -12,11 +12,11 @@ CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NETWORKING=y
CONFIG_NET_UDP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_COAP=y
CONFIG_DNS_RESOLVER=y
CONFIG_JSON_LIBRARY=y
CONFIG_HWINFO=y
CONFIG_POSIX_API=y
# Turn on the updatehub
CONFIG_UPDATEHUB=y

View file

@ -1,5 +1,6 @@
CONFIG_LOG=y
CONFIG_MAIN_STACK_SIZE=1200
CONFIG_POSIX_API=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
@ -16,7 +17,6 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
# Network address config
CONFIG_NET_CONFIG_SETTINGS=y

View file

@ -1,6 +1,7 @@
CONFIG_LOG=y
CONFIG_GPIO=y
CONFIG_MAIN_STACK_SIZE=1200
CONFIG_POSIX_API=y
CONFIG_MODBUS=y
CONFIG_MODBUS_ROLE_SERVER=y
@ -14,7 +15,6 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
# Network address config
CONFIG_NET_CONFIG_SETTINGS=y

View file

@ -3,8 +3,8 @@ CONFIG_NETWORKING=y
CONFIG_NET_TCP=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_MAX_FDS=6
CONFIG_POSIX_API=y
# Kernel options
CONFIG_MAIN_STACK_SIZE=2048