mirror of
https://github.com/irssi/irssi.git
synced 2025-04-26 13:01:11 -05:00
Merge pull request #408 from LemonBoy/delete-ipv6-ifdef
Delete the HAVE_IPV6 ifdef.
This commit is contained in:
commit
26431133aa
4
INSTALL
4
INSTALL
@ -29,10 +29,6 @@ configure options
|
|||||||
|
|
||||||
Build the irssi proxy (see startup-HOWTO).
|
Build the irssi proxy (see startup-HOWTO).
|
||||||
|
|
||||||
--disable-ipv6
|
|
||||||
|
|
||||||
Disable IPv6 support.
|
|
||||||
|
|
||||||
--disable-ssl
|
--disable-ssl
|
||||||
|
|
||||||
Disable SSL support.
|
Disable SSL support.
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* misc.. */
|
/* misc.. */
|
||||||
#undef HAVE_IPV6
|
|
||||||
#undef HAVE_SOCKS_H
|
#undef HAVE_SOCKS_H
|
||||||
#undef HAVE_STATIC_PERL
|
#undef HAVE_STATIC_PERL
|
||||||
#undef HAVE_GMODULE
|
#undef HAVE_GMODULE
|
||||||
|
33
configure.ac
33
configure.ac
@ -140,15 +140,6 @@ AC_ARG_WITH(perl,
|
|||||||
fi,
|
fi,
|
||||||
want_perl=static)
|
want_perl=static)
|
||||||
|
|
||||||
AC_ARG_ENABLE(ipv6,
|
|
||||||
[ --disable-ipv6 Disable IPv6 support],
|
|
||||||
if test x$enableval = xno; then
|
|
||||||
want_ipv6=no
|
|
||||||
else
|
|
||||||
want_ipv6=yes
|
|
||||||
fi,
|
|
||||||
want_ipv6=yes)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(dane,
|
AC_ARG_ENABLE(dane,
|
||||||
[ --enable-dane Enable DANE support],
|
[ --enable-dane Enable DANE support],
|
||||||
if test x$enableval = xno ; then
|
if test x$enableval = xno ; then
|
||||||
@ -577,29 +568,6 @@ COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
|
|||||||
AC_SUBST(COMMON_NOUI_LIBS)
|
AC_SUBST(COMMON_NOUI_LIBS)
|
||||||
AC_SUBST(COMMON_LIBS)
|
AC_SUBST(COMMON_LIBS)
|
||||||
|
|
||||||
dnl **
|
|
||||||
dnl ** IPv6 support
|
|
||||||
dnl **
|
|
||||||
|
|
||||||
have_ipv6=no
|
|
||||||
if test "x$want_ipv6" = "xyes"; then
|
|
||||||
AC_MSG_CHECKING([for IPv6])
|
|
||||||
AC_CACHE_VAL(irssi_cv_type_in6_addr,
|
|
||||||
[AC_TRY_COMPILE([
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <arpa/inet.h>],
|
|
||||||
[struct in6_addr i = in6addr_any; return &i == &i;],
|
|
||||||
have_ipv6=yes,
|
|
||||||
)])
|
|
||||||
if test $have_ipv6 = yes; then
|
|
||||||
AC_DEFINE(HAVE_IPV6)
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($have_ipv6)
|
|
||||||
fi
|
|
||||||
|
|
||||||
have_dane=no
|
have_dane=no
|
||||||
if test "x$want_dane" = "xyes"; then
|
if test "x$want_dane" = "xyes"; then
|
||||||
AC_MSG_CHECKING([for DANE])
|
AC_MSG_CHECKING([for DANE])
|
||||||
@ -742,7 +710,6 @@ echo "Install prefix ................... : $prefix"
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Building with IPv6 support ....... : $have_ipv6"
|
|
||||||
echo "Building with SSL support ........ : $have_openssl"
|
echo "Building with SSL support ........ : $have_openssl"
|
||||||
if test "x$have_openssl" = "xno" -a "x$enable_ssl" = "xyes"; then
|
if test "x$have_openssl" = "xno" -a "x$enable_ssl" = "xyes"; then
|
||||||
if test -f /etc/debian_version; then
|
if test -f /etc/debian_version; then
|
||||||
|
@ -30,17 +30,11 @@
|
|||||||
union sockaddr_union {
|
union sockaddr_union {
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
struct sockaddr_in6 sin6;
|
struct sockaddr_in6 sin6;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#define SIZEOF_SOCKADDR(so) ((so).sa.sa_family == AF_INET6 ? \
|
||||||
# define SIZEOF_SOCKADDR(so) ((so).sa.sa_family == AF_INET6 ? \
|
|
||||||
sizeof(so.sin6) : sizeof(so.sin))
|
sizeof(so.sin6) : sizeof(so.sin))
|
||||||
#else
|
|
||||||
# define SIZEOF_SOCKADDR(so) (sizeof(so.sin))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GIOChannel *g_io_channel_new(int handle)
|
GIOChannel *g_io_channel_new(int handle)
|
||||||
{
|
{
|
||||||
@ -56,7 +50,7 @@ GIOChannel *g_io_channel_new(int handle)
|
|||||||
|
|
||||||
IPADDR ip4_any = {
|
IPADDR ip4_any = {
|
||||||
AF_INET,
|
AF_INET,
|
||||||
#if defined(HAVE_IPV6) && defined(IN6ADDR_ANY_INIT)
|
#if defined(IN6ADDR_ANY_INIT)
|
||||||
IN6ADDR_ANY_INIT
|
IN6ADDR_ANY_INIT
|
||||||
#else
|
#else
|
||||||
{ INADDR_ANY }
|
{ INADDR_ANY }
|
||||||
@ -68,10 +62,8 @@ int net_ip_compare(IPADDR *ip1, IPADDR *ip2)
|
|||||||
if (ip1->family != ip2->family)
|
if (ip1->family != ip2->family)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (ip1->family == AF_INET6)
|
if (ip1->family == AF_INET6)
|
||||||
return memcmp(&ip1->ip, &ip2->ip, sizeof(ip1->ip)) == 0;
|
return memcmp(&ip1->ip, &ip2->ip, sizeof(ip1->ip)) == 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
return memcmp(&ip1->ip, &ip2->ip, 4) == 0;
|
return memcmp(&ip1->ip, &ip2->ip, 4) == 0;
|
||||||
}
|
}
|
||||||
@ -80,22 +72,16 @@ int net_ip_compare(IPADDR *ip1, IPADDR *ip2)
|
|||||||
static void sin_set_ip(union sockaddr_union *so, const IPADDR *ip)
|
static void sin_set_ip(union sockaddr_union *so, const IPADDR *ip)
|
||||||
{
|
{
|
||||||
if (ip == NULL) {
|
if (ip == NULL) {
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
so->sin6.sin6_family = AF_INET6;
|
so->sin6.sin6_family = AF_INET6;
|
||||||
so->sin6.sin6_addr = in6addr_any;
|
so->sin6.sin6_addr = in6addr_any;
|
||||||
#else
|
|
||||||
so->sin.sin_family = AF_INET;
|
|
||||||
so->sin.sin_addr.s_addr = INADDR_ANY;
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
so->sin.sin_family = ip->family;
|
so->sin.sin_family = ip->family;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (ip->family == AF_INET6)
|
if (ip->family == AF_INET6)
|
||||||
memcpy(&so->sin6.sin6_addr, &ip->ip, sizeof(ip->ip));
|
memcpy(&so->sin6.sin6_addr, &ip->ip, sizeof(ip->ip));
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
memcpy(&so->sin.sin_addr, &ip->ip, 4);
|
memcpy(&so->sin.sin_addr, &ip->ip, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,31 +89,25 @@ void sin_get_ip(const union sockaddr_union *so, IPADDR *ip)
|
|||||||
{
|
{
|
||||||
ip->family = so->sin.sin_family;
|
ip->family = so->sin.sin_family;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (ip->family == AF_INET6)
|
if (ip->family == AF_INET6)
|
||||||
memcpy(&ip->ip, &so->sin6.sin6_addr, sizeof(ip->ip));
|
memcpy(&ip->ip, &so->sin6.sin6_addr, sizeof(ip->ip));
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
memcpy(&ip->ip, &so->sin.sin_addr, 4);
|
memcpy(&ip->ip, &so->sin.sin_addr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sin_set_port(union sockaddr_union *so, int port)
|
static void sin_set_port(union sockaddr_union *so, int port)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (so->sin.sin_family == AF_INET6)
|
if (so->sin.sin_family == AF_INET6)
|
||||||
so->sin6.sin6_port = htons((unsigned short)port);
|
so->sin6.sin6_port = htons((unsigned short)port);
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
so->sin.sin_port = htons((unsigned short)port);
|
so->sin.sin_port = htons((unsigned short)port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sin_get_port(union sockaddr_union *so)
|
static int sin_get_port(union sockaddr_union *so)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
return ntohs((so->sin.sin_family == AF_INET6) ?
|
||||||
if (so->sin.sin_family == AF_INET6)
|
so->sin6.sin6_port :
|
||||||
return ntohs(so->sin6.sin6_port);
|
so->sin.sin_port);
|
||||||
#endif
|
|
||||||
return ntohs(so->sin.sin_port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect to socket */
|
/* Connect to socket */
|
||||||
@ -272,7 +252,7 @@ GIOChannel *net_listen(IPADDR *my_ip, int *port)
|
|||||||
|
|
||||||
/* create the socket */
|
/* create the socket */
|
||||||
handle = socket(so.sin.sin_family, SOCK_STREAM, 0);
|
handle = socket(so.sin.sin_family, SOCK_STREAM, 0);
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (handle == -1 && (errno == EINVAL || errno == EAFNOSUPPORT)) {
|
if (handle == -1 && (errno == EINVAL || errno == EAFNOSUPPORT)) {
|
||||||
/* IPv6 is not supported by OS */
|
/* IPv6 is not supported by OS */
|
||||||
so.sin.sin_family = AF_INET;
|
so.sin.sin_family = AF_INET;
|
||||||
@ -280,7 +260,7 @@ GIOChannel *net_listen(IPADDR *my_ip, int *port)
|
|||||||
|
|
||||||
handle = socket(AF_INET, SOCK_STREAM, 0);
|
handle = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -399,21 +379,15 @@ int net_getsockname(GIOChannel *handle, IPADDR *addr, int *port)
|
|||||||
Returns 0 = ok, others = error code for net_gethosterror() */
|
Returns 0 = ok, others = error code for net_gethosterror() */
|
||||||
int net_gethostbyname(const char *addr, IPADDR *ip4, IPADDR *ip6)
|
int net_gethostbyname(const char *addr, IPADDR *ip4, IPADDR *ip6)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
union sockaddr_union *so;
|
union sockaddr_union *so;
|
||||||
struct addrinfo hints, *ai, *ailist;
|
struct addrinfo hints, *ai, *ailist;
|
||||||
int ret, count_v4, count_v6, use_v4, use_v6;
|
int ret, count_v4, count_v6, use_v4, use_v6;
|
||||||
#else
|
|
||||||
struct hostent *hp;
|
|
||||||
int count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_val_if_fail(addr != NULL, -1);
|
g_return_val_if_fail(addr != NULL, -1);
|
||||||
|
|
||||||
memset(ip4, 0, sizeof(IPADDR));
|
memset(ip4, 0, sizeof(IPADDR));
|
||||||
memset(ip6, 0, sizeof(IPADDR));
|
memset(ip6, 0, sizeof(IPADDR));
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
memset(&hints, 0, sizeof(struct addrinfo));
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
@ -454,44 +428,21 @@ int net_gethostbyname(const char *addr, IPADDR *ip4, IPADDR *ip6)
|
|||||||
}
|
}
|
||||||
freeaddrinfo(ailist);
|
freeaddrinfo(ailist);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
|
||||||
hp = gethostbyname(addr);
|
|
||||||
if (hp == NULL)
|
|
||||||
return h_errno;
|
|
||||||
|
|
||||||
/* count IPs */
|
|
||||||
count = 0;
|
|
||||||
while (hp->h_addr_list[count] != NULL)
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (count == 0)
|
|
||||||
return HOST_NOT_FOUND; /* shouldn't happen? */
|
|
||||||
|
|
||||||
/* if there are multiple addresses, return random one */
|
|
||||||
ip4->family = AF_INET;
|
|
||||||
memcpy(&ip4->ip, hp->h_addr_list[rand() % count], 4);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get name for host, *name should be g_free()'d unless it's NULL.
|
/* Get name for host, *name should be g_free()'d unless it's NULL.
|
||||||
Return values are the same as with net_gethostbyname() */
|
Return values are the same as with net_gethostbyname() */
|
||||||
int net_gethostbyaddr(IPADDR *ip, char **name)
|
int net_gethostbyaddr(IPADDR *ip, char **name)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
union sockaddr_union so;
|
union sockaddr_union so;
|
||||||
int host_error;
|
int host_error;
|
||||||
char hostname[NI_MAXHOST];
|
char hostname[NI_MAXHOST];
|
||||||
#else
|
|
||||||
struct hostent *hp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_val_if_fail(ip != NULL, -1);
|
g_return_val_if_fail(ip != NULL, -1);
|
||||||
g_return_val_if_fail(name != NULL, -1);
|
g_return_val_if_fail(name != NULL, -1);
|
||||||
|
|
||||||
*name = NULL;
|
*name = NULL;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
memset(&so, 0, sizeof(so));
|
memset(&so, 0, sizeof(so));
|
||||||
sin_set_ip(&so, ip);
|
sin_set_ip(&so, ip);
|
||||||
|
|
||||||
@ -502,37 +453,13 @@ int net_gethostbyaddr(IPADDR *ip, char **name)
|
|||||||
return host_error;
|
return host_error;
|
||||||
|
|
||||||
*name = g_strdup(hostname);
|
*name = g_strdup(hostname);
|
||||||
#else
|
|
||||||
if (ip->family != AF_INET) return -1;
|
|
||||||
hp = gethostbyaddr((const char *) &ip->ip, 4, AF_INET);
|
|
||||||
if (hp == NULL) return -1;
|
|
||||||
|
|
||||||
*name = g_strdup(hp->h_name);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int net_ip2host(IPADDR *ip, char *host)
|
int net_ip2host(IPADDR *ip, char *host)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
return inet_ntop(ip->family, &ip->ip, host, MAX_IP_LEN) ? 0 : -1;
|
||||||
if (!inet_ntop(ip->family, &ip->ip, host, MAX_IP_LEN))
|
|
||||||
return -1;
|
|
||||||
#else
|
|
||||||
unsigned long ip4;
|
|
||||||
|
|
||||||
if (ip->family != AF_INET) {
|
|
||||||
strcpy(host, "0.0.0.0");
|
|
||||||
} else {
|
|
||||||
ip4 = ntohl(ip->ip.s_addr);
|
|
||||||
g_snprintf(host, MAX_IP_LEN, "%lu.%lu.%lu.%lu",
|
|
||||||
(ip4 & 0xff000000UL) >> 24,
|
|
||||||
(ip4 & 0x00ff0000) >> 16,
|
|
||||||
(ip4 & 0x0000ff00) >> 8,
|
|
||||||
(ip4 & 0x000000ff));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int net_host2ip(const char *host, IPADDR *ip)
|
int net_host2ip(const char *host, IPADDR *ip)
|
||||||
@ -542,12 +469,8 @@ int net_host2ip(const char *host, IPADDR *ip)
|
|||||||
if (strchr(host, ':') != NULL) {
|
if (strchr(host, ':') != NULL) {
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
ip->family = AF_INET6;
|
ip->family = AF_INET6;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (inet_pton(AF_INET6, host, &ip->ip) == 0)
|
if (inet_pton(AF_INET6, host, &ip->ip) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
|
||||||
ip->ip.s_addr = 0;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
ip->family = AF_INET;
|
ip->family = AF_INET;
|
||||||
@ -582,40 +505,20 @@ int net_geterror(GIOChannel *handle)
|
|||||||
/* get error of net_gethostname() */
|
/* get error of net_gethostname() */
|
||||||
const char *net_gethosterror(int error)
|
const char *net_gethosterror(int error)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
g_return_val_if_fail(error != 0, NULL);
|
g_return_val_if_fail(error != 0, NULL);
|
||||||
|
|
||||||
return gai_strerror(error);
|
return gai_strerror(error);
|
||||||
#else
|
|
||||||
switch (error) {
|
|
||||||
case HOST_NOT_FOUND:
|
|
||||||
return "Host not found";
|
|
||||||
case NO_ADDRESS:
|
|
||||||
return "No IP address found for name";
|
|
||||||
case NO_RECOVERY:
|
|
||||||
return "A non-recovable name server error occurred";
|
|
||||||
case TRY_AGAIN:
|
|
||||||
return "A temporary error on an authoritative name server";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* unknown error */
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return TRUE if host lookup failed because it didn't exist (ie. not
|
/* return TRUE if host lookup failed because it didn't exist (ie. not
|
||||||
some error with name server) */
|
some error with name server) */
|
||||||
int net_hosterror_notfound(int error)
|
int net_hosterror_notfound(int error)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
#ifdef EAI_NODATA /* NODATA is deprecated */
|
#ifdef EAI_NODATA /* NODATA is deprecated */
|
||||||
return error != 1 && (error == EAI_NONAME || error == EAI_NODATA);
|
return error != 1 && (error == EAI_NONAME || error == EAI_NODATA);
|
||||||
#else
|
#else
|
||||||
return error != 1 && (error == EAI_NONAME);
|
return error != 1 && (error == EAI_NONAME);
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
return error == HOST_NOT_FOUND || error == NO_ADDRESS;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get name of TCP service */
|
/* Get name of TCP service */
|
||||||
|
@ -21,19 +21,11 @@
|
|||||||
|
|
||||||
struct _IPADDR {
|
struct _IPADDR {
|
||||||
unsigned short family;
|
unsigned short family;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
struct in6_addr ip;
|
struct in6_addr ip;
|
||||||
#else
|
|
||||||
struct in_addr ip;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* maxmimum string length of IP address */
|
/* maxmimum string length of IP address */
|
||||||
#ifdef HAVE_IPV6
|
#define MAX_IP_LEN INET6_ADDRSTRLEN
|
||||||
# define MAX_IP_LEN INET6_ADDRSTRLEN
|
|
||||||
#else
|
|
||||||
# define MAX_IP_LEN 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IPADDR_IS_V6(ip) ((ip)->family != AF_INET)
|
#define IPADDR_IS_V6(ip) ((ip)->family != AF_INET)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user