diff --git a/arch/sim/src/sim/posix/sim_hostusrsock.c b/arch/sim/src/sim/posix/sim_hostusrsock.c index 54b575db04..c4f452c508 100644 --- a/arch/sim/src/sim/posix/sim_hostusrsock.c +++ b/arch/sim/src/sim/posix/sim_hostusrsock.c @@ -57,7 +57,7 @@ static fd_set g_active_write_fds; * Private Functions ****************************************************************************/ -static void usrsock_host_clear_fd(int fd, fd_set *fds) +static void host_usrsock_clear_fd(int fd, fd_set *fds) { if (FD_ISSET(fd, fds)) { @@ -82,7 +82,7 @@ static void usrsock_host_clear_fd(int fd, fd_set *fds) } } -static void usrsock_host_set_fd(int fd, fd_set *fds) +static void host_usrsock_set_fd(int fd, fd_set *fds) { if (!FD_ISSET(fd, fds)) { @@ -128,7 +128,7 @@ static void sock_nonblock(int socket, int enable) } } -static int usrsock_host_sockopt(int sockfd, int level, int optname, +static int host_usrsock_sockopt(int sockfd, int level, int optname, const void *optval, nuttx_socklen_t *optlen, bool set) { @@ -185,7 +185,7 @@ static int usrsock_host_sockopt(int sockfd, int level, int optname, * Public Functions ****************************************************************************/ -int usrsock_host_socket(int domain, int type, int protocol) +int host_usrsock_socket(int domain, int type, int protocol) { int opt = 1; int ret; @@ -246,20 +246,20 @@ int usrsock_host_socket(int domain, int type, int protocol) setsockopt(ret, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); sock_nonblock(ret, true); - usrsock_host_set_fd(ret, &g_active_read_fds); + host_usrsock_set_fd(ret, &g_active_read_fds); return ret; } -int usrsock_host_close(int sockfd) +int host_usrsock_close(int sockfd) { - usrsock_host_clear_fd(sockfd, &g_active_read_fds); - usrsock_host_clear_fd(sockfd, &g_active_write_fds); + host_usrsock_clear_fd(sockfd, &g_active_read_fds); + host_usrsock_clear_fd(sockfd, &g_active_write_fds); return close(sockfd); } -int usrsock_host_connect(int sockfd, +int host_usrsock_connect(int sockfd, const struct nuttx_sockaddr *addr, nuttx_socklen_t addrlen) { @@ -277,12 +277,12 @@ int usrsock_host_connect(int sockfd, return -errno; } - usrsock_host_set_fd(sockfd, &g_active_read_fds); + host_usrsock_set_fd(sockfd, &g_active_read_fds); return ret; } -ssize_t usrsock_host_sendto(int sockfd, const void *buf, +ssize_t host_usrsock_sendto(int sockfd, const void *buf, size_t len, int flags, const struct nuttx_sockaddr *dest_addr, nuttx_socklen_t addrlen) @@ -305,7 +305,7 @@ ssize_t usrsock_host_sendto(int sockfd, const void *buf, { if (errno == EAGAIN) { - usrsock_host_set_fd(sockfd, &g_active_write_fds); + host_usrsock_set_fd(sockfd, &g_active_write_fds); } else { @@ -316,7 +316,7 @@ ssize_t usrsock_host_sendto(int sockfd, const void *buf, return ret >= 0 ? ret : -errno; } -ssize_t usrsock_host_recvfrom(int sockfd, void *buf, size_t len, int flags, +ssize_t host_usrsock_recvfrom(int sockfd, void *buf, size_t len, int flags, struct nuttx_sockaddr *src_addr, nuttx_socklen_t *addrlen) { @@ -349,26 +349,26 @@ ssize_t usrsock_host_recvfrom(int sockfd, void *buf, size_t len, int flags, sockaddr_to_nuttx(&naddr, naddrlen, src_addr, addrlen); } - usrsock_host_set_fd(sockfd, &g_active_read_fds); + host_usrsock_set_fd(sockfd, &g_active_read_fds); return ret; } -int usrsock_host_setsockopt(int sockfd, int level, int optname, +int host_usrsock_setsockopt(int sockfd, int level, int optname, const void *optval, nuttx_socklen_t optlen) { - return usrsock_host_sockopt(sockfd, level, optname, + return host_usrsock_sockopt(sockfd, level, optname, optval, &optlen, true); } -int usrsock_host_getsockopt(int sockfd, int level, int optname, +int host_usrsock_getsockopt(int sockfd, int level, int optname, void *optval, nuttx_socklen_t *optlen) { - return usrsock_host_sockopt(sockfd, level, optname, + return host_usrsock_sockopt(sockfd, level, optname, optval, optlen, false); } -int usrsock_host_getsockname(int sockfd, +int host_usrsock_getsockname(int sockfd, struct nuttx_sockaddr *addr, nuttx_socklen_t *addrlen) { @@ -390,7 +390,7 @@ int usrsock_host_getsockname(int sockfd, return ret; } -int usrsock_host_getpeername(int sockfd, +int host_usrsock_getpeername(int sockfd, struct nuttx_sockaddr *addr, nuttx_socklen_t *addrlen) { @@ -412,7 +412,7 @@ int usrsock_host_getpeername(int sockfd, return ret; } -int usrsock_host_bind(int sockfd, +int host_usrsock_bind(int sockfd, const struct nuttx_sockaddr *addr, nuttx_socklen_t addrlen) { @@ -424,7 +424,7 @@ int usrsock_host_bind(int sockfd, return bind(sockfd, &naddr, naddrlen) < 0 ? -errno : 0; } -int usrsock_host_listen(int sockfd, int backlog) +int host_usrsock_listen(int sockfd, int backlog) { int ret; @@ -434,12 +434,12 @@ int usrsock_host_listen(int sockfd, int backlog) return -errno; } - usrsock_host_set_fd(sockfd, &g_active_read_fds); + host_usrsock_set_fd(sockfd, &g_active_read_fds); return ret; } -int usrsock_host_accept(int sockfd, struct nuttx_sockaddr *addr, +int host_usrsock_accept(int sockfd, struct nuttx_sockaddr *addr, nuttx_socklen_t *addrlen) { socklen_t naddrlen = sizeof(socklen_t); @@ -458,18 +458,18 @@ int usrsock_host_accept(int sockfd, struct nuttx_sockaddr *addr, } sock_nonblock(ret, true); - usrsock_host_set_fd(ret, &g_active_read_fds); - usrsock_host_set_fd(sockfd, &g_active_read_fds); + host_usrsock_set_fd(ret, &g_active_read_fds); + host_usrsock_set_fd(sockfd, &g_active_read_fds); return ret; } -int usrsock_host_ioctl(int fd, unsigned long request, ...) +int host_usrsock_ioctl(int fd, unsigned long request, ...) { return 0; } -void usrsock_host_loop(void) +void host_usrsock_loop(void) { struct timeval timeout; fd_set write_fds; @@ -499,13 +499,13 @@ void usrsock_host_loop(void) if (FD_ISSET(i, &read_fds)) { - usrsock_host_clear_fd(i, &g_active_read_fds); + host_usrsock_clear_fd(i, &g_active_read_fds); events |= NUTTX_USRSOCK_EVENT_RECVFROM_AVAIL; } if (FD_ISSET(i, &write_fds)) { - usrsock_host_clear_fd(i, &g_active_write_fds); + host_usrsock_clear_fd(i, &g_active_write_fds); events |= NUTTX_USRSOCK_EVENT_SENDTO_READY; } diff --git a/arch/sim/src/sim/sim_hostusrsock.h b/arch/sim/src/sim/sim_hostusrsock.h index 8fbfdc0c12..fa1a58491d 100644 --- a/arch/sim/src/sim/sim_hostusrsock.h +++ b/arch/sim/src/sim/sim_hostusrsock.h @@ -258,60 +258,60 @@ struct nuttx_cmsghdr #ifdef __SIM__ int usrsock_event_callback(int16_t usockid, uint16_t events); -int usrsock_host_socket(int domain, int type, int protocol); -int usrsock_host_close(int sockfd); -int usrsock_host_connect(int sockfd, const struct nuttx_sockaddr *addr, +int host_usrsock_socket(int domain, int type, int protocol); +int host_usrsock_close(int sockfd); +int host_usrsock_connect(int sockfd, const struct nuttx_sockaddr *addr, nuttx_socklen_t addrlen); -ssize_t usrsock_host_sendto(int sockfd, const void *buf, size_t len, +ssize_t host_usrsock_sendto(int sockfd, const void *buf, size_t len, int flags, const struct nuttx_sockaddr *dest_addr, nuttx_socklen_t addrlen); -ssize_t usrsock_host_recvfrom(int sockfd, void *buf, size_t len, int flags, +ssize_t host_usrsock_recvfrom(int sockfd, void *buf, size_t len, int flags, struct nuttx_sockaddr *src_addr, nuttx_socklen_t *addrlen); -int usrsock_host_setsockopt(int sockfd, int level, int optname, +int host_usrsock_setsockopt(int sockfd, int level, int optname, const void *optval, nuttx_socklen_t optlen); -int usrsock_host_getsockopt(int sockfd, int level, int optname, +int host_usrsock_getsockopt(int sockfd, int level, int optname, void *optval, nuttx_socklen_t *optlen); -int usrsock_host_getsockname(int sockfd, +int host_usrsock_getsockname(int sockfd, struct nuttx_sockaddr *addr, nuttx_socklen_t *addrlen); -int usrsock_host_getpeername(int sockfd, +int host_usrsock_getpeername(int sockfd, struct nuttx_sockaddr *addr, nuttx_socklen_t *addrlen); -int usrsock_host_bind(int sockfd, const struct nuttx_sockaddr *addr, +int host_usrsock_bind(int sockfd, const struct nuttx_sockaddr *addr, nuttx_socklen_t addrlen); -int usrsock_host_listen(int sockfd, int backlog); -int usrsock_host_accept(int sockfd, struct nuttx_sockaddr *addr, +int host_usrsock_listen(int sockfd, int backlog); +int host_usrsock_accept(int sockfd, struct nuttx_sockaddr *addr, nuttx_socklen_t *addrlen); -int usrsock_host_ioctl(int fd, unsigned long request, ...); +int host_usrsock_ioctl(int fd, unsigned long request, ...); #else -int usrsock_host_socket(int domain, int type, int protocol); -int usrsock_host_close(int sockfd); -int usrsock_host_connect(int sockfd, const struct sockaddr *addr, +int host_usrsock_socket(int domain, int type, int protocol); +int host_usrsock_close(int sockfd); +int host_usrsock_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -ssize_t usrsock_host_sendto(int sockfd, const void *buf, size_t len, +ssize_t host_usrsock_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); -ssize_t usrsock_host_recvfrom(int sockfd, void *buf, size_t len, int flags, +ssize_t host_usrsock_recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); -int usrsock_host_setsockopt(int sockfd, int level, int optname, +int host_usrsock_setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); -int usrsock_host_getsockopt(int sockfd, int level, int optname, +int host_usrsock_getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); -int usrsock_host_getsockname(int sockfd, struct sockaddr *addr, +int host_usrsock_getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int usrsock_host_getpeername(int sockfd, struct sockaddr *addr, +int host_usrsock_getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int usrsock_host_bind(int sockfd, const struct sockaddr *addr, +int host_usrsock_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -int usrsock_host_listen(int sockfd, int backlog); -int usrsock_host_accept(int sockfd, struct sockaddr *addr, +int host_usrsock_listen(int sockfd, int backlog); +int host_usrsock_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int usrsock_host_ioctl(int fd, unsigned long request, ...); -void usrsock_host_loop(void); +int host_usrsock_ioctl(int fd, unsigned long request, ...); +void host_usrsock_loop(void); #endif /* __SIM__ */ #endif /* __ARCH_SIM_SRC_SIM_HOSTUSRSOCK_H */ diff --git a/arch/sim/src/sim/sim_initialize.c b/arch/sim/src/sim/sim_initialize.c index 52a5a0950f..fefe0a521f 100644 --- a/arch/sim/src/sim/sim_initialize.c +++ b/arch/sim/src/sim/sim_initialize.c @@ -180,7 +180,7 @@ static int sim_loop_task(int argc, char **argv) #endif #ifdef CONFIG_SIM_NETUSRSOCK - usrsock_host_loop(); + host_usrsock_loop(); #endif #ifdef CONFIG_RPTUN diff --git a/arch/sim/src/sim/sim_usrsock.c b/arch/sim/src/sim/sim_usrsock.c index a38ed63c7d..fd7b66d922 100644 --- a/arch/sim/src/sim/sim_usrsock.c +++ b/arch/sim/src/sim/sim_usrsock.c @@ -132,7 +132,7 @@ static int usrsock_socket_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_socket_s *req = data; - int fd = usrsock_host_socket(req->domain, req->type, req->protocol); + int fd = host_usrsock_socket(req->domain, req->type, req->protocol); int ret = usrsock_send_ack(usrsock, req->head.xid, fd); if (ret >= 0 && fd >= 0) @@ -147,7 +147,7 @@ static int usrsock_close_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_close_s *req = data; - int ret = usrsock_host_close(req->usockid); + int ret = host_usrsock_close(req->usockid); return usrsock_send_ack(usrsock, req->head.xid, ret); } @@ -156,7 +156,7 @@ static int usrsock_connect_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_connect_s *req = data; - int ret = usrsock_host_connect(req->usockid, + int ret = host_usrsock_connect(req->usockid, (const struct sockaddr *)(req + 1), req->addrlen); @@ -167,7 +167,7 @@ static int usrsock_sendto_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_sendto_s *req = data; - int ret = usrsock_host_sendto(req->usockid, + int ret = host_usrsock_sendto(req->usockid, (const void *)(req + 1) + req->addrlen, req->buflen, req->flags, req->addrlen ? @@ -201,7 +201,7 @@ static int usrsock_recvfrom_handler(struct usrsock_s *usrsock, buflen = sizeof(usrsock->out) - sizeof(*ack) - inaddrlen; } - ret = usrsock_host_recvfrom(req->usockid, + ret = host_usrsock_recvfrom(req->usockid, (void *)(ack + 1) + inaddrlen, buflen, req->flags, outaddrlen ? @@ -221,7 +221,7 @@ static int usrsock_setsockopt_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_setsockopt_s *req = data; - int ret = usrsock_host_setsockopt(req->usockid, req->level, + int ret = host_usrsock_setsockopt(req->usockid, req->level, req->option, req + 1, req->valuelen); return usrsock_send_ack(usrsock, req->head.xid, ret); @@ -236,7 +236,7 @@ static int usrsock_getsockopt_handler(struct usrsock_s *usrsock, int ret; ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; - ret = usrsock_host_getsockopt(req->usockid, + ret = host_usrsock_getsockopt(req->usockid, req->level, req->option, ack + 1, &optlen); @@ -254,7 +254,7 @@ static int usrsock_getsockname_handler(struct usrsock_s *usrsock, int ret; ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; - ret = usrsock_host_getsockname(req->usockid, + ret = host_usrsock_getsockname(req->usockid, (struct sockaddr *)(ack + 1), &outaddrlen); return usrsock_send_dack(usrsock, ack, req->head.xid, @@ -271,7 +271,7 @@ static int usrsock_getpeername_handler(struct usrsock_s *usrsock, int ret; ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; - ret = usrsock_host_getpeername(req->usockid, + ret = host_usrsock_getpeername(req->usockid, (struct sockaddr *)(ack + 1), &outaddrlen); return usrsock_send_dack(usrsock, ack, req->head.xid, @@ -282,7 +282,7 @@ static int usrsock_bind_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_bind_s *req = data; - int ret = usrsock_host_bind(req->usockid, + int ret = host_usrsock_bind(req->usockid, (const struct sockaddr *)(req + 1), req->addrlen); @@ -293,7 +293,7 @@ static int usrsock_listen_handler(struct usrsock_s *usrsock, const void *data, size_t len) { const struct usrsock_request_listen_s *req = data; - int ret = usrsock_host_listen(req->usockid, req->backlog); + int ret = host_usrsock_listen(req->usockid, req->backlog); return usrsock_send_ack(usrsock, req->head.xid, ret); } @@ -309,7 +309,7 @@ static int usrsock_accept_handler(struct usrsock_s *usrsock, int ret; ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; - sockfd = usrsock_host_accept(req->usockid, + sockfd = host_usrsock_accept(req->usockid, outaddrlen ? (struct sockaddr *)(ack + 1) : NULL, outaddrlen ? &outaddrlen : NULL); @@ -352,7 +352,7 @@ static int usrsock_ioctl_handler(struct usrsock_s *usrsock, ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; memcpy(ack + 1, req + 1, req->arglen); - ret = usrsock_host_ioctl(req->usockid, req->cmd, + ret = host_usrsock_ioctl(req->usockid, req->cmd, (unsigned long)(ack + 1)); return usrsock_send_dack(usrsock, ack, req->head.xid, ret,