From 276eccb1bf702177b44824a689393d729cbc42a3 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 11 Feb 2011 07:38:27 +0000 Subject: [PATCH] +ecore_con_client_port_get SVN revision: 56950 --- legacy/ecore/ChangeLog | 4 ++++ legacy/ecore/src/lib/ecore_con/Ecore_Con.h | 1 + legacy/ecore/src/lib/ecore_con/ecore_con.c | 21 ++++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog index 637386b1ff..e9b5e9b4ce 100644 --- a/legacy/ecore/ChangeLog +++ b/legacy/ecore/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/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h index 5a562e6b2f..753e19d3a3 100644 --- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h +++ b/legacy/ecore/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/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c index a367cda783..cb8c328543 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con.c +++ b/legacy/ecore/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 @@ -1104,6 +1104,25 @@ ecore_con_client_ip_get(Ecore_Con_Client *cl) return cl->ip; } +/** + * @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