From bdfbaac8c07a326e708e7a8132dd451adabc4a6c Mon Sep 17 00:00:00 2001 From: discomfitor Date: Fri, 11 Feb 2011 07:38:27 +0000 Subject: [PATCH] +ecore_con_client_port_get git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@56950 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 4 ++++ src/lib/ecore_con/Ecore_Con.h | 1 + src/lib/ecore_con/ecore_con.c | 21 ++++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 637386b..e9b5e9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,3 +30,7 @@ * Unify event handler code * Always increment server event count for client events + +2011-02-11 Mike Blumenkrantz + + * Added ecore_con_client_port_get diff --git a/src/lib/ecore_con/Ecore_Con.h b/src/lib/ecore_con/Ecore_Con.h index 5a562e6..753e19d 100644 --- a/src/lib/ecore_con/Ecore_Con.h +++ b/src/lib/ecore_con/Ecore_Con.h @@ -485,6 +485,7 @@ EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl); EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl); EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout); EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl); +EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl); /** * @} diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c index a367cda..cb8c328 100644 --- a/src/lib/ecore_con/ecore_con.c +++ b/src/lib/ecore_con/ecore_con.c @@ -1082,7 +1082,7 @@ ecore_con_client_data_get(Ecore_Con_Client *cl) } /** - * Gets the IP address of a cleint that has connected. + * Gets the IP address of a client that has connected. * * @param cl The given client. * @return A pointer to an internal string that contains the IP address of @@ -1105,6 +1105,25 @@ ecore_con_client_ip_get(Ecore_Con_Client *cl) } /** + * @brief Return the port that the client has connected to + * @param cl The client + * @return The port that @p cl has connected to, or -1 on error + * Use this function to return the port on which a given client has connected. + */ +EAPI int +ecore_con_client_port_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_port_get"); + return -1; + } + if (cl->client_addr->sa_family == AF_INET) + return ((struct sockaddr_in*)cl->client_addr)->sin_port; + return ((struct sockaddr_in6*)cl->client_addr)->sin6_port; +} + +/** * @brief Check how long a client has been connected * @param cl The client to check * @return The total time, in seconds, that the client has been connected to the server -- 2.7.4