Skip to content

Commit d45cd67

Browse files
jukkarnashif
authored andcommitted
net: Convert network codebase to use renamed network APIs
Rename network symbols in network stack to use the renamed network APIs. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 33ac14a commit d45cd67

File tree

330 files changed

+9040
-8944
lines changed

Some content is hidden

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

330 files changed

+9040
-8944
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.

include/zephyr/logging/log_backend_net.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ extern "C" {
4242
bool log_backend_net_set_addr(const char *addr);
4343

4444
/**
45-
* @brief Allows user to set a server IP address, provided as sockaddr structure, at runtime
45+
* @brief Allows user to set a server IP address, provided as net_sockaddr structure, at runtime
4646
*
4747
* @details This function allows the user to set an IPv4 or IPv6 address at runtime. It can be
4848
* called either before or after the backend has been initialized. If it gets called when
4949
* the net logger backend context is running, it'll release it and create another one with
5050
* the new address next time process() gets called.
5151
*
52-
* @param addr Pointer to the sockaddr structure that contains the IP address.
52+
* @param addr Pointer to the net_sockaddr structure that contains the IP address.
5353
*
5454
* @return True if address could be set, false otherwise.
5555
*/
56-
bool log_backend_net_set_ip(const struct sockaddr *addr);
56+
bool log_backend_net_set_ip(const struct net_sockaddr *addr);
5757

5858
/**
5959
* @brief update the hostname

include/zephyr/net/canbus.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ struct canbus_api {
3939
/** Set socket CAN option */
4040
int (*setsockopt)(const struct device *dev, void *obj, int level,
4141
int optname,
42-
const void *optval, socklen_t optlen);
42+
const void *optval, net_socklen_t optlen);
4343

4444
/** Get socket CAN option */
4545
int (*getsockopt)(const struct device *dev, void *obj, int level,
4646
int optname,
47-
const void *optval, socklen_t *optlen);
47+
const void *optval, net_socklen_t *optlen);
4848
};
4949

5050
/* Make sure that the network interface API is properly setup inside

include/zephyr/net/capture.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ struct net_capture_info {
337337
const struct device *capture_dev;
338338
struct net_if *capture_iface;
339339
struct net_if *tunnel_iface;
340-
struct sockaddr *peer;
341-
struct sockaddr *local;
340+
struct net_sockaddr *peer;
341+
struct net_sockaddr *local;
342342
bool is_enabled;
343343
};
344344

0 commit comments

Comments
 (0)