summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordiscomfitor <michael.blumenkrantz@gmail.com>2013-12-20 00:07:50 -0500
committerdiscomfitor <michael.blumenkrantz@gmail.com>2013-12-20 00:08:43 -0500
commit41fe698fc2ac2b02b5fefcd5e638a5486f36c353 (patch)
tree4c08633f376d57037c41f25687fc9f5925cb767a /src/lib
parent2bcfc800c991b33aea116d16ad962a6eae6ac697 (diff)
reformat ecore_con so I can read it...
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_con/ecore_con.c559
-rw-r--r--src/lib/ecore_con/ecore_con_alloc.c54
-rw-r--r--src/lib/ecore_con/ecore_con_ares.c155
-rw-r--r--src/lib/ecore_con/ecore_con_dns.c13
-rw-r--r--src/lib/ecore_con/ecore_con_eet.c93
-rw-r--r--src/lib/ecore_con/ecore_con_info.c33
-rw-r--r--src/lib/ecore_con/ecore_con_local.c50
-rw-r--r--src/lib/ecore_con/ecore_con_local_win32.c201
-rw-r--r--src/lib/ecore_con/ecore_con_socks.c492
-rw-r--r--src/lib/ecore_con/ecore_con_ssl.c277
-rw-r--r--src/lib/ecore_con/ecore_con_url.c311
11 files changed, 1152 insertions, 1086 deletions
diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index d28a84582a..33f6f775e3 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -47,65 +47,65 @@
47#include "Ecore_Con.h" 47#include "Ecore_Con.h"
48#include "ecore_con_private.h" 48#include "ecore_con_private.h"
49 49
50static Eina_Bool _ecore_con_client_timer(Ecore_Con_Client *cl); 50static Eina_Bool _ecore_con_client_timer(Ecore_Con_Client *cl);
51static void _ecore_con_cl_timer_update(Ecore_Con_Client *cl); 51static void _ecore_con_cl_timer_update(Ecore_Con_Client *cl);
52static Eina_Bool _ecore_con_server_timer(Ecore_Con_Server *svr); 52static Eina_Bool _ecore_con_server_timer(Ecore_Con_Server *svr);
53static void _ecore_con_server_timer_update(Ecore_Con_Server *svr); 53static void _ecore_con_server_timer_update(Ecore_Con_Server *svr);
54 54
55static void _ecore_con_cb_tcp_connect(void *data, 55static void _ecore_con_cb_tcp_connect(void *data,
56 Ecore_Con_Info *info); 56 Ecore_Con_Info *info);
57static void _ecore_con_cb_udp_connect(void *data, 57static void _ecore_con_cb_udp_connect(void *data,
58 Ecore_Con_Info *info); 58 Ecore_Con_Info *info);
59static void _ecore_con_cb_tcp_listen(void *data, 59static void _ecore_con_cb_tcp_listen(void *data,
60 Ecore_Con_Info *info); 60 Ecore_Con_Info *info);
61static void _ecore_con_cb_udp_listen(void *data, 61static void _ecore_con_cb_udp_listen(void *data,
62 Ecore_Con_Info *info); 62 Ecore_Con_Info *info);
63 63
64static void _ecore_con_server_free(Ecore_Con_Server *svr); 64static void _ecore_con_server_free(Ecore_Con_Server *svr);
65static void _ecore_con_client_free(Ecore_Con_Client *cl); 65static void _ecore_con_client_free(Ecore_Con_Client *cl);
66 66
67static void _ecore_con_cl_read(Ecore_Con_Server *svr); 67static void _ecore_con_cl_read(Ecore_Con_Server *svr);
68static Eina_Bool _ecore_con_svr_tcp_handler(void *data, 68static Eina_Bool _ecore_con_svr_tcp_handler(void *data,
69 Ecore_Fd_Handler *fd_handler); 69 Ecore_Fd_Handler *fd_handler);
70static Eina_Bool _ecore_con_cl_handler(void *data, 70static Eina_Bool _ecore_con_cl_handler(void *data,
71 Ecore_Fd_Handler *fd_handler); 71 Ecore_Fd_Handler *fd_handler);
72static Eina_Bool _ecore_con_cl_udp_handler(void *data, 72static Eina_Bool _ecore_con_cl_udp_handler(void *data,
73 Ecore_Fd_Handler *fd_handler); 73 Ecore_Fd_Handler *fd_handler);
74static Eina_Bool _ecore_con_svr_udp_handler(void *data, 74static Eina_Bool _ecore_con_svr_udp_handler(void *data,
75 Ecore_Fd_Handler *fd_handler); 75 Ecore_Fd_Handler *fd_handler);
76 76
77static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl); 77static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl);
78static Eina_Bool _ecore_con_svr_cl_handler(void *data, 78static Eina_Bool _ecore_con_svr_cl_handler(void *data,
79 Ecore_Fd_Handler *fd_handler); 79 Ecore_Fd_Handler *fd_handler);
80 80
81static void _ecore_con_server_flush(Ecore_Con_Server *svr); 81static void _ecore_con_server_flush(Ecore_Con_Server *svr);
82static void _ecore_con_client_flush(Ecore_Con_Client *cl); 82static void _ecore_con_client_flush(Ecore_Con_Client *cl);
83 83
84static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr, 84static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
85 void *ev); 85 void *ev);
86static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr, 86static void _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
87 void *ev); 87 void *ev);
88static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr, 88static void _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
89 void *ev); 89 void *ev);
90static void _ecore_con_event_server_add_free(void *data, 90static void _ecore_con_event_server_add_free(void *data,
91 void *ev); 91 void *ev);
92static void _ecore_con_event_server_del_free(void *data, 92static void _ecore_con_event_server_del_free(void *data,
93 void *ev); 93 void *ev);
94static void _ecore_con_event_server_data_free(void *data, 94static void _ecore_con_event_server_data_free(void *data,
95 void *ev); 95 void *ev);
96static void _ecore_con_event_server_error_free(void *data, 96static void _ecore_con_event_server_error_free(void *data,
97 Ecore_Con_Event_Server_Error *e); 97 Ecore_Con_Event_Server_Error *e);
98static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr, 98static void _ecore_con_event_client_error_free(Ecore_Con_Server *svr,
99 Ecore_Con_Event_Client_Error *e); 99 Ecore_Con_Event_Client_Error *e);
100static void _ecore_con_event_server_write_free(void *data, 100static void _ecore_con_event_server_write_free(void *data,
101 Ecore_Con_Event_Server_Write *e); 101 Ecore_Con_Event_Server_Write *e);
102static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr, 102static void _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
103 Ecore_Con_Event_Client_Write *e); 103 Ecore_Con_Event_Client_Write *e);
104 104
105static void _ecore_con_lookup_done(void *data, 105static void _ecore_con_lookup_done(void *data,
106 Ecore_Con_Info *infos); 106 Ecore_Con_Info *infos);
107 107
108static const char * _ecore_con_pretty_ip(struct sockaddr *client_addr); 108static const char *_ecore_con_pretty_ip(struct sockaddr *client_addr);
109 109
110#ifdef HAVE_SYSTEMD 110#ifdef HAVE_SYSTEMD
111int sd_fd_index = 0; 111int sd_fd_index = 0;
@@ -144,14 +144,14 @@ _ecore_con_server_kill(Ecore_Con_Server *svr)
144} 144}
145 145
146#define _ecore_con_server_kill(svr) do { \ 146#define _ecore_con_server_kill(svr) do { \
147 DBG("KILL %p", (svr)); \ 147 DBG("KILL %p", (svr)); \
148 _ecore_con_server_kill((svr)); \ 148 _ecore_con_server_kill((svr)); \
149} while (0) 149 } while (0)
150 150
151#define _ecore_con_client_kill(cl) do { \ 151#define _ecore_con_client_kill(cl) do { \
152 DBG("KILL %p", (cl)); \ 152 DBG("KILL %p", (cl)); \
153 _ecore_con_client_kill((cl)); \ 153 _ecore_con_client_kill((cl)); \
154} while (0) 154 } while (0)
155 155
156EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0; 156EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0;
157EAPI int ECORE_CON_EVENT_CLIENT_DEL = 0; 157EAPI int ECORE_CON_EVENT_CLIENT_DEL = 0;
@@ -209,7 +209,6 @@ ecore_con_init(void)
209 ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new(); 209 ECORE_CON_EVENT_SERVER_ERROR = ecore_event_type_new();
210 ECORE_CON_EVENT_PROXY_BIND = ecore_event_type_new(); 210 ECORE_CON_EVENT_PROXY_BIND = ecore_event_type_new();
211 211
212
213 eina_magic_string_set(ECORE_MAGIC_CON_SERVER, "Ecore_Con_Server"); 212 eina_magic_string_set(ECORE_MAGIC_CON_SERVER, "Ecore_Con_Server");
214 eina_magic_string_set(ECORE_MAGIC_CON_CLIENT, "Ecore_Con_Client"); 213 eina_magic_string_set(ECORE_MAGIC_CON_CLIENT, "Ecore_Con_Client");
215 eina_magic_string_set(ECORE_MAGIC_CON_URL, "Ecore_Con_Url"); 214 eina_magic_string_set(ECORE_MAGIC_CON_URL, "Ecore_Con_Url");
@@ -224,8 +223,8 @@ ecore_con_init(void)
224#endif 223#endif
225 224
226 eina_log_timing(_ecore_con_log_dom, 225 eina_log_timing(_ecore_con_log_dom,
227 EINA_LOG_STATE_STOP, 226 EINA_LOG_STATE_STOP,
228 EINA_LOG_STATE_INIT); 227 EINA_LOG_STATE_INIT);
229 228
230 return _ecore_con_init_count; 229 return _ecore_con_init_count;
231} 230}
@@ -240,8 +239,8 @@ ecore_con_shutdown(void)
240 return _ecore_con_init_count; 239 return _ecore_con_init_count;
241 240
242 eina_log_timing(_ecore_con_log_dom, 241 eina_log_timing(_ecore_con_log_dom,
243 EINA_LOG_STATE_START, 242 EINA_LOG_STATE_START,
244 EINA_LOG_STATE_SHUTDOWN); 243 EINA_LOG_STATE_SHUTDOWN);
245 244
246 EINA_LIST_FOREACH_SAFE(servers, l, l2, svr) 245 EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
247 { 246 {
@@ -271,9 +270,9 @@ ecore_con_shutdown(void)
271} 270}
272 271
273EAPI Eina_Bool 272EAPI Eina_Bool
274ecore_con_lookup(const char *name, 273ecore_con_lookup(const char *name,
275 Ecore_Con_Dns_Cb done_cb, 274 Ecore_Con_Dns_Cb done_cb,
276 const void *data) 275 const void *data)
277{ 276{
278 Ecore_Con_Server *svr; 277 Ecore_Con_Server *svr;
279 Ecore_Con_Lookup *lk; 278 Ecore_Con_Lookup *lk;
@@ -344,9 +343,9 @@ on_error:
344 343
345EAPI Ecore_Con_Server * 344EAPI Ecore_Con_Server *
346ecore_con_server_add(Ecore_Con_Type compl_type, 345ecore_con_server_add(Ecore_Con_Type compl_type,
347 const char *name, 346 const char *name,
348 int port, 347 int port,
349 const void *data) 348 const void *data)
350{ 349{
351 Ecore_Con_Server *svr; 350 Ecore_Con_Server *svr;
352 Ecore_Con_Type type; 351 Ecore_Con_Type type;
@@ -382,7 +381,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
382 if ((type == ECORE_CON_LOCAL_USER) || 381 if ((type == ECORE_CON_LOCAL_USER) ||
383 (type == ECORE_CON_LOCAL_SYSTEM) || 382 (type == ECORE_CON_LOCAL_SYSTEM) ||
384 (type == ECORE_CON_LOCAL_ABSTRACT)) 383 (type == ECORE_CON_LOCAL_ABSTRACT))
385 /* Local */ 384 /* Local */
386#ifdef _WIN32 385#ifdef _WIN32
387 if (!ecore_con_local_listen(svr)) 386 if (!ecore_con_local_listen(svr))
388 goto error; 387 goto error;
@@ -396,9 +395,9 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
396 (type == ECORE_CON_REMOTE_CORK)) 395 (type == ECORE_CON_REMOTE_CORK))
397 { 396 {
398 /* TCP */ 397 /* TCP */
399 if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen, 398 if (!ecore_con_info_tcp_listen(svr, _ecore_con_cb_tcp_listen,
400 svr)) 399 svr))
401 goto error; 400 goto error;
402 } 401 }
403 else if ((type == ECORE_CON_REMOTE_MCAST) || 402 else if ((type == ECORE_CON_REMOTE_MCAST) ||
404 (type == ECORE_CON_REMOTE_UDP)) 403 (type == ECORE_CON_REMOTE_UDP))
@@ -419,7 +418,6 @@ error:
419 if (svr->path) 418 if (svr->path)
420 free(svr->path); 419 free(svr->path);
421 420
422
423 if (svr->fd_handler) 421 if (svr->fd_handler)
424 ecore_main_fd_handler_del(svr->fd_handler); 422 ecore_main_fd_handler_del(svr->fd_handler);
425 423
@@ -439,9 +437,9 @@ error:
439 437
440EAPI Ecore_Con_Server * 438EAPI Ecore_Con_Server *
441ecore_con_server_connect(Ecore_Con_Type compl_type, 439ecore_con_server_connect(Ecore_Con_Type compl_type,
442 const char *name, 440 const char *name,
443 int port, 441 int port,
444 const void *data) 442 const void *data)
445{ 443{
446 Ecore_Con_Server *svr; 444 Ecore_Con_Server *svr;
447 Ecore_Con_Type type; 445 Ecore_Con_Type type;
@@ -491,16 +489,16 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
491 EINA_SAFETY_ON_TRUE_GOTO(ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL), error); 489 EINA_SAFETY_ON_TRUE_GOTO(ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL), error);
492 490
493 EINA_SAFETY_ON_TRUE_GOTO(((type == ECORE_CON_REMOTE_TCP) || 491 EINA_SAFETY_ON_TRUE_GOTO(((type == ECORE_CON_REMOTE_TCP) ||
494 (type == ECORE_CON_REMOTE_NODELAY) || 492 (type == ECORE_CON_REMOTE_NODELAY) ||
495 (type == ECORE_CON_REMOTE_CORK) || 493 (type == ECORE_CON_REMOTE_CORK) ||
496 (type == ECORE_CON_REMOTE_UDP) || 494 (type == ECORE_CON_REMOTE_UDP) ||
497 (type == ECORE_CON_REMOTE_BROADCAST)) && 495 (type == ECORE_CON_REMOTE_BROADCAST)) &&
498 (port < 0), error); 496 (port < 0), error);
499 497
500 if ((type == ECORE_CON_LOCAL_USER) || 498 if ((type == ECORE_CON_LOCAL_USER) ||
501 (type == ECORE_CON_LOCAL_SYSTEM) || 499 (type == ECORE_CON_LOCAL_SYSTEM) ||
502 (type == ECORE_CON_LOCAL_ABSTRACT)) 500 (type == ECORE_CON_LOCAL_ABSTRACT))
503 /* Local */ 501 /* Local */
504#ifdef _WIN32 502#ifdef _WIN32
505 if (!ecore_con_local_connect(svr, _ecore_con_cl_handler)) goto error; 503 if (!ecore_con_local_connect(svr, _ecore_con_cl_handler)) goto error;
506#else 504#else
@@ -512,7 +510,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
512 (type == ECORE_CON_REMOTE_CORK)) 510 (type == ECORE_CON_REMOTE_CORK))
513 { 511 {
514 /* TCP */ 512 /* TCP */
515 EINA_SAFETY_ON_FALSE_GOTO(ecore_con_info_tcp_connect(svr, _ecore_con_cb_tcp_connect, svr), error); 513 EINA_SAFETY_ON_FALSE_GOTO(ecore_con_info_tcp_connect(svr, _ecore_con_cb_tcp_connect, svr), error);
516 } 514 }
517 else if ((type == ECORE_CON_REMOTE_UDP) || (type == ECORE_CON_REMOTE_BROADCAST)) 515 else if ((type == ECORE_CON_REMOTE_UDP) || (type == ECORE_CON_REMOTE_BROADCAST))
518 /* UDP and MCAST */ 516 /* UDP and MCAST */
@@ -543,7 +541,7 @@ error:
543 541
544EAPI void 542EAPI void
545ecore_con_server_timeout_set(Ecore_Con_Server *svr, 543ecore_con_server_timeout_set(Ecore_Con_Server *svr,
546 double timeout) 544 double timeout)
547{ 545{
548 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) 546 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
549 { 547 {
@@ -602,7 +600,7 @@ ecore_con_server_data_get(Ecore_Con_Server *svr)
602 600
603EAPI void * 601EAPI void *
604ecore_con_server_data_set(Ecore_Con_Server *svr, 602ecore_con_server_data_set(Ecore_Con_Server *svr,
605 void *data) 603 void *data)
606{ 604{
607 void *ret = NULL; 605 void *ret = NULL;
608 606
@@ -672,8 +670,8 @@ ecore_con_server_port_get(Ecore_Con_Server *svr)
672 670
673EAPI int 671EAPI int
674ecore_con_server_send(Ecore_Con_Server *svr, 672ecore_con_server_send(Ecore_Con_Server *svr,
675 const void *data, 673 const void *data,
676 int size) 674 int size)
677{ 675{
678 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) 676 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
679 { 677 {
@@ -711,8 +709,8 @@ ecore_con_server_send(Ecore_Con_Server *svr,
711 709
712EAPI void 710EAPI void
713ecore_con_server_client_limit_set(Ecore_Con_Server *svr, 711ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
714 int client_limit, 712 int client_limit,
715 char reject_excess_clients) 713 char reject_excess_clients)
716{ 714{
717 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) 715 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
718 { 716 {
@@ -780,8 +778,8 @@ ecore_con_server_flush(Ecore_Con_Server *svr)
780 778
781EAPI int 779EAPI int
782ecore_con_client_send(Ecore_Con_Client *cl, 780ecore_con_client_send(Ecore_Con_Client *cl,
783 const void *data, 781 const void *data,
784 int size) 782 int size)
785{ 783{
786 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) 784 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
787 { 785 {
@@ -848,7 +846,7 @@ ecore_con_client_connected_get(Ecore_Con_Client *cl)
848 846
849EAPI void 847EAPI void
850ecore_con_client_timeout_set(Ecore_Con_Client *cl, 848ecore_con_client_timeout_set(Ecore_Con_Client *cl,
851 double timeout) 849 double timeout)
852{ 850{
853 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) 851 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
854 { 852 {
@@ -890,7 +888,7 @@ ecore_con_client_del(Ecore_Con_Client *cl)
890 888
891EAPI void 889EAPI void
892ecore_con_client_data_set(Ecore_Con_Client *cl, 890ecore_con_client_data_set(Ecore_Con_Client *cl,
893 const void *data) 891 const void *data)
894{ 892{
895 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) 893 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
896 { 894 {
@@ -936,9 +934,9 @@ ecore_con_client_port_get(Ecore_Con_Client *cl)
936 return -1; 934 return -1;
937 } 935 }
938 if (cl->client_addr->sa_family == AF_INET) 936 if (cl->client_addr->sa_family == AF_INET)
939 return ((struct sockaddr_in*)cl->client_addr)->sin_port; 937 return ((struct sockaddr_in *)cl->client_addr)->sin_port;
940#ifdef HAVE_IPV6 938#ifdef HAVE_IPV6
941 return ((struct sockaddr_in6*)cl->client_addr)->sin6_port; 939 return ((struct sockaddr_in6 *)cl->client_addr)->sin6_port;
942#else 940#else
943 return -1; 941 return -1;
944#endif 942#endif
@@ -999,64 +997,64 @@ ecore_con_client_fd_get(Ecore_Con_Client *cl)
999void 997void
1000ecore_con_event_proxy_bind(Ecore_Con_Server *svr) 998ecore_con_event_proxy_bind(Ecore_Con_Server *svr)
1001{ 999{
1002 Ecore_Con_Event_Proxy_Bind *e; 1000 Ecore_Con_Event_Proxy_Bind *e;
1003 int ev = ECORE_CON_EVENT_PROXY_BIND; 1001 int ev = ECORE_CON_EVENT_PROXY_BIND;
1004 1002
1005 e = ecore_con_event_proxy_bind_alloc(); 1003 e = ecore_con_event_proxy_bind_alloc();
1006 EINA_SAFETY_ON_NULL_RETURN(e); 1004 EINA_SAFETY_ON_NULL_RETURN(e);
1007 1005
1008 svr->event_count = eina_list_append(svr->event_count, e); 1006 svr->event_count = eina_list_append(svr->event_count, e);
1009 _ecore_con_server_timer_update(svr); 1007 _ecore_con_server_timer_update(svr);
1010 e->server = svr; 1008 e->server = svr;
1011 e->ip = svr->proxyip; 1009 e->ip = svr->proxyip;
1012 e->port = svr->proxyport; 1010 e->port = svr->proxyport;
1013 ecore_event_add(ev, e, 1011 ecore_event_add(ev, e,
1014 _ecore_con_event_server_add_free, NULL); 1012 _ecore_con_event_server_add_free, NULL);
1015 _ecore_con_event_count++; 1013 _ecore_con_event_count++;
1016} 1014}
1017 1015
1018void 1016void
1019ecore_con_event_server_add(Ecore_Con_Server *svr) 1017ecore_con_event_server_add(Ecore_Con_Server *svr)
1020{ 1018{
1021 /* we got our server! */ 1019 /* we got our server! */
1022 Ecore_Con_Event_Server_Add *e; 1020 Ecore_Con_Event_Server_Add *e;
1023 int ev = ECORE_CON_EVENT_SERVER_ADD; 1021 int ev = ECORE_CON_EVENT_SERVER_ADD;
1024 1022
1025 e = ecore_con_event_server_add_alloc(); 1023 e = ecore_con_event_server_add_alloc();
1026 EINA_SAFETY_ON_NULL_RETURN(e); 1024 EINA_SAFETY_ON_NULL_RETURN(e);
1027 1025
1028 svr->connecting = EINA_FALSE; 1026 svr->connecting = EINA_FALSE;
1029 svr->start_time = ecore_time_get(); 1027 svr->start_time = ecore_time_get();
1030 svr->event_count = eina_list_append(svr->event_count, e); 1028 svr->event_count = eina_list_append(svr->event_count, e);
1031 _ecore_con_server_timer_update(svr); 1029 _ecore_con_server_timer_update(svr);
1032 e->server = svr; 1030 e->server = svr;
1033 if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE; 1031 if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE;
1034 ecore_event_add(ev, e, 1032 ecore_event_add(ev, e,
1035 _ecore_con_event_server_add_free, NULL); 1033 _ecore_con_event_server_add_free, NULL);
1036 _ecore_con_event_count++; 1034 _ecore_con_event_count++;
1037} 1035}
1038 1036
1039void 1037void
1040ecore_con_event_server_del(Ecore_Con_Server *svr) 1038ecore_con_event_server_del(Ecore_Con_Server *svr)
1041{ 1039{
1042 Ecore_Con_Event_Server_Del *e; 1040 Ecore_Con_Event_Server_Del *e;
1043 1041
1044 svr->delete_me = EINA_TRUE; 1042 svr->delete_me = EINA_TRUE;
1045 INF("svr %p is dead", svr); 1043 INF("svr %p is dead", svr);
1046 e = ecore_con_event_server_del_alloc(); 1044 e = ecore_con_event_server_del_alloc();
1047 EINA_SAFETY_ON_NULL_RETURN(e); 1045 EINA_SAFETY_ON_NULL_RETURN(e);
1048 1046
1049 svr->event_count = eina_list_append(svr->event_count, e); 1047 svr->event_count = eina_list_append(svr->event_count, e);
1050 _ecore_con_server_timer_update(svr); 1048 _ecore_con_server_timer_update(svr);
1051 e->server = svr; 1049 e->server = svr;
1052 if (svr->ecs) 1050 if (svr->ecs)
1053 { 1051 {
1054 svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE; 1052 svr->ecs_state = svr->ecs->lookup ? ECORE_CON_PROXY_STATE_RESOLVED : ECORE_CON_PROXY_STATE_DONE;
1055 eina_stringshare_replace(&svr->proxyip, NULL); 1053 eina_stringshare_replace(&svr->proxyip, NULL);
1056 svr->proxyport = 0; 1054 svr->proxyport = 0;
1057 } 1055 }
1058 ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e, 1056 ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
1059 _ecore_con_event_server_del_free, NULL); 1057 _ecore_con_event_server_del_free, NULL);
1060 _ecore_con_event_count++; 1058 _ecore_con_event_count++;
1061} 1059}
1062 1060
@@ -1130,20 +1128,20 @@ ecore_con_event_client_add(Ecore_Con_Client *cl)
1130void 1128void
1131ecore_con_event_client_del(Ecore_Con_Client *cl) 1129ecore_con_event_client_del(Ecore_Con_Client *cl)
1132{ 1130{
1133 Ecore_Con_Event_Client_Del *e; 1131 Ecore_Con_Event_Client_Del *e;
1134 1132
1135 if (!cl) return; 1133 if (!cl) return;
1136 cl->delete_me = EINA_TRUE; 1134 cl->delete_me = EINA_TRUE;
1137 INF("cl %p is dead", cl); 1135 INF("cl %p is dead", cl);
1138 e = ecore_con_event_client_del_alloc(); 1136 e = ecore_con_event_client_del_alloc();
1139 EINA_SAFETY_ON_NULL_RETURN(e); 1137 EINA_SAFETY_ON_NULL_RETURN(e);
1140 cl->event_count = eina_list_append(cl->event_count, e); 1138 cl->event_count = eina_list_append(cl->event_count, e);
1141 1139
1142 cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e); 1140 cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
1143 _ecore_con_cl_timer_update(cl); 1141 _ecore_con_cl_timer_update(cl);
1144 e->client = cl; 1142 e->client = cl;
1145 ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, 1143 ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
1146 (Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server); 1144 (Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
1147 _ecore_con_event_count++; 1145 _ecore_con_event_count++;
1148} 1146}
1149 1147
@@ -1195,7 +1193,6 @@ ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, E
1195 _ecore_con_event_count++; 1193 _ecore_con_event_count++;
1196} 1194}
1197 1195
1198
1199void 1196void
1200ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info) 1197ecore_con_server_infos_del(Ecore_Con_Server *svr, void *info)
1201{ 1198{
@@ -1457,7 +1454,7 @@ _ecore_con_cl_timer_update(Ecore_Con_Client *cl)
1457} 1454}
1458 1455
1459static void 1456static void
1460_ecore_con_cb_tcp_listen(void *data, 1457_ecore_con_cb_tcp_listen(void *data,
1461 Ecore_Con_Info *net_info) 1458 Ecore_Con_Info *net_info)
1462{ 1459{
1463 Ecore_Con_Server *svr; 1460 Ecore_Con_Server *svr;
@@ -1477,38 +1474,38 @@ _ecore_con_cb_tcp_listen(void *data,
1477 if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max) 1474 if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
1478 { 1475 {
1479 if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index, 1476 if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
1480 net_info->info.ai_family, 1477 net_info->info.ai_family,
1481 net_info->info.ai_socktype, 1478 net_info->info.ai_socktype,
1482 1, 1479 1,
1483 svr->port) <= 0) 1480 svr->port) <= 0)
1484 { 1481 {
1485 ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation."); 1482 ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
1486 goto error; 1483 goto error;
1487 } 1484 }
1488 1485
1489 svr->fd = SD_LISTEN_FDS_START + sd_fd_index++; 1486 svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
1490 1487
1491 /* I am wondering if that's really going to work as the bind is already done */ 1488 /* I am wondering if that's really going to work as the bind is already done */
1492 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error; 1489 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
1493 1490
1494 lin.l_onoff = 1; 1491 lin.l_onoff = 1;
1495 lin.l_linger = 0; 1492 lin.l_linger = 0;
1496 if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin, 1493 if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
1497 sizeof(struct linger)) < 0) 1494 sizeof(struct linger)) < 0)
1498 goto error; 1495 goto error;
1499 1496
1500 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY) 1497 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
1501 { 1498 {
1502 int flag = 1; 1499 int flag = 1;
1503 1500
1504 if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, 1501 if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
1505 sizeof(int)) < 0) 1502 sizeof(int)) < 0)
1506 { 1503 {
1507 goto error; 1504 goto error;
1508 } 1505 }
1509 } 1506 }
1510 1507
1511 goto fd_ready; 1508 goto fd_ready;
1512 } 1509 }
1513#endif 1510#endif
1514 1511
@@ -1526,7 +1523,7 @@ _ecore_con_cb_tcp_listen(void *data,
1526 1523
1527 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY) 1524 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_NODELAY)
1528 { 1525 {
1529 int flag = 1; 1526 int flag = 1;
1530 1527
1531 if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, 1528 if (setsockopt(svr->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
1532 sizeof(int)) < 0) 1529 sizeof(int)) < 0)
@@ -1541,10 +1538,10 @@ _ecore_con_cb_tcp_listen(void *data,
1541 if (listen(svr->fd, 4096) < 0) goto error; 1538 if (listen(svr->fd, 4096) < 0) goto error;
1542 1539
1543#ifdef HAVE_SYSTEMD 1540#ifdef HAVE_SYSTEMD
1544 fd_ready: 1541fd_ready:
1545#endif 1542#endif
1546 svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, 1543 svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
1547 _ecore_con_svr_tcp_handler, svr, NULL, NULL); 1544 _ecore_con_svr_tcp_handler, svr, NULL, NULL);
1548 if (!svr->fd_handler) 1545 if (!svr->fd_handler)
1549 { 1546 {
1550 memerr = "Memory allocation failure"; 1547 memerr = "Memory allocation failure";
@@ -1554,13 +1551,13 @@ _ecore_con_cb_tcp_listen(void *data,
1554 return; 1551 return;
1555 1552
1556error: 1553error:
1557 if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); 1554 if (errno || memerr) ecore_con_event_server_error(svr, memerr ? : strerror(errno));
1558 ecore_con_ssl_server_shutdown(svr); 1555 ecore_con_ssl_server_shutdown(svr);
1559 _ecore_con_server_kill(svr); 1556 _ecore_con_server_kill(svr);
1560} 1557}
1561 1558
1562static void 1559static void
1563_ecore_con_cb_udp_listen(void *data, 1560_ecore_con_cb_udp_listen(void *data,
1564 Ecore_Con_Info *net_info) 1561 Ecore_Con_Info *net_info)
1565{ 1562{
1566 Ecore_Con_Server *svr; 1563 Ecore_Con_Server *svr;
@@ -1586,21 +1583,21 @@ _ecore_con_cb_udp_listen(void *data,
1586 if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max) 1583 if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
1587 { 1584 {
1588 if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index, 1585 if (sd_is_socket_inet(SD_LISTEN_FDS_START + sd_fd_index,
1589 net_info->info.ai_family, 1586 net_info->info.ai_family,
1590 net_info->info.ai_socktype, 1587 net_info->info.ai_socktype,
1591 -1, 1588 -1,
1592 svr->port) <= 0) 1589 svr->port) <= 0)
1593 { 1590 {
1594 ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation."); 1591 ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
1595 goto error; 1592 goto error;
1596 } 1593 }
1597 svr->fd = SD_LISTEN_FDS_START + sd_fd_index++; 1594 svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
1598 1595
1599 if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0) 1596 if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0)
1600 goto error; 1597 goto error;
1601 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error; 1598 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
1602 1599
1603 goto fd_ready; 1600 goto fd_ready;
1604 } 1601 }
1605#endif 1602#endif
1606 svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype, 1603 svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype,
@@ -1643,7 +1640,7 @@ _ecore_con_cb_udp_listen(void *data,
1643 goto error; 1640 goto error;
1644 1641
1645#ifdef HAVE_SYSTEMD 1642#ifdef HAVE_SYSTEMD
1646 fd_ready: 1643fd_ready:
1647#endif 1644#endif
1648 svr->fd_handler = 1645 svr->fd_handler =
1649 ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, 1646 ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
@@ -1659,13 +1656,13 @@ _ecore_con_cb_udp_listen(void *data,
1659 return; 1656 return;
1660 1657
1661error: 1658error:
1662 if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); 1659 if (errno || memerr) ecore_con_event_server_error(svr, memerr ? : strerror(errno));
1663 ecore_con_ssl_server_shutdown(svr); 1660 ecore_con_ssl_server_shutdown(svr);
1664 _ecore_con_server_kill(svr); 1661 _ecore_con_server_kill(svr);
1665} 1662}
1666 1663
1667static void 1664static void
1668_ecore_con_cb_tcp_connect(void *data, 1665_ecore_con_cb_tcp_connect(void *data,
1669 Ecore_Con_Info *net_info) 1666 Ecore_Con_Info *net_info)
1670{ 1667{
1671 Ecore_Con_Server *svr; 1668 Ecore_Con_Server *svr;
@@ -1752,13 +1749,13 @@ _ecore_con_cb_tcp_connect(void *data,
1752 1749
1753error: 1750error:
1754 ecore_con_event_server_error(svr, 1751 ecore_con_event_server_error(svr,
1755 memerr ?: errno? strerror(errno) : "DNS error"); 1752 memerr ? : errno ? strerror(errno) : "DNS error");
1756 ecore_con_ssl_server_shutdown(svr); 1753 ecore_con_ssl_server_shutdown(svr);
1757 _ecore_con_server_kill(svr); 1754 _ecore_con_server_kill(svr);
1758} 1755}
1759 1756
1760static void 1757static void
1761_ecore_con_cb_udp_connect(void *data, 1758_ecore_con_cb_udp_connect(void *data,
1762 Ecore_Con_Info *net_info) 1759 Ecore_Con_Info *net_info)
1763{ 1760{
1764 Ecore_Con_Server *svr; 1761 Ecore_Con_Server *svr;
@@ -1810,7 +1807,7 @@ _ecore_con_cb_udp_connect(void *data,
1810 return; 1807 return;
1811 1808
1812error: 1809error:
1813 if (errno || memerr) ecore_con_event_server_error(svr, memerr ?: strerror(errno)); 1810 if (errno || memerr) ecore_con_event_server_error(svr, memerr ? : strerror(errno));
1814 ecore_con_ssl_server_shutdown(svr); 1811 ecore_con_ssl_server_shutdown(svr);
1815 _ecore_con_server_kill(svr); 1812 _ecore_con_server_kill(svr);
1816} 1813}
@@ -1850,13 +1847,13 @@ svr_try_connect_plain(Ecore_Con_Server *svr)
1850 1847
1851 if ((!svr->delete_me) && (!svr->handshaking) && svr->connecting) 1848 if ((!svr->delete_me) && (!svr->handshaking) && svr->connecting)
1852 { 1849 {
1853 if (svr->ecs) 1850 if (svr->ecs)
1854 { 1851 {
1855 if (ecore_con_socks_svr_init(svr)) 1852 if (ecore_con_socks_svr_init(svr))
1856 return ECORE_CON_INPROGRESS; 1853 return ECORE_CON_INPROGRESS;
1857 } 1854 }
1858 else 1855 else
1859 ecore_con_event_server_add(svr); 1856 ecore_con_event_server_add(svr);
1860 } 1857 }
1861 1858
1862 if (svr->fd_handler) 1859 if (svr->fd_handler)
@@ -1884,25 +1881,27 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr)
1884 int family = client_addr->sa_family; 1881 int family = client_addr->sa_family;
1885 void *src; 1882 void *src;
1886 1883
1887 switch(family) 1884 switch (family)
1888 { 1885 {
1889 case AF_INET: 1886 case AF_INET:
1890 src = &(((struct sockaddr_in *)client_addr)->sin_addr); 1887 src = &(((struct sockaddr_in *)client_addr)->sin_addr);
1891 break; 1888 break;
1889
1892#ifdef HAVE_IPV6 1890#ifdef HAVE_IPV6
1893 case AF_INET6: 1891 case AF_INET6:
1894 src = &(((struct sockaddr_in6 *)client_addr)->sin6_addr); 1892 src = &(((struct sockaddr_in6 *)client_addr)->sin6_addr);
1895 1893
1896 if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)src)) 1894 if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)src))
1897 { 1895 {
1898 family = AF_INET; 1896 family = AF_INET;
1899 src = (char*)src + 12; 1897 src = (char *)src + 12;
1900 } 1898 }
1901 break; 1899 break;
1900
1902#endif 1901#endif
1903 default: 1902 default:
1904 return eina_stringshare_add("0.0.0.0"); 1903 return eina_stringshare_add("0.0.0.0");
1905 } 1904 }
1906 1905
1907 if (!inet_ntop(family, src, ipbuf, sizeof(ipbuf))) 1906 if (!inet_ntop(family, src, ipbuf, sizeof(ipbuf)))
1908 return eina_stringshare_add("0.0.0.0"); 1907 return eina_stringshare_add("0.0.0.0");
@@ -1912,7 +1911,7 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr)
1912} 1911}
1913 1912
1914static Eina_Bool 1913static Eina_Bool
1915_ecore_con_svr_tcp_handler(void *data, 1914_ecore_con_svr_tcp_handler(void *data,
1916 Ecore_Fd_Handler *fd_handler EINA_UNUSED) 1915 Ecore_Fd_Handler *fd_handler EINA_UNUSED)
1917{ 1916{
1918 Ecore_Con_Server *svr; 1917 Ecore_Con_Server *svr;
@@ -1995,7 +1994,7 @@ error:
1995 } 1994 }
1996 } 1995 }
1997 free(cl); 1996 free(cl);
1998 if (clerr || errno) ecore_con_event_server_error(svr, clerr ?: strerror(errno)); 1997 if (clerr || errno) ecore_con_event_server_error(svr, clerr ? : strerror(errno));
1999 return ECORE_CALLBACK_RENEW; 1998 return ECORE_CALLBACK_RENEW;
2000} 1999}
2001 2000
@@ -2010,13 +2009,13 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
2010 2009
2011 /* only possible with non-ssl connections */ 2010 /* only possible with non-ssl connections */
2012 if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED)) 2011 if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED))
2013 return; 2012 return;
2014 2013
2015 if (svr->handshaking && (!svr->ecs_state)) 2014 if (svr->handshaking && (!svr->ecs_state))
2016 { 2015 {
2017 DBG("Continuing ssl handshake"); 2016 DBG("Continuing ssl handshake");
2018 if (!ecore_con_ssl_server_init(svr)) 2017 if (!ecore_con_ssl_server_init(svr))
2019 lost_server = EINA_FALSE; 2018 lost_server = EINA_FALSE;
2020 _ecore_con_server_timer_update(svr); 2019 _ecore_con_server_timer_update(svr);
2021 } 2020 }
2022 2021
@@ -2026,7 +2025,7 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
2026 num = read(svr->fd, buf, sizeof(buf)); 2025 num = read(svr->fd, buf, sizeof(buf));
2027 /* 0 is not a valid return value for a tcp socket */ 2026 /* 0 is not a valid return value for a tcp socket */
2028 if ((num > 0) || ((num < 0) && (errno == EAGAIN))) 2027 if ((num > 0) || ((num < 0) && (errno == EAGAIN)))
2029 lost_server = EINA_FALSE; 2028 lost_server = EINA_FALSE;
2030 else if (num < 0) 2029 else if (num < 0)
2031 ecore_con_event_server_error(svr, strerror(errno)); 2030 ecore_con_event_server_error(svr, strerror(errno));
2032 } 2031 }
@@ -2035,7 +2034,7 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
2035 num = ecore_con_ssl_server_read(svr, buf, sizeof(buf)); 2034 num = ecore_con_ssl_server_read(svr, buf, sizeof(buf));
2036 /* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */ 2035 /* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */
2037 if (num >= 0) 2036 if (num >= 0)
2038 lost_server = EINA_FALSE; 2037 lost_server = EINA_FALSE;
2039 } 2038 }
2040 2039
2041 if ((!svr->delete_me) && (num > 0)) 2040 if ((!svr->delete_me) && (num > 0))
@@ -2047,11 +2046,11 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
2047 } 2046 }
2048 2047
2049 if (lost_server) 2048 if (lost_server)
2050 _ecore_con_server_kill(svr); 2049 _ecore_con_server_kill(svr);
2051} 2050}
2052 2051
2053static Eina_Bool 2052static Eina_Bool
2054_ecore_con_cl_handler(void *data, 2053_ecore_con_cl_handler(void *data,
2055 Ecore_Fd_Handler *fd_handler) 2054 Ecore_Fd_Handler *fd_handler)
2056{ 2055{
2057 Ecore_Con_Server *svr; 2056 Ecore_Con_Server *svr;
@@ -2111,7 +2110,7 @@ _ecore_con_cl_handler(void *data,
2111} 2110}
2112 2111
2113static Eina_Bool 2112static Eina_Bool
2114_ecore_con_cl_udp_handler(void *data, 2113_ecore_con_cl_udp_handler(void *data,
2115 Ecore_Fd_Handler *fd_handler) 2114 Ecore_Fd_Handler *fd_handler)
2116{ 2115{
2117 unsigned char buf[READBUFSIZ]; 2116 unsigned char buf[READBUFSIZ];
@@ -2147,7 +2146,7 @@ _ecore_con_cl_udp_handler(void *data,
2147} 2146}
2148 2147
2149static Eina_Bool 2148static Eina_Bool
2150_ecore_con_svr_udp_handler(void *data, 2149_ecore_con_svr_udp_handler(void *data,
2151 Ecore_Fd_Handler *fd_handler) 2150 Ecore_Fd_Handler *fd_handler)
2152{ 2151{
2153 unsigned char buf[READBUFSIZ]; 2152 unsigned char buf[READBUFSIZ];
@@ -2172,13 +2171,13 @@ _ecore_con_svr_udp_handler(void *data,
2172 num = fcntl(svr->fd, F_SETFL, O_NONBLOCK); 2171 num = fcntl(svr->fd, F_SETFL, O_NONBLOCK);
2173 if (num >= 0) 2172 if (num >= 0)
2174 num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0, 2173 num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0,
2175 (struct sockaddr *)&client_addr, 2174 (struct sockaddr *)&client_addr,
2176 &client_addr_len); 2175 &client_addr_len);
2177 2176
2178#else 2177#else
2179 num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT, 2178 num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT,
2180 (struct sockaddr *)&client_addr, 2179 (struct sockaddr *)&client_addr,
2181 &client_addr_len); 2180 &client_addr_len);
2182#endif 2181#endif
2183 2182
2184 if (num < 0 && (errno != EAGAIN) && (errno != EINTR)) 2183 if (num < 0 && (errno != EAGAIN) && (errno != EINTR))
@@ -2190,7 +2189,6 @@ _ecore_con_svr_udp_handler(void *data,
2190 return ECORE_CALLBACK_CANCEL; 2189 return ECORE_CALLBACK_CANCEL;
2191 } 2190 }
2192 2191
2193
2194/* Create a new client for use in the client data event */ 2192/* Create a new client for use in the client data event */
2195 cl = calloc(1, sizeof(Ecore_Con_Client)); 2193 cl = calloc(1, sizeof(Ecore_Con_Client));
2196 EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW); 2194 EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW);
@@ -2259,7 +2257,7 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
2259} 2257}
2260 2258
2261static Eina_Bool 2259static Eina_Bool
2262_ecore_con_svr_cl_handler(void *data, 2260_ecore_con_svr_cl_handler(void *data,
2263 Ecore_Fd_Handler *fd_handler) 2261 Ecore_Fd_Handler *fd_handler)
2264{ 2262{
2265 Ecore_Con_Client *cl; 2263 Ecore_Con_Client *cl;
@@ -2349,12 +2347,12 @@ _ecore_con_server_flush(Ecore_Con_Server *svr)
2349 2347
2350 if (count < 0) 2348 if (count < 0)
2351 { 2349 {
2352 if ((errno != EAGAIN) && (errno != EINTR)) 2350 if ((errno != EAGAIN) && (errno != EINTR))
2353 { 2351 {
2354 ecore_con_event_server_error(svr, strerror(errno)); 2352 ecore_con_event_server_error(svr, strerror(errno));
2355 _ecore_con_server_kill(svr); 2353 _ecore_con_server_kill(svr);
2356 } 2354 }
2357 return; 2355 return;
2358 } 2356 }
2359 2357
2360 if (count && (!svr->ecs_state)) ecore_con_event_server_write(svr, count); 2358 if (count && (!svr->ecs_state)) ecore_con_event_server_write(svr, count);
@@ -2437,8 +2435,8 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
2437 { 2435 {
2438 if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me)) 2436 if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me))
2439 { 2437 {
2440 ecore_con_event_client_error(cl, strerror(errno)); 2438 ecore_con_event_client_error(cl, strerror(errno));
2441 _ecore_con_client_kill(cl); 2439 _ecore_con_client_kill(cl);
2442 } 2440 }
2443 2441
2444 return; 2442 return;
@@ -2469,7 +2467,7 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
2469 2467
2470static void 2468static void
2471_ecore_con_event_client_add_free(Ecore_Con_Server *svr, 2469_ecore_con_event_client_add_free(Ecore_Con_Server *svr,
2472 void *ev) 2470 void *ev)
2473{ 2471{
2474 Ecore_Con_Event_Client_Add *e; 2472 Ecore_Con_Event_Client_Add *e;
2475 2473
@@ -2477,7 +2475,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
2477 if (e->client) 2475 if (e->client)
2478 { 2476 {
2479 Eina_Bool svrfreed = EINA_FALSE; 2477 Eina_Bool svrfreed = EINA_FALSE;
2480 2478
2481 e->client->event_count = eina_list_remove(e->client->event_count, e); 2479 e->client->event_count = eina_list_remove(e->client->event_count, e);
2482 if (e->client->host_server) 2480 if (e->client->host_server)
2483 { 2481 {
@@ -2503,7 +2501,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
2503 2501
2504static void 2502static void
2505_ecore_con_event_client_del_free(Ecore_Con_Server *svr, 2503_ecore_con_event_client_del_free(Ecore_Con_Server *svr,
2506 void *ev) 2504 void *ev)
2507{ 2505{
2508 Ecore_Con_Event_Client_Del *e; 2506 Ecore_Con_Event_Client_Del *e;
2509 2507
@@ -2511,7 +2509,7 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
2511 if (e->client) 2509 if (e->client)
2512 { 2510 {
2513 Eina_Bool svrfreed = EINA_FALSE; 2511 Eina_Bool svrfreed = EINA_FALSE;
2514 2512
2515 e->client->event_count = eina_list_remove(e->client->event_count, e); 2513 e->client->event_count = eina_list_remove(e->client->event_count, e);
2516 if (e->client->host_server) 2514 if (e->client->host_server)
2517 { 2515 {
@@ -2541,7 +2539,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
2541 if (e->client) 2539 if (e->client)
2542 { 2540 {
2543 Eina_Bool svrfreed = EINA_FALSE; 2541 Eina_Bool svrfreed = EINA_FALSE;
2544 2542
2545 e->client->event_count = eina_list_remove(e->client->event_count, e); 2543 e->client->event_count = eina_list_remove(e->client->event_count, e);
2546 if (e->client->host_server) 2544 if (e->client->host_server)
2547 { 2545 {
@@ -2557,7 +2555,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
2557 if (((!e->client->event_count) && (e->client->delete_me)) || 2555 if (((!e->client->event_count) && (e->client->delete_me)) ||
2558 ((e->client->host_server && 2556 ((e->client->host_server &&
2559 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || 2557 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2560 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) 2558 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2561 ecore_con_client_del(e->client); 2559 ecore_con_client_del(e->client);
2562 } 2560 }
2563 } 2561 }
@@ -2569,7 +2567,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
2569 2567
2570static void 2568static void
2571_ecore_con_event_client_data_free(Ecore_Con_Server *svr, 2569_ecore_con_event_client_data_free(Ecore_Con_Server *svr,
2572 void *ev) 2570 void *ev)
2573{ 2571{
2574 Ecore_Con_Event_Client_Data *e; 2572 Ecore_Con_Event_Client_Data *e;
2575 2573
@@ -2577,7 +2575,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
2577 if (e->client) 2575 if (e->client)
2578 { 2576 {
2579 Eina_Bool svrfreed = EINA_FALSE; 2577 Eina_Bool svrfreed = EINA_FALSE;
2580 2578
2581 e->client->event_count = eina_list_remove(e->client->event_count, e); 2579 e->client->event_count = eina_list_remove(e->client->event_count, e);
2582 if (e->client->host_server) 2580 if (e->client->host_server)
2583 { 2581 {
@@ -2593,7 +2591,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
2593 if (((!e->client->event_count) && (e->client->delete_me)) || 2591 if (((!e->client->event_count) && (e->client->delete_me)) ||
2594 ((e->client->host_server && 2592 ((e->client->host_server &&
2595 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || 2593 ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2596 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) 2594 (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2597 ecore_con_client_del(e->client); 2595 ecore_con_client_del(e->client);
2598 } 2596 }
2599 } 2597 }
@@ -2606,7 +2604,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
2606 2604
2607static void 2605static void
2608_ecore_con_event_server_add_free(void *data EINA_UNUSED, 2606_ecore_con_event_server_add_free(void *data EINA_UNUSED,
2609 void *ev) 2607 void *ev)
2610{ 2608{
2611 Ecore_Con_Event_Server_Add *e; 2609 Ecore_Con_Event_Server_Add *e;
2612 2610
@@ -2625,7 +2623,7 @@ _ecore_con_event_server_add_free(void *data EINA_UNUSED,
2625 2623
2626static void 2624static void
2627_ecore_con_event_server_del_free(void *data EINA_UNUSED, 2625_ecore_con_event_server_del_free(void *data EINA_UNUSED,
2628 void *ev) 2626 void *ev)
2629{ 2627{
2630 Ecore_Con_Event_Server_Del *e; 2628 Ecore_Con_Event_Server_Del *e;
2631 2629
@@ -2661,7 +2659,7 @@ _ecore_con_event_server_write_free(void *data EINA_UNUSED,
2661 2659
2662static void 2660static void
2663_ecore_con_event_server_data_free(void *data EINA_UNUSED, 2661_ecore_con_event_server_data_free(void *data EINA_UNUSED,
2664 void *ev) 2662 void *ev)
2665{ 2663{
2666 Ecore_Con_Event_Server_Data *e; 2664 Ecore_Con_Event_Server_Data *e;
2667 2665
@@ -2680,7 +2678,6 @@ _ecore_con_event_server_data_free(void *data EINA_UNUSED,
2680 ecore_con_mempool_shutdown(); 2678 ecore_con_mempool_shutdown();
2681} 2679}
2682 2680
2683
2684static void 2681static void
2685_ecore_con_event_server_error_free(void *data EINA_UNUSED, Ecore_Con_Event_Server_Error *e) 2682_ecore_con_event_server_error_free(void *data EINA_UNUSED, Ecore_Con_Event_Server_Error *e)
2686{ 2683{
@@ -2703,7 +2700,7 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
2703 if (e->client) 2700 if (e->client)
2704 { 2701 {
2705 Eina_Bool svrfreed = EINA_FALSE; 2702 Eina_Bool svrfreed = EINA_FALSE;
2706 2703
2707 if (eina_list_data_find(svr->clients, e->client)) 2704 if (eina_list_data_find(svr->clients, e->client))
2708 { 2705 {
2709 e->client->event_count = eina_list_remove(e->client->event_count, e); 2706 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
2728} 2725}
2729 2726
2730static void 2727static void
2731_ecore_con_lookup_done(void *data, 2728_ecore_con_lookup_done(void *data,
2732 Ecore_Con_Info *infos) 2729 Ecore_Con_Info *infos)
2733{ 2730{
2734 Ecore_Con_Server *svr; 2731 Ecore_Con_Server *svr;
diff --git a/src/lib/ecore_con/ecore_con_alloc.c b/src/lib/ecore_con/ecore_con_alloc.c
index 1747ea3b20..1c04a557bc 100644
--- a/src/lib/ecore_con/ecore_con_alloc.c
+++ b/src/lib/ecore_con/ecore_con_alloc.c
@@ -10,24 +10,24 @@
10typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool; 10typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
11struct _Ecore_Con_Mempool 11struct _Ecore_Con_Mempool
12{ 12{
13 const char *name; 13 const char *name;
14 Eina_Mempool *mp; 14 Eina_Mempool *mp;
15 size_t size; 15 size_t size;
16}; 16};
17 17
18#define GENERIC_ALLOC_FREE(TYPE, Type) \ 18#define GENERIC_ALLOC_FREE(TYPE, Type) \
19 Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \ 19 Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
20 \ 20 \
21 TYPE * \ 21 TYPE * \
22 Type##_alloc(void) \ 22 Type##_alloc(void) \
23 { \ 23 { \
24 return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \ 24 return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
25 } \ 25 } \
26 \ 26 \
27 void \ 27 void \
28 Type##_free(TYPE *e) \ 28 Type##_free(TYPE * e) \
29 { \ 29 { \
30 eina_mempool_free(Type##_mp.mp, e); \ 30 eina_mempool_free(Type##_mp.mp, e); \
31 } 31 }
32 32
33GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add); 33GENERIC_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);
43GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind); 43GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind);
44 44
45static Ecore_Con_Mempool *mempool_array[] = { 45static Ecore_Con_Mempool *mempool_array[] = {
46 &ecore_con_event_client_add_mp, 46 &ecore_con_event_client_add_mp,
47 &ecore_con_event_client_del_mp, 47 &ecore_con_event_client_del_mp,
48 &ecore_con_event_client_write_mp, 48 &ecore_con_event_client_write_mp,
49 &ecore_con_event_client_data_mp, 49 &ecore_con_event_client_data_mp,
50 &ecore_con_event_server_error_mp, 50 &ecore_con_event_server_error_mp,
51 &ecore_con_event_client_error_mp, 51 &ecore_con_event_client_error_mp,
52 &ecore_con_event_server_add_mp, 52 &ecore_con_event_server_add_mp,
53 &ecore_con_event_server_del_mp, 53 &ecore_con_event_server_del_mp,
54 &ecore_con_event_server_write_mp, 54 &ecore_con_event_server_write_mp,
55 &ecore_con_event_server_data_mp, 55 &ecore_con_event_server_data_mp,
56 &ecore_con_event_proxy_bind_mp 56 &ecore_con_event_proxy_bind_mp
57}; 57};
58 58
59void 59void
@@ -68,7 +68,7 @@ ecore_con_mempool_init(void)
68 68
69 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) 69 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
70 { 70 {
71 retry: 71retry:
72 mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 16); 72 mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 16);
73 if (!mempool_array[i]->mp) 73 if (!mempool_array[i]->mp)
74 { 74 {
diff --git a/src/lib/ecore_con/ecore_con_ares.c b/src/lib/ecore_con/ecore_con_ares.c
index 3c0ca22c85..9988b2163e 100644
--- a/src/lib/ecore_con/ecore_con_ares.c
+++ b/src/lib/ecore_con/ecore_con_ares.c
@@ -44,41 +44,42 @@ struct _Ecore_Con_CAres
44 struct addrinfo hints; 44 struct addrinfo hints;
45 Ecore_Con_Info *result; 45 Ecore_Con_Info *result;
46 46
47 union { 47 union
48 {
48 struct in_addr v4; 49 struct in_addr v4;
49#ifdef HAVE_IPV6 50#ifdef HAVE_IPV6
50 struct in6_addr v6; 51 struct in6_addr v6;
51#endif 52#endif
52 } addr; 53 } addr;
53 54
54 Eina_Bool byaddr : 1; 55 Eina_Bool byaddr : 1;
55 Eina_Bool isv6 : 1; 56 Eina_Bool isv6 : 1;
56}; 57};
57 58
58static ares_channel info_channel; 59static ares_channel info_channel;
59static int info_init = 0; 60static int info_init = 0;
60static Eina_List *info_fds = NULL; 61static Eina_List *info_fds = NULL;
61 62
62static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg, 63static void _ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
63 int status, 64 int status,
64 int timeouts, 65 int timeouts,
65 char *node, 66 char *node,
66 char *service); 67 char *service);
67static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg, 68static void _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
68 int status, 69 int status,
69 int timeouts, 70 int timeouts,
70 struct hostent *hostent); 71 struct hostent *hostent);
71static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf, 72static Eina_Bool _ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
72 Ecore_Fd_Handler *fd_handler); 73 Ecore_Fd_Handler *fd_handler);
73static Eina_Bool _ecore_con_info_cares_timeout_cb(void *data); 74static Eina_Bool _ecore_con_info_cares_timeout_cb(void *data);
74 75
75static void 76static void
76_ecore_con_info_cares_state_cb(void *data, 77 _ecore_con_info_cares_state_cb(void *data,
77 ares_socket_t fd, 78 ares_socket_t fd,
78 int readable, 79 int readable,
79 int writable); 80 int writable);
80static int 81static int
81_ecore_con_info_fds_search(const Ecore_Con_FD *fd1, 82 _ecore_con_info_fds_search(const Ecore_Con_FD *fd1,
82 const Ecore_Con_FD *fd2); 83 const Ecore_Con_FD *fd2);
83 84
84int 85int
@@ -95,7 +96,7 @@ ecore_con_info_init(void)
95 opts.sock_state_cb = _ecore_con_info_cares_state_cb; 96 opts.sock_state_cb = _ecore_con_info_cares_state_cb;
96 97
97 if (ares_init_options(&info_channel, &opts, 98 if (ares_init_options(&info_channel, &opts,
98 ARES_OPT_LOOKUPS | ARES_OPT_SOCK_STATE_CB) != ARES_SUCCESS) 99 ARES_OPT_LOOKUPS | ARES_OPT_SOCK_STATE_CB) != ARES_SUCCESS)
99 { 100 {
100 ares_library_cleanup(); 101 ares_library_cleanup();
101 return 0; 102 return 0;
@@ -113,11 +114,11 @@ ecore_con_info_shutdown(void)
113 if (info_init == 0) 114 if (info_init == 0)
114 { 115 {
115 /* Cancel all ongoing request */ 116 /* Cancel all ongoing request */
116 ares_cancel(info_channel); 117 ares_cancel(info_channel);
117 ares_destroy(info_channel); 118 ares_destroy(info_channel);
118 119
119 /* Shutdown ares */ 120 /* Shutdown ares */
120 ares_library_cleanup(); 121 ares_library_cleanup();
121 } 122 }
122 123
123 return info_init; 124 return info_init;
@@ -126,7 +127,7 @@ ecore_con_info_shutdown(void)
126int 127int
127ecore_con_info_tcp_connect(Ecore_Con_Server *svr, 128ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
128 Ecore_Con_Info_Cb done_cb, 129 Ecore_Con_Info_Cb done_cb,
129 void *data) 130 void *data)
130{ 131{
131 struct addrinfo hints; 132 struct addrinfo hints;
132 133
@@ -149,7 +150,7 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
149int 150int
150ecore_con_info_tcp_listen(Ecore_Con_Server *svr, 151ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
151 Ecore_Con_Info_Cb done_cb, 152 Ecore_Con_Info_Cb done_cb,
152 void *data) 153 void *data)
153{ 154{
154 struct addrinfo hints; 155 struct addrinfo hints;
155 156
@@ -172,7 +173,7 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
172int 173int
173ecore_con_info_udp_connect(Ecore_Con_Server *svr, 174ecore_con_info_udp_connect(Ecore_Con_Server *svr,
174 Ecore_Con_Info_Cb done_cb, 175 Ecore_Con_Info_Cb done_cb,
175 void *data) 176 void *data)
176{ 177{
177 struct addrinfo hints; 178 struct addrinfo hints;
178 179
@@ -195,7 +196,7 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
195int 196int
196ecore_con_info_udp_listen(Ecore_Con_Server *svr, 197ecore_con_info_udp_listen(Ecore_Con_Server *svr,
197 Ecore_Con_Info_Cb done_cb, 198 Ecore_Con_Info_Cb done_cb,
198 void *data) 199 void *data)
199{ 200{
200 struct addrinfo hints; 201 struct addrinfo hints;
201 202
@@ -218,7 +219,7 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
218int 219int
219ecore_con_info_mcast_listen(Ecore_Con_Server *svr, 220ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
220 Ecore_Con_Info_Cb done_cb, 221 Ecore_Con_Info_Cb done_cb,
221 void *data) 222 void *data)
222{ 223{
223 struct addrinfo hints; 224 struct addrinfo hints;
224 225
@@ -240,10 +241,10 @@ ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
240 241
241static Eina_Bool 242static Eina_Bool
242_ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg, 243_ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
243 int addrtype, 244 int addrtype,
244 const char *name, 245 const char *name,
245 struct sockaddr *addr, 246 struct sockaddr *addr,
246 int addrlen) 247 int addrlen)
247{ 248{
248 int length = 0; 249 int length = 0;
249 250
@@ -285,8 +286,8 @@ _ecore_con_info_ares_getnameinfo(Ecore_Con_CAres *arg,
285EAPI int 286EAPI int
286ecore_con_info_get(Ecore_Con_Server *svr, 287ecore_con_info_get(Ecore_Con_Server *svr,
287 Ecore_Con_Info_Cb done_cb, 288 Ecore_Con_Info_Cb done_cb,
288 void *data, 289 void *data,
289 struct addrinfo *hints) 290 struct addrinfo *hints)
290{ 291{
291 Ecore_Con_CAres *cares; 292 Ecore_Con_CAres *cares;
292#ifdef HAVE_IPV6 293#ifdef HAVE_IPV6
@@ -358,7 +359,7 @@ _ecore_con_info_cares_timeout_cb(void *data EINA_UNUSED)
358} 359}
359 360
360static Eina_Bool 361static Eina_Bool
361_ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf, 362_ecore_con_info_cares_fd_cb(Ecore_Con_FD *ecf,
362 Ecore_Fd_Handler *fd_handler) 363 Ecore_Fd_Handler *fd_handler)
363{ 364{
364 ares_socket_t read_fd, write_fd; 365 ares_socket_t read_fd, write_fd;
@@ -392,7 +393,7 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
392 Ecore_Con_FD *search = NULL, *ecf = NULL; 393 Ecore_Con_FD *search = NULL, *ecf = NULL;
393 394
394 search = eina_list_search_unsorted(info_fds, 395 search = eina_list_search_unsorted(info_fds,
395 (Eina_Compare_Cb)_ecore_con_info_fds_search, &ecf); 396 (Eina_Compare_Cb)_ecore_con_info_fds_search, &ecf);
396 397
397 if (!(readable | writable)) 398 if (!(readable | writable))
398 { 399 {
@@ -414,7 +415,7 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
414 415
415 search->fd = fd; 416 search->fd = fd;
416 search->handler = ecore_main_fd_handler_add(fd, ECORE_FD_WRITE | ECORE_FD_READ, 417 search->handler = ecore_main_fd_handler_add(fd, ECORE_FD_WRITE | ECORE_FD_READ,
417 (Ecore_Fd_Cb)_ecore_con_info_cares_fd_cb, search, NULL, NULL); 418 (Ecore_Fd_Cb)_ecore_con_info_cares_fd_cb, search, NULL, NULL);
418 /* c-ares default timeout is 5 seconds */ 419 /* c-ares default timeout is 5 seconds */
419 search->timer = ecore_timer_add(5, _ecore_con_info_cares_timeout_cb, NULL); 420 search->timer = ecore_timer_add(5, _ecore_con_info_cares_timeout_cb, NULL);
420 info_fds = eina_list_append(info_fds, search); 421 info_fds = eina_list_append(info_fds, search);
@@ -427,9 +428,9 @@ _ecore_con_info_cares_state_cb(void *data EINA_UNUSED,
427 428
428static void 429static void
429_ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg, 430_ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
430 int status, 431 int status,
431 int timeouts EINA_UNUSED, 432 int timeouts EINA_UNUSED,
432 struct hostent *hostent) 433 struct hostent *hostent)
433{ 434{
434 struct sockaddr *addr; 435 struct sockaddr *addr;
435 int addrlen; 436 int addrlen;
@@ -465,6 +466,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
465 addr = (struct sockaddr *)addri; 466 addr = (struct sockaddr *)addri;
466 break; 467 break;
467 } 468 }
469
468#ifdef HAVE_IPV6 470#ifdef HAVE_IPV6
469 case AF_INET6: 471 case AF_INET6:
470 { 472 {
@@ -487,6 +489,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
487 addr = (struct sockaddr *)addri6; 489 addr = (struct sockaddr *)addri6;
488 break; 490 break;
489 } 491 }
492
490#endif 493#endif
491 default: 494 default:
492 ERR("Unknown addrtype %i", hostent->h_addrtype); 495 ERR("Unknown addrtype %i", hostent->h_addrtype);
@@ -505,56 +508,56 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
505 { 508 {
506#ifdef HAVE_IPV6 509#ifdef HAVE_IPV6
507 /* This happen when host doesn't have a reverse. */ 510 /* This happen when host doesn't have a reverse. */
508 if (arg->isv6) 511 if (arg->isv6)
509 { 512 {
510 struct sockaddr_in6 *addri6; 513 struct sockaddr_in6 *addri6;
511 514
512 addrlen = sizeof(struct sockaddr_in6); 515 addrlen = sizeof(struct sockaddr_in6);
513 addri6 = malloc(addrlen); 516 addri6 = malloc(addrlen);
514 517
515 if (!addri6) 518 if (!addri6)
516 goto on_mem_error; 519 goto on_mem_error;
517 520
518 addri6->sin6_family = AF_INET6; 521 addri6->sin6_family = AF_INET6;
519 addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port); 522 addri6->sin6_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
520 addri6->sin6_flowinfo = 0; 523 addri6->sin6_flowinfo = 0;
521 addri6->sin6_scope_id = 0; 524 addri6->sin6_scope_id = 0;
522 525
523 memcpy(&addri6->sin6_addr.s6_addr, 526 memcpy(&addri6->sin6_addr.s6_addr,
524 &arg->addr.v6, sizeof(struct in6_addr)); 527 &arg->addr.v6, sizeof(struct in6_addr));
525 528
526 addr = (struct sockaddr *)addri6; 529 addr = (struct sockaddr *)addri6;
527 } 530 }
528 else 531 else
529#endif 532#endif
530 { 533 {
531 struct sockaddr_in *addri; 534 struct sockaddr_in *addri;
532 535
533 addrlen = sizeof(struct sockaddr_in); 536 addrlen = sizeof(struct sockaddr_in);
534 addri = malloc(addrlen); 537 addri = malloc(addrlen);
535 538
536 if (!addri) 539 if (!addri)
537 goto on_mem_error; 540 goto on_mem_error;
538 541
539 addri->sin_family = AF_INET; 542 addri->sin_family = AF_INET;
540 addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port); 543 addri->sin_port = htons(arg->svr->ecs ? arg->svr->ecs->port : arg->svr->port);
541 544
542 memcpy(&addri->sin_addr.s_addr, 545 memcpy(&addri->sin_addr.s_addr,
543 &arg->addr.v4, sizeof(struct in_addr)); 546 &arg->addr.v4, sizeof(struct in_addr));
544 547
545 addr = (struct sockaddr *)addri; 548 addr = (struct sockaddr *)addri;
546 } 549 }
547 550
548 if (!_ecore_con_info_ares_getnameinfo(arg, 551 if (!_ecore_con_info_ares_getnameinfo(arg,
549#ifdef HAVE_IPV6 552#ifdef HAVE_IPV6
550 arg->isv6 ? AF_INET6 : 553 arg->isv6 ? AF_INET6 :
551#endif 554#endif
552 AF_INET, 555 AF_INET,
553 NULL, addr, 556 NULL, addr,
554 addrlen)) 557 addrlen))
555 goto on_error; 558 goto on_error;
556 559
557 break; 560 break;
558 } 561 }
559 562
560 case ARES_ENOTIMP: /* unknown family */ 563 case ARES_ENOTIMP: /* unknown family */
@@ -589,10 +592,10 @@ on_error:
589 592
590static void 593static void
591_ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg, 594_ecore_con_info_ares_nameinfo(Ecore_Con_CAres *arg,
592 int status, 595 int status,
593 int timeouts EINA_UNUSED, 596 int timeouts EINA_UNUSED,
594 char *node, 597 char *node,
595 char *service) 598 char *service)
596{ 599{
597 switch (status) 600 switch (status)
598 { 601 {
diff --git a/src/lib/ecore_con/ecore_con_dns.c b/src/lib/ecore_con/ecore_con_dns.c
index 324e783776..5f602a8c05 100644
--- a/src/lib/ecore_con/ecore_con_dns.c
+++ b/src/lib/ecore_con/ecore_con_dns.c
@@ -21,12 +21,12 @@
21#include "Ecore_Con.h" 21#include "Ecore_Con.h"
22#include "ecore_con_private.h" 22#include "ecore_con_private.h"
23 23
24typedef struct dns_addrinfo dns_addrinfo; 24typedef struct dns_addrinfo dns_addrinfo;
25typedef struct dns_resolv_conf dns_resolv_conf; 25typedef struct dns_resolv_conf dns_resolv_conf;
26typedef struct dns_resolver dns_resolver; 26typedef struct dns_resolver dns_resolver;
27typedef struct dns_hosts dns_hosts; 27typedef struct dns_hosts dns_hosts;
28 28
29typedef struct _Ecore_Con_DNS Ecore_Con_DNS; 29typedef struct _Ecore_Con_DNS Ecore_Con_DNS;
30 30
31struct _Ecore_Con_DNS 31struct _Ecore_Con_DNS
32{ 32{
@@ -71,15 +71,17 @@ _ecore_con_dns_check(Ecore_Con_DNS *dns)
71{ 71{
72 struct addrinfo *ent = NULL; 72 struct addrinfo *ent = NULL;
73 int error = 0; 73 int error = 0;
74 74
75 error = dns_ai_nextent(&ent, dns->ai); 75 error = dns_ai_nextent(&ent, dns->ai);
76 76
77 switch (error) 77 switch (error)
78 { 78 {
79 case 0: 79 case 0:
80 break; 80 break;
81
81 case EAGAIN: 82 case EAGAIN:
82 return 1; 83 return 1;
84
83 default: 85 default:
84 ERR("resolve failed: %s", dns_strerror(error)); 86 ERR("resolve failed: %s", dns_strerror(error));
85 goto error; 87 goto error;
@@ -298,7 +300,6 @@ ecore_con_info_get(Ecore_Con_Server *svr,
298 { 300 {
299 ERR("res_open: %s", dns_strerror(error)); 301 ERR("res_open: %s", dns_strerror(error));
300 goto reserr; 302 goto reserr;
301
302 } 303 }
303 304
304 error = _dns_addrinfo_get(dns, svr->ecs ? svr->ecs->ip : svr->name, dns->svr->ecs ? dns->svr->ecs->port : dns->svr->port); 305 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,
312 { 313 {
313 case 0: 314 case 0:
314 break; 315 break;
316
315 case 1: 317 case 1:
316 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); 318 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);
317 svr->infos = eina_list_append(svr->infos, dns); 319 svr->infos = eina_list_append(svr->infos, dns);
318 dns->timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_dns_timer_cb, dns); 320 dns->timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_dns_timer_cb, dns);
319 break; 321 break;
322
320 default: 323 default:
321 return 0; 324 return 0;
322 } 325 }
diff --git a/src/lib/ecore_con/ecore_con_eet.c b/src/lib/ecore_con/ecore_con_eet.c
index 8f3574ae6f..6399dcf80d 100644
--- a/src/lib/ecore_con/ecore_con_eet.c
+++ b/src/lib/ecore_con/ecore_con_eet.c
@@ -17,54 +17,54 @@
17 17
18#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007 18#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007
19 19
20typedef struct _Ecore_Con_Eet_Data Ecore_Con_Eet_Data; 20typedef struct _Ecore_Con_Eet_Data Ecore_Con_Eet_Data;
21typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data; 21typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data;
22typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client; 22typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client;
23typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server; 23typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server;
24 24
25struct _Ecore_Con_Reply 25struct _Ecore_Con_Reply
26{ 26{
27 Ecore_Con_Eet *ece; 27 Ecore_Con_Eet *ece;
28 Ecore_Con_Client *client; 28 Ecore_Con_Client *client;
29 29
30 Eet_Connection *econn; 30 Eet_Connection *econn;
31 31
32 char *buffer_section; 32 char *buffer_section;
33 unsigned char *buffer; 33 unsigned char *buffer;
34 unsigned int buffer_length; 34 unsigned int buffer_length;
35 unsigned int buffer_current; 35 unsigned int buffer_current;
36 Ecore_Con_Eet_Raw_Data *buffer_handler; 36 Ecore_Con_Eet_Raw_Data *buffer_handler;
37}; 37};
38 38
39struct _Ecore_Con_Eet_Data 39struct _Ecore_Con_Eet_Data
40{ 40{
41 Ecore_Con_Eet_Data_Cb func; 41 Ecore_Con_Eet_Data_Cb func;
42 const char *name; 42 const char *name;
43 const void *data; 43 const void *data;
44}; 44};
45 45
46struct _Ecore_Con_Eet_Raw_Data 46struct _Ecore_Con_Eet_Raw_Data
47{ 47{
48 Ecore_Con_Eet_Raw_Data_Cb func; 48 Ecore_Con_Eet_Raw_Data_Cb func;
49 const char *name; 49 const char *name;
50 const void *data; 50 const void *data;
51}; 51};
52 52
53struct _Ecore_Con_Eet_Client 53struct _Ecore_Con_Eet_Client
54{ 54{
55 Ecore_Con_Eet_Client_Cb func; 55 Ecore_Con_Eet_Client_Cb func;
56 const void *data; 56 const void *data;
57}; 57};
58 58
59struct _Ecore_Con_Eet_Server 59struct _Ecore_Con_Eet_Server
60{ 60{
61 Ecore_Con_Eet_Server_Cb func; 61 Ecore_Con_Eet_Server_Cb func;
62 const void *data; 62 const void *data;
63}; 63};
64 64
65struct _Ecore_Con_Eet 65struct _Ecore_Con_Eet
66{ 66{
67 Ecore_Con_Server *server; 67 Ecore_Con_Server *server;
68 68
69 Ecore_Event_Handler *handler_add; 69 Ecore_Event_Handler *handler_add;
70 Ecore_Event_Handler *handler_del; 70 Ecore_Event_Handler *handler_del;
@@ -73,25 +73,28 @@ struct _Ecore_Con_Eet
73 Eet_Data_Descriptor *edd; 73 Eet_Data_Descriptor *edd;
74 Eet_Data_Descriptor *matching; 74 Eet_Data_Descriptor *matching;
75 75
76 Eina_Hash *data_callbacks; 76 Eina_Hash *data_callbacks;
77 Eina_Hash *raw_data_callbacks; 77 Eina_Hash *raw_data_callbacks;
78 78
79 union { 79 union
80 struct { 80 {
81 struct
82 {
81 Eina_List *connections; 83 Eina_List *connections;
82 Eina_List *client_connect_callbacks; 84 Eina_List *client_connect_callbacks;
83 Eina_List *client_disconnect_callbacks; 85 Eina_List *client_disconnect_callbacks;
84 } server; 86 } server;
85 struct { 87 struct
88 {
86 Ecore_Con_Reply *r; 89 Ecore_Con_Reply *r;
87 Eina_List *server_connect_callbacks; 90 Eina_List *server_connect_callbacks;
88 Eina_List *server_disconnect_callbacks; 91 Eina_List *server_disconnect_callbacks;
89 } client; 92 } client;
90 } u; 93 } u;
91 94
92 const void *data; 95 const void *data;
93 96
94 Eina_Bool client : 1; 97 Eina_Bool client : 1;
95}; 98};
96 99
97static void 100static void
@@ -111,6 +114,7 @@ _ecore_con_eet_raw_data_free(void *data)
111 eina_stringshare_del(eced->name); 114 eina_stringshare_del(eced->name);
112 free(eced); 115 free(eced);
113} 116}
117
114static void 118static void
115_ecore_con_eet_reply_cleanup(Ecore_Con_Reply *n) 119_ecore_con_eet_reply_cleanup(Ecore_Con_Reply *n)
116{ 120{
@@ -122,9 +126,10 @@ _ecore_con_eet_reply_cleanup(Ecore_Con_Reply *n)
122} 126}
123 127
124typedef struct _Ecore_Con_Eet_Protocol Ecore_Con_Eet_Protocol; 128typedef struct _Ecore_Con_Eet_Protocol Ecore_Con_Eet_Protocol;
125struct _Ecore_Con_Eet_Protocol { 129struct _Ecore_Con_Eet_Protocol
130{
126 const char *type; 131 const char *type;
127 void *data; 132 void *data;
128}; 133};
129 134
130static const char * 135static const char *
@@ -172,9 +177,9 @@ _ecore_con_eet_read_cb(const void *eet_data, size_t size, void *user_data)
172 if (!protocol) return EINA_TRUE; 177 if (!protocol) return EINA_TRUE;
173 178
174 cb = eina_hash_find(n->ece->data_callbacks, protocol->type); 179 cb = eina_hash_find(n->ece->data_callbacks, protocol->type);
175 if (!cb) return EINA_TRUE; /* Should I report unknow protocol communication ? */ 180 if (!cb) return EINA_TRUE; /* Should I report unknow protocol communication ? */
176 181
177 cb->func((void*)cb->data, n, cb->name, protocol->data); 182 cb->func((void *)cb->data, n, cb->name, protocol->data);
178 183
179 eina_stringshare_del(protocol->type); 184 eina_stringshare_del(protocol->type);
180 free(protocol); 185 free(protocol);
@@ -187,7 +192,7 @@ _ecore_con_eet_server_write_cb(const void *data, size_t size, void *user_data)
187{ 192{
188 Ecore_Con_Reply *n = user_data; 193 Ecore_Con_Reply *n = user_data;
189 194
190 if (ecore_con_client_send(n->client, data, size) != (int) size) 195 if (ecore_con_client_send(n->client, data, size) != (int)size)
191 return EINA_FALSE; 196 return EINA_FALSE;
192 return EINA_TRUE; 197 return EINA_TRUE;
193} 198}
@@ -197,7 +202,7 @@ _ecore_con_eet_client_write_cb(const void *data, size_t size, void *user_data)
197{ 202{
198 Ecore_Con_Reply *n = user_data; 203 Ecore_Con_Reply *n = user_data;
199 204
200 if (ecore_con_server_send(n->ece->server, data, size) != (int) size) 205 if (ecore_con_server_send(n->ece->server, data, size) != (int)size)
201 return EINA_FALSE; 206 return EINA_FALSE;
202 return EINA_TRUE; 207 return EINA_TRUE;
203} 208}
@@ -222,7 +227,7 @@ _ecore_con_eet_server_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
222 ecore_con_client_data_set(n->client, n); 227 ecore_con_client_data_set(n->client, n);
223 228
224 EINA_LIST_FOREACH(r->u.server.client_connect_callbacks, ll, ecec) 229 EINA_LIST_FOREACH(r->u.server.client_connect_callbacks, ll, ecec)
225 if (!ecec->func((void*) ecec->data, n, n->client)) 230 if (!ecec->func((void *)ecec->data, n, n->client))
226 { 231 {
227 eet_connection_close(n->econn, NULL); 232 eet_connection_close(n->econn, NULL);
228 free(n); 233 free(n);
@@ -251,7 +256,7 @@ _ecore_con_eet_server_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_E
251 Eina_List *ll; 256 Eina_List *ll;
252 257
253 EINA_LIST_FOREACH(r->u.server.client_disconnect_callbacks, ll, ecec) 258 EINA_LIST_FOREACH(r->u.server.client_disconnect_callbacks, ll, ecec)
254 ecec->func((void*) ecec->data, n, n->client); 259 ecec->func((void *)ecec->data, n, n->client);
255 260
256 eet_connection_close(n->econn, NULL); 261 eet_connection_close(n->econn, NULL);
257 free(n); 262 free(n);
@@ -272,7 +277,7 @@ _ecore_con_eet_raw_data_push(Ecore_Con_Reply *n, void *data, int size)
272 if (n->buffer_current == n->buffer_length) 277 if (n->buffer_current == n->buffer_length)
273 { 278 {
274 if (n->buffer_handler) 279 if (n->buffer_handler)
275 n->buffer_handler->func((void*) n->buffer_handler->data, n, n->buffer_handler->name, n->buffer_section, n->buffer, n->buffer_length); 280 n->buffer_handler->func((void *)n->buffer_handler->data, n, n->buffer_handler->name, n->buffer_section, n->buffer, n->buffer_length);
276 _ecore_con_eet_reply_cleanup(n); 281 _ecore_con_eet_reply_cleanup(n);
277 } 282 }
278} 283}
@@ -292,7 +297,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
292 _ecore_con_eet_raw_data_push(n, data, size); 297 _ecore_con_eet_raw_data_push(n, data, size);
293 return; 298 return;
294 } 299 }
295 else if (eet_connection_empty(n->econn) && size > (int) (4 * sizeof (unsigned int) + 2)) 300 else if (eet_connection_empty(n->econn) && size > (int)(4 * sizeof (unsigned int) + 2))
296 { 301 {
297 unsigned int *tmp = data; 302 unsigned int *tmp = data;
298 size -= 4 * sizeof (unsigned int); 303 size -= 4 * sizeof (unsigned int);
@@ -305,7 +310,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
305 310
306 if (protocol_length > 1 && section_length > 1 && protocol_length + section_length <= size && data_length < 10 * 1024 * 1024) 311 if (protocol_length > 1 && section_length > 1 && protocol_length + section_length <= size && data_length < 10 * 1024 * 1024)
307 { 312 {
308 char *buffer = (char*) &tmp[4]; 313 char *buffer = (char *)&tmp[4];
309 char *protocol; 314 char *protocol;
310 char *section; 315 char *section;
311 316
@@ -325,7 +330,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
325 if (n->buffer_handler) 330 if (n->buffer_handler)
326 n->buffer = malloc(sizeof (unsigned char) * data_length); 331 n->buffer = malloc(sizeof (unsigned char) * data_length);
327 else 332 else
328 n->buffer = (void*) 1; 333 n->buffer = (void *)1;
329 if (n->buffer) 334 if (n->buffer)
330 { 335 {
331 _ecore_con_eet_raw_data_push(n, buffer, size); 336 _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
382 n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_client_write_cb, n); 387 n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_client_write_cb, n);
383 388
384 EINA_LIST_FOREACH(r->u.client.server_connect_callbacks, ll, eces) 389 EINA_LIST_FOREACH(r->u.client.server_connect_callbacks, ll, eces)
385 if (!eces->func((void*) eces->data, n, n->ece->server)) 390 if (!eces->func((void *)eces->data, n, n->ece->server))
386 { 391 {
387 eet_connection_close(n->econn, NULL); 392 eet_connection_close(n->econn, NULL);
388 free(n); 393 free(n);
@@ -406,7 +411,7 @@ _ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_E
406 411
407 /* Client disconnected */ 412 /* Client disconnected */
408 EINA_LIST_FOREACH(r->u.client.server_disconnect_callbacks, ll, eces) 413 EINA_LIST_FOREACH(r->u.client.server_disconnect_callbacks, ll, eces)
409 eces->func((void*) eces->data, r->u.client.r, r->server); 414 eces->func((void *)eces->data, r->u.client.r, r->server);
410 415
411 eet_connection_close(r->u.client.r->econn, NULL); 416 eet_connection_close(r->u.client.r->econn, NULL);
412 free(r->u.client.r); 417 free(r->u.client.r);
@@ -430,8 +435,8 @@ _ecore_con_eet_client_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Ser
430} 435}
431 436
432/************** 437/**************
433 * Global API * 438* Global API *
434 **************/ 439**************/
435 440
436EAPI Ecore_Con_Eet * 441EAPI Ecore_Con_Eet *
437ecore_con_eet_server_new(Ecore_Con_Server *server) 442ecore_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_
578 eced->data = data; 583 eced->data = data;
579 eced->name = eina_stringshare_add(name); 584 eced->name = eina_stringshare_add(name);
580 585
581 eina_hash_direct_add(ece->raw_data_callbacks, eced->name, eced); 586 eina_hash_direct_add(ece->raw_data_callbacks, eced->name, eced);
582} 587}
583 588
584EAPI void 589EAPI void
@@ -590,7 +595,7 @@ ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name)
590 { 595 {
591 ece->u.client.r->buffer_handler = NULL; 596 ece->u.client.r->buffer_handler = NULL;
592 free(ece->u.client.r->buffer); 597 free(ece->u.client.r->buffer);
593 ece->u.client.r->buffer = (void*) 1; 598 ece->u.client.r->buffer = (void *)1;
594 } 599 }
595 eina_hash_del(ece->raw_data_callbacks, name, NULL); 600 eina_hash_del(ece->raw_data_callbacks, name, NULL);
596} 601}
@@ -740,7 +745,7 @@ EAPI void *
740ecore_con_eet_data_get(Ecore_Con_Eet *ece) 745ecore_con_eet_data_get(Ecore_Con_Eet *ece)
741{ 746{
742 if (!ece) return NULL; 747 if (!ece) return NULL;
743 return (void*) ece->data; 748 return (void *)ece->data;
744} 749}
745 750
746EAPI Ecore_Con_Eet * 751EAPI Ecore_Con_Eet *
diff --git a/src/lib/ecore_con/ecore_con_info.c b/src/lib/ecore_con/ecore_con_info.c
index 62a1836d21..76fd6c730d 100644
--- a/src/lib/ecore_con/ecore_con_info.c
+++ b/src/lib/ecore_con/ecore_con_info.c
@@ -45,7 +45,7 @@ typedef struct _CB_Data CB_Data;
45 45
46struct _CB_Data 46struct _CB_Data
47{ 47{
48 EINA_INLIST; 48 EINA_INLIST;
49 Ecore_Con_Info_Cb cb_done; 49 Ecore_Con_Info_Cb cb_done;
50 void *data; 50 void *data;
51 Ecore_Fd_Handler *fdh; 51 Ecore_Fd_Handler *fdh;
@@ -56,11 +56,11 @@ struct _CB_Data
56 56
57static void _ecore_con_info_readdata(CB_Data *cbdata); 57static void _ecore_con_info_readdata(CB_Data *cbdata);
58static void _ecore_con_info_slave_free(CB_Data *cbdata); 58static void _ecore_con_info_slave_free(CB_Data *cbdata);
59static Eina_Bool _ecore_con_info_data_handler(void *data, 59static Eina_Bool _ecore_con_info_data_handler(void *data,
60 Ecore_Fd_Handler *fd_handler); 60 Ecore_Fd_Handler *fd_handler);
61static Eina_Bool _ecore_con_info_exit_handler(void *data, 61static Eina_Bool _ecore_con_info_exit_handler(void *data,
62 int type EINA_UNUSED, 62 int type EINA_UNUSED,
63 void *event); 63 void *event);
64 64
65static int info_init = 0; 65static int info_init = 0;
66static CB_Data *info_slaves = NULL; 66static CB_Data *info_slaves = NULL;
@@ -77,7 +77,8 @@ ecore_con_info_shutdown(void)
77{ 77{
78 info_init--; 78 info_init--;
79 if (info_init == 0) 79 if (info_init == 0)
80 while (info_slaves) _ecore_con_info_slave_free(info_slaves); 80 while (info_slaves)
81 _ecore_con_info_slave_free(info_slaves);
81 82
82 return info_init; 83 return info_init;
83} 84}
@@ -85,7 +86,7 @@ ecore_con_info_shutdown(void)
85int 86int
86ecore_con_info_tcp_connect(Ecore_Con_Server *svr, 87ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
87 Ecore_Con_Info_Cb done_cb, 88 Ecore_Con_Info_Cb done_cb,
88 void *data) 89 void *data)
89{ 90{
90 struct addrinfo hints; 91 struct addrinfo hints;
91 92
@@ -104,7 +105,7 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
104int 105int
105ecore_con_info_tcp_listen(Ecore_Con_Server *svr, 106ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
106 Ecore_Con_Info_Cb done_cb, 107 Ecore_Con_Info_Cb done_cb,
107 void *data) 108 void *data)
108{ 109{
109 struct addrinfo hints; 110 struct addrinfo hints;
110 111
@@ -123,7 +124,7 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
123int 124int
124ecore_con_info_udp_connect(Ecore_Con_Server *svr, 125ecore_con_info_udp_connect(Ecore_Con_Server *svr,
125 Ecore_Con_Info_Cb done_cb, 126 Ecore_Con_Info_Cb done_cb,
126 void *data) 127 void *data)
127{ 128{
128 struct addrinfo hints; 129 struct addrinfo hints;
129 130
@@ -142,7 +143,7 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
142int 143int
143ecore_con_info_udp_listen(Ecore_Con_Server *svr, 144ecore_con_info_udp_listen(Ecore_Con_Server *svr,
144 Ecore_Con_Info_Cb done_cb, 145 Ecore_Con_Info_Cb done_cb,
145 void *data) 146 void *data)
146{ 147{
147 struct addrinfo hints; 148 struct addrinfo hints;
148 149
@@ -161,7 +162,7 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
161int 162int
162ecore_con_info_mcast_listen(Ecore_Con_Server *svr, 163ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
163 Ecore_Con_Info_Cb done_cb, 164 Ecore_Con_Info_Cb done_cb,
164 void *data) 165 void *data)
165{ 166{
166 struct addrinfo hints; 167 struct addrinfo hints;
167 168
@@ -192,7 +193,7 @@ _ecore_fd_close_on_exec(int fd)
192 return EINA_FALSE; 193 return EINA_FALSE;
193 return EINA_TRUE; 194 return EINA_TRUE;
194#else 195#else
195 (void) fd; 196 (void)fd;
196 return EINA_FALSE; 197 return EINA_FALSE;
197#endif 198#endif
198} 199}
@@ -200,8 +201,8 @@ _ecore_fd_close_on_exec(int fd)
200EAPI int 201EAPI int
201ecore_con_info_get(Ecore_Con_Server *svr, 202ecore_con_info_get(Ecore_Con_Server *svr,
202 Ecore_Con_Info_Cb done_cb, 203 Ecore_Con_Info_Cb done_cb,
203 void *data, 204 void *data,
204 struct addrinfo *hints) 205 struct addrinfo *hints)
205{ 206{
206 CB_Data *cbdata; 207 CB_Data *cbdata;
207 int fd[2]; 208 int fd[2];
@@ -407,7 +408,7 @@ _ecore_con_info_slave_free(CB_Data *cbdata)
407} 408}
408 409
409static Eina_Bool 410static Eina_Bool
410_ecore_con_info_data_handler(void *data, 411_ecore_con_info_data_handler(void *data,
411 Ecore_Fd_Handler *fd_handler) 412 Ecore_Fd_Handler *fd_handler)
412{ 413{
413 CB_Data *cbdata; 414 CB_Data *cbdata;
@@ -434,9 +435,9 @@ _ecore_con_info_data_handler(void *data,
434} 435}
435 436
436static Eina_Bool 437static Eina_Bool
437_ecore_con_info_exit_handler(void *data, 438_ecore_con_info_exit_handler(void *data,
438 int type EINA_UNUSED, 439 int type EINA_UNUSED,
439 void *event) 440 void *event)
440{ 441{
441 CB_Data *cbdata; 442 CB_Data *cbdata;
442 Ecore_Exe_Event_Del *ev; 443 Ecore_Exe_Event_Del *ev;
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index 54dde177bc..29863ccb72 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -181,10 +181,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
181int 181int
182ecore_con_local_listen( 182ecore_con_local_listen(
183 Ecore_Con_Server *svr, 183 Ecore_Con_Server *svr,
184 Eina_Bool (* 184 Eina_Bool (*
185 cb_listen)(void *data, 185 cb_listen)(void *data,
186 Ecore_Fd_Handler * 186 Ecore_Fd_Handler *
187 fd_handler), 187 fd_handler),
188 void *data 188 void *data
189 EINA_UNUSED) 189 EINA_UNUSED)
190{ 190{
@@ -291,28 +291,28 @@ start:
291 if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max) 291 if (svr->type & ECORE_CON_SOCKET_ACTIVATE && sd_fd_index < sd_fd_max)
292 { 292 {
293 if (sd_is_socket_unix(SD_LISTEN_FDS_START + sd_fd_index, 293 if (sd_is_socket_unix(SD_LISTEN_FDS_START + sd_fd_index,
294 SOCK_STREAM, 1, 294 SOCK_STREAM, 1,
295 socket_unix.sun_path, 295 socket_unix.sun_path,
296 abstract_socket ? socket_unix_len : 0) <= 0) 296 abstract_socket ? socket_unix_len : 0) <= 0)
297 { 297 {
298 ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation."); 298 ERR("Your systemd unit seems to provide fd in the wrong order for Socket activation.");
299 goto error_umask; 299 goto error_umask;
300 } 300 }
301 svr->fd = SD_LISTEN_FDS_START + sd_fd_index++; 301 svr->fd = SD_LISTEN_FDS_START + sd_fd_index++;
302 302
303 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) 303 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
304 goto error_umask; 304 goto error_umask;
305 305
306 lin.l_onoff = 1; 306 lin.l_onoff = 1;
307 lin.l_linger = 0; 307 lin.l_linger = 0;
308 if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin, 308 if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
309 sizeof(struct linger)) < 0) 309 sizeof(struct linger)) < 0)
310 goto error_umask; 310 goto error_umask;
311 311
312 goto fd_ready; 312 goto fd_ready;
313 } 313 }
314#else 314#else
315 (void) abstract_socket; 315 (void)abstract_socket;
316#endif 316#endif
317 svr->fd = socket(AF_UNIX, SOCK_STREAM, 0); 317 svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
318 if (svr->fd < 0) 318 if (svr->fd < 0)
@@ -346,7 +346,7 @@ start:
346 goto error_umask; 346 goto error_umask;
347 347
348#ifdef HAVE_SYSTEMD 348#ifdef HAVE_SYSTEMD
349 fd_ready: 349fd_ready:
350#endif 350#endif
351 svr->path = strdup(buf); 351 svr->path = strdup(buf);
352 if (!svr->path) 352 if (!svr->path)
diff --git a/src/lib/ecore_con/ecore_con_local_win32.c b/src/lib/ecore_con/ecore_con_local_win32.c
index 2b7e5c5bd2..0eed03e875 100644
--- a/src/lib/ecore_con/ecore_con_local_win32.c
+++ b/src/lib/ecore_con/ecore_con_local_win32.c
@@ -12,7 +12,6 @@
12 12
13#define BUFSIZE 512 13#define BUFSIZE 512
14 14
15
16static int _ecore_con_local_init_count = 0; 15static int _ecore_con_local_init_count = 0;
17 16
18int 17int
@@ -33,58 +32,57 @@ ecore_con_local_shutdown(void)
33 return _ecore_con_local_init_count; 32 return _ecore_con_local_init_count;
34} 33}
35 34
36
37static Eina_Bool 35static Eina_Bool
38_ecore_con_local_win32_server_read_client_handler(void *data, Ecore_Win32_Handler *wh) 36_ecore_con_local_win32_server_read_client_handler(void *data, Ecore_Win32_Handler *wh)
39{ 37{
40 Ecore_Con_Client *cl; 38 Ecore_Con_Client *cl;
41 void *buf; 39 void *buf;
42 DWORD n; 40 DWORD n;
43 Eina_Bool broken_pipe = EINA_FALSE; 41 Eina_Bool broken_pipe = EINA_FALSE;
44 42
45 cl = (Ecore_Con_Client *)data; 43 cl = (Ecore_Con_Client *)data;
46 44
47 if (!ResetEvent(cl->host_server->event_read)) 45 if (!ResetEvent(cl->host_server->event_read))
48 return ECORE_CALLBACK_RENEW; 46 return ECORE_CALLBACK_RENEW;
49 47
50 buf = malloc(cl->host_server->nbr_bytes); 48 buf = malloc(cl->host_server->nbr_bytes);
51 if (!buf) 49 if (!buf)
52 return ECORE_CALLBACK_RENEW; 50 return ECORE_CALLBACK_RENEW;
53 51
54 if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL)) 52 if (ReadFile(cl->host_server->pipe, buf, cl->host_server->nbr_bytes, &n, NULL))
55 { 53 {
56 if (!cl->delete_me) 54 if (!cl->delete_me)
57 ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE); 55 ecore_con_event_client_data(cl, buf, cl->host_server->nbr_bytes, EINA_FALSE);
58 cl->host_server->want_write = 1; 56 cl->host_server->want_write = 1;
59 } 57 }
60 else 58 else
61 { 59 {
62 if (GetLastError() == ERROR_BROKEN_PIPE) 60 if (GetLastError() == ERROR_BROKEN_PIPE)
63 broken_pipe = EINA_TRUE; 61 broken_pipe = EINA_TRUE;
64 } 62 }
65 63
66 if (broken_pipe) 64 if (broken_pipe)
67 { 65 {
68#if 0 66#if 0
69 char *msg; 67 char *msg;
70 68
71 msg = evil_last_error_get(); 69 msg = evil_last_error_get();
72 if (msg) 70 if (msg)
73 { 71 {
74 ecore_con_event_client_error(cl, msg); 72 ecore_con_event_client_error(cl, msg);
75 free(msg); 73 free(msg);
76 } 74 }
77#endif 75#endif
78 _ecore_con_client_kill(cl); 76 _ecore_con_client_kill(cl);
79 return ECORE_CALLBACK_CANCEL; 77 return ECORE_CALLBACK_CANCEL;
80 } 78 }
81 79
82 if (cl->host_server->want_write) 80 if (cl->host_server->want_write)
83 ecore_con_local_win32_client_flush(cl); 81 ecore_con_local_win32_client_flush(cl);
84 82
85 ecore_main_win32_handler_del(wh); 83 ecore_main_win32_handler_del(wh);
86 84
87 return ECORE_CALLBACK_DONE; 85 return ECORE_CALLBACK_DONE;
88} 86}
89 87
90static Eina_Bool 88static Eina_Bool
@@ -147,54 +145,54 @@ _ecore_con_local_win32_client_peek_server_handler(void *data, Ecore_Win32_Handle
147static Eina_Bool 145static Eina_Bool
148_ecore_con_local_win32_client_read_server_handler(void *data, Ecore_Win32_Handler *wh) 146_ecore_con_local_win32_client_read_server_handler(void *data, Ecore_Win32_Handler *wh)
149{ 147{
150 Ecore_Con_Server *svr; 148 Ecore_Con_Server *svr;
151 void *buf; 149 void *buf;
152 DWORD n; 150 DWORD n;
153 Eina_Bool broken_pipe = EINA_FALSE; 151 Eina_Bool broken_pipe = EINA_FALSE;
154 152
155 svr = (Ecore_Con_Server *)data; 153 svr = (Ecore_Con_Server *)data;
156 154
157 if (!ResetEvent(svr->event_read)) 155 if (!ResetEvent(svr->event_read))
158 return ECORE_CALLBACK_RENEW; 156 return ECORE_CALLBACK_RENEW;
159 157
160 buf = malloc(svr->nbr_bytes); 158 buf = malloc(svr->nbr_bytes);
161 if (!buf) 159 if (!buf)
162 return ECORE_CALLBACK_RENEW; 160 return ECORE_CALLBACK_RENEW;
163 161
164 if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL)) 162 if (ReadFile(svr->pipe, buf, svr->nbr_bytes, &n, NULL))
165 { 163 {
166 if (!svr->delete_me) 164 if (!svr->delete_me)
167 ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE); 165 ecore_con_event_server_data(svr, buf, svr->nbr_bytes, EINA_FALSE);
168 svr->want_write = 1; 166 svr->want_write = 1;
169 } 167 }
170 else 168 else
171 { 169 {
172 if (GetLastError() == ERROR_BROKEN_PIPE) 170 if (GetLastError() == ERROR_BROKEN_PIPE)
173 broken_pipe = EINA_TRUE; 171 broken_pipe = EINA_TRUE;
174 } 172 }
175 173
176 if (broken_pipe) 174 if (broken_pipe)
177 { 175 {
178#if 0 176#if 0
179 char *msg; 177 char *msg;
180 178
181 msg = evil_last_error_get(); 179 msg = evil_last_error_get();
182 if (msg) 180 if (msg)
183 { 181 {
184 ecore_con_event_server_error(svr, msg); 182 ecore_con_event_server_error(svr, msg);
185 free(msg); 183 free(msg);
186 } 184 }
187#endif 185#endif
188 _ecore_con_server_kill(svr); 186 _ecore_con_server_kill(svr);
189 return ECORE_CALLBACK_CANCEL; 187 return ECORE_CALLBACK_CANCEL;
190 } 188 }
191 189
192 if (svr->want_write) 190 if (svr->want_write)
193 ecore_con_local_win32_server_flush(svr); 191 ecore_con_local_win32_server_flush(svr);
194 192
195 ecore_main_win32_handler_del(wh); 193 ecore_main_win32_handler_del(wh);
196 194
197 return ECORE_CALLBACK_DONE; 195 return ECORE_CALLBACK_DONE;
198} 196}
199 197
200/* thread to read data sent by the server to the client */ 198/* 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)
356 ResumeThread(cl->host_server->thread_read); 354 ResumeThread(cl->host_server->thread_read);
357 return ECORE_CALLBACK_DONE; 355 return ECORE_CALLBACK_DONE;
358 356
359 del_handler_peek: 357del_handler_peek:
360 ecore_main_win32_handler_del(handler_peek); 358 ecore_main_win32_handler_del(handler_peek);
361 close_event_peek: 359close_event_peek:
362 CloseHandle(cl->host_server->event_peek); 360 CloseHandle(cl->host_server->event_peek);
363 del_handler_read: 361del_handler_read:
364 ecore_main_win32_handler_del(handler_read); 362 ecore_main_win32_handler_del(handler_read);
365 close_event_read: 363close_event_read:
366 CloseHandle(cl->host_server->event_read); 364 CloseHandle(cl->host_server->event_read);
367 free_cl: 365free_cl:
368 free(cl); 366 free(cl);
369 367
370 return ECORE_CALLBACK_CANCEL; 368 return ECORE_CALLBACK_CANCEL;
@@ -472,11 +470,11 @@ ecore_con_local_listen(Ecore_Con_Server *svr)
472 470
473 return EINA_TRUE; 471 return EINA_TRUE;
474 472
475 del_handler: 473del_handler:
476 ecore_main_win32_handler_del(handler); 474 ecore_main_win32_handler_del(handler);
477 close_pipe: 475close_pipe:
478 CloseHandle(svr->pipe); 476 CloseHandle(svr->pipe);
479 free_path: 477free_path:
480 free(svr->path); 478 free(svr->path);
481 svr->path = NULL; 479 svr->path = NULL;
482 480
@@ -579,7 +577,7 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
579 { 577 {
580 ERR("Connection to a server failed"); 578 ERR("Connection to a server failed");
581 return EINA_FALSE; 579 return EINA_FALSE;
582 } 580 }
583 581
584 /* pipe busy, so we wait for it */ 582 /* pipe busy, so we wait for it */
585 if (!WaitNamedPipe(buf, NMPWAIT_WAIT_FOREVER)) 583 if (!WaitNamedPipe(buf, NMPWAIT_WAIT_FOREVER))
@@ -641,18 +639,18 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
641 639
642 return EINA_TRUE; 640 return EINA_TRUE;
643 641
644 del_handler_peek: 642del_handler_peek:
645 ecore_main_win32_handler_del(handler_peek); 643 ecore_main_win32_handler_del(handler_peek);
646 close_event_peek: 644close_event_peek:
647 CloseHandle(svr->event_peek); 645 CloseHandle(svr->event_peek);
648 del_handler_read: 646del_handler_read:
649 ecore_main_win32_handler_del(handler_read); 647 ecore_main_win32_handler_del(handler_read);
650 close_event_read: 648close_event_read:
651 CloseHandle(svr->event_read); 649 CloseHandle(svr->event_read);
652 free_path: 650free_path:
653 free(svr->path); 651 free(svr->path);
654 svr->path = NULL; 652 svr->path = NULL;
655 close_pipe: 653close_pipe:
656 CloseHandle(svr->pipe); 654 CloseHandle(svr->pipe);
657 655
658 return EINA_FALSE; 656 return EINA_FALSE;
@@ -752,3 +750,4 @@ ecore_con_local_win32_client_flush(Ecore_Con_Client *cl)
752 750
753 return EINA_TRUE; 751 return EINA_TRUE;
754} 752}
753
diff --git a/src/lib/ecore_con/ecore_con_socks.c b/src/lib/ecore_con/ecore_con_socks.c
index d4adfdc78d..345144419e 100644
--- a/src/lib/ecore_con/ecore_con_socks.c
+++ b/src/lib/ecore_con/ecore_con_socks.c
@@ -48,7 +48,7 @@
48#include "ecore_con_private.h" 48#include "ecore_con_private.h"
49 49
50#if defined(_WIN32) && !defined(IF_NAMESIZE) 50#if defined(_WIN32) && !defined(IF_NAMESIZE)
51#define IF_NAMESIZE 16 51#define IF_NAMESIZE 16
52#endif 52#endif
53 53
54/* http://tools.ietf.org/html/rfc1928 54/* http://tools.ietf.org/html/rfc1928
@@ -58,9 +58,9 @@
58 o X'03' to X'7F' IANA ASSIGNED 58 o X'03' to X'7F' IANA ASSIGNED
59 o X'80' to X'FE' RESERVED FOR PRIVATE METHODS 59 o X'80' to X'FE' RESERVED FOR PRIVATE METHODS
60 o X'FF' NO ACCEPTABLE METHODS 60 o X'FF' NO ACCEPTABLE METHODS
61*/ 61 */
62#define ECORE_CON_SOCKS_V5_METHOD_NONE 0 62#define ECORE_CON_SOCKS_V5_METHOD_NONE 0
63#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1 63#define ECORE_CON_SOCKS_V5_METHOD_GSSAPI 1
64#define ECORE_CON_SOCKS_V5_METHOD_USERPASS 2 64#define ECORE_CON_SOCKS_V5_METHOD_USERPASS 2
65 65
66static int ECORE_CON_SOCKS_V5_METHODS[] = 66static int ECORE_CON_SOCKS_V5_METHODS[] =
@@ -72,27 +72,27 @@ static int ECORE_CON_SOCKS_V5_METHODS[] =
72 72
73#define ECORE_CON_SOCKS_V5_TOTAL_METHODS (sizeof(ECORE_CON_SOCKS_V5_METHODS) / sizeof(int)) 73#define ECORE_CON_SOCKS_V5_TOTAL_METHODS (sizeof(ECORE_CON_SOCKS_V5_METHODS) / sizeof(int))
74 74
75#define _ecore_con_server_kill(svr) do { \ 75#define _ecore_con_server_kill(svr) do { \
76 DBG("KILL %p", (svr)); \ 76 DBG("KILL %p", (svr)); \
77 _ecore_con_server_kill((svr)); \ 77 _ecore_con_server_kill((svr)); \
78} while (0) 78 } while (0)
79 79
80#define ECORE_CON_SOCKS_VERSION_CHECK(X) do { \ 80#define ECORE_CON_SOCKS_VERSION_CHECK(X) do { \
81 if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \ 81 if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
82 return; \ 82 return; \
83} while (0) 83 } while (0)
84#define ECORE_CON_SOCKS_VERSION_CHECK_RETURN(X, ret) do { \ 84#define ECORE_CON_SOCKS_VERSION_CHECK_RETURN(X, ret) do { \
85 if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \ 85 if (!(X) || ((X)->version < 4) || ((X)->version > 5)) \
86 return (ret); \ 86 return (ret); \
87} while (0) 87 } while (0)
88 88
89#define ECORE_CON_SOCKS_CAST(X) \ 89#define ECORE_CON_SOCKS_CAST(X) \
90 Ecore_Con_Socks_v4 *v4 = NULL; \ 90 Ecore_Con_Socks_v4 * v4 = NULL; \
91 Ecore_Con_Socks_v5 *v5 = NULL; \ 91 Ecore_Con_Socks_v5 *v5 = NULL; \
92 if ((X) && ((X)->version == 4)) \ 92 if ((X) && ((X)->version == 4)) \
93 v4 = (Ecore_Con_Socks_v4 *)(X); \ 93 v4 = (Ecore_Con_Socks_v4 *)(X); \
94 else if ((X) && ((X)->version == 5)) \ 94 else if ((X) && ((X)->version == 5)) \
95 v5 = (Ecore_Con_Socks_v5 *)(X); 95 v5 = (Ecore_Con_Socks_v5 *)(X);
96 96
97Eina_List *ecore_con_socks_proxies = NULL; 97Eina_List *ecore_con_socks_proxies = NULL;
98 98
@@ -116,7 +116,7 @@ _ecore_con_socks_find(unsigned char version, const char *ip, int port, const cha
116 if (plen != ecs->plen) continue; 116 if (plen != ecs->plen) continue;
117 if (password && strcmp(ecs->password, password)) continue; 117 if (password && strcmp(ecs->password, password)) continue;
118 } 118 }
119 return (Ecore_Con_Socks*)ecs; 119 return (Ecore_Con_Socks *)ecs;
120 } 120 }
121 return NULL; 121 return NULL;
122} 122}
@@ -141,7 +141,7 @@ _ecore_con_socks_svr_init_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4)
141 141
142 addrlen = v4->lookup ? strlen(svr->name) + 1 : 0; 142 addrlen = v4->lookup ? strlen(svr->name) + 1 : 0;
143 if (v4->username) ulen += v4->ulen; 143 if (v4->username) ulen += v4->ulen;
144 buflen = sizeof(char) * (8 + ulen + addrlen); 144 buflen = sizeof(char) * (8 + ulen + addrlen);
145 sbuf = malloc(buflen); 145 sbuf = malloc(buflen);
146 if (!sbuf) 146 if (!sbuf)
147 { 147 {
@@ -180,7 +180,7 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
180 unsigned char *sbuf; 180 unsigned char *sbuf;
181 181
182 if (v5->username) 182 if (v5->username)
183 buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS); 183 buflen = sizeof(char) * (2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS);
184 else 184 else
185 buflen = 3; 185 buflen = 3;
186 sbuf = malloc(buflen); 186 sbuf = malloc(buflen);
@@ -196,9 +196,9 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
196 sbuf[0] = 5; 196 sbuf[0] = 5;
197 if (v5->username) 197 if (v5->username)
198 { 198 {
199 sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS; 199 sbuf[1] = ECORE_CON_SOCKS_V5_TOTAL_METHODS;
200 for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++) 200 for (x = 2; x < 2 + ECORE_CON_SOCKS_V5_TOTAL_METHODS; x++)
201 sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2]; 201 sbuf[x] = ECORE_CON_SOCKS_V5_METHODS[x - 2];
202 } 202 }
203 else 203 else
204 { 204 {
@@ -210,19 +210,20 @@ _ecore_con_socks_svr_init_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
210 return EINA_TRUE; 210 return EINA_TRUE;
211} 211}
212 212
213#define ECORE_CON_SOCKS_READ(EXACT) \ 213#define ECORE_CON_SOCKS_READ(EXACT) \
214 if (num < EXACT) \ 214 if (num < EXACT) \
215 { \ 215 { \
216 if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \ 216 if (!svr->ecs_recvbuf) svr->ecs_recvbuf = eina_binbuf_new(); \
217 if (!svr->ecs_recvbuf) goto error; \ 217 if (!svr->ecs_recvbuf) goto error; \
218 eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \ 218 eina_binbuf_append_length(svr->ecs_recvbuf, buf, num); \
219 /* the slowest connection on earth */ \ 219 /* the slowest connection on earth */ \
220 if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \ 220 if (eina_binbuf_length_get(svr->ecs_recvbuf) != EXACT) return; \
221 data = eina_binbuf_string_get(svr->ecs_recvbuf); \ 221 data = eina_binbuf_string_get(svr->ecs_recvbuf); \
222 } \ 222 } \
223 else if (num > EXACT) goto error; \ 223 else if (num > EXACT) \
224 else \ 224 goto error; \
225 data = buf 225 else \
226 data = buf
226 227
227static void 228static void
228_ecore_con_socks_read_v4(Ecore_Con_Server *svr, Ecore_Con_Socks_v4 *v4 EINA_UNUSED, const unsigned char *buf, unsigned int num) 229_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
238 case 90: 239 case 90:
239 /* success! */ 240 /* success! */
240 break; 241 break;
242
241 case 91: 243 case 91:
242 ecore_con_event_server_error(svr, "proxy request rejected or failed"); 244 ecore_con_event_server_error(svr, "proxy request rejected or failed");
243 goto error; 245 goto error;
246
244 case 92: 247 case 92:
245 ecore_con_event_server_error(svr, "proxying SOCKS server could not perform authentication"); 248 ecore_con_event_server_error(svr, "proxying SOCKS server could not perform authentication");
246 goto error; 249 goto error;
250
247 case 93: 251 case 93:
248 ecore_con_event_server_error(svr, "proxy request authentication rejected"); 252 ecore_con_event_server_error(svr, "proxy request authentication rejected");
249 goto error; 253 goto error;
254
250 default: 255 default:
251 ecore_con_event_server_error(svr, "garbage data from proxy"); 256 ecore_con_event_server_error(svr, "garbage data from proxy");
252 goto error; 257 goto error;
@@ -285,30 +290,33 @@ _ecore_con_socks_auth_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5)
285 unsigned char *data; 290 unsigned char *data;
286 switch (v5->method) 291 switch (v5->method)
287 { 292 {
288 case ECORE_CON_SOCKS_V5_METHOD_NONE: 293 case ECORE_CON_SOCKS_V5_METHOD_NONE:
289 svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST; 294 svr->ecs_state = ECORE_CON_PROXY_STATE_REQUEST;
290 return EINA_TRUE; 295 return EINA_TRUE;
291 case ECORE_CON_SOCKS_V5_METHOD_GSSAPI: 296
292 return EINA_TRUE; 297 case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
293 case ECORE_CON_SOCKS_V5_METHOD_USERPASS: 298 return EINA_TRUE;
294 if (!v5->username) return EINA_FALSE; 299
295 if (!v5->password) v5->plen = 1; 300 case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
296 /* http://tools.ietf.org/html/rfc1929 */ 301 if (!v5->username) return EINA_FALSE;
297 size = sizeof(char) * (3 + v5->ulen + v5->plen); 302 if (!v5->password) v5->plen = 1;
298 data = malloc(size); 303 /* http://tools.ietf.org/html/rfc1929 */
299 if (!data) break; 304 size = sizeof(char) * (3 + v5->ulen + v5->plen);
300 data[0] = 1; 305 data = malloc(size);
301 data[1] = v5->ulen; 306 if (!data) break;
302 memcpy(&data[2], v5->username, v5->ulen); 307 data[0] = 1;
303 data[1 + v5->ulen] = v5->plen; 308 data[1] = v5->ulen;
304 if (v5->password) 309 memcpy(&data[2], v5->username, v5->ulen);
305 memcpy(&data[2 + v5->ulen], v5->password, v5->plen); 310 data[1 + v5->ulen] = v5->plen;
306 else 311 if (v5->password)
307 data[2 + v5->ulen] = 0; 312 memcpy(&data[2 + v5->ulen], v5->password, v5->plen);
308 svr->ecs_buf = eina_binbuf_manage_new_length(data, size); 313 else
309 return EINA_TRUE; 314 data[2 + v5->ulen] = 0;
310 default: 315 svr->ecs_buf = eina_binbuf_manage_new_length(data, size);
311 break; 316 return EINA_TRUE;
317
318 default:
319 break;
312 } 320 }
313 return EINA_FALSE; 321 return EINA_FALSE;
314} 322}
@@ -321,179 +329,197 @@ _ecore_con_socks_read_v5(Ecore_Con_Server *svr, Ecore_Con_Socks_v5 *v5, const un
321 DBG("SOCKS: %d bytes", num); 329 DBG("SOCKS: %d bytes", num);
322 switch (svr->ecs_state) 330 switch (svr->ecs_state)
323 { 331 {
324 332 case ECORE_CON_PROXY_STATE_READ:
325 case ECORE_CON_PROXY_STATE_READ: 333 ECORE_CON_SOCKS_READ(2);
326 ECORE_CON_SOCKS_READ(2); 334 /* http://en.wikipedia.org/wiki/SOCKS */
327 /* http://en.wikipedia.org/wiki/SOCKS */ 335 if (data[0] != 5) goto error;
328 if (data[0] != 5) goto error; 336 if (data[1] == 0xFF)
329 if (data[1] == 0xFF)
330 {
331 ecore_con_event_server_error(svr, "proxy authentication methods rejected");
332 goto error;
333 }
334 v5->method = data[1];
335 if (!_ecore_con_socks_auth_v5(svr, v5)) goto error;
336 if (svr->ecs_state == ECORE_CON_PROXY_STATE_REQUEST)
337 {
338 /* run again to skip auth reading */
339 _ecore_con_socks_read_v5(svr, v5, NULL, 0);
340 return;
341 }
342 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
343 svr->ecs_state = ECORE_CON_PROXY_STATE_AUTH;
344 break;
345 case ECORE_CON_PROXY_STATE_AUTH:
346 ECORE_CON_SOCKS_READ(2);
347 switch (v5->method)
348 {
349 case ECORE_CON_SOCKS_V5_METHOD_NONE:
350 CRIT("HOW DID THIS HAPPEN?????????");
351 goto error;
352 case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
353 /* TODO: this */
354 break;
355 case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
356 if (data[0] != 1)
357 {
358 ecore_con_event_server_error(svr, "protocol error");
359 goto error; /* wrong version */
360 }
361 if (data[1])
362 {
363 ecore_con_event_server_error(svr, "proxy request authentication rejected");
364 goto error;
365 }
366 default:
367 break;
368 }
369 case ECORE_CON_PROXY_STATE_REQUEST:
370 { 337 {
371 size_t addrlen, buflen; 338 ecore_con_event_server_error(svr, "proxy authentication methods rejected");
372 unsigned char *sbuf; 339 goto error;
373 addrlen = v5->lookup ? strlen(svr->name) + 1 : (unsigned int)svr->ecs_addrlen;
374 buflen = sizeof(char) * (6 + addrlen);
375 sbuf = malloc(buflen);
376 if (!sbuf)
377 {
378 ecore_con_event_server_error(svr, "Memory allocation failure!");
379 goto error;
380 }
381 sbuf[0] = 5;
382 sbuf[1] = v5->bind ? 2 : 1; /* TODO: 0x03 for UDP port association */
383 sbuf[2] = 0;
384 if (v5->lookup) /* domain name */
385 {
386 sbuf[3] = 3;
387 sbuf[4] = addrlen - 1;
388 memcpy(sbuf + 5, svr->name, addrlen - 1);
389 }
390 else
391 {
392 sbuf[3] = (svr->ecs_addrlen == 4) ? 1 : 4;
393 memcpy(sbuf + 4, svr->ecs_addr, addrlen);
394 }
395 sbuf[addrlen + 4] = svr->port >> 8;
396 sbuf[addrlen + 5] = svr->port & 0xff;
397
398 svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
399 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
400 break;
401 } 340 }
402 case ECORE_CON_PROXY_STATE_CONFIRM: 341 v5->method = data[1];
342 if (!_ecore_con_socks_auth_v5(svr, v5)) goto error;
343 if (svr->ecs_state == ECORE_CON_PROXY_STATE_REQUEST)
403 { 344 {
404 /* this is ugly because we have to read an exact number of bytes, 345 /* run again to skip auth reading */
405 * but we don't know what that number is until we've already read 346 _ecore_con_socks_read_v5(svr, v5, NULL, 0);
406 * at least 5 bytes to determine the length of the unknown stream. 347 return;
407 * yep. 348 }
408 */ 349 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
409 size_t to_read, len = svr->ecs_recvbuf ? eina_binbuf_length_get(svr->ecs_recvbuf) : 0; 350 svr->ecs_state = ECORE_CON_PROXY_STATE_AUTH;
410 if (num + len < 5) 351 break;
411 {
412 /* guarantees we get called again */
413 ECORE_CON_SOCKS_READ(5);
414 }
415 if (len >= 5)
416 {
417 data = eina_binbuf_string_get(svr->ecs_recvbuf);
418 data += 3;
419 }
420 else
421 data = buf + 3 - len;
422 switch (data[0])
423 {
424 case 1:
425 to_read = 4;
426 break;
427 case 3:
428 to_read = data[1] + 1;
429 break;
430 case 4:
431 to_read = 16;
432 /* lazy debugging stub comment */
433 break;
434 default:
435 ecore_con_event_server_error(svr, "protocol error");
436 goto error;
437 }
438 /* at this point, we finally know exactly how much we need to read */
439 ECORE_CON_SOCKS_READ(6 + to_read);
440 352
441 if (data[0] != 5) 353 case ECORE_CON_PROXY_STATE_AUTH:
354 ECORE_CON_SOCKS_READ(2);
355 switch (v5->method)
356 {
357 case ECORE_CON_SOCKS_V5_METHOD_NONE:
358 CRIT("HOW DID THIS HAPPEN?????????");
359 goto error;
360
361 case ECORE_CON_SOCKS_V5_METHOD_GSSAPI:
362 /* TODO: this */
363 break;
364
365 case ECORE_CON_SOCKS_V5_METHOD_USERPASS:
366 if (data[0] != 1)
442 { 367 {
443 ecore_con_event_server_error(svr, "protocol error"); 368 ecore_con_event_server_error(svr, "protocol error");
444 goto error; /* wrong version */ 369 goto error; /* wrong version */
445 }
446 switch (data[1])
447 {
448 case 0:
449 break;
450 case 1:
451 ecore_con_event_server_error(svr, "general proxy failure");
452 goto error;
453 case 2:
454 ecore_con_event_server_error(svr, "connection not allowed by ruleset");
455 goto error;
456 case 3:
457 ecore_con_event_server_error(svr, "network unreachable");
458 goto error;
459 case 4:
460 ecore_con_event_server_error(svr, "host unreachable");
461 goto error;
462 case 5:
463 ecore_con_event_server_error(svr, "connection refused by destination host");
464 goto error;
465 case 6:
466 ecore_con_event_server_error(svr, "TTL expired");
467 goto error;
468 case 7:
469 ecore_con_event_server_error(svr, "command not supported / protocol error");
470 goto error;
471 case 8:
472 ecore_con_event_server_error(svr, "address type not supported");
473 default:
474 goto error;
475 } 370 }
476 if (data[2]) 371 if (data[1])
477 { 372 {
478 ecore_con_event_server_error(svr, "protocol error"); 373 ecore_con_event_server_error(svr, "proxy request authentication rejected");
479 goto error; 374 goto error;
480 } 375 }
481 memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr)); 376
482 if (!svr->ssl_state) 377 default:
483 ecore_con_event_server_add(svr);
484 if (svr->ssl_state || (svr->buf && eina_binbuf_length_get(svr->buf)))
485 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
486 svr->ecs_buf_offset = svr->ecs_addrlen = 0;
487 svr->ecs_state = ECORE_CON_PROXY_STATE_DONE;
488 INF("PROXY CONNECTED");
489 break; 378 break;
490 } 379 }
380
381 case ECORE_CON_PROXY_STATE_REQUEST:
382 {
383 size_t addrlen, buflen;
384 unsigned char *sbuf;
385 addrlen = v5->lookup ? strlen(svr->name) + 1 : (unsigned int)svr->ecs_addrlen;
386 buflen = sizeof(char) * (6 + addrlen);
387 sbuf = malloc(buflen);
388 if (!sbuf)
389 {
390 ecore_con_event_server_error(svr, "Memory allocation failure!");
391 goto error;
392 }
393 sbuf[0] = 5;
394 sbuf[1] = v5->bind ? 2 : 1; /* TODO: 0x03 for UDP port association */
395 sbuf[2] = 0;
396 if (v5->lookup) /* domain name */
397 {
398 sbuf[3] = 3;
399 sbuf[4] = addrlen - 1;
400 memcpy(sbuf + 5, svr->name, addrlen - 1);
401 }
402 else
403 {
404 sbuf[3] = (svr->ecs_addrlen == 4) ? 1 : 4;
405 memcpy(sbuf + 4, svr->ecs_addr, addrlen);
406 }
407 sbuf[addrlen + 4] = svr->port >> 8;
408 sbuf[addrlen + 5] = svr->port & 0xff;
409
410 svr->ecs_buf = eina_binbuf_manage_new_length(sbuf, buflen);
411 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE);
412 break;
413 }
414
415 case ECORE_CON_PROXY_STATE_CONFIRM:
416 {
417 /* this is ugly because we have to read an exact number of bytes,
418 * but we don't know what that number is until we've already read
419 * at least 5 bytes to determine the length of the unknown stream.
420 * yep.
421 */
422 size_t to_read, len = svr->ecs_recvbuf ? eina_binbuf_length_get(svr->ecs_recvbuf) : 0;
423 if (num + len < 5)
424 {
425 /* guarantees we get called again */
426 ECORE_CON_SOCKS_READ(5);
427 }
428 if (len >= 5)
429 {
430 data = eina_binbuf_string_get(svr->ecs_recvbuf);
431 data += 3;
432 }
433 else
434 data = buf + 3 - len;
435 switch (data[0])
436 {
437 case 1:
438 to_read = 4;
439 break;
440
441 case 3:
442 to_read = data[1] + 1;
443 break;
444
445 case 4:
446 to_read = 16;
447 /* lazy debugging stub comment */
448 break;
449
450 default:
451 ecore_con_event_server_error(svr, "protocol error");
452 goto error;
453 }
454 /* at this point, we finally know exactly how much we need to read */
455 ECORE_CON_SOCKS_READ(6 + to_read);
456
457 if (data[0] != 5)
458 {
459 ecore_con_event_server_error(svr, "protocol error");
460 goto error; /* wrong version */
461 }
462 switch (data[1])
463 {
464 case 0:
465 break;
466
467 case 1:
468 ecore_con_event_server_error(svr, "general proxy failure");
469 goto error;
470
471 case 2:
472 ecore_con_event_server_error(svr, "connection not allowed by ruleset");
473 goto error;
474
475 case 3:
476 ecore_con_event_server_error(svr, "network unreachable");
477 goto error;
478
479 case 4:
480 ecore_con_event_server_error(svr, "host unreachable");
481 goto error;
482
483 case 5:
484 ecore_con_event_server_error(svr, "connection refused by destination host");
485 goto error;
486
487 case 6:
488 ecore_con_event_server_error(svr, "TTL expired");
489 goto error;
490
491 case 7:
492 ecore_con_event_server_error(svr, "command not supported / protocol error");
493 goto error;
494
495 case 8:
496 ecore_con_event_server_error(svr, "address type not supported");
497
498 default:
499 goto error;
500 }
501 if (data[2])
502 {
503 ecore_con_event_server_error(svr, "protocol error");
504 goto error;
505 }
506 memset(svr->ecs_addr, 0, sizeof(svr->ecs_addr));
507 if (!svr->ssl_state)
508 ecore_con_event_server_add(svr);
509 if (svr->ssl_state || (svr->buf && eina_binbuf_length_get(svr->buf)))
510 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
511 svr->ecs_buf_offset = svr->ecs_addrlen = 0;
512 svr->ecs_state = ECORE_CON_PROXY_STATE_DONE;
513 INF("PROXY CONNECTED");
514 break;
515 }
516
491 default: 517 default:
492 break; 518 break;
493 } 519 }
494 if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf); 520 if (svr->ecs_recvbuf) eina_binbuf_free(svr->ecs_recvbuf);
495 svr->ecs_recvbuf = NULL; 521 svr->ecs_recvbuf = NULL;
496 522
497 return; 523 return;
498error: 524error:
499 _ecore_con_server_kill(svr); 525 _ecore_con_server_kill(svr);
@@ -613,7 +639,7 @@ ecore_con_socks_init(void)
613 ecore_con_socks_lookup_set(ecs, lookup); 639 ecore_con_socks_lookup_set(ecs, lookup);
614 ecore_con_socks_apply_always(ecs); 640 ecore_con_socks_apply_always(ecs);
615 INF("Added global proxy server %s%s%s:%d - DNS lookup %s", 641 INF("Added global proxy server %s%s%s:%d - DNS lookup %s",
616 u ?: "", u ? "@" : "", h, port, lookup ? "ENABLED" : "DISABLED"); 642 u ? : "", u ? "@" : "", h, port, lookup ? "ENABLED" : "DISABLED");
617} 643}
618 644
619///////////////////////////////////////////////////////////////////////////////////// 645/////////////////////////////////////////////////////////////////////////////////////
@@ -706,11 +732,12 @@ ecore_con_socks4_remote_del(const char *ip, int port, const char *username)
706 if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0]))) return; 732 if ((!ip) || (!ip[0]) || (port < -1) || (port > 65535) || (username && (!username[0]))) return;
707 if (!ecore_con_socks_proxies) return; 733 if (!ecore_con_socks_proxies) return;
708 734
709 v4 = (Ecore_Con_Socks_v4*)_ecore_con_socks_find(4, ip, port, username, username ? strlen(username) : 0, NULL, 0); 735 v4 = (Ecore_Con_Socks_v4 *)_ecore_con_socks_find(4, ip, port, username, username ? strlen(username) : 0, NULL, 0);
710 if (!v4) return; 736 if (!v4) return;
711 ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v4); 737 ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v4);
712 _ecore_con_socks_free((Ecore_Con_Socks*)v4); 738 _ecore_con_socks_free((Ecore_Con_Socks *)v4);
713} 739}
740
714/** 741/**
715 * Add a SOCKS v5 proxy to the proxy list 742 * Add a SOCKS v5 proxy to the proxy list
716 * 743 *
@@ -744,8 +771,8 @@ ecore_con_socks5_remote_add(const char *ip, int port, const char *username, cons
744 /* max length for protocol */ 771 /* max length for protocol */
745 if ((!plen) || (plen > 255)) return NULL; 772 if ((!plen) || (plen > 255)) return NULL;
746 } 773 }
747 ecs5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen); 774 ecs5 = (Ecore_Con_Socks_v5 *)_ecore_con_socks_find(5, ip, port, username, ulen, password, plen);
748 if (ecs5) return (Ecore_Con_Socks*)ecs5; 775 if (ecs5) return (Ecore_Con_Socks *)ecs5;
749 776
750 ecs5 = calloc(1, sizeof(Ecore_Con_Socks_v5)); 777 ecs5 = calloc(1, sizeof(Ecore_Con_Socks_v5));
751 if (!ecs5) return NULL; 778 if (!ecs5) return NULL;
@@ -758,7 +785,7 @@ ecore_con_socks5_remote_add(const char *ip, int port, const char *username, cons
758 ecs5->password = eina_stringshare_add(password); 785 ecs5->password = eina_stringshare_add(password);
759 ecs5->plen = plen; 786 ecs5->plen = plen;
760 ecore_con_socks_proxies = eina_list_append(ecore_con_socks_proxies, ecs5); 787 ecore_con_socks_proxies = eina_list_append(ecore_con_socks_proxies, ecs5);
761 return (Ecore_Con_Socks*)ecs5; 788 return (Ecore_Con_Socks *)ecs5;
762} 789}
763 790
764/** 791/**
@@ -805,10 +832,10 @@ ecore_con_socks5_remote_del(const char *ip, int port, const char *username, cons
805 return; 832 return;
806 if (!ecore_con_socks_proxies) return; 833 if (!ecore_con_socks_proxies) return;
807 834
808 v5 = (Ecore_Con_Socks_v5*)_ecore_con_socks_find(5, ip, port, username, username ? strlen(username) : 0, password, password ? strlen(password) : 0); 835 v5 = (Ecore_Con_Socks_v5 *)_ecore_con_socks_find(5, ip, port, username, username ? strlen(username) : 0, password, password ? strlen(password) : 0);
809 if (!v5) return; 836 if (!v5) return;
810 ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v5); 837 ecore_con_socks_proxies = eina_list_remove(ecore_con_socks_proxies, v5);
811 _ecore_con_socks_free((Ecore_Con_Socks*)v5); 838 _ecore_con_socks_free((Ecore_Con_Socks *)v5);
812} 839}
813 840
814/** 841/**
@@ -954,4 +981,5 @@ ecore_con_socks_apply_always(Ecore_Con_Socks *ecs)
954{ 981{
955 _ecore_con_proxy_global = ecs; 982 _ecore_con_proxy_global = ecs;
956} 983}
984
957/** @} */ 985/** @} */
diff --git a/src/lib/ecore_con/ecore_con_ssl.c b/src/lib/ecore_con/ecore_con_ssl.c
index 09a08941b2..d10d4fa75b 100644
--- a/src/lib/ecore_con/ecore_con_ssl.c
+++ b/src/lib/ecore_con/ecore_con_ssl.c
@@ -80,7 +80,7 @@ _gnutls_print_session(const gnutls_datum_t *cert_list, unsigned int cert_list_si
80 { 80 {
81 gnutls_x509_crt_init(&crt); 81 gnutls_x509_crt_init(&crt);
82 gnutls_x509_crt_import(crt, &cert_list[x], GNUTLS_X509_FMT_DER); 82 gnutls_x509_crt_import(crt, &cert_list[x], GNUTLS_X509_FMT_DER);
83 gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_FULL, (gnutls_datum_t*)&c); 83 gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_FULL, (gnutls_datum_t *)&c);
84 INF("CERTIFICATE:\n%s", c); 84 INF("CERTIFICATE:\n%s", c);
85 gnutls_free(c); 85 gnutls_free(c);
86 gnutls_x509_crt_deinit(crt); 86 gnutls_x509_crt_deinit(crt);
@@ -90,13 +90,14 @@ _gnutls_print_session(const gnutls_datum_t *cert_list, unsigned int cert_list_si
90 90
91#ifdef ISCOMFITOR 91#ifdef ISCOMFITOR
92static void 92static void
93_gnutls_log_func(int level, 93_gnutls_log_func(int level,
94 const char *str) 94 const char *str)
95{ 95{
96 char buf[128]; 96 char buf[128];
97 strncat(buf, str, strlen(str) - 1); 97 strncat(buf, str, strlen(str) - 1);
98 DBG("|<%d>| %s", level, buf); 98 DBG("|<%d>| %s", level, buf);
99} 99}
100
100#endif 101#endif
101 102
102static const char * 103static const char *
@@ -151,174 +152,174 @@ _openssl_print_verify_error(int error)
151 switch (error) 152 switch (error)
152 { 153 {
153#define ERROR(X) \ 154#define ERROR(X) \
154 case (X): \ 155case (X): \
155 ERR("%s", #X); \ 156 ERR("%s", #X); \
156 break 157 break
157#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 158#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
158 ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT); 159 ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT);
159#endif 160#endif
160#ifdef X509_V_ERR_UNABLE_TO_GET_CRL 161#ifdef X509_V_ERR_UNABLE_TO_GET_CRL
161 ERROR(X509_V_ERR_UNABLE_TO_GET_CRL); 162 ERROR(X509_V_ERR_UNABLE_TO_GET_CRL);
162#endif 163#endif
163#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 164#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
164 ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE); 165 ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
165#endif 166#endif
166#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 167#ifdef X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
167 ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE); 168 ERROR(X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE);
168#endif 169#endif
169#ifdef X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 170#ifdef X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
170 ERROR(X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY); 171 ERROR(X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY);
171#endif 172#endif
172#ifdef X509_V_ERR_CERT_SIGNATURE_FAILURE 173#ifdef X509_V_ERR_CERT_SIGNATURE_FAILURE
173 ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE); 174 ERROR(X509_V_ERR_CERT_SIGNATURE_FAILURE);
174#endif 175#endif
175#ifdef X509_V_ERR_CRL_SIGNATURE_FAILURE 176#ifdef X509_V_ERR_CRL_SIGNATURE_FAILURE
176 ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE); 177 ERROR(X509_V_ERR_CRL_SIGNATURE_FAILURE);
177#endif 178#endif
178#ifdef X509_V_ERR_CERT_NOT_YET_VALID 179#ifdef X509_V_ERR_CERT_NOT_YET_VALID
179 ERROR(X509_V_ERR_CERT_NOT_YET_VALID); 180 ERROR(X509_V_ERR_CERT_NOT_YET_VALID);
180#endif 181#endif
181#ifdef X509_V_ERR_CERT_HAS_EXPIRED 182#ifdef X509_V_ERR_CERT_HAS_EXPIRED
182 ERROR(X509_V_ERR_CERT_HAS_EXPIRED); 183 ERROR(X509_V_ERR_CERT_HAS_EXPIRED);
183#endif 184#endif
184#ifdef X509_V_ERR_CRL_NOT_YET_VALID 185#ifdef X509_V_ERR_CRL_NOT_YET_VALID
185 ERROR(X509_V_ERR_CRL_NOT_YET_VALID); 186 ERROR(X509_V_ERR_CRL_NOT_YET_VALID);
186#endif 187#endif
187#ifdef X509_V_ERR_CRL_HAS_EXPIRED 188#ifdef X509_V_ERR_CRL_HAS_EXPIRED
188 ERROR(X509_V_ERR_CRL_HAS_EXPIRED); 189 ERROR(X509_V_ERR_CRL_HAS_EXPIRED);
189#endif 190#endif
190#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 191#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
191 ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD); 192 ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD);
192#endif 193#endif
193#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 194#ifdef X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
194 ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD); 195 ERROR(X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD);
195#endif 196#endif
196#ifdef X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 197#ifdef X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
197 ERROR(X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD); 198 ERROR(X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD);
198#endif 199#endif
199#ifdef X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 200#ifdef X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
200 ERROR(X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD); 201 ERROR(X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD);
201#endif 202#endif
202#ifdef X509_V_ERR_OUT_OF_MEM 203#ifdef X509_V_ERR_OUT_OF_MEM
203 ERROR(X509_V_ERR_OUT_OF_MEM); 204 ERROR(X509_V_ERR_OUT_OF_MEM);
204#endif 205#endif
205#ifdef X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 206#ifdef X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
206 ERROR(X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT); 207 ERROR(X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
207#endif 208#endif
208#ifdef X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 209#ifdef X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
209 ERROR(X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN); 210 ERROR(X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN);
210#endif 211#endif
211#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 212#ifdef X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
212 ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY); 213 ERROR(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY);
213#endif 214#endif
214#ifdef X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 215#ifdef X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
215 ERROR(X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE); 216 ERROR(X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE);
216#endif 217#endif
217#ifdef X509_V_ERR_CERT_CHAIN_TOO_LONG 218#ifdef X509_V_ERR_CERT_CHAIN_TOO_LONG
218 ERROR(X509_V_ERR_CERT_CHAIN_TOO_LONG); 219 ERROR(X509_V_ERR_CERT_CHAIN_TOO_LONG);
219#endif 220#endif
220#ifdef X509_V_ERR_CERT_REVOKED 221#ifdef X509_V_ERR_CERT_REVOKED
221 ERROR(X509_V_ERR_CERT_REVOKED); 222 ERROR(X509_V_ERR_CERT_REVOKED);
222#endif 223#endif
223#ifdef X509_V_ERR_INVALID_CA 224#ifdef X509_V_ERR_INVALID_CA
224 ERROR(X509_V_ERR_INVALID_CA); 225 ERROR(X509_V_ERR_INVALID_CA);
225#endif 226#endif
226#ifdef X509_V_ERR_PATH_LENGTH_EXCEEDED 227#ifdef X509_V_ERR_PATH_LENGTH_EXCEEDED
227 ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED); 228 ERROR(X509_V_ERR_PATH_LENGTH_EXCEEDED);
228#endif 229#endif
229#ifdef X509_V_ERR_INVALID_PURPOSE 230#ifdef X509_V_ERR_INVALID_PURPOSE
230 ERROR(X509_V_ERR_INVALID_PURPOSE); 231 ERROR(X509_V_ERR_INVALID_PURPOSE);
231#endif 232#endif
232#ifdef X509_V_ERR_CERT_UNTRUSTED 233#ifdef X509_V_ERR_CERT_UNTRUSTED
233 ERROR(X509_V_ERR_CERT_UNTRUSTED); 234 ERROR(X509_V_ERR_CERT_UNTRUSTED);
234#endif 235#endif
235#ifdef X509_V_ERR_CERT_REJECTED 236#ifdef X509_V_ERR_CERT_REJECTED
236 ERROR(X509_V_ERR_CERT_REJECTED); 237 ERROR(X509_V_ERR_CERT_REJECTED);
237#endif 238#endif
238 /* These are 'informational' when looking for issuer cert */ 239 /* These are 'informational' when looking for issuer cert */
239#ifdef X509_V_ERR_SUBJECT_ISSUER_MISMATCH 240#ifdef X509_V_ERR_SUBJECT_ISSUER_MISMATCH
240 ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH); 241 ERROR(X509_V_ERR_SUBJECT_ISSUER_MISMATCH);
241#endif 242#endif
242#ifdef X509_V_ERR_AKID_SKID_MISMATCH 243#ifdef X509_V_ERR_AKID_SKID_MISMATCH
243 ERROR(X509_V_ERR_AKID_SKID_MISMATCH); 244 ERROR(X509_V_ERR_AKID_SKID_MISMATCH);
244#endif 245#endif
245#ifdef X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 246#ifdef X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
246 ERROR(X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH); 247 ERROR(X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH);
247#endif 248#endif
248#ifdef X509_V_ERR_KEYUSAGE_NO_CERTSIGN 249#ifdef X509_V_ERR_KEYUSAGE_NO_CERTSIGN
249 ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN); 250 ERROR(X509_V_ERR_KEYUSAGE_NO_CERTSIGN);
250#endif 251#endif
251 252
252#ifdef X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 253#ifdef X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER
253 ERROR(X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER); 254 ERROR(X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER);
254#endif 255#endif
255#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 256#ifdef X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
256 ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION); 257 ERROR(X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION);
257#endif 258#endif
258#ifdef X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 259#ifdef X509_V_ERR_KEYUSAGE_NO_CRL_SIGN
259 ERROR(X509_V_ERR_KEYUSAGE_NO_CRL_SIGN); 260 ERROR(X509_V_ERR_KEYUSAGE_NO_CRL_SIGN);
260#endif 261#endif
261#ifdef X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 262#ifdef X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION
262 ERROR(X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION); 263 ERROR(X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION);
263#endif 264#endif
264#ifdef X509_V_ERR_INVALID_NON_CA 265#ifdef X509_V_ERR_INVALID_NON_CA
265 ERROR(X509_V_ERR_INVALID_NON_CA); 266 ERROR(X509_V_ERR_INVALID_NON_CA);
266#endif 267#endif
267#ifdef X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 268#ifdef X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED
268 ERROR(X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED); 269 ERROR(X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED);
269#endif 270#endif
270#ifdef X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 271#ifdef X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE
271 ERROR(X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE); 272 ERROR(X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE);
272#endif 273#endif
273#ifdef X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 274#ifdef X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED
274 ERROR(X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED); 275 ERROR(X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED);
275#endif 276#endif
276 277
277#ifdef X509_V_ERR_INVALID_EXTENSION 278#ifdef X509_V_ERR_INVALID_EXTENSION
278 ERROR(X509_V_ERR_INVALID_EXTENSION); 279 ERROR(X509_V_ERR_INVALID_EXTENSION);
279#endif 280#endif
280#ifdef X509_V_ERR_INVALID_POLICY_EXTENSION 281#ifdef X509_V_ERR_INVALID_POLICY_EXTENSION
281 ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION); 282 ERROR(X509_V_ERR_INVALID_POLICY_EXTENSION);
282#endif 283#endif
283#ifdef X509_V_ERR_NO_EXPLICIT_POLICY 284#ifdef X509_V_ERR_NO_EXPLICIT_POLICY
284 ERROR(X509_V_ERR_NO_EXPLICIT_POLICY); 285 ERROR(X509_V_ERR_NO_EXPLICIT_POLICY);
285#endif 286#endif
286#ifdef X509_V_ERR_DIFFERENT_CRL_SCOPE 287#ifdef X509_V_ERR_DIFFERENT_CRL_SCOPE
287 ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE); 288 ERROR(X509_V_ERR_DIFFERENT_CRL_SCOPE);
288#endif 289#endif
289#ifdef X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 290#ifdef X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
290 ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE); 291 ERROR(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE);
291#endif 292#endif
292 293
293#ifdef X509_V_ERR_UNNESTED_RESOURCE 294#ifdef X509_V_ERR_UNNESTED_RESOURCE
294 ERROR(X509_V_ERR_UNNESTED_RESOURCE); 295 ERROR(X509_V_ERR_UNNESTED_RESOURCE);
295#endif 296#endif
296 297
297#ifdef X509_V_ERR_PERMITTED_VIOLATION 298#ifdef X509_V_ERR_PERMITTED_VIOLATION
298 ERROR(X509_V_ERR_PERMITTED_VIOLATION); 299 ERROR(X509_V_ERR_PERMITTED_VIOLATION);
299#endif 300#endif
300#ifdef X509_V_ERR_EXCLUDED_VIOLATION 301#ifdef X509_V_ERR_EXCLUDED_VIOLATION
301 ERROR(X509_V_ERR_EXCLUDED_VIOLATION); 302 ERROR(X509_V_ERR_EXCLUDED_VIOLATION);
302#endif 303#endif
303#ifdef X509_V_ERR_SUBTREE_MINMAX 304#ifdef X509_V_ERR_SUBTREE_MINMAX
304 ERROR(X509_V_ERR_SUBTREE_MINMAX); 305 ERROR(X509_V_ERR_SUBTREE_MINMAX);
305#endif 306#endif
306#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 307#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
307 ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE); 308 ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE);
308#endif 309#endif
309#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 310#ifdef X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
310 ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX); 311 ERROR(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
311#endif 312#endif
312#ifdef X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 313#ifdef X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
313 ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX); 314 ERROR(X509_V_ERR_UNSUPPORTED_NAME_SYNTAX);
314#endif 315#endif
315#ifdef X509_V_ERR_CRL_PATH_VALIDATION_ERROR 316#ifdef X509_V_ERR_CRL_PATH_VALIDATION_ERROR
316 ERROR(X509_V_ERR_CRL_PATH_VALIDATION_ERROR); 317 ERROR(X509_V_ERR_CRL_PATH_VALIDATION_ERROR);
317#endif 318#endif
318 319
319 /* The application is not happy */ 320 /* The application is not happy */
320#ifdef X509_V_ERR_APPLICATION_VERIFICATION 321#ifdef X509_V_ERR_APPLICATION_VERIFICATION
321 ERROR(X509_V_ERR_APPLICATION_VERIFICATION); 322 ERROR(X509_V_ERR_APPLICATION_VERIFICATION);
322#endif 323#endif
323 } 324 }
324#undef ERROR 325#undef ERROR
@@ -339,7 +340,6 @@ _openssl_print_errors(void *conn, int type)
339 ecore_con_event_client_error(conn, buf); 340 ecore_con_event_client_error(conn, buf);
340 else 341 else
341 ecore_con_event_server_error(conn, buf); 342 ecore_con_event_server_error(conn, buf);
342
343 } while (1); 343 } while (1);
344} 344}
345 345
@@ -368,11 +368,11 @@ _openssl_name_verify(const char *name, const char *svrname)
368 } 368 }
369 } 369 }
370 else 370 else
371 if (strcasecmp(name, svrname)) 371 if (strcasecmp(name, svrname))
372 { 372 {
373 ERR("%s != %s", name, svrname); 373 ERR("%s != %s", name, svrname);
374 return EINA_FALSE; 374 return EINA_FALSE;
375 } 375 }
376 return EINA_TRUE; 376 return EINA_TRUE;
377} 377}
378 378
@@ -381,7 +381,7 @@ _openssl_print_session(SSL *ssl)
381{ 381{
382 /* print session info into DBG */ 382 /* print session info into DBG */
383 SSL_SESSION *s; 383 SSL_SESSION *s;
384 STACK_OF(X509) *sk; 384 STACK_OF(X509) * sk;
385 BIO *b; 385 BIO *b;
386 char log[4096], *p; 386 char log[4096], *p;
387 int x; 387 int x;
@@ -430,23 +430,23 @@ static Ecore_Con_Ssl_Error
430static Ecore_Con_Ssl_Error 430static Ecore_Con_Ssl_Error
431 SSL_SUFFIX(_ecore_con_ssl_shutdown) (void); 431 SSL_SUFFIX(_ecore_con_ssl_shutdown) (void);
432 432
433static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server * svr, const char *ca_file); 433static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server *svr, const char *ca_file);
434static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server * svr, const char *crl_file); 434static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server *svr, const char *crl_file);
435static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server * svr, const char *cert); 435static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server *svr, const char *cert);
436static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (Ecore_Con_Server * svr, const char *key_file); 436static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (Ecore_Con_Server *svr, const char *key_file);
437 437
438static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_prepare) (Ecore_Con_Server * svr, int ssl_type); 438static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_prepare) (Ecore_Con_Server *svr, int ssl_type);
439static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_init) (Ecore_Con_Server * svr); 439static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_init) (Ecore_Con_Server *svr);
440static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (Ecore_Con_Server *svr); 440static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (Ecore_Con_Server *svr);
441static int SSL_SUFFIX(_ecore_con_ssl_server_read) (Ecore_Con_Server *svr, unsigned char *buf, int size); 441static int SSL_SUFFIX(_ecore_con_ssl_server_read) (Ecore_Con_Server *svr, unsigned char *buf, int size);
442static int SSL_SUFFIX(_ecore_con_ssl_server_write) (Ecore_Con_Server *svr, const unsigned char *buf, int size); 442static int SSL_SUFFIX(_ecore_con_ssl_server_write) (Ecore_Con_Server *svr, const unsigned char *buf, int size);
443 443
444static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_init) (Ecore_Con_Client * cl); 444static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_init) (Ecore_Con_Client *cl);
445static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (Ecore_Con_Client *cl); 445static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (Ecore_Con_Client *cl);
446static int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client * cl, 446static int SSL_SUFFIX(_ecore_con_ssl_client_read) (Ecore_Con_Client *cl,
447 unsigned char *buf, int size); 447 unsigned char *buf, int size);
448static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client * cl, 448static int SSL_SUFFIX(_ecore_con_ssl_client_write) (Ecore_Con_Client *cl,
449 const unsigned char *buf, int size); 449 const unsigned char *buf, int size);
450 450
451/* 451/*
452 * General SSL API 452 * General SSL API
@@ -478,7 +478,7 @@ ecore_con_ssl_shutdown(void)
478 478
479Ecore_Con_Ssl_Error 479Ecore_Con_Ssl_Error
480ecore_con_ssl_server_prepare(Ecore_Con_Server *svr, 480ecore_con_ssl_server_prepare(Ecore_Con_Server *svr,
481 int ssl_type) 481 int ssl_type)
482{ 482{
483 if (!ssl_type) 483 if (!ssl_type)
484 return ECORE_CON_SSL_ERROR_NONE; 484 return ECORE_CON_SSL_ERROR_NONE;
@@ -503,8 +503,8 @@ ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr)
503 503
504int 504int
505ecore_con_ssl_server_read(Ecore_Con_Server *svr, 505ecore_con_ssl_server_read(Ecore_Con_Server *svr,
506 unsigned char *buf, 506 unsigned char *buf,
507 int size) 507 int size)
508{ 508{
509 return SSL_SUFFIX(_ecore_con_ssl_server_read) (svr, buf, size); 509 return SSL_SUFFIX(_ecore_con_ssl_server_read) (svr, buf, size);
510} 510}
@@ -512,7 +512,7 @@ ecore_con_ssl_server_read(Ecore_Con_Server *svr,
512int 512int
513ecore_con_ssl_server_write(Ecore_Con_Server *svr, 513ecore_con_ssl_server_write(Ecore_Con_Server *svr,
514 const unsigned char *buf, 514 const unsigned char *buf,
515 int size) 515 int size)
516{ 516{
517 return SSL_SUFFIX(_ecore_con_ssl_server_write) (svr, buf, size); 517 return SSL_SUFFIX(_ecore_con_ssl_server_write) (svr, buf, size);
518} 518}
@@ -535,8 +535,8 @@ ecore_con_ssl_client_shutdown(Ecore_Con_Client *cl)
535 535
536int 536int
537ecore_con_ssl_client_read(Ecore_Con_Client *cl, 537ecore_con_ssl_client_read(Ecore_Con_Client *cl,
538 unsigned char *buf, 538 unsigned char *buf,
539 int size) 539 int size)
540{ 540{
541 return SSL_SUFFIX(_ecore_con_ssl_client_read) (cl, buf, size); 541 return SSL_SUFFIX(_ecore_con_ssl_client_read) (cl, buf, size);
542} 542}
@@ -544,7 +544,7 @@ ecore_con_ssl_client_read(Ecore_Con_Client *cl,
544int 544int
545ecore_con_ssl_client_write(Ecore_Con_Client *cl, 545ecore_con_ssl_client_write(Ecore_Con_Client *cl,
546 const unsigned char *buf, 546 const unsigned char *buf,
547 int size) 547 int size)
548{ 548{
549 return SSL_SUFFIX(_ecore_con_ssl_client_write) (cl, buf, size); 549 return SSL_SUFFIX(_ecore_con_ssl_client_write) (cl, buf, size);
550} 550}
@@ -650,7 +650,7 @@ ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr)
650 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__); 650 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, __func__);
651 return NULL; 651 return NULL;
652 } 652 }
653 return svr->verify_name ?: svr->name; 653 return svr->verify_name ? : svr->name;
654} 654}
655 655
656/** 656/**
@@ -666,7 +666,7 @@ ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr)
666 666
667EAPI Eina_Bool 667EAPI Eina_Bool
668ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, 668ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr,
669 const char *cert) 669 const char *cert)
670{ 670{
671 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) 671 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
672 { 672 {
@@ -699,7 +699,7 @@ ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr,
699 699
700EAPI Eina_Bool 700EAPI Eina_Bool
701ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, 701ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr,
702 const char *ca_file) 702 const char *ca_file)
703{ 703{
704 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) 704 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
705 { 705 {
@@ -731,7 +731,7 @@ ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr,
731 731
732EAPI Eina_Bool 732EAPI Eina_Bool
733ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, 733ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr,
734 const char *key_file) 734 const char *key_file)
735{ 735{
736 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) 736 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
737 { 737 {
@@ -763,7 +763,7 @@ ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr,
763 763
764EAPI Eina_Bool