/*
* Creates an PF_INET socket.
*/
+__attribute__((visibility("hidden")))
int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type, int proto)
{
- int val, ret;
+ int val = 1, ret;
/* Create server socket */
if ((sock->fd = socket(PF_INET, type, proto)) < 0) {
/*
* Bind socket and return.
*/
+__attribute__((visibility("hidden")))
int lttcomm_bind_inet_sock(struct lttcomm_sock *sock)
{
int ret;
/*
* Connect PF_INET socket.
*/
+__attribute__((visibility("hidden")))
int lttcomm_connect_inet_sock(struct lttcomm_sock *sock)
{
int ret, closeret;
* Do an accept(2) on the sock and return the new lttcomm socket. The socket
* MUST be bind(2) before.
*/
+__attribute__((visibility("hidden")))
struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock)
{
int new_fd;
- socklen_t len = 0;
+ socklen_t len;
struct lttcomm_sock *new_sock;
if (sock->proto == LTTCOMM_SOCK_UDP) {
goto end;
}
- new_sock = lttcomm_alloc_sock(LTTCOMM_INET, sock->proto);
+ new_sock = lttcomm_alloc_sock(sock->proto);
if (new_sock == NULL) {
goto error;
}
+ len = sizeof(new_sock->sockaddr.addr.sin);
+
/* Blocking call */
new_fd = accept(sock->fd, (struct sockaddr *) &new_sock->sockaddr.addr.sin,
&len);
}
new_sock->fd = new_fd;
+ new_sock->ops = &inet_ops;
end:
return new_sock;
/*
* Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN.
*/
+__attribute__((visibility("hidden")))
int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog)
{
int ret;
*
* Return the size of received data.
*/
+__attribute__((visibility("hidden")))
ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
*
* Return the size of sent data.
*/
+__attribute__((visibility("hidden")))
ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
/*
* Shutdown cleanly and close.
*/
+__attribute__((visibility("hidden")))
int lttcomm_close_inet_sock(struct lttcomm_sock *sock)
{
- int ret, closeret;
+ int ret;
- /* Don't try to close an invalid mark socket */
+ /* Don't try to close an invalid marked socket */
if (sock->fd == -1) {
return 0;
}
- closeret = close(sock->fd);
- if (closeret) {
+ ret = close(sock->fd);
+ if (ret) {
PERROR("close inet");
}