X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Finet6.c;h=8c0d0b795c64ebf48f534427387443fbdcf2ba08;hb=7966af5763c4aaca39df9bbfa9277ff15715c720;hp=66a4b552f25e659589435485b7bd88eb609d1e07;hpb=1a65bbb8755fa1ae4a013bc1aa94c39297b8779e;p=lttng-tools.git diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c index 66a4b552f..8c0d0b795 100644 --- a/src/common/sessiond-comm/inet6.c +++ b/src/common/sessiond-comm/inet6.c @@ -1,22 +1,11 @@ /* - * Copyright (C) 2012 - David Goulet + * Copyright (C) 2012 David Goulet * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE -#include #include #include #include @@ -24,13 +13,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include "inet6.h" @@ -52,7 +41,6 @@ static const struct lttcomm_proto_ops inet6_ops = { /* * Creates an PF_INET socket. */ -LTTNG_HIDDEN int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type, int proto) { int val = 1, ret; @@ -95,22 +83,17 @@ error: /* * Bind socket and return. */ -LTTNG_HIDDEN int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock) { - return bind(sock->fd, - (const struct sockaddr *) ALIGNED_CONST_PTR( - sock->sockaddr.addr.sin6), - sizeof(sock->sockaddr.addr.sin6)); + struct sockaddr_in6 sockaddr = sock->sockaddr.addr.sin6; + return bind(sock->fd, &sockaddr, sizeof(sockaddr)); } static int connect_no_timeout(struct lttcomm_sock *sock) { - return connect(sock->fd, - (const struct sockaddr *) ALIGNED_CONST_PTR( - sock->sockaddr.addr.sin6), - sizeof(sock->sockaddr.addr.sin6)); + struct sockaddr_in6 sockaddr = sock->sockaddr.addr.sin6; + return connect(sock->fd, &sockaddr, sizeof(sockaddr)); } static @@ -120,6 +103,7 @@ int connect_with_timeout(struct lttcomm_sock *sock) int ret, flags, connect_ret; struct timespec orig_time, cur_time; unsigned long diff_ms; + struct sockaddr_in6 sockaddr; ret = fcntl(sock->fd, F_GETFL, 0); if (ret == -1) { @@ -141,10 +125,8 @@ int connect_with_timeout(struct lttcomm_sock *sock) return -1; } - connect_ret = connect(sock->fd, - (const struct sockaddr *) ALIGNED_CONST_PTR( - sock->sockaddr.addr.sin6), - sizeof(sock->sockaddr.addr.sin6)); + sockaddr = sock->sockaddr.addr.sin6; + connect_ret = connect(sock->fd, &sockaddr, sizeof(sockaddr)); if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINPROGRESS) { goto error; @@ -226,7 +208,6 @@ error: /* * Connect PF_INET socket. */ -LTTNG_HIDDEN int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock) { int ret, closeret; @@ -256,7 +237,6 @@ error_connect: * Do an accept(2) on the sock and return the new lttcomm socket. The socket * MUST be bind(2) before. */ -LTTNG_HIDDEN struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock) { int new_fd; @@ -300,7 +280,6 @@ error: /* * Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN. */ -LTTNG_HIDDEN int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog) { int ret; @@ -331,7 +310,6 @@ end: * * Return the size of received data. */ -LTTNG_HIDDEN ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags) { @@ -360,7 +338,7 @@ ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, } iov[0].iov_base += ret; iov[0].iov_len -= ret; - assert(ret <= len_last); + LTTNG_ASSERT(ret <= len_last); } } while ((ret > 0 && ret < len_last) || (ret < 0 && errno == EINTR)); if (ret < 0) { @@ -378,7 +356,6 @@ end: * * Return the size of sent data. */ -LTTNG_HIDDEN ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags) { @@ -425,7 +402,6 @@ ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, const void *buf, /* * Shutdown cleanly and close. */ -LTTNG_HIDDEN int lttcomm_close_inet6_sock(struct lttcomm_sock *sock) { int ret;