Skip to content

drivers: modem: use zsock_ variants of socket API #26061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions drivers/modem/modem_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void modem_socket_put(struct modem_socket_config *cfg, int sock_fd)
* initial implementation, but this should be improved in the future.
*/
int modem_socket_poll(struct modem_socket_config *cfg,
struct pollfd *fds, int nfds, int msecs)
struct zsock_pollfd *fds, int nfds, int msecs)
{
struct modem_socket *sock;
int ret, i;
Expand All @@ -274,10 +274,10 @@ int modem_socket_poll(struct modem_socket_config *cfg,
* Handle user check for POLLOUT events:
* we consider the socket to always be writeable.
*/
if (fds[i].events & POLLOUT) {
fds[i].revents |= POLLOUT;
if (fds[i].events & ZSOCK_POLLOUT) {
fds[i].revents |= ZSOCK_POLLOUT;
found_count++;
} else if (fds[i].events & POLLIN) {
} else if (fds[i].events & ZSOCK_POLLIN) {
sock->is_polled = true;
}
}
Expand All @@ -296,8 +296,9 @@ int modem_socket_poll(struct modem_socket_config *cfg,
continue;
}

if (fds[i].events & POLLIN && sock->packet_sizes[0] > 0U) {
fds[i].revents |= POLLIN;
if ((fds[i].events & ZSOCK_POLLIN) &&
(sock->packet_sizes[0] > 0U)) {
fds[i].revents |= ZSOCK_POLLIN;
found_count++;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/modem/modem_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct modem_socket *modem_socket_from_id(struct modem_socket_config *cfg,
struct modem_socket *modem_socket_from_newid(struct modem_socket_config *cfg);
void modem_socket_put(struct modem_socket_config *cfg, int sock_fd);
int modem_socket_poll(struct modem_socket_config *cfg,
struct pollfd *fds, int nfds, int msecs);
struct zsock_pollfd *fds, int nfds, int msecs);
void modem_socket_wait_data(struct modem_socket_config *cfg,
struct modem_socket *sock);
void modem_socket_data_ready(struct modem_socket_config *cfg,
Expand Down
20 changes: 10 additions & 10 deletions drivers/modem/ublox-sara-r4.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static struct modem_data mdata;
static struct modem_context mctx;

#if defined(CONFIG_DNS_RESOLVER)
static struct addrinfo result;
static struct zsock_addrinfo result;
static struct sockaddr result_addr;
static char result_canonname[DNS_MAX_NAME_SIZE + 1];
#endif
Expand Down Expand Up @@ -1308,7 +1308,7 @@ static int offload_connect(void *obj, const struct sockaddr *addr,
}

/* support for POLLIN only for now. */
static int offload_poll(struct pollfd *fds, int nfds, int msecs)
static int offload_poll(struct zsock_pollfd *fds, int nfds, int msecs)
{
int i;
void *obj;
Expand Down Expand Up @@ -1350,15 +1350,15 @@ static ssize_t offload_recvfrom(void *obj, void *buf, size_t len,
return -1;
}

if (flags & MSG_PEEK) {
if (flags & ZSOCK_MSG_PEEK) {
errno = ENOTSUP;
return -1;
}

next_packet_size = modem_socket_next_packet_size(&mdata.socket_config,
sock);
if (!next_packet_size) {
if (flags & MSG_DONTWAIT) {
if (flags & ZSOCK_MSG_DONTWAIT) {
errno = EAGAIN;
return -1;
}
Expand Down Expand Up @@ -1560,8 +1560,8 @@ NET_SOCKET_REGISTER(ublox_sara_r4, AF_UNSPEC, offload_is_supported,
* Later, we can add additional handling if it makes sense.
*/
static int offload_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res)
const struct zsock_addrinfo *hints,
struct zsock_addrinfo **res)
{
struct modem_cmd cmd = MODEM_CMD("+UDNSRN: ", on_cmd_dns, 1U, ",");
uint32_t port = 0U;
Expand All @@ -1583,7 +1583,7 @@ static int offload_getaddrinfo(const char *node, const char *service,
if (service) {
port = ATOI(service, 0U, "port");
if (port < 1 || port > USHRT_MAX) {
return EAI_SERVICE;
return DNS_EAI_SERVICE;
}
}

Expand All @@ -1604,7 +1604,7 @@ static int offload_getaddrinfo(const char *node, const char *service,

/* user flagged node as numeric host, but we failed net_addr_pton */
if (hints && hints->ai_flags & AI_NUMERICHOST) {
return EAI_NONAME;
return DNS_EAI_NONAME;
}

snprintk(sendbuf, sizeof(sendbuf), "AT+UDNSRN=0,\"%s\"", node);
Expand All @@ -1620,11 +1620,11 @@ static int offload_getaddrinfo(const char *node, const char *service,
&net_sin(&result_addr)->sin_addr,
sendbuf, NET_IPV4_ADDR_LEN)));

*res = (struct addrinfo *)&result;
*res = (struct zsock_addrinfo *)&result;
return 0;
}

static void offload_freeaddrinfo(struct addrinfo *res)
static void offload_freeaddrinfo(struct zsock_addrinfo *res)
{
/* using static result from offload_getaddrinfo() -- no need to free */
res = NULL;
Expand Down