forked from enlightenment/efl
reformat ecore_con so I can read it...
This commit is contained in:
parent
2bcfc800c9
commit
41fe698fc2
|
@ -47,65 +47,65 @@
|
||||||
#include "Ecore_Con.h"
|
#include "Ecore_Con.h"
|
||||||
#include "ecore_con_private.h"
|
#include "ecore_con_private.h"
|
||||||
|
|
||||||
static Eina_Bool _ecore_con_client_timer(Ecore_Con_Client *cl);
|
static Eina_Bool _ecore_con_client_timer(Ecore_Con_Client *cl);
|
||||||
static void _ecore_con_cl_timer_update(Ecore_Con_Client *cl);
|
static void _ecore_con_cl_timer_update(Ecore_Con_Client *cl);
|
||||||
static Eina_Bool _ecore_con_server_timer(Ecore_Con_Server *svr);
|
static Eina_Bool _ecore_con_server_timer(Ecore_Con_Server *svr);
|
||||||
static void _ecore_con_server_timer_update(Ecore_Con_Server *svr);
|
static void _ecore_con_server_timer_update(Ecore_Con_Server *svr);
|
||||||
|
|
||||||
static void _ecore_con_cb_tcp_connect(void *data,
|
static void _ecore_con_cb_tcp_connect(void *data,
|
||||||
Ecore_Con_Info *info);
|
Ecore_Con_Info *info);
|
||||||
static void _ecore_con_cb_udp_connect(void *data,
|
static void _ecore_con_cb_udp_connect(void *data,
|
||||||
Ecore_Con_Info *info);
|
Ecore_Con_Info *info);
|
||||||
static void _ecore_con_cb_tcp_listen(void *data,
|
static void _ecore_con_cb_tcp_listen(void *data,
|
||||||
Ecore_Con_Info *info);
|
Ecore_Con_Info *info);
|
||||||
static void _ecore_con_cb_udp_listen(void *data,
|
static void _ecore_con_cb_udp_listen(void *data,
|
||||||
Ecore_Con_Info *info);
|
Ecore_Con_Info *info);
|
||||||
|
|
||||||
static void _ecore_con_server_free(Ecore_Con_Server *svr);
|
static void _ecore_con_server_free(Ecore_Con_Server *svr);
|
||||||
static void _ecore_con_client_free(Ecore_Con_Client *cl);
|
static void _ecore_con_client_free(Ecore_Con_Client *cl);
|
||||||
|
|
||||||
static void _ecore_con_cl_read(Ecore_Con_Server *svr);
|
static void _ecore_con_cl_read(Ecore_Con_Server *svr);
|
||||||
static Eina_Bool _ecore_con_svr_tcp_handler(void *data,
|
static Eina_Bool _ecore_con_svr_tcp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
static Eina_Bool _ecore_con_cl_handler(void *data,
|
static Eina_Bool _ecore_con_cl_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
static Eina_Bool _ecore_con_cl_udp_handler(void *data,
|
static Eina_Bool _ecore_con_cl_udp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
static Eina_Bool _ecore_con_svr_udp_handler(void *data,
|
static Eina_Bool _ecore_con_svr_udp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
|
|
||||||
static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl);
|
static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl);
|
||||||
static Eina_Bool _ecore_con_svr_cl_handler(void *data,
|
static Eina_Bool _ecore_con_svr_cl_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
|
|
||||||
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
|
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
|
||||||
static void _ecore_con_client_flush(Ecore_Con_Client *cl);
|
static void _ecore_con_client_flush(Ecore_Con_Client *cl);
|
||||||
|
|
||||||
static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||||
void *ev);
|
void *ev);
|
||||||
static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||||
void *ev);
|
void *ev);
|
||||||
static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||||
void *ev);
|
void *ev);
|
||||||
static void _ecore_con_event_server_add_free(void *data,
|
static void _ecore_con_event_server_add_free(void *data,
|
||||||
void *ev);
|
void *ev);
|
||||||
static void _ecore_con_event_server_del_free(void *data,
|
static void _ecore_con_event_server_del_free(void *data,
|
||||||
void *ev);
|
void *ev);
|
||||||
static void _ecore_con_event_server_data_free(void *data,
|
static void _ecore_con_event_server_data_free(void *data,
|
||||||
void *ev);
|
void *ev);
|
||||||
static void _ecore_con_event_server_error_free(void *data,
|
static void _ecore_con_event_server_error_free(void *data,
|
||||||
Ecore_Con_Event_Server_Error *e);
|
Ecore_Con_Event_Server_Error *e);
|
||||||
static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
|
static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Event_Client_Error *e);
|
Ecore_Con_Event_Client_Error *e);
|
||||||
static void _ecore_con_event_server_write_free(void *data,
|
static void _ecore_con_event_server_write_free(void *data,
|
||||||
Ecore_Con_Event_Server_Write *e);
|
Ecore_Con_Event_Server_Write *e);
|
||||||
static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Event_Client_Write *e);
|
Ecore_Con_Event_Client_Write *e);
|
||||||
|
|
||||||
static void _ecore_con_lookup_done(void *data,
|
static void _ecore_con_lookup_done(void *data,
|
||||||
Ecore_Con_Info *infos);
|
Ecore_Con_Info *infos);
|
||||||
|
|
||||||
static const char * _ecore_con_pretty_ip(struct sockaddr *client_addr);
|
static const char *_ecore_con_pretty_ip(struct sockaddr *client_addr);
|
||||||
|
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
int sd_fd_index = 0;
|
int sd_fd_index = 0;
|
||||||
|
@ -144,14 +144,14 @@ _ecore_con_server_kill(Ecore_Con_Server *svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ecore_con_server_kill(svr) do { \
|
#define _ecore_con_server_kill(svr) do { \
|
||||||
DBG("KILL %p", (svr)); \
|
DBG("KILL %p", (svr)); \
|
||||||
_ecore_con_server_kill((svr)); \
|
_ecore_con_server_kill((svr)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define _ecore_con_client_kill(cl) do { \
|
#define _ecore_con_client_kill(cl) do { \
|
||||||
DBG("KILL %p", (cl)); \
|
DBG("KILL %p", (cl)); \
|
||||||
_ecore_con_client_kill((cl)); \
|
_ecore_con_client_kill((cl)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0;
|
EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0;
|
||||||
EAPI int ECORE_CON_EVENT_CLIENT_DEL = 0;
|
EAPI int ECORE_CON_EVENT_CLIENT_DEL = 0;
|
||||||
|
@ -209,7 +209,6 @@ ecore_con_init(void)
|
||||||
ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new();
|
ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new();
|
||||||
ECORE_CON_EVENT_PROXY_BIND = ecore_event_type_new();
|
ECORE_CON_EVENT_PROXY_BIND = ecore_event_type_new();
|
||||||
|
|
||||||
|
|
||||||
eina_magic_string_set(ECORE_MAGIC_CON_SERVER, "Ecore_Con_Server");
|
eina_magic_string_set(ECORE_MAGIC_CON_SERVER, "Ecore_Con_Server");
|
||||||
eina_magic_string_set(ECORE_MAGIC_CON_CLIENT, "Ecore_Con_Client");
|
eina_magic_string_set(ECORE_MAGIC_CON_CLIENT, "Ecore_Con_Client");
|
||||||
eina_magic_string_set(ECORE_MAGIC_CON_URL, "Ecore_Con_Url");
|
eina_magic_string_set(ECORE_MAGIC_CON_URL, "Ecore_Con_Url");
|
||||||
|
@ -224,8 +223,8 @@ ecore_con_init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
eina_log_timing(_ecore_con_log_dom,
|
eina_log_timing(_ecore_con_log_dom,
|
||||||
EINA_LOG_STATE_STOP,
|
EINA_LOG_STATE_STOP,
|
||||||
EINA_LOG_STATE_INIT);
|
EINA_LOG_STATE_INIT);
|
||||||
|
|
||||||
return _ecore_con_init_count;
|
return _ecore_con_init_count;
|
||||||
}
|
}
|
||||||
|
@ -240,8 +239,8 @@ ecore_con_shutdown(void)
|
||||||
return _ecore_con_init_count;
|
return _ecore_con_init_count;
|
||||||
|
|
||||||
eina_log_timing(_ecore_con_log_dom,
|
eina_log_timing(_ecore_con_log_dom,
|
||||||
EINA_LOG_STATE_START,
|
EINA_LOG_STATE_START,
|
||||||
EINA_LOG_STATE_SHUTDOWN);
|
EINA_LOG_STATE_SHUTDOWN);
|
||||||
|
|
||||||
EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
|
EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
|
||||||
{
|
{
|
||||||
|
@ -271,9 +270,9 @@ ecore_con_shutdown(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_con_lookup(const char *name,
|
ecore_con_lookup(const char *name,
|
||||||
Ecore_Con_Dns_Cb done_cb,
|
Ecore_Con_Dns_Cb done_cb,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
Ecore_Con_Lookup *lk;
|
Ecore_Con_Lookup *lk;
|
||||||
|
@ -344,9 +343,9 @@ on_error:
|
||||||
|
|
||||||
EAPI Ecore_Con_Server *
|
EAPI Ecore_Con_Server *
|
||||||
ecore_con_server_add(Ecore_Con_Type compl_type,
|
ecore_con_server_add(Ecore_Con_Type compl_type,
|
||||||
const char *name,
|
const char *name,
|
||||||
int port,
|
int port,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
Ecore_Con_Type type;
|
Ecore_Con_Type type;
|
||||||
|
@ -382,7 +381,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
|
||||||
if ((type == ECORE_CON_LOCAL_USER) ||
|
if ((type == ECORE_CON_LOCAL_USER) ||
|
||||||
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
||||||
(type == ECORE_CON_LOCAL_ABSTRACT))
|
(type == ECORE_CON_LOCAL_ABSTRACT))
|
||||||
/* Local */
|
/* Local */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!ecore_con_local_listen(svr))
|
if (!ecore_con_local_listen(svr))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -396,9 +395,9 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
|
||||||
(type == ECORE_CON_REMOTE_CORK))
|
(type == ECORE_CON_REMOTE_CORK))
|
||||||
{
|
{
|
||||||
/* TCP */
|
/* TCP */
|
||||||
if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen,
|
if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen,
|
||||||
svr))
|
svr))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
else if ((type == ECORE_CON_REMOTE_MCAST) ||
|
else if ((type == ECORE_CON_REMOTE_MCAST) ||
|
||||||
(type == ECORE_CON_REMOTE_UDP))
|
(type == ECORE_CON_REMOTE_UDP))
|
||||||
|
@ -419,7 +418,6 @@ error:
|
||||||
if (svr->path)
|
if (svr->path)
|
||||||
free(svr->path);
|
free(svr->path);
|
||||||
|
|
||||||
|
|
||||||
if (svr->fd_handler)
|
if (svr->fd_handler)
|
||||||
ecore_main_fd_handler_del(svr->fd_handler);
|
ecore_main_fd_handler_del(svr->fd_handler);
|
||||||
|
|
||||||
|
@ -439,9 +437,9 @@ error:
|
||||||
|
|
||||||
EAPI Ecore_Con_Server *
|
EAPI Ecore_Con_Server *
|
||||||
ecore_con_server_connect(Ecore_Con_Type compl_type,
|
ecore_con_server_connect(Ecore_Con_Type compl_type,
|
||||||
const char *name,
|
const char *name,
|
||||||
int port,
|
int port,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
Ecore_Con_Type type;
|
Ecore_Con_Type type;
|
||||||
|
@ -491,16 +489,16 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
|
||||||
EINA_SAFETY_ON_TRUE_GOTO(ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL), error);
|
EINA_SAFETY_ON_TRUE_GOTO(ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL), error);
|
||||||
|
|
||||||
EINA_SAFETY_ON_TRUE_GOTO(((type == ECORE_CON_REMOTE_TCP) ||
|
EINA_SAFETY_ON_TRUE_GOTO(((type == ECORE_CON_REMOTE_TCP) ||
|
||||||
(type == ECORE_CON_REMOTE_NODELAY) ||
|
(type == ECORE_CON_REMOTE_NODELAY) ||
|
||||||
(type == ECORE_CON_REMOTE_CORK) ||
|
(type == ECORE_CON_REMOTE_CORK) ||
|
||||||
(type == ECORE_CON_REMOTE_UDP) ||
|
(type == ECORE_CON_REMOTE_UDP) ||
|
||||||
(type == ECORE_CON_REMOTE_BROADCAST)) &&
|
(type == ECORE_CON_REMOTE_BROADCAST)) &&
|
||||||
(port < 0), error);
|
(port < 0), error);
|
||||||
|
|
||||||
if ((type == ECORE_CON_LOCAL_USER) ||
|
if ((type == ECORE_CON_LOCAL_USER) ||
|
||||||
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
||||||
(type == ECORE_CON_LOCAL_ABSTRACT))
|
(type == ECORE_CON_LOCAL_ABSTRACT))
|
||||||
/* Local */
|
/* Local */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!ecore_con_local_connect(svr, _ecore_con_cl_handler)) goto error;
|
if (!ecore_con_local_connect(svr, _ecore_con_cl_handler)) goto error;
|
||||||
#else
|
#else
|
||||||
|
@ -512,7 +510,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
|
||||||
(type == ECORE_CON_REMOTE_CORK))
|
(type == ECORE_CON_REMOTE_CORK))
|
||||||
{
|
{
|
||||||
/* TCP */
|
/* TCP */
|
||||||
EINA_SAFETY_ON_FALSE_GOTO(ecore_con_info_tcp_connect(svr, _ecore_con_cb_tcp_connect, svr), error);
|
EINA_SAFETY_ON_FALSE_GOTO(ecore_con_info_tcp_connect(svr, _ecore_con_cb_tcp_connect, svr), error);
|
||||||
}
|
}
|
||||||
else if ((type == ECORE_CON_REMOTE_UDP) || (type == ECORE_CON_REMOTE_BROADCAST))
|
else if ((type == ECORE_CON_REMOTE_UDP) || (type == ECORE_CON_REMOTE_BROADCAST))
|
||||||
/* UDP and MCAST */
|
/* UDP and MCAST */
|
||||||
|
@ -543,7 +541,7 @@ error:
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_con_server_timeout_set(Ecore_Con_Server *svr,
|
ecore_con_server_timeout_set(Ecore_Con_Server *svr,
|
||||||
double timeout)
|
double timeout)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -602,7 +600,7 @@ ecore_con_server_data_get(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
ecore_con_server_data_set(Ecore_Con_Server *svr,
|
ecore_con_server_data_set(Ecore_Con_Server *svr,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
|
|
||||||
|
@ -672,8 +670,8 @@ ecore_con_server_port_get(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_con_server_send(Ecore_Con_Server *svr,
|
ecore_con_server_send(Ecore_Con_Server *svr,
|
||||||
const void *data,
|
const void *data,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -711,8 +709,8 @@ ecore_con_server_send(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
|
ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
|
||||||
int client_limit,
|
int client_limit,
|
||||||
char reject_excess_clients)
|
char reject_excess_clients)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -780,8 +778,8 @@ ecore_con_server_flush(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_con_client_send(Ecore_Con_Client *cl,
|
ecore_con_client_send(Ecore_Con_Client *cl,
|
||||||
const void *data,
|
const void *data,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||||
{
|
{
|
||||||
|
@ -848,7 +846,7 @@ ecore_con_client_connected_get(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_con_client_timeout_set(Ecore_Con_Client *cl,
|
ecore_con_client_timeout_set(Ecore_Con_Client *cl,
|
||||||
double timeout)
|
double timeout)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||||
{
|
{
|
||||||
|
@ -890,7 +888,7 @@ ecore_con_client_del(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_con_client_data_set(Ecore_Con_Client *cl,
|
ecore_con_client_data_set(Ecore_Con_Client *cl,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||||
{
|
{
|
||||||
|
@ -936,9 +934,9 @@ ecore_con_client_port_get(Ecore_Con_Client *cl)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (cl->client_addr->sa_family == AF_INET)
|
if (cl->client_addr->sa_family == AF_INET)
|
||||||
return ((struct sockaddr_in*)cl->client_addr)->sin_port;
|
return ((struct sockaddr_in *)cl->client_addr)->sin_port;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
return ((struct sockaddr_in6*)cl->client_addr)->sin6_port;
|
return ((struct sockaddr_in6 *)cl->client_addr)->sin6_port;
|
||||||
#else
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -999,64 +997,64 @@ ecore_con_client_fd_get(Ecore_Con_Client *cl)
|
||||||
void
|
void
|
||||||
ecore_con_event_proxy_bind(Ecore_Con_Server *svr)
|
ecore_con_event_proxy_bind(Ecore_Con_Server *svr)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Proxy_Bind *e;
|
Ecore_Con_Event_Proxy_Bind *e;
|
||||||
int ev = ECORE_CON_EVENT_PROXY_BIND;
|
int ev = ECORE_CON_EVENT_PROXY_BIND;
|
||||||
|
|
||||||
e = ecore_con_event_proxy_bind_alloc();
|
e = ecore_con_event_proxy_bind_alloc();
|
||||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||||
|
|
||||||
svr->event_count = eina_list_append(svr->event_count, e);
|
svr->event_count = eina_list_append(svr->event_count, e);
|
||||||
_ecore_con_server_timer_update(svr);
|
_ecore_con_server_timer_update(svr);
|
||||||
e->server = svr;
|
e->server = svr;
|
||||||
e->ip = svr->proxyip;
|
e->ip = svr->proxyip;
|
||||||
e->port = svr->proxyport;
|
e->port = svr->proxyport;
|
||||||
ecore_event_add(ev, e,
|
ecore_event_add(ev, e,
|
||||||
_ecore_con_event_server_add_free, NULL);
|
_ecore_con_event_server_add_free, NULL);
|
||||||
_ecore_con_event_count++;
|
_ecore_con_event_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_server_add(Ecore_Con_Server *svr)
|
ecore_con_event_server_add(Ecore_Con_Server *svr)
|
||||||
{
|
{
|
||||||
/* we got our server! */
|
/* we got our server! */
|
||||||
Ecore_Con_Event_Server_Add *e;
|
Ecore_Con_Event_Server_Add *e;
|
||||||
int ev = ECORE_CON_EVENT_SERVER_ADD;
|
int ev = ECORE_CON_EVENT_SERVER_ADD;
|
||||||
|
|
||||||
e = ecore_con_event_server_add_alloc();
|
e = ecore_con_event_server_add_alloc();
|
||||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||||
|
|
||||||
svr->connecting = EINA_FALSE;
|
svr->connecting = EINA_FALSE;
|
||||||
svr->start_time = ecore_time_get();
|
svr->start_time = ecore_time_get();
|
||||||
svr->event_count = eina_list_append(svr->event_count, e);
|
svr->event_count = eina_list_append(svr->event_count, e);
|
||||||
_ecore_con_server_timer_update(svr);
|
_ecore_con_server_timer_update(svr);
|
||||||
e->server = svr;
|
e->server = svr;
|
||||||
if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE;
|
if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE;
|
||||||
ecore_event_add(ev, e,
|
ecore_event_add(ev, e,
|
||||||
_ecore_con_event_server_add_free, NULL);
|
_ecore_con_event_server_add_free, NULL);
|
||||||
_ecore_con_event_count++;
|
_ecore_con_event_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_server_del(Ecore_Con_Server *svr)
|
ecore_con_event_server_del(Ecore_Con_Server *svr)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Del *e;
|
Ecore_Con_Event_Server_Del *e;
|
||||||
|
|
||||||
svr->delete_me = EINA_TRUE;
|
svr->delete_me = EINA_TRUE;
|
||||||
INF("svr %p is dead", svr);
|
INF("svr %p is dead", svr);
|
||||||
e = ecore_con_event_server_del_alloc();
|
e = ecore_con_event_server_del_alloc();
|
||||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||||
|
|
||||||
svr->event_count = eina_list_append(svr->event_count, e);
|
svr->event_count = eina_list_append(svr->event_count, e);
|
||||||
_ecore_con_server_timer_update(svr);
|
_ecore_con_server_timer_update(svr);
|
||||||
e->server = svr;
|
e->server = svr;
|
||||||
if (svr->ecs)
|
if (svr->ecs)
|
||||||
{
|
{
|
||||||
svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE;
|
svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE;
|
||||||
eina_stringshare_replace(&svr->proxyip, NULL);
|
eina_stringshare_replace(&svr->proxyip, NULL);
|
||||||
svr->proxyport = 0;
|
svr->proxyport = 0;
|
||||||
}
|
}
|
||||||
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
|
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
|
||||||
_ecore_con_event_server_del_free, NULL);
|
_ecore_con_event_server_del_free, NULL);
|
||||||
_ecore_con_event_count++;
|
_ecore_con_event_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,20 +1128,20 @@ ecore_con_event_client_add(Ecore_Con_Client *cl)
|
||||||
void
|
void
|
||||||
ecore_con_event_client_del(Ecore_Con_Client *cl)
|
ecore_con_event_client_del(Ecore_Con_Client *cl)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Del *e;
|
Ecore_Con_Event_Client_Del *e;
|
||||||
|
|
||||||
if (!cl) return;
|
if (!cl) return;
|
||||||
cl->delete_me = EINA_TRUE;
|
cl->delete_me = EINA_TRUE;
|
||||||
INF("cl %p is dead", cl);
|
INF("cl %p is dead", cl);
|
||||||
e = ecore_con_event_client_del_alloc();
|
e = ecore_con_event_client_del_alloc();
|
||||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||||
cl->event_count = eina_list_append(cl->event_count, e);
|
cl->event_count = eina_list_append(cl->event_count, e);
|
||||||
|
|
||||||
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(cl);
|
||||||
e->client = cl;
|
e->client = cl;
|
||||||
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
|
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
|
||||||
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
|
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
|
||||||
_ecore_con_event_count++;
|
_ecore_con_event_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1193,6 @@ ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, E
|
||||||
_ecore_con_event_count++;
|
_ecore_con_event_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info)
|
ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info)
|
||||||
{
|
{
|
||||||
|
@ -1457,7 +1454,7 @@ _ecore_con_cl_timer_update(Ecore_Con_Client *cl)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_cb_tcp_listen(void *data,
|
_ecore_con_cb_tcp_listen(void *data,
|
||||||
Ecore_Con_Info *net_info)
|
Ecore_Con_Info *net_info)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
@ -1477,38 +1474,38 @@ _ecore_con_cb_tcp_listen(void *data,
|
||||||
if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
|
if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
|
||||||
{
|
{
|
||||||
if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
|
if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
|
||||||
net_info->info.ai_family,
|
net_info->info.ai_family,
|
||||||
net_info->info.ai_socktype,
|
net_info->info.ai_socktype,
|
||||||
1,
|
1,
|
||||||
svr->port) <= 0)
|
svr->port) <= 0)
|
||||||
{
|
{
|
||||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||||
|
|
||||||
/* I am wondering if that's really going to work as the bind is already done */
|
/* I am wondering if that's really going to work as the bind is already done */
|
||||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||||
|
|
||||||
lin.l_onoff = 1;
|
lin.l_onoff = 1;
|
||||||
lin.l_linger = 0;
|
lin.l_linger = 0;
|
||||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||||
sizeof(struct linger)) < 0)
|
sizeof(struct linger)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
|
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
|
||||||
{
|
{
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
|
|
||||||
if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
||||||
sizeof(int)) < 0)
|
sizeof(int)) < 0)
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
goto fd_ready;
|
goto fd_ready;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1526,7 +1523,7 @@ _ecore_con_cb_tcp_listen(void *data,
|
||||||
|
|
||||||
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
|
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
|
||||||
{
|
{
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
|
|
||||||
if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
||||||
sizeof(int)) < 0)
|
sizeof(int)) < 0)
|
||||||
|
@ -1541,10 +1538,10 @@ _ecore_con_cb_tcp_listen(void *data,
|
||||||
if (listen(svr->fd, 4096) < 0) goto error;
|
if (listen(svr->fd, 4096) < 0) goto error;
|
||||||
|
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
fd_ready:
|
fd_ready:
|
||||||
#endif
|
#endif
|
||||||
svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
|
svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
|
||||||
_ecore_con_svr_tcp_handler, svr, NULL, NULL);
|
_ecore_con_svr_tcp_handler, svr, NULL, NULL);
|
||||||
if (!svr->fd_handler)
|
if (!svr->fd_handler)
|
||||||
{
|
{
|
||||||
memerr = "Memory allocation failure";
|
memerr = "Memory allocation failure";
|
||||||
|
@ -1554,13 +1551,13 @@ _ecore_con_cb_tcp_listen(void *data,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno));
|
if (errno || memerr) ecore_con_event_server_error(svr, memerr ? : strerror(errno));
|
||||||
ecore_con_ssl_server_shutdown(svr);
|
ecore_con_ssl_server_shutdown(svr);
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_cb_udp_listen(void *data,
|
_ecore_con_cb_udp_listen(void *data,
|
||||||
Ecore_Con_Info *net_info)
|
Ecore_Con_Info *net_info)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
@ -1586,21 +1583,21 @@ _ecore_con_cb_udp_listen(void *data,
|
||||||
if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
|
if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
|
||||||
{
|
{
|
||||||
if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
|
if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
|
||||||
net_info->info.ai_family,
|
net_info->info.ai_family,
|
||||||
net_info->info.ai_socktype,
|
net_info->info.ai_socktype,
|
||||||
-1,
|
-1,
|
||||||
svr->port) <= 0)
|
svr->port) <= 0)
|
||||||
{
|
{
|
||||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||||
|
|
||||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0)
|
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||||
|
|
||||||
goto fd_ready;
|
goto fd_ready;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype,
|
svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype,
|
||||||
|
@ -1643,7 +1640,7 @@ _ecore_con_cb_udp_listen(void *data,
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
fd_ready:
|
fd_ready:
|
||||||
#endif
|
#endif
|
||||||
svr->fd_handler =
|
svr->fd_handler =
|
||||||
ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
|
ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
|
||||||
|
@ -1659,13 +1656,13 @@ _ecore_con_cb_udp_listen(void *data,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno));
|
if (errno || memerr) ecore_con_event_server_error(svr, memerr ? : strerror(errno));
|
||||||
ecore_con_ssl_server_shutdown(svr);
|
ecore_con_ssl_server_shutdown(svr);
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_cb_tcp_connect(void *data,
|
_ecore_con_cb_tcp_connect(void *data,
|
||||||
Ecore_Con_Info *net_info)
|
Ecore_Con_Info *net_info)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
@ -1752,13 +1749,13 @@ _ecore_con_cb_tcp_connect(void *data,
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ecore_con_event_server_error(svr,
|
ecore_con_event_server_error(svr,
|
||||||
memerr ?: errno? strerror(errno) : "DNS error");
|
memerr ? : errno ? strerror(errno) : "DNS error");
|
||||||
ecore_con_ssl_server_shutdown(svr);
|
ecore_con_ssl_server_shutdown(svr);
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_cb_udp_connect(void *data,
|
_ecore_con_cb_udp_connect(void *data,
|
||||||
Ecore_Con_Info *net_info)
|
Ecore_Con_Info *net_info)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
@ -1810,7 +1807,7 @@ _ecore_con_cb_udp_connect(void *data,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno));
|
if (errno || memerr) ecore_con_event_server_error(svr, memerr ? : strerror(errno));
|
||||||
ecore_con_ssl_server_shutdown(svr);
|
ecore_con_ssl_server_shutdown(svr);
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
}
|
}
|
||||||
|
@ -1850,13 +1847,13 @@ svr_try_connect_plain(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
if ((!svr->delete_me) && (!svr->handshaking) && svr->connecting)
|
if ((!svr->delete_me) && (!svr->handshaking) && svr->connecting)
|
||||||
{
|
{
|
||||||
if (svr->ecs)
|
if (svr->ecs)
|
||||||
{
|
{
|
||||||
if (ecore_con_socks_svr_init(svr))
|
if (ecore_con_socks_svr_init(svr))
|
||||||
return ECORE_CON_INPROGRESS;
|
return ECORE_CON_INPROGRESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ecore_con_event_server_add(svr);
|
ecore_con_event_server_add(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svr->fd_handler)
|
if (svr->fd_handler)
|
||||||
|
@ -1884,25 +1881,27 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr)
|
||||||
int family = client_addr->sa_family;
|
int family = client_addr->sa_family;
|
||||||
void *src;
|
void *src;
|
||||||
|
|
||||||
switch(family)
|
switch (family)
|
||||||
{
|
{
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
src = &(((struct sockaddr_in *)client_addr)->sin_addr);
|
src = &(((struct sockaddr_in *)client_addr)->sin_addr);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case AF_INET6:
|
#ifdef HAVE_IPV6
|
||||||
src = &(((struct sockaddr_in6 *)client_addr)->sin6_addr);
|
case AF_INET6:
|
||||||
|
src = &(((struct sockaddr_in6 *)client_addr)->sin6_addr);
|
||||||
|
|
||||||
|
if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)src))
|
||||||
|
{
|
||||||
|
family = AF_INET;
|
||||||
|
src = (char *)src + 12;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)src))
|
|
||||||
{
|
|
||||||
family = AF_INET;
|
|
||||||
src = (char*)src + 12;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return eina_stringshare_add("0.0.0.0");
|
return eina_stringshare_add("0.0.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inet_ntop(family, src, ipbuf, sizeof(ipbuf)))
|
if (!inet_ntop(family, src, ipbuf, sizeof(ipbuf)))
|
||||||
return eina_stringshare_add("0.0.0.0");
|
return eina_stringshare_add("0.0.0.0");
|
||||||
|
@ -1912,7 +1911,7 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_svr_tcp_handler(void *data,
|
_ecore_con_svr_tcp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler EINA_UNUSED)
|
Ecore_Fd_Handler *fd_handler EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
@ -1995,7 +1994,7 @@ error:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(cl);
|
free(cl);
|
||||||
if (clerr || errno) ecore_con_event_server_error(svr, clerr ?: strerror(errno));
|
if (clerr || errno) ecore_con_event_server_error(svr, clerr ? : strerror(errno));
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2010,13 +2009,13 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
/* only possible with non-ssl connections */
|
/* only possible with non-ssl connections */
|
||||||
if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED))
|
if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (svr->handshaking && (!svr->ecs_state))
|
if (svr->handshaking && (!svr->ecs_state))
|
||||||
{
|
{
|
||||||
DBG("Continuing ssl handshake");
|
DBG("Continuing ssl handshake");
|
||||||
if (!ecore_con_ssl_server_init(svr))
|
if (!ecore_con_ssl_server_init(svr))
|
||||||
lost_server = EINA_FALSE;
|
lost_server = EINA_FALSE;
|
||||||
_ecore_con_server_timer_update(svr);
|
_ecore_con_server_timer_update(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,7 +2025,7 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
|
||||||
num = read(svr->fd, buf, sizeof(buf));
|
num = read(svr->fd, buf, sizeof(buf));
|
||||||
/* 0 is not a valid return value for a tcp socket */
|
/* 0 is not a valid return value for a tcp socket */
|
||||||
if ((num > 0) || ((num < 0) && (errno == EAGAIN)))
|
if ((num > 0) || ((num < 0) && (errno == EAGAIN)))
|
||||||
lost_server = EINA_FALSE;
|
lost_server = EINA_FALSE;
|
||||||
else if (num < 0)
|
else if (num < 0)
|
||||||
ecore_con_event_server_error(svr, strerror(errno));
|
ecore_con_event_server_error(svr, strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -2035,7 +2034,7 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
|
||||||
num = ecore_con_ssl_server_read(svr, buf, sizeof(buf));
|
num = ecore_con_ssl_server_read(svr, buf, sizeof(buf));
|
||||||
/* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */
|
/* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */
|
||||||
if (num >= 0)
|
if (num >= 0)
|
||||||
lost_server = EINA_FALSE;
|
lost_server = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!svr->delete_me) && (num > 0))
|
if ((!svr->delete_me) && (num > 0))
|
||||||
|
@ -2047,11 +2046,11 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lost_server)
|
if (lost_server)
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_cl_handler(void *data,
|
_ecore_con_cl_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
@ -2111,7 +2110,7 @@ _ecore_con_cl_handler(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_cl_udp_handler(void *data,
|
_ecore_con_cl_udp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
unsigned char buf[READBUFSIZ];
|
unsigned char buf[READBUFSIZ];
|
||||||
|
@ -2147,7 +2146,7 @@ _ecore_con_cl_udp_handler(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_svr_udp_handler(void *data,
|
_ecore_con_svr_udp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
unsigned char buf[READBUFSIZ];
|
unsigned char buf[READBUFSIZ];
|
||||||
|
@ -2172,13 +2171,13 @@ _ecore_con_svr_udp_handler(void *data,
|
||||||
num = fcntl(svr->fd, F_SETFL, O_NONBLOCK);
|
num = fcntl(svr->fd, F_SETFL, O_NONBLOCK);
|
||||||
if (num >= 0)
|
if (num >= 0)
|
||||||
num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0,
|
num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0,
|
||||||
(struct sockaddr *)&client_addr,
|
(struct sockaddr *)&client_addr,
|
||||||
&client_addr_len);
|
&client_addr_len);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT,
|
num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT,
|
||||||
(struct sockaddr *)&client_addr,
|
(struct sockaddr *)&client_addr,
|
||||||
&client_addr_len);
|
&client_addr_len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (num < 0 && (errno != EAGAIN) && (errno != EINTR))
|
if (num < 0 && (errno != EAGAIN) && (errno != EINTR))
|
||||||
|
@ -2190,7 +2189,6 @@ _ecore_con_svr_udp_handler(void *data,
|
||||||
return ECORE_CALLBACK_CANCEL;
|
return ECORE_CALLBACK_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create a new client for use in the client data event */
|
/* Create a new client for use in the client data event */
|
||||||
cl = calloc(1, sizeof(Ecore_Con_Client));
|
cl = calloc(1, sizeof(Ecore_Con_Client));
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW);
|
||||||
|
@ -2259,7 +2257,7 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_svr_cl_handler(void *data,
|
_ecore_con_svr_cl_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
Ecore_Con_Client *cl;
|
Ecore_Con_Client *cl;
|
||||||
|
@ -2349,12 +2347,12 @@ _ecore_con_server_flush(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
{
|
{
|
||||||
if ((errno != EAGAIN) && (errno != EINTR))
|
if ((errno != EAGAIN) && (errno != EINTR))
|
||||||
{
|
{
|
||||||
ecore_con_event_server_error(svr, strerror(errno));
|
ecore_con_event_server_error(svr, strerror(errno));
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count && (!svr->ecs_state)) ecore_con_event_server_write(svr, count);
|
if (count && (!svr->ecs_state)) ecore_con_event_server_write(svr, count);
|
||||||
|
@ -2437,8 +2435,8 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
|
||||||
{
|
{
|
||||||
if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me))
|
if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me))
|
||||||
{
|
{
|
||||||
ecore_con_event_client_error(cl, strerror(errno));
|
ecore_con_event_client_error(cl, strerror(errno));
|
||||||
_ecore_con_client_kill(cl);
|
_ecore_con_client_kill(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -2469,7 +2467,7 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
_ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||||
void *ev)
|
void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Add *e;
|
Ecore_Con_Event_Client_Add *e;
|
||||||
|
|
||||||
|
@ -2503,7 +2501,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
_ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||||
void *ev)
|
void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Del *e;
|
Ecore_Con_Event_Client_Del *e;
|
||||||
|
|
||||||
|
@ -2557,7 +2555,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||||
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
||||||
((e->client->host_server &&
|
((e->client->host_server &&
|
||||||
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
||||||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
||||||
ecore_con_client_del(e->client);
|
ecore_con_client_del(e->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2569,7 +2567,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||||
void *ev)
|
void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Data *e;
|
Ecore_Con_Event_Client_Data *e;
|
||||||
|
|
||||||
|
@ -2593,7 +2591,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||||
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
||||||
((e->client->host_server &&
|
((e->client->host_server &&
|
||||||
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
||||||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
||||||
ecore_con_client_del(e->client);
|
ecore_con_client_del(e->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2606,7 +2604,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_server_add_free(void *data EINA_UNUSED,
|
_ecore_con_event_server_add_free(void *data EINA_UNUSED,
|
||||||
void *ev)
|
void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Add *e;
|
Ecore_Con_Event_Server_Add *e;
|
||||||
|
|
||||||
|
@ -2625,7 +2623,7 @@ _ecore_con_event_server_add_free(void *data EINA_UNUSED,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_server_del_free(void *data EINA_UNUSED,
|
_ecore_con_event_server_del_free(void *data EINA_UNUSED,
|
||||||
void *ev)
|
void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Del *e;
|
Ecore_Con_Event_Server_Del *e;
|
||||||
|
|
||||||
|
@ -2661,7 +2659,7 @@ _ecore_con_event_server_write_free(void *data EINA_UNUSED,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_server_data_free(void *data EINA_UNUSED,
|
_ecore_con_event_server_data_free(void *data EINA_UNUSED,
|
||||||
void *ev)
|
void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Server_Data *e;
|
Ecore_Con_Event_Server_Data *e;
|
||||||
|
|
||||||
|
@ -2680,7 +2678,6 @@ _ecore_con_event_server_data_free(void *data EINA_UNUSED,
|
||||||
ecore_con_mempool_shutdown();
|
ecore_con_mempool_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_event_server_error_free(void *data EINA_UNUSED, Ecore_Con_Event_Server_Error *e)
|
_ecore_con_event_server_error_free(void *data EINA_UNUSED, Ecore_Con_Event_Server_Error *e)
|
||||||
{
|
{
|
||||||
|
@ -2728,7 +2725,7 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_lookup_done(void *data,
|
_ecore_con_lookup_done(void *data,
|
||||||
Ecore_Con_Info *infos)
|
Ecore_Con_Info *infos)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
|
|
|
@ -10,24 +10,24 @@
|
||||||
typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
|
typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
|
||||||
struct _Ecore_Con_Mempool
|
struct _Ecore_Con_Mempool
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
Eina_Mempool *mp;
|
Eina_Mempool *mp;
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GENERIC_ALLOC_FREE(TYPE, Type) \
|
#define GENERIC_ALLOC_FREE(TYPE, Type) \
|
||||||
Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
|
Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
|
||||||
\
|
\
|
||||||
TYPE * \
|
TYPE * \
|
||||||
Type##_alloc(void) \
|
Type##_alloc(void) \
|
||||||
{ \
|
{ \
|
||||||
return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
|
return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void \
|
void \
|
||||||
Type##_free(TYPE *e) \
|
Type##_free(TYPE * e) \
|
||||||
{ \
|
{ \
|
||||||
eina_mempool_free(Type##_mp.mp, e); \
|
eina_mempool_free(Type##_mp.mp, e); \
|
||||||
}
|
}
|
||||||
|
|
||||||
GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
|
GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
|
||||||
|
@ -43,17 +43,17 @@ GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Data, ecore_con_event_server_data);
|
||||||
GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind);
|
GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind);
|
||||||
|
|
||||||
static Ecore_Con_Mempool *mempool_array[] = {
|
static Ecore_Con_Mempool *mempool_array[] = {
|
||||||
&ecore_con_event_client_add_mp,
|
&ecore_con_event_client_add_mp,
|
||||||
&ecore_con_event_client_del_mp,
|
&ecore_con_event_client_del_mp,
|
||||||
&ecore_con_event_client_write_mp,
|
&ecore_con_event_client_write_mp,
|
||||||
&ecore_con_event_client_data_mp,
|
&ecore_con_event_client_data_mp,
|
||||||
&ecore_con_event_server_error_mp,
|
&ecore_con_event_server_error_mp,
|
||||||
&ecore_con_event_client_error_mp,
|
&ecore_con_event_client_error_mp,
|
||||||
&ecore_con_event_server_add_mp,
|
&ecore_con_event_server_add_mp,
|
||||||
&ecore_con_event_server_del_mp,
|
&ecore_con_event_server_del_mp,
|
||||||
&ecore_con_event_server_write_mp,
|
&ecore_con_event_server_write_mp,
|
||||||
&ecore_con_event_server_data_mp,
|
&ecore_con_event_server_data_mp,
|
||||||
&ecore_con_event_proxy_bind_mp
|
&ecore_con_event_proxy_bind_mp
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -68,7 +68,7 @@ ecore_con_mempool_init(void)
|
||||||
|
|
||||||
for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
|
for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
|
||||||
{
|
{
|
||||||
retry:
|
retry:
|
||||||
mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 16);
|
mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 16);
|
||||||
if (!mempool_array[i]->mp)
|
if (!mempool_array[i]->mp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,41 +44,42 @@ struct _Ecore_Con_CAres
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
Ecore_Con_Info *result;
|
Ecore_Con_Info *result;
|
||||||
|
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
struct in_addr v4;
|
struct in_addr v4;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
struct in6_addr v6;
|
struct in6_addr v6;
|
||||||
#endif
|
#endif
|
||||||
} addr;
|
} addr;
|
||||||
|
|
||||||
Eina_Bool byaddr : 1;
|
Eina_Bool byaddr : 1;
|
||||||
Eina_Bool isv6 : 1;
|
Eina_Bool isv6 : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ares_channel info_channel;
|
static ares_channel info_channel;
|
||||||
static int info_init = 0;
|
static int info_init = 0;
|
||||||
static Eina_List *info_fds = NULL;
|
static Eina_List *info_fds = NULL;
|
||||||
|
|
||||||
static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
||||||
int status,
|
int status,
|
||||||
int timeouts,
|
int timeouts,
|
||||||
char *node,
|
char *node,
|
||||||
char *service);
|
char *service);
|
||||||
static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||||
int status,
|
int status,
|
||||||
int timeouts,
|
int timeouts,
|
||||||
struct hostent *hostent);
|
struct hostent *hostent);
|
||||||
static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
|
static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
static Eina_Bool _ecore_con_info_cares_timeout_cb(void *data);
|
static Eina_Bool _ecore_con_info_cares_timeout_cb(void *data);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_info_cares_state_cb(void *data,
|
_ecore_con_info_cares_state_cb(void *data,
|
||||||
ares_socket_t fd,
|
ares_socket_t fd,
|
||||||
int readable,
|
int readable,
|
||||||
int writable);
|
int writable);
|
||||||
static int
|
static int
|
||||||
_ecore_con_info_fds_search(const Ecore_Con_FD *fd1,
|
_ecore_con_info_fds_search(const Ecore_Con_FD *fd1,
|
||||||
const Ecore_Con_FD *fd2);
|
const Ecore_Con_FD *fd2);
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -95,7 +96,7 @@ ecore_con_info_init(void)
|
||||||
opts.sock_state_cb = _ecore_con_info_cares_state_cb;
|
opts.sock_state_cb = _ecore_con_info_cares_state_cb;
|
||||||
|
|
||||||
if (ares_init_options(&info_channel, &opts,
|
if (ares_init_options(&info_channel, &opts,
|
||||||
ARES_OPT_LOOKUPS | ARES_OPT_SOCK_STATE_CB) != ARES_SUCCESS)
|
ARES_OPT_LOOKUPS | ARES_OPT_SOCK_STATE_CB) != ARES_SUCCESS)
|
||||||
{
|
{
|
||||||
ares_library_cleanup();
|
ares_library_cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -113,11 +114,11 @@ ecore_con_info_shutdown(void)
|
||||||
if (info_init == 0)
|
if (info_init == 0)
|
||||||
{
|
{
|
||||||
/* Cancel all ongoing request */
|
/* Cancel all ongoing request */
|
||||||
ares_cancel(info_channel);
|
ares_cancel(info_channel);
|
||||||
ares_destroy(info_channel);
|
ares_destroy(info_channel);
|
||||||
|
|
||||||
/* Shutdown ares */
|
/* Shutdown ares */
|
||||||
ares_library_cleanup();
|
ares_library_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
return info_init;
|
return info_init;
|
||||||
|
@ -126,7 +127,7 @@ ecore_con_info_shutdown(void)
|
||||||
int
|
int
|
||||||
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -240,10 +241,10 @@ ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
|
_ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
|
||||||
int addrtype,
|
int addrtype,
|
||||||
const char *name,
|
const char *name,
|
||||||
struct sockaddr *addr,
|
struct sockaddr *addr,
|
||||||
int addrlen)
|
int addrlen)
|
||||||
{
|
{
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
|
@ -285,8 +286,8 @@ _ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_con_info_get(Ecore_Con_Server *svr,
|
ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data,
|
void *data,
|
||||||
struct addrinfo *hints)
|
struct addrinfo *hints)
|
||||||
{
|
{
|
||||||
Ecore_Con_CAres *cares;
|
Ecore_Con_CAres *cares;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
|
@ -358,7 +359,7 @@ _ecore_con_info_cares_timeout_cb(void *data EINA_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
|
_ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
ares_socket_t read_fd, write_fd;
|
ares_socket_t read_fd, write_fd;
|
||||||
|
@ -392,7 +393,7 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
|
||||||
Ecore_Con_FD *search = NULL, *ecf = NULL;
|
Ecore_Con_FD *search = NULL, *ecf = NULL;
|
||||||
|
|
||||||
search = eina_list_search_unsorted(info_fds,
|
search = eina_list_search_unsorted(info_fds,
|
||||||
(Eina_Compare_Cb)_ecore_con_info_fds_search, &ecf);
|
(Eina_Compare_Cb)_ecore_con_info_fds_search, &ecf);
|
||||||
|
|
||||||
if (!(readable | writable))
|
if (!(readable | writable))
|
||||||
{
|
{
|
||||||
|
@ -414,7 +415,7 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
|
||||||
|
|
||||||
search->fd = fd;
|
search->fd = fd;
|
||||||
search->handler = ecore_main_fd_handler_add(fd, ECORE_FD_WRITE | ECORE_FD_READ,
|
search->handler = ecore_main_fd_handler_add(fd, ECORE_FD_WRITE | ECORE_FD_READ,
|
||||||
(Ecore_Fd_Cb)_ecore_con_info_cares_fd_cb, search, NULL, NULL);
|
(Ecore_Fd_Cb)_ecore_con_info_cares_fd_cb, search, NULL, NULL);
|
||||||
/* c-ares default timeout is 5 seconds */
|
/* c-ares default timeout is 5 seconds */
|
||||||
search->timer = ecore_timer_add(5, _ecore_con_info_cares_timeout_cb, NULL);
|
search->timer = ecore_timer_add(5, _ecore_con_info_cares_timeout_cb, NULL);
|
||||||
info_fds = eina_list_append(info_fds, search);
|
info_fds = eina_list_append(info_fds, search);
|
||||||
|
@ -427,9 +428,9 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
_ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||||
int status,
|
int status,
|
||||||
int timeouts EINA_UNUSED,
|
int timeouts EINA_UNUSED,
|
||||||
struct hostent *hostent)
|
struct hostent *hostent)
|
||||||
{
|
{
|
||||||
struct sockaddr *addr;
|
struct sockaddr *addr;
|
||||||
int addrlen;
|
int addrlen;
|
||||||
|
@ -465,6 +466,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||||
addr = (struct sockaddr *)addri;
|
addr = (struct sockaddr *)addri;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
{
|
{
|
||||||
|
@ -487,6 +489,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||||
addr = (struct sockaddr *)addri6;
|
addr = (struct sockaddr *)addri6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
ERR("Unknown addrtype %i", hostent->h_addrtype);
|
ERR("Unknown addrtype %i", hostent->h_addrtype);
|
||||||
|
@ -505,56 +508,56 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
/* This happen when host doesn't have a reverse. */
|
/* This happen when host doesn't have a reverse. */
|
||||||
if (arg->isv6)
|
if (arg->isv6)
|
||||||
{
|
{
|
||||||
struct sockaddr_in6 *addri6;
|
struct sockaddr_in6 *addri6;
|
||||||
|
|
||||||
addrlen = sizeof(struct sockaddr_in6);
|
addrlen = sizeof(struct sockaddr_in6);
|
||||||
addri6 = malloc(addrlen);
|
addri6 = malloc(addrlen);
|
||||||
|
|
||||||
if (!addri6)
|
if (!addri6)
|
||||||
goto on_mem_error;
|
goto on_mem_error;
|
||||||
|
|
||||||
addri6->sin6_family = AF_INET6;
|
addri6->sin6_family = AF_INET6;
|
||||||
addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
||||||
addri6->sin6_flowinfo = 0;
|
addri6->sin6_flowinfo = 0;
|
||||||
addri6->sin6_scope_id = 0;
|
addri6->sin6_scope_id = 0;
|
||||||
|
|
||||||
memcpy(&addri6->sin6_addr.s6_addr,
|
memcpy(&addri6->sin6_addr.s6_addr,
|
||||||
&arg->addr.v6, sizeof(struct in6_addr));
|
&arg->addr.v6, sizeof(struct in6_addr));
|
||||||
|
|
||||||
addr = (struct sockaddr *)addri6;
|
addr = (struct sockaddr *)addri6;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
struct sockaddr_in *addri;
|
struct sockaddr_in *addri;
|
||||||
|
|
||||||
addrlen = sizeof(struct sockaddr_in);
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
addri = malloc(addrlen);
|
addri = malloc(addrlen);
|
||||||
|
|
||||||
if (!addri)
|
if (!addri)
|
||||||
goto on_mem_error;
|
goto on_mem_error;
|
||||||
|
|
||||||
addri->sin_family = AF_INET;
|
addri->sin_family = AF_INET;
|
||||||
addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
||||||
|
|
||||||
memcpy(&addri->sin_addr.s_addr,
|
memcpy(&addri->sin_addr.s_addr,
|
||||||
&arg->addr.v4, sizeof(struct in_addr));
|
&arg->addr.v4, sizeof(struct in_addr));
|
||||||
|
|
||||||
addr = (struct sockaddr *)addri;
|
addr = (struct sockaddr *)addri;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_ecore_con_info_ares_getnameinfo(arg,
|
if (!_ecore_con_info_ares_getnameinfo(arg,
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
arg->isv6 ? AF_INET6 :
|
arg->isv6 ? AF_INET6 :
|
||||||
#endif
|
#endif
|
||||||
AF_INET,
|
AF_INET,
|
||||||
NULL, addr,
|
NULL, addr,
|
||||||
addrlen))
|
addrlen))
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ARES_ENOTIMP: /* unknown family */
|
case ARES_ENOTIMP: /* unknown family */
|
||||||
|
@ -589,10 +592,10 @@ on_error:
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
_ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
||||||
int status,
|
int status,
|
||||||
int timeouts EINA_UNUSED,
|
int timeouts EINA_UNUSED,
|
||||||
char *node,
|
char *node,
|
||||||
char *service)
|
char *service)
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
#include "Ecore_Con.h"
|
#include "Ecore_Con.h"
|
||||||
#include "ecore_con_private.h"
|
#include "ecore_con_private.h"
|
||||||
|
|
||||||
typedef struct dns_addrinfo dns_addrinfo;
|
typedef struct dns_addrinfo dns_addrinfo;
|
||||||
typedef struct dns_resolv_conf dns_resolv_conf;
|
typedef struct dns_resolv_conf dns_resolv_conf;
|
||||||
typedef struct dns_resolver dns_resolver;
|
typedef struct dns_resolver dns_resolver;
|
||||||
typedef struct dns_hosts dns_hosts;
|
typedef struct dns_hosts dns_hosts;
|
||||||
|
|
||||||
typedef struct _Ecore_Con_DNS Ecore_Con_DNS;
|
typedef struct _Ecore_Con_DNS Ecore_Con_DNS;
|
||||||
|
|
||||||
struct _Ecore_Con_DNS
|
struct _Ecore_Con_DNS
|
||||||
{
|
{
|
||||||
|
@ -78,8 +78,10 @@ _ecore_con_dns_check(Ecore_Con_DNS *dns)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("resolve failed: %s", dns_strerror(error));
|
ERR("resolve failed: %s", dns_strerror(error));
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -298,7 +300,6 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
{
|
{
|
||||||
ERR("res_open: %s", dns_strerror(error));
|
ERR("res_open: %s", dns_strerror(error));
|
||||||
goto reserr;
|
goto reserr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error = _dns_addrinfo_get(dns, svr->ecs ? svr->ecs->ip : svr->name, dns->svr->ecs ? dns->svr->ecs->port : dns->svr->port);
|
error = _dns_addrinfo_get(dns, svr->ecs ? svr->ecs->ip : svr->name, dns->svr->ecs ? dns->svr->ecs->port : dns->svr->port);
|
||||||
|
@ -312,11 +313,13 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
dns->fdh = ecore_main_fd_handler_add(dns_ai_pollfd(dns->ai), dns_ai_events(dns->ai), (Ecore_Fd_Cb)_dns_fd_cb, dns, NULL, NULL);
|
dns->fdh = ecore_main_fd_handler_add(dns_ai_pollfd(dns->ai), dns_ai_events(dns->ai), (Ecore_Fd_Cb)_dns_fd_cb, dns, NULL, NULL);
|
||||||
svr->infos = eina_list_append(svr->infos, dns);
|
svr->infos = eina_list_append(svr->infos, dns);
|
||||||
dns->timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_dns_timer_cb, dns);
|
dns->timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_dns_timer_cb, dns);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,54 +17,54 @@
|
||||||
|
|
||||||
#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007
|
#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007
|
||||||
|
|
||||||
typedef struct _Ecore_Con_Eet_Data Ecore_Con_Eet_Data;
|
typedef struct _Ecore_Con_Eet_Data Ecore_Con_Eet_Data;
|
||||||
typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data;
|
typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data;
|
||||||
typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client;
|
typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client;
|
||||||
typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server;
|
typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server;
|
||||||
|
|
||||||
struct _Ecore_Con_Reply
|
struct _Ecore_Con_Reply
|
||||||
{
|
{
|
||||||
Ecore_Con_Eet *ece;
|
Ecore_Con_Eet *ece;
|
||||||
Ecore_Con_Client *client;
|
Ecore_Con_Client *client;
|
||||||
|
|
||||||
Eet_Connection *econn;
|
Eet_Connection *econn;
|
||||||
|
|
||||||
char *buffer_section;
|
char *buffer_section;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
unsigned int buffer_length;
|
unsigned int buffer_length;
|
||||||
unsigned int buffer_current;
|
unsigned int buffer_current;
|
||||||
Ecore_Con_Eet_Raw_Data *buffer_handler;
|
Ecore_Con_Eet_Raw_Data *buffer_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ecore_Con_Eet_Data
|
struct _Ecore_Con_Eet_Data
|
||||||
{
|
{
|
||||||
Ecore_Con_Eet_Data_Cb func;
|
Ecore_Con_Eet_Data_Cb func;
|
||||||
const char *name;
|
const char *name;
|
||||||
const void *data;
|
const void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ecore_Con_Eet_Raw_Data
|
struct _Ecore_Con_Eet_Raw_Data
|
||||||
{
|
{
|
||||||
Ecore_Con_Eet_Raw_Data_Cb func;
|
Ecore_Con_Eet_Raw_Data_Cb func;
|
||||||
const char *name;
|
const char *name;
|
||||||
const void *data;
|
const void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ecore_Con_Eet_Client
|
struct _Ecore_Con_Eet_Client
|
||||||
{
|
{
|
||||||
Ecore_Con_Eet_Client_Cb func;
|
Ecore_Con_Eet_Client_Cb func;
|
||||||
const void *data;
|
const void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ecore_Con_Eet_Server
|
struct _Ecore_Con_Eet_Server
|
||||||
{
|
{
|
||||||
Ecore_Con_Eet_Server_Cb func;
|
Ecore_Con_Eet_Server_Cb func;
|
||||||
const void *data;
|
const void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ecore_Con_Eet
|
struct _Ecore_Con_Eet
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *server;
|
Ecore_Con_Server *server;
|
||||||
|
|
||||||
Ecore_Event_Handler *handler_add;
|
Ecore_Event_Handler *handler_add;
|
||||||
Ecore_Event_Handler *handler_del;
|
Ecore_Event_Handler *handler_del;
|
||||||
|
@ -73,25 +73,28 @@ struct _Ecore_Con_Eet
|
||||||
Eet_Data_Descriptor *edd;
|
Eet_Data_Descriptor *edd;
|
||||||
Eet_Data_Descriptor *matching;
|
Eet_Data_Descriptor *matching;
|
||||||
|
|
||||||
Eina_Hash *data_callbacks;
|
Eina_Hash *data_callbacks;
|
||||||
Eina_Hash *raw_data_callbacks;
|
Eina_Hash *raw_data_callbacks;
|
||||||
|
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
Eina_List *connections;
|
Eina_List *connections;
|
||||||
Eina_List *client_connect_callbacks;
|
Eina_List *client_connect_callbacks;
|
||||||
Eina_List *client_disconnect_callbacks;
|
Eina_List *client_disconnect_callbacks;
|
||||||
} server;
|
} server;
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
Ecore_Con_Reply *r;
|
Ecore_Con_Reply *r;
|
||||||
Eina_List *server_connect_callbacks;
|
Eina_List *server_connect_callbacks;
|
||||||
Eina_List *server_disconnect_callbacks;
|
Eina_List *server_disconnect_callbacks;
|
||||||
} client;
|
} client;
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
const void *data;
|
const void *data;
|
||||||
|
|
||||||
Eina_Bool client : 1;
|
Eina_Bool client : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -111,6 +114,7 @@ _ecore_con_eet_raw_data_free(void *data)
|
||||||
eina_stringshare_del(eced->name);
|
eina_stringshare_del(eced->name);
|
||||||
free(eced);
|
free(eced);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_eet_reply_cleanup(Ecore_Con_Reply *n)
|
_ecore_con_eet_reply_cleanup(Ecore_Con_Reply *n)
|
||||||
{
|
{
|
||||||
|
@ -122,9 +126,10 @@ _ecore_con_eet_reply_cleanup(Ecore_Con_Reply *n)
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _Ecore_Con_Eet_Protocol Ecore_Con_Eet_Protocol;
|
typedef struct _Ecore_Con_Eet_Protocol Ecore_Con_Eet_Protocol;
|
||||||
struct _Ecore_Con_Eet_Protocol {
|
struct _Ecore_Con_Eet_Protocol
|
||||||
|
{
|
||||||
const char *type;
|
const char *type;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
@ -172,9 +177,9 @@ _ecore_con_eet_read_cb(const void *eet_data, size_t size, void *user_data)
|
||||||
if (!protocol) return EINA_TRUE;
|
if (!protocol) return EINA_TRUE;
|
||||||
|
|
||||||
cb = eina_hash_find(n->ece->data_callbacks, protocol->type);
|
cb = eina_hash_find(n->ece->data_callbacks, protocol->type);
|
||||||
if (!cb) return EINA_TRUE; /* Should I report unknow protocol communication ? */
|
if (!cb) return EINA_TRUE; /* Should I report unknow protocol communication ? */
|
||||||
|
|
||||||
cb->func((void*)cb->data, n, cb->name, protocol->data);
|
cb->func((void *)cb->data, n, cb->name, protocol->data);
|
||||||
|
|
||||||
eina_stringshare_del(protocol->type);
|
eina_stringshare_del(protocol->type);
|
||||||
free(protocol);
|
free(protocol);
|
||||||
|
@ -187,7 +192,7 @@ _ecore_con_eet_server_write_cb(const void *data, size_t size, void *user_data)
|
||||||
{
|
{
|
||||||
Ecore_Con_Reply *n = user_data;
|
Ecore_Con_Reply *n = user_data;
|
||||||
|
|
||||||
if (ecore_con_client_send(n->client, data, size) != (int) size)
|
if (ecore_con_client_send(n->client, data, size) != (int)size)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +202,7 @@ _ecore_con_eet_client_write_cb(const void *data, size_t size, void *user_data)
|
||||||
{
|
{
|
||||||
Ecore_Con_Reply *n = user_data;
|
Ecore_Con_Reply *n = user_data;
|
||||||
|
|
||||||
if (ecore_con_server_send(n->ece->server, data, size) != (int) size)
|
if (ecore_con_server_send(n->ece->server, data, size) != (int)size)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +227,7 @@ _ecore_con_eet_server_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
|
||||||
ecore_con_client_data_set(n->client, n);
|
ecore_con_client_data_set(n->client, n);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(r->u.server.client_connect_callbacks, ll, ecec)
|
EINA_LIST_FOREACH(r->u.server.client_connect_callbacks, ll, ecec)
|
||||||
if (!ecec->func((void*) ecec->data, n, n->client))
|
if (!ecec->func((void *)ecec->data, n, n->client))
|
||||||
{
|
{
|
||||||
eet_connection_close(n->econn, NULL);
|
eet_connection_close(n->econn, NULL);
|
||||||
free(n);
|
free(n);
|
||||||
|
@ -251,7 +256,7 @@ _ecore_con_eet_server_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_E
|
||||||
Eina_List *ll;
|
Eina_List *ll;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(r->u.server.client_disconnect_callbacks, ll, ecec)
|
EINA_LIST_FOREACH(r->u.server.client_disconnect_callbacks, ll, ecec)
|
||||||
ecec->func((void*) ecec->data, n, n->client);
|
ecec->func((void *)ecec->data, n, n->client);
|
||||||
|
|
||||||
eet_connection_close(n->econn, NULL);
|
eet_connection_close(n->econn, NULL);
|
||||||
free(n);
|
free(n);
|
||||||
|
@ -272,7 +277,7 @@ _ecore_con_eet_raw_data_push(Ecore_Con_Reply *n, void *data, int size)
|
||||||
if (n->buffer_current == n->buffer_length)
|
if (n->buffer_current == n->buffer_length)
|
||||||
{
|
{
|
||||||
if (n->buffer_handler)
|
if (n->buffer_handler)
|
||||||
n->buffer_handler->func((void*) n->buffer_handler->data, n, n->buffer_handler->name, n->buffer_section, n->buffer, n->buffer_length);
|
n->buffer_handler->func((void *)n->buffer_handler->data, n, n->buffer_handler->name, n->buffer_section, n->buffer, n->buffer_length);
|
||||||
_ecore_con_eet_reply_cleanup(n);
|
_ecore_con_eet_reply_cleanup(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +297,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
|
||||||
_ecore_con_eet_raw_data_push(n, data, size);
|
_ecore_con_eet_raw_data_push(n, data, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (eet_connection_empty(n->econn) && size > (int) (4 * sizeof (unsigned int) + 2))
|
else if (eet_connection_empty(n->econn) && size > (int)(4 * sizeof (unsigned int) + 2))
|
||||||
{
|
{
|
||||||
unsigned int *tmp = data;
|
unsigned int *tmp = data;
|
||||||
size -= 4 * sizeof (unsigned int);
|
size -= 4 * sizeof (unsigned int);
|
||||||
|
@ -305,7 +310,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
|
||||||
|
|
||||||
if (protocol_length > 1 && section_length > 1 && protocol_length + section_length <= size && data_length < 10 * 1024 * 1024)
|
if (protocol_length > 1 && section_length > 1 && protocol_length + section_length <= size && data_length < 10 * 1024 * 1024)
|
||||||
{
|
{
|
||||||
char *buffer = (char*) &tmp[4];
|
char *buffer = (char *)&tmp[4];
|
||||||
char *protocol;
|
char *protocol;
|
||||||
char *section;
|
char *section;
|
||||||
|
|
||||||
|
@ -325,7 +330,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
|
||||||
if (n->buffer_handler)
|
if (n->buffer_handler)
|
||||||
n->buffer = malloc(sizeof (unsigned char) * data_length);
|
n->buffer = malloc(sizeof (unsigned char) * data_length);
|
||||||
else
|
else
|
||||||
n->buffer = (void*) 1;
|
n->buffer = (void *)1;
|
||||||
if (n->buffer)
|
if (n->buffer)
|
||||||
{
|
{
|
||||||
_ecore_con_eet_raw_data_push(n, buffer, size);
|
_ecore_con_eet_raw_data_push(n, buffer, size);
|
||||||
|
@ -382,7 +387,7 @@ _ecore_con_eet_client_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
|
||||||
n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_client_write_cb, n);
|
n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_client_write_cb, n);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(r->u.client.server_connect_callbacks, ll, eces)
|
EINA_LIST_FOREACH(r->u.client.server_connect_callbacks, ll, eces)
|
||||||
if (!eces->func((void*) eces->data, n, n->ece->server))
|
if (!eces->func((void *)eces->data, n, n->ece->server))
|
||||||
{
|
{
|
||||||
eet_connection_close(n->econn, NULL);
|
eet_connection_close(n->econn, NULL);
|
||||||
free(n);
|
free(n);
|
||||||
|
@ -406,7 +411,7 @@ _ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_E
|
||||||
|
|
||||||
/* Client disconnected */
|
/* Client disconnected */
|
||||||
EINA_LIST_FOREACH(r->u.client.server_disconnect_callbacks, ll, eces)
|
EINA_LIST_FOREACH(r->u.client.server_disconnect_callbacks, ll, eces)
|
||||||
eces->func((void*) eces->data, r->u.client.r, r->server);
|
eces->func((void *)eces->data, r->u.client.r, r->server);
|
||||||
|
|
||||||
eet_connection_close(r->u.client.r->econn, NULL);
|
eet_connection_close(r->u.client.r->econn, NULL);
|
||||||
free(r->u.client.r);
|
free(r->u.client.r);
|
||||||
|
@ -430,8 +435,8 @@ _ecore_con_eet_client_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Ser
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
* Global API *
|
* Global API *
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
EAPI Ecore_Con_Eet *
|
EAPI Ecore_Con_Eet *
|
||||||
ecore_con_eet_server_new(Ecore_Con_Server *server)
|
ecore_con_eet_server_new(Ecore_Con_Server *server)
|
||||||
|
@ -590,7 +595,7 @@ ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name)
|
||||||
{
|
{
|
||||||
ece->u.client.r->buffer_handler = NULL;
|
ece->u.client.r->buffer_handler = NULL;
|
||||||
free(ece->u.client.r->buffer);
|
free(ece->u.client.r->buffer);
|
||||||
ece->u.client.r->buffer = (void*) 1;
|
ece->u.client.r->buffer = (void *)1;
|
||||||
}
|
}
|
||||||
eina_hash_del(ece->raw_data_callbacks, name, NULL);
|
eina_hash_del(ece->raw_data_callbacks, name, NULL);
|
||||||
}
|
}
|
||||||
|
@ -740,7 +745,7 @@ EAPI void *
|
||||||
ecore_con_eet_data_get(Ecore_Con_Eet *ece)
|
ecore_con_eet_data_get(Ecore_Con_Eet *ece)
|
||||||
{
|
{
|
||||||
if (!ece) return NULL;
|
if (!ece) return NULL;
|
||||||
return (void*) ece->data;
|
return (void *)ece->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Ecore_Con_Eet *
|
EAPI Ecore_Con_Eet *
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef struct _CB_Data CB_Data;
|
||||||
|
|
||||||
struct _CB_Data
|
struct _CB_Data
|
||||||
{
|
{
|
||||||
EINA_INLIST;
|
EINA_INLIST;
|
||||||
Ecore_Con_Info_Cb cb_done;
|
Ecore_Con_Info_Cb cb_done;
|
||||||
void *data;
|
void *data;
|
||||||
Ecore_Fd_Handler *fdh;
|
Ecore_Fd_Handler *fdh;
|
||||||
|
@ -56,11 +56,11 @@ struct _CB_Data
|
||||||
|
|
||||||
static void _ecore_con_info_readdata(CB_Data *cbdata);
|
static void _ecore_con_info_readdata(CB_Data *cbdata);
|
||||||
static void _ecore_con_info_slave_free(CB_Data *cbdata);
|
static void _ecore_con_info_slave_free(CB_Data *cbdata);
|
||||||
static Eina_Bool _ecore_con_info_data_handler(void *data,
|
static Eina_Bool _ecore_con_info_data_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
static Eina_Bool _ecore_con_info_exit_handler(void *data,
|
static Eina_Bool _ecore_con_info_exit_handler(void *data,
|
||||||
int type EINA_UNUSED,
|
int type EINA_UNUSED,
|
||||||
void *event);
|
void *event);
|
||||||
|
|
||||||
static int info_init = 0;
|
static int info_init = 0;
|
||||||
static CB_Data *info_slaves = NULL;
|
static CB_Data *info_slaves = NULL;
|
||||||
|
@ -77,7 +77,8 @@ ecore_con_info_shutdown(void)
|
||||||
{
|
{
|
||||||
info_init--;
|
info_init--;
|
||||||
if (info_init == 0)
|
if (info_init == 0)
|
||||||
while (info_slaves) _ecore_con_info_slave_free(info_slaves);
|
while (info_slaves)
|
||||||
|
_ecore_con_info_slave_free(info_slaves);
|
||||||
|
|
||||||
return info_init;
|
return info_init;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +86,7 @@ ecore_con_info_shutdown(void)
|
||||||
int
|
int
|
||||||
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ _ecore_fd_close_on_exec(int fd)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
#else
|
#else
|
||||||
(void) fd;
|
(void)fd;
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -200,8 +201,8 @@ _ecore_fd_close_on_exec(int fd)
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_con_info_get(Ecore_Con_Server *svr,
|
ecore_con_info_get(Ecore_Con_Server *svr,
|
||||||
Ecore_Con_Info_Cb done_cb,
|
Ecore_Con_Info_Cb done_cb,
|
||||||
void *data,
|
void *data,
|
||||||
struct addrinfo *hints)
|
struct addrinfo *hints)
|
||||||
{
|
{
|
||||||
CB_Data *cbdata;
|
CB_Data *cbdata;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
|
@ -407,7 +408,7 @@ _ecore_con_info_slave_free(CB_Data *cbdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_info_data_handler(void *data,
|
_ecore_con_info_data_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
CB_Data *cbdata;
|
CB_Data *cbdata;
|
||||||
|
@ -434,9 +435,9 @@ _ecore_con_info_data_handler(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_info_exit_handler(void *data,
|
_ecore_con_info_exit_handler(void *data,
|
||||||
int type EINA_UNUSED,
|
int type EINA_UNUSED,
|
||||||
void *event)
|
void *event)
|
||||||
{
|
{
|
||||||
CB_Data *cbdata;
|
CB_Data *cbdata;
|
||||||
Ecore_Exe_Event_Del *ev;
|
Ecore_Exe_Event_Del *ev;
|
||||||
|
|
|
@ -181,10 +181,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_local_listen(
|
ecore_con_local_listen(
|
||||||
Ecore_Con_Server *svr,
|
Ecore_Con_Server *svr,
|
||||||
Eina_Bool (*
|
Eina_Bool (*
|
||||||
cb_listen)(void *data,
|
cb_listen)(void *data,
|
||||||
Ecore_Fd_Handler *
|
Ecore_Fd_Handler *
|
||||||
fd_handler),
|
fd_handler),
|
||||||
void *data
|
void *data
|
||||||
EINA_UNUSED)
|
EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -291,28 +291,28 @@ start:
|
||||||
if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
|
if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
|
||||||
{
|
{
|
||||||
if (sd_is_socket_unix(SD_LISTEN_FDS_START + sd_fd_index,
|
if (sd_is_socket_unix(SD_LISTEN_FDS_START + sd_fd_index,
|
||||||
SOCK_STREAM, 1,
|
SOCK_STREAM, 1,
|
||||||
socket_unix.sun_path,
|
socket_unix.sun_path,
|
||||||
abstract_socket ? socket_unix_len : 0) <= 0)
|
abstract_socket ? socket_unix_len : 0) <= 0)
|
||||||
{
|
{
|
||||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||||
goto error_umask;
|
goto error_umask;
|
||||||
}
|
}
|
||||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||||
|
|
||||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
|
||||||
goto error_umask;
|
goto error_umask;
|
||||||
|
|
||||||
lin.l_onoff = 1;
|
lin.l_onoff = 1;
|
||||||
lin.l_linger = 0;
|
lin.l_linger = 0;
|
||||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||||
sizeof(struct linger)) < 0)
|
sizeof(struct linger)) < 0)
|
||||||
goto error_umask;
|
goto error_umask;
|
||||||
|
|
||||||
goto fd_ready;
|
goto fd_ready;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void) abstract_socket;
|
(void)abstract_socket;
|
||||||
#endif
|
#endif
|
||||||
svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
if (svr->fd < 0)
|
if (svr->fd < 0)
|
||||||
|
@ -346,7 +346,7 @@ start:
|
||||||
goto error_umask;
|
goto error_umask;
|
||||||
|
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
fd_ready:
|
fd_ready:
|
||||||
#endif
|
#endif
|
||||||
svr->path = strdup(buf);
|
svr->path = strdup(buf);
|
||||||
if (!svr->path)
|
if (!svr->path)
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#define BUFSIZE 512
|
#define BUFSIZE 512
|
||||||
|
|
||||||
|
|
||||||
static int _ecore_con_local_init_count = 0;
|
static int _ecore_con_local_init_count = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -33,58 +32,57 @@ ecore_con_local_shutdown(void)
|
||||||
return _ecore_con_local_init_count;
|
return _ecore_con_local_init_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_local_win32_server_read_client_handler(void *data, Ecore_Win32_Handler *wh)
|
_ecore_con_local_win32_server_read_client_handler(void *data, Ecore_Win32_Handler *wh)
|
||||||
{
|
{
|
||||||
Ecore_Con_Client *cl;
|
Ecore_Con_Client *cl;
|
||||||
void *buf;
|
void *buf;
|
||||||
DWORD n;
|
DWORD n;
|
||||||
Eina_Bool broken_pipe = EINA_FALSE;
|
Eina_Bool broken_pipe = EINA_FALSE;
|
||||||
|
|
||||||
cl = (Ecore_Con_Client *)data;
|
cl = (Ecore_Con_Client *)data;
|
||||||
|
|
||||||
if (!ResetEvent(cl->host_server->event_read))
|
if (!ResetEvent(cl->host_server->event_read))
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
buf = malloc(cl->host_server->nbr_bytes);
|
buf = malloc(cl->host_server->nbr_bytes);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL))
|
if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL))
|
||||||
{
|
{
|
||||||
if (!cl->delete_me)
|
if (!cl->delete_me)
|
||||||
ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE);
|
ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE);
|
||||||
cl->host_server->want_write = 1;
|
cl->host_server->want_write = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_BROKEN_PIPE)
|
if (GetLastError() == ERROR_BROKEN_PIPE)
|
||||||
broken_pipe = EINA_TRUE;
|
broken_pipe = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broken_pipe)
|
if (broken_pipe)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
msg = evil_last_error_get();
|
msg = evil_last_error_get();
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
ecore_con_event_client_error(cl, msg);
|
ecore_con_event_client_error(cl, msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_ecore_con_client_kill(cl);
|
_ecore_con_client_kill(cl);
|
||||||
return ECORE_CALLBACK_CANCEL;
|
return ECORE_CALLBACK_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cl->host_server->want_write)
|
if (cl->host_server->want_write)
|
||||||
ecore_con_local_win32_client_flush(cl);
|
ecore_con_local_win32_client_flush(cl);
|
||||||
|
|
||||||
ecore_main_win32_handler_del(wh);
|
ecore_main_win32_handler_del(wh);
|
||||||
|
|
||||||
return ECORE_CALLBACK_DONE;
|
return ECORE_CALLBACK_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -147,54 +145,54 @@ _ecore_con_local_win32_client_peek_server_handler(void *data, Ecore_Win32_Handle
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_local_win32_client_read_server_handler(void *data, Ecore_Win32_Handler *wh)
|
_ecore_con_local_win32_client_read_server_handler(void *data, Ecore_Win32_Handler *wh)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
void *buf;
|
void *buf;
|
||||||
DWORD n;
|
DWORD n;
|
||||||
Eina_Bool broken_pipe = EINA_FALSE;
|
Eina_Bool broken_pipe = EINA_FALSE;
|
||||||
|
|
||||||
svr = (Ecore_Con_Server *)data;
|
svr = (Ecore_Con_Server *)data;
|
||||||
|
|
||||||
if (!ResetEvent(svr->event_read))
|
if (!ResetEvent(svr->event_read))
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
buf = malloc(svr->nbr_bytes);
|
buf = malloc(svr->nbr_bytes);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL))
|
if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL))
|
||||||
{
|
{
|
||||||
if (!svr->delete_me)
|
if (!svr->delete_me)
|
||||||
ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE);
|
ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE);
|
||||||
svr->want_write = 1;
|
svr->want_write = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_BROKEN_PIPE)
|
if (GetLastError() == ERROR_BROKEN_PIPE)
|
||||||
broken_pipe = EINA_TRUE;
|
broken_pipe = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broken_pipe)
|
if (broken_pipe)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
msg = evil_last_error_get();
|
msg = evil_last_error_get();
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
ecore_con_event_server_error(svr, msg);
|
ecore_con_event_server_error(svr, msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_ecore_con_server_kill(svr);
|
_ecore_con_server_kill(svr);
|
||||||
return ECORE_CALLBACK_CANCEL;
|
return ECORE_CALLBACK_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svr->want_write)
|
if (svr->want_write)
|
||||||
ecore_con_local_win32_server_flush(svr);
|
ecore_con_local_win32_server_flush(svr);
|
||||||
|
|
||||||
ecore_main_win32_handler_del(wh);
|
ecore_main_win32_handler_del(wh);
|
||||||
|
|
||||||
return ECORE_CALLBACK_DONE;
|
return ECORE_CALLBACK_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* thread to read data sent by the server to the client */
|
/* thread to read data sent by the server to the client */
|
||||||
|
@ -356,15 +354,15 @@ _ecore_con_local_win32_client_add(void *data, Ecore_Win32_Handler *wh)
|
||||||
ResumeThread(cl->host_server->thread_read);
|
ResumeThread(cl->host_server->thread_read);
|
||||||
return ECORE_CALLBACK_DONE;
|
return ECORE_CALLBACK_DONE;
|
||||||
|
|
||||||
del_handler_peek:
|
del_handler_peek:
|
||||||
ecore_main_win32_handler_del(handler_peek);
|
ecore_main_win32_handler_del(handler_peek);
|
||||||
close_event_peek:
|
close_event_peek:
|
||||||
CloseHandle(cl->host_server->event_peek);
|
CloseHandle(cl->host_server->event_peek);
|
||||||
del_handler_read:
|
del_handler_read:
|
||||||
ecore_main_win32_handler_del(handler_read);
|
ecore_main_win32_handler_del(handler_read);
|
||||||
close_event_read:
|
close_event_read:
|
||||||
CloseHandle(cl->host_server->event_read);
|
CloseHandle(cl->host_server->event_read);
|
||||||
free_cl:
|
free_cl:
|
||||||
free(cl);
|
free(cl);
|
||||||
|
|
||||||
return ECORE_CALLBACK_CANCEL;
|
return ECORE_CALLBACK_CANCEL;
|
||||||
|
@ -472,11 +470,11 @@ ecore_con_local_listen(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
||||||
del_handler:
|
del_handler:
|
||||||
ecore_main_win32_handler_del(handler);
|
ecore_main_win32_handler_del(handler);
|
||||||
close_pipe:
|
close_pipe:
|
||||||
CloseHandle(svr->pipe);
|
CloseHandle(svr->pipe);
|
||||||
free_path:
|
free_path:
|
||||||
free(svr->path);
|
free(svr->path);
|
||||||
svr->path = NULL;
|
svr->path = NULL;
|
||||||
|
|
||||||
|
@ -579,7 +577,7 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
||||||
{
|
{
|
||||||
ERR("Connection to a server failed");
|
ERR("Connection to a server failed");
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pipe busy, so we wait for it */
|
/* pipe busy, so we wait for it */
|
||||||
if (!WaitNamedPipe(buf, NMPWAIT_WAIT_FOREVER))
|
if (!WaitNamedPipe(buf, NMPWAIT_WAIT_FOREVER))
|
||||||
|
@ -641,18 +639,18 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
||||||
del_handler_peek:
|
del_handler_peek:
|
||||||
ecore_main_win32_handler_del(handler_peek);
|
ecore_main_win32_handler_del(handler_peek);
|
||||||
close_event_peek:
|
close_event_peek:
|
||||||
CloseHandle(svr->event_peek);
|
CloseHandle(svr->event_peek);
|
||||||
del_handler_read:
|
del_handler_read:
|
||||||
ecore_main_win32_handler_del(handler_read);
|
ecore_main_win32_handler_del(handler_read);
|
||||||
close_event_read:
|
close_event_read:
|
||||||
CloseHandle(svr->event_read);
|
CloseHandle(svr->event_read);
|
||||||
free_path:
|
free_path:
|
||||||
free(svr->path);
|
free(svr->path);
|
||||||
svr->path = NULL;
|
svr->path = NULL;
|
||||||
close_pipe:
|
close_pipe:
|
||||||
CloseHandle(svr->pipe);
|
CloseHandle(svr->pipe);
|
||||||
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
@ -752,3 +750,4 @@ ecore_con_local_win32_client_flush(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#include "ecore_con_private.h"
|
#include "ecore_con_private.h"
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(IF_NAMESIZE)
|
#if defined(_WIN32) && !defined(IF_NAMESIZE)
|
||||||
#define IF_NAMESIZE 16
|
#define IF_NAMESIZE 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* http://tools.ietf.org/html/rfc1928
|
/* http://tools.ietf.org/html/rfc1928
|
||||||
|
@ -58,9 +58,9 @@
|
||||||
o X'03' to X'7F' IANA ASSIGNED
|
o X'03' to X'7F' IANA ASSIGNED
|
||||||
o X'80' to X'FE' RESERVED FOR PRIVATE METHODS
|
o X'80' to X'FE' RESERVED FOR PRIVATE METHODS
|
||||||
o X'FF' NO ACCEPTABLE METHODS
|
o X'FF' NO ACCEPTABLE METHODS
|
||||||
*/
|
*/
|
||||||
#define ECORE_CON_SOCKS_V5_METHOD_NONE 0
|
#define ECORE_CON_SOCKS_V5_METHOD_NONE 0
|
||||||
#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1
|
#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1
|
||||||
#define ECORE_CON_SOCKS_V5_METHOD_USERPASS 2
|
#define ECORE_CON_SOCKS_V5_METHOD_USERPASS 2
|
||||||
|
|
||||||
static int ECORE_CON_SOCKS_V5_METHODS[] =
|
static int ECORE_CON_SOCKS_V5_METHODS[] =
|
||||||
|
@ -72,27 +72,27 @@ static int ECORE_CON_SOCKS_V5_METHODS[] =
|
||||||
|
|
||||||
#define ECORE_CON_SOCKS_V5_TOTAL_METHODS (sizeof(ECORE_CON_SOCKS_V5_METHODS) / sizeof(int))
|
#define ECORE_CON_SOCKS_V5_TOTAL_METHODS (sizeof(ECORE_CON_SOCKS_V5_METHODS) / sizeof(int))
|
||||||
|
|
||||||
#define _ecore_con_server_kill(svr) do { \
|
#define _ecore_con_server_kill(svr) do { \
|
||||||
DBG("KILL %p", (svr)); \
|
DBG("KILL %p", (svr)); \
|
||||||
_ecore_con_server_kill((svr)); \
|
_ecore_con_server_kill((svr)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ECORE_CON_SOCKS_VERSION_CHECK(X) do { \
|
#define ECORE_CON_SOCKS_VERSION_CHECK(X) do { \
|
||||||
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
||||||
return; \
|
return; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define ECORE_CON_SOCKS_VERSION_CHECK_RETURN(X, ret) do { \
|
#define ECORE_CON_SOCKS_VERSION_CHECK_RETURN(X, ret) do { \
|
||||||
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
||||||
return (ret); \
|
return (ret); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ECORE_CON_SOCKS_CAST(X) \
|
#define ECORE_CON_SOCKS_CAST(X) \
|
||||||
Ecore_Con_Socks_v4 *v4 = NULL; \
|
Ecore_Con_Socks_v4 * v4 = NULL; \
|
||||||
Ecore_Con_Socks_v5 *v5 = NULL; \
|
Ecore_Con_Socks_v5 *v5 = NULL; \
|
||||||
if ((X) && ((X)->version == 4)) \
|
if ((X) && ((X)->version == 4)) \
|
||||||
v4 = (Ecore_Con_Socks_v4 *)(X); \
|
v4 = (Ecore_Con_Socks_v4 *)(X); \
|
||||||
else if ((X) && ((X)->version == 5)) \
|
else if ((X) && ((X)->version == 5)) \
|
||||||
v5 = (Ecore_Con_Socks_v5 *)(X);
|
v5 = (Ecore_Con_Socks_v5 *)(X);
|
||||||
|
|
||||||
Eina_List *ecore_con_socks_proxies = NULL;
|
Eina_List *ecore_con_socks_proxies = NULL;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ _ecore_con_socks_find(unsigned char version, const char *ip, int port, const cha
|
||||||
if (plen != ecs->plen) continue;
|
if (plen != ecs->plen) continue;
|
||||||
if (password && strcmp(ecs->password, password)) continue;
|
if (password && strcmp(ecs->password, password)) continue;
|
||||||
}
|
}
|
||||||
return (Ecore_Con_Socks*)ecs;
|
return (Ecore_Con_Socks *)ecs;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ _ecore_con_socks_svr_init_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4)
|
||||||
|
|
||||||
addrlen = v4->lookup ? strlen(svr->name) + 1 : 0;
|
addrlen = v4->lookup ? strlen(svr->name) + 1 : 0;
|
||||||
if (v4->username) ulen += v4->ulen;
|
if (v4->username) ulen += v4->ulen;
|
||||||
buflen = sizeof(char) * (8 + ulen + addrlen);
|
buflen = sizeof(char) * (8 + ulen + addrlen);
|
||||||
sbuf = malloc(buflen);
|
sbuf = malloc(buflen);
|
||||||
if (!sbuf)
|
if (!sbuf)
|
||||||
{
|
{
|
||||||
|
@ -180,7 +180,7 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
||||||
unsigned char *sbuf;
|
unsigned char *sbuf;
|
||||||
|
|
||||||
if (v5->username)
|
if (v5->username)
|
||||||
buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS);
|
buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS);
|
||||||
else
|
else
|
||||||
buflen = 3;
|
buflen = 3;
|
||||||
sbuf = malloc(buflen);
|
sbuf = malloc(buflen);
|
||||||
|
@ -196,9 +196,9 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
||||||
sbuf[0] = 5;
|
sbuf[0] = 5;
|
||||||
if (v5->username)
|
if (v5->username)
|
||||||
{
|
{
|
||||||
sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS;
|
sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS;
|
||||||
for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++)
|
for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++)
|
||||||
sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2];
|
sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -210,19 +210,20 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ECORE_CON_SOCKS_READ(EXACT) \
|
#define ECORE_CON_SOCKS_READ(EXACT) \
|
||||||
if (num < EXACT) \
|
if (num < EXACT) \
|
||||||
{ \
|
{ \
|
||||||
if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \
|
if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \
|
||||||
if (!svr->ecs_recvbuf) goto error; \
|
if (!svr->ecs_recvbuf) goto error; \
|
||||||
eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \
|
eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \
|
||||||
/* the slowest connection on earth */ \
|
/* the slowest connection on earth */ \
|
||||||
if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \
|
if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \
|
||||||
data = eina_binbuf_string_get(svr->ecs_recvbuf); \
|
data = eina_binbuf_string_get(svr->ecs_recvbuf); \
|
||||||
} \
|
} \
|
||||||
else if (num > EXACT) goto error; \
|
else if (num > EXACT) \
|
||||||
else \
|
goto error; \
|
||||||
data = buf
|
else \
|
||||||
|
data = buf
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_socks_read_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4 EINA_UNUSED, const unsigned char *buf, unsigned int num)
|
_ecore_con_socks_read_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4 EINA_UNUSED, const unsigned char *buf, unsigned int num)
|
||||||
|
@ -238,15 +239,19 @@ _ecore_con_socks_read_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4 EINA_UNUS
|
||||||
case 90:
|
case 90:
|
||||||
/* success! */
|
/* success! */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 91:
|
case 91:
|
||||||
ecore_con_event_server_error(svr, "proxy request rejected or failed");
|
ecore_con_event_server_error(svr, "proxy request rejected or failed");
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
case 92:
|
case 92:
|
||||||
ecore_con_event_server_error(svr, "proxying SOCKS server could not perform authentication");
|
ecore_con_event_server_error(svr, "proxying SOCKS server could not perform authentication");
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
case 93:
|
case 93:
|
||||||
ecore_con_event_server_error(svr, "proxy request authentication rejected");
|
ecore_con_event_server_error(svr, "proxy request authentication rejected");
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ecore_con_event_server_error(svr, "garbage data from proxy");
|
ecore_con_event_server_error(svr, "garbage data from proxy");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -285,30 +290,33 @@ _ecore_con_socks_auth_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
switch (v5->method)
|
switch (v5->method)
|
||||||
{
|
{
|
||||||
case ECORE_CON_SOCKS_V5_METHOD_NONE:
|
case ECORE_CON_SOCKS_V5_METHOD_NONE:
|
||||||
svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST;
|
svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
|
|
||||||
return EINA_TRUE;
|
case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
|
||||||
case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
|
return EINA_TRUE;
|
||||||
if (!v5->username) return EINA_FALSE;
|
|
||||||
if (!v5->password) v5->plen = 1;
|
case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
|
||||||
/* http://tools.ietf.org/html/rfc1929 */
|
if (!v5->username) return EINA_FALSE;
|
||||||
size = sizeof(char) * (3 + v5->ulen + v5->plen);
|
if (!v5->password) v5->plen = 1;
|
||||||
data = malloc(size);
|
/* http://tools.ietf.org/html/rfc1929 */
|
||||||
if (!data) break;
|
size = sizeof(char) * (3 + v5->ulen + v5->plen);
|
||||||
data[0] = 1;
|
data = malloc(size);
|
||||||
data[1] = v5->ulen;
|
if (!data) break;
|
||||||
memcpy(&data[2], v5->username, v5->ulen);
|
data[0] = 1;
|
||||||
data[1 + v5->ulen] = v5->plen;
|
data[1] = v5->ulen;
|
||||||
if (v5->password)
|
memcpy(&data[2], v5->username, v5->ulen);
|
||||||
memcpy(&data[2 + v5->ulen], v5->password, v5->plen);
|
data[1 + v5->ulen] = v5->plen;
|
||||||
else
|
if (v5->password)
|
||||||
data[2 + v5->ulen] = 0;
|
memcpy(&data[2 + v5->ulen], v5->password, v5->plen);
|
||||||
svr->ecs_buf = eina_binbuf_manage_new_length(data, size);
|
else
|
||||||
return EINA_TRUE;
|
data[2 + v5->ulen] = 0;
|
||||||
default:
|
svr->ecs_buf = eina_binbuf_manage_new_length(data, size);
|
||||||
break;
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -321,173 +329,191 @@ _ecore_con_socks_read_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5, const un
|
||||||
DBG("SOCKS: %d bytes", num);
|
DBG("SOCKS: %d bytes", num);
|
||||||
switch (svr->ecs_state)
|
switch (svr->ecs_state)
|
||||||
{
|
{
|
||||||
|
case ECORE_CON_PROXY_STATE_READ:
|
||||||
case ECORE_CON_PROXY_STATE_READ:
|
ECORE_CON_SOCKS_READ(2);
|
||||||
ECORE_CON_SOCKS_READ(2);
|
/* http://en.wikipedia.org/wiki/SOCKS */
|
||||||
/* http://en.wikipedia.org/wiki/SOCKS */
|
if (data[0] != 5) goto error;
|
||||||
if (data[0] != 5) goto error;
|
if (data[1] == 0xFF)
|
||||||
if (data[1] == 0xFF)
|
|
||||||
{
|
|
||||||
ecore_con_event_server_error(svr, "proxy authentication methods rejected");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
v5->method = data[1];
|
|
||||||
if (!_ecore_con_socks_auth_v5(svr, v5)) goto error;
|
|
||||||
if (svr->ecs_state == ECORE_CON_PROXY_STATE_REQUEST)
|
|
||||||
{
|
|
||||||
/* run again to skip auth reading */
|
|
||||||
_ecore_con_socks_read_v5(svr, v5, NULL, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
|
|
||||||
svr->ecs_state = ECORE_CON_PROXY_STATE_AUTH;
|
|
||||||
break;
|
|
||||||
case ECORE_CON_PROXY_STATE_AUTH:
|
|
||||||
ECORE_CON_SOCKS_READ(2);
|
|
||||||
switch (v5->method)
|
|
||||||
{
|
|
||||||
case ECORE_CON_SOCKS_V5_METHOD_NONE:
|
|
||||||
CRIT("HOW DID THIS HAPPEN?????????");
|
|
||||||
goto error;
|
|
||||||
case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
|
|
||||||
/* TODO: this */
|
|
||||||
break;
|
|
||||||
case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
|
|
||||||
if (data[0] != 1)
|
|
||||||
{
|
|
||||||
ecore_con_event_server_error(svr, "protocol error");
|
|
||||||
goto error; /* wrong version */
|
|
||||||
}
|
|
||||||
if (data[1])
|
|
||||||
{
|
|
||||||
ecore_con_event_server_error(svr, "proxy request authentication rejected");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ECORE_CON_PROXY_STATE_REQUEST:
|
|
||||||
{
|
{
|
||||||
size_t addrlen, buflen;
|
ecore_con_event_server_error(svr, "proxy authentication methods rejected");
|
||||||
unsigned char *sbuf;
|
goto error;
|
||||||
addrlen = v5->lookup ? strlen(svr->name) + 1 : (unsigned int)svr->ecs_addrlen;
|
|
||||||
buflen = sizeof(char) * (6 + addrlen);
|
|
||||||
sbuf = malloc(buflen);
|
|
||||||
if (!sbuf)
|
|
||||||
{
|
|
||||||
ecore_con_event_server_error(svr, "Memory allocation failure!");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
sbuf[0] = 5;
|
|
||||||
sbuf[1] = v5->bind ? 2 : 1; /* TODO: 0x03 for UDP port association */
|
|
||||||
sbuf[2] = 0;
|
|
||||||
if (v5->lookup) /* domain name */
|
|
||||||
{
|
|
||||||
sbuf[3] = 3;
|
|
||||||
sbuf[4] = addrlen - 1;
|
|
||||||
memcpy(sbuf + 5, svr->name, addrlen - 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sbuf[3] = (svr->ecs_addrlen == 4) ? 1 : 4;
|
|
||||||
memcpy(sbuf + 4, svr->ecs_addr, addrlen);
|
|
||||||
}
|
|
||||||
sbuf[addrlen + 4] = svr->port >> 8;
|
|
||||||
sbuf[addrlen + 5] = svr->port & 0xff;
|
|
||||||
|
|
||||||
svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
|
|
||||||
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ECORE_CON_PROXY_STATE_CONFIRM:
|
v5->method = data[1];
|
||||||
|
if (!_ecore_con_socks_auth_v5(svr, v5)) goto error;
|
||||||
|
if (svr->ecs_state == ECORE_CON_PROXY_STATE_REQUEST)
|
||||||
{
|
{
|
||||||
/* this is ugly because we have to read an exact number of bytes,
|
/* run again to skip auth reading */
|
||||||
* but we don't know what that number is until we've already read
|
_ecore_con_socks_read_v5(svr, v5, NULL, 0);
|
||||||
* at least 5 bytes to determine the length of the unknown stream.
|
return;
|
||||||
* yep.
|
}
|
||||||
*/
|
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
|
||||||
size_t to_read, len = svr->ecs_recvbuf ? eina_binbuf_length_get(svr->ecs_recvbuf) : 0;
|
svr->ecs_state = ECORE_CON_PROXY_STATE_AUTH;
|
||||||
if (num + len < 5)
|
break;
|
||||||
{
|
|
||||||
/* guarantees we get called again */
|
|
||||||
ECORE_CON_SOCKS_READ(5);
|
|
||||||
}
|
|
||||||
if (len >= 5)
|
|
||||||
{
|
|
||||||
data = eina_binbuf_string_get(svr->ecs_recvbuf);
|
|
||||||
data += 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
data = buf + 3 - len;
|
|
||||||
switch (data[0])
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
to_read = 4;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
to_read = data[1] + 1;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
to_read = 16;
|
|
||||||
/* lazy debugging stub comment */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ecore_con_event_server_error(svr, "protocol error");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
/* at this point, we finally know exactly how much we need to read */
|
|
||||||
ECORE_CON_SOCKS_READ(6 + to_read);
|
|
||||||
|
|
||||||
if (data[0] != 5)
|
case ECORE_CON_PROXY_STATE_AUTH:
|
||||||
|
ECORE_CON_SOCKS_READ(2);
|
||||||
|
switch (v5->method)
|
||||||
|
{
|
||||||
|
case ECORE_CON_SOCKS_V5_METHOD_NONE:
|
||||||
|
CRIT("HOW DID THIS HAPPEN?????????");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
|
||||||
|
/* TODO: this */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
|
||||||
|
if (data[0] != 1)
|
||||||
{
|
{
|
||||||
ecore_con_event_server_error(svr, "protocol error");
|
ecore_con_event_server_error(svr, "protocol error");
|
||||||
goto error; /* wrong version */
|
goto error; /* wrong version */
|
||||||
}
|
}
|
||||||
switch (data[1])
|
if (data[1])
|
||||||
{
|
{
|
||||||
case 0:
|
ecore_con_event_server_error(svr, "proxy request authentication rejected");
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
ecore_con_event_server_error(svr, "general proxy failure");
|
|
||||||
goto error;
|
|
||||||
case 2:
|
|
||||||
ecore_con_event_server_error(svr, "connection not allowed by ruleset");
|
|
||||||
goto error;
|
|
||||||
case 3:
|
|
||||||
ecore_con_event_server_error(svr, "network unreachable");
|
|
||||||
goto error;
|
|
||||||
case 4:
|
|
||||||
ecore_con_event_server_error(svr, "host unreachable");
|
|
||||||
goto error;
|
|
||||||
case 5:
|
|
||||||
ecore_con_event_server_error(svr, "connection refused by destination host");
|
|
||||||
goto error;
|
|
||||||
case 6:
|
|
||||||
ecore_con_event_server_error(svr, "TTL expired");
|
|
||||||
goto error;
|
|
||||||
case 7:
|
|
||||||
ecore_con_event_server_error(svr, "command not supported / protocol error");
|
|
||||||
goto error;
|
|
||||||
case 8:
|
|
||||||
ecore_con_event_server_error(svr, "address type not supported");
|
|
||||||
default:
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (data[2])
|
|
||||||
{
|
|
||||||
ecore_con_event_server_error(svr, "protocol error");
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr));
|
|
||||||
if (!svr->ssl_state)
|
default:
|
||||||
ecore_con_event_server_add(svr);
|
|
||||||
if (svr->ssl_state || (svr->buf && eina_binbuf_length_get(svr->buf)))
|
|
||||||
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
|
|
||||||
svr->ecs_buf_offset = svr->ecs_addrlen = 0;
|
|
||||||
svr->ecs_state = ECORE_CON_PROXY_STATE_DONE;
|
|
||||||
INF("PROXY CONNECTED");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ECORE_CON_PROXY_STATE_REQUEST:
|
||||||
|
{
|
||||||
|
size_t addrlen, buflen;
|
||||||
|
unsigned char *sbuf;
|
||||||
|
addrlen = v5->lookup ? strlen(svr->name) + 1 : (unsigned int)svr->ecs_addrlen;
|
||||||
|
buflen = sizeof(char) * (6 + addrlen);
|
||||||
|
sbuf = malloc(buflen);
|
||||||
|
if (!sbuf)
|
||||||
|
{
|
||||||
|
ecore_con_event_server_error(svr, "Memory allocation failure!");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
sbuf[0] = 5;
|
||||||
|
sbuf[1] = v5->bind ? 2 : 1; /* TODO: 0x03 for UDP port association */
|
||||||
|
sbuf[2] = 0;
|
||||||
|
if (v5->lookup) /* domain name */
|
||||||
|
{
|
||||||
|
sbuf[3] = 3;
|
||||||
|
sbuf[4] = addrlen - 1;
|
||||||
|
memcpy(sbuf + 5, svr->name, addrlen - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sbuf[3] = (svr->ecs_addrlen == 4) ? 1 : 4;
|
||||||
|
memcpy(sbuf + 4, svr->ecs_addr, addrlen);
|
||||||
|
}
|
||||||
|
sbuf[addrlen + 4] = svr->port >> 8;
|
||||||
|
sbuf[addrlen + 5] = svr->port & 0xff;
|
||||||
|
|
||||||
|
svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
|
||||||
|
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECORE_CON_PROXY_STATE_CONFIRM:
|
||||||
|
{
|
||||||
|
/* this is ugly because we have to read an exact number of bytes,
|
||||||
|
* but we don't know what that number is until we've already read
|
||||||
|
* at least 5 bytes to determine the length of the unknown stream.
|
||||||
|
* yep.
|
||||||
|
*/
|
||||||
|
size_t to_read, len = svr->ecs_recvbuf ? eina_binbuf_length_get(svr->ecs_recvbuf) : 0;
|
||||||
|
if (num + len < 5)
|
||||||
|
{
|
||||||
|
/* guarantees we get called again */
|
||||||
|
ECORE_CON_SOCKS_READ(5);
|
||||||
|
}
|
||||||
|
if (len >= 5)
|
||||||
|
{
|
||||||
|
data = eina_binbuf_string_get(svr->ecs_recvbuf);
|
||||||
|
data += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
data = buf + 3 - len;
|
||||||
|
switch (data[0])
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
to_read = 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
to_read = data[1] + 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
to_read = 16;
|
||||||
|
/* lazy debugging stub comment */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ecore_con_event_server_error(svr, "protocol error");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
/* at this point, we finally know exactly how much we need to read */
|
||||||
|
ECORE_CON_SOCKS_READ(6 + to_read);
|
||||||
|
|
||||||
|
if (data[0] != 5)
|
||||||
|
{
|
||||||
|
ecore_con_event_server_error(svr, "protocol error");
|
||||||
|
goto error; /* wrong version */
|
||||||
|
}
|
||||||
|
switch (data[1])
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
ecore_con_event_server_error(svr, "general proxy failure");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
ecore_con_event_server_error(svr, "connection not allowed by ruleset");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
ecore_con_event_server_error(svr, "network unreachable");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
ecore_con_event_server_error(svr, "host unreachable");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
ecore_con_event_server_error(svr, "connection refused by destination host");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
ecore_con_event_server_error(svr, "TTL expired");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
ecore_con_event_server_error(svr, "command not supported / protocol error");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
ecore_con_event_server_error(svr, "address type not supported");
|
||||||
|
|
||||||
|
default:
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (data[2])
|
||||||
|
{
|
||||||
|
ecore_con_event_server_error(svr, "protocol error");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr));
|
||||||
|
if (!svr->ssl_state)
|
||||||
|
ecore_con_event_server_add(svr);
|
||||||
|
if (svr->ssl_state || (svr->buf && eina_binbuf_length_get(svr->buf)))
|
||||||
|
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
|
||||||
|
svr->ecs_buf_offset = svr->ecs_addrlen = 0;
|
||||||
|
svr->ecs_state = ECORE_CON_PROXY_STATE_DONE;
|
||||||
|
INF("PROXY CONNECTED");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +639,7 @@ ecore_con_socks_init(void)
|
||||||
ecore_con_socks_lookup_set(ecs, lookup);
|
ecore_con_socks_lookup_set(ecs, lookup);
|
||||||
ecore_con_socks_apply_always(ecs);
|
ecore_con_socks_apply_always(ecs);
|
||||||
INF("Added global proxy server %s%s%s:%d - DNS lookup %s",
|
INF("Added global proxy server %s%s%s:%d - DNS lookup %s",
|
||||||
u ?: "", u ? "@" : "", h, port, lookup ? "ENABLED" : "DISABLED");
|
u ? : "", u ? "@" : "", h, port, lookup ? "ENABLED" : "DISABLED");
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -706,11 +732,12 @@ ecore_con_socks4_remote_del(const char *ip, int port, const char *username)
|
||||||
if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0]))) return;
|
if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0]))) return;
|
||||||
if (!ecore_con_socks_proxies) return;
|
if (!ecore_con_socks_proxies) return;
|
||||||
|
|
||||||
v4 = (Ecore_Con_Socks_v4*)_ecore_con_socks_find(4, ip, port, username, username ? strlen(username) : 0, NULL, 0);
|
v4 = (Ecore_Con_Socks_v4 *)_ecore_con_socks_find(4, ip, port, username, username ? strlen(username) : 0, NULL, 0);
|
||||||
if (!v4) return;
|
if (!v4) return;
|
||||||
ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v4);
|
ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v4);
|
||||||
_ecore_con_socks_free((Ecore_Con_Socks*)v4);
|
_ecore_con_socks_free((Ecore_Con_Socks *)v4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a SOCKS v5 proxy to the proxy list
|
* Add a SOCKS v5 proxy to the proxy list
|
||||||
*
|
*
|
||||||
|
@ -744,8 +771,8 @@ ecore_con_socks5_remote_add(const char *ip, int port, const char *username, cons
|
||||||
/* max length for protocol */
|
/* max length for protocol */
|
||||||
if ((!plen) || (plen > 255)) return NULL;
|
if ((!plen) || (plen > 255)) return NULL;
|
||||||
}
|
}
|
||||||
ecs5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen);
|
ecs5 = (Ecore_Con_Socks_v5 *)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen);
|
||||||
if (ecs5) return (Ecore_Con_Socks*)ecs5;
|
if (ecs5) return (Ecore_Con_Socks *)ecs5;
|
||||||
|
|
||||||
ecs5 = calloc(1, sizeof(Ecore_Con_Socks_v5));
|
ecs5 = calloc(1, sizeof(Ecore_Con_Socks_v5));
|
||||||
if (!ecs5) return NULL;
|
if (!ecs5) return NULL;
|
||||||
|
@ -758,7 +785,7 @@ ecore_con_socks5_remote_add(const char *ip, int port, const char *username, cons
|
||||||
ecs5->password = eina_stringshare_add(password);
|
ecs5->password = eina_stringshare_add(password);
|
||||||
ecs5->plen = plen;
|
ecs5->plen = plen;
|
||||||
ecore_con_socks_proxies = eina_list_append(ecore_con_socks_proxies, ecs5);
|
ecore_con_socks_proxies = eina_list_append(ecore_con_socks_proxies, ecs5);
|
||||||
return (Ecore_Con_Socks*)ecs5;
|
return (Ecore_Con_Socks *)ecs5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -805,10 +832,10 @@ ecore_con_socks5_remote_del(const char *ip, int port, const char *username, cons
|
||||||
return;
|
return;
|
||||||
if (!ecore_con_socks_proxies) return;
|
if (!ecore_con_socks_proxies) return;
|
||||||
|
|
||||||
v5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, username ? strlen(username) : 0, password, password ? strlen(password) : 0);
|
v5 = (Ecore_Con_Socks_v5 *)_ecore_con_socks_find(5, ip, port, username, username ? strlen(username) : 0, password, password ? strlen(password) : 0);
|
||||||
if (!v5) return;
|
if (!v5) return;
|
||||||
ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v5);
|
ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v5);
|
||||||
_ecore_con_socks_free((Ecore_Con_Socks*)v5);
|
_ecore_con_socks_free((Ecore_Con_Socks *)v5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -954,4 +981,5 @@ ecore_con_socks_apply_always(Ecore_Con_Socks *ecs)
|
||||||
{
|
{
|
||||||
_ecore_con_proxy_global = ecs;
|
_ecore_con_proxy_global = ecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -80,7 +80,7 @@ _gnutls_print_session(const gnutls_datum_t *cert_list, unsigned int cert_list_si
|
||||||
{
|
{
|
||||||
gnutls_x509_crt_init(&crt);
|
gnutls_x509_crt_init(&crt);
|
||||||
gnutls_x509_crt_import(crt, &cert_list[x], GNUTLS_X509_FMT_DER);
|
gnutls_x509_crt_import(crt, &cert_list[x], GNUTLS_X509_FMT_DER);
|
||||||
gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_FULL, (gnutls_datum_t*)&c);
|
gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_FULL, (gnutls_datum_t *)&c);
|
||||||
INF("CERTIFICATE:\n%s", c);
|
INF("CERTIFICATE:\n%s", c);
|
||||||
gnutls_free(c);
|
gnutls_free(c);
|
||||||
gnutls_x509_crt_deinit(crt);
|
gnutls_x509_crt_deinit(crt);
|
||||||
|
@ -90,13 +90,14 @@ _gnutls_print_session(const gnutls_datum_t *cert_list, unsigned int cert_list_si
|
||||||
|
|
||||||
#ifdef ISCOMFITOR
|
#ifdef ISCOMFITOR
|
||||||
static void
|
static void
|
||||||
_gnutls_log_func(int level,
|
_gnutls_log_func(int level,
|
||||||
const char *str)
|
const char *str)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
strncat(buf, str, strlen(str) - 1);
|
strncat(buf, str, strlen(str) - 1);
|
||||||
DBG("|<%d>| %s", level, buf);
|
DBG("|<%d>| %s", level, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
@ -151,174 +152,174 @@ _openssl_print_verify_error(int error)
|
||||||
switch (error)
|
switch (error)
|
||||||
{
|
{
|
||||||
#define ERROR(X) \
|
#define ERROR(X) \
|
||||||
case (X): \
|
case (X): \
|
||||||
ERR("%s", #X); \
|
ERR("%s", #X); \
|
||||||
break
|
break
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
|
#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT);
|
ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_GET_CRL
|
#ifdef X509_V_ERR_UNABLE_TO_GET_CRL
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_GET_CRL);
|
ERROR(X509_V_ERR_UNABLE_TO_GET_CRL);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
|
#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
|
ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
|
#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE);
|
ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
|
#ifdef X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY);
|
ERROR(X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_SIGNATURE_FAILURE
|
#ifdef X509_V_ERR_CERT_SIGNATURE_FAILURE
|
||||||
ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE);
|
ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CRL_SIGNATURE_FAILURE
|
#ifdef X509_V_ERR_CRL_SIGNATURE_FAILURE
|
||||||
ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE);
|
ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_NOT_YET_VALID
|
#ifdef X509_V_ERR_CERT_NOT_YET_VALID
|
||||||
ERROR(X509_V_ERR_CERT_NOT_YET_VALID);
|
ERROR(X509_V_ERR_CERT_NOT_YET_VALID);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_HAS_EXPIRED
|
#ifdef X509_V_ERR_CERT_HAS_EXPIRED
|
||||||
ERROR(X509_V_ERR_CERT_HAS_EXPIRED);
|
ERROR(X509_V_ERR_CERT_HAS_EXPIRED);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CRL_NOT_YET_VALID
|
#ifdef X509_V_ERR_CRL_NOT_YET_VALID
|
||||||
ERROR(X509_V_ERR_CRL_NOT_YET_VALID);
|
ERROR(X509_V_ERR_CRL_NOT_YET_VALID);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CRL_HAS_EXPIRED
|
#ifdef X509_V_ERR_CRL_HAS_EXPIRED
|
||||||
ERROR(X509_V_ERR_CRL_HAS_EXPIRED);
|
ERROR(X509_V_ERR_CRL_HAS_EXPIRED);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
|
#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
|
||||||
ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD);
|
ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
|
#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
|
||||||
ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD);
|
ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
|
#ifdef X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
|
||||||
ERROR(X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD);
|
ERROR(X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
|
#ifdef X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
|
||||||
ERROR(X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD);
|
ERROR(X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_OUT_OF_MEM
|
#ifdef X509_V_ERR_OUT_OF_MEM
|
||||||
ERROR(X509_V_ERR_OUT_OF_MEM);
|
ERROR(X509_V_ERR_OUT_OF_MEM);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
|
#ifdef X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
|
||||||
ERROR(X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
|
ERROR(X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
|
#ifdef X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
|
||||||
ERROR(X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN);
|
ERROR(X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
|
#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY);
|
ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
|
#ifdef X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE);
|
ERROR(X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_CHAIN_TOO_LONG
|
#ifdef X509_V_ERR_CERT_CHAIN_TOO_LONG
|
||||||
ERROR(X509_V_ERR_CERT_CHAIN_TOO_LONG);
|
ERROR(X509_V_ERR_CERT_CHAIN_TOO_LONG);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_REVOKED
|
#ifdef X509_V_ERR_CERT_REVOKED
|
||||||
ERROR(X509_V_ERR_CERT_REVOKED);
|
ERROR(X509_V_ERR_CERT_REVOKED);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_INVALID_CA
|
#ifdef X509_V_ERR_INVALID_CA
|
||||||
ERROR(X509_V_ERR_INVALID_CA);
|
ERROR(X509_V_ERR_INVALID_CA);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_PATH_LENGTH_EXCEEDED
|
#ifdef X509_V_ERR_PATH_LENGTH_EXCEEDED
|
||||||
ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED);
|
ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_INVALID_PURPOSE
|
#ifdef X509_V_ERR_INVALID_PURPOSE
|
||||||
ERROR(X509_V_ERR_INVALID_PURPOSE);
|
ERROR(X509_V_ERR_INVALID_PURPOSE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_UNTRUSTED
|
#ifdef X509_V_ERR_CERT_UNTRUSTED
|
||||||
ERROR(X509_V_ERR_CERT_UNTRUSTED);
|
ERROR(X509_V_ERR_CERT_UNTRUSTED);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CERT_REJECTED
|
#ifdef X509_V_ERR_CERT_REJECTED
|
||||||
ERROR(X509_V_ERR_CERT_REJECTED);
|
ERROR(X509_V_ERR_CERT_REJECTED);
|
||||||
#endif
|
#endif
|
||||||
/* These are 'informational' when looking for issuer cert */
|
/* These are 'informational' when looking for issuer cert */
|
||||||
#ifdef X509_V_ERR_SUBJECT_ISSUER_MISMATCH
|
#ifdef X509_V_ERR_SUBJECT_ISSUER_MISMATCH
|
||||||
ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH);
|
ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_AKID_SKID_MISMATCH
|
#ifdef X509_V_ERR_AKID_SKID_MISMATCH
|
||||||
ERROR(X509_V_ERR_AKID_SKID_MISMATCH);
|
ERROR(X509_V_ERR_AKID_SKID_MISMATCH);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
|
#ifdef X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
|
||||||
ERROR(X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH);
|
ERROR(X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_KEYUSAGE_NO_CERTSIGN
|
#ifdef X509_V_ERR_KEYUSAGE_NO_CERTSIGN
|
||||||
ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN);
|
ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER
|
#ifdef X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER
|
||||||
ERROR(X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER);
|
ERROR(X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
|
#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
|
||||||
ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION);
|
ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_KEYUSAGE_NO_CRL_SIGN
|
#ifdef X509_V_ERR_KEYUSAGE_NO_CRL_SIGN
|
||||||
ERROR(X509_V_ERR_KEYUSAGE_NO_CRL_SIGN);
|
ERROR(X509_V_ERR_KEYUSAGE_NO_CRL_SIGN);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION
|
#ifdef X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION
|
||||||
ERROR(X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION);
|
ERROR(X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_INVALID_NON_CA
|
#ifdef X509_V_ERR_INVALID_NON_CA
|
||||||
ERROR(X509_V_ERR_INVALID_NON_CA);
|
ERROR(X509_V_ERR_INVALID_NON_CA);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED
|
#ifdef X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED
|
||||||
ERROR(X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED);
|
ERROR(X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE
|
#ifdef X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE
|
||||||
ERROR(X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE);
|
ERROR(X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED
|
#ifdef X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED
|
||||||
ERROR(X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED);
|
ERROR(X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef X509_V_ERR_INVALID_EXTENSION
|
#ifdef X509_V_ERR_INVALID_EXTENSION
|
||||||
ERROR(X509_V_ERR_INVALID_EXTENSION);
|
ERROR(X509_V_ERR_INVALID_EXTENSION);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_INVALID_POLICY_EXTENSION
|
#ifdef X509_V_ERR_INVALID_POLICY_EXTENSION
|
||||||
ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION);
|
ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_NO_EXPLICIT_POLICY
|
#ifdef X509_V_ERR_NO_EXPLICIT_POLICY
|
||||||
ERROR(X509_V_ERR_NO_EXPLICIT_POLICY);
|
ERROR(X509_V_ERR_NO_EXPLICIT_POLICY);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_DIFFERENT_CRL_SCOPE
|
#ifdef X509_V_ERR_DIFFERENT_CRL_SCOPE
|
||||||
ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE);
|
ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
|
#ifdef X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
|
||||||
ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE);
|
ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef X509_V_ERR_UNNESTED_RESOURCE
|
#ifdef X509_V_ERR_UNNESTED_RESOURCE
|
||||||
ERROR(X509_V_ERR_UNNESTED_RESOURCE);
|
ERROR(X509_V_ERR_UNNESTED_RESOURCE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef X509_V_ERR_PERMITTED_VIOLATION
|
#ifdef X509_V_ERR_PERMITTED_VIOLATION
|
||||||
ERROR(X509_V_ERR_PERMITTED_VIOLATION);
|
ERROR(X509_V_ERR_PERMITTED_VIOLATION);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_EXCLUDED_VIOLATION
|
#ifdef X509_V_ERR_EXCLUDED_VIOLATION
|
||||||
ERROR(X509_V_ERR_EXCLUDED_VIOLATION);
|
ERROR(X509_V_ERR_EXCLUDED_VIOLATION);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_SUBTREE_MINMAX
|
#ifdef X509_V_ERR_SUBTREE_MINMAX
|
||||||
ERROR(X509_V_ERR_SUBTREE_MINMAX);
|
ERROR(X509_V_ERR_SUBTREE_MINMAX);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
|
#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
|
||||||
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE);
|
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
|
#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
|
||||||
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
|
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
|
#ifdef X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
|
||||||
ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX);
|
ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX);
|
||||||
#endif
|
#endif
|
||||||
#ifdef X509_V_ERR_CRL_PATH_VALIDATION_ERROR
|
#ifdef X509_V_ERR_CRL_PATH_VALIDATION_ERROR
|
||||||
ERROR(X509_V_ERR_CRL_PATH_VALIDATION_ERROR);
|
ERROR(X509_V_ERR_CRL_PATH_VALIDATION_ERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The application is not happy */
|
/* The application is not happy */
|
||||||
#ifdef X509_V_ERR_APPLICATION_VERIFICATION
|
#ifdef X509_V_ERR_APPLICATION_VERIFICATION
|
||||||
ERROR(X509_V_ERR_APPLICATION_VERIFICATION);
|
ERROR(X509_V_ERR_APPLICATION_VERIFICATION);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
|
@ -339,7 +340,6 @@ _openssl_print_errors(void *conn, int type)
|
||||||
ecore_con_event_client_error(conn, buf);
|
ecore_con_event_client_error(conn, buf);
|
||||||
else
|
else
|
||||||
ecore_con_event_server_error(conn, buf);
|
ecore_con_event_server_error(conn, buf);
|
||||||
|
|
||||||
} while (1);
|
} while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,11 +368,11 @@ _openssl_name_verify(const char *name, const char *svrname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcasecmp(name, svrname))
|
if (strcasecmp(name, svrname))
|
||||||
{
|
{
|
||||||
ERR("%s != %s", name, svrname);
|
ERR("%s != %s", name, svrname);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ _openssl_print_session(SSL *ssl)
|
||||||
{
|
{
|
||||||
/* print session info into DBG */
|
/* print session info into DBG */
|
||||||
SSL_SESSION *s;
|
SSL_SESSION *s;
|
||||||
STACK_OF(X509) *sk;
|
STACK_OF(X509) * sk;
|
||||||
BIO *b;
|
BIO *b;
|
||||||
char log[4096], *p;
|
char log[4096], *p;
|
||||||
int x;
|
int x;
|
||||||
|
@ -430,23 +430,23 @@ static Ecore_Con_Ssl_Error
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
SSL_SUFFIX(_ecore_con_ssl_shutdown) (void);
|
SSL_SUFFIX(_ecore_con_ssl_shutdown) (void);
|
||||||
|
|
||||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server * svr, const char *ca_file);
|
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server *svr, const char *ca_file);
|
||||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server * svr, const char *crl_file);
|
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server *svr, const char *crl_file);
|
||||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server * svr, const char *cert);
|
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server *svr, const char *cert);
|
||||||
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (Ecore_Con_Server * svr, const char *key_file);
|
static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (Ecore_Con_Server *svr, const char *key_file);
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_prepare) (Ecore_Con_Server * svr, int ssl_type);
|
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_prepare) (Ecore_Con_Server *svr, int ssl_type);
|
||||||
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_init) (Ecore_Con_Server * svr);
|
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_init) (Ecore_Con_Server *svr);
|
||||||
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (Ecore_Con_Server *svr);
|
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (Ecore_Con_Server *svr);
|
||||||
static int SSL_SUFFIX(_ecore_con_ssl_server_read) (Ecore_Con_Server *svr, unsigned char *buf, int size);
|
static int SSL_SUFFIX(_ecore_con_ssl_server_read) (Ecore_Con_Server *svr, unsigned char *buf, int size);
|
||||||
static int SSL_SUFFIX(_ecore_con_ssl_server_write) (Ecore_Con_Server *svr, const unsigned char *buf, int size);
|
static int SSL_SUFFIX(_ecore_con_ssl_server_write) (Ecore_Con_Server *svr, const unsigned char *buf, int size);
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_init) (Ecore_Con_Client * cl);
|
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_init) (Ecore_Con_Client *cl);
|
||||||
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (Ecore_Con_Client *cl);
|
static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (Ecore_Con_Client *cl);
|
||||||
static int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client * cl,
|
static int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client *cl,
|
||||||
unsigned char *buf, int size);
|
unsigned char *buf, int size);
|
||||||
static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client * cl,
|
static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client *cl,
|
||||||
const unsigned char *buf, int size);
|
const unsigned char *buf, int size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General SSL API
|
* General SSL API
|
||||||
|
@ -478,7 +478,7 @@ ecore_con_ssl_shutdown(void)
|
||||||
|
|
||||||
Ecore_Con_Ssl_Error
|
Ecore_Con_Ssl_Error
|
||||||
ecore_con_ssl_server_prepare(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_prepare(Ecore_Con_Server *svr,
|
||||||
int ssl_type)
|
int ssl_type)
|
||||||
{
|
{
|
||||||
if (!ssl_type)
|
if (!ssl_type)
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
|
@ -503,8 +503,8 @@ ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_con_ssl_server_read(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_read(Ecore_Con_Server *svr,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_server_read) (svr, buf, size);
|
return SSL_SUFFIX(_ecore_con_ssl_server_read) (svr, buf, size);
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ ecore_con_ssl_server_read(Ecore_Con_Server *svr,
|
||||||
int
|
int
|
||||||
ecore_con_ssl_server_write(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_write(Ecore_Con_Server *svr,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_server_write) (svr, buf, size);
|
return SSL_SUFFIX(_ecore_con_ssl_server_write) (svr, buf, size);
|
||||||
}
|
}
|
||||||
|
@ -535,8 +535,8 @@ ecore_con_ssl_client_shutdown(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_con_ssl_client_read(Ecore_Con_Client *cl,
|
ecore_con_ssl_client_read(Ecore_Con_Client *cl,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_client_read) (cl, buf, size);
|
return SSL_SUFFIX(_ecore_con_ssl_client_read) (cl, buf, size);
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ ecore_con_ssl_client_read(Ecore_Con_Client *cl,
|
||||||
int
|
int
|
||||||
ecore_con_ssl_client_write(Ecore_Con_Client *cl,
|
ecore_con_ssl_client_write(Ecore_Con_Client *cl,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_client_write) (cl, buf, size);
|
return SSL_SUFFIX(_ecore_con_ssl_client_write) (cl, buf, size);
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr)
|
||||||
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__);
|
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return svr->verify_name ?: svr->name;
|
return svr->verify_name ? : svr->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -666,7 +666,7 @@ ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr,
|
||||||
const char *cert)
|
const char *cert)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -699,7 +699,7 @@ ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr,
|
||||||
const char *ca_file)
|
const char *ca_file)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -731,7 +731,7 @@ ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr,
|
||||||
const char *key_file)
|
const char *key_file)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -763,7 +763,7 @@ ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr,
|
ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr,
|
||||||
const char *crl_file)
|
const char *crl_file)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||||
{
|
{
|
||||||
|
@ -898,7 +898,7 @@ _ecore_con_ssl_shutdown_gnutls(void)
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
|
||||||
int ssl_type)
|
int ssl_type)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ _ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
|
||||||
|
|
||||||
if (svr->use_cert)
|
if (svr->use_cert)
|
||||||
{
|
{
|
||||||
if (svr->created)
|
if (svr->created)
|
||||||
{
|
{
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_init(&svr->dh_params));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_init(&svr->dh_params));
|
||||||
INF("Generating DH params");
|
INF("Generating DH params");
|
||||||
|
@ -938,11 +938,11 @@ _ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
|
||||||
//gnutls_psk_set_server_dh_params(svr->pskcred_s, svr->dh_params);
|
//gnutls_psk_set_server_dh_params(svr->pskcred_s, svr->dh_params);
|
||||||
INF("DH params successfully generated and applied!");
|
INF("DH params successfully generated and applied!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c));
|
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c));
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_client_credentials(&svr->anoncred_c));
|
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_client_credentials(&svr->anoncred_c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
svr->ssl_prepared = EINA_TRUE;
|
svr->ssl_prepared = EINA_TRUE;
|
||||||
|
@ -954,7 +954,6 @@ error:
|
||||||
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr)
|
_ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr)
|
||||||
{
|
{
|
||||||
|
@ -1070,7 +1069,7 @@ _ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr)
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_init(&cert));
|
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_init(&cert));
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER));
|
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER));
|
||||||
|
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, svr->verify_name ?: svr->name));
|
SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, svr->verify_name ? : svr->name));
|
||||||
gnutls_x509_crt_deinit(cert);
|
gnutls_x509_crt_deinit(cert);
|
||||||
DBG("SSL certificate verification succeeded!");
|
DBG("SSL certificate verification succeeded!");
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
|
@ -1092,7 +1091,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_cafile_add_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_cafile_add_gnutls(Ecore_Con_Server *svr,
|
||||||
const char *ca_file)
|
const char *ca_file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
Eina_Iterator *it;
|
Eina_Iterator *it;
|
||||||
|
@ -1127,7 +1126,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_crl_add_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_crl_add_gnutls(Ecore_Con_Server *svr,
|
||||||
const char *crl_file)
|
const char *crl_file)
|
||||||
{
|
{
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_crl_file(svr->cert, crl_file,
|
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_crl_file(svr->cert, crl_file,
|
||||||
GNUTLS_X509_FMT_PEM) < 1);
|
GNUTLS_X509_FMT_PEM) < 1);
|
||||||
|
@ -1140,7 +1139,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_privkey_add_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_privkey_add_gnutls(Ecore_Con_Server *svr,
|
||||||
const char *key_file)
|
const char *key_file)
|
||||||
{
|
{
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_key_file(svr->cert, svr->cert_file, key_file,
|
SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_key_file(svr->cert, svr->cert_file, key_file,
|
||||||
GNUTLS_X509_FMT_PEM));
|
GNUTLS_X509_FMT_PEM));
|
||||||
|
@ -1153,7 +1152,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_cert_add_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_cert_add_gnutls(Ecore_Con_Server *svr,
|
||||||
const char *cert_file)
|
const char *cert_file)
|
||||||
{
|
{
|
||||||
if (!(svr->cert_file = strdup(cert_file)))
|
if (!(svr->cert_file = strdup(cert_file)))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
@ -1209,8 +1208,8 @@ _ecore_con_ssl_server_shutdown_gnutls(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1245,7 +1244,7 @@ _ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_server_write_gnutls(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_write_gnutls(Ecore_Con_Server *svr,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1396,7 +1395,7 @@ _ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, cl->host_server->name));
|
SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, cl->host_server->name));
|
||||||
gnutls_x509_crt_deinit(cert);
|
gnutls_x509_crt_deinit(cert);
|
||||||
*/
|
*/
|
||||||
DBG("SSL certificate verification succeeded!");
|
DBG("SSL certificate verification succeeded!");
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
|
|
||||||
|
@ -1412,7 +1411,7 @@ error:
|
||||||
/*
|
/*
|
||||||
if (cert)
|
if (cert)
|
||||||
gnutls_x509_crt_deinit(cert);
|
gnutls_x509_crt_deinit(cert);
|
||||||
*/
|
*/
|
||||||
_ecore_con_ssl_client_shutdown_gnutls(cl);
|
_ecore_con_ssl_client_shutdown_gnutls(cl);
|
||||||
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1435,8 +1434,8 @@ _ecore_con_ssl_client_shutdown_gnutls(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
|
_ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1471,7 +1470,7 @@ _ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *cl,
|
_ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *cl,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1527,7 +1526,7 @@ _ecore_con_ssl_shutdown_openssl(void)
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *svr,
|
||||||
int ssl_type)
|
int ssl_type)
|
||||||
{
|
{
|
||||||
long options;
|
long options;
|
||||||
int dh = 0;
|
int dh = 0;
|
||||||
|
@ -1665,11 +1664,11 @@ _ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
if (svr->verify)
|
if (svr->verify)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = SSL_get_verify_result(svr->ssl);
|
err = SSL_get_verify_result(svr->ssl);
|
||||||
_openssl_print_verify_error(err);
|
_openssl_print_verify_error(err);
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(err);
|
SSL_ERROR_CHECK_GOTO_ERROR(err);
|
||||||
}
|
}
|
||||||
clen = X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_subject_alt_name, NULL, 0);
|
clen = X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_subject_alt_name, NULL, 0);
|
||||||
if (clen > 0)
|
if (clen > 0)
|
||||||
|
@ -1681,7 +1680,7 @@ _ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr)
|
||||||
c = alloca(++clen);
|
c = alloca(++clen);
|
||||||
X509_NAME_get_text_by_NID(X509_get_subject_name(cert), name, c, clen);
|
X509_NAME_get_text_by_NID(X509_get_subject_name(cert), name, c, clen);
|
||||||
INF("CERT NAME: %s\n", c);
|
INF("CERT NAME: %s\n", c);
|
||||||
SSL_ERROR_CHECK_GOTO_ERROR(!_openssl_name_verify(c, svr->verify_name ?: svr->name));
|
SSL_ERROR_CHECK_GOTO_ERROR(!_openssl_name_verify(c, svr->verify_name ? : svr->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1697,7 +1696,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_cafile_add_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_cafile_add_openssl(Ecore_Con_Server *svr,
|
||||||
const char *ca_file)
|
const char *ca_file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -1715,7 +1714,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_crl_add_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_crl_add_openssl(Ecore_Con_Server *svr,
|
||||||
const char *crl_file)
|
const char *crl_file)
|
||||||
{
|
{
|
||||||
X509_STORE *st;
|
X509_STORE *st;
|
||||||
X509_LOOKUP *lu;
|
X509_LOOKUP *lu;
|
||||||
|
@ -1739,7 +1738,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *svr,
|
||||||
const char *key_file)
|
const char *key_file)
|
||||||
{
|
{
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
EVP_PKEY *privkey = NULL;
|
EVP_PKEY *privkey = NULL;
|
||||||
|
@ -1765,7 +1764,7 @@ error:
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *svr,
|
||||||
const char *cert_file)
|
const char *cert_file)
|
||||||
{
|
{
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
X509 *cert = NULL;
|
X509 *cert = NULL;
|
||||||
|
@ -1811,8 +1810,8 @@ _ecore_con_ssl_server_shutdown_openssl(Ecore_Con_Server *svr)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1842,7 +1841,7 @@ _ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr,
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr,
|
_ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1885,7 +1884,7 @@ _ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl)
|
||||||
cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING;
|
cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING;
|
||||||
|
|
||||||
case ECORE_CON_SSL_STATE_HANDSHAKING:
|
case ECORE_CON_SSL_STATE_HANDSHAKING:
|
||||||
if (!cl->ssl)
|
if (!cl->ssl)
|
||||||
{
|
{
|
||||||
DBG("Client was previously lost, going to error condition");
|
DBG("Client was previously lost, going to error condition");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1953,8 +1952,8 @@ _ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
_ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -1984,7 +1983,7 @@ _ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_write_openssl(Ecore_Con_Client *cl,
|
_ecore_con_ssl_client_write_openssl(Ecore_Con_Client *cl,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
@ -2030,7 +2029,7 @@ _ecore_con_ssl_shutdown_none(void)
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr EINA_UNUSED,
|
_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
int ssl_type EINA_UNUSED)
|
int ssl_type EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -2043,7 +2042,7 @@ _ecore_con_ssl_server_init_none(Ecore_Con_Server *svr EINA_UNUSED)
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_cafile_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
_ecore_con_ssl_server_cafile_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
const char *ca_file EINA_UNUSED)
|
const char *ca_file EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2057,14 +2056,14 @@ _ecore_con_ssl_server_cert_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_privkey_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
_ecore_con_ssl_server_privkey_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
const char *key_file EINA_UNUSED)
|
const char *key_file EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_ssl_server_crl_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
_ecore_con_ssl_server_crl_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
const char *crl_file EINA_UNUSED)
|
const char *crl_file EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2077,8 +2076,8 @@ _ecore_con_ssl_server_shutdown_none(Ecore_Con_Server *svr EINA_UNUSED)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_server_read_none(Ecore_Con_Server *svr EINA_UNUSED,
|
_ecore_con_ssl_server_read_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
unsigned char *buf EINA_UNUSED,
|
unsigned char *buf EINA_UNUSED,
|
||||||
int size EINA_UNUSED)
|
int size EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2086,7 +2085,7 @@ _ecore_con_ssl_server_read_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_server_write_none(Ecore_Con_Server *svr EINA_UNUSED,
|
_ecore_con_ssl_server_write_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||||
const unsigned char *buf EINA_UNUSED,
|
const unsigned char *buf EINA_UNUSED,
|
||||||
int size EINA_UNUSED)
|
int size EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2105,8 +2104,8 @@ _ecore_con_ssl_client_shutdown_none(Ecore_Con_Client *cl EINA_UNUSED)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_read_none(Ecore_Con_Client *cl EINA_UNUSED,
|
_ecore_con_ssl_client_read_none(Ecore_Con_Client *cl EINA_UNUSED,
|
||||||
unsigned char *buf EINA_UNUSED,
|
unsigned char *buf EINA_UNUSED,
|
||||||
int size EINA_UNUSED)
|
int size EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2114,7 +2113,7 @@ _ecore_con_ssl_client_read_none(Ecore_Con_Client *cl EINA_UNUSED,
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_write_none(Ecore_Con_Client *cl EINA_UNUSED,
|
_ecore_con_ssl_client_write_none(Ecore_Con_Client *cl EINA_UNUSED,
|
||||||
const unsigned char *buf EINA_UNUSED,
|
const unsigned char *buf EINA_UNUSED,
|
||||||
int size EINA_UNUSED)
|
int size EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,13 @@
|
||||||
// all the types, defines, enums etc. from curl that we actuall USE.
|
// all the types, defines, enums etc. from curl that we actuall USE.
|
||||||
// we have to add to this if we use more things from curl not already
|
// we have to add to this if we use more things from curl not already
|
||||||
// defined here. see culr headers to get them from
|
// defined here. see culr headers to get them from
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CURLM_CALL_MULTI_PERFORM = -1,
|
CURLM_CALL_MULTI_PERFORM = -1,
|
||||||
CURLM_OK = 0
|
CURLM_OK = 0
|
||||||
} CURLMcode;
|
} CURLMcode;
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CURLE_OK = 0,
|
CURLE_OK = 0,
|
||||||
CURLE_OPERATION_TIMEDOUT = 28
|
CURLE_OPERATION_TIMEDOUT = 28
|
||||||
} CURLcode;
|
} CURLcode;
|
||||||
|
@ -45,10 +47,11 @@ typedef enum {
|
||||||
#define CURLOPTTYPE_OBJECTPOINT 10000
|
#define CURLOPTTYPE_OBJECTPOINT 10000
|
||||||
#define CURLOPTTYPE_FUNCTIONPOINT 20000
|
#define CURLOPTTYPE_FUNCTIONPOINT 20000
|
||||||
#define CURLOPTTYPE_OFF_T 30000
|
#define CURLOPTTYPE_OFF_T 30000
|
||||||
#define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
|
#define CINIT(na, t, nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CINIT(FILE, OBJECTPOINT, 1),
|
CINIT(FILE, OBJECTPOINT, 1),
|
||||||
CINIT(URL, OBJECTPOINT, 2),
|
CINIT(URL, OBJECTPOINT, 2),
|
||||||
CINIT(PROXY, OBJECTPOINT, 4),
|
CINIT(PROXY, OBJECTPOINT, 4),
|
||||||
CINIT(USERPWD, OBJECTPOINT, 5),
|
CINIT(USERPWD, OBJECTPOINT, 5),
|
||||||
CINIT(INFILE, OBJECTPOINT, 9),
|
CINIT(INFILE, OBJECTPOINT, 9),
|
||||||
|
@ -91,30 +94,37 @@ typedef enum {
|
||||||
#define CURLINFO_SLIST 0x400000
|
#define CURLINFO_SLIST 0x400000
|
||||||
#define CURLINFO_MASK 0x0fffff
|
#define CURLINFO_MASK 0x0fffff
|
||||||
#define CURLINFO_TYPEMASK 0xf00000
|
#define CURLINFO_TYPEMASK 0xf00000
|
||||||
typedef enum {
|
typedef enum
|
||||||
CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
|
{
|
||||||
|
CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
|
||||||
} CURLINFO;
|
} CURLINFO;
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CURLVERSION_FOURTH = 3
|
CURLVERSION_FOURTH = 3
|
||||||
} CURLversion;
|
} CURLversion;
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CURLMSG_DONE = 1
|
CURLMSG_DONE = 1
|
||||||
} CURLMSG;
|
} CURLMSG;
|
||||||
#undef CINIT
|
#undef CINIT
|
||||||
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
#define CINIT(name, type, num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CINIT(PIPELINING, LONG, 3)
|
CINIT(PIPELINING, LONG, 3)
|
||||||
} CURLMoption;
|
} CURLMoption;
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CURL_TIMECOND_NONE = 0,
|
CURL_TIMECOND_NONE = 0,
|
||||||
CURL_TIMECOND_IFMODSINCE = 1,
|
CURL_TIMECOND_IFMODSINCE = 1,
|
||||||
CURL_TIMECOND_IFUNMODSINCE = 2
|
CURL_TIMECOND_IFUNMODSINCE = 2
|
||||||
} curl_TimeCond;
|
} curl_TimeCond;
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
CURL_HTTP_VERSION_1_0 = 1,
|
CURL_HTTP_VERSION_1_0 = 1,
|
||||||
CURL_HTTP_VERSION_1_1 = 2,
|
CURL_HTTP_VERSION_1_1 = 2,
|
||||||
};
|
};
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
CURLPROXY_HTTP = 0,
|
CURLPROXY_HTTP = 0,
|
||||||
CURLPROXY_SOCKS4 = 4,
|
CURLPROXY_SOCKS4 = 4,
|
||||||
CURLPROXY_SOCKS5 = 5,
|
CURLPROXY_SOCKS5 = 5,
|
||||||
|
@ -122,90 +132,93 @@ typedef enum {
|
||||||
CURLPROXY_SOCKS5_HOSTNAME = 7
|
CURLPROXY_SOCKS5_HOSTNAME = 7
|
||||||
} curl_proxytype;
|
} curl_proxytype;
|
||||||
|
|
||||||
#define CURL_GLOBAL_SSL (1<<0)
|
#define CURL_GLOBAL_SSL (1 << 0)
|
||||||
#define CURL_GLOBAL_WIN32 (1<<1)
|
#define CURL_GLOBAL_WIN32 (1 << 1)
|
||||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
|
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32)
|
||||||
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
|
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
|
||||||
#define CURLOPT_WRITEDATA CURLOPT_FILE
|
#define CURLOPT_WRITEDATA CURLOPT_FILE
|
||||||
#define CURLOPT_READDATA CURLOPT_INFILE
|
#define CURLOPT_READDATA CURLOPT_INFILE
|
||||||
#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
|
#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
|
||||||
#define CURLVERSION_NOW CURLVERSION_FOURTH
|
#define CURLVERSION_NOW CURLVERSION_FOURTH
|
||||||
#define CURLAUTH_BASIC (((unsigned long)1)<<0)
|
#define CURLAUTH_BASIC (((unsigned long)1) << 0)
|
||||||
#define CURLAUTH_DIGEST_IE (((unsigned long)1)<<4)
|
#define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4)
|
||||||
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
|
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
|
||||||
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE))
|
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE))
|
||||||
#define CURL_READFUNC_ABORT 0x10000000
|
#define CURL_READFUNC_ABORT 0x10000000
|
||||||
|
|
||||||
typedef void CURLM;
|
typedef void CURLM;
|
||||||
typedef void CURL;
|
typedef void CURL;
|
||||||
struct curl_slist {
|
struct curl_slist
|
||||||
char *data;
|
{
|
||||||
|
char *data;
|
||||||
struct curl_slist *next;
|
struct curl_slist *next;
|
||||||
};
|
};
|
||||||
typedef struct {
|
typedef struct
|
||||||
CURLversion age;
|
{
|
||||||
const char *version;
|
CURLversion age;
|
||||||
unsigned int version_num;
|
const char *version;
|
||||||
const char *host;
|
unsigned int version_num;
|
||||||
int features;
|
const char *host;
|
||||||
const char *ssl_version;
|
int features;
|
||||||
long ssl_version_num;
|
const char *ssl_version;
|
||||||
const char *libz_version;
|
long ssl_version_num;
|
||||||
const char * const *protocols;
|
const char *libz_version;
|
||||||
const char *ares;
|
const char *const *protocols;
|
||||||
int ares_num;
|
const char *ares;
|
||||||
const char *libidn;
|
int ares_num;
|
||||||
int iconv_ver_num;
|
const char *libidn;
|
||||||
const char *libssh_version;
|
int iconv_ver_num;
|
||||||
|
const char *libssh_version;
|
||||||
} curl_version_info_data;
|
} curl_version_info_data;
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
CURLMSG msg;
|
CURLMSG msg;
|
||||||
CURL *easy_handle;
|
CURL *easy_handle;
|
||||||
union {
|
union
|
||||||
void *whatever;
|
{
|
||||||
|
void *whatever;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
} data;
|
} data;
|
||||||
} CURLMsg;
|
} CURLMsg;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Ecore_Con_Curl Ecore_Con_Curl;
|
typedef struct _Ecore_Con_Curl Ecore_Con_Curl;
|
||||||
|
|
||||||
struct _Ecore_Con_Curl
|
struct _Ecore_Con_Curl
|
||||||
{
|
{
|
||||||
Eina_Module *mod;
|
Eina_Module *mod;
|
||||||
|
|
||||||
CURLM *_curlm;
|
CURLM *_curlm;
|
||||||
|
|
||||||
CURLcode (*curl_global_init) (long flags);
|
CURLcode (*curl_global_init)(long flags);
|
||||||
void (*curl_global_cleanup)(void);
|
void (*curl_global_cleanup)(void);
|
||||||
CURLM *(*curl_multi_init)(void);
|
CURLM *(*curl_multi_init)(void);
|
||||||
CURLMcode (*curl_multi_timeout)(CURLM *multi_handle,
|
CURLMcode (*curl_multi_timeout)(CURLM *multi_handle,
|
||||||
long *milliseconds);
|
long *milliseconds);
|
||||||
CURLMcode (*curl_multi_cleanup)(CURLM *multi_handle);
|
CURLMcode (*curl_multi_cleanup)(CURLM *multi_handle);
|
||||||
CURLMcode (*curl_multi_remove_handle)(CURLM *multi_handle,
|
CURLMcode (*curl_multi_remove_handle)(CURLM *multi_handle,
|
||||||
CURL *curl_handle);
|
CURL *curl_handle);
|
||||||
const char *(*curl_multi_strerror)(CURLMcode);
|
const char *(*curl_multi_strerror)(CURLMcode);
|
||||||
CURLMsg *(*curl_multi_info_read)(CURLM *multi_handle,
|
CURLMsg *(*curl_multi_info_read)(CURLM * multi_handle,
|
||||||
int *msgs_in_queue);
|
int *msgs_in_queue);
|
||||||
CURLMcode (*curl_multi_fdset)(CURLM *multi_handle,
|
CURLMcode (*curl_multi_fdset)(CURLM *multi_handle,
|
||||||
fd_set *read_fd_set,
|
fd_set *read_fd_set,
|
||||||
fd_set *write_fd_set,
|
fd_set *write_fd_set,
|
||||||
fd_set *exc_fd_set,
|
fd_set *exc_fd_set,
|
||||||
int *max_fd);
|
int *max_fd);
|
||||||
CURLMcode (*curl_multi_perform)(CURLM *multi_handle,
|
CURLMcode (*curl_multi_perform)(CURLM *multi_handle,
|
||||||
int *running_handles);
|
int *running_handles);
|
||||||
CURLMcode (*curl_multi_add_handle)(CURLM *multi_handle,
|
CURLMcode (*curl_multi_add_handle)(CURLM *multi_handle,
|
||||||
CURL *curl_handle);
|
CURL *curl_handle);
|
||||||
CURLMcode (*curl_multi_setopt)(CURLM *multi_handle,
|
CURLMcode (*curl_multi_setopt)(CURLM *multi_handle,
|
||||||
CURLMoption option, ...);
|
CURLMoption option, ...);
|
||||||
CURL *(*curl_easy_init)(void);
|
CURL *(*curl_easy_init)(void);
|
||||||
CURLcode (*curl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
CURLcode (*curl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||||
const char *(*curl_easy_strerror)(CURLcode);
|
const char *(*curl_easy_strerror)(CURLcode);
|
||||||
void (*curl_easy_cleanup)(CURL *curl);
|
void (*curl_easy_cleanup)(CURL *curl);
|
||||||
CURLcode (*curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
CURLcode (*curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||||
void (*curl_slist_free_all)(struct curl_slist *);
|
void (*curl_slist_free_all)(struct curl_slist *);
|
||||||
struct curl_slist *(*curl_slist_append)(struct curl_slist *list,
|
struct curl_slist *(*curl_slist_append)(struct curl_slist *list,
|
||||||
const char *string);
|
const char *string);
|
||||||
curl_version_info_data *(*curl_version_info)(CURLversion);
|
curl_version_info_data *(*curl_version_info)(CURLversion);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,15 +261,15 @@ _c_init(void)
|
||||||
_c = calloc(1, sizeof(Ecore_Con_Curl));
|
_c = calloc(1, sizeof(Ecore_Con_Curl));
|
||||||
if (!_c) goto error;
|
if (!_c) goto error;
|
||||||
|
|
||||||
#define LOAD(x) \
|
#define LOAD(x) \
|
||||||
if (!_c->mod) { \
|
if (!_c->mod) { \
|
||||||
if ((_c->mod = eina_module_new(x))) { \
|
if ((_c->mod = eina_module_new(x))) { \
|
||||||
if (!eina_module_load(_c->mod)) { \
|
if (!eina_module_load(_c->mod)) { \
|
||||||
eina_module_free(_c->mod); \
|
eina_module_free(_c->mod); \
|
||||||
_c->mod = NULL; \
|
_c->mod = NULL; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
LOAD("libcurl.dll"); // try 1
|
LOAD("libcurl.dll"); // try 1
|
||||||
LOAD("curllib.dll"); // if fail try 2
|
LOAD("curllib.dll"); // if fail try 2
|
||||||
|
@ -268,7 +281,8 @@ _c_init(void)
|
||||||
#endif
|
#endif
|
||||||
if (!_c->mod) goto error;
|
if (!_c->mod) goto error;
|
||||||
|
|
||||||
#define SYM(x) if (!(_c->x = eina_module_symbol_get(_c->mod, #x))) goto error
|
#define SYM(x) if (!(_c->x = eina_module_symbol_get(_c->mod, #x))) \
|
||||||
|
goto error
|
||||||
SYM(curl_global_init);
|
SYM(curl_global_init);
|
||||||
SYM(curl_global_cleanup);
|
SYM(curl_global_cleanup);
|
||||||
SYM(curl_multi_init);
|
SYM(curl_multi_init);
|
||||||
|
@ -429,24 +443,26 @@ ecore_con_url_new(const char *url)
|
||||||
if (_ecore_con_proxy_global->version == 5)
|
if (_ecore_con_proxy_global->version == 5)
|
||||||
{
|
{
|
||||||
if (_ecore_con_proxy_global->lookup)
|
if (_ecore_con_proxy_global->lookup)
|
||||||
snprintf(host, sizeof(host), "socks5h://%s",
|
snprintf(host, sizeof(host), "socks5h://%s",
|
||||||
_ecore_con_proxy_global->ip);
|
_ecore_con_proxy_global->ip);
|
||||||
else snprintf(host, sizeof(host), "socks5://%s",
|
else
|
||||||
_ecore_con_proxy_global->ip);
|
snprintf(host, sizeof(host), "socks5://%s",
|
||||||
|
_ecore_con_proxy_global->ip);
|
||||||
}
|
}
|
||||||
else if (_ecore_con_proxy_global->version == 4)
|
else if (_ecore_con_proxy_global->version == 4)
|
||||||
{
|
{
|
||||||
if (_ecore_con_proxy_global->lookup)
|
if (_ecore_con_proxy_global->lookup)
|
||||||
snprintf(host, sizeof(host), "socks4a://%s",
|
snprintf(host, sizeof(host), "socks4a://%s",
|
||||||
_ecore_con_proxy_global->ip);
|
_ecore_con_proxy_global->ip);
|
||||||
else snprintf(host, sizeof(host), "socks4://%s",
|
else
|
||||||
_ecore_con_proxy_global->ip);
|
snprintf(host, sizeof(host), "socks4://%s",
|
||||||
|
_ecore_con_proxy_global->ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ecore_con_proxy_global->port > 0 &&
|
if (_ecore_con_proxy_global->port > 0 &&
|
||||||
_ecore_con_proxy_global->port <= 65535)
|
_ecore_con_proxy_global->port <= 65535)
|
||||||
snprintf(proxy, sizeof(proxy), "%s:%d", host,
|
snprintf(proxy, sizeof(proxy), "%s:%d", host,
|
||||||
_ecore_con_proxy_global->port);
|
_ecore_con_proxy_global->port);
|
||||||
else snprintf(proxy, sizeof(proxy), "%s", host);
|
else snprintf(proxy, sizeof(proxy), "%s", host);
|
||||||
|
|
||||||
ecore_con_url_proxy_set(url_con, proxy);
|
ecore_con_url_proxy_set(url_con, proxy);
|
||||||
|
@ -549,8 +565,10 @@ ecore_con_url_free(Ecore_Con_Url *url_con)
|
||||||
ECORE_MAGIC_SET(url_con, ECORE_MAGIC_NONE);
|
ECORE_MAGIC_SET(url_con, ECORE_MAGIC_NONE);
|
||||||
|
|
||||||
_c->curl_slist_free_all(url_con->headers);
|
_c->curl_slist_free_all(url_con->headers);
|
||||||
EINA_LIST_FREE(url_con->additional_headers, s) free(s);
|
EINA_LIST_FREE(url_con->additional_headers, s)
|
||||||
EINA_LIST_FREE(url_con->response_headers, s) free(s);
|
free(s);
|
||||||
|
EINA_LIST_FREE(url_con->response_headers, s)
|
||||||
|
free(s);
|
||||||
eina_stringshare_del(url_con->url);
|
eina_stringshare_del(url_con->url);
|
||||||
if (url_con->post_data) free(url_con->post_data);
|
if (url_con->post_data) free(url_con->post_data);
|
||||||
free(url_con);
|
free(url_con);
|
||||||
|
@ -639,7 +657,8 @@ ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con)
|
||||||
ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, __func__);
|
ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EINA_LIST_FREE(url_con->additional_headers, s) free(s);
|
EINA_LIST_FREE(url_con->additional_headers, s)
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
|
@ -720,7 +739,7 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, const c
|
||||||
{
|
{
|
||||||
if (safe)
|
if (safe)
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH,
|
||||||
CURLAUTH_ANYSAFE);
|
CURLAUTH_ANYSAFE);
|
||||||
else
|
else
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH,
|
||||||
CURLAUTH_ANY);
|
CURLAUTH_ANY);
|
||||||
|
@ -770,7 +789,8 @@ _ecore_con_url_send(Ecore_Con_Url *url_con, int mode, const void *data, long len
|
||||||
if (url_con->dead) return EINA_FALSE;
|
if (url_con->dead) return EINA_FALSE;
|
||||||
|
|
||||||
/* Free response headers from previous send() calls */
|
/* Free response headers from previous send() calls */
|
||||||
EINA_LIST_FREE(url_con->response_headers, s) free((char *)s);
|
EINA_LIST_FREE(url_con->response_headers, s)
|
||||||
|
free((char *)s);
|
||||||
url_con->response_headers = NULL;
|
url_con->response_headers = NULL;
|
||||||
url_con->status = 0;
|
url_con->status = 0;
|
||||||
|
|
||||||
|
@ -801,8 +821,9 @@ _ecore_con_url_send(Ecore_Con_Url *url_con, int mode, const void *data, long len
|
||||||
else
|
else
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
else _c->curl_easy_setopt(url_con->curl_easy,
|
else
|
||||||
CURLOPT_POSTFIELDSIZE, 0);
|
_c->curl_easy_setopt(url_con->curl_easy,
|
||||||
|
CURLOPT_POSTFIELDSIZE, 0);
|
||||||
if (mode == MODE_POST)
|
if (mode == MODE_POST)
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_POST, 1);
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_POST, 1);
|
||||||
}
|
}
|
||||||
|
@ -811,19 +832,21 @@ _ecore_con_url_send(Ecore_Con_Url *url_con, int mode, const void *data, long len
|
||||||
{
|
{
|
||||||
case ECORE_CON_URL_TIME_NONE:
|
case ECORE_CON_URL_TIME_NONE:
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
||||||
CURL_TIMECOND_NONE);
|
CURL_TIMECOND_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECORE_CON_URL_TIME_IFMODSINCE:
|
case ECORE_CON_URL_TIME_IFMODSINCE:
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
||||||
CURL_TIMECOND_IFMODSINCE);
|
CURL_TIMECOND_IFMODSINCE);
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE,
|
||||||
(long)url_con->timestamp);
|
(long)url_con->timestamp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECORE_CON_URL_TIME_IFUNMODSINCE:
|
case ECORE_CON_URL_TIME_IFUNMODSINCE:
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
||||||
CURL_TIMECOND_IFUNMODSINCE);
|
CURL_TIMECOND_IFUNMODSINCE);
|
||||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE,
|
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE,
|
||||||
(long)url_con->timestamp);
|
(long)url_con->timestamp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Additional headers */
|
/* Additional headers */
|
||||||
|
@ -1127,11 +1150,13 @@ ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Versio
|
||||||
CURLOPT_HTTP_VERSION,
|
CURLOPT_HTTP_VERSION,
|
||||||
CURL_HTTP_VERSION_1_0);
|
CURL_HTTP_VERSION_1_0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECORE_CON_URL_HTTP_VERSION_1_1:
|
case ECORE_CON_URL_HTTP_VERSION_1_1:
|
||||||
res = _c->curl_easy_setopt(url_con->curl_easy,
|
res = _c->curl_easy_setopt(url_con->curl_easy,
|
||||||
CURLOPT_HTTP_VERSION,
|
CURLOPT_HTTP_VERSION,
|
||||||
CURL_HTTP_VERSION_1_1);
|
CURL_HTTP_VERSION_1_1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1157,8 +1182,9 @@ ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy)
|
||||||
}
|
}
|
||||||
if (!url_con->url) return EINA_FALSE;
|
if (!url_con->url) return EINA_FALSE;
|
||||||
if (url_con->dead) return EINA_FALSE;
|
if (url_con->dead) return EINA_FALSE;
|
||||||
if (!proxy) res = _c->curl_easy_setopt(url_con->curl_easy,
|
if (!proxy)
|
||||||
CURLOPT_PROXY, "");
|
res = _c->curl_easy_setopt(url_con->curl_easy,
|
||||||
|
CURLOPT_PROXY, "");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// before curl version 7.21.7, socks protocol:// prefix is not supported
|
// before curl version 7.21.7, socks protocol:// prefix is not supported
|
||||||
|
@ -1317,7 +1343,7 @@ _ecore_con_url_event_url_complete(Ecore_Con_Url *url_con, CURLMsg *curlmsg)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERR("Curl message have errors: %d (%s)",
|
ERR("Curl message have errors: %d (%s)",
|
||||||
curlmsg->data.result, _c->curl_easy_strerror(curlmsg->data.result));
|
curlmsg->data.result, _c->curl_easy_strerror(curlmsg->data.result));
|
||||||
}
|
}
|
||||||
e->status = status;
|
e->status = status;
|
||||||
e->url_con = url_con;
|
e->url_con = url_con;
|
||||||
|
@ -1500,7 +1526,7 @@ _ecore_con_url_info_read(void)
|
||||||
if (curlmsg->easy_handle == url_con->curl_easy)
|
if (curlmsg->easy_handle == url_con->curl_easy)
|
||||||
_ecore_con_url_event_url_complete(url_con, curlmsg);
|
_ecore_con_url_event_url_complete(url_con, curlmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1510,8 +1536,10 @@ _ecore_con_url_curl_clear(void)
|
||||||
Ecore_Fd_Handler *fdh;
|
Ecore_Fd_Handler *fdh;
|
||||||
Ecore_Con_Url *url_con;
|
Ecore_Con_Url *url_con;
|
||||||
|
|
||||||
EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh);
|
EINA_LIST_FREE(_fd_hd_list, fdh)
|
||||||
EINA_LIST_FREE(_url_con_list, url_con) _ecore_con_url_multi_remove(url_con);
|
ecore_main_fd_handler_del(fdh);
|
||||||
|
EINA_LIST_FREE(_url_con_list, url_con)
|
||||||
|
_ecore_con_url_multi_remove(url_con);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -1521,7 +1549,8 @@ _ecore_con_url_fd_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd_handler E
|
||||||
long ms;
|
long ms;
|
||||||
|
|
||||||
if (!_c) return ECORE_CALLBACK_CANCEL;
|
if (!_c) return ECORE_CALLBACK_CANCEL;
|
||||||
EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh);
|
EINA_LIST_FREE(_fd_hd_list, fdh)
|
||||||
|
ecore_main_fd_handler_del(fdh);
|
||||||
_c->curl_multi_timeout(_c->_curlm, &ms);
|
_c->curl_multi_timeout(_c->_curlm, &ms);
|
||||||
if ((ms >= CURL_MIN_TIMEOUT) || (ms <= 0)) ms = CURL_MIN_TIMEOUT;
|
if ((ms >= CURL_MIN_TIMEOUT) || (ms <= 0)) ms = CURL_MIN_TIMEOUT;
|
||||||
ecore_timer_interval_set(_curl_timer, (double)ms / 1000.0);
|
ecore_timer_interval_set(_curl_timer, (double)ms / 1000.0);
|
||||||
|
@ -1566,7 +1595,7 @@ _ecore_con_url_fdset(void)
|
||||||
_ecore_con_url_fd_handler,
|
_ecore_con_url_fd_handler,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (fd_handler)
|
if (fd_handler)
|
||||||
_fd_hd_list = eina_list_append(_fd_hd_list, fd_handler);
|
_fd_hd_list = eina_list_append(_fd_hd_list, fd_handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1578,7 +1607,8 @@ _ecore_con_url_timer(void *data EINA_UNUSED)
|
||||||
int still_running;
|
int still_running;
|
||||||
CURLMcode ret;
|
CURLMcode ret;
|
||||||
|
|
||||||
EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh);
|
EINA_LIST_FREE(_fd_hd_list, fdh)
|
||||||
|
ecore_main_fd_handler_del(fdh);
|
||||||
_ecore_con_url_info_read();
|
_ecore_con_url_info_read();
|
||||||
if (!_c) return ECORE_CALLBACK_RENEW;
|
if (!_c) return ECORE_CALLBACK_RENEW;
|
||||||
ret = _c->curl_multi_perform(_c->_curlm, &still_running);
|
ret = _c->curl_multi_perform(_c->_curlm, &still_running);
|
||||||
|
@ -1650,3 +1680,4 @@ _ecore_con_event_url_free(Ecore_Con_Url *url_con, void *ev)
|
||||||
url_con->event_count--;
|
url_con->event_count--;
|
||||||
if (url_con->dead && (!url_con->event_count)) ecore_con_url_free(url_con);
|
if (url_con->dead && (!url_con->event_count)) ecore_con_url_free(url_con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue