Skip to content

Commit 3ac183f

Browse files
committed
app: Update net symbols with net_/zsock_ prefix
Networking related types, functions and structures got net_ or zsock_ prefix depending on the case. Doing corresponding changes to SM. This was brought into NCS by the 2026.01.12 upmerge: nrfconnect/sdk-nrf#26468 Signed-off-by: Tommi Rantanen <tommi.rantanen@nordicsemi.no>
1 parent 3573810 commit 3ac183f

File tree

7 files changed

+132
-131
lines changed

7 files changed

+132
-131
lines changed

app/src/sm_at_icmp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static uint32_t send_ping_wait_reply(void)
122122
const uint16_t icmp_hdr_len = ICMP_HDR_LEN;
123123
struct timeval tv;
124124

125-
if (si->ai_family == AF_INET) {
125+
if (si->ai_family == NET_AF_INET) {
126126
/* Generate IPv4 ICMP EchoReq */
127127

128128
/* Ping header */
@@ -469,8 +469,8 @@ static int ping_test_handler(const char *target)
469469
}
470470

471471
/* Use the first result to decide which address family to use */
472-
if (res->ai_family == AF_INET) {
473-
char ipv4_addr[INET_ADDRSTRLEN];
472+
if (res->ai_family == NET_AF_INET) {
473+
char ipv4_addr[NET_INET_ADDRSTRLEN];
474474

475475
LOG_INF("Ping target's IPv4 address");
476476
util_get_ip_addr(ping_argv.pdn, ipv4_addr, NULL);
@@ -489,8 +489,8 @@ static int ping_test_handler(const char *target)
489489
return -ret;
490490
}
491491
ping_argv.src = res;
492-
} else if (res->ai_family == AF_INET6) {
493-
char ipv6_addr[INET6_ADDRSTRLEN];
492+
} else if (res->ai_family == NET_AF_INET6) {
493+
char ipv6_addr[NET_INET6_ADDRSTRLEN];
494494

495495
LOG_INF("Ping target's IPv6 address");
496496
util_get_ip_addr(ping_argv.pdn, NULL, ipv6_addr);

app/src/sm_at_mqtt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static int broker_init(void)
316316
if (err) {
317317
return -EAGAIN;
318318
}
319-
if (sa.sa_family == AF_INET) {
319+
if (sa.sa_family == NET_AF_INET) {
320320
ctx.broker = *(struct sockaddr_in *)&sa;
321321
} else {
322322
ctx.broker6 = *(struct sockaddr_in6 *)&sa;
@@ -374,7 +374,7 @@ static int do_mqtt_connect(void)
374374
}
375375

376376
/* MQTT client configuration */
377-
if (ctx.family == AF_INET) {
377+
if (ctx.family == NET_AF_INET) {
378378
client.broker = &ctx.broker;
379379
} else {
380380
client.broker = &ctx.broker6;
@@ -591,7 +591,7 @@ static int handle_at_mqtt_connect(enum at_parser_cmd_type cmd_type, struct at_pa
591591
return err;
592592
}
593593
}
594-
ctx.family = (op == MQTTC_CONNECT) ? AF_INET : AF_INET6;
594+
ctx.family = (op == MQTTC_CONNECT) ? NET_AF_INET : NET_AF_INET6;
595595
err = do_mqtt_connect();
596596
} else if (op == MQTTC_DISCONNECT) {
597597
err = do_mqtt_disconnect();

app/src/sm_at_socket.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct sm_send_ntf {
7979
};
8080

8181
static struct sm_socket {
82-
int type; /* SOCK_STREAM or SOCK_DGRAM */
82+
int type; /* NRF_SOCK_STREAM or NRF_SOCK_DGRAM */
8383
uint16_t role; /* Client or Server */
8484
sec_tag_t sec_tag; /* Security tag of the credential */
8585
int family; /* Socket address family */
@@ -119,7 +119,7 @@ static void init_socket(struct sm_socket *socket)
119119
socket->type = 0;
120120
socket->role = AT_SOCKET_ROLE_CLIENT;
121121
socket->sec_tag = SEC_TAG_TLS_INVALID;
122-
socket->family = AF_UNSPEC;
122+
socket->family = NRF_AF_UNSPEC;
123123
socket->fd = INVALID_SOCKET;
124124
socket->cid = 0;
125125
socket->send_flags = 0;
@@ -489,7 +489,7 @@ static int clear_so_send_cb(struct sm_socket *socket)
489489
static int do_socket_open(struct sm_socket *sock)
490490
{
491491
int ret = 0;
492-
int proto = IPPROTO_TCP;
492+
int proto = NRF_IPPROTO_TCP;
493493

494494
if (sock->family != NRF_AF_INET && sock->family != NRF_AF_INET6 &&
495495
sock->family != NRF_AF_PACKET) {
@@ -715,7 +715,7 @@ static int sockopt_set(struct sm_socket *sock, enum at_sockopt at_option, int at
715715
{
716716
int ret, level, option;
717717
void *value = &at_value;
718-
socklen_t len = sizeof(at_value);
718+
net_socklen_t len = sizeof(at_value);
719719
struct timeval tmo;
720720

721721
ret = at_sockopt_to_sockopt(at_option, &level, &option);
@@ -741,7 +741,7 @@ static int sockopt_set(struct sm_socket *sock, enum at_sockopt at_option, int at
741741
static int sockopt_get(struct sm_socket *sock, enum at_sockopt at_option)
742742
{
743743
int ret, value, level, option;
744-
socklen_t len = sizeof(int);
744+
net_socklen_t len = sizeof(int);
745745

746746
ret = at_sockopt_to_sockopt(at_option, &level, &option);
747747
if (ret) {
@@ -813,7 +813,7 @@ static int at_sec_sockopt_to_sockopt(enum at_sec_sockopt at_option, int *level,
813813
}
814814

815815
static int sec_sockopt_set(struct sm_socket *sock, enum at_sec_sockopt at_option, void *value,
816-
socklen_t len)
816+
net_socklen_t len)
817817
{
818818
int ret, level, option;
819819

@@ -823,7 +823,7 @@ static int sec_sockopt_set(struct sm_socket *sock, enum at_sec_sockopt at_option
823823
}
824824

825825
/* Options with special handling. */
826-
if (level == SOL_TLS && option == TLS_HOSTNAME) {
826+
if (level == ZSOCK_SOL_TLS && option == ZSOCK_TLS_HOSTNAME) {
827827
if (sm_util_casecmp(value, "NULL")) {
828828
value = NULL;
829829
len = 0;
@@ -843,7 +843,7 @@ static int sec_sockopt_set(struct sm_socket *sock, enum at_sec_sockopt at_option
843843
static int sec_sockopt_get(struct sm_socket *sock, enum at_sec_sockopt at_option)
844844
{
845845
int ret, value, level, option;
846-
socklen_t len = sizeof(int);
846+
net_socklen_t len = sizeof(int);
847847

848848
ret = at_sec_sockopt_to_sockopt(at_option, &level, &option);
849849
if (ret) {
@@ -894,7 +894,7 @@ int bind_to_local_addr(struct sm_socket *sock, uint16_t port)
894894

895895
struct nrf_sockaddr_in local = {
896896
.sin_family = NRF_AF_INET,
897-
.sin_port = htons(port)
897+
.sin_port = net_htons(port)
898898
};
899899

900900
if (nrf_inet_pton(NRF_AF_INET, ipv4_addr, &local.sin_addr) != 1) {
@@ -920,7 +920,7 @@ int bind_to_local_addr(struct sm_socket *sock, uint16_t port)
920920

921921
struct nrf_sockaddr_in6 local = {
922922
.sin6_family = NRF_AF_INET6,
923-
.sin6_port = htons(port)
923+
.sin6_port = net_htons(port)
924924
};
925925

926926
if (nrf_inet_pton(NRF_AF_INET6, ipv6_addr, &local.sin6_addr) != 1) {
@@ -944,14 +944,14 @@ int bind_to_local_addr(struct sm_socket *sock, uint16_t port)
944944
static int do_connect(struct sm_socket *sock, const char *url, uint16_t port)
945945
{
946946
int ret = 0;
947-
struct sockaddr sa = {.sa_family = AF_UNSPEC};
947+
struct net_sockaddr sa = {.sa_family = NET_AF_UNSPEC};
948948

949949
LOG_DBG("connect %s:%d", url, port);
950950
ret = util_resolve_host(sock->cid, url, port, sock->family, &sa);
951951
if (ret) {
952952
return -EAGAIN;
953953
}
954-
if (sa.sa_family == AF_INET) {
954+
if (sa.sa_family == NRF_AF_INET) {
955955
ret = nrf_connect(sock->fd, (struct nrf_sockaddr *)&sa,
956956
sizeof(struct nrf_sockaddr_in));
957957
} else {
@@ -1048,9 +1048,9 @@ static int do_recv(struct sm_socket *sock, int timeout, int flags,
10481048
int sockfd = sock->fd;
10491049
struct timeval tmo = {.tv_sec = timeout};
10501050

1051-
ret = nrf_setsockopt(sock->fd, SOL_SOCKET, SO_RCVTIMEO, &tmo, sizeof(tmo));
1051+
ret = nrf_setsockopt(sock->fd, NRF_SOL_SOCKET, NRF_SO_RCVTIMEO, &tmo, sizeof(tmo));
10521052
if (ret) {
1053-
LOG_ERR("nrf_setsockopt(%d) error: %d", SO_RCVTIMEO, -errno);
1053+
LOG_ERR("nrf_setsockopt(%d) error: %d", NRF_SO_RCVTIMEO, -errno);
10541054
return -errno;
10551055
}
10561056
ret = nrf_recv(sockfd, (void *)sm_data_buf, data_len, flags);
@@ -1093,7 +1093,7 @@ static int do_sendto(struct sm_socket *sock, const char *url, uint16_t port, con
10931093
{
10941094
int ret = 0;
10951095
uint32_t sent = 0;
1096-
struct sockaddr sa = {.sa_family = AF_UNSPEC};
1096+
struct net_sockaddr sa = {.sa_family = NET_AF_UNSPEC};
10971097
bool send_ntf = (flags & SM_MSG_SEND_ACK) != 0;
10981098

10991099
LOG_DBG("sendto %s:%d, flags=%d", url, port, flags);
@@ -1120,8 +1120,8 @@ static int do_sendto(struct sm_socket *sock, const char *url, uint16_t port, con
11201120
do {
11211121
ret = nrf_sendto(sock->fd, data + sent, len - sent, flags,
11221122
(struct nrf_sockaddr *)&sa,
1123-
sa.sa_family == AF_INET ? sizeof(struct nrf_sockaddr_in)
1124-
: sizeof(struct nrf_sockaddr_in6));
1123+
sa.sa_family == NRF_AF_INET ? sizeof(struct nrf_sockaddr_in)
1124+
: sizeof(struct nrf_sockaddr_in6));
11251125
if (ret <= 0) {
11261126
ret = -errno;
11271127
break;
@@ -1157,13 +1157,13 @@ static int do_recvfrom(struct sm_socket *sock, int timeout, int flags,
11571157
enum sm_socket_mode mode, size_t data_len)
11581158
{
11591159
int ret;
1160-
struct sockaddr remote;
1161-
socklen_t addrlen = sizeof(struct sockaddr);
1160+
struct net_sockaddr remote;
1161+
net_socklen_t addrlen = sizeof(struct nrf_sockaddr);
11621162
struct timeval tmo = {.tv_sec = timeout};
11631163

1164-
ret = nrf_setsockopt(sock->fd, SOL_SOCKET, SO_RCVTIMEO, &tmo, sizeof(tmo));
1164+
ret = nrf_setsockopt(sock->fd, NRF_SOL_SOCKET, NRF_SO_RCVTIMEO, &tmo, sizeof(tmo));
11651165
if (ret) {
1166-
LOG_ERR("nrf_setsockopt(%d) error: %d", SO_RCVTIMEO, -errno);
1166+
LOG_ERR("nrf_setsockopt(%d) error: %d", NRF_SO_RCVTIMEO, -errno);
11671167
return -errno;
11681168
}
11691169
ret = nrf_recvfrom(sock->fd, (void *)sm_data_buf, data_len, flags,
@@ -1184,7 +1184,7 @@ static int do_recvfrom(struct sm_socket *sock, int timeout, int flags,
11841184
char peer_addr[NRF_INET6_ADDRSTRLEN] = {0};
11851185
uint16_t peer_port = 0;
11861186

1187-
util_get_peer_addr(&remote, peer_addr, &peer_port);
1187+
util_get_peer_addr((struct net_sockaddr *)&remote, peer_addr, &peer_port);
11881188
rsp_send("\r\n#XRECVFROM: %d,%d,%d,\"%s\",%d\r\n", sock->fd, mode,
11891189
ret, peer_addr, peer_port);
11901190
}
@@ -1209,7 +1209,7 @@ static int socket_datamode_callback(uint8_t op, const uint8_t *data, int len, ui
12091209
int ret = 0;
12101210

12111211
if (op == DATAMODE_SEND) {
1212-
if (datamode_sock->type == SOCK_DGRAM &&
1212+
if (datamode_sock->type == NRF_SOCK_DGRAM &&
12131213
(flags & SM_DATAMODE_FLAGS_MORE_DATA) != 0) {
12141214
LOG_ERR("Data mode buffer overflow");
12151215
exit_datamode_handler(-EOVERFLOW);
@@ -1300,8 +1300,8 @@ STATIC int handle_at_socket(enum at_parser_cmd_type cmd_type, struct at_parser *
13001300

13011301
case AT_PARSER_CMD_TYPE_TEST:
13021302
rsp_send("\r\n#XSOCKET: <handle>,(%d,%d,%d),(%d,%d,%d),(%d,%d),<cid>\r\n",
1303-
AF_INET, AF_INET6, AF_PACKET,
1304-
SOCK_STREAM, SOCK_DGRAM, SOCK_RAW,
1303+
NRF_AF_INET, NRF_AF_INET6, NRF_AF_PACKET,
1304+
NRF_SOCK_STREAM, NRF_SOCK_DGRAM, NRF_SOCK_RAW,
13051305
AT_SOCKET_ROLE_CLIENT, AT_SOCKET_ROLE_SERVER);
13061306
err = 0;
13071307
break;
@@ -1357,9 +1357,9 @@ STATIC int handle_at_secure_socket(enum at_parser_cmd_type cmd_type,
13571357
goto error;
13581358
}
13591359
if (sock->role == AT_SOCKET_ROLE_SERVER) {
1360-
peer_verify = TLS_PEER_VERIFY_NONE;
1360+
peer_verify = ZSOCK_TLS_PEER_VERIFY_NONE;
13611361
} else if (sock->role == AT_SOCKET_ROLE_CLIENT) {
1362-
peer_verify = TLS_PEER_VERIFY_REQUIRED;
1362+
peer_verify = ZSOCK_TLS_PEER_VERIFY_REQUIRED;
13631363
} else {
13641364
err = -EINVAL;
13651365
goto error;
@@ -1407,8 +1407,8 @@ STATIC int handle_at_secure_socket(enum at_parser_cmd_type cmd_type,
14071407
case AT_PARSER_CMD_TYPE_TEST:
14081408
rsp_send("\r\n#XSSOCKET: <handle>,(%d,%d),(%d,%d),(%d,%d),"
14091409
"<sec_tag>,<peer_verify>,<cid>\r\n",
1410-
AF_INET, AF_INET6,
1411-
SOCK_STREAM, SOCK_DGRAM,
1410+
NRF_AF_INET, NRF_AF_INET6,
1411+
NRF_SOCK_STREAM, NRF_SOCK_DGRAM,
14121412
AT_SOCKET_ROLE_CLIENT, AT_SOCKET_ROLE_SERVER);
14131413
err = 0;
14141414
break;
@@ -1962,7 +1962,7 @@ STATIC int handle_at_getaddrinfo(enum at_parser_cmd_type cmd_type, struct at_par
19621962
uint32_t param_count)
19631963
{
19641964
int err = -EINVAL;
1965-
char hostname[NI_MAXHOST];
1965+
char hostname[ZSOCK_NI_MAXHOST];
19661966
char host[SM_MAX_URL];
19671967
int size = SM_MAX_URL;
19681968
struct nrf_addrinfo *result;
@@ -1978,13 +1978,13 @@ STATIC int handle_at_getaddrinfo(enum at_parser_cmd_type cmd_type, struct at_par
19781978
if (param_count == 3) {
19791979
/* DNS query with designated address family */
19801980
struct nrf_addrinfo hints = {
1981-
.ai_family = AF_UNSPEC
1981+
.ai_family = NRF_AF_UNSPEC
19821982
};
19831983
err = at_parser_num_get(parser, 2, &hints.ai_family);
19841984
if (err) {
19851985
return err;
19861986
}
1987-
if (hints.ai_family < 0 || hints.ai_family > AF_INET6) {
1987+
if (hints.ai_family < 0 || hints.ai_family > NRF_AF_INET6) {
19881988
return -EINVAL;
19891989
}
19901990
err = nrf_getaddrinfo(host, NULL, &hints, &result);
@@ -2010,7 +2010,7 @@ STATIC int handle_at_getaddrinfo(enum at_parser_cmd_type cmd_type, struct at_par
20102010

20112011
nrf_inet_ntop(NRF_AF_INET, &host->sin_addr, hostname,
20122012
sizeof(hostname));
2013-
} else if (res->ai_family == AF_INET6) {
2013+
} else if (res->ai_family == NRF_AF_INET6) {
20142014
struct nrf_sockaddr_in6 *host =
20152015
(struct nrf_sockaddr_in6 *)result->ai_addr;
20162016

app/src/sm_ppp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ static bool configure_ppp_link_ip_addresses(struct ppp_context *ctx)
183183
{
184184
static uint8_t ppp_ll_addr[PPP_INTERFACE_IDENTIFIER_LEN];
185185
uint8_t ll_addr_len;
186-
char addr4[INET_ADDRSTRLEN];
187-
char addr6[INET6_ADDRSTRLEN];
186+
char addr4[NET_INET_ADDRSTRLEN];
187+
char addr6[NET_INET6_ADDRSTRLEN];
188188

189189
util_get_ip_addr(ppp_pdn_cid, addr4, addr6);
190190

191191
if (*addr4) {
192-
if (zsock_inet_pton(AF_INET, addr4, &ctx->ipcp.my_options.address) != 1) {
192+
if (zsock_inet_pton(NET_AF_INET, addr4, &ctx->ipcp.my_options.address) != 1) {
193193
return false;
194194
}
195195
} else if (!*addr6) {
@@ -200,7 +200,7 @@ static bool configure_ppp_link_ip_addresses(struct ppp_context *ctx)
200200
if (*addr6) {
201201
struct in6_addr in6;
202202

203-
if (zsock_inet_pton(AF_INET6, addr6, &in6) != 1) {
203+
if (zsock_inet_pton(NET_AF_INET6, addr6, &in6) != 1) {
204204
return false;
205205
}
206206
/* The interface identifier is the last 64 bits of the IPv6 address. */

0 commit comments

Comments
 (0)