2019-09-18 05:20:38 -04:00
|
|
|
/* Copyright (C) 2019 Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LIBIGLOO__SOCKET_H_
|
|
|
|
#define _LIBIGLOO__SOCKET_H_
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Put a good description of this file here
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Put stuff here */
|
|
|
|
|
2019-09-18 14:40:59 -04:00
|
|
|
#include <igloo/config.h>
|
|
|
|
|
2019-09-25 11:29:39 -04:00
|
|
|
#ifdef IGLOO_CTC_HAVE_SYS_SELECT_H
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
|
|
|
#ifdef IGLOO_CTC_HAVE_POLL
|
|
|
|
#include <poll.h>
|
|
|
|
#endif
|
|
|
|
|
2019-09-18 14:40:59 -04:00
|
|
|
#include "types.h"
|
2019-09-18 19:16:44 -04:00
|
|
|
#include "socketaddr.h"
|
2019-09-18 05:20:38 -04:00
|
|
|
|
|
|
|
igloo_RO_FORWARD_TYPE(igloo_socket_t);
|
|
|
|
|
2019-09-18 14:40:59 -04:00
|
|
|
typedef enum {
|
|
|
|
igloo_SOCKET_SHUTDOWN_NONE = 0x0,
|
|
|
|
igloo_SOCKET_SHUTDOWN_RECEIVE = 0x1,
|
|
|
|
igloo_SOCKET_SHUTDOWN_SEND = 0x2,
|
|
|
|
igloo_SOCKET_SHUTDOWN_RECEIVESEND = igloo_SOCKET_SHUTDOWN_RECEIVE|igloo_SOCKET_SHUTDOWN_SEND
|
|
|
|
} igloo_socket_shutdown_t;
|
|
|
|
|
|
|
|
/* Advanced control functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
igloo_SOCKET_CONTROL_NONE = 0,
|
|
|
|
igloo_SOCKET_CONTROL_SET_NODELAY,
|
|
|
|
igloo_SOCKET_CONTROL_SET_SEND_BUFFER,
|
|
|
|
igloo_SOCKET_CONTROL_SET_RECEIVE_BUFFER
|
|
|
|
} igloo_socket_control_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
igloo_SOCKET_ADDRESSOP_CLEAR,
|
|
|
|
igloo_SOCKET_ADDRESSOP_ADD,
|
|
|
|
igloo_SOCKET_ADDRESSOP_REMOVE,
|
|
|
|
igloo_SOCKET_ADDRESSOP_REPLACE
|
|
|
|
} igloo_socket_addressop_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
igloo_SOCKET_ENDPOINT_LOCAL,
|
|
|
|
igloo_SOCKET_ENDPOINT_LOCAL_PHYSICAL,
|
|
|
|
igloo_SOCKET_ENDPOINT_LOCAL_LOGICAL,
|
|
|
|
igloo_SOCKET_ENDPOINT_PEER,
|
|
|
|
igloo_SOCKET_ENDPOINT_PEER_PHYSICAL,
|
|
|
|
igloo_SOCKET_ENDPOINT_PEER_LOGICAL
|
|
|
|
} igloo_socket_endpoint_t;
|
|
|
|
|
2019-09-25 11:29:39 -04:00
|
|
|
typedef enum {
|
|
|
|
igloo_SOCKET_ACTION_NONE = 0,
|
|
|
|
igloo_SOCKET_ACTION_CONNECT,
|
|
|
|
igloo_SOCKET_ACTION_ACCEPT
|
|
|
|
} igloo_socket_action_t;
|
|
|
|
|
2019-09-24 01:41:02 -04:00
|
|
|
igloo_socket_t * igloo_socket_new(igloo_socketaddr_domain_t domain, igloo_socketaddr_type_t type, igloo_socketaddr_protocol_t protocol, const char *name, igloo_ro_t associated, igloo_ro_t instance, igloo_error_t *error);
|
2019-09-24 01:39:23 -04:00
|
|
|
igloo_socket_t * igloo_socket_new_simple(igloo_socket_endpoint_t endpoint, igloo_socketaddr_t *addr, igloo_error_t *error);
|
2019-09-18 14:40:59 -04:00
|
|
|
igloo_error_t igloo_socket_alter_address(igloo_socket_t *sock, igloo_socket_addressop_t op, igloo_socket_endpoint_t endpoint, igloo_socketaddr_t *addr);
|
|
|
|
igloo_socketaddr_t * igloo_socket_get_main_address(igloo_socket_t *sock, igloo_socket_endpoint_t endpoint, igloo_error_t *error);
|
|
|
|
igloo_list_t * igloo_socket_get_address(igloo_socket_t *sock, igloo_socket_endpoint_t endpoint, igloo_error_t *error);
|
|
|
|
igloo_error_t igloo_socket_connect(igloo_socket_t *sock);
|
|
|
|
igloo_error_t igloo_socket_listen(igloo_socket_t *sock, ssize_t backlog);
|
|
|
|
igloo_error_t igloo_socket_shutdown(igloo_socket_t *sock, igloo_socket_shutdown_t how);
|
2019-09-25 02:52:38 -04:00
|
|
|
igloo_socket_t * igloo_socket_accept(igloo_socket_t *sock, const char *name, igloo_ro_t associated, igloo_error_t *error);
|
2019-09-18 14:40:59 -04:00
|
|
|
igloo_error_t igloo_socket_control(igloo_socket_t *sock, igloo_socket_control_t control, ...);
|
|
|
|
|
2019-09-25 11:29:39 -04:00
|
|
|
igloo_error_t igloo_socket_nonblocking(igloo_socket_t *sock, igloo_socket_action_t action);
|
|
|
|
#ifdef IGLOO_CTC_HAVE_SYS_SELECT_H
|
|
|
|
igloo_error_t igloo_socket_nonblocking_select_set(igloo_socket_t *sock, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int *maxfd);
|
|
|
|
igloo_error_t igloo_socket_nonblocking_select_clear(igloo_socket_t *sock, fd_set *readfds, fd_set *writefds, fd_set *exceptfds);
|
|
|
|
igloo_error_t igloo_socket_nonblocking_select_result(igloo_socket_t *sock, fd_set *readfds, fd_set *writefds, fd_set *exceptfds);
|
|
|
|
#endif
|
|
|
|
#ifdef IGLOO_CTC_HAVE_POLL
|
|
|
|
igloo_error_t igloo_socket_nonblocking_poll_fill(igloo_socket_t *sock, struct pollfd *fd);
|
|
|
|
igloo_error_t igloo_socket_nonblocking_poll_result(igloo_socket_t *sock, struct pollfd *fd);
|
|
|
|
#endif
|
2019-09-18 14:40:59 -04:00
|
|
|
|
2019-09-18 05:20:38 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-18 07:42:40 -04:00
|
|
|
#endif /* ! _LIBIGLOO__SOCKET_H_ */
|