forked from enlightenment/efl
add calls to get ip addr of client or server (NULL for created servers of
course) and comments/docs SVN revision: 21437
This commit is contained in:
parent
4924cf8ba2
commit
e8929d7043
|
@ -151,12 +151,14 @@ extern "C" {
|
|||
EAPI int ecore_con_server_connected_get(Ecore_Con_Server *svr);
|
||||
EAPI int ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size);
|
||||
EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char reject_excess_clients);
|
||||
EAPI char *ecore_con_server_ip_get(Ecore_Con_Server *svr);
|
||||
|
||||
EAPI int ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size);
|
||||
EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
|
||||
EAPI void *ecore_con_client_del(Ecore_Con_Client *cl);
|
||||
EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data);
|
||||
EAPI void *ecore_con_client_data_get(Ecore_Con_Client *cl);
|
||||
EAPI char *ecore_con_client_ip_get(Ecore_Con_Client *cl);
|
||||
|
||||
EAPI int ecore_con_ssl_available_get(void);
|
||||
|
||||
|
|
|
@ -338,6 +338,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
|
|||
if (svr->fd >= 0) close(svr->fd);
|
||||
if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
|
||||
if (svr->write_buf) free(svr->write_buf);
|
||||
if (svr->ip) free(svr->ip);
|
||||
#if USE_OPENSSL
|
||||
if (svr->ssl) SSL_free(svr->ssl);
|
||||
if (svr->ssl_ctx) SSL_CTX_free(svr->ssl_ctx);
|
||||
|
@ -626,6 +627,28 @@ ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char
|
|||
svr->reject_excess_clients = reject_excess_clients;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IP address of a server that has been connected to.
|
||||
*
|
||||
* @param svr The given server.
|
||||
* @return A pointer to an internal string that contains the IP address of
|
||||
* the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
|
||||
* This string should not be modified or trusted to stay valid after
|
||||
* deletion for the @p svr object. If no IP is known NULL is returned.
|
||||
* @ingroup Ecore_Con_Server_Group
|
||||
*/
|
||||
EAPI char *
|
||||
ecore_con_server_ip_get(Ecore_Con_Server *svr)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
|
||||
{
|
||||
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
|
||||
"ecore_con_server_ip_get");
|
||||
return NULL;
|
||||
}
|
||||
return svr->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions
|
||||
*
|
||||
|
@ -760,6 +783,28 @@ ecore_con_client_data_get(Ecore_Con_Client *cl)
|
|||
return cl->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IP address of a cleint that has connected.
|
||||
*
|
||||
* @param cl The given client.
|
||||
* @return A pointer to an internal string that contains the IP address of
|
||||
* the connected client in the form "XXX.YYY.ZZZ.AAA" IP notation.
|
||||
* This string should not be modified or trusted to stay valid after
|
||||
* deletion for the @p cl object. If no IP is known NULL is returned.
|
||||
* @ingroup Ecore_Con_Client_Group
|
||||
*/
|
||||
EAPI char *
|
||||
ecore_con_client_ip_get(Ecore_Con_Client *cl)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
||||
{
|
||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
|
||||
"ecore_con_client_ip_get");
|
||||
return NULL;
|
||||
}
|
||||
return cl->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if SSL support is available
|
||||
* @return 1 if SSL is available, 0 if it is not.
|
||||
|
@ -796,6 +841,7 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
|
|||
#endif
|
||||
if (svr->name) free(svr->name);
|
||||
if (svr->path) free(svr->path);
|
||||
if (svr->ip) free(svr->ip);
|
||||
if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
|
||||
free(svr);
|
||||
}
|
||||
|
@ -808,6 +854,7 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
|
|||
if (cl->buf) free(cl->buf);
|
||||
if (cl->fd >= 0) close(cl->fd);
|
||||
if (cl->fd_handler) ecore_main_fd_handler_del(cl->fd_handler);
|
||||
if (cl->ip) free(cl->ip);
|
||||
free(cl);
|
||||
}
|
||||
|
||||
|
@ -831,7 +878,9 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
|||
if (new_fd >= 0)
|
||||
{
|
||||
Ecore_Con_Client *cl;
|
||||
|
||||
char buf[64];
|
||||
uint32_t ip;
|
||||
|
||||
if ((svr->client_limit >= 0) && (svr->reject_excess_clients))
|
||||
{
|
||||
close(new_fd);
|
||||
|
@ -854,6 +903,14 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
|
|||
cl, NULL, NULL);
|
||||
ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);
|
||||
ecore_list_append(svr->clients, cl);
|
||||
ip = incoming.sin_addr.s_addr;
|
||||
snprintf(buf, sizeof(buf),
|
||||
"%i.%i.%i.%i",
|
||||
(ip ) & 0xff,
|
||||
(ip >> 8 ) & 0xff,
|
||||
(ip >> 16) & 0xff,
|
||||
(ip >> 24) & 0xff);
|
||||
cl->ip = strdup(buf);
|
||||
{
|
||||
Ecore_Con_Event_Client_Add *e;
|
||||
|
||||
|
@ -925,6 +982,8 @@ _ecore_con_cb_dns_lookup(void *data, struct hostent *he)
|
|||
Ecore_Con_Server *svr;
|
||||
struct sockaddr_in socket_addr;
|
||||
int curstate = 0;
|
||||
char buf[64];
|
||||
uint32_t ip;
|
||||
|
||||
svr = data;
|
||||
|
||||
|
@ -955,6 +1014,14 @@ _ecore_con_cb_dns_lookup(void *data, struct hostent *he)
|
|||
NULL, NULL);
|
||||
|
||||
if (!svr->fd_handler) goto error;
|
||||
ip = socket_addr.sin_addr.s_addr;
|
||||
snprintf(buf, sizeof(buf),
|
||||
"%i.%i.%i.%i",
|
||||
(ip ) & 0xff,
|
||||
(ip >> 8 ) & 0xff,
|
||||
(ip >> 16) & 0xff,
|
||||
(ip >> 24) & 0xff);
|
||||
svr->ip = strdup(buf);
|
||||
|
||||
#if USE_OPENSSL
|
||||
if (svr->type & ECORE_CON_USE_SSL)
|
||||
|
|
|
@ -44,6 +44,7 @@ struct _Ecore_Con_Client
|
|||
int buf_size;
|
||||
int buf_offset;
|
||||
unsigned char *buf;
|
||||
char *ip;
|
||||
int event_count;
|
||||
char dead : 1;
|
||||
char delete_me : 1;
|
||||
|
@ -71,6 +72,7 @@ struct _Ecore_Con_Server
|
|||
SSL_CTX *ssl_ctx;
|
||||
SSL *ssl;
|
||||
#endif
|
||||
char *ip;
|
||||
char dead : 1;
|
||||
char created : 1;
|
||||
char connecting : 1;
|
||||
|
|
|
@ -299,7 +299,8 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v);
|
|||
EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients);
|
||||
EAPI void ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *srv, int size);
|
||||
EAPI int ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *srv);
|
||||
|
||||
EAPI char *ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr);
|
||||
|
||||
/* FIXME: this needs to become an ipc message */
|
||||
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);
|
||||
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);
|
|||
EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl);
|
||||
EAPI void ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size);
|
||||
EAPI int ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl);
|
||||
EAPI char *ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl);
|
||||
|
||||
EAPI int ecore_ipc_ssl_available_get(void);
|
||||
/* FIXME: need to add a callback to "ok" large ipc messages greater than */
|
||||
|
|
|
@ -612,6 +612,13 @@ ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char
|
|||
ecore_con_server_client_limit_set(svr->server, client_limit, reject_excess_clients);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max data payload size for an Ipc message in bytes
|
||||
*
|
||||
* @param svr The given server.
|
||||
* @param size The maximum data payload size in bytes.
|
||||
* @ingroup Ecore_Ipc_Server_Group
|
||||
*/
|
||||
EAPI void
|
||||
ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size)
|
||||
{
|
||||
|
@ -624,6 +631,13 @@ ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size)
|
|||
svr->max_buf_size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max data payload size for an Ipc message in bytes
|
||||
*
|
||||
* @param svr The given server.
|
||||
* @return The maximum data payload in bytes.
|
||||
* @ingroup Ecore_Ipc_Server_Group
|
||||
*/
|
||||
EAPI int
|
||||
ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr)
|
||||
{
|
||||
|
@ -636,6 +650,28 @@ ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr)
|
|||
return svr->max_buf_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IP address of a server that has been connected to.
|
||||
*
|
||||
* @param svr The given server.
|
||||
* @return A pointer to an internal string that contains the IP address of
|
||||
* the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
|
||||
* This string should not be modified or trusted to stay valid after
|
||||
* deletion for the @p svr object. If no IP is known NULL is returned.
|
||||
* @ingroup Ecore_Ipc_Server_Group
|
||||
*/
|
||||
EAPI char *
|
||||
ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
|
||||
{
|
||||
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
|
||||
"ecore_con_server_ip_get");
|
||||
return NULL;
|
||||
}
|
||||
return ecore_con_server_ip_get(svr->server);
|
||||
}
|
||||
|
||||
|
||||
#define CLENC(_member) \
|
||||
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)
|
|||
return cl->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max data payload size for an Ipc message in bytes
|
||||
*
|
||||
* @param client The given client.
|
||||
* @param size The maximum data payload size in bytes.
|
||||
* @ingroup Ecore_Ipc_Client_Group
|
||||
*/
|
||||
EAPI void
|
||||
ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size)
|
||||
{
|
||||
|
@ -834,6 +877,13 @@ ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size)
|
|||
cl->max_buf_size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max data payload size for an Ipc message in bytes
|
||||
*
|
||||
* @param cl The given client.
|
||||
* @param size The maximum data payload size in bytes.
|
||||
* @ingroup Ecore_Ipc_Client_Group
|
||||
*/
|
||||
EAPI int
|
||||
ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl)
|
||||
{
|
||||
|
@ -846,6 +896,28 @@ ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl)
|
|||
return cl->max_buf_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IP address of a client that has been connected to.
|
||||
*
|
||||
* @param cl The given client.
|
||||
* @return A pointer to an internal string that contains the IP address of
|
||||
* the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
|
||||
* This string should not be modified or trusted to stay valid after
|
||||
* deletion for the @p cl object. If no IP is known NULL is returned.
|
||||
* @ingroup Ecore_Ipc_Client_Group
|
||||
*/
|
||||
EAPI char *
|
||||
ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
|
||||
{
|
||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
|
||||
"ecore_con_client_ip_get");
|
||||
return NULL;
|
||||
}
|
||||
return ecore_con_client_ip_get(cl->client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if SSL support is available
|
||||
* @return 1 if SSL is available, 0 if it is not.
|
||||
|
|
Loading…
Reference in New Issue