summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_con/Ecore_Con.h2
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con.c69
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con_private.h2
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h4
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c72
5 files changed, 147 insertions, 2 deletions
diff --git a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h
index 130f0625bb..24a5a9a62e 100644
--- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h
+++ b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h
@@ -151,12 +151,14 @@ extern "C" {
151 EAPI int ecore_con_server_connected_get(Ecore_Con_Server *svr); 151 EAPI int ecore_con_server_connected_get(Ecore_Con_Server *svr);
152 EAPI int ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size); 152 EAPI int ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size);
153 EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char reject_excess_clients); 153 EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char reject_excess_clients);
154 EAPI char *ecore_con_server_ip_get(Ecore_Con_Server *svr);
154 155
155 EAPI int ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size); 156 EAPI int ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size);
156 EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl); 157 EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
157 EAPI void *ecore_con_client_del(Ecore_Con_Client *cl); 158 EAPI void *ecore_con_client_del(Ecore_Con_Client *cl);
158 EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data); 159 EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data);
159 EAPI void *ecore_con_client_data_get(Ecore_Con_Client *cl); 160 EAPI void *ecore_con_client_data_get(Ecore_Con_Client *cl);
161 EAPI char *ecore_con_client_ip_get(Ecore_Con_Client *cl);
160 162
161 EAPI int ecore_con_ssl_available_get(void); 163 EAPI int ecore_con_ssl_available_get(void);
162 164
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c
index 9461276b03..6378db5e1c 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con.c
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c
@@ -338,6 +338,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
338 if (svr->fd >= 0) close(svr->fd); 338 if (svr->fd >= 0) close(svr->fd);
339 if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler); 339 if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
340 if (svr->write_buf) free(svr->write_buf); 340 if (svr->write_buf) free(svr->write_buf);
341 if (svr->ip) free(svr->ip);
341#if USE_OPENSSL 342#if USE_OPENSSL
342 if (svr->ssl) SSL_free(svr->ssl); 343 if (svr->ssl) SSL_free(svr->ssl);
343 if (svr->ssl_ctx) SSL_CTX_free(svr->ssl_ctx); 344 if (svr->ssl_ctx) SSL_CTX_free(svr->ssl_ctx);
@@ -627,6 +628,28 @@ ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char
627} 628}
628 629
629/** 630/**
631 * Gets the IP address of a server that has been connected to.
632 *
633 * @param svr The given server.
634 * @return A pointer to an internal string that contains the IP address of
635 * the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
636 * This string should not be modified or trusted to stay valid after
637 * deletion for the @p svr object. If no IP is known NULL is returned.
638 * @ingroup Ecore_Con_Server_Group
639 */
640EAPI char *
641ecore_con_server_ip_get(Ecore_Con_Server *svr)
642{
643 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
644 {
645 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
646 "ecore_con_server_ip_get");
647 return NULL;
648 }
649 return svr->ip;
650}
651
652/**
630 * @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions 653 * @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions
631 * 654 *
632 * Functions that operate on Ecore connection client objects. 655 * Functions that operate on Ecore connection client objects.
@@ -761,6 +784,28 @@ ecore_con_client_data_get(Ecore_Con_Client *cl)
761} 784}
762 785
763/** 786/**
787 * Gets the IP address of a cleint that has connected.
788 *
789 * @param cl The given client.
790 * @return A pointer to an internal string that contains the IP address of
791 * the connected client in the form "XXX.YYY.ZZZ.AAA" IP notation.
792 * This string should not be modified or trusted to stay valid after
793 * deletion for the @p cl object. If no IP is known NULL is returned.
794 * @ingroup Ecore_Con_Client_Group
795 */
796EAPI char *
797ecore_con_client_ip_get(Ecore_Con_Client *cl)
798{
799 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
800 {
801 ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
802 "ecore_con_client_ip_get");
803 return NULL;
804 }
805 return cl->ip;
806}
807
808/**
764 * Returns if SSL support is available 809 * Returns if SSL support is available
765 * @return 1 if SSL is available, 0 if it is not. 810 * @return 1 if SSL is available, 0 if it is not.
766 * @ingroup Ecore_Con_Client_Group 811 * @ingroup Ecore_Con_Client_Group
@@ -796,6 +841,7 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
796#endif 841#endif
797 if (svr->name) free(svr->name); 842 if (svr->name) free(svr->name);
798 if (svr->path) free(svr->path); 843 if (svr->path) free(svr->path);
844 if (svr->ip) free(svr->ip);
799 if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler); 845 if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
800 free(svr); 846 free(svr);
801} 847}
@@ -808,6 +854,7 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
808 if (cl->buf) free(cl->buf); 854 if (cl->buf) free(cl->buf);
809 if (cl->fd >= 0) close(cl->fd); 855 if (cl->fd >= 0) close(cl->fd);
810 if (cl->fd_handler) ecore_main_fd_handler_del(cl->fd_handler); 856 if (cl->fd_handler) ecore_main_fd_handler_del(cl->fd_handler);
857 if (cl->ip) free(cl->ip);
811 free(cl); 858 free(cl);
812} 859}
813 860
@@ -831,7 +878,9 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
831 if (new_fd >= 0) 878 if (new_fd >= 0)
832 { 879 {
833 Ecore_Con_Client *cl; 880 Ecore_Con_Client *cl;
834 881 char buf[64];
882 uint32_t ip;
883
835 if ((svr->client_limit >= 0) && (svr->reject_excess_clients)) 884 if ((svr->client_limit >= 0) && (svr->reject_excess_clients))
836 { 885 {
837 close(new_fd); 886 close(new_fd);
@@ -854,6 +903,14 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
854 cl, NULL, NULL); 903 cl, NULL, NULL);
855 ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); 904 ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);
856 ecore_list_append(svr->clients, cl); 905 ecore_list_append(svr->clients, cl);
906 ip = incoming.sin_addr.s_addr;
907 snprintf(buf, sizeof(buf),
908 "%i.%i.%i.%i",
909 (ip ) & 0xff,
910 (ip >> 8 ) & 0xff,
911 (ip >> 16) & 0xff,
912 (ip >> 24) & 0xff);
913 cl->ip = strdup(buf);
857 { 914 {
858 Ecore_Con_Event_Client_Add *e; 915 Ecore_Con_Event_Client_Add *e;
859 916
@@ -925,6 +982,8 @@ _ecore_con_cb_dns_lookup(void *data, struct hostent *he)
925 Ecore_Con_Server *svr; 982 Ecore_Con_Server *svr;
926 struct sockaddr_in socket_addr; 983 struct sockaddr_in socket_addr;
927 int curstate = 0; 984 int curstate = 0;
985 char buf[64];
986 uint32_t ip;
928 987
929 svr = data; 988 svr = data;
930 989
@@ -955,6 +1014,14 @@ _ecore_con_cb_dns_lookup(void *data, struct hostent *he)
955 NULL, NULL); 1014 NULL, NULL);
956 1015
957 if (!svr->fd_handler) goto error; 1016 if (!svr->fd_handler) goto error;
1017 ip = socket_addr.sin_addr.s_addr;
1018 snprintf(buf, sizeof(buf),
1019 "%i.%i.%i.%i",
1020 (ip ) & 0xff,
1021 (ip >> 8 ) & 0xff,
1022 (ip >> 16) & 0xff,
1023 (ip >> 24) & 0xff);
1024 svr->ip = strdup(buf);
958 1025
959#if USE_OPENSSL 1026#if USE_OPENSSL
960 if (svr->type & ECORE_CON_USE_SSL) 1027 if (svr->type & ECORE_CON_USE_SSL)
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h
index 95063b8a50..270361a9db 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h
@@ -44,6 +44,7 @@ struct _Ecore_Con_Client
44 int buf_size; 44 int buf_size;
45 int buf_offset; 45 int buf_offset;
46 unsigned char *buf; 46 unsigned char *buf;
47 char *ip;
47 int event_count; 48 int event_count;
48 char dead : 1; 49 char dead : 1;
49 char delete_me : 1; 50 char delete_me : 1;
@@ -71,6 +72,7 @@ struct _Ecore_Con_Server
71 SSL_CTX *ssl_ctx; 72 SSL_CTX *ssl_ctx;
72 SSL *ssl; 73 SSL *ssl;
73#endif 74#endif
75 char *ip;
74 char dead : 1; 76 char dead : 1;
75 char created : 1; 77 char created : 1;
76 char connecting : 1; 78 char connecting : 1;
diff --git a/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h b/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h
index 65bf3a7ab2..dc1088fa43 100644
--- a/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h
+++ b/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h
@@ -299,7 +299,8 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v);
299 EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients); 299 EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients);
300 EAPI void ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *srv, int size); 300 EAPI void ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *srv, int size);
301 EAPI int ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *srv); 301 EAPI int ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *srv);
302 302 EAPI char *ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr);
303
303 /* FIXME: this needs to become an ipc message */ 304 /* FIXME: this needs to become an ipc message */
304 EAPI int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, void *data, int size); 305 EAPI int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, void *data, int size);
305 EAPI Ecore_Ipc_Server *ecore_ipc_client_server_get(Ecore_Ipc_Client *cl); 306 EAPI Ecore_Ipc_Server *ecore_ipc_client_server_get(Ecore_Ipc_Client *cl);
@@ -308,6 +309,7 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v);
308 EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl); 309 EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl);
309 EAPI void ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size); 310 EAPI void ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size);
310 EAPI int ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl); 311 EAPI int ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl);
312 EAPI char *ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl);
311 313
312 EAPI int ecore_ipc_ssl_available_get(void); 314 EAPI int ecore_ipc_ssl_available_get(void);
313 /* FIXME: need to add a callback to "ok" large ipc messages greater than */ 315 /* FIXME: need to add a callback to "ok" large ipc messages greater than */
diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
index efedbecb01..d64b2c427d 100644
--- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
+++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
@@ -612,6 +612,13 @@ ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char
612 ecore_con_server_client_limit_set(svr->server, client_limit, reject_excess_clients); 612 ecore_con_server_client_limit_set(svr->server, client_limit, reject_excess_clients);
613} 613}
614 614
615/**
616 * Sets the max data payload size for an Ipc message in bytes
617 *
618 * @param svr The given server.
619 * @param size The maximum data payload size in bytes.
620 * @ingroup Ecore_Ipc_Server_Group
621 */
615EAPI void 622EAPI void
616ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size) 623ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size)
617{ 624{
@@ -624,6 +631,13 @@ ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size)
624 svr->max_buf_size = size; 631 svr->max_buf_size = size;
625} 632}
626 633
634/**
635 * Gets the max data payload size for an Ipc message in bytes
636 *
637 * @param svr The given server.
638 * @return The maximum data payload in bytes.
639 * @ingroup Ecore_Ipc_Server_Group
640 */
627EAPI int 641EAPI int
628ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr) 642ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr)
629{ 643{
@@ -636,6 +650,28 @@ ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr)
636 return svr->max_buf_size; 650 return svr->max_buf_size;
637} 651}
638 652
653/**
654 * Gets the IP address of a server that has been connected to.
655 *
656 * @param svr The given server.
657 * @return A pointer to an internal string that contains the IP address of
658 * the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
659 * This string should not be modified or trusted to stay valid after
660 * deletion for the @p svr object. If no IP is known NULL is returned.
661 * @ingroup Ecore_Ipc_Server_Group
662 */
663EAPI char *
664ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr)
665{
666 if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
667 {
668 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
669 "ecore_con_server_ip_get");
670 return NULL;
671 }
672 return ecore_con_server_ip_get(svr->server);
673}
674
639 675
640#define CLENC(_member) \ 676#define CLENC(_member) \
641 d = _ecore_ipc_dlt_int(msg._member, cl->prev.o._member, &md); \ 677 d = _ecore_ipc_dlt_int(msg._member, cl->prev.o._member, &md); \
@@ -822,6 +858,13 @@ ecore_ipc_client_data_get(Ecore_Ipc_Client *cl)
822 return cl->data; 858 return cl->data;
823} 859}
824 860
861/**
862 * Sets the max data payload size for an Ipc message in bytes
863 *
864 * @param client The given client.
865 * @param size The maximum data payload size in bytes.
866 * @ingroup Ecore_Ipc_Client_Group
867 */
825EAPI void 868EAPI void
826ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size) 869ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size)
827{ 870{
@@ -834,6 +877,13 @@ ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size)
834 cl->max_buf_size = size; 877 cl->max_buf_size = size;
835} 878}
836 879
880/**
881 * Sets the max data payload size for an Ipc message in bytes
882 *
883 * @param cl The given client.
884 * @param size The maximum data payload size in bytes.
885 * @ingroup Ecore_Ipc_Client_Group
886 */
837EAPI int 887EAPI int
838ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl) 888ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl)
839{ 889{
@@ -847,6 +897,28 @@ ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl)
847} 897}
848 898
849/** 899/**
900 * Gets the IP address of a client that has been connected to.
901 *
902 * @param cl The given client.
903 * @return A pointer to an internal string that contains the IP address of
904 * the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
905 * This string should not be modified or trusted to stay valid after
906 * deletion for the @p cl object. If no IP is known NULL is returned.
907 * @ingroup Ecore_Ipc_Client_Group
908 */
909EAPI char *
910ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl)
911{
912 if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
913 {
914 ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
915 "ecore_con_client_ip_get");
916 return NULL;
917 }
918 return ecore_con_client_ip_get(cl->client);
919}
920
921/**
850 * Returns if SSL support is available 922 * Returns if SSL support is available
851 * @return 1 if SSL is available, 0 if it is not. 923 * @return 1 if SSL is available, 0 if it is not.
852 * @ingroup Ecore_Con_Client_Group 924 * @ingroup Ecore_Con_Client_Group