2003-09-23 01:09:32 -07:00
|
|
|
#ifndef _ECORE_CON_PRIVATE_H
|
|
|
|
#define _ECORE_CON_PRIVATE_H
|
|
|
|
|
2008-10-30 08:26:11 -07:00
|
|
|
#include "ecore_private.h"
|
2006-11-05 08:49:55 -08:00
|
|
|
#include "Ecore_Con.h"
|
2005-09-05 03:17:08 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#define ECORE_MAGIC_CON_SERVER 0x77665544
|
|
|
|
#define ECORE_MAGIC_CON_CLIENT 0x77556677
|
2007-09-26 09:01:04 -07:00
|
|
|
#define ECORE_MAGIC_CON_URL 0x77074255
|
2003-09-23 01:09:32 -07:00
|
|
|
|
2008-01-08 13:06:43 -08:00
|
|
|
#define ECORE_CON_TYPE 0x0f
|
2012-06-04 02:16:19 -07:00
|
|
|
#define ECORE_CON_SSL 0xf0
|
|
|
|
#define ECORE_CON_SUPER_SSL 0xf00
|
2008-01-08 13:06:43 -08:00
|
|
|
|
2012-12-05 16:11:14 -08:00
|
|
|
#if HAVE_GNUTLS
|
2008-10-30 08:26:11 -07:00
|
|
|
# include <gnutls/gnutls.h>
|
2012-12-05 16:11:14 -08:00
|
|
|
#elif HAVE_OPENSSL
|
2008-10-30 08:26:11 -07:00
|
|
|
# include <openssl/ssl.h>
|
2004-03-31 08:47:45 -08:00
|
|
|
#endif
|
|
|
|
|
2016-10-30 10:40:54 -07:00
|
|
|
#ifdef HAVE_SYS_UN_H
|
|
|
|
#include <sys/un.h>
|
|
|
|
#endif
|
|
|
|
|
2016-11-22 04:01:46 -08:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
2004-04-03 07:03:33 -08:00
|
|
|
#define READBUFSIZ 65536
|
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
extern int _ecore_con_log_dom;
|
2010-01-06 16:30:05 -08:00
|
|
|
|
|
|
|
#ifdef ECORE_CON_DEFAULT_LOG_COLOR
|
|
|
|
#undef ECORE_LOG_DEFAULT_LOG_COLOR
|
|
|
|
#endif
|
|
|
|
#define ECORE_CON_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
|
|
|
|
|
2009-12-21 09:32:19 -08:00
|
|
|
#ifdef ERR
|
|
|
|
# undef ERR
|
|
|
|
#endif
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_ecore_con_log_dom, __VA_ARGS__)
|
|
|
|
|
|
|
|
#ifdef DBG
|
|
|
|
# undef DBG
|
|
|
|
#endif
|
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG(_ecore_con_log_dom, __VA_ARGS__)
|
|
|
|
|
|
|
|
#ifdef INF
|
|
|
|
# undef INF
|
|
|
|
#endif
|
|
|
|
#define INF(...) EINA_LOG_DOM_INFO(_ecore_con_log_dom, __VA_ARGS__)
|
|
|
|
|
|
|
|
#ifdef WRN
|
|
|
|
# undef WRN
|
|
|
|
#endif
|
|
|
|
#define WRN(...) EINA_LOG_DOM_WARN(_ecore_con_log_dom, __VA_ARGS__)
|
|
|
|
|
2013-12-25 19:22:05 -08:00
|
|
|
#ifdef CRI
|
|
|
|
# undef CRI
|
2009-12-21 09:32:19 -08:00
|
|
|
#endif
|
2013-12-25 19:22:05 -08:00
|
|
|
#define CRI(...) EINA_LOG_DOM_CRIT(_ecore_con_log_dom, __VA_ARGS__)
|
2009-12-21 09:32:19 -08:00
|
|
|
|
2010-07-22 04:32:55 -07:00
|
|
|
typedef struct _Ecore_Con_Lookup Ecore_Con_Lookup;
|
|
|
|
typedef struct _Ecore_Con_Info Ecore_Con_Info;
|
2012-02-14 21:53:50 -08:00
|
|
|
typedef struct Ecore_Con_Socks Ecore_Con_Socks_v4;
|
2011-12-05 19:32:16 -08:00
|
|
|
typedef struct Ecore_Con_Socks_v5 Ecore_Con_Socks_v5;
|
2010-07-22 04:32:55 -07:00
|
|
|
typedef void (*Ecore_Con_Info_Cb)(void *data, Ecore_Con_Info *infos);
|
|
|
|
|
2008-10-01 08:27:52 -07:00
|
|
|
typedef enum _Ecore_Con_State
|
2010-07-26 23:30:27 -07:00
|
|
|
{
|
|
|
|
ECORE_CON_CONNECTED,
|
|
|
|
ECORE_CON_DISCONNECTED,
|
|
|
|
ECORE_CON_INPROGRESS
|
|
|
|
} Ecore_Con_State;
|
2008-10-01 08:27:52 -07:00
|
|
|
|
2008-10-30 08:26:11 -07:00
|
|
|
typedef enum _Ecore_Con_Ssl_Error
|
2010-07-26 23:30:27 -07:00
|
|
|
{
|
|
|
|
ECORE_CON_SSL_ERROR_NONE = 0,
|
|
|
|
ECORE_CON_SSL_ERROR_NOT_SUPPORTED,
|
|
|
|
ECORE_CON_SSL_ERROR_INIT_FAILED,
|
|
|
|
ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED,
|
2015-11-02 14:11:09 -08:00
|
|
|
ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED,
|
|
|
|
ECORE_CON_SSL_ERROR_SSL3_NOT_SUPPORTED
|
2010-07-26 23:30:27 -07:00
|
|
|
} Ecore_Con_Ssl_Error;
|
2008-10-30 08:26:11 -07:00
|
|
|
|
2010-09-23 21:15:42 -07:00
|
|
|
typedef enum _Ecore_Con_Ssl_Handshake
|
|
|
|
{
|
|
|
|
ECORE_CON_SSL_STATE_DONE = 0,
|
|
|
|
ECORE_CON_SSL_STATE_HANDSHAKING,
|
|
|
|
ECORE_CON_SSL_STATE_INIT
|
|
|
|
} Ecore_Con_Ssl_State;
|
|
|
|
|
2012-02-14 21:53:50 -08:00
|
|
|
typedef enum Ecore_Con_Proxy_State
|
|
|
|
{ /* named PROXY instead of SOCKS in case some handsome and enterprising
|
|
|
|
* developer decides to add HTTP CONNECT support
|
|
|
|
*/
|
|
|
|
ECORE_CON_PROXY_STATE_DONE = 0,
|
|
|
|
ECORE_CON_PROXY_STATE_RESOLVED,
|
|
|
|
ECORE_CON_PROXY_STATE_INIT,
|
|
|
|
ECORE_CON_PROXY_STATE_READ,
|
|
|
|
ECORE_CON_PROXY_STATE_AUTH,
|
|
|
|
ECORE_CON_PROXY_STATE_REQUEST,
|
|
|
|
ECORE_CON_PROXY_STATE_CONFIRM,
|
|
|
|
} Ecore_Con_Proxy_State;
|
2011-12-05 19:32:16 -08:00
|
|
|
|
2016-02-12 12:02:01 -08:00
|
|
|
struct _Efl_Network_Client_Data
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2015-01-30 02:03:00 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
SOCKET fd;
|
|
|
|
#else
|
2010-07-26 23:30:27 -07:00
|
|
|
int fd;
|
2015-01-30 02:03:00 -08:00
|
|
|
#endif
|
2010-09-18 12:26:05 -07:00
|
|
|
Ecore_Con_Server *host_server;
|
2010-07-26 23:30:27 -07:00
|
|
|
void *data;
|
2003-09-23 01:09:32 -07:00
|
|
|
Ecore_Fd_Handler *fd_handler;
|
2014-04-04 03:35:16 -07:00
|
|
|
size_t buf_offset;
|
2011-07-16 06:07:39 -07:00
|
|
|
Eina_Binbuf *buf;
|
2010-11-16 13:32:50 -08:00
|
|
|
const char *ip;
|
2011-11-10 18:44:16 -08:00
|
|
|
Eina_List *event_count;
|
2010-07-26 23:30:27 -07:00
|
|
|
struct sockaddr *client_addr;
|
|
|
|
int client_addr_len;
|
2010-09-21 21:48:09 -07:00
|
|
|
double start_time;
|
|
|
|
Ecore_Timer *until_deletion;
|
|
|
|
double disconnect_time;
|
2012-12-05 16:11:14 -08:00
|
|
|
#if HAVE_GNUTLS
|
2010-09-23 23:54:49 -07:00
|
|
|
gnutls_datum_t session_ticket;
|
|
|
|
gnutls_session_t session;
|
2012-12-05 16:11:14 -08:00
|
|
|
#elif HAVE_OPENSSL
|
2010-07-26 23:30:27 -07:00
|
|
|
SSL *ssl;
|
|
|
|
int ssl_err;
|
2008-10-30 08:26:11 -07:00
|
|
|
#endif
|
2010-09-23 21:15:42 -07:00
|
|
|
Ecore_Con_Ssl_State ssl_state;
|
2011-06-15 11:58:34 -07:00
|
|
|
Eina_Bool handshaking : 1;
|
2011-12-21 02:02:30 -08:00
|
|
|
Eina_Bool upgrade : 1; /* STARTTLS queued */
|
|
|
|
Eina_Bool delete_me : 1; /* del event has been queued */
|
2003-09-23 01:09:32 -07:00
|
|
|
};
|
|
|
|
|
2016-02-12 12:02:01 -08:00
|
|
|
typedef struct _Efl_Network_Client_Data Efl_Network_Client_Data;
|
2014-08-22 05:14:59 -07:00
|
|
|
|
2016-02-04 23:09:53 -08:00
|
|
|
struct _Efl_Network_Server_Data
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2015-01-30 02:03:00 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
SOCKET fd;
|
|
|
|
#else
|
2010-07-26 23:30:27 -07:00
|
|
|
int fd;
|
2015-01-30 02:03:00 -08:00
|
|
|
#endif
|
2010-07-26 23:30:27 -07:00
|
|
|
Ecore_Con_Type type;
|
|
|
|
char *name;
|
|
|
|
int port;
|
|
|
|
char *path;
|
|
|
|
void *data;
|
2003-09-23 01:09:32 -07:00
|
|
|
Ecore_Fd_Handler *fd_handler;
|
2010-07-26 23:30:27 -07:00
|
|
|
Eina_List *clients;
|
2010-09-20 12:31:11 -07:00
|
|
|
unsigned int client_count;
|
2011-07-16 06:07:39 -07:00
|
|
|
Eina_Binbuf *buf;
|
2014-04-04 03:35:16 -07:00
|
|
|
size_t write_buf_offset;
|
2011-01-21 02:01:04 -08:00
|
|
|
Eina_List *infos;
|
2011-11-10 18:44:16 -08:00
|
|
|
Eina_List *event_count;
|
2010-07-26 23:30:27 -07:00
|
|
|
int client_limit;
|
|
|
|
pid_t ppid;
|
2011-12-05 19:32:16 -08:00
|
|
|
/* socks */
|
|
|
|
Ecore_Con_Socks *ecs;
|
2012-02-14 21:53:50 -08:00
|
|
|
Ecore_Con_Proxy_State ecs_state;
|
2011-12-05 19:32:16 -08:00
|
|
|
int ecs_addrlen;
|
|
|
|
unsigned char ecs_addr[16];
|
2014-04-04 03:35:16 -07:00
|
|
|
size_t ecs_buf_offset;
|
2011-12-05 19:32:16 -08:00
|
|
|
Eina_Binbuf *ecs_buf;
|
|
|
|
Eina_Binbuf *ecs_recvbuf;
|
|
|
|
const char *proxyip;
|
|
|
|
int proxyport;
|
|
|
|
/* endsocks */
|
2011-12-07 17:14:55 -08:00
|
|
|
const char *verify_name;
|
2012-12-05 16:11:14 -08:00
|
|
|
#if HAVE_GNUTLS
|
2010-09-23 23:54:49 -07:00
|
|
|
gnutls_session_t session;
|
2008-10-30 08:26:11 -07:00
|
|
|
gnutls_anon_client_credentials_t anoncred_c;
|
|
|
|
gnutls_anon_server_credentials_t anoncred_s;
|
2010-09-21 17:10:10 -07:00
|
|
|
gnutls_psk_client_credentials_t pskcred_c;
|
|
|
|
gnutls_psk_server_credentials_t pskcred_s;
|
2010-07-26 23:30:27 -07:00
|
|
|
gnutls_certificate_credentials_t cert;
|
2010-09-27 20:16:08 -07:00
|
|
|
char *cert_file;
|
2010-09-19 12:25:47 -07:00
|
|
|
gnutls_dh_params_t dh_params;
|
2012-12-05 16:11:14 -08:00
|
|
|
#elif HAVE_OPENSSL
|
2010-07-26 23:30:27 -07:00
|
|
|
SSL_CTX *ssl_ctx;
|
|
|
|
SSL *ssl;
|
|
|
|
int ssl_err;
|
2004-03-31 08:47:45 -08:00
|
|
|
#endif
|
2010-09-21 21:48:09 -07:00
|
|
|
double start_time;
|
2011-06-17 04:16:50 -07:00
|
|
|
Ecore_Timer *until_deletion;
|
|
|
|
double disconnect_time;
|
2010-09-21 21:48:09 -07:00
|
|
|
double client_disconnect_time;
|
2010-11-16 13:32:50 -08:00
|
|
|
const char *ip;
|
2012-04-11 20:51:36 -07:00
|
|
|
Eina_Bool created : 1; /* @c EINA_TRUE if server is our listening server */
|
|
|
|
Eina_Bool connecting : 1; /* @c EINA_FALSE if just initialized or connected */
|
|
|
|
Eina_Bool handshaking : 1; /* @c EINA_TRUE if server is ssl handshaking */
|
2011-12-21 02:02:30 -08:00
|
|
|
Eina_Bool upgrade : 1; /* STARTTLS queued */
|
2012-06-04 02:03:04 -07:00
|
|
|
Eina_Bool disable_proxy : 1; /* proxy should never be used with this connection */
|
2011-06-15 11:58:34 -07:00
|
|
|
Eina_Bool ssl_prepared : 1;
|
2012-04-11 20:51:36 -07:00
|
|
|
Eina_Bool use_cert : 1; /* @c EINA_TRUE if using certificate auth */
|
2010-09-27 20:16:08 -07:00
|
|
|
Ecore_Con_Ssl_State ssl_state; /* current state of ssl handshake on the server */
|
2012-04-11 20:51:36 -07:00
|
|
|
Eina_Bool verify : 1; /* @c EINA_TRUE if certificates will be verified */
|
|
|
|
Eina_Bool verify_basic : 1; /* @c EINA_TRUE if certificates will be verified only against the hostname */
|
2010-09-17 23:30:13 -07:00
|
|
|
Eina_Bool reject_excess_clients : 1;
|
2011-12-21 02:02:30 -08:00
|
|
|
Eina_Bool delete_me : 1; /* del event has been queued */
|
2011-05-14 10:52:30 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
Eina_Bool want_write : 1;
|
|
|
|
Eina_Bool read_stop : 1;
|
|
|
|
Eina_Bool read_stopped : 1;
|
|
|
|
HANDLE pipe;
|
|
|
|
HANDLE thread_read;
|
|
|
|
HANDLE event_read;
|
|
|
|
HANDLE event_peek;
|
|
|
|
DWORD nbr_bytes;
|
|
|
|
#endif
|
2003-09-23 01:09:32 -07:00
|
|
|
};
|
|
|
|
|
2016-02-04 23:09:53 -08:00
|
|
|
typedef struct _Efl_Network_Server_Data Efl_Network_Server_Data;
|
2014-08-22 08:06:27 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
struct _Ecore_Con_Info
|
|
|
|
{
|
2010-07-26 23:30:27 -07:00
|
|
|
unsigned int size;
|
2008-10-09 05:30:19 -07:00
|
|
|
struct addrinfo info;
|
2010-07-26 23:30:27 -07:00
|
|
|
char ip[NI_MAXHOST];
|
|
|
|
char service[NI_MAXSERV];
|
2008-10-09 05:30:19 -07:00
|
|
|
};
|
|
|
|
|
2010-07-22 04:32:55 -07:00
|
|
|
struct _Ecore_Con_Lookup
|
|
|
|
{
|
|
|
|
Ecore_Con_Dns_Cb done_cb;
|
|
|
|
const void *data;
|
|
|
|
};
|
|
|
|
|
2012-02-14 21:53:50 -08:00
|
|
|
struct Ecore_Con_Socks /* v4 */
|
2011-12-05 19:32:16 -08:00
|
|
|
{
|
|
|
|
unsigned char version;
|
|
|
|
|
|
|
|
const char *ip;
|
|
|
|
int port;
|
|
|
|
const char *username;
|
2012-02-14 21:53:50 -08:00
|
|
|
unsigned int ulen;
|
2011-12-05 19:32:16 -08:00
|
|
|
Eina_Bool lookup : 1;
|
|
|
|
Eina_Bool bind : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Ecore_Con_Socks_v5
|
|
|
|
{
|
|
|
|
unsigned char version;
|
|
|
|
|
|
|
|
const char *ip;
|
|
|
|
int port;
|
|
|
|
const char *username;
|
2012-02-14 21:53:50 -08:00
|
|
|
unsigned int ulen;
|
2011-12-05 19:32:16 -08:00
|
|
|
Eina_Bool lookup : 1;
|
|
|
|
Eina_Bool bind : 1;
|
2012-02-14 21:53:50 -08:00
|
|
|
/* v5 only */
|
|
|
|
unsigned char method;
|
|
|
|
const char *password;
|
|
|
|
unsigned int plen;
|
2011-12-05 19:32:16 -08:00
|
|
|
};
|
|
|
|
|
2013-03-09 22:49:54 -08:00
|
|
|
#ifdef HAVE_SYSTEMD
|
|
|
|
extern int sd_fd_index;
|
|
|
|
extern int sd_fd_max;
|
|
|
|
#endif
|
|
|
|
|
2016-09-20 11:00:17 -07:00
|
|
|
/* init must be called from main thread */
|
|
|
|
Eina_Bool ecore_con_libproxy_init(void);
|
|
|
|
void ecore_con_libproxy_proxies_free(char **proxies);
|
|
|
|
/* BLOCKING! should be called from a worker thread */
|
|
|
|
char **ecore_con_libproxy_proxies_get(const char *url);
|
|
|
|
|
2016-09-18 23:19:16 -07:00
|
|
|
|
2011-12-05 19:32:16 -08:00
|
|
|
extern Ecore_Con_Socks *_ecore_con_proxy_once;
|
|
|
|
extern Ecore_Con_Socks *_ecore_con_proxy_global;
|
|
|
|
void ecore_con_socks_init(void);
|
|
|
|
void ecore_con_socks_shutdown(void);
|
|
|
|
Eina_Bool ecore_con_socks_svr_init(Ecore_Con_Server *svr);
|
|
|
|
void ecore_con_socks_read(Ecore_Con_Server *svr, unsigned char *buf, int num);
|
|
|
|
void ecore_con_socks_dns_cb(const char *canonname, const char *ip, struct sockaddr *addr, int addrlen, Ecore_Con_Server *svr);
|
2015-05-14 00:15:41 -07:00
|
|
|
|
2011-01-21 02:01:04 -08:00
|
|
|
/* from ecore_con.c */
|
|
|
|
void ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info);
|
2011-12-05 19:32:16 -08:00
|
|
|
void ecore_con_event_proxy_bind(Ecore_Con_Server *svr);
|
2011-05-14 10:52:30 -07:00
|
|
|
void ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num, Eina_Bool duplicate);
|
|
|
|
void ecore_con_event_server_del(Ecore_Con_Server *svr);
|
2011-12-09 21:09:47 -08:00
|
|
|
#define ecore_con_event_server_error(svr, error) _ecore_con_event_server_error((svr), (char*)(error), EINA_TRUE)
|
|
|
|
void _ecore_con_event_server_error(Ecore_Con_Server *svr, char *error, Eina_Bool duplicate);
|
2011-05-14 10:52:30 -07:00
|
|
|
void ecore_con_event_client_add(Ecore_Con_Client *cl);
|
|
|
|
void ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate);
|
|
|
|
void ecore_con_event_client_del(Ecore_Con_Client *cl);
|
2011-02-10 00:49:23 -08:00
|
|
|
void ecore_con_event_client_error(Ecore_Con_Client *cl, const char *error);
|
2011-12-05 19:32:16 -08:00
|
|
|
void _ecore_con_server_kill(Ecore_Con_Server *svr);
|
2012-01-19 00:02:41 -08:00
|
|
|
void _ecore_con_client_kill(Ecore_Con_Client *cl);
|
2015-05-14 00:15:41 -07:00
|
|
|
|
|
|
|
int ecore_con_local_init(void);
|
|
|
|
int ecore_con_local_shutdown(void);
|
2011-05-14 10:52:30 -07:00
|
|
|
/* from ecore_local_win32.c */
|
|
|
|
#ifdef _WIN32
|
|
|
|
Eina_Bool ecore_con_local_listen(Ecore_Con_Server *svr);
|
|
|
|
Eina_Bool ecore_con_local_connect(Ecore_Con_Server *svr,
|
|
|
|
Eina_Bool (*cb_done)(void *data,
|
2011-07-04 17:06:27 -07:00
|
|
|
Ecore_Fd_Handler *fd_handler));
|
2011-05-14 10:52:30 -07:00
|
|
|
Eina_Bool ecore_con_local_win32_server_flush(Ecore_Con_Server *svr);
|
|
|
|
Eina_Bool ecore_con_local_win32_client_flush(Ecore_Con_Client *cl);
|
|
|
|
void ecore_con_local_win32_server_del(Ecore_Con_Server *svr);
|
|
|
|
void ecore_con_local_win32_client_del(Ecore_Con_Client *cl);
|
|
|
|
#else
|
2010-01-04 11:35:21 -08:00
|
|
|
/* from ecore_local.c */
|
2010-07-26 23:30:27 -07:00
|
|
|
int ecore_con_local_connect(Ecore_Con_Server *svr,
|
|
|
|
Eina_Bool (*cb_done)(
|
|
|
|
void *data,
|
|
|
|
Ecore_Fd_Handler *fd_handler),
|
2011-07-04 17:06:27 -07:00
|
|
|
void *data);
|
2010-07-26 23:30:27 -07:00
|
|
|
int ecore_con_local_listen(Ecore_Con_Server *svr,
|
|
|
|
Eina_Bool (*cb_listen)(
|
|
|
|
void *data,
|
|
|
|
Ecore_Fd_Handler *fd_handler),
|
|
|
|
void *data);
|
2011-05-14 10:52:30 -07:00
|
|
|
#endif
|
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
/* from ecore_con_info.c */
|
2010-07-26 23:30:27 -07:00
|
|
|
int ecore_con_info_init(void);
|
|
|
|
int ecore_con_info_shutdown(void);
|
|
|
|
int ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
|
|
|
Ecore_Con_Info_Cb done_cb,
|
|
|
|
void *data);
|
|
|
|
int ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
|
|
|
Ecore_Con_Info_Cb done_cb,
|
|
|
|
void *data);
|
|
|
|
int ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
|
|
|
Ecore_Con_Info_Cb done_cb,
|
|
|
|
void *data);
|
|
|
|
int ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
|
|
|
Ecore_Con_Info_Cb done_cb,
|
|
|
|
void *data);
|
|
|
|
int ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
|
|
|
Ecore_Con_Info_Cb done_cb,
|
|
|
|
void *data);
|
2011-01-21 02:01:04 -08:00
|
|
|
void ecore_con_info_data_clear(void *info);
|
|
|
|
|
2011-07-04 17:06:27 -07:00
|
|
|
void ecore_con_event_server_add(Ecore_Con_Server *svr);
|
|
|
|
|
|
|
|
|
2008-10-30 08:26:11 -07:00
|
|
|
/* from ecore_con_ssl.c */
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_init(void);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_shutdown(void);
|
2010-09-18 12:26:05 -07:00
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_server_prepare(Ecore_Con_Server *svr, int ssl_type);
|
2008-12-15 09:59:19 -08:00
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_server_init(Ecore_Con_Server *svr);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr);
|
2010-07-26 23:30:27 -07:00
|
|
|
int ecore_con_ssl_server_read(Ecore_Con_Server *svr,
|
|
|
|
unsigned char *buf,
|
|
|
|
int size);
|
|
|
|
int ecore_con_ssl_server_write(Ecore_Con_Server *svr,
|
2011-07-16 06:07:39 -07:00
|
|
|
const unsigned char *buf,
|
2010-07-26 23:30:27 -07:00
|
|
|
int size);
|
2008-12-15 09:59:19 -08:00
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_client_init(Ecore_Con_Client *svr);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_client_shutdown(Ecore_Con_Client *svr);
|
2010-07-26 23:30:27 -07:00
|
|
|
int ecore_con_ssl_client_read(Ecore_Con_Client *svr,
|
|
|
|
unsigned char *buf,
|
|
|
|
int size);
|
|
|
|
int ecore_con_ssl_client_write(Ecore_Con_Client *svr,
|
2011-07-16 06:07:39 -07:00
|
|
|
const unsigned char *buf,
|
2010-07-26 23:30:27 -07:00
|
|
|
int size);
|
|
|
|
|
|
|
|
int ecore_con_info_get(Ecore_Con_Server *svr,
|
|
|
|
Ecore_Con_Info_Cb done_cb,
|
|
|
|
void *data,
|
|
|
|
struct addrinfo *hints);
|
2010-07-22 04:32:55 -07:00
|
|
|
|
|
|
|
|
2011-11-06 04:26:00 -08:00
|
|
|
#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
|
|
|
|
TYPE *Type##_alloc(void); \
|
|
|
|
void Type##_free(TYPE *e);
|
|
|
|
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Del, ecore_con_event_client_del);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Write, ecore_con_event_client_write);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Data, ecore_con_event_client_data);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Error, ecore_con_event_server_error);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Error, ecore_con_event_client_error);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Add, ecore_con_event_server_add);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Del, ecore_con_event_server_del);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Write, ecore_con_event_server_write);
|
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Data, ecore_con_event_server_data);
|
2011-12-05 19:32:16 -08:00
|
|
|
GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind);
|
2011-11-06 04:26:00 -08:00
|
|
|
|
|
|
|
void ecore_con_mempool_init(void);
|
|
|
|
void ecore_con_mempool_shutdown(void);
|
|
|
|
|
|
|
|
#undef GENERIC_ALLOC_FREE_HEADER
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2016-10-22 08:15:16 -07:00
|
|
|
/* allow windows and posix to use the same error comparison */
|
|
|
|
#ifndef SOCKET_ERROR
|
|
|
|
#define SOCKET_ERROR -1
|
|
|
|
#endif
|
|
|
|
#ifndef INVALID_SOCKET
|
|
|
|
#define INVALID_SOCKET -1
|
|
|
|
#endif
|
2016-11-18 06:17:08 -08:00
|
|
|
#ifndef SOCKET_TO_LOOP_FD
|
|
|
|
#define SOCKET_TO_LOOP_FD(sock) ((int)sock)
|
|
|
|
#endif
|
2016-10-22 16:49:01 -07:00
|
|
|
#ifndef _WIN32
|
|
|
|
#define closesocket(fd) close(fd)
|
|
|
|
#define SOCKET int
|
2016-11-18 06:17:08 -08:00
|
|
|
#define SOCKET_FMT "%d"
|
|
|
|
#else
|
2016-11-22 04:01:46 -08:00
|
|
|
#define SOCKET_FMT "%"PRIuPTR
|
2016-11-18 06:17:08 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This define will force SOCKET to be 'unsigned long', this will
|
|
|
|
* force compile to emit errors when assuming "int"/"%d", which is the
|
|
|
|
* case on UNIX but not on Windows.
|
|
|
|
*/
|
|
|
|
//#define EFL_NET_CHECK_SOCKET_TYPE 1
|
|
|
|
#if EFL_NET_CHECK_SOCKET_TYPE
|
|
|
|
#undef SOCKET
|
|
|
|
#undef SOCKET_FMT
|
|
|
|
#undef INVALID_SOCKET
|
|
|
|
#define SOCKET unsigned long
|
|
|
|
#define SOCKET_FMT "%lu"
|
|
|
|
#define INVALID_SOCKET ((SOCKET)-1)
|
2016-10-22 16:49:01 -07:00
|
|
|
#endif
|
2016-10-22 08:15:16 -07:00
|
|
|
|
2016-10-22 16:19:56 -07:00
|
|
|
/* some platforms do not have AI_V4MAPPED, then define to 0 so bitwise OR won't be changed */
|
|
|
|
#ifndef AI_V4MAPPED
|
|
|
|
#define AI_V4MAPPED 0
|
|
|
|
#endif
|
2016-11-18 06:20:57 -08:00
|
|
|
#ifndef AI_ADDRCONFIG
|
|
|
|
#define AI_ADDRCONFIG 0
|
|
|
|
#endif
|
2016-10-22 16:19:56 -07:00
|
|
|
|
2016-11-18 06:27:15 -08:00
|
|
|
/* Windows do not define EAI_SYSTEM, so just define to some number
|
|
|
|
* that won't be matched, effectively disabling the subsequent
|
|
|
|
* checks/usage
|
|
|
|
*/
|
|
|
|
#ifndef EAI_SYSTEM
|
|
|
|
#define EAI_SYSTEM 254 /* number that won't match anything in EAI_* */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2016-10-24 14:47:15 -07:00
|
|
|
void _efl_net_server_udp_client_init(Eo *client, SOCKET fd, const struct sockaddr *addr, socklen_t addrlen, const char *str);
|
2016-10-22 16:49:01 -07:00
|
|
|
void _efl_net_server_udp_client_feed(Eo *client, Eina_Rw_Slice slice);
|
|
|
|
|
2016-10-25 05:03:34 -07:00
|
|
|
void _efl_net_socket_udp_init(Eo *o, const struct sockaddr *addr, socklen_t addrlen, const char *str);
|
|
|
|
|
2016-10-27 04:01:19 -07:00
|
|
|
#ifndef _WIN32
|
2016-10-26 13:57:37 -07:00
|
|
|
Eina_Bool efl_net_unix_fmt(char *buf, size_t buflen, SOCKET fd, const struct sockaddr_un *addr, socklen_t addrlen);
|
2016-10-27 04:01:19 -07:00
|
|
|
#endif
|
2016-10-26 13:57:37 -07:00
|
|
|
Eina_Bool efl_net_ip_port_fmt(char *buf, size_t buflen, const struct sockaddr *addr);
|
2016-10-22 16:49:01 -07:00
|
|
|
|
2016-11-01 11:01:57 -07:00
|
|
|
#ifdef HAVE_SYSTEMD
|
|
|
|
/**
|
|
|
|
* Checks if the next FD in the sd_fd_index:sd_fd_max is of the
|
|
|
|
* expected family, protocol and if it's listening.
|
|
|
|
*
|
|
|
|
* This is similar to sd_is_socket()/sd_is_socket_inet(), but will
|
|
|
|
* also parse address in our standard format "IP:PORT", including IPv6
|
|
|
|
* within braces, and then will validate the address with
|
|
|
|
* getsockaddr() for INET.
|
|
|
|
*
|
|
|
|
* @param address the address to validate
|
|
|
|
* @param family AF_UNIX or AF_UNSPEC for INET, in that case AF_INET
|
|
|
|
* or AF_INET6 will be inferred from @a address.
|
|
|
|
* @param type SOCK_STREAM or SOCK_DGRAM
|
|
|
|
* @param[out] listening where to return listening state, should be
|
|
|
|
* NULL for @a type SOCK_DGRAM
|
|
|
|
*
|
|
|
|
* @return 0 on success, error otherwise.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_ip_socket_activate_check(const char *address, int family, int type, Eina_Bool *listening);
|
|
|
|
#endif
|
|
|
|
|
2016-09-09 16:09:51 -07:00
|
|
|
/**
|
|
|
|
* @brief splits an address in the format "host:port" in two
|
|
|
|
* null-terminated strings.
|
|
|
|
*
|
|
|
|
* The address may be 'server.com:1234', 'server.com:http',
|
|
|
|
* 'server.com' (@c *p_port will be NULL), IPv4 127.0.0.1:456 or
|
|
|
|
* IPv6 [::1]:456
|
|
|
|
*
|
|
|
|
* @param[inout] buf contains the string to be split and will be modified.
|
|
|
|
* @param[out] p_host returns a pointer inside @a buf with
|
|
|
|
* null-terminated host part.
|
|
|
|
* @param[out] p_port returns a pointer with null-terminated port
|
|
|
|
* part. The pointer may be inside @a buf if port was
|
|
|
|
* specified or #NULL if it wasn't specified.
|
|
|
|
*
|
|
|
|
* @return #EINA_TRUE on success, #EINA_FALSE on errors.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Bool efl_net_ip_port_split(char *buf, const char **p_host, const char **p_port);
|
|
|
|
|
2016-10-22 16:49:01 -07:00
|
|
|
SOCKET efl_net_socket4(int domain, int type, int protocol, Eina_Bool close_on_exec);
|
2016-08-24 08:34:59 -07:00
|
|
|
|
2016-10-20 19:15:09 -07:00
|
|
|
/**
|
|
|
|
* @brief callback to notify of resolved address.
|
|
|
|
*
|
|
|
|
* The callback is given the ownership of the result, thus must free
|
|
|
|
* it with freeaddrinfo().
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
typedef void (*Efl_Net_Ip_Resolve_Async_Cb)(void *data, const char *host, const char *port, const struct addrinfo *hints, struct addrinfo *result, int gai_error);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief asynchronously resolve a host and port using getaddrinfo().
|
|
|
|
*
|
|
|
|
* This will call getaddrinfo() in a thread, taking care to return the
|
|
|
|
* result to the main loop and calling @a cb with given user @a data.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Ecore_Thread *efl_net_ip_resolve_async_new(const char *host, const char *port, const struct addrinfo *hints, Efl_Net_Ip_Resolve_Async_Cb cb, const void *data);
|
|
|
|
|
2016-09-09 16:09:51 -07:00
|
|
|
/**
|
|
|
|
* @brief callback to notify of connection.
|
|
|
|
*
|
|
|
|
* The callback is given the ownership of the socket (sockfd), thus
|
|
|
|
* must close().
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
2016-11-18 06:17:08 -08:00
|
|
|
typedef void (*Efl_Net_Connect_Async_Cb)(void *data, const struct sockaddr *addr, socklen_t addrlen, SOCKET sockfd, Eina_Error error);
|
2016-09-09 16:09:51 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief asynchronously create a socket and connect to the address.
|
|
|
|
*
|
|
|
|
* This will call socket() and connect() in a thread, taking care to
|
|
|
|
* return the result to the main loop and calling @a cb with given
|
|
|
|
* user @a data.
|
|
|
|
*
|
efl_net_dialer_tcp: add SOCKS proxy support.
SOCKS is implemented in its own thread using synchronous/blocking
primitives, which simplifies the code a lot -- as well as simulate the
usage of Ecore_Thread as our users will likely do.
Since SOCKSv4a and SOCKSv5 allow name resolution, the whole
getaddrinfo() is done in the same thread, when needed, instead of a
separate thread to do that, which should also save some resources.
Instead of the legacy ECORE_CON_SOCKS_V4 and ECORE_CON_SOCKS_V5, now
we use socks_proxy, all_proxy and no_proxy. This matches our other
dialers http/websocket (which will use http_proxy, all_proxy and
no_proxy). If desired it's easy to add back support for those
variables, but I think we should just deprecate them. (The legacy code
will keep unchanged, thus direct users of ecore_con_server will still
use those -- just the previous users of ecore_con_server will be
converted to use the new API).
2016-09-18 20:56:18 -07:00
|
|
|
* For name resolution and proxy support use
|
|
|
|
* efl_net_ip_connect_async_new()
|
|
|
|
*
|
2016-09-09 16:09:51 -07:00
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Ecore_Thread *efl_net_connect_async_new(const struct sockaddr *addr, socklen_t addrlen, int type, int protocol, Eina_Bool close_on_exec, Efl_Net_Connect_Async_Cb cb, const void *data);
|
|
|
|
|
efl_net_dialer_tcp: add SOCKS proxy support.
SOCKS is implemented in its own thread using synchronous/blocking
primitives, which simplifies the code a lot -- as well as simulate the
usage of Ecore_Thread as our users will likely do.
Since SOCKSv4a and SOCKSv5 allow name resolution, the whole
getaddrinfo() is done in the same thread, when needed, instead of a
separate thread to do that, which should also save some resources.
Instead of the legacy ECORE_CON_SOCKS_V4 and ECORE_CON_SOCKS_V5, now
we use socks_proxy, all_proxy and no_proxy. This matches our other
dialers http/websocket (which will use http_proxy, all_proxy and
no_proxy). If desired it's easy to add back support for those
variables, but I think we should just deprecate them. (The legacy code
will keep unchanged, thus direct users of ecore_con_server will still
use those -- just the previous users of ecore_con_server will be
converted to use the new API).
2016-09-18 20:56:18 -07:00
|
|
|
/**
|
|
|
|
* @brief asynchronously create a socket and connect to the IP address.
|
|
|
|
*
|
|
|
|
* This wil resolve the address using getaddrinfo(), create a socket
|
|
|
|
* and connect in a thread.
|
|
|
|
*
|
|
|
|
* If a @a proxy is given, then it's always used. Otherwise the
|
|
|
|
* environment variable @a proxy_env is used unless it matches @a
|
|
|
|
* no_proxy_env. Some systems may do special queries for proxy from
|
|
|
|
* the thread.
|
|
|
|
*
|
|
|
|
* @param address the host:port to connect. Host may be a name or an
|
|
|
|
* IP address, IPv6 addresses should be enclosed in braces.
|
|
|
|
* @param proxy a mandatory proxy to use. If "" (empty string), it's
|
|
|
|
* disabled. If NULL, then @a proxy_env is used unless it
|
|
|
|
* matches @a no_proxy_env.
|
|
|
|
* @param proxy_env if @a proxy is NULL, then this will be used as the
|
|
|
|
* proxy unless it matches @a no_proxy_env.
|
|
|
|
* @param no_proxy_env a comma-separated list of matches that will
|
|
|
|
* avoid using @a proxy_env. "server.com" will inhibit proxy
|
|
|
|
* for "server.com", "host.server.com" but not "xserver.com".
|
|
|
|
* @param type the socket type, such as SOCK_STREAM or SOCK_DGRAM.
|
|
|
|
* @param protocol the socket protocol, such as IPPROTO_TCP.
|
|
|
|
* @param close_on_exec if EINA_TRUE, will set SOCK_CLOEXEC.
|
|
|
|
* @param cb the callback to report connection
|
|
|
|
* @param data data to give to callback
|
|
|
|
*
|
|
|
|
* @return an Ecore_Thread that will execute the connection.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Ecore_Thread *efl_net_ip_connect_async_new(const char *address, const char *proxy, const char *proxy_env, const char *no_proxy_env, int type, int protocol, Eina_Bool close_on_exec, Efl_Net_Connect_Async_Cb cb, const void *data);
|
|
|
|
|
2016-09-08 12:12:18 -07:00
|
|
|
static inline Eina_Error
|
|
|
|
efl_net_socket_error_get(void)
|
|
|
|
{
|
|
|
|
#ifndef _WIN32
|
|
|
|
return errno;
|
|
|
|
#else
|
|
|
|
Eina_Error err = WSAGetLastError();
|
|
|
|
|
|
|
|
if (0) { }
|
|
|
|
|
|
|
|
/* used by send() */
|
|
|
|
#if defined(WSAEACCES) && (WSAEACCES != EACCES)
|
|
|
|
else if (err == WSAEACCES) err = EACCES;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEWOULDBLOCK) && (WSAEWOULDBLOCK != EAGAIN)
|
|
|
|
else if (err == WSAEWOULDBLOCK) err = EAGAIN;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEBADF) && (WSAEBADF != EBADF)
|
|
|
|
else if (err == WSAEBADF) err = EBADF;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAECONNRESET) && (WSAECONNRESET != ECONNRESET)
|
|
|
|
else if (err == WSAECONNRESET) err = ECONNRESET;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEDESTADDRREQ) && (WSAEDESTADDRREQ != EDESTADDRREQ)
|
|
|
|
else if (err == WSAEDESTADDRREQ) err = EDESTADDRREQ;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEFAULT) && (WSAEFAULT != EFAULT)
|
|
|
|
else if (err == WSAEFAULT) err = EFAULT;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEINTR) && (WSAEINTR != EINTR)
|
|
|
|
else if (err == WSAEINTR) err = EINTR;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEINVAL) && (WSAEINVAL != EINVAL)
|
|
|
|
else if (err == WSAEINVAL) err = EINVAL;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEISCONN) && (WSAEISCONN != EISCONN)
|
|
|
|
else if (err == WSAEISCONN) err = EISCONN;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEMSGSIZE) && (WSAEMSGSIZE != EMSGSIZE)
|
|
|
|
else if (err == WSAEMSGSIZE) err = EMSGSIZE;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAENOBUFS) && (WSAENOBUFS != ENOBUFS)
|
|
|
|
else if (err == WSAENOBUFS) err = ENOBUFS;
|
|
|
|
#endif
|
|
|
|
#if defined(WSA_NOT_ENOUGH_MEMORY) && (WSA_NOT_ENOUGH_MEMORY != ENOMEM)
|
|
|
|
else if (err == WSA_NOT_ENOUGH_MEMORY) err = ENOMEM;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAENOTCONN) && (WSAENOTCONN != ENOTCONN)
|
|
|
|
else if (err == WSAENOTCONN) err = ENOTCONN;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAENOTSOCK) && (WSAENOTSOCK != ENOTSOCK)
|
|
|
|
else if (err == WSAENOTSOCK) err = ENOTSOCK;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAEOPNOTSUPP) && (WSAEOPNOTSUPP != EOPNOTSUPP)
|
|
|
|
else if (err == WSAEOPNOTSUPP) err = EOPNOTSUPP;
|
|
|
|
#endif
|
|
|
|
#if defined(WSAESHUTDOWN) && (WSAESHUTDOWN != EPIPE)
|
|
|
|
else if (err == WSAESHUTDOWN) err = EPIPE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* extras used by recv() */
|
|
|
|
#if defined(WSAECONNREFUSED) && (WSAECONNREFUSED != ECONNREFUSED)
|
|
|
|
else if (err == WSAECONNREFUSED) err = ECONNREFUSED;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* extras used by getsockopt() */
|
|
|
|
#if defined(WSAENOPROTOOPT) && (WSAENOPROTOOPT != ENOPROTOOPT)
|
|
|
|
else if (err == WSAENOPROTOOPT) err = ENOPROTOOPT;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return err;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-10-25 05:03:34 -07:00
|
|
|
/**
|
|
|
|
* Join a multicast group specified by address.
|
|
|
|
*
|
|
|
|
* Address must be an IPv4 or IPv6 depending on @a fd and will be
|
|
|
|
* parsed using inet_pton() with corresponding @a family. The address
|
|
|
|
* may contain an '@@' delimiter to specify the local interface IP
|
|
|
|
* address to use. No interface means '0.0.0.0'.
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @param family the socket family of fd, AF_INET or AF_INET6.
|
|
|
|
* @param address the address in the format IP[@@IFACE]
|
|
|
|
*
|
|
|
|
* @return 0 on success, errno mapping otherwise.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_multicast_join(SOCKET fd, int family, const char *address);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Leave a multicast group specified by address.
|
|
|
|
*
|
|
|
|
* This reverses the effect of efl_net_multicast_join().
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @param family the socket family of fd, AF_INET or AF_INET6.
|
|
|
|
* @param address the address in the format IP[@@IFACE]
|
|
|
|
*
|
|
|
|
* @return 0 on success, errno mapping otherwise.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_multicast_leave(SOCKET fd, int family, const char *address);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Time-To-Live of multicast packets. <= 1 disables going
|
|
|
|
* outside of local network.
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @param family the socket family of fd, AF_INET or AF_INET6.
|
|
|
|
* @param ttl the time-to-live in units.
|
|
|
|
*
|
|
|
|
* @return 0 on success, errno mapping otherwise.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_multicast_ttl_set(SOCKET fd, int family, uint8_t ttl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the current time-to-live of multicast packets.
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @param family the socket family of fd, AF_INET or AF_INET6.
|
|
|
|
* @param[out] ttl returns the time-to-live in units.
|
|
|
|
*
|
|
|
|
* @return 0 on success, errno mapping otherwise.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_multicast_ttl_get(SOCKET fd, int family, uint8_t *ttl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets if the current local address should get a copy of the packets sent.
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @param family the socket family of fd, AF_INET or AF_INET6.
|
|
|
|
* @param loopback if #EINA_TRUE, enables receive of local copy. #EINA_FALSE means only remote peers will do.
|
|
|
|
*
|
|
|
|
* @return 0 on success, errno mapping otherwise.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_multicast_loopback_set(SOCKET fd, int family, Eina_Bool loopback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets if the current local address should get a copy of the packets sent.
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @param family the socket family of fd, AF_INET or AF_INET6.
|
|
|
|
* @param[out] loopback returns if #EINA_TRUE, enables receive of local copy. #EINA_FALSE means only remote peers will do.
|
|
|
|
*
|
|
|
|
* @return 0 on success, errno mapping otherwise.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
Eina_Error efl_net_multicast_loopback_get(SOCKET fd, int family, Eina_Bool *loopback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Query the size of the next UDP datagram pending on queue.
|
|
|
|
*
|
|
|
|
* @param fd socket to operate on.
|
|
|
|
* @return the size in bytes.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
size_t efl_net_udp_datagram_size_query(SOCKET fd);
|
|
|
|
|
2016-10-28 17:48:19 -07:00
|
|
|
|
|
|
|
/* SSL abstraction API */
|
|
|
|
extern void *efl_net_ssl_context_connection_new(Efl_Net_Ssl_Context *context);
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#endif
|