Skip to content

Commit b5588ed

Browse files
jukkarnashif
authored andcommitted
net: Convert modem drivers to use renamed network APIs
Rename network symbols in modem drivers to use the renamed network APIs. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 985d1c0 commit b5588ed

File tree

17 files changed

+311
-372
lines changed

17 files changed

+311
-372
lines changed

drivers/modem/hl7800.c

Lines changed: 72 additions & 100 deletions
Large diffs are not rendered by default.

drivers/modem/hl78xx/hl78xx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <zephyr/net/net_offload.h>
1212
#include <zephyr/net/offloaded_netdev.h>
1313
#include <zephyr/net/socket_offload.h>
14-
#include <zephyr/posix/fcntl.h>
1514
#include <zephyr/logging/log.h>
1615
#include <zephyr/pm/device.h>
1716
#include <zephyr/pm/device_runtime.h>

drivers/modem/hl78xx/hl78xx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ struct hl78xx_config {
349349
struct socket_read_data {
350350
char *recv_buf;
351351
size_t recv_buf_len;
352-
struct sockaddr *recv_addr;
352+
struct net_sockaddr *recv_addr;
353353
uint16_t recv_read_len;
354354
};
355355

drivers/modem/hl78xx/hl78xx_sockets.c

Lines changed: 68 additions & 65 deletions
Large diffs are not rendered by default.

drivers/modem/modem_context.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@ LOG_MODULE_REGISTER(modem_context, CONFIG_MODEM_LOG_LEVEL);
2020

2121
static struct modem_context *contexts[CONFIG_MODEM_CONTEXT_MAX_NUM];
2222

23-
int modem_context_sprint_ip_addr(const struct sockaddr *addr, char *buf, size_t buf_size)
23+
int modem_context_sprint_ip_addr(const struct net_sockaddr *addr, char *buf, size_t buf_size)
2424
{
2525
static const char unknown_str[] = "unk";
2626

27-
if (addr->sa_family == AF_INET6) {
27+
if (addr->sa_family == NET_AF_INET6) {
2828
if (buf_size < NET_IPV6_ADDR_LEN) {
2929
return -ENOMEM;
3030
}
3131

32-
if (net_addr_ntop(AF_INET6, &net_sin6(addr)->sin6_addr,
32+
if (net_addr_ntop(NET_AF_INET6, &net_sin6(addr)->sin6_addr,
3333
buf, buf_size) == NULL) {
3434
return -ENOMEM;
3535
}
3636
return 0;
3737
}
3838

39-
if (addr->sa_family == AF_INET) {
39+
if (addr->sa_family == NET_AF_INET) {
4040
if (buf_size < NET_IPV4_ADDR_LEN) {
4141
return -ENOMEM;
4242
}
43-
if (net_addr_ntop(AF_INET, &net_sin(addr)->sin_addr,
43+
if (net_addr_ntop(NET_AF_INET, &net_sin(addr)->sin_addr,
4444
buf, buf_size) == NULL) {
4545
return -ENOMEM;
4646
}
@@ -56,17 +56,17 @@ int modem_context_sprint_ip_addr(const struct sockaddr *addr, char *buf, size_t
5656
return 0;
5757
}
5858

59-
int modem_context_get_addr_port(const struct sockaddr *addr, uint16_t *port)
59+
int modem_context_get_addr_port(const struct net_sockaddr *addr, uint16_t *port)
6060
{
6161
if (!addr || !port) {
6262
return -EINVAL;
6363
}
6464

65-
if (addr->sa_family == AF_INET6) {
66-
*port = ntohs(net_sin6(addr)->sin6_port);
65+
if (addr->sa_family == NET_AF_INET6) {
66+
*port = net_ntohs(net_sin6(addr)->sin6_port);
6767
return 0;
68-
} else if (addr->sa_family == AF_INET) {
69-
*port = ntohs(net_sin(addr)->sin_port);
68+
} else if (addr->sa_family == NET_AF_INET) {
69+
*port = net_ntohs(net_sin(addr)->sin_port);
7070
return 0;
7171
}
7272

drivers/modem/modem_context.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,23 @@ struct modem_context {
7575
/**
7676
* @brief IP address to string
7777
*
78-
* @param addr: sockaddr to be converted
78+
* @param addr: net_sockaddr to be converted
7979
* @param buf: Buffer to store IP in string form
8080
* @param buf_size: buffer size
8181
*
8282
* @retval 0 if ok, < 0 if error.
8383
*/
84-
int modem_context_sprint_ip_addr(const struct sockaddr *addr, char *buf, size_t buf_size);
84+
int modem_context_sprint_ip_addr(const struct net_sockaddr *addr, char *buf, size_t buf_size);
8585

8686
/**
8787
* @brief Get port from IP address
8888
*
89-
* @param addr: sockaddr
89+
* @param addr: net_sockaddr
9090
* @param port: store port
9191
*
9292
* @retval 0 if ok, < 0 if error.
9393
*/
94-
int modem_context_get_addr_port(const struct sockaddr *addr, uint16_t *port);
94+
int modem_context_get_addr_port(const struct net_sockaddr *addr, uint16_t *port);
9595

9696
/**
9797
* @brief Gets modem context by id.

drivers/modem/modem_socket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ void modem_socket_put(struct modem_socket_config *cfg, int sock_fd)
241241
sock->sock_fd = -1;
242242
sock->is_waiting = false;
243243
sock->is_connected = false;
244-
(void)memset(&sock->src, 0, sizeof(struct sockaddr));
245-
(void)memset(&sock->dst, 0, sizeof(struct sockaddr));
244+
(void)memset(&sock->src, 0, sizeof(struct net_sockaddr));
245+
(void)memset(&sock->dst, 0, sizeof(struct net_sockaddr));
246246
memset(&sock->packet_sizes, 0, sizeof(sock->packet_sizes));
247247
sock->packet_count = 0;
248248
k_sem_reset(&sock->sem_data_ready);

drivers/modem/modem_socket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ __net_socket struct modem_socket {
2727
sa_family_t family;
2828
enum net_sock_type type;
2929
int ip_proto;
30-
struct sockaddr src;
31-
struct sockaddr dst;
30+
struct net_sockaddr src;
31+
struct net_sockaddr dst;
3232

3333
/** The number identifying the socket handle inside the modem */
3434
int id;

drivers/modem/quectel-bg9x.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ MODEM_CMD_DEFINE(on_cmd_unsol_rdy)
438438
* Desc: This function will send "binary" data over the socket object.
439439
*/
440440
static ssize_t send_socket_data(struct modem_socket *sock,
441-
const struct sockaddr *dst_addr,
441+
const struct net_sockaddr *dst_addr,
442442
struct modem_cmd *handler_cmds,
443443
size_t handler_cmds_len,
444444
const char *buf, size_t buf_len,
@@ -518,7 +518,7 @@ static ssize_t send_socket_data(struct modem_socket *sock,
518518
* Desc: This function will send data on the socket object.
519519
*/
520520
static ssize_t offload_sendto(void *obj, const void *buf, size_t len,
521-
int flags, const struct sockaddr *to,
521+
int flags, const struct net_sockaddr *to,
522522
socklen_t tolen)
523523
{
524524
int ret;
@@ -549,7 +549,7 @@ static ssize_t offload_sendto(void *obj, const void *buf, size_t len,
549549
}
550550

551551
/* UDP is not supported. */
552-
if (sock->ip_proto == IPPROTO_UDP) {
552+
if (sock->ip_proto == NET_IPPROTO_UDP) {
553553
errno = ENOTSUP;
554554
return -1;
555555
}
@@ -575,7 +575,7 @@ static ssize_t offload_sendto(void *obj, const void *buf, size_t len,
575575
* Desc: This function will receive data on the socket object.
576576
*/
577577
static ssize_t offload_recvfrom(void *obj, void *buf, size_t len,
578-
int flags, struct sockaddr *from,
578+
int flags, struct net_sockaddr *from,
579579
socklen_t *fromlen)
580580
{
581581
struct modem_socket *sock = (struct modem_socket *)obj;
@@ -684,7 +684,7 @@ static int offload_ioctl(void *obj, unsigned int request, va_list args)
684684
/* Func: offload_connect
685685
* Desc: This function will connect with a provided TCP.
686686
*/
687-
static int offload_connect(void *obj, const struct sockaddr *addr,
687+
static int offload_connect(void *obj, const struct net_sockaddr *addr,
688688
socklen_t addrlen)
689689
{
690690
struct modem_socket *sock = (struct modem_socket *) obj;
@@ -713,14 +713,14 @@ static int offload_connect(void *obj, const struct sockaddr *addr,
713713
}
714714

715715
/* Find the correct destination port. */
716-
if (addr->sa_family == AF_INET6) {
717-
dst_port = ntohs(net_sin6(addr)->sin6_port);
718-
} else if (addr->sa_family == AF_INET) {
719-
dst_port = ntohs(net_sin(addr)->sin_port);
716+
if (addr->sa_family == NET_AF_INET6) {
717+
dst_port = net_ntohs(net_sin6(addr)->sin6_port);
718+
} else if (addr->sa_family == NET_AF_INET) {
719+
dst_port = net_ntohs(net_sin(addr)->sin_port);
720720
}
721721

722722
/* UDP is not supported. */
723-
if (sock->ip_proto == IPPROTO_UDP) {
723+
if (sock->ip_proto == NET_IPPROTO_UDP) {
724724
errno = ENOTSUP;
725725
return -1;
726726
}
@@ -811,7 +811,7 @@ static int offload_close(void *obj)
811811
/* Func: offload_sendmsg
812812
* Desc: This function sends messages to the modem.
813813
*/
814-
static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags)
814+
static ssize_t offload_sendmsg(void *obj, const struct net_msghdr *msg, int flags)
815815
{
816816
ssize_t sent = 0;
817817
int rc;
@@ -1129,16 +1129,16 @@ static struct offloaded_if_api api_funcs = {
11291129

11301130
static bool offload_is_supported(int family, int type, int proto)
11311131
{
1132-
if (family != AF_INET &&
1133-
family != AF_INET6) {
1132+
if (family != NET_AF_INET &&
1133+
family != NET_AF_INET6) {
11341134
return false;
11351135
}
11361136

1137-
if (type != SOCK_STREAM) {
1137+
if (type != NET_SOCK_STREAM) {
11381138
return false;
11391139
}
11401140

1141-
if (proto != IPPROTO_TCP) {
1141+
if (proto != NET_IPPROTO_TCP) {
11421142
return false;
11431143
}
11441144

@@ -1287,4 +1287,4 @@ NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, modem_init, NULL,
12871287

12881288
/* Register NET sockets. */
12891289
NET_SOCKET_OFFLOAD_REGISTER(quectel_bg9x, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY,
1290-
AF_UNSPEC, offload_is_supported, offload_socket);
1290+
NET_AF_UNSPEC, offload_is_supported, offload_socket);

drivers/modem/quectel-bg9x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct modem_data {
123123
struct socket_read_data {
124124
char *recv_buf;
125125
size_t recv_buf_len;
126-
struct sockaddr *recv_addr;
126+
struct net_sockaddr *recv_addr;
127127
uint16_t recv_read_len;
128128
};
129129

0 commit comments

Comments
 (0)