drivers: modem: use zsock_ variants of socket API
By using the Zephyr-native zsock_ family of types and functions, these drivers will be decoupled from NET_SOCKETS_POSIX_NAMES. Signed-off-by: Adam Porter <porter.adam@gmail.com>
This commit is contained in:
parent
603c24dec9
commit
9da0f2af31
3 changed files with 18 additions and 17 deletions
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -1350,7 +1350,7 @@ 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;
|
||||
}
|
||||
|
@ -1358,7 +1358,7 @@ static ssize_t offload_recvfrom(void *obj, void *buf, size_t len,
|
|||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue