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);
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);
}
/**
+ * 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
*
* Functions that operate on Ecore connection client objects.
}
/**
+ * 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.
* @ingroup Ecore_Con_Client_Group
#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);
}
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);
}
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);
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;
Ecore_Con_Server *svr;
struct sockaddr_in socket_addr;
int curstate = 0;
+ char buf[64];
+ uint32_t ip;
svr = data;
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)
int buf_size;
int buf_offset;
unsigned char *buf;
+ char *ip;
int event_count;
char dead : 1;
char delete_me : 1;
SSL_CTX *ssl_ctx;
SSL *ssl;
#endif
+ char *ip;
char dead : 1;
char created : 1;
char connecting : 1;
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);
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 */
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)
{
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)
{
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); \
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)
{
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)
{
}
/**
+ * 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.
* @ingroup Ecore_Con_Client_Group