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_private.h"
|
||||
|
||||
static Eina_Bool _ecore_con_client_timer(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 void _ecore_con_server_timer_update(Ecore_Con_Server *svr);
|
||||
static Eina_Bool _ecore_con_client_timer(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 void _ecore_con_server_timer_update(Ecore_Con_Server *svr);
|
||||
|
||||
static void _ecore_con_cb_tcp_connect(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_udp_connect(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_tcp_listen(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_udp_listen(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_tcp_connect(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_udp_connect(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_tcp_listen(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
static void _ecore_con_cb_udp_listen(void *data,
|
||||
Ecore_Con_Info *info);
|
||||
|
||||
static void _ecore_con_server_free(Ecore_Con_Server *svr);
|
||||
static void _ecore_con_client_free(Ecore_Con_Client *cl);
|
||||
static void _ecore_con_server_free(Ecore_Con_Server *svr);
|
||||
static void _ecore_con_client_free(Ecore_Con_Client *cl);
|
||||
|
||||
static void _ecore_con_cl_read(Ecore_Con_Server *svr);
|
||||
static Eina_Bool _ecore_con_svr_tcp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_cl_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_cl_udp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_svr_udp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static void _ecore_con_cl_read(Ecore_Con_Server *svr);
|
||||
static Eina_Bool _ecore_con_svr_tcp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_cl_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_cl_udp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_svr_udp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
|
||||
static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl);
|
||||
static Eina_Bool _ecore_con_svr_cl_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl);
|
||||
static Eina_Bool _ecore_con_svr_cl_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
|
||||
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
|
||||
static void _ecore_con_client_flush(Ecore_Con_Client *cl);
|
||||
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
|
||||
static void _ecore_con_client_flush(Ecore_Con_Client *cl);
|
||||
|
||||
static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||
void *ev);
|
||||
static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||
void *ev);
|
||||
static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_add_free(void *data,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_del_free(void *data,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_data_free(void *data,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_error_free(void *data,
|
||||
Ecore_Con_Event_Server_Error *e);
|
||||
static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Event_Client_Error *e);
|
||||
static void _ecore_con_event_server_write_free(void *data,
|
||||
Ecore_Con_Event_Server_Write *e);
|
||||
static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Event_Client_Write *e);
|
||||
static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||
void *ev);
|
||||
static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||
void *ev);
|
||||
static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_add_free(void *data,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_del_free(void *data,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_data_free(void *data,
|
||||
void *ev);
|
||||
static void _ecore_con_event_server_error_free(void *data,
|
||||
Ecore_Con_Event_Server_Error *e);
|
||||
static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Event_Client_Error *e);
|
||||
static void _ecore_con_event_server_write_free(void *data,
|
||||
Ecore_Con_Event_Server_Write *e);
|
||||
static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Event_Client_Write *e);
|
||||
|
||||
static void _ecore_con_lookup_done(void *data,
|
||||
Ecore_Con_Info *infos);
|
||||
static void _ecore_con_lookup_done(void *data,
|
||||
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
|
||||
int sd_fd_index = 0;
|
||||
|
@ -144,14 +144,14 @@ _ecore_con_server_kill(Ecore_Con_Server *svr)
|
|||
}
|
||||
|
||||
#define _ecore_con_server_kill(svr) do { \
|
||||
DBG("KILL %p", (svr)); \
|
||||
_ecore_con_server_kill((svr)); \
|
||||
} while (0)
|
||||
DBG("KILL %p", (svr)); \
|
||||
_ecore_con_server_kill((svr)); \
|
||||
} while (0)
|
||||
|
||||
#define _ecore_con_client_kill(cl) do { \
|
||||
DBG("KILL %p", (cl)); \
|
||||
_ecore_con_client_kill((cl)); \
|
||||
} while (0)
|
||||
#define _ecore_con_client_kill(cl) do { \
|
||||
DBG("KILL %p", (cl)); \
|
||||
_ecore_con_client_kill((cl)); \
|
||||
} while (0)
|
||||
|
||||
EAPI int ECORE_CON_EVENT_CLIENT_ADD = 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_PROXY_BIND = ecore_event_type_new();
|
||||
|
||||
|
||||
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_URL, "Ecore_Con_Url");
|
||||
|
@ -224,8 +223,8 @@ ecore_con_init(void)
|
|||
#endif
|
||||
|
||||
eina_log_timing(_ecore_con_log_dom,
|
||||
EINA_LOG_STATE_STOP,
|
||||
EINA_LOG_STATE_INIT);
|
||||
EINA_LOG_STATE_STOP,
|
||||
EINA_LOG_STATE_INIT);
|
||||
|
||||
return _ecore_con_init_count;
|
||||
}
|
||||
|
@ -240,8 +239,8 @@ ecore_con_shutdown(void)
|
|||
return _ecore_con_init_count;
|
||||
|
||||
eina_log_timing(_ecore_con_log_dom,
|
||||
EINA_LOG_STATE_START,
|
||||
EINA_LOG_STATE_SHUTDOWN);
|
||||
EINA_LOG_STATE_START,
|
||||
EINA_LOG_STATE_SHUTDOWN);
|
||||
|
||||
EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
|
||||
{
|
||||
|
@ -271,9 +270,9 @@ ecore_con_shutdown(void)
|
|||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
ecore_con_lookup(const char *name,
|
||||
ecore_con_lookup(const char *name,
|
||||
Ecore_Con_Dns_Cb done_cb,
|
||||
const void *data)
|
||||
const void *data)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
Ecore_Con_Lookup *lk;
|
||||
|
@ -344,9 +343,9 @@ on_error:
|
|||
|
||||
EAPI Ecore_Con_Server *
|
||||
ecore_con_server_add(Ecore_Con_Type compl_type,
|
||||
const char *name,
|
||||
int port,
|
||||
const void *data)
|
||||
const char *name,
|
||||
int port,
|
||||
const void *data)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
Ecore_Con_Type type;
|
||||
|
@ -382,7 +381,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
|
|||
if ((type == ECORE_CON_LOCAL_USER) ||
|
||||
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
||||
(type == ECORE_CON_LOCAL_ABSTRACT))
|
||||
/* Local */
|
||||
/* Local */
|
||||
#ifdef _WIN32
|
||||
if (!ecore_con_local_listen(svr))
|
||||
goto error;
|
||||
|
@ -396,9 +395,9 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
|
|||
(type == ECORE_CON_REMOTE_CORK))
|
||||
{
|
||||
/* TCP */
|
||||
if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen,
|
||||
svr))
|
||||
goto error;
|
||||
if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen,
|
||||
svr))
|
||||
goto error;
|
||||
}
|
||||
else if ((type == ECORE_CON_REMOTE_MCAST) ||
|
||||
(type == ECORE_CON_REMOTE_UDP))
|
||||
|
@ -419,7 +418,6 @@ error:
|
|||
if (svr->path)
|
||||
free(svr->path);
|
||||
|
||||
|
||||
if (svr->fd_handler)
|
||||
ecore_main_fd_handler_del(svr->fd_handler);
|
||||
|
||||
|
@ -439,9 +437,9 @@ error:
|
|||
|
||||
EAPI Ecore_Con_Server *
|
||||
ecore_con_server_connect(Ecore_Con_Type compl_type,
|
||||
const char *name,
|
||||
int port,
|
||||
const void *data)
|
||||
const char *name,
|
||||
int port,
|
||||
const void *data)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
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(((type == ECORE_CON_REMOTE_TCP) ||
|
||||
(type == ECORE_CON_REMOTE_NODELAY) ||
|
||||
(type == ECORE_CON_REMOTE_CORK) ||
|
||||
(type == ECORE_CON_REMOTE_UDP) ||
|
||||
(type == ECORE_CON_REMOTE_BROADCAST)) &&
|
||||
(port < 0), error);
|
||||
(type == ECORE_CON_REMOTE_NODELAY) ||
|
||||
(type == ECORE_CON_REMOTE_CORK) ||
|
||||
(type == ECORE_CON_REMOTE_UDP) ||
|
||||
(type == ECORE_CON_REMOTE_BROADCAST)) &&
|
||||
(port < 0), error);
|
||||
|
||||
if ((type == ECORE_CON_LOCAL_USER) ||
|
||||
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
||||
(type == ECORE_CON_LOCAL_ABSTRACT))
|
||||
/* Local */
|
||||
/* Local */
|
||||
#ifdef _WIN32
|
||||
if (!ecore_con_local_connect(svr, _ecore_con_cl_handler)) goto error;
|
||||
#else
|
||||
|
@ -512,7 +510,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
|
|||
(type == ECORE_CON_REMOTE_CORK))
|
||||
{
|
||||
/* 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))
|
||||
/* UDP and MCAST */
|
||||
|
@ -543,7 +541,7 @@ error:
|
|||
|
||||
EAPI void
|
||||
ecore_con_server_timeout_set(Ecore_Con_Server *svr,
|
||||
double timeout)
|
||||
double timeout)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||
{
|
||||
|
@ -602,7 +600,7 @@ ecore_con_server_data_get(Ecore_Con_Server *svr)
|
|||
|
||||
EAPI void *
|
||||
ecore_con_server_data_set(Ecore_Con_Server *svr,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
void *ret = NULL;
|
||||
|
||||
|
@ -672,8 +670,8 @@ ecore_con_server_port_get(Ecore_Con_Server *svr)
|
|||
|
||||
EAPI int
|
||||
ecore_con_server_send(Ecore_Con_Server *svr,
|
||||
const void *data,
|
||||
int size)
|
||||
const void *data,
|
||||
int size)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||
{
|
||||
|
@ -711,8 +709,8 @@ ecore_con_server_send(Ecore_Con_Server *svr,
|
|||
|
||||
EAPI void
|
||||
ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
|
||||
int client_limit,
|
||||
char reject_excess_clients)
|
||||
int client_limit,
|
||||
char reject_excess_clients)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||
{
|
||||
|
@ -780,8 +778,8 @@ ecore_con_server_flush(Ecore_Con_Server *svr)
|
|||
|
||||
EAPI int
|
||||
ecore_con_client_send(Ecore_Con_Client *cl,
|
||||
const void *data,
|
||||
int size)
|
||||
const void *data,
|
||||
int size)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||
{
|
||||
|
@ -848,7 +846,7 @@ ecore_con_client_connected_get(Ecore_Con_Client *cl)
|
|||
|
||||
EAPI void
|
||||
ecore_con_client_timeout_set(Ecore_Con_Client *cl,
|
||||
double timeout)
|
||||
double timeout)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||
{
|
||||
|
@ -890,7 +888,7 @@ ecore_con_client_del(Ecore_Con_Client *cl)
|
|||
|
||||
EAPI void
|
||||
ecore_con_client_data_set(Ecore_Con_Client *cl,
|
||||
const void *data)
|
||||
const void *data)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||
{
|
||||
|
@ -936,9 +934,9 @@ ecore_con_client_port_get(Ecore_Con_Client *cl)
|
|||
return -1;
|
||||
}
|
||||
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
|
||||
return ((struct sockaddr_in6*)cl->client_addr)->sin6_port;
|
||||
return ((struct sockaddr_in6 *)cl->client_addr)->sin6_port;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -999,64 +997,64 @@ ecore_con_client_fd_get(Ecore_Con_Client *cl)
|
|||
void
|
||||
ecore_con_event_proxy_bind(Ecore_Con_Server *svr)
|
||||
{
|
||||
Ecore_Con_Event_Proxy_Bind *e;
|
||||
int ev = ECORE_CON_EVENT_PROXY_BIND;
|
||||
Ecore_Con_Event_Proxy_Bind *e;
|
||||
int ev = ECORE_CON_EVENT_PROXY_BIND;
|
||||
|
||||
e = ecore_con_event_proxy_bind_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
e = ecore_con_event_proxy_bind_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
|
||||
svr->event_count = eina_list_append(svr->event_count, e);
|
||||
_ecore_con_server_timer_update(svr);
|
||||
e->server = svr;
|
||||
e->ip = svr->proxyip;
|
||||
e->port = svr->proxyport;
|
||||
ecore_event_add(ev, e,
|
||||
_ecore_con_event_server_add_free, NULL);
|
||||
svr->event_count = eina_list_append(svr->event_count, e);
|
||||
_ecore_con_server_timer_update(svr);
|
||||
e->server = svr;
|
||||
e->ip = svr->proxyip;
|
||||
e->port = svr->proxyport;
|
||||
ecore_event_add(ev, e,
|
||||
_ecore_con_event_server_add_free, NULL);
|
||||
_ecore_con_event_count++;
|
||||
}
|
||||
|
||||
void
|
||||
ecore_con_event_server_add(Ecore_Con_Server *svr)
|
||||
{
|
||||
/* we got our server! */
|
||||
Ecore_Con_Event_Server_Add *e;
|
||||
int ev = ECORE_CON_EVENT_SERVER_ADD;
|
||||
/* we got our server! */
|
||||
Ecore_Con_Event_Server_Add *e;
|
||||
int ev = ECORE_CON_EVENT_SERVER_ADD;
|
||||
|
||||
e = ecore_con_event_server_add_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
e = ecore_con_event_server_add_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
|
||||
svr->connecting = EINA_FALSE;
|
||||
svr->start_time = ecore_time_get();
|
||||
svr->event_count = eina_list_append(svr->event_count, e);
|
||||
_ecore_con_server_timer_update(svr);
|
||||
e->server = svr;
|
||||
if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE;
|
||||
ecore_event_add(ev, e,
|
||||
_ecore_con_event_server_add_free, NULL);
|
||||
svr->connecting = EINA_FALSE;
|
||||
svr->start_time = ecore_time_get();
|
||||
svr->event_count = eina_list_append(svr->event_count, e);
|
||||
_ecore_con_server_timer_update(svr);
|
||||
e->server = svr;
|
||||
if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE;
|
||||
ecore_event_add(ev, e,
|
||||
_ecore_con_event_server_add_free, NULL);
|
||||
_ecore_con_event_count++;
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
INF("svr %p is dead", svr);
|
||||
e = ecore_con_event_server_del_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
svr->delete_me = EINA_TRUE;
|
||||
INF("svr %p is dead", svr);
|
||||
e = ecore_con_event_server_del_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
|
||||
svr->event_count = eina_list_append(svr->event_count, e);
|
||||
_ecore_con_server_timer_update(svr);
|
||||
e->server = svr;
|
||||
if (svr->ecs)
|
||||
{
|
||||
svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE;
|
||||
eina_stringshare_replace(&svr->proxyip, NULL);
|
||||
svr->proxyport = 0;
|
||||
}
|
||||
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
|
||||
_ecore_con_event_server_del_free, NULL);
|
||||
svr->event_count = eina_list_append(svr->event_count, e);
|
||||
_ecore_con_server_timer_update(svr);
|
||||
e->server = svr;
|
||||
if (svr->ecs)
|
||||
{
|
||||
svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE;
|
||||
eina_stringshare_replace(&svr->proxyip, NULL);
|
||||
svr->proxyport = 0;
|
||||
}
|
||||
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
|
||||
_ecore_con_event_server_del_free, NULL);
|
||||
_ecore_con_event_count++;
|
||||
}
|
||||
|
||||
|
@ -1130,20 +1128,20 @@ ecore_con_event_client_add(Ecore_Con_Client *cl)
|
|||
void
|
||||
ecore_con_event_client_del(Ecore_Con_Client *cl)
|
||||
{
|
||||
Ecore_Con_Event_Client_Del *e;
|
||||
Ecore_Con_Event_Client_Del *e;
|
||||
|
||||
if (!cl) return;
|
||||
cl->delete_me = EINA_TRUE;
|
||||
INF("cl %p is dead", cl);
|
||||
e = ecore_con_event_client_del_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||
cl->event_count = eina_list_append(cl->event_count, e);
|
||||
if (!cl) return;
|
||||
cl->delete_me = EINA_TRUE;
|
||||
INF("cl %p is dead", cl);
|
||||
e = ecore_con_event_client_del_alloc();
|
||||
EINA_SAFETY_ON_NULL_RETURN(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);
|
||||
_ecore_con_cl_timer_update(cl);
|
||||
e->client = cl;
|
||||
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
|
||||
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
|
||||
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
||||
_ecore_con_cl_timer_update(cl);
|
||||
e->client = cl;
|
||||
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
|
||||
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
|
||||
_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++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
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
|
||||
_ecore_con_cb_tcp_listen(void *data,
|
||||
_ecore_con_cb_tcp_listen(void *data,
|
||||
Ecore_Con_Info *net_info)
|
||||
{
|
||||
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 (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
|
||||
net_info->info.ai_family,
|
||||
net_info->info.ai_socktype,
|
||||
1,
|
||||
svr->port) <= 0)
|
||||
{
|
||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||
goto error;
|
||||
}
|
||||
net_info->info.ai_family,
|
||||
net_info->info.ai_socktype,
|
||||
1,
|
||||
svr->port) <= 0)
|
||||
{
|
||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||
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 */
|
||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||
/* 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;
|
||||
|
||||
lin.l_onoff = 1;
|
||||
lin.l_linger = 0;
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||
sizeof(struct linger)) < 0)
|
||||
goto error;
|
||||
lin.l_onoff = 1;
|
||||
lin.l_linger = 0;
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||
sizeof(struct linger)) < 0)
|
||||
goto error;
|
||||
|
||||
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
|
||||
{
|
||||
int flag = 1;
|
||||
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
|
||||
{
|
||||
int flag = 1;
|
||||
|
||||
if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
||||
sizeof(int)) < 0)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
||||
sizeof(int)) < 0)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
goto fd_ready;
|
||||
goto fd_ready;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1526,7 +1523,7 @@ _ecore_con_cb_tcp_listen(void *data,
|
|||
|
||||
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,
|
||||
sizeof(int)) < 0)
|
||||
|
@ -1541,10 +1538,10 @@ _ecore_con_cb_tcp_listen(void *data,
|
|||
if (listen(svr->fd, 4096) < 0) goto error;
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
fd_ready:
|
||||
fd_ready:
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
memerr = "Memory allocation failure";
|
||||
|
@ -1554,13 +1551,13 @@ _ecore_con_cb_tcp_listen(void *data,
|
|||
return;
|
||||
|
||||
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_server_kill(svr);
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_con_cb_udp_listen(void *data,
|
||||
_ecore_con_cb_udp_listen(void *data,
|
||||
Ecore_Con_Info *net_info)
|
||||
{
|
||||
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 (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
|
||||
net_info->info.ai_family,
|
||||
net_info->info.ai_socktype,
|
||||
-1,
|
||||
svr->port) <= 0)
|
||||
{
|
||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||
goto error;
|
||||
}
|
||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||
net_info->info.ai_family,
|
||||
net_info->info.ai_socktype,
|
||||
-1,
|
||||
svr->port) <= 0)
|
||||
{
|
||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||
goto error;
|
||||
}
|
||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0)
|
||||
goto error;
|
||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0)
|
||||
goto error;
|
||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||
|
||||
goto fd_ready;
|
||||
goto fd_ready;
|
||||
}
|
||||
#endif
|
||||
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;
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
fd_ready:
|
||||
fd_ready:
|
||||
#endif
|
||||
svr->fd_handler =
|
||||
ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
|
||||
|
@ -1659,13 +1656,13 @@ _ecore_con_cb_udp_listen(void *data,
|
|||
return;
|
||||
|
||||
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_server_kill(svr);
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_con_cb_tcp_connect(void *data,
|
||||
_ecore_con_cb_tcp_connect(void *data,
|
||||
Ecore_Con_Info *net_info)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
|
@ -1752,13 +1749,13 @@ _ecore_con_cb_tcp_connect(void *data,
|
|||
|
||||
error:
|
||||
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_server_kill(svr);
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_con_cb_udp_connect(void *data,
|
||||
_ecore_con_cb_udp_connect(void *data,
|
||||
Ecore_Con_Info *net_info)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
|
@ -1810,7 +1807,7 @@ _ecore_con_cb_udp_connect(void *data,
|
|||
return;
|
||||
|
||||
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_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->ecs)
|
||||
{
|
||||
if (ecore_con_socks_svr_init(svr))
|
||||
return ECORE_CON_INPROGRESS;
|
||||
}
|
||||
else
|
||||
ecore_con_event_server_add(svr);
|
||||
if (svr->ecs)
|
||||
{
|
||||
if (ecore_con_socks_svr_init(svr))
|
||||
return ECORE_CON_INPROGRESS;
|
||||
}
|
||||
else
|
||||
ecore_con_event_server_add(svr);
|
||||
}
|
||||
|
||||
if (svr->fd_handler)
|
||||
|
@ -1884,25 +1881,27 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr)
|
|||
int family = client_addr->sa_family;
|
||||
void *src;
|
||||
|
||||
switch(family)
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
src = &(((struct sockaddr_in *)client_addr)->sin_addr);
|
||||
break;
|
||||
#ifdef HAVE_IPV6
|
||||
case AF_INET6:
|
||||
src = &(((struct sockaddr_in6 *)client_addr)->sin6_addr);
|
||||
case AF_INET:
|
||||
src = &(((struct sockaddr_in *)client_addr)->sin_addr);
|
||||
break;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
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
|
||||
default:
|
||||
return eina_stringshare_add("0.0.0.0");
|
||||
}
|
||||
default:
|
||||
return eina_stringshare_add("0.0.0.0");
|
||||
}
|
||||
|
||||
if (!inet_ntop(family, src, ipbuf, sizeof(ipbuf)))
|
||||
return eina_stringshare_add("0.0.0.0");
|
||||
|
@ -1912,7 +1911,7 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr)
|
|||
}
|
||||
|
||||
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_Con_Server *svr;
|
||||
|
@ -1995,7 +1994,7 @@ error:
|
|||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -2010,13 +2009,13 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
|
|||
|
||||
/* only possible with non-ssl connections */
|
||||
if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED))
|
||||
return;
|
||||
return;
|
||||
|
||||
if (svr->handshaking && (!svr->ecs_state))
|
||||
{
|
||||
DBG("Continuing ssl handshake");
|
||||
if (!ecore_con_ssl_server_init(svr))
|
||||
lost_server = EINA_FALSE;
|
||||
lost_server = EINA_FALSE;
|
||||
_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));
|
||||
/* 0 is not a valid return value for a tcp socket */
|
||||
if ((num > 0) || ((num < 0) && (errno == EAGAIN)))
|
||||
lost_server = EINA_FALSE;
|
||||
lost_server = EINA_FALSE;
|
||||
else if (num < 0)
|
||||
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));
|
||||
/* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */
|
||||
if (num >= 0)
|
||||
lost_server = EINA_FALSE;
|
||||
lost_server = EINA_FALSE;
|
||||
}
|
||||
|
||||
if ((!svr->delete_me) && (num > 0))
|
||||
|
@ -2047,11 +2046,11 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
|
|||
}
|
||||
|
||||
if (lost_server)
|
||||
_ecore_con_server_kill(svr);
|
||||
_ecore_con_server_kill(svr);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_con_cl_handler(void *data,
|
||||
_ecore_con_cl_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
|
@ -2111,7 +2110,7 @@ _ecore_con_cl_handler(void *data,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_con_cl_udp_handler(void *data,
|
||||
_ecore_con_cl_udp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
unsigned char buf[READBUFSIZ];
|
||||
|
@ -2147,7 +2146,7 @@ _ecore_con_cl_udp_handler(void *data,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_con_svr_udp_handler(void *data,
|
||||
_ecore_con_svr_udp_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
unsigned char buf[READBUFSIZ];
|
||||
|
@ -2172,13 +2171,13 @@ _ecore_con_svr_udp_handler(void *data,
|
|||
num = fcntl(svr->fd, F_SETFL, O_NONBLOCK);
|
||||
if (num >= 0)
|
||||
num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0,
|
||||
(struct sockaddr *)&client_addr,
|
||||
&client_addr_len);
|
||||
(struct sockaddr *)&client_addr,
|
||||
&client_addr_len);
|
||||
|
||||
#else
|
||||
num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT,
|
||||
(struct sockaddr *)&client_addr,
|
||||
&client_addr_len);
|
||||
(struct sockaddr *)&client_addr,
|
||||
&client_addr_len);
|
||||
#endif
|
||||
|
||||
if (num < 0 && (errno != EAGAIN) && (errno != EINTR))
|
||||
|
@ -2190,7 +2189,6 @@ _ecore_con_svr_udp_handler(void *data,
|
|||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
|
||||
/* Create a new client for use in the client data event */
|
||||
cl = calloc(1, sizeof(Ecore_Con_Client));
|
||||
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
|
||||
_ecore_con_svr_cl_handler(void *data,
|
||||
_ecore_con_svr_cl_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
Ecore_Con_Client *cl;
|
||||
|
@ -2349,12 +2347,12 @@ _ecore_con_server_flush(Ecore_Con_Server *svr)
|
|||
|
||||
if (count < 0)
|
||||
{
|
||||
if ((errno != EAGAIN) && (errno != EINTR))
|
||||
{
|
||||
ecore_con_event_server_error(svr, strerror(errno));
|
||||
_ecore_con_server_kill(svr);
|
||||
}
|
||||
return;
|
||||
if ((errno != EAGAIN) && (errno != EINTR))
|
||||
{
|
||||
ecore_con_event_server_error(svr, strerror(errno));
|
||||
_ecore_con_server_kill(svr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
ecore_con_event_client_error(cl, strerror(errno));
|
||||
_ecore_con_client_kill(cl);
|
||||
ecore_con_event_client_error(cl, strerror(errno));
|
||||
_ecore_con_client_kill(cl);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2469,7 +2467,7 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
|
|||
|
||||
static void
|
||||
_ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||
void *ev)
|
||||
void *ev)
|
||||
{
|
||||
Ecore_Con_Event_Client_Add *e;
|
||||
|
||||
|
@ -2477,7 +2475,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
|||
if (e->client)
|
||||
{
|
||||
Eina_Bool svrfreed = EINA_FALSE;
|
||||
|
||||
|
||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
||||
if (e->client->host_server)
|
||||
{
|
||||
|
@ -2503,7 +2501,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
|||
|
||||
static void
|
||||
_ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||
void *ev)
|
||||
void *ev)
|
||||
{
|
||||
Ecore_Con_Event_Client_Del *e;
|
||||
|
||||
|
@ -2511,7 +2509,7 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
|||
if (e->client)
|
||||
{
|
||||
Eina_Bool svrfreed = EINA_FALSE;
|
||||
|
||||
|
||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
||||
if (e->client->host_server)
|
||||
{
|
||||
|
@ -2541,7 +2539,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
|||
if (e->client)
|
||||
{
|
||||
Eina_Bool svrfreed = EINA_FALSE;
|
||||
|
||||
|
||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
||||
if (e->client->host_server)
|
||||
{
|
||||
|
@ -2557,7 +2555,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
|||
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
||||
((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_MCAST))))
|
||||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
||||
ecore_con_client_del(e->client);
|
||||
}
|
||||
}
|
||||
|
@ -2569,7 +2567,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
|||
|
||||
static void
|
||||
_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||
void *ev)
|
||||
void *ev)
|
||||
{
|
||||
Ecore_Con_Event_Client_Data *e;
|
||||
|
||||
|
@ -2577,7 +2575,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
|||
if (e->client)
|
||||
{
|
||||
Eina_Bool svrfreed = EINA_FALSE;
|
||||
|
||||
|
||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
||||
if (e->client->host_server)
|
||||
{
|
||||
|
@ -2593,7 +2591,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
|||
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
||||
((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_MCAST))))
|
||||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
||||
ecore_con_client_del(e->client);
|
||||
}
|
||||
}
|
||||
|
@ -2606,7 +2604,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
|||
|
||||
static void
|
||||
_ecore_con_event_server_add_free(void *data EINA_UNUSED,
|
||||
void *ev)
|
||||
void *ev)
|
||||
{
|
||||
Ecore_Con_Event_Server_Add *e;
|
||||
|
||||
|
@ -2625,7 +2623,7 @@ _ecore_con_event_server_add_free(void *data EINA_UNUSED,
|
|||
|
||||
static void
|
||||
_ecore_con_event_server_del_free(void *data EINA_UNUSED,
|
||||
void *ev)
|
||||
void *ev)
|
||||
{
|
||||
Ecore_Con_Event_Server_Del *e;
|
||||
|
||||
|
@ -2661,7 +2659,7 @@ _ecore_con_event_server_write_free(void *data EINA_UNUSED,
|
|||
|
||||
static void
|
||||
_ecore_con_event_server_data_free(void *data EINA_UNUSED,
|
||||
void *ev)
|
||||
void *ev)
|
||||
{
|
||||
Ecore_Con_Event_Server_Data *e;
|
||||
|
||||
|
@ -2680,7 +2678,6 @@ _ecore_con_event_server_data_free(void *data EINA_UNUSED,
|
|||
ecore_con_mempool_shutdown();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_ecore_con_event_server_error_free(void *data EINA_UNUSED, Ecore_Con_Event_Server_Error *e)
|
||||
{
|
||||
|
@ -2703,7 +2700,7 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
|
|||
if (e->client)
|
||||
{
|
||||
Eina_Bool svrfreed = EINA_FALSE;
|
||||
|
||||
|
||||
if (eina_list_data_find(svr->clients, e->client))
|
||||
{
|
||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
||||
|
@ -2728,7 +2725,7 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
|
|||
}
|
||||
|
||||
static void
|
||||
_ecore_con_lookup_done(void *data,
|
||||
_ecore_con_lookup_done(void *data,
|
||||
Ecore_Con_Info *infos)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
|
|
|
@ -10,24 +10,24 @@
|
|||
typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
|
||||
struct _Ecore_Con_Mempool
|
||||
{
|
||||
const char *name;
|
||||
const char *name;
|
||||
Eina_Mempool *mp;
|
||||
size_t size;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
#define GENERIC_ALLOC_FREE(TYPE, Type) \
|
||||
Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
|
||||
\
|
||||
TYPE * \
|
||||
Type##_alloc(void) \
|
||||
{ \
|
||||
return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
Type##_free(TYPE *e) \
|
||||
{ \
|
||||
eina_mempool_free(Type##_mp.mp, e); \
|
||||
#define GENERIC_ALLOC_FREE(TYPE, Type) \
|
||||
Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
|
||||
\
|
||||
TYPE * \
|
||||
Type##_alloc(void) \
|
||||
{ \
|
||||
return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
Type##_free(TYPE * e) \
|
||||
{ \
|
||||
eina_mempool_free(Type##_mp.mp, e); \
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
static Ecore_Con_Mempool *mempool_array[] = {
|
||||
&ecore_con_event_client_add_mp,
|
||||
&ecore_con_event_client_del_mp,
|
||||
&ecore_con_event_client_write_mp,
|
||||
&ecore_con_event_client_data_mp,
|
||||
&ecore_con_event_server_error_mp,
|
||||
&ecore_con_event_client_error_mp,
|
||||
&ecore_con_event_server_add_mp,
|
||||
&ecore_con_event_server_del_mp,
|
||||
&ecore_con_event_server_write_mp,
|
||||
&ecore_con_event_server_data_mp,
|
||||
&ecore_con_event_proxy_bind_mp
|
||||
&ecore_con_event_client_add_mp,
|
||||
&ecore_con_event_client_del_mp,
|
||||
&ecore_con_event_client_write_mp,
|
||||
&ecore_con_event_client_data_mp,
|
||||
&ecore_con_event_server_error_mp,
|
||||
&ecore_con_event_client_error_mp,
|
||||
&ecore_con_event_server_add_mp,
|
||||
&ecore_con_event_server_del_mp,
|
||||
&ecore_con_event_server_write_mp,
|
||||
&ecore_con_event_server_data_mp,
|
||||
&ecore_con_event_proxy_bind_mp
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -68,7 +68,7 @@ ecore_con_mempool_init(void)
|
|||
|
||||
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);
|
||||
if (!mempool_array[i]->mp)
|
||||
{
|
||||
|
|
|
@ -44,41 +44,42 @@ struct _Ecore_Con_CAres
|
|||
struct addrinfo hints;
|
||||
Ecore_Con_Info *result;
|
||||
|
||||
union {
|
||||
union
|
||||
{
|
||||
struct in_addr v4;
|
||||
#ifdef HAVE_IPV6
|
||||
struct in6_addr v6;
|
||||
#endif
|
||||
} addr;
|
||||
|
||||
Eina_Bool byaddr : 1;
|
||||
Eina_Bool isv6 : 1;
|
||||
Eina_Bool byaddr : 1;
|
||||
Eina_Bool isv6 : 1;
|
||||
};
|
||||
|
||||
static ares_channel info_channel;
|
||||
static int info_init = 0;
|
||||
static Eina_List *info_fds = NULL;
|
||||
|
||||
static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
char *node,
|
||||
char *service);
|
||||
static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
struct hostent *hostent);
|
||||
static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
char *node,
|
||||
char *service);
|
||||
static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
struct hostent *hostent);
|
||||
static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
|
||||
Ecore_Fd_Handler *fd_handler);
|
||||
static Eina_Bool _ecore_con_info_cares_timeout_cb(void *data);
|
||||
|
||||
static void
|
||||
_ecore_con_info_cares_state_cb(void *data,
|
||||
_ecore_con_info_cares_state_cb(void *data,
|
||||
ares_socket_t fd,
|
||||
int readable,
|
||||
int writable);
|
||||
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);
|
||||
|
||||
int
|
||||
|
@ -95,7 +96,7 @@ ecore_con_info_init(void)
|
|||
opts.sock_state_cb = _ecore_con_info_cares_state_cb;
|
||||
|
||||
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();
|
||||
return 0;
|
||||
|
@ -113,11 +114,11 @@ ecore_con_info_shutdown(void)
|
|||
if (info_init == 0)
|
||||
{
|
||||
/* Cancel all ongoing request */
|
||||
ares_cancel(info_channel);
|
||||
ares_destroy(info_channel);
|
||||
ares_cancel(info_channel);
|
||||
ares_destroy(info_channel);
|
||||
|
||||
/* Shutdown ares */
|
||||
ares_library_cleanup();
|
||||
/* Shutdown ares */
|
||||
ares_library_cleanup();
|
||||
}
|
||||
|
||||
return info_init;
|
||||
|
@ -126,7 +127,7 @@ ecore_con_info_shutdown(void)
|
|||
int
|
||||
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -149,7 +150,7 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -172,7 +173,7 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -195,7 +196,7 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -218,7 +219,7 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -240,10 +241,10 @@ ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
|||
|
||||
static Eina_Bool
|
||||
_ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
|
||||
int addrtype,
|
||||
const char *name,
|
||||
int addrtype,
|
||||
const char *name,
|
||||
struct sockaddr *addr,
|
||||
int addrlen)
|
||||
int addrlen)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
|
@ -285,8 +286,8 @@ _ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
|
|||
EAPI int
|
||||
ecore_con_info_get(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data,
|
||||
struct addrinfo *hints)
|
||||
void *data,
|
||||
struct addrinfo *hints)
|
||||
{
|
||||
Ecore_Con_CAres *cares;
|
||||
#ifdef HAVE_IPV6
|
||||
|
@ -358,7 +359,7 @@ _ecore_con_info_cares_timeout_cb(void *data EINA_UNUSED)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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))
|
||||
{
|
||||
|
@ -414,7 +415,7 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
|
|||
|
||||
search->fd = fd;
|
||||
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 */
|
||||
search->timer = ecore_timer_add(5, _ecore_con_info_cares_timeout_cb, NULL);
|
||||
info_fds = eina_list_append(info_fds, search);
|
||||
|
@ -427,9 +428,9 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
|
|||
|
||||
static void
|
||||
_ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
||||
int status,
|
||||
int timeouts EINA_UNUSED,
|
||||
struct hostent *hostent)
|
||||
int status,
|
||||
int timeouts EINA_UNUSED,
|
||||
struct hostent *hostent)
|
||||
{
|
||||
struct sockaddr *addr;
|
||||
int addrlen;
|
||||
|
@ -465,6 +466,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
addr = (struct sockaddr *)addri;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
case AF_INET6:
|
||||
{
|
||||
|
@ -487,6 +489,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
addr = (struct sockaddr *)addri6;
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
default:
|
||||
ERR("Unknown addrtype %i", hostent->h_addrtype);
|
||||
|
@ -505,56 +508,56 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
{
|
||||
#ifdef HAVE_IPV6
|
||||
/* This happen when host doesn't have a reverse. */
|
||||
if (arg->isv6)
|
||||
{
|
||||
struct sockaddr_in6 *addri6;
|
||||
if (arg->isv6)
|
||||
{
|
||||
struct sockaddr_in6 *addri6;
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
addri6 = malloc(addrlen);
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
addri6 = malloc(addrlen);
|
||||
|
||||
if (!addri6)
|
||||
goto on_mem_error;
|
||||
if (!addri6)
|
||||
goto on_mem_error;
|
||||
|
||||
addri6->sin6_family = AF_INET6;
|
||||
addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
||||
addri6->sin6_flowinfo = 0;
|
||||
addri6->sin6_scope_id = 0;
|
||||
addri6->sin6_family = AF_INET6;
|
||||
addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
||||
addri6->sin6_flowinfo = 0;
|
||||
addri6->sin6_scope_id = 0;
|
||||
|
||||
memcpy(&addri6->sin6_addr.s6_addr,
|
||||
&arg->addr.v6, sizeof(struct in6_addr));
|
||||
memcpy(&addri6->sin6_addr.s6_addr,
|
||||
&arg->addr.v6, sizeof(struct in6_addr));
|
||||
|
||||
addr = (struct sockaddr *)addri6;
|
||||
}
|
||||
else
|
||||
addr = (struct sockaddr *)addri6;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct sockaddr_in *addri;
|
||||
{
|
||||
struct sockaddr_in *addri;
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
addri = malloc(addrlen);
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
addri = malloc(addrlen);
|
||||
|
||||
if (!addri)
|
||||
goto on_mem_error;
|
||||
if (!addri)
|
||||
goto on_mem_error;
|
||||
|
||||
addri->sin_family = AF_INET;
|
||||
addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
||||
addri->sin_family = AF_INET;
|
||||
addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
|
||||
|
||||
memcpy(&addri->sin_addr.s_addr,
|
||||
&arg->addr.v4, sizeof(struct in_addr));
|
||||
memcpy(&addri->sin_addr.s_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
|
||||
arg->isv6 ? AF_INET6 :
|
||||
arg->isv6 ? AF_INET6 :
|
||||
#endif
|
||||
AF_INET,
|
||||
NULL, addr,
|
||||
addrlen))
|
||||
goto on_error;
|
||||
AF_INET,
|
||||
NULL, addr,
|
||||
addrlen))
|
||||
goto on_error;
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case ARES_ENOTIMP: /* unknown family */
|
||||
|
@ -589,10 +592,10 @@ on_error:
|
|||
|
||||
static void
|
||||
_ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
|
||||
int status,
|
||||
int timeouts EINA_UNUSED,
|
||||
char *node,
|
||||
char *service)
|
||||
int status,
|
||||
int timeouts EINA_UNUSED,
|
||||
char *node,
|
||||
char *service)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
#include "Ecore_Con.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_resolver dns_resolver;
|
||||
typedef struct dns_resolver dns_resolver;
|
||||
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
|
||||
{
|
||||
|
@ -71,15 +71,17 @@ _ecore_con_dns_check(Ecore_Con_DNS *dns)
|
|||
{
|
||||
struct addrinfo *ent = NULL;
|
||||
int error = 0;
|
||||
|
||||
|
||||
error = dns_ai_nextent(&ent, dns->ai);
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case EAGAIN:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
ERR("resolve failed: %s", dns_strerror(error));
|
||||
goto error;
|
||||
|
@ -298,7 +300,6 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
|||
{
|
||||
ERR("res_open: %s", dns_strerror(error));
|
||||
goto reserr;
|
||||
|
||||
}
|
||||
|
||||
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:
|
||||
break;
|
||||
|
||||
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);
|
||||
svr->infos = eina_list_append(svr->infos, dns);
|
||||
dns->timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_dns_timer_cb, dns);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,54 +17,54 @@
|
|||
|
||||
#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_Client Ecore_Con_Eet_Client;
|
||||
typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server;
|
||||
typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client;
|
||||
typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server;
|
||||
|
||||
struct _Ecore_Con_Reply
|
||||
{
|
||||
Ecore_Con_Eet *ece;
|
||||
Ecore_Con_Client *client;
|
||||
Ecore_Con_Eet *ece;
|
||||
Ecore_Con_Client *client;
|
||||
|
||||
Eet_Connection *econn;
|
||||
Eet_Connection *econn;
|
||||
|
||||
char *buffer_section;
|
||||
unsigned char *buffer;
|
||||
unsigned int buffer_length;
|
||||
unsigned int buffer_current;
|
||||
char *buffer_section;
|
||||
unsigned char *buffer;
|
||||
unsigned int buffer_length;
|
||||
unsigned int buffer_current;
|
||||
Ecore_Con_Eet_Raw_Data *buffer_handler;
|
||||
};
|
||||
|
||||
struct _Ecore_Con_Eet_Data
|
||||
{
|
||||
Ecore_Con_Eet_Data_Cb func;
|
||||
const char *name;
|
||||
const void *data;
|
||||
const char *name;
|
||||
const void *data;
|
||||
};
|
||||
|
||||
struct _Ecore_Con_Eet_Raw_Data
|
||||
{
|
||||
Ecore_Con_Eet_Raw_Data_Cb func;
|
||||
const char *name;
|
||||
const void *data;
|
||||
const char *name;
|
||||
const void *data;
|
||||
};
|
||||
|
||||
struct _Ecore_Con_Eet_Client
|
||||
{
|
||||
Ecore_Con_Eet_Client_Cb func;
|
||||
const void *data;
|
||||
const void *data;
|
||||
};
|
||||
|
||||
struct _Ecore_Con_Eet_Server
|
||||
{
|
||||
Ecore_Con_Eet_Server_Cb func;
|
||||
const void *data;
|
||||
const void *data;
|
||||
};
|
||||
|
||||
struct _Ecore_Con_Eet
|
||||
{
|
||||
Ecore_Con_Server *server;
|
||||
Ecore_Con_Server *server;
|
||||
|
||||
Ecore_Event_Handler *handler_add;
|
||||
Ecore_Event_Handler *handler_del;
|
||||
|
@ -73,25 +73,28 @@ struct _Ecore_Con_Eet
|
|||
Eet_Data_Descriptor *edd;
|
||||
Eet_Data_Descriptor *matching;
|
||||
|
||||
Eina_Hash *data_callbacks;
|
||||
Eina_Hash *raw_data_callbacks;
|
||||
Eina_Hash *data_callbacks;
|
||||
Eina_Hash *raw_data_callbacks;
|
||||
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Eina_List *connections;
|
||||
Eina_List *client_connect_callbacks;
|
||||
Eina_List *client_disconnect_callbacks;
|
||||
} server;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
Ecore_Con_Reply *r;
|
||||
Eina_List *server_connect_callbacks;
|
||||
Eina_List *server_disconnect_callbacks;
|
||||
Eina_List *server_connect_callbacks;
|
||||
Eina_List *server_disconnect_callbacks;
|
||||
} client;
|
||||
} u;
|
||||
|
||||
const void *data;
|
||||
|
||||
Eina_Bool client : 1;
|
||||
Eina_Bool client : 1;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -111,6 +114,7 @@ _ecore_con_eet_raw_data_free(void *data)
|
|||
eina_stringshare_del(eced->name);
|
||||
free(eced);
|
||||
}
|
||||
|
||||
static void
|
||||
_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;
|
||||
struct _Ecore_Con_Eet_Protocol {
|
||||
struct _Ecore_Con_Eet_Protocol
|
||||
{
|
||||
const char *type;
|
||||
void *data;
|
||||
void *data;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
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_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;
|
||||
|
||||
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_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);
|
||||
|
||||
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);
|
||||
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_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);
|
||||
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_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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
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;
|
||||
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)
|
||||
{
|
||||
char *buffer = (char*) &tmp[4];
|
||||
char *buffer = (char *)&tmp[4];
|
||||
char *protocol;
|
||||
char *section;
|
||||
|
||||
|
@ -325,7 +330,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
|
|||
if (n->buffer_handler)
|
||||
n->buffer = malloc(sizeof (unsigned char) * data_length);
|
||||
else
|
||||
n->buffer = (void*) 1;
|
||||
n->buffer = (void *)1;
|
||||
if (n->buffer)
|
||||
{
|
||||
_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);
|
||||
|
||||
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);
|
||||
free(n);
|
||||
|
@ -406,7 +411,7 @@ _ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_E
|
|||
|
||||
/* Client disconnected */
|
||||
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);
|
||||
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 *
|
||||
ecore_con_eet_server_new(Ecore_Con_Server *server)
|
||||
|
@ -578,7 +583,7 @@ ecore_con_eet_raw_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_
|
|||
eced->data = data;
|
||||
eced->name = eina_stringshare_add(name);
|
||||
|
||||
eina_hash_direct_add(ece->raw_data_callbacks, eced->name, eced);
|
||||
eina_hash_direct_add(ece->raw_data_callbacks, eced->name, eced);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -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;
|
||||
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);
|
||||
}
|
||||
|
@ -740,7 +745,7 @@ EAPI void *
|
|||
ecore_con_eet_data_get(Ecore_Con_Eet *ece)
|
||||
{
|
||||
if (!ece) return NULL;
|
||||
return (void*) ece->data;
|
||||
return (void *)ece->data;
|
||||
}
|
||||
|
||||
EAPI Ecore_Con_Eet *
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef struct _CB_Data CB_Data;
|
|||
|
||||
struct _CB_Data
|
||||
{
|
||||
EINA_INLIST;
|
||||
EINA_INLIST;
|
||||
Ecore_Con_Info_Cb cb_done;
|
||||
void *data;
|
||||
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_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);
|
||||
static Eina_Bool _ecore_con_info_exit_handler(void *data,
|
||||
static Eina_Bool _ecore_con_info_exit_handler(void *data,
|
||||
int type EINA_UNUSED,
|
||||
void *event);
|
||||
void *event);
|
||||
|
||||
static int info_init = 0;
|
||||
static CB_Data *info_slaves = NULL;
|
||||
|
@ -77,7 +77,8 @@ ecore_con_info_shutdown(void)
|
|||
{
|
||||
info_init--;
|
||||
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;
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ ecore_con_info_shutdown(void)
|
|||
int
|
||||
ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -104,7 +105,7 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -123,7 +124,7 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -142,7 +143,7 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -161,7 +162,7 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data)
|
||||
void *data)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
||||
|
@ -192,7 +193,7 @@ _ecore_fd_close_on_exec(int fd)
|
|||
return EINA_FALSE;
|
||||
return EINA_TRUE;
|
||||
#else
|
||||
(void) fd;
|
||||
(void)fd;
|
||||
return EINA_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
@ -200,8 +201,8 @@ _ecore_fd_close_on_exec(int fd)
|
|||
EAPI int
|
||||
ecore_con_info_get(Ecore_Con_Server *svr,
|
||||
Ecore_Con_Info_Cb done_cb,
|
||||
void *data,
|
||||
struct addrinfo *hints)
|
||||
void *data,
|
||||
struct addrinfo *hints)
|
||||
{
|
||||
CB_Data *cbdata;
|
||||
int fd[2];
|
||||
|
@ -407,7 +408,7 @@ _ecore_con_info_slave_free(CB_Data *cbdata)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_con_info_data_handler(void *data,
|
||||
_ecore_con_info_data_handler(void *data,
|
||||
Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
CB_Data *cbdata;
|
||||
|
@ -434,9 +435,9 @@ _ecore_con_info_data_handler(void *data,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_con_info_exit_handler(void *data,
|
||||
_ecore_con_info_exit_handler(void *data,
|
||||
int type EINA_UNUSED,
|
||||
void *event)
|
||||
void *event)
|
||||
{
|
||||
CB_Data *cbdata;
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
|
|
|
@ -181,10 +181,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
|||
int
|
||||
ecore_con_local_listen(
|
||||
Ecore_Con_Server *svr,
|
||||
Eina_Bool (*
|
||||
cb_listen)(void *data,
|
||||
Ecore_Fd_Handler *
|
||||
fd_handler),
|
||||
Eina_Bool (*
|
||||
cb_listen)(void *data,
|
||||
Ecore_Fd_Handler *
|
||||
fd_handler),
|
||||
void *data
|
||||
EINA_UNUSED)
|
||||
{
|
||||
|
@ -291,28 +291,28 @@ start:
|
|||
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,
|
||||
SOCK_STREAM, 1,
|
||||
socket_unix.sun_path,
|
||||
abstract_socket ? socket_unix_len : 0) <= 0)
|
||||
{
|
||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||
goto error_umask;
|
||||
}
|
||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||
SOCK_STREAM, 1,
|
||||
socket_unix.sun_path,
|
||||
abstract_socket ? socket_unix_len : 0) <= 0)
|
||||
{
|
||||
ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
|
||||
goto error_umask;
|
||||
}
|
||||
svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
|
||||
|
||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
|
||||
goto error_umask;
|
||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
|
||||
goto error_umask;
|
||||
|
||||
lin.l_onoff = 1;
|
||||
lin.l_linger = 0;
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||
sizeof(struct linger)) < 0)
|
||||
goto error_umask;
|
||||
lin.l_onoff = 1;
|
||||
lin.l_linger = 0;
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||
sizeof(struct linger)) < 0)
|
||||
goto error_umask;
|
||||
|
||||
goto fd_ready;
|
||||
goto fd_ready;
|
||||
}
|
||||
#else
|
||||
(void) abstract_socket;
|
||||
(void)abstract_socket;
|
||||
#endif
|
||||
svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (svr->fd < 0)
|
||||
|
@ -346,7 +346,7 @@ start:
|
|||
goto error_umask;
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
fd_ready:
|
||||
fd_ready:
|
||||
#endif
|
||||
svr->path = strdup(buf);
|
||||
if (!svr->path)
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#define BUFSIZE 512
|
||||
|
||||
|
||||
static int _ecore_con_local_init_count = 0;
|
||||
|
||||
int
|
||||
|
@ -33,58 +32,57 @@ ecore_con_local_shutdown(void)
|
|||
return _ecore_con_local_init_count;
|
||||
}
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_con_local_win32_server_read_client_handler(void *data, Ecore_Win32_Handler *wh)
|
||||
{
|
||||
Ecore_Con_Client *cl;
|
||||
void *buf;
|
||||
DWORD n;
|
||||
Eina_Bool broken_pipe = EINA_FALSE;
|
||||
Ecore_Con_Client *cl;
|
||||
void *buf;
|
||||
DWORD n;
|
||||
Eina_Bool broken_pipe = EINA_FALSE;
|
||||
|
||||
cl = (Ecore_Con_Client *)data;
|
||||
cl = (Ecore_Con_Client *)data;
|
||||
|
||||
if (!ResetEvent(cl->host_server->event_read))
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
if (!ResetEvent(cl->host_server->event_read))
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
|
||||
buf = malloc(cl->host_server->nbr_bytes);
|
||||
if (!buf)
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
buf = malloc(cl->host_server->nbr_bytes);
|
||||
if (!buf)
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
|
||||
if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL))
|
||||
{
|
||||
if (!cl->delete_me)
|
||||
ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE);
|
||||
cl->host_server->want_write = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetLastError() == ERROR_BROKEN_PIPE)
|
||||
broken_pipe = EINA_TRUE;
|
||||
}
|
||||
if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL))
|
||||
{
|
||||
if (!cl->delete_me)
|
||||
ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE);
|
||||
cl->host_server->want_write = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetLastError() == ERROR_BROKEN_PIPE)
|
||||
broken_pipe = EINA_TRUE;
|
||||
}
|
||||
|
||||
if (broken_pipe)
|
||||
{
|
||||
if (broken_pipe)
|
||||
{
|
||||
#if 0
|
||||
char *msg;
|
||||
char *msg;
|
||||
|
||||
msg = evil_last_error_get();
|
||||
if (msg)
|
||||
{
|
||||
ecore_con_event_client_error(cl, msg);
|
||||
free(msg);
|
||||
}
|
||||
msg = evil_last_error_get();
|
||||
if (msg)
|
||||
{
|
||||
ecore_con_event_client_error(cl, msg);
|
||||
free(msg);
|
||||
}
|
||||
#endif
|
||||
_ecore_con_client_kill(cl);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
_ecore_con_client_kill(cl);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
if (cl->host_server->want_write)
|
||||
ecore_con_local_win32_client_flush(cl);
|
||||
if (cl->host_server->want_write)
|
||||
ecore_con_local_win32_client_flush(cl);
|
||||
|
||||
ecore_main_win32_handler_del(wh);
|
||||
|
||||
return ECORE_CALLBACK_DONE;
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -147,54 +145,54 @@ _ecore_con_local_win32_client_peek_server_handler(void *data, Ecore_Win32_Handle
|
|||
static Eina_Bool
|
||||
_ecore_con_local_win32_client_read_server_handler(void *data, Ecore_Win32_Handler *wh)
|
||||
{
|
||||
Ecore_Con_Server *svr;
|
||||
void *buf;
|
||||
DWORD n;
|
||||
Eina_Bool broken_pipe = EINA_FALSE;
|
||||
Ecore_Con_Server *svr;
|
||||
void *buf;
|
||||
DWORD n;
|
||||
Eina_Bool broken_pipe = EINA_FALSE;
|
||||
|
||||
svr = (Ecore_Con_Server *)data;
|
||||
svr = (Ecore_Con_Server *)data;
|
||||
|
||||
if (!ResetEvent(svr->event_read))
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
if (!ResetEvent(svr->event_read))
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
|
||||
buf = malloc(svr->nbr_bytes);
|
||||
if (!buf)
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
buf = malloc(svr->nbr_bytes);
|
||||
if (!buf)
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
|
||||
if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL))
|
||||
{
|
||||
if (!svr->delete_me)
|
||||
ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE);
|
||||
svr->want_write = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetLastError() == ERROR_BROKEN_PIPE)
|
||||
broken_pipe = EINA_TRUE;
|
||||
}
|
||||
if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL))
|
||||
{
|
||||
if (!svr->delete_me)
|
||||
ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE);
|
||||
svr->want_write = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetLastError() == ERROR_BROKEN_PIPE)
|
||||
broken_pipe = EINA_TRUE;
|
||||
}
|
||||
|
||||
if (broken_pipe)
|
||||
{
|
||||
if (broken_pipe)
|
||||
{
|
||||
#if 0
|
||||
char *msg;
|
||||
char *msg;
|
||||
|
||||
msg = evil_last_error_get();
|
||||
if (msg)
|
||||
{
|
||||
ecore_con_event_server_error(svr, msg);
|
||||
free(msg);
|
||||
}
|
||||
msg = evil_last_error_get();
|
||||
if (msg)
|
||||
{
|
||||
ecore_con_event_server_error(svr, msg);
|
||||
free(msg);
|
||||
}
|
||||
#endif
|
||||
_ecore_con_server_kill(svr);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
_ecore_con_server_kill(svr);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
if (svr->want_write)
|
||||
ecore_con_local_win32_server_flush(svr);
|
||||
if (svr->want_write)
|
||||
ecore_con_local_win32_server_flush(svr);
|
||||
|
||||
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 */
|
||||
|
@ -356,15 +354,15 @@ _ecore_con_local_win32_client_add(void *data, Ecore_Win32_Handler *wh)
|
|||
ResumeThread(cl->host_server->thread_read);
|
||||
return ECORE_CALLBACK_DONE;
|
||||
|
||||
del_handler_peek:
|
||||
del_handler_peek:
|
||||
ecore_main_win32_handler_del(handler_peek);
|
||||
close_event_peek:
|
||||
close_event_peek:
|
||||
CloseHandle(cl->host_server->event_peek);
|
||||
del_handler_read:
|
||||
del_handler_read:
|
||||
ecore_main_win32_handler_del(handler_read);
|
||||
close_event_read:
|
||||
close_event_read:
|
||||
CloseHandle(cl->host_server->event_read);
|
||||
free_cl:
|
||||
free_cl:
|
||||
free(cl);
|
||||
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
|
@ -472,11 +470,11 @@ ecore_con_local_listen(Ecore_Con_Server *svr)
|
|||
|
||||
return EINA_TRUE;
|
||||
|
||||
del_handler:
|
||||
del_handler:
|
||||
ecore_main_win32_handler_del(handler);
|
||||
close_pipe:
|
||||
close_pipe:
|
||||
CloseHandle(svr->pipe);
|
||||
free_path:
|
||||
free_path:
|
||||
free(svr->path);
|
||||
svr->path = NULL;
|
||||
|
||||
|
@ -579,7 +577,7 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
|||
{
|
||||
ERR("Connection to a server failed");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* pipe busy, so we wait for it */
|
||||
if (!WaitNamedPipe(buf, NMPWAIT_WAIT_FOREVER))
|
||||
|
@ -641,18 +639,18 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
|||
|
||||
return EINA_TRUE;
|
||||
|
||||
del_handler_peek:
|
||||
del_handler_peek:
|
||||
ecore_main_win32_handler_del(handler_peek);
|
||||
close_event_peek:
|
||||
close_event_peek:
|
||||
CloseHandle(svr->event_peek);
|
||||
del_handler_read:
|
||||
del_handler_read:
|
||||
ecore_main_win32_handler_del(handler_read);
|
||||
close_event_read:
|
||||
close_event_read:
|
||||
CloseHandle(svr->event_read);
|
||||
free_path:
|
||||
free_path:
|
||||
free(svr->path);
|
||||
svr->path = NULL;
|
||||
close_pipe:
|
||||
close_pipe:
|
||||
CloseHandle(svr->pipe);
|
||||
|
||||
return EINA_FALSE;
|
||||
|
@ -752,3 +750,4 @@ ecore_con_local_win32_client_flush(Ecore_Con_Client *cl)
|
|||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "ecore_con_private.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(IF_NAMESIZE)
|
||||
#define IF_NAMESIZE 16
|
||||
#define IF_NAMESIZE 16
|
||||
#endif
|
||||
|
||||
/* http://tools.ietf.org/html/rfc1928
|
||||
|
@ -58,9 +58,9 @@
|
|||
o X'03' to X'7F' IANA ASSIGNED
|
||||
o X'80' to X'FE' RESERVED FOR PRIVATE METHODS
|
||||
o X'FF' NO ACCEPTABLE METHODS
|
||||
*/
|
||||
#define ECORE_CON_SOCKS_V5_METHOD_NONE 0
|
||||
#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1
|
||||
*/
|
||||
#define ECORE_CON_SOCKS_V5_METHOD_NONE 0
|
||||
#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1
|
||||
#define ECORE_CON_SOCKS_V5_METHOD_USERPASS 2
|
||||
|
||||
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_server_kill(svr) do { \
|
||||
DBG("KILL %p", (svr)); \
|
||||
_ecore_con_server_kill((svr)); \
|
||||
} while (0)
|
||||
#define _ecore_con_server_kill(svr) do { \
|
||||
DBG("KILL %p", (svr)); \
|
||||
_ecore_con_server_kill((svr)); \
|
||||
} while (0)
|
||||
|
||||
#define ECORE_CON_SOCKS_VERSION_CHECK(X) do { \
|
||||
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
||||
return; \
|
||||
} while (0)
|
||||
#define ECORE_CON_SOCKS_VERSION_CHECK_RETURN(X, ret) do { \
|
||||
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
||||
return (ret); \
|
||||
} while (0)
|
||||
#define ECORE_CON_SOCKS_VERSION_CHECK(X) do { \
|
||||
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
||||
return; \
|
||||
} while (0)
|
||||
#define ECORE_CON_SOCKS_VERSION_CHECK_RETURN(X, ret) do { \
|
||||
if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
|
||||
return (ret); \
|
||||
} while (0)
|
||||
|
||||
#define ECORE_CON_SOCKS_CAST(X) \
|
||||
Ecore_Con_Socks_v4 *v4 = NULL; \
|
||||
Ecore_Con_Socks_v5 *v5 = NULL; \
|
||||
if ((X) && ((X)->version == 4)) \
|
||||
v4 = (Ecore_Con_Socks_v4 *)(X); \
|
||||
else if ((X) && ((X)->version == 5)) \
|
||||
v5 = (Ecore_Con_Socks_v5 *)(X);
|
||||
#define ECORE_CON_SOCKS_CAST(X) \
|
||||
Ecore_Con_Socks_v4 * v4 = NULL; \
|
||||
Ecore_Con_Socks_v5 *v5 = NULL; \
|
||||
if ((X) && ((X)->version == 4)) \
|
||||
v4 = (Ecore_Con_Socks_v4 *)(X); \
|
||||
else if ((X) && ((X)->version == 5)) \
|
||||
v5 = (Ecore_Con_Socks_v5 *)(X);
|
||||
|
||||
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 (password && strcmp(ecs->password, password)) continue;
|
||||
}
|
||||
return (Ecore_Con_Socks*)ecs;
|
||||
return (Ecore_Con_Socks *)ecs;
|
||||
}
|
||||
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;
|
||||
if (v4->username) ulen += v4->ulen;
|
||||
buflen = sizeof(char) * (8 + ulen + addrlen);
|
||||
buflen = sizeof(char) * (8 + ulen + addrlen);
|
||||
sbuf = malloc(buflen);
|
||||
if (!sbuf)
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
|||
unsigned char *sbuf;
|
||||
|
||||
if (v5->username)
|
||||
buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS);
|
||||
buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS);
|
||||
else
|
||||
buflen = 3;
|
||||
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;
|
||||
if (v5->username)
|
||||
{
|
||||
sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS;
|
||||
for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++)
|
||||
sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2];
|
||||
sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS;
|
||||
for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++)
|
||||
sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -210,19 +210,20 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
#define ECORE_CON_SOCKS_READ(EXACT) \
|
||||
if (num < EXACT) \
|
||||
{ \
|
||||
if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \
|
||||
if (!svr->ecs_recvbuf) goto error; \
|
||||
eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \
|
||||
/* the slowest connection on earth */ \
|
||||
if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \
|
||||
data = eina_binbuf_string_get(svr->ecs_recvbuf); \
|
||||
} \
|
||||
else if (num > EXACT) goto error; \
|
||||
else \
|
||||
data = buf
|
||||
#define ECORE_CON_SOCKS_READ(EXACT) \
|
||||
if (num < EXACT) \
|
||||
{ \
|
||||
if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \
|
||||
if (!svr->ecs_recvbuf) goto error; \
|
||||
eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \
|
||||
/* the slowest connection on earth */ \
|
||||
if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \
|
||||
data = eina_binbuf_string_get(svr->ecs_recvbuf); \
|
||||
} \
|
||||
else if (num > EXACT) \
|
||||
goto error; \
|
||||
else \
|
||||
data = buf
|
||||
|
||||
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)
|
||||
|
@ -238,15 +239,19 @@ _ecore_con_socks_read_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4 EINA_UNUS
|
|||
case 90:
|
||||
/* success! */
|
||||
break;
|
||||
|
||||
case 91:
|
||||
ecore_con_event_server_error(svr, "proxy request rejected or failed");
|
||||
goto error;
|
||||
|
||||
case 92:
|
||||
ecore_con_event_server_error(svr, "proxying SOCKS server could not perform authentication");
|
||||
goto error;
|
||||
|
||||
case 93:
|
||||
ecore_con_event_server_error(svr, "proxy request authentication rejected");
|
||||
goto error;
|
||||
|
||||
default:
|
||||
ecore_con_event_server_error(svr, "garbage data from proxy");
|
||||
goto error;
|
||||
|
@ -285,30 +290,33 @@ _ecore_con_socks_auth_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
|
|||
unsigned char *data;
|
||||
switch (v5->method)
|
||||
{
|
||||
case ECORE_CON_SOCKS_V5_METHOD_NONE:
|
||||
svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST;
|
||||
return EINA_TRUE;
|
||||
case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
|
||||
return EINA_TRUE;
|
||||
case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
|
||||
if (!v5->username) return EINA_FALSE;
|
||||
if (!v5->password) v5->plen = 1;
|
||||
/* http://tools.ietf.org/html/rfc1929 */
|
||||
size = sizeof(char) * (3 + v5->ulen + v5->plen);
|
||||
data = malloc(size);
|
||||
if (!data) break;
|
||||
data[0] = 1;
|
||||
data[1] = v5->ulen;
|
||||
memcpy(&data[2], v5->username, v5->ulen);
|
||||
data[1 + v5->ulen] = v5->plen;
|
||||
if (v5->password)
|
||||
memcpy(&data[2 + v5->ulen], v5->password, v5->plen);
|
||||
else
|
||||
data[2 + v5->ulen] = 0;
|
||||
svr->ecs_buf = eina_binbuf_manage_new_length(data, size);
|
||||
return EINA_TRUE;
|
||||
default:
|
||||
break;
|
||||
case ECORE_CON_SOCKS_V5_METHOD_NONE:
|
||||
svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST;
|
||||
return EINA_TRUE;
|
||||
|
||||
case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
|
||||
return EINA_TRUE;
|
||||
|
||||
case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
|
||||
if (!v5->username) return EINA_FALSE;
|
||||
if (!v5->password) v5->plen = 1;
|
||||
/* http://tools.ietf.org/html/rfc1929 */
|
||||
size = sizeof(char) * (3 + v5->ulen + v5->plen);
|
||||
data = malloc(size);
|
||||
if (!data) break;
|
||||
data[0] = 1;
|
||||
data[1] = v5->ulen;
|
||||
memcpy(&data[2], v5->username, v5->ulen);
|
||||
data[1 + v5->ulen] = v5->plen;
|
||||
if (v5->password)
|
||||
memcpy(&data[2 + v5->ulen], v5->password, v5->plen);
|
||||
else
|
||||
data[2 + v5->ulen] = 0;
|
||||
svr->ecs_buf = eina_binbuf_manage_new_length(data, size);
|
||||
return EINA_TRUE;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -321,179 +329,197 @@ _ecore_con_socks_read_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5, const un
|
|||
DBG("SOCKS: %d bytes", num);
|
||||
switch (svr->ecs_state)
|
||||
{
|
||||
|
||||
case ECORE_CON_PROXY_STATE_READ:
|
||||
ECORE_CON_SOCKS_READ(2);
|
||||
/* http://en.wikipedia.org/wiki/SOCKS */
|
||||
if (data[0] != 5) goto error;
|
||||
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:
|
||||
case ECORE_CON_PROXY_STATE_READ:
|
||||
ECORE_CON_SOCKS_READ(2);
|
||||
/* http://en.wikipedia.org/wiki/SOCKS */
|
||||
if (data[0] != 5) goto error;
|
||||
if (data[1] == 0xFF)
|
||||
{
|
||||
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;
|
||||
ecore_con_event_server_error(svr, "proxy authentication methods rejected");
|
||||
goto error;
|
||||
}
|
||||
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,
|
||||
* 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);
|
||||
/* 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;
|
||||
|
||||
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");
|
||||
goto error; /* wrong version */
|
||||
goto error; /* wrong version */
|
||||
}
|
||||
switch (data[1])
|
||||
if (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");
|
||||
ecore_con_event_server_error(svr, "proxy request authentication rejected");
|
||||
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");
|
||||
|
||||
default:
|
||||
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:
|
||||
break;
|
||||
}
|
||||
if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf);
|
||||
svr->ecs_recvbuf = NULL;
|
||||
|
||||
|
||||
return;
|
||||
error:
|
||||
_ecore_con_server_kill(svr);
|
||||
|
@ -613,7 +639,7 @@ ecore_con_socks_init(void)
|
|||
ecore_con_socks_lookup_set(ecs, lookup);
|
||||
ecore_con_socks_apply_always(ecs);
|
||||
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 (!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;
|
||||
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
|
||||
*
|
||||
|
@ -744,8 +771,8 @@ ecore_con_socks5_remote_add(const char *ip, int port, const char *username, cons
|
|||
/* max length for protocol */
|
||||
if ((!plen) || (plen > 255)) return NULL;
|
||||
}
|
||||
ecs5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen);
|
||||
if (ecs5) return (Ecore_Con_Socks*)ecs5;
|
||||
ecs5 = (Ecore_Con_Socks_v5 *)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen);
|
||||
if (ecs5) return (Ecore_Con_Socks *)ecs5;
|
||||
|
||||
ecs5 = calloc(1, sizeof(Ecore_Con_Socks_v5));
|
||||
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->plen = plen;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -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_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);
|
||||
gnutls_free(c);
|
||||
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
|
||||
static void
|
||||
_gnutls_log_func(int level,
|
||||
_gnutls_log_func(int level,
|
||||
const char *str)
|
||||
{
|
||||
char buf[128];
|
||||
strncat(buf, str, strlen(str) - 1);
|
||||
DBG("|<%d>| %s", level, buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static const char *
|
||||
|
@ -151,174 +152,174 @@ _openssl_print_verify_error(int error)
|
|||
switch (error)
|
||||
{
|
||||
#define ERROR(X) \
|
||||
case (X): \
|
||||
ERR("%s", #X); \
|
||||
break
|
||||
case (X): \
|
||||
ERR("%s", #X); \
|
||||
break
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#ifdef X509_V_ERR_CERT_SIGNATURE_FAILURE
|
||||
ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE);
|
||||
ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_CRL_SIGNATURE_FAILURE
|
||||
ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE);
|
||||
ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE);
|
||||
#endif
|
||||
#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
|
||||
#ifdef X509_V_ERR_CERT_HAS_EXPIRED
|
||||
ERROR(X509_V_ERR_CERT_HAS_EXPIRED);
|
||||
ERROR(X509_V_ERR_CERT_HAS_EXPIRED);
|
||||
#endif
|
||||
#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
|
||||
#ifdef X509_V_ERR_CRL_HAS_EXPIRED
|
||||
ERROR(X509_V_ERR_CRL_HAS_EXPIRED);
|
||||
ERROR(X509_V_ERR_CRL_HAS_EXPIRED);
|
||||
#endif
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#ifdef X509_V_ERR_OUT_OF_MEM
|
||||
ERROR(X509_V_ERR_OUT_OF_MEM);
|
||||
ERROR(X509_V_ERR_OUT_OF_MEM);
|
||||
#endif
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#ifdef X509_V_ERR_CERT_REVOKED
|
||||
ERROR(X509_V_ERR_CERT_REVOKED);
|
||||
ERROR(X509_V_ERR_CERT_REVOKED);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_INVALID_CA
|
||||
ERROR(X509_V_ERR_INVALID_CA);
|
||||
ERROR(X509_V_ERR_INVALID_CA);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_PATH_LENGTH_EXCEEDED
|
||||
ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED);
|
||||
ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_INVALID_PURPOSE
|
||||
ERROR(X509_V_ERR_INVALID_PURPOSE);
|
||||
ERROR(X509_V_ERR_INVALID_PURPOSE);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_CERT_UNTRUSTED
|
||||
ERROR(X509_V_ERR_CERT_UNTRUSTED);
|
||||
ERROR(X509_V_ERR_CERT_UNTRUSTED);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_CERT_REJECTED
|
||||
ERROR(X509_V_ERR_CERT_REJECTED);
|
||||
ERROR(X509_V_ERR_CERT_REJECTED);
|
||||
#endif
|
||||
/* These are 'informational' when looking for issuer cert */
|
||||
/* These are 'informational' when looking for issuer cert */
|
||||
#ifdef X509_V_ERR_SUBJECT_ISSUER_MISMATCH
|
||||
ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH);
|
||||
ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_AKID_SKID_MISMATCH
|
||||
ERROR(X509_V_ERR_AKID_SKID_MISMATCH);
|
||||
ERROR(X509_V_ERR_AKID_SKID_MISMATCH);
|
||||
#endif
|
||||
#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
|
||||
#ifdef X509_V_ERR_KEYUSAGE_NO_CERTSIGN
|
||||
ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN);
|
||||
ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN);
|
||||
#endif
|
||||
|
||||
#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
|
||||
#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
|
||||
ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION);
|
||||
ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION);
|
||||
#endif
|
||||
#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
|
||||
#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
|
||||
#ifdef X509_V_ERR_INVALID_NON_CA
|
||||
ERROR(X509_V_ERR_INVALID_NON_CA);
|
||||
ERROR(X509_V_ERR_INVALID_NON_CA);
|
||||
#endif
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
|
||||
#ifdef X509_V_ERR_INVALID_EXTENSION
|
||||
ERROR(X509_V_ERR_INVALID_EXTENSION);
|
||||
ERROR(X509_V_ERR_INVALID_EXTENSION);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_INVALID_POLICY_EXTENSION
|
||||
ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION);
|
||||
ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_NO_EXPLICIT_POLICY
|
||||
ERROR(X509_V_ERR_NO_EXPLICIT_POLICY);
|
||||
ERROR(X509_V_ERR_NO_EXPLICIT_POLICY);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_DIFFERENT_CRL_SCOPE
|
||||
ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE);
|
||||
ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE);
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE);
|
||||
#endif
|
||||
|
||||
#ifdef X509_V_ERR_UNNESTED_RESOURCE
|
||||
ERROR(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
ERROR(X509_V_ERR_UNNESTED_RESOURCE);
|
||||
#endif
|
||||
|
||||
#ifdef X509_V_ERR_PERMITTED_VIOLATION
|
||||
ERROR(X509_V_ERR_PERMITTED_VIOLATION);
|
||||
ERROR(X509_V_ERR_PERMITTED_VIOLATION);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_EXCLUDED_VIOLATION
|
||||
ERROR(X509_V_ERR_EXCLUDED_VIOLATION);
|
||||
ERROR(X509_V_ERR_EXCLUDED_VIOLATION);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_SUBTREE_MINMAX
|
||||
ERROR(X509_V_ERR_SUBTREE_MINMAX);
|
||||
ERROR(X509_V_ERR_SUBTREE_MINMAX);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE);
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
|
||||
#endif
|
||||
#ifdef X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX);
|
||||
ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX);
|
||||
#endif
|
||||
#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
|
||||
|
||||
/* The application is not happy */
|
||||
/* The application is not happy */
|
||||
#ifdef X509_V_ERR_APPLICATION_VERIFICATION
|
||||
ERROR(X509_V_ERR_APPLICATION_VERIFICATION);
|
||||
ERROR(X509_V_ERR_APPLICATION_VERIFICATION);
|
||||
#endif
|
||||
}
|
||||
#undef ERROR
|
||||
|
@ -339,7 +340,6 @@ _openssl_print_errors(void *conn, int type)
|
|||
ecore_con_event_client_error(conn, buf);
|
||||
else
|
||||
ecore_con_event_server_error(conn, buf);
|
||||
|
||||
} while (1);
|
||||
}
|
||||
|
||||
|
@ -368,11 +368,11 @@ _openssl_name_verify(const char *name, const char *svrname)
|
|||
}
|
||||
}
|
||||
else
|
||||
if (strcasecmp(name, svrname))
|
||||
{
|
||||
ERR("%s != %s", name, svrname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
if (strcasecmp(name, svrname))
|
||||
{
|
||||
ERR("%s != %s", name, svrname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ _openssl_print_session(SSL *ssl)
|
|||
{
|
||||
/* print session info into DBG */
|
||||
SSL_SESSION *s;
|
||||
STACK_OF(X509) *sk;
|
||||
STACK_OF(X509) * sk;
|
||||
BIO *b;
|
||||
char log[4096], *p;
|
||||
int x;
|
||||
|
@ -430,23 +430,23 @@ static Ecore_Con_Ssl_Error
|
|||
static Ecore_Con_Ssl_Error
|
||||
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_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_privkey_add) (Ecore_Con_Server * svr, const char *key_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_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 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_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_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_write) (Ecore_Con_Server *svr, const 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 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 int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client * cl,
|
||||
unsigned char *buf, int size);
|
||||
static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client * cl,
|
||||
const unsigned char *buf, int size);
|
||||
static int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client *cl,
|
||||
unsigned char *buf, int size);
|
||||
static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client *cl,
|
||||
const unsigned char *buf, int size);
|
||||
|
||||
/*
|
||||
* General SSL API
|
||||
|
@ -478,7 +478,7 @@ ecore_con_ssl_shutdown(void)
|
|||
|
||||
Ecore_Con_Ssl_Error
|
||||
ecore_con_ssl_server_prepare(Ecore_Con_Server *svr,
|
||||
int ssl_type)
|
||||
int ssl_type)
|
||||
{
|
||||
if (!ssl_type)
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
|
@ -503,8 +503,8 @@ ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr)
|
|||
|
||||
int
|
||||
ecore_con_ssl_server_read(Ecore_Con_Server *svr,
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
unsigned char *buf,
|
||||
int 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
|
||||
ecore_con_ssl_server_write(Ecore_Con_Server *svr,
|
||||
const unsigned char *buf,
|
||||
int size)
|
||||
int 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
|
||||
ecore_con_ssl_client_read(Ecore_Con_Client *cl,
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
unsigned char *buf,
|
||||
int 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
|
||||
ecore_con_ssl_client_write(Ecore_Con_Client *cl,
|
||||
const unsigned char *buf,
|
||||
int size)
|
||||
int 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__);
|
||||
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
|
||||
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))
|
||||
{
|
||||
|
@ -699,7 +699,7 @@ ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr,
|
|||
|
||||
EAPI Eina_Bool
|
||||
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))
|
||||
{
|
||||
|
@ -731,7 +731,7 @@ ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr,
|
|||
|
||||
EAPI Eina_Bool
|
||||
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))
|
||||
{
|
||||
|
@ -763,7 +763,7 @@ ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr,
|
|||
|
||||
EAPI Eina_Bool
|
||||
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))
|
||||
{
|
||||
|
@ -898,7 +898,7 @@ _ecore_con_ssl_shutdown_gnutls(void)
|
|||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
|
||||
int ssl_type)
|
||||
int ssl_type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -923,7 +923,7 @@ _ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
|
|||
|
||||
if (svr->use_cert)
|
||||
{
|
||||
if (svr->created)
|
||||
if (svr->created)
|
||||
{
|
||||
SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_init(&svr->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);
|
||||
INF("DH params successfully generated and applied!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c));
|
||||
else
|
||||
{
|
||||
//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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
svr->ssl_prepared = EINA_TRUE;
|
||||
|
@ -954,7 +954,6 @@ error:
|
|||
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
||||
}
|
||||
|
||||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_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_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);
|
||||
DBG("SSL certificate verification succeeded!");
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
|
@ -1092,7 +1091,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_ecore_con_ssl_server_cafile_add_gnutls(Ecore_Con_Server *svr,
|
||||
const char *ca_file)
|
||||
const char *ca_file)
|
||||
{
|
||||
struct stat st;
|
||||
Eina_Iterator *it;
|
||||
|
@ -1127,7 +1126,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_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,
|
||||
GNUTLS_X509_FMT_PEM) < 1);
|
||||
|
@ -1140,7 +1139,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_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,
|
||||
GNUTLS_X509_FMT_PEM));
|
||||
|
@ -1153,7 +1152,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_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)))
|
||||
return EINA_FALSE;
|
||||
|
@ -1209,8 +1208,8 @@ _ecore_con_ssl_server_shutdown_gnutls(Ecore_Con_Server *svr)
|
|||
|
||||
static int
|
||||
_ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -1245,7 +1244,7 @@ _ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr,
|
|||
static int
|
||||
_ecore_con_ssl_server_write_gnutls(Ecore_Con_Server *svr,
|
||||
const unsigned char *buf,
|
||||
int size)
|
||||
int size)
|
||||
{
|
||||
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));
|
||||
gnutls_x509_crt_deinit(cert);
|
||||
*/
|
||||
*/
|
||||
DBG("SSL certificate verification succeeded!");
|
||||
return ECORE_CON_SSL_ERROR_NONE;
|
||||
|
||||
|
@ -1412,7 +1411,7 @@ error:
|
|||
/*
|
||||
if (cert)
|
||||
gnutls_x509_crt_deinit(cert);
|
||||
*/
|
||||
*/
|
||||
_ecore_con_ssl_client_shutdown_gnutls(cl);
|
||||
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
||||
}
|
||||
|
@ -1435,8 +1434,8 @@ _ecore_con_ssl_client_shutdown_gnutls(Ecore_Con_Client *cl)
|
|||
|
||||
static int
|
||||
_ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -1471,7 +1470,7 @@ _ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl,
|
|||
static int
|
||||
_ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *cl,
|
||||
const unsigned char *buf,
|
||||
int size)
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -1527,7 +1526,7 @@ _ecore_con_ssl_shutdown_openssl(void)
|
|||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *svr,
|
||||
int ssl_type)
|
||||
int ssl_type)
|
||||
{
|
||||
long options;
|
||||
int dh = 0;
|
||||
|
@ -1665,11 +1664,11 @@ _ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr)
|
|||
|
||||
if (svr->verify)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
|
||||
err = SSL_get_verify_result(svr->ssl);
|
||||
_openssl_print_verify_error(err);
|
||||
SSL_ERROR_CHECK_GOTO_ERROR(err);
|
||||
err = SSL_get_verify_result(svr->ssl);
|
||||
_openssl_print_verify_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);
|
||||
if (clen > 0)
|
||||
|
@ -1681,7 +1680,7 @@ _ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr)
|
|||
c = alloca(++clen);
|
||||
X509_NAME_get_text_by_NID(X509_get_subject_name(cert), name, c, clen);
|
||||
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
|
||||
_ecore_con_ssl_server_cafile_add_openssl(Ecore_Con_Server *svr,
|
||||
const char *ca_file)
|
||||
const char *ca_file)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
|
@ -1715,7 +1714,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_ecore_con_ssl_server_crl_add_openssl(Ecore_Con_Server *svr,
|
||||
const char *crl_file)
|
||||
const char *crl_file)
|
||||
{
|
||||
X509_STORE *st;
|
||||
X509_LOOKUP *lu;
|
||||
|
@ -1739,7 +1738,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *svr,
|
||||
const char *key_file)
|
||||
const char *key_file)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
EVP_PKEY *privkey = NULL;
|
||||
|
@ -1765,7 +1764,7 @@ error:
|
|||
|
||||
static Eina_Bool
|
||||
_ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *svr,
|
||||
const char *cert_file)
|
||||
const char *cert_file)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
X509 *cert = NULL;
|
||||
|
@ -1811,8 +1810,8 @@ _ecore_con_ssl_server_shutdown_openssl(Ecore_Con_Server *svr)
|
|||
|
||||
static int
|
||||
_ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr,
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -1842,7 +1841,7 @@ _ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr,
|
|||
static int
|
||||
_ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr,
|
||||
const unsigned char *buf,
|
||||
int size)
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -1885,7 +1884,7 @@ _ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl)
|
|||
cl->ssl_state = 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");
|
||||
goto error;
|
||||
|
@ -1953,8 +1952,8 @@ _ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl)
|
|||
|
||||
static int
|
||||
_ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
unsigned char *buf,
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -1984,7 +1983,7 @@ _ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
|||
static int
|
||||
_ecore_con_ssl_client_write_openssl(Ecore_Con_Client *cl,
|
||||
const unsigned char *buf,
|
||||
int size)
|
||||
int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
|
@ -2030,7 +2029,7 @@ _ecore_con_ssl_shutdown_none(void)
|
|||
|
||||
static Ecore_Con_Ssl_Error
|
||||
_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;
|
||||
}
|
||||
|
@ -2043,7 +2042,7 @@ _ecore_con_ssl_server_init_none(Ecore_Con_Server *svr EINA_UNUSED)
|
|||
|
||||
static Eina_Bool
|
||||
_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;
|
||||
}
|
||||
|
@ -2057,14 +2056,14 @@ _ecore_con_ssl_server_cert_add_none(Ecore_Con_Server *svr EINA_UNUSED,
|
|||
|
||||
static Eina_Bool
|
||||
_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;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_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;
|
||||
}
|
||||
|
@ -2077,8 +2076,8 @@ _ecore_con_ssl_server_shutdown_none(Ecore_Con_Server *svr EINA_UNUSED)
|
|||
|
||||
static int
|
||||
_ecore_con_ssl_server_read_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||
unsigned char *buf EINA_UNUSED,
|
||||
int size EINA_UNUSED)
|
||||
unsigned char *buf EINA_UNUSED,
|
||||
int size EINA_UNUSED)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -2086,7 +2085,7 @@ _ecore_con_ssl_server_read_none(Ecore_Con_Server *svr EINA_UNUSED,
|
|||
static int
|
||||
_ecore_con_ssl_server_write_none(Ecore_Con_Server *svr EINA_UNUSED,
|
||||
const unsigned char *buf EINA_UNUSED,
|
||||
int size EINA_UNUSED)
|
||||
int size EINA_UNUSED)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -2105,8 +2104,8 @@ _ecore_con_ssl_client_shutdown_none(Ecore_Con_Client *cl EINA_UNUSED)
|
|||
|
||||
static int
|
||||
_ecore_con_ssl_client_read_none(Ecore_Con_Client *cl EINA_UNUSED,
|
||||
unsigned char *buf EINA_UNUSED,
|
||||
int size EINA_UNUSED)
|
||||
unsigned char *buf EINA_UNUSED,
|
||||
int size EINA_UNUSED)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -2114,7 +2113,7 @@ _ecore_con_ssl_client_read_none(Ecore_Con_Client *cl EINA_UNUSED,
|
|||
static int
|
||||
_ecore_con_ssl_client_write_none(Ecore_Con_Client *cl EINA_UNUSED,
|
||||
const unsigned char *buf EINA_UNUSED,
|
||||
int size EINA_UNUSED)
|
||||
int size EINA_UNUSED)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@
|
|||
// 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
|
||||
// defined here. see culr headers to get them from
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CURLM_CALL_MULTI_PERFORM = -1,
|
||||
CURLM_OK = 0
|
||||
} CURLMcode;
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CURLE_OK = 0,
|
||||
CURLE_OPERATION_TIMEDOUT = 28
|
||||
} CURLcode;
|
||||
|
@ -45,10 +47,11 @@ typedef enum {
|
|||
#define CURLOPTTYPE_OBJECTPOINT 10000
|
||||
#define CURLOPTTYPE_FUNCTIONPOINT 20000
|
||||
#define CURLOPTTYPE_OFF_T 30000
|
||||
#define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
|
||||
typedef enum {
|
||||
#define CINIT(na, t, nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
|
||||
typedef enum
|
||||
{
|
||||
CINIT(FILE, OBJECTPOINT, 1),
|
||||
CINIT(URL, OBJECTPOINT, 2),
|
||||
CINIT(URL, OBJECTPOINT, 2),
|
||||
CINIT(PROXY, OBJECTPOINT, 4),
|
||||
CINIT(USERPWD, OBJECTPOINT, 5),
|
||||
CINIT(INFILE, OBJECTPOINT, 9),
|
||||
|
@ -91,30 +94,37 @@ typedef enum {
|
|||
#define CURLINFO_SLIST 0x400000
|
||||
#define CURLINFO_MASK 0x0fffff
|
||||
#define CURLINFO_TYPEMASK 0xf00000
|
||||
typedef enum {
|
||||
CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
|
||||
typedef enum
|
||||
{
|
||||
CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
|
||||
} CURLINFO;
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CURLVERSION_FOURTH = 3
|
||||
} CURLversion;
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CURLMSG_DONE = 1
|
||||
} CURLMSG;
|
||||
#undef CINIT
|
||||
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||
typedef enum {
|
||||
#define CINIT(name, type, num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||
typedef enum
|
||||
{
|
||||
CINIT(PIPELINING, LONG, 3)
|
||||
} CURLMoption;
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CURL_TIMECOND_NONE = 0,
|
||||
CURL_TIMECOND_IFMODSINCE = 1,
|
||||
CURL_TIMECOND_IFUNMODSINCE = 2
|
||||
} curl_TimeCond;
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
CURL_HTTP_VERSION_1_0 = 1,
|
||||
CURL_HTTP_VERSION_1_1 = 2,
|
||||
};
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CURLPROXY_HTTP = 0,
|
||||
CURLPROXY_SOCKS4 = 4,
|
||||
CURLPROXY_SOCKS5 = 5,
|
||||
|
@ -122,90 +132,93 @@ typedef enum {
|
|||
CURLPROXY_SOCKS5_HOSTNAME = 7
|
||||
} curl_proxytype;
|
||||
|
||||
#define CURL_GLOBAL_SSL (1<<0)
|
||||
#define CURL_GLOBAL_WIN32 (1<<1)
|
||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
|
||||
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
|
||||
#define CURLOPT_WRITEDATA CURLOPT_FILE
|
||||
#define CURLOPT_READDATA CURLOPT_INFILE
|
||||
#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
|
||||
#define CURLVERSION_NOW CURLVERSION_FOURTH
|
||||
#define CURLAUTH_BASIC (((unsigned long)1)<<0)
|
||||
#define CURLAUTH_DIGEST_IE (((unsigned long)1)<<4)
|
||||
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
|
||||
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE))
|
||||
#define CURL_GLOBAL_SSL (1 << 0)
|
||||
#define CURL_GLOBAL_WIN32 (1 << 1)
|
||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32)
|
||||
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
|
||||
#define CURLOPT_WRITEDATA CURLOPT_FILE
|
||||
#define CURLOPT_READDATA CURLOPT_INFILE
|
||||
#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
|
||||
#define CURLVERSION_NOW CURLVERSION_FOURTH
|
||||
#define CURLAUTH_BASIC (((unsigned long)1) << 0)
|
||||
#define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4)
|
||||
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
|
||||
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE))
|
||||
#define CURL_READFUNC_ABORT 0x10000000
|
||||
|
||||
typedef void CURLM;
|
||||
typedef void CURL;
|
||||
struct curl_slist {
|
||||
char *data;
|
||||
struct curl_slist
|
||||
{
|
||||
char *data;
|
||||
struct curl_slist *next;
|
||||
};
|
||||
typedef struct {
|
||||
CURLversion age;
|
||||
const char *version;
|
||||
unsigned int version_num;
|
||||
const char *host;
|
||||
int features;
|
||||
const char *ssl_version;
|
||||
long ssl_version_num;
|
||||
const char *libz_version;
|
||||
const char * const *protocols;
|
||||
const char *ares;
|
||||
int ares_num;
|
||||
const char *libidn;
|
||||
int iconv_ver_num;
|
||||
const char *libssh_version;
|
||||
typedef struct
|
||||
{
|
||||
CURLversion age;
|
||||
const char *version;
|
||||
unsigned int version_num;
|
||||
const char *host;
|
||||
int features;
|
||||
const char *ssl_version;
|
||||
long ssl_version_num;
|
||||
const char *libz_version;
|
||||
const char *const *protocols;
|
||||
const char *ares;
|
||||
int ares_num;
|
||||
const char *libidn;
|
||||
int iconv_ver_num;
|
||||
const char *libssh_version;
|
||||
} curl_version_info_data;
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
CURLMSG msg;
|
||||
CURL *easy_handle;
|
||||
union {
|
||||
void *whatever;
|
||||
CURL *easy_handle;
|
||||
union
|
||||
{
|
||||
void *whatever;
|
||||
CURLcode result;
|
||||
} data;
|
||||
} CURLMsg;
|
||||
|
||||
|
||||
typedef struct _Ecore_Con_Curl Ecore_Con_Curl;
|
||||
|
||||
struct _Ecore_Con_Curl
|
||||
{
|
||||
Eina_Module *mod;
|
||||
|
||||
CURLM *_curlm;
|
||||
|
||||
CURLcode (*curl_global_init) (long flags);
|
||||
void (*curl_global_cleanup)(void);
|
||||
CURLM *(*curl_multi_init)(void);
|
||||
CURLMcode (*curl_multi_timeout)(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
CURLMcode (*curl_multi_cleanup)(CURLM *multi_handle);
|
||||
CURLMcode (*curl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
const char *(*curl_multi_strerror)(CURLMcode);
|
||||
CURLMsg *(*curl_multi_info_read)(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
CURLMcode (*curl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
CURLMcode (*curl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
CURLMcode (*curl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
CURLMcode (*curl_multi_setopt)(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
CURL *(*curl_easy_init)(void);
|
||||
CURLcode (*curl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
const char *(*curl_easy_strerror)(CURLcode);
|
||||
void (*curl_easy_cleanup)(CURL *curl);
|
||||
CURLcode (*curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
void (*curl_slist_free_all)(struct curl_slist *);
|
||||
struct curl_slist *(*curl_slist_append)(struct curl_slist *list,
|
||||
const char *string);
|
||||
Eina_Module *mod;
|
||||
|
||||
CURLM *_curlm;
|
||||
|
||||
CURLcode (*curl_global_init)(long flags);
|
||||
void (*curl_global_cleanup)(void);
|
||||
CURLM *(*curl_multi_init)(void);
|
||||
CURLMcode (*curl_multi_timeout)(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
CURLMcode (*curl_multi_cleanup)(CURLM *multi_handle);
|
||||
CURLMcode (*curl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
const char *(*curl_multi_strerror)(CURLMcode);
|
||||
CURLMsg *(*curl_multi_info_read)(CURLM * multi_handle,
|
||||
int *msgs_in_queue);
|
||||
CURLMcode (*curl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
CURLMcode (*curl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
CURLMcode (*curl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
CURLMcode (*curl_multi_setopt)(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
CURL *(*curl_easy_init)(void);
|
||||
CURLcode (*curl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
const char *(*curl_easy_strerror)(CURLcode);
|
||||
void (*curl_easy_cleanup)(CURL *curl);
|
||||
CURLcode (*curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
void (*curl_slist_free_all)(struct curl_slist *);
|
||||
struct curl_slist *(*curl_slist_append)(struct curl_slist *list,
|
||||
const char *string);
|
||||
curl_version_info_data *(*curl_version_info)(CURLversion);
|
||||
};
|
||||
|
||||
|
@ -242,33 +255,34 @@ static Eina_Bool
|
|||
_c_init(void)
|
||||
{
|
||||
long ms = 0;
|
||||
|
||||
|
||||
if (_c) return EINA_TRUE;
|
||||
if (_c_fail) return EINA_FALSE;
|
||||
_c = calloc(1, sizeof(Ecore_Con_Curl));
|
||||
if (!_c) goto error;
|
||||
|
||||
#define LOAD(x) \
|
||||
if (!_c->mod) { \
|
||||
if ((_c->mod = eina_module_new(x))) { \
|
||||
if (!eina_module_load(_c->mod)) { \
|
||||
eina_module_free(_c->mod); \
|
||||
_c->mod = NULL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define LOAD(x) \
|
||||
if (!_c->mod) { \
|
||||
if ((_c->mod = eina_module_new(x))) { \
|
||||
if (!eina_module_load(_c->mod)) { \
|
||||
eina_module_free(_c->mod); \
|
||||
_c->mod = NULL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
LOAD("libcurl.dll"); // try 1
|
||||
LOAD("curllib.dll"); // if fail try 2
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
LOAD("libcurl.4.dylib"); // try 1
|
||||
LOAD("libcurl.so.4"); // if fail try 2
|
||||
#else
|
||||
#else
|
||||
LOAD("libcurl.so.4"); // try only
|
||||
#endif
|
||||
#endif
|
||||
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_cleanup);
|
||||
SYM(curl_multi_init);
|
||||
|
@ -289,7 +303,7 @@ _c_init(void)
|
|||
SYM(curl_slist_free_all);
|
||||
SYM(curl_slist_append);
|
||||
SYM(curl_version_info);
|
||||
|
||||
|
||||
// curl_global_init() is not thread safe!
|
||||
if (_c->curl_global_init(CURL_GLOBAL_ALL)) goto error;
|
||||
_c->_curlm = _c->curl_multi_init();
|
||||
|
@ -396,7 +410,7 @@ ecore_con_url_new(const char *url)
|
|||
|
||||
if (!_init_count) return NULL;
|
||||
if (!_c_init()) return NULL;
|
||||
|
||||
|
||||
url_con = calloc(1, sizeof(Ecore_Con_Url));
|
||||
if (!url_con) return NULL;
|
||||
|
||||
|
@ -429,24 +443,26 @@ ecore_con_url_new(const char *url)
|
|||
if (_ecore_con_proxy_global->version == 5)
|
||||
{
|
||||
if (_ecore_con_proxy_global->lookup)
|
||||
snprintf(host, sizeof(host), "socks5h://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
else snprintf(host, sizeof(host), "socks5://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
snprintf(host, sizeof(host), "socks5h://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
else
|
||||
snprintf(host, sizeof(host), "socks5://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
}
|
||||
else if (_ecore_con_proxy_global->version == 4)
|
||||
{
|
||||
if (_ecore_con_proxy_global->lookup)
|
||||
snprintf(host, sizeof(host), "socks4a://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
else snprintf(host, sizeof(host), "socks4://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
snprintf(host, sizeof(host), "socks4a://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
else
|
||||
snprintf(host, sizeof(host), "socks4://%s",
|
||||
_ecore_con_proxy_global->ip);
|
||||
}
|
||||
|
||||
if (_ecore_con_proxy_global->port > 0 &&
|
||||
_ecore_con_proxy_global->port <= 65535)
|
||||
snprintf(proxy, sizeof(proxy), "%s:%d", host,
|
||||
_ecore_con_proxy_global->port);
|
||||
snprintf(proxy, sizeof(proxy), "%s:%d", host,
|
||||
_ecore_con_proxy_global->port);
|
||||
else snprintf(proxy, sizeof(proxy), "%s", host);
|
||||
|
||||
ecore_con_url_proxy_set(url_con, proxy);
|
||||
|
@ -467,12 +483,12 @@ ecore_con_url_new(const char *url)
|
|||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_WRITEFUNCTION,
|
||||
_ecore_con_url_data_cb);
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_WRITEDATA, url_con);
|
||||
|
||||
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_PROGRESSFUNCTION,
|
||||
_ecore_con_url_progress_cb);
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_PROGRESSDATA, url_con);
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_NOPROGRESS, EINA_FALSE);
|
||||
|
||||
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HEADERFUNCTION,
|
||||
_ecore_con_url_header_cb);
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HEADERDATA, url_con);
|
||||
|
@ -549,8 +565,10 @@ ecore_con_url_free(Ecore_Con_Url *url_con)
|
|||
ECORE_MAGIC_SET(url_con, ECORE_MAGIC_NONE);
|
||||
|
||||
_c->curl_slist_free_all(url_con->headers);
|
||||
EINA_LIST_FREE(url_con->additional_headers, s) free(s);
|
||||
EINA_LIST_FREE(url_con->response_headers, s) free(s);
|
||||
EINA_LIST_FREE(url_con->additional_headers, s)
|
||||
free(s);
|
||||
EINA_LIST_FREE(url_con->response_headers, s)
|
||||
free(s);
|
||||
eina_stringshare_del(url_con->url);
|
||||
if (url_con->post_data) free(url_con->post_data);
|
||||
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__);
|
||||
return;
|
||||
}
|
||||
EINA_LIST_FREE(url_con->additional_headers, s) free(s);
|
||||
EINA_LIST_FREE(url_con->additional_headers, s)
|
||||
free(s);
|
||||
}
|
||||
|
||||
EAPI void *
|
||||
|
@ -720,11 +739,11 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, const c
|
|||
{
|
||||
if (safe)
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH,
|
||||
CURLAUTH_ANYSAFE);
|
||||
CURLAUTH_ANYSAFE);
|
||||
else
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH,
|
||||
CURLAUTH_ANY);
|
||||
|
||||
|
||||
ret = _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_USERNAME,
|
||||
username);
|
||||
if (ret != CURLE_OK)
|
||||
|
@ -733,7 +752,7 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, const c
|
|||
_c->curl_easy_strerror(ret));
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ret = _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_PASSWORD,
|
||||
password);
|
||||
if (ret != CURLE_OK)
|
||||
|
@ -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;
|
||||
|
||||
/* 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->status = 0;
|
||||
|
||||
|
@ -801,8 +821,9 @@ _ecore_con_url_send(Ecore_Con_Url *url_con, int mode, const void *data, long len
|
|||
else
|
||||
return EINA_FALSE;
|
||||
}
|
||||
else _c->curl_easy_setopt(url_con->curl_easy,
|
||||
CURLOPT_POSTFIELDSIZE, 0);
|
||||
else
|
||||
_c->curl_easy_setopt(url_con->curl_easy,
|
||||
CURLOPT_POSTFIELDSIZE, 0);
|
||||
if (mode == MODE_POST)
|
||||
_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:
|
||||
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
|
||||
CURL_TIMECOND_NONE);
|
||||
CURL_TIMECOND_NONE);
|
||||
break;
|
||||
|
||||
case ECORE_CON_URL_TIME_IFMODSINCE:
|
||||
_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,
|
||||
(long)url_con->timestamp);
|
||||
(long)url_con->timestamp);
|
||||
break;
|
||||
|
||||
case ECORE_CON_URL_TIME_IFUNMODSINCE:
|
||||
_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,
|
||||
(long)url_con->timestamp);
|
||||
(long)url_con->timestamp);
|
||||
break;
|
||||
}
|
||||
/* Additional headers */
|
||||
|
@ -1112,7 +1135,7 @@ EAPI Eina_Bool
|
|||
ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Version version)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
|
||||
if (!_c) return EINA_FALSE;
|
||||
if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
|
||||
{
|
||||
|
@ -1127,11 +1150,13 @@ ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Versio
|
|||
CURLOPT_HTTP_VERSION,
|
||||
CURL_HTTP_VERSION_1_0);
|
||||
break;
|
||||
|
||||
case ECORE_CON_URL_HTTP_VERSION_1_1:
|
||||
res = _c->curl_easy_setopt(url_con->curl_easy,
|
||||
CURLOPT_HTTP_VERSION,
|
||||
CURL_HTTP_VERSION_1_1);
|
||||
break;
|
||||
|
||||
default:
|
||||
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->dead) return EINA_FALSE;
|
||||
if (!proxy) res = _c->curl_easy_setopt(url_con->curl_easy,
|
||||
CURLOPT_PROXY, "");
|
||||
if (!proxy)
|
||||
res = _c->curl_easy_setopt(url_con->curl_easy,
|
||||
CURLOPT_PROXY, "");
|
||||
else
|
||||
{
|
||||
// before curl version 7.21.7, socks protocol:// prefix is not supported
|
||||
|
@ -1215,7 +1241,7 @@ EAPI Eina_Bool
|
|||
ecore_con_url_proxy_username_set(Ecore_Con_Url *url_con, const char *username)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
|
||||
if (!_c) return EINA_FALSE;
|
||||
if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
|
||||
{
|
||||
|
@ -1245,7 +1271,7 @@ EAPI Eina_Bool
|
|||
ecore_con_url_proxy_password_set(Ecore_Con_Url *url_con, const char *password)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
|
||||
if (!_c) return EINA_FALSE;
|
||||
if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
|
||||
{
|
||||
|
@ -1277,7 +1303,7 @@ static void
|
|||
_ecore_con_url_status_get(Ecore_Con_Url *url_con)
|
||||
{
|
||||
long status = 0;
|
||||
|
||||
|
||||
if (!_c) return;
|
||||
if (!url_con->curl_easy) return;
|
||||
if (!_c->curl_easy_getinfo(url_con->curl_easy, CURLINFO_RESPONSE_CODE,
|
||||
|
@ -1317,7 +1343,7 @@ _ecore_con_url_event_url_complete(Ecore_Con_Url *url_con, CURLMsg *curlmsg)
|
|||
else
|
||||
{
|
||||
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->url_con = url_con;
|
||||
|
@ -1451,7 +1477,7 @@ _ecore_con_url_progress_cb(void *clientp, double dltotal, double dlnow, double u
|
|||
e->up.total = ultotal;
|
||||
e->up.now = ulnow;
|
||||
url_con->event_count++;
|
||||
ecore_event_add(ECORE_CON_EVENT_URL_PROGRESS, e,
|
||||
ecore_event_add(ECORE_CON_EVENT_URL_PROGRESS, e,
|
||||
(Ecore_End_Cb)_ecore_con_event_url_free, url_con);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1491,7 +1517,7 @@ _ecore_con_url_info_read(void)
|
|||
{
|
||||
Eina_List *l, *ll;
|
||||
Ecore_Con_Url *url_con = NULL;
|
||||
|
||||
|
||||
DBG("Curl message: %d", curlmsg->msg);
|
||||
if (curlmsg->msg == CURLMSG_DONE)
|
||||
{
|
||||
|
@ -1500,7 +1526,7 @@ _ecore_con_url_info_read(void)
|
|||
if (curlmsg->easy_handle == url_con->curl_easy)
|
||||
_ecore_con_url_event_url_complete(url_con, curlmsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1510,8 +1536,10 @@ _ecore_con_url_curl_clear(void)
|
|||
Ecore_Fd_Handler *fdh;
|
||||
Ecore_Con_Url *url_con;
|
||||
|
||||
EINA_LIST_FREE(_fd_hd_list, fdh) ecore_main_fd_handler_del(fdh);
|
||||
EINA_LIST_FREE(_url_con_list, url_con) _ecore_con_url_multi_remove(url_con);
|
||||
EINA_LIST_FREE(_fd_hd_list, fdh)
|
||||
ecore_main_fd_handler_del(fdh);
|
||||
EINA_LIST_FREE(_url_con_list, url_con)
|
||||
_ecore_con_url_multi_remove(url_con);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -1521,7 +1549,8 @@ _ecore_con_url_fd_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd_handler E
|
|||
long ms;
|
||||
|
||||
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);
|
||||
if ((ms >= CURL_MIN_TIMEOUT) || (ms <= 0)) ms = CURL_MIN_TIMEOUT;
|
||||
ecore_timer_interval_set(_curl_timer, (double)ms / 1000.0);
|
||||
|
@ -1537,7 +1566,7 @@ _ecore_con_url_fdset(void)
|
|||
int fd, fd_max;
|
||||
|
||||
if (!_c) return;
|
||||
|
||||
|
||||
FD_ZERO(&read_set);
|
||||
FD_ZERO(&write_set);
|
||||
FD_ZERO(&exc_set);
|
||||
|
@ -1566,7 +1595,7 @@ _ecore_con_url_fdset(void)
|
|||
_ecore_con_url_fd_handler,
|
||||
NULL, NULL, NULL);
|
||||
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;
|
||||
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();
|
||||
if (!_c) return ECORE_CALLBACK_RENEW;
|
||||
ret = _c->curl_multi_perform(_c->_curlm, &still_running);
|
||||
|
@ -1601,7 +1631,7 @@ _ecore_con_url_timer(void *data EINA_UNUSED)
|
|||
if (still_running)
|
||||
{
|
||||
long ms;
|
||||
|
||||
|
||||
_ecore_con_url_fdset();
|
||||
_c->curl_multi_timeout(_c->_curlm, &ms);
|
||||
DBG("multiperform is still running: %d, timeout: %ld",
|
||||
|
@ -1650,3 +1680,4 @@ _ecore_con_event_url_free(Ecore_Con_Url *url_con, void *ev)
|
|||
url_con->event_count--;
|
||||
if (url_con->dead && (!url_con->event_count)) ecore_con_url_free(url_con);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue