forked from enlightenment/efl
Ecore-con: Test for IPV6 availability
SVN revision: 63680
This commit is contained in:
parent
ed03a201ef
commit
1fc4a13f80
|
@ -1303,6 +1303,22 @@ have_openssl="no"
|
|||
have_cares="no"
|
||||
if test "x${have_ecore_con}" = "xyes" ; then
|
||||
|
||||
# Verify IPV6 availability in headers
|
||||
have_ipv6="no"
|
||||
AC_CHECK_TYPES([struct ipv6_mreq], [have_ipv6="yes"], [have_ipv6="no"],
|
||||
[[
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
]])
|
||||
|
||||
if test "x${have_ipv6}" = "xyes" ; then
|
||||
AC_DEFINE(HAVE_IPV6, 1, [Define if IPV6 is supported])
|
||||
fi
|
||||
|
||||
ECORE_CHECK_CURL([${want_curl}],
|
||||
[
|
||||
have_curl="yes"
|
||||
|
|
|
@ -869,7 +869,11 @@ ecore_con_client_port_get(Ecore_Con_Client *cl)
|
|||
}
|
||||
if (cl->client_addr->sa_family == AF_INET)
|
||||
return ((struct sockaddr_in*)cl->client_addr)->sin_port;
|
||||
#ifdef HAVE_IPV6
|
||||
return ((struct sockaddr_in6*)cl->client_addr)->sin6_port;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI double
|
||||
|
@ -1440,7 +1444,9 @@ _ecore_con_cb_udp_listen(void *data,
|
|||
Ecore_Con_Server *svr;
|
||||
Ecore_Con_Type type;
|
||||
struct ip_mreq mreq;
|
||||
#ifdef HAVE_IPV6
|
||||
struct ipv6_mreq mreq6;
|
||||
#endif
|
||||
const int on = 1;
|
||||
|
||||
svr = data;
|
||||
|
@ -1477,6 +1483,7 @@ _ecore_con_cb_udp_listen(void *data,
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_IPV6
|
||||
else if (net_info->info.ai_family == AF_INET6)
|
||||
{
|
||||
if (!inet_pton(net_info->info.ai_family, net_info->ip,
|
||||
|
@ -1493,6 +1500,7 @@ _ecore_con_cb_udp_listen(void *data,
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof(on)) != 0)
|
||||
|
@ -1765,6 +1773,9 @@ static const char *
|
|||
_ecore_con_pretty_ip(struct sockaddr *client_addr,
|
||||
socklen_t size)
|
||||
{
|
||||
#ifndef HAVE_IPV6
|
||||
char ipbuf[INET_ADDRSTRLEN + 1];
|
||||
#else
|
||||
char ipbuf[INET6_ADDRSTRLEN + 1];
|
||||
|
||||
/* show v4mapped address in pretty form */
|
||||
|
@ -1783,6 +1794,7 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr,
|
|||
return eina_stringshare_add(ipbuf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (getnameinfo(client_addr, size, ipbuf, sizeof (ipbuf), NULL, 0, NI_NUMERICHOST))
|
||||
return eina_stringshare_add("0.0.0.0");
|
||||
|
|
|
@ -41,7 +41,9 @@ struct _Ecore_Con_CAres
|
|||
|
||||
union {
|
||||
struct in_addr v4;
|
||||
#ifdef HAVE_IPV6
|
||||
struct in6_addr v6;
|
||||
#endif
|
||||
} addr;
|
||||
|
||||
Eina_Bool byaddr : 1;
|
||||
|
@ -124,7 +126,11 @@ ecore_con_info_tcp_connect(Ecore_Con_Server *svr,
|
|||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
#ifdef HAVE_IPV6
|
||||
hints.ai_family = AF_INET6;
|
||||
#else
|
||||
hints.ai_family = AF_INET;
|
||||
#endif
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
@ -143,7 +149,11 @@ ecore_con_info_tcp_listen(Ecore_Con_Server *svr,
|
|||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
#ifdef HAVE_IPV6
|
||||
hints.ai_family = AF_INET6;
|
||||
#else
|
||||
hints.ai_family = AF_INET;
|
||||
#endif
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
@ -162,7 +172,11 @@ ecore_con_info_udp_connect(Ecore_Con_Server *svr,
|
|||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
#ifdef HAVE_IPV6
|
||||
hints.ai_family = AF_INET6;
|
||||
#else
|
||||
hints.ai_family = AF_INET;
|
||||
#endif
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
@ -181,7 +195,11 @@ ecore_con_info_udp_listen(Ecore_Con_Server *svr,
|
|||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
#ifdef HAVE_IPV6
|
||||
hints.ai_family = AF_INET6;
|
||||
#else
|
||||
hints.ai_family = AF_INET;
|
||||
#endif
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
@ -200,7 +218,11 @@ ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
|
|||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
#ifdef HAVE_IPV6
|
||||
hints.ai_family = AF_INET6;
|
||||
#else
|
||||
hints.ai_family = AF_INET;
|
||||
#endif
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_flags = 0;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
@ -262,7 +284,11 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
|||
struct addrinfo *hints)
|
||||
{
|
||||
Ecore_Con_CAres *cares;
|
||||
#ifdef HAVE_IPV6
|
||||
int ai_family = AF_INET6;
|
||||
#else
|
||||
int ai_family = AF_INET;
|
||||
#endif
|
||||
|
||||
cares = calloc(1, sizeof(Ecore_Con_CAres));
|
||||
if (!cares)
|
||||
|
@ -288,6 +314,7 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
|||
(ares_host_callback)_ecore_con_info_ares_host_cb,
|
||||
cares);
|
||||
}
|
||||
#ifdef HAVE_IPV6
|
||||
else if (inet_pton(AF_INET6, svr->name, &cares->addr.v6) == 1)
|
||||
{
|
||||
cares->byaddr = EINA_TRUE;
|
||||
|
@ -298,6 +325,7 @@ ecore_con_info_get(Ecore_Con_Server *svr,
|
|||
(ares_host_callback)_ecore_con_info_ares_host_cb,
|
||||
cares);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
cares->byaddr = EINA_FALSE;
|
||||
|
@ -432,7 +460,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
addr = (struct sockaddr *)addri;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *addri6;
|
||||
|
@ -454,7 +482,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
addr = (struct sockaddr *)addri6;
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
default:
|
||||
ERR("Unknown addrtype %i", hostent->h_addrtype);
|
||||
goto on_error;
|
||||
|
@ -470,6 +498,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
case ARES_ENOTFOUND: /* address notfound */
|
||||
if (arg->byaddr)
|
||||
{
|
||||
#ifdef HAVE_IPV6
|
||||
/* This happen when host doesn't have a reverse. */
|
||||
if (arg->isv6)
|
||||
{
|
||||
|
@ -492,6 +521,7 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
addr = (struct sockaddr *)addri6;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct sockaddr_in *addri;
|
||||
|
||||
|
@ -511,8 +541,11 @@ _ecore_con_info_ares_host_cb(Ecore_Con_CAres *arg,
|
|||
}
|
||||
|
||||
if (!_ecore_con_info_ares_getnameinfo(arg,
|
||||
#ifdef HAVE_IPV6
|
||||
arg->isv6 ? AF_INET6 :
|
||||
#else
|
||||
AF_INET,
|
||||
#endif
|
||||
NULL, addr,
|
||||
addrlen))
|
||||
goto on_error;
|
||||
|
|
Loading…
Reference in New Issue