Lines Matching refs:sock

169 	struct nsos_socket *sock;  in nsos_socket_create()  local
198 sock = k_malloc(sizeof(*sock)); in nsos_socket_create()
199 if (!sock) { in nsos_socket_create()
204 sock->fd = fd; in nsos_socket_create()
205 sock->recv_timeout = K_FOREVER; in nsos_socket_create()
206 sock->send_timeout = K_FOREVER; in nsos_socket_create()
208 sock->poll.mid.fd = nsos_adapt_socket(family_mid, type_mid, proto_mid); in nsos_socket_create()
209 if (sock->poll.mid.fd < 0) { in nsos_socket_create()
210 errno = errno_from_nsos_mid(-sock->poll.mid.fd); in nsos_socket_create()
214 zvfs_finalize_typed_fd(fd, sock, &nsos_socket_fd_op_vtable.fd_vtable, ZVFS_MODE_IFSOCK); in nsos_socket_create()
219 k_free(sock); in nsos_socket_create()
234 struct nsos_socket *sock = obj; in nsos_read() local
237 ret = nsi_host_read(sock->poll.mid.fd, buf, sz); in nsos_read()
247 struct nsos_socket *sock = obj; in nsos_write() local
250 ret = nsi_host_write(sock->poll.mid.fd, buf, sz); in nsos_write()
260 struct nsos_socket *sock = obj; in nsos_close() local
264 ret = nsi_host_close(sock->poll.mid.fd); in nsos_close()
270 if (poll == &sock->poll) { in nsos_close()
276 k_free(sock); in nsos_close()
288 static int nsos_poll_prepare(struct nsos_socket *sock, struct zsock_pollfd *pfd, in nsos_poll_prepare() argument
325 static int nsos_poll_update(struct nsos_socket *sock, struct zsock_pollfd *pfd, in nsos_poll_update() argument
356 struct nsos_socket *sock = obj; in nsos_ioctl() local
368 return nsos_poll_prepare(obj, pfd, pev, pev_end, &sock->poll); in nsos_ioctl()
378 return nsos_poll_update(obj, pfd, pev, &sock->poll); in nsos_ioctl()
387 flags = nsos_adapt_fcntl_getfl(sock->poll.mid.fd); in nsos_ioctl()
401 ret = nsos_adapt_fcntl_setfl(sock->poll.mid.fd, flags); in nsos_ioctl()
410 ret = nsos_adapt_fionread(sock->poll.mid.fd, avail); in nsos_ioctl()
557 static int nsos_wait_for_poll(struct nsos_socket *sock, int events, in nsos_wait_for_poll() argument
561 .fd = sock->fd, in nsos_wait_for_poll()
570 ret = nsos_adapt_dup(sock->poll.mid.fd); in nsos_wait_for_poll()
577 ret = nsos_poll_prepare(sock, &pfd, &pev, pev_end, &socket_poll); in nsos_wait_for_poll()
594 nsos_poll_update(sock, &pfd, &pev, &socket_poll); in nsos_wait_for_poll()
607 static int nsos_poll_if_blocking(struct nsos_socket *sock, int events, in nsos_poll_if_blocking() argument
616 sock_flags = nsos_adapt_fcntl_getfl(sock->poll.mid.fd); in nsos_poll_if_blocking()
621 return nsos_wait_for_poll(sock, events, timeout); in nsos_poll_if_blocking()
629 struct nsos_socket *sock = obj; in nsos_bind() local
640 ret = nsos_adapt_bind(sock->poll.mid.fd, addr_mid, addrlen_mid); in nsos_bind()
651 static int nsos_connect_blocking(struct nsos_socket *sock, in nsos_connect_blocking() argument
659 ret = nsos_adapt_fcntl_setfl(sock->poll.mid.fd, fcntl_flags | NSOS_MID_O_NONBLOCK); in nsos_connect_blocking()
664 ret = nsos_adapt_connect(sock->poll.mid.fd, addr_mid, addrlen_mid); in nsos_connect_blocking()
669 ret = nsos_wait_for_poll(sock, ZSOCK_POLLOUT, sock->send_timeout); in nsos_connect_blocking()
674 ret = nsos_adapt_getsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_connect_blocking()
684 clear_nonblock_ret = nsos_adapt_fcntl_setfl(sock->poll.mid.fd, fcntl_flags); in nsos_connect_blocking()
694 struct nsos_socket *sock = obj; in nsos_connect() local
706 flags = nsos_adapt_fcntl_getfl(sock->poll.mid.fd); in nsos_connect()
709 ret = nsos_adapt_connect(sock->poll.mid.fd, addr_mid, addrlen_mid); in nsos_connect()
711 ret = nsos_connect_blocking(sock, addr_mid, addrlen_mid, flags); in nsos_connect()
725 struct nsos_socket *sock = obj; in nsos_listen() local
728 ret = nsos_adapt_listen(sock->poll.mid.fd, backlog); in nsos_listen()
800 struct nsos_socket *sock = obj; in nsos_sendto() local
819 ret = nsos_poll_if_blocking(sock, ZSOCK_POLLOUT, sock->send_timeout, flags); in nsos_sendto()
824 ret = nsos_adapt_sendto(sock->poll.mid.fd, buf, len, flags_mid, in nsos_sendto()
838 struct nsos_socket *sock = obj; in nsos_sendmsg() local
878 ret = nsos_poll_if_blocking(sock, ZSOCK_POLLOUT, sock->send_timeout, flags); in nsos_sendmsg()
883 ret = nsos_adapt_sendmsg(sock->poll.mid.fd, &msg_mid, flags_mid); in nsos_sendmsg()
900 struct nsos_socket *sock = obj; in nsos_recvfrom() local
914 ret = nsos_poll_if_blocking(sock, ZSOCK_POLLIN, sock->recv_timeout, flags); in nsos_recvfrom()
919 ret = nsos_adapt_recvfrom(sock->poll.mid.fd, buf, len, flags_mid, in nsos_recvfrom()
1023 static int nsos_getsockopt_int(struct nsos_socket *sock, int nsos_mid_level, int nsos_mid_optname, in nsos_getsockopt_int() argument
1034 err = nsos_adapt_getsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_getsockopt_int()
1049 struct nsos_socket *sock = obj; in nsos_getsockopt() local
1063 err = nsos_adapt_getsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_getsockopt()
1083 err = nsos_adapt_getsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_getsockopt()
1107 err = nsos_adapt_getsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_getsockopt()
1131 err = nsos_adapt_getsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_getsockopt()
1147 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1151 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1155 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1159 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1163 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1172 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1176 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1180 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1184 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1193 return nsos_getsockopt_int(sock, in nsos_getsockopt()
1204 static int nsos_setsockopt_int(struct nsos_socket *sock, int nsos_mid_level, int nsos_mid_optname, in nsos_setsockopt_int() argument
1214 err = nsos_adapt_setsockopt(sock->poll.mid.fd, nsos_mid_level, nsos_mid_optname, in nsos_setsockopt_int()
1227 struct nsos_socket *sock = obj; in nsos_setsockopt() local
1243 err = nsos_adapt_setsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_setsockopt()
1266 err = nsos_adapt_setsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_setsockopt()
1275 sock->recv_timeout = K_FOREVER; in nsos_setsockopt()
1277 sock->recv_timeout = K_USEC(tv->tv_sec * 1000000LL + tv->tv_usec); in nsos_setsockopt()
1295 err = nsos_adapt_setsockopt(sock->poll.mid.fd, NSOS_MID_SOL_SOCKET, in nsos_setsockopt()
1304 sock->send_timeout = K_FOREVER; in nsos_setsockopt()
1306 sock->send_timeout = K_USEC(tv->tv_sec * 1000000LL + tv->tv_usec); in nsos_setsockopt()
1312 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1316 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1320 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1324 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1328 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1332 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1341 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1345 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1349 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1353 return nsos_setsockopt_int(sock, in nsos_setsockopt()
1362 return nsos_setsockopt_int(sock, in nsos_setsockopt()