Skip to content

Commit 1713176

Browse files
committed
net: Namespace network symbols to avoid conflicts with Posix/libc
Rename network symbols i.e., add net_, NET_ or ZSOCK_ prefixes to those network symbols that can be found in Posix or libc. This way we can avoid circular dependency issues. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent f996686 commit 1713176

File tree

413 files changed

+9723
-9699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+9723
-9699
lines changed

doc/connectivity/networking/api/coap_client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The following is an example of a CoAP client initialization and request sending:
3737
req.payload = NULL;
3838
req.len = 0;
3939
40-
/* Sock is a file descriptor referencing a socket, address is the sockaddr struct for the
40+
/* Sock is a file descriptor referencing a socket, address is the net_sockaddr struct for the
4141
* destination address of the request or NULL if the socket is already connected.
4242
*/
4343
ret = coap_client_req(&client, sock, &address, &req, -1);

doc/connectivity/networking/api/coap_server.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The following is an example of a CoAP resource registered with our service:
7474
#include <zephyr/net/coap_service.h>
7575
7676
static int my_get(struct coap_resource *resource, struct coap_packet *request,
77-
struct sockaddr *addr, socklen_t addr_len)
77+
struct net_sockaddr *addr, socklen_t addr_len)
7878
{
7979
static const char *msg = "Hello, world!";
8080
uint8_t data[CONFIG_COAP_SERVER_MESSAGE_SIZE];
@@ -106,7 +106,7 @@ The following is an example of a CoAP resource registered with our service:
106106
}
107107
108108
static int my_put(struct coap_resource *resource, struct coap_packet *request,
109-
struct sockaddr *addr, socklen_t addr_len)
109+
struct net_sockaddr *addr, socklen_t addr_len)
110110
{
111111
/* ... Handle the incoming request ... */
112112
@@ -142,7 +142,7 @@ of CoAP services. An example using a temperature sensor can look like:
142142
K_WORK_DELAYABLE_DEFINE(temp_work, notify_observers);
143143
144144
static int send_temperature(struct coap_resource *resource,
145-
const struct sockaddr *addr, socklen_t addr_len,
145+
const struct net_sockaddr *addr, socklen_t addr_len,
146146
uint16_t age, uint16_t id, const uint8_t *token, uint8_t tkl,
147147
bool is_response)
148148
{
@@ -187,7 +187,7 @@ of CoAP services. An example using a temperature sensor can look like:
187187
}
188188
189189
static int temp_get(struct coap_resource *resource, struct coap_packet *request,
190-
struct sockaddr *addr, socklen_t addr_len)
190+
struct net_sockaddr *addr, socklen_t addr_len)
191191
{
192192
uint8_t token[COAP_TOKEN_MAX_LEN];
193193
uint16_t id;

doc/connectivity/networking/api/dns_resolve.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ Example:
5959
if (status == DNS_EAI_INPROGRESS && info) {
6060
char str[MAX_STR_LEN + 1];
6161
62-
if (info->ai_family == AF_INET) {
63-
net_addr_ntop(AF_INET,
62+
if (info->ai_family == NET_AF_INET) {
63+
net_addr_ntop(NET_AF_INET,
6464
&net_sin(&info->ai_addr)->sin_addr,
6565
str, NET_IPV4_ADDR_LEN);
66-
} else if (info->ai_family == AF_INET6) {
67-
net_addr_ntop(AF_INET6,
66+
} else if (info->ai_family == NET_AF_INET6) {
67+
net_addr_ntop(NET_AF_INET6,
6868
&net_sin6(&info->ai_addr)->sin6_addr,
6969
str, NET_IPV6_ADDR_LEN);
7070
} else if (info->ai_family == AF_LOCAL) {

doc/connectivity/networking/api/http_server.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ To use custom socket creation:
166166
167167
The custom socket creation function receives:
168168
- ``svc``: Pointer to the service descriptor
169-
- ``af``: Address family (AF_INET or AF_INET6)
170-
- ``proto``: Protocol (IPPROTO_TCP or IPPROTO_TLS_1_2 for HTTPS)
169+
- ``af``: Address family (NET_AF_INET or NET_AF_INET6)
170+
- ``proto``: Protocol (NET_IPPROTO_TCP or NET_IPPROTO_TLS_1_2 for HTTPS)
171171

172172
The function should return the socket file descriptor on success, or a negative error code on failure.
173173

doc/connectivity/networking/api/mqtt.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ of the MQTT client and can be shared among MQTT clients:
5151
.. code-block:: c
5252
5353
/* MQTT Broker address information. */
54-
static struct sockaddr_storage broker;
54+
static struct net_sockaddr_storage broker;
5555
5656
An MQTT client library will notify MQTT events to the application through a
5757
callback function created to handle respective events:

doc/connectivity/networking/api/mqtt_sn.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ used. An example configuration for UDP transport is shown below:
7575
.. code-block:: c
7676
7777
struct mqtt_sn_data client_id = MQTT_SN_DATA_STRING_LITERAL("ZEPHYR");
78-
struct sockaddr_in gateway = {0};
78+
struct net_sockaddr_in gateway = {0};
7979
8080
uint8_t tx_buf[256];
8181
uint8_t rx_buf[256];
8282
83-
mqtt_sn_transport_udp_init(&tp, (struct sockaddr*)&gateway, sizeof((gateway)));
83+
mqtt_sn_transport_udp_init(&tp, (struct net_sockaddr*)&gateway, sizeof((gateway)));
8484
8585
mqtt_sn_client_init(&client, &client_id, &tp.tp, evt_cb, tx_buf, sizeof(tx_buf), rx_buf, sizeof(rx_buf));
8686

doc/connectivity/networking/api/net_pkt.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ bytes:
109109

110110
.. code-block:: c
111111
112-
pkt = net_pkt_alloc_with_buffer(iface, 800, AF_INET4, IPPROTO_UDP, K_FOREVER);
112+
pkt = net_pkt_alloc_with_buffer(iface, 800, NET_AF_INET4, IPPROTO_UDP, K_FOREVER);
113113
114114
will successfully allocate 800 + 20 + 8 bytes of buffer for the new
115115
net_pkt where:
116116

117117
.. code-block:: c
118118
119-
pkt = net_pkt_alloc_with_buffer(iface, 1600, AF_INET4, IPPROTO_UDP, K_FOREVER);
119+
pkt = net_pkt_alloc_with_buffer(iface, 1600, NET_AF_INET4, IPPROTO_UDP, K_FOREVER);
120120
121121
will successfully allocate 1500 bytes, and where 20 + 8 bytes (IPv4 +
122122
UDP headers) will not be used for the payload.

drivers/ethernet/eth_adin2111.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ int eth_adin2111_oa_data_read(const struct device *dev, const uint16_t port_idx)
317317

318318
if (ftr & ADIN2111_OA_DATA_FTR_EV) {
319319
pkt = net_pkt_rx_alloc_with_buffer(iface, CONFIG_ETH_ADIN2111_BUFFER_SIZE,
320-
AF_UNSPEC, 0,
320+
NET_AF_UNSPEC, 0,
321321
K_MSEC(CONFIG_ETH_ADIN2111_TIMEOUT));
322322
if (!pkt) {
323323
LOG_ERR("OA RX: cannot allcate packet space, skipping.");
@@ -439,7 +439,7 @@ static int eth_adin2111_reg_read_generic(const struct device *dev,
439439
#endif /* CONFIG_ETH_ADIN2111_SPI_CFG0 */
440440

441441
/* spi header */
442-
*(uint16_t *)buf = htons((ADIN2111_READ_TXN_CTRL | reg));
442+
*(uint16_t *)buf = net_htons((ADIN2111_READ_TXN_CTRL | reg));
443443
#if CONFIG_ETH_ADIN2111_SPI_CFG0
444444
buf[2] = crc8_ccitt(0, buf, ADIN2111_SPI_HEADER_SIZE);
445445
/* TA */
@@ -471,7 +471,7 @@ static int eth_adin2111_reg_read_generic(const struct device *dev,
471471
}
472472
#endif /* CONFIG_ETH_ADIN2111_SPI_CFG0 */
473473

474-
*val = ntohl((*(uint32_t *)(&buf[header_len])));
474+
*val = net_ntohl((*(uint32_t *)(&buf[header_len])));
475475

476476
return ret;
477477
}
@@ -490,14 +490,14 @@ static int eth_adin2111_reg_write_generic(const struct device *dev,
490490
#endif /* CONFIG_ETH_ADIN2111_SPI_CFG0 */
491491

492492
/* spi header */
493-
*(uint16_t *)buf = htons((ADIN2111_WRITE_TXN_CTRL | reg));
493+
*(uint16_t *)buf = net_htons((ADIN2111_WRITE_TXN_CTRL | reg));
494494
#if CONFIG_ETH_ADIN2111_SPI_CFG0
495495
buf[2] = crc8_ccitt(0, buf, header_size);
496496
++header_size;
497497
#endif /* CONFIG_ETH_ADIN2111_SPI_CFG0 */
498498

499499
/* reg */
500-
*(uint32_t *)(buf + header_size) = htonl(val);
500+
*(uint32_t *)(buf + header_size) = net_htonl(val);
501501
#if CONFIG_ETH_ADIN2111_SPI_CFG0
502502
buf[header_size + data_size] = crc8_ccitt(0, &buf[header_size], data_size);
503503
++data_size;
@@ -576,7 +576,7 @@ static int adin2111_read_fifo(const struct device *dev, const uint16_t port_idx)
576576
fsize -= ADIN2111_FRAME_HEADER_SIZE;
577577

578578
/* spi header */
579-
*(uint16_t *)cmd_buf = htons((ADIN2111_READ_TXN_CTRL | rx_reg));
579+
*(uint16_t *)cmd_buf = net_htons((ADIN2111_READ_TXN_CTRL | rx_reg));
580580
#if CONFIG_ETH_ADIN2111_SPI_CFG0
581581
cmd_buf[2] = crc8_ccitt(0, cmd_buf, ADIN2111_SPI_HEADER_SIZE);
582582
/* TA */
@@ -608,7 +608,7 @@ static int adin2111_read_fifo(const struct device *dev, const uint16_t port_idx)
608608
/* remove CRC32 and pass to the stack */
609609
fsize_real = fsize - sizeof(uint32_t);
610610

611-
pkt = net_pkt_rx_alloc_with_buffer(iface, fsize_real, AF_UNSPEC, 0,
611+
pkt = net_pkt_rx_alloc_with_buffer(iface, fsize_real, NET_AF_UNSPEC, 0,
612612
K_MSEC(CONFIG_ETH_ADIN2111_TIMEOUT));
613613
if (!pkt) {
614614
eth_stats_update_errors_rx(iface);
@@ -838,7 +838,7 @@ static int adin2111_port_send(const struct device *dev, struct net_pkt *pkt)
838838
eth_adin2111_lock(adin, K_FOREVER);
839839
}
840840

841-
ret = eth_adin2111_send_oa_frame(cfg->adin, pkt, htons(cfg->port_idx));
841+
ret = eth_adin2111_send_oa_frame(cfg->adin, pkt, net_htons(cfg->port_idx));
842842

843843
goto end_check;
844844
}
@@ -887,14 +887,14 @@ static int adin2111_port_send(const struct device *dev, struct net_pkt *pkt)
887887
memset(ctx->buf, 0, burst_size + ADIN2111_WRITE_HEADER_SIZE);
888888

889889
/* spi header */
890-
*(uint16_t *)ctx->buf = htons(ADIN2111_TXN_CTRL_TX_REG);
890+
*(uint16_t *)ctx->buf = net_htons(ADIN2111_TXN_CTRL_TX_REG);
891891
#if CONFIG_ETH_ADIN2111_SPI_CFG0
892892
ctx->buf[2] = crc8_ccitt(0, ctx->buf, header_size);
893893
++header_size;
894894
#endif /* CONFIG_ETH_ADIN2111_SPI_CFG0 */
895895

896896
/* frame header */
897-
*(uint16_t *)(ctx->buf + header_size) = htons(cfg->port_idx);
897+
*(uint16_t *)(ctx->buf + header_size) = net_htons(cfg->port_idx);
898898

899899
/* read pkt into tx buffer */
900900
ret = net_pkt_read(pkt,

drivers/ethernet/eth_cyclonev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,8 @@ static void eth_cyclonev_receive(struct eth_cyclonev_priv *p)
680680
p->rx_current_desc_number = last_desc_index;
681681

682682
/* Allocate packet with buffer */
683-
pkt = net_pkt_rx_alloc_with_buffer(p->iface, frame_length, AF_UNSPEC, 0, K_NO_WAIT);
683+
pkt = net_pkt_rx_alloc_with_buffer(p->iface, frame_length,
684+
NET_AF_UNSPEC, 0, K_NO_WAIT);
684685
if (!pkt) {
685686
LOG_ERR("net_pkt_rx_alloc_with_buffer() failed");
686687
eth_stats_update_errors_rx(p->iface);

drivers/ethernet/eth_e1000.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static struct net_pkt *e1000_rx(struct e1000_dev *dev)
157157

158158
hexdump(buf, len, "%zd byte(s)", len);
159159

160-
pkt = net_pkt_rx_alloc_with_buffer(dev->iface, len, AF_UNSPEC, 0,
160+
pkt = net_pkt_rx_alloc_with_buffer(dev->iface, len, NET_AF_UNSPEC, 0,
161161
K_NO_WAIT);
162162
if (!pkt) {
163163
LOG_ERR("Out of buffers");

0 commit comments

Comments
 (0)