Replacing legacy IPV6 define with RB_IPV6 (which is included in libratbox's config.h).

This commit is contained in:
Valery Yatsko 2008-04-05 20:57:30 +04:00
parent 47adde3def
commit ccda6e3fc5
16 changed files with 53 additions and 98 deletions

View file

@ -317,50 +317,6 @@ AC_CHECK_TYPE(socklen_t, ,
AC_ARG_ENABLE(ipv6,
AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
if test $ipv6 != yes; then
have_v6="no"
else
AC_MSG_CHECKING([for core IPv6 support])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#define IN_AUTOCONF
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>]],
[[struct sockaddr_in6 s;
s.sin6_family = 0;]]
)],
[
if test "$CYGWIN" = "yes"; then
AC_MSG_RESULT([no, Cygwin's IPv6 is incomplete])
have_v6=no
else
have_v6=yes
AC_DEFINE(IPV6, 1, [Define if IPv6 support is present and available.])
AC_MSG_RESULT(yes)
AC_MSG_CHECKING([for struct in6addr_any])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#define IN_AUTOCONF
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>]],
[[struct in6_addr a = in6addr_any;]]
)],
[AC_MSG_RESULT(yes)],
[
AC_MSG_RESULT(no)
AC_DEFINE(NO_IN6ADDR_ANY, 1, [Define to 1 if your system has no in6addr_any.])
inet_misc=1
]
)
fi
],
[AC_MSG_RESULT(no)
have_v6="no"])
fi
AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
CRYPT_LIB=$ac_cv_search_crypt
@ -1267,7 +1223,6 @@ Configuration:
Ziplinks : $zlib
OpenSSL : $openssl
IPv6 support : $have_v6
Socket Engine : $SELECT_TYPE
Small network : $small_net
Block allocator : $balloc

View file

@ -139,20 +139,20 @@
#define CLIENT_PARSE_ERROR -1
#define CLIENT_OK 1
#ifdef IPV6
#ifdef RB_IPV6
#ifndef AF_INET6
#error "AF_INET6 not defined"
#endif
#else /* #ifdef IPV6 */
#else /* #ifdef RB_IPV6 */
#ifndef AF_INET6
#define AF_INET6 AF_MAX /* Dummy AF_INET6 declaration */
#endif
#endif /* #ifdef IPV6 */
#endif /* #ifdef RB_IPV6 */
#ifdef IPV6
#ifdef RB_IPV6
#define PATRICIA_BITS 128
#else
#define PATRICIA_BITS 32

View file

@ -47,7 +47,7 @@ struct AuthRequest
unsigned int flags; /* current state of request */
rb_fde_t *F; /* file descriptor for auth queries */
time_t timeout; /* time when query expires */
#ifdef IPV6
#ifdef RB_IPV6
int ip6_int;
#endif
};

View file

@ -91,7 +91,7 @@ mo_etrace(struct Client *client_p, struct Client *source_p, int parc, const char
{
if(!irccmp(parv[1], "-full"))
do_etrace_full(source_p);
#ifdef IPV6
#ifdef RB_IPV6
else if(!irccmp(parv[1], "-v6"))
do_etrace(source_p, 0, 1);
else if(!irccmp(parv[1], "-v4"))
@ -151,7 +151,7 @@ do_etrace(struct Client *source_p, int ipv4, int ipv6)
{
target_p = ptr->data;
#ifdef IPV6
#ifdef RB_IPV6
if((!ipv4 && target_p->localClient->ip.ss_family == AF_INET) ||
(!ipv6 && target_p->localClient->ip.ss_family == AF_INET6))
continue;

View file

@ -701,7 +701,7 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
bits = 0;
if((t = parse_netmask(lhost, (struct sockaddr *)&iphost, &bits)) != HM_HOST)
{
#ifdef IPV6
#ifdef RB_IPV6
if(t == HM_IPV6)
t = AF_INET6;
else

View file

@ -119,7 +119,7 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
/* parses as an IP, check for a dline */
if((type = parse_netmask(host, (struct sockaddr *)&ip, &host_mask)) != HM_HOST)
{
#ifdef IPV6
#ifdef RB_IPV6
if(type == HM_IPV6)
aconf = find_dline((struct sockaddr *)&ip, AF_INET6);
else
@ -153,7 +153,7 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
if((aconf = find_address_conf(host, NULL, user_trunc, notildeuser_trunc,
(type != HM_HOST) ? (struct sockaddr *)&ip : NULL,
(type != HM_HOST) ? (
#ifdef IPV6
#ifdef RB_IPV6
(type == HM_IPV6) ? AF_INET6 :
#endif
AF_INET) : 0)))

View file

@ -149,7 +149,7 @@ confopts(struct Client *source_p)
*p++ = 'Z';
#endif
#ifdef IPV6
#ifdef RB_IPV6
*p++ = '6';
#endif

View file

@ -33,7 +33,7 @@
#include "send.h"
#include "irc_string.h"
#ifdef IPV6
#ifdef RB_IPV6
static unsigned long hash_ipv6(struct sockaddr *, int);
#endif
static unsigned long hash_ipv4(struct sockaddr *, int);
@ -63,7 +63,7 @@ parse_netmask(const char *text, struct sockaddr *naddr, int *nb)
else
addr = (struct rb_sockaddr_storage *)naddr;
#ifdef IPV6
#ifdef RB_IPV6
if(strchr(ip, ':'))
{
if((ptr = strchr(ip, '/')))
@ -133,7 +133,7 @@ hash_ipv4(struct sockaddr *saddr, int bits)
* Output: A hash value of the IP address.
* Side effects: None
*/
#ifdef IPV6
#ifdef RB_IPV6
static unsigned long
hash_ipv6(struct sockaddr *saddr, int bits)
{
@ -221,7 +221,7 @@ find_conf_by_address(const char *name, const char *sockhost,
if(addr)
{
/* Check for IPV6 matches... */
#ifdef IPV6
#ifdef RB_IPV6
if(fam == AF_INET6)
{
@ -448,7 +448,7 @@ find_exact_conf_by_address(const char *address, int type, const char *username)
address = "/NOMATCH!/";
arec = rb_malloc(sizeof(struct AddressRec));
masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
#ifdef IPV6
#ifdef RB_IPV6
if(masktype == HM_IPV6)
{
/* We have to do this, since we do not re-hash for every bit -A1kmm. */
@ -507,7 +507,7 @@ add_conf_by_address(const char *address, int type, const char *username, struct
masktype = parse_netmask(address, (struct sockaddr *)&arec->Mask.ipa.addr, &bits);
arec->Mask.ipa.bits = bits;
arec->masktype = masktype;
#ifdef IPV6
#ifdef RB_IPV6
if(masktype == HM_IPV6)
{
/* We have to do this, since we do not re-hash for every bit -A1kmm. */
@ -550,7 +550,7 @@ delete_one_address_conf(const char *address, struct ConfItem *aconf)
struct AddressRec *arec, *arecl = NULL;
struct rb_sockaddr_storage addr;
masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
#ifdef IPV6
#ifdef RB_IPV6
if(masktype == HM_IPV6)
{
/* We have to do this, since we do not re-hash for every bit -A1kmm. */

View file

@ -34,7 +34,7 @@
#define INADDRSZ 4
#endif
#ifdef IPV6
#ifdef RB_IPV6
#ifndef IN6ADDRSZ
#define IN6ADDRSZ 16
#endif
@ -398,7 +398,7 @@ inetntoa(const char *in)
*/
static const char *inet_ntop4(const u_char * src, char *dst, unsigned int size);
#ifdef IPV6
#ifdef RB_IPV6
static const char *inet_ntop6(const u_char * src, char *dst, unsigned int size);
#endif
@ -427,7 +427,7 @@ inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
* author:
* Paul Vixie, 1996.
*/
#ifdef IPV6
#ifdef RB_IPV6
static const char *
inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
{
@ -542,7 +542,7 @@ inetpton_sock(const char *src, struct sockaddr *dst)
SET_SS_LEN((struct rb_sockaddr_storage *) dst, sizeof(struct sockaddr_in));
return 1;
}
#ifdef IPV6
#ifdef RB_IPV6
else if(inetpton(AF_INET6, src, &((struct sockaddr_in6 *) dst)->sin6_addr))
{
((struct sockaddr_in6 *) dst)->sin6_port = 0;
@ -562,7 +562,7 @@ inetntop_sock(struct sockaddr *src, char *dst, unsigned int size)
case AF_INET:
return (inetntop(AF_INET, &((struct sockaddr_in *) src)->sin_addr, dst, size));
break;
#ifdef IPV6
#ifdef RB_IPV6
case AF_INET6:
return (inetntop(AF_INET6, &((struct sockaddr_in6 *) src)->sin6_addr, dst, size));
break;
@ -588,7 +588,7 @@ inetntop(int af, const void *src, char *dst, unsigned int size)
{
case AF_INET:
return (inet_ntop4(src, dst, size));
#ifdef IPV6
#ifdef RB_IPV6
case AF_INET6:
if(IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) src) ||
IN6_IS_ADDR_V4COMPAT((const struct in6_addr *) src))
@ -677,7 +677,7 @@ inet_pton4(src, dst)
return (1);
}
#ifdef IPV6
#ifdef RB_IPV6
/* int
* inet_pton6(src, dst)
* convert presentation level address to network order binary form.
@ -803,7 +803,7 @@ inetpton(af, src, dst)
{
case AF_INET:
return (inet_pton4(src, dst));
#ifdef IPV6
#ifdef RB_IPV6
case AF_INET6:
/* Somebody might have passed as an IPv4 address this is sick but it works */
if(inet_pton4(src, dst))

View file

@ -307,7 +307,7 @@ int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask
iaddr = &((struct sockaddr_in *)addr)->sin_addr;
idest = &((struct sockaddr_in *)dest)->sin_addr;
}
#ifdef IPV6
#ifdef RB_IPV6
else
{
iaddr = &((struct sockaddr_in6 *)addr)->sin6_addr;
@ -346,7 +346,7 @@ int match_ips(const char *s1, const char *s2)
if (cidrlen == 0)
return 0;
#ifdef IPV6
#ifdef RB_IPV6
if (strchr(mask, ':') && strchr(address, ':'))
{
aftype = AF_INET6;
@ -414,7 +414,7 @@ int match_cidr(const char *s1, const char *s2)
if (cidrlen == 0)
return 0;
#ifdef IPV6
#ifdef RB_IPV6
if (strchr(ip, ':') && strchr(ipmask, ':'))
{
aftype = AF_INET6;

View file

@ -241,7 +241,7 @@ conf_set_serverinfo_vhost(void *data)
static void
conf_set_serverinfo_vhost6(void *data)
{
#ifdef IPV6
#ifdef RB_IPV6
if(inetpton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0)
{
conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data);
@ -670,7 +670,7 @@ conf_set_class_ping_time(void *data)
static void
conf_set_class_cidr_bitlen(void *data)
{
#ifdef IPV6
#ifdef RB_IPV6
unsigned int maxsize = 128;
#else
unsigned int maxsize = 32;
@ -759,14 +759,14 @@ conf_set_listen_port(void *data)
if(listener_address == NULL)
{
add_listener(args->v.number, listener_address, AF_INET);
#ifdef IPV6
#ifdef RB_IPV6
add_listener(args->v.number, listener_address, AF_INET6);
#endif
}
else
{
int family;
#ifdef IPV6
#ifdef RB_IPV6
if(strchr(listener_address, ':') != NULL)
family = AF_INET6;
else
@ -1221,7 +1221,7 @@ conf_set_connect_aftype(void *data)
if(strcasecmp(aft, "ipv4") == 0)
yy_server->aftype = AF_INET;
#ifdef IPV6
#ifdef RB_IPV6
else if(strcasecmp(aft, "ipv6") == 0)
yy_server->aftype = AF_INET6;
#endif

View file

@ -142,7 +142,7 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2)
else
{
int bitlen = 32;
#ifdef IPV6
#ifdef RB_IPV6
if(client_p->localClient->ip.ss_family == AF_INET6)
bitlen = 128;
#endif
@ -262,7 +262,7 @@ add_unknown_ip(struct Client *client_p)
if((pnode = rb_match_ip(unknown_tree, (struct sockaddr *)&client_p->localClient->ip)) == NULL)
{
int bitlen = 32;
#ifdef IPV6
#ifdef RB_IPV6
if(client_p->localClient->ip.ss_family == AF_INET6)
bitlen = 128;
#endif

View file

@ -118,7 +118,7 @@ extern char irc_domain[HOSTLEN + 1];
*/
static int res_ourserver(const struct rb_sockaddr_storage *inp)
{
#ifdef IPV6
#ifdef RB_IPV6
struct sockaddr_in6 *v6;
struct sockaddr_in6 *v6in = (struct sockaddr_in6 *)inp;
#endif
@ -129,7 +129,7 @@ static int res_ourserver(const struct rb_sockaddr_storage *inp)
for (ns = 0; ns < irc_nscount; ns++)
{
const struct rb_sockaddr_storage *srv = &irc_nsaddr_list[ns];
#ifdef IPV6
#ifdef RB_IPV6
v6 = (struct sockaddr_in6 *)srv;
#endif
v4 = (struct sockaddr_in *)srv;
@ -139,7 +139,7 @@ static int res_ourserver(const struct rb_sockaddr_storage *inp)
*/
switch (srv->ss_family)
{
#ifdef IPV6
#ifdef RB_IPV6
case AF_INET6:
if (srv->ss_family == inp->ss_family)
if (v6->sin6_port == v6in->sin6_port)
@ -446,7 +446,7 @@ static void do_query_number(struct DNSQuery *query, const struct rb_sockaddr_sto
rb_sprintf(request->queryname, "%u.%u.%u.%u.in-addr.arpa", (unsigned int)(cp[3]),
(unsigned int)(cp[2]), (unsigned int)(cp[1]), (unsigned int)(cp[0]));
}
#ifdef IPV6
#ifdef RB_IPV6
else if (addr->ss_family == AF_INET6)
{
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
@ -532,7 +532,7 @@ static void resend_query(struct reslist *request)
do_query_number(NULL, &request->addr, request);
break;
case T_A:
#ifdef IPV6
#ifdef RB_IPV6
case T_AAAA:
#endif
do_query_name(NULL, request->name, request, request->type);
@ -577,7 +577,7 @@ static int proc_answer(struct reslist *request, HEADER * header, char *buf, char
int n; /* temp count */
int rd_length;
struct sockaddr_in *v4; /* conversion */
#ifdef IPV6
#ifdef RB_IPV6
struct sockaddr_in6 *v6;
#endif
current = (unsigned char *)buf + sizeof(HEADER);
@ -658,7 +658,7 @@ static int proc_answer(struct reslist *request, HEADER * header, char *buf, char
memcpy(&v4->sin_addr, current, sizeof(struct in_addr));
return (1);
break;
#ifdef IPV6
#ifdef RB_IPV6
case T_AAAA:
if (request->type != T_AAAA)
return (0);
@ -818,7 +818,7 @@ static void res_readreply(rb_fde_t *F, void *data)
* ip#.
*
*/
#ifdef IPV6
#ifdef RB_IPV6
if (request->addr.ss_family == AF_INET6)
gethost_byname_type(request->name, request->query, T_AAAA);
else

View file

@ -199,7 +199,7 @@ auth_dns_callback(void *vptr, struct DNSReply *reply)
good = 0;
}
}
#ifdef IPV6
#ifdef RB_IPV6
else if(auth->client->localClient->ip.ss_family == AF_INET6)
{
struct sockaddr_in6 *ip, *ip_fwd;
@ -304,7 +304,7 @@ start_auth_query(struct AuthRequest *auth)
(struct sockaddr *) &localaddr, &locallen);
/* XXX mangle_mapped_sockaddr((struct sockaddr *)&localaddr); */
#ifdef IPV6
#ifdef RB_IPV6
if(localaddr.ss_family == AF_INET6)
{
((struct sockaddr_in6 *)&localaddr)->sin6_port = 0;
@ -313,7 +313,7 @@ start_auth_query(struct AuthRequest *auth)
((struct sockaddr_in *)&localaddr)->sin_port = 0;
destaddr = auth->client->localClient->ip;
#ifdef IPV6
#ifdef RB_IPV6
if(localaddr.ss_family == AF_INET6)
{
((struct sockaddr_in6 *)&destaddr)->sin6_port = htons(113);

View file

@ -245,7 +245,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
case NOT_AUTHORISED:
{
int port = -1;
#ifdef IPV6
#ifdef RB_IPV6
if(source_p->localClient->ip.ss_family == AF_INET6)
port = ntohs(((struct sockaddr_in6 *)&source_p->localClient->listener->addr)->sin6_port);
else
@ -721,7 +721,7 @@ set_default_conf(void)
memset(&ServerInfo.ip, 0, sizeof(ServerInfo.ip));
ServerInfo.specific_ipv4_vhost = 0;
#ifdef IPV6
#ifdef RB_IPV6
memset(&ServerInfo.ip6, 0, sizeof(ServerInfo.ip6));
ServerInfo.specific_ipv6_vhost = 0;
#endif

View file

@ -1498,7 +1498,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
return 0;
}
#ifdef IPV6
#ifdef RB_IPV6
if(theiripnum.ss_family == AF_INET6)
((struct sockaddr_in6 *)&theiripnum)->sin6_port = htons(server_p->port);
else
@ -1586,7 +1586,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
SET_SS_LEN(&myipnum, sizeof(struct sockaddr_in));
}
#ifdef IPV6
#ifdef RB_IPV6
else if((server_p->aftype == AF_INET6) && ServerInfo.specific_ipv6_vhost)
{
memcpy(&myipnum, &ServerInfo.ip6, sizeof(myipnum));
@ -1599,7 +1599,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
{
/* log */
ilog(L_SERVER, "Connecting to %s[%s] port %d (%s)", server_p->name, server_p->host, server_p->port,
#ifdef IPV6
#ifdef RB_IPV6
server_p->aftype == AF_INET6 ? "IPv6" :
#endif
(server_p->aftype == AF_INET ? "IPv4" : "?"));
@ -1615,7 +1615,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
/* log */
inetntop_sock((struct sockaddr *)&myipnum, vhoststr, sizeof vhoststr);
ilog(L_SERVER, "Connecting to %s[%s] port %d (%s) (vhost %s)", server_p->name, server_p->host, server_p->port,
#ifdef IPV6
#ifdef RB_IPV6
server_p->aftype == AF_INET6 ? "IPv6" :
#endif
(server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr);