with HAVE_RFC2553 macro. Original patch by Petr Pisar.
dnl Process this file with autoconf to produce a configure script.
dnl
-dnl $Id: configure.in,v 1.127 2009/03/25 17:26:31 fabiankeil Exp $
+dnl $Id: configure.in,v 1.128 2009/04/17 11:27:49 fabiankeil Exp $
dnl
dnl Written by and Copyright (C) 2001-2009 the
dnl Privoxy team. http://www.privoxy.org/
dnl Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dnl
dnl $Log: configure.in,v $
+dnl Revision 1.128 2009/04/17 11:27:49 fabiankeil
+dnl Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+dnl
dnl Revision 1.127 2009/03/25 17:26:31 fabiankeil
dnl And they are running again. Bump version to 3.0.13 UNRELEASED.
dnl
dnl AutoConf Initialization
dnl =================================================================
-AC_REVISION($Revision: 1.127 $)
+AC_REVISION($Revision: 1.128 $)
AC_INIT(jcc.c)
if test ! -f config.h.in; then
AC_TYPE_SIGNAL
dnl uncommenting does not work for swa. suse linux
dnl AC_FUNC_STAT
-AC_CHECK_FUNCS([access atexit getaddrinfo getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r getnameinfo gettimeofday inet_ntoa localtime_r memchr memmove memset poll putenv random regcomp select setlocale snprintf socket strchr strdup strerror strftime strlcat strlcpy strptime strstr strtoul timegm tzset])
-
+AC_CHECK_FUNCS([access atexit getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r gettimeofday inet_ntoa localtime_r memchr memmove memset poll putenv random regcomp select setlocale snprintf socket strchr strdup strerror strftime strlcat strlcpy strptime strstr strtoul timegm tzset])
+
+dnl Checks for RFC 2553 resolver and socket functions
+AC_CHECK_FUNC([getaddrinfo],
+ [AC_CHECK_FUNC([getnameinfo],
+ [AC_DEFINE([HAVE_RFC2553], [1],
+ [Define if RFC 2553 resolver functions like getaddrinfo(3) and
+ getnameinfo(3) present])
+ ])
+])
dnl =================================================================
dnl Checks for libraries.
-const char filters_rcs[] = "$Id: filters.c,v 1.118 2009/04/17 11:37:03 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.119 2009/04/17 11:38:28 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.119 2009/04/17 11:38:28 fabiankeil
+ * Add and use parse_forwarder_address() to reduce code duplication.
+ *
* Revision 1.118 2009/04/17 11:37:03 fabiankeil
* Allow IPv6 addresses in forward-override{}.
*
#include <string.h>
#include <assert.h>
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
#include <netdb.h>
#include <sys/socket.h>
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
#ifndef _WIN32
#ifndef __OS2__
static jb_err prepare_for_filtering(struct client_state *csp);
#ifdef FEATURE_ACL
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/*********************************************************************
*
* Function : sockaddr_storage_to_ip
return 1;
}
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
/*********************************************************************
while (acl != NULL)
{
if (
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
match_sockaddr(&acl->src->addr, &acl->src->mask, &csp->tcp_addr)
#else
(csp->ip_addr_long & acl->src->mask) == acl->src->addr
}
}
else if (
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/*
* XXX: An undefined acl->dst is full of zeros and should be
* considered a wildcard address. sockaddr_storage_to_ip()
int acl_addr(const char *aspec, struct access_control_addr *aca)
{
int i, masklength;
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
struct addrinfo hints, *result;
uint8_t *mask_data;
in_port_t *mask_port;
unsigned int addr_len;
#else
long port;
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
char *p;
char *acl_spec = NULL;
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/* XXX: Depend on ai_family */
masklength = 128;
#else
}
if ((masklength < 0) ||
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
(masklength > 128)
#else
(masklength > 32)
p = strchr(acl_spec, ':');
}
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
/* XXX: This will be logged as parse error. */
return(-1);
}
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
/* build the netmask */
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/* Clip masklength according to current family. */
if ((aca->addr.ss_family == AF_INET) && (masklength > 32))
{
* (i.e. save on the network portion of the address).
*/
aca->addr = aca->addr & aca->mask;
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
return(0);
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.52 2009/04/17 11:34:34 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.53 2009/04/17 11:39:52 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.53 2009/04/17 11:39:52 fabiankeil
+ * If the hostname is 'localhost' or not specified, request an AF_INET address.
+ *
* Revision 1.52 2009/04/17 11:34:34 fabiankeil
* Style cosmetics for the IPv6 code.
*
* file descriptor.
*
*********************************************************************/
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/* Getaddrinfo implementation */
jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
{
}
-# else /* ndef HAVE_GETADDRINFO */
+#else /* ndef HAVE_RFC2553 */
/* Pre-getaddrinfo implementation */
jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
return(fd);
}
-#endif /* ndef HAVE_GETADDRINFO */
+#endif /* ndef HAVE_RFC2553 */
/*********************************************************************
*********************************************************************/
int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
{
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
struct addrinfo hints;
struct addrinfo *result, *rp;
/*
int retval;
#else
struct sockaddr_in inaddr;
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
jb_socket fd;
#ifndef _WIN32
int one = 1;
*pfd = JB_INVALID_SOCKET;
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
retval = snprintf(servnam, sizeof(servnam), "%d", portnum);
if ((-1 == retval) || (sizeof(servnam) <= retval))
{
inaddr.sin_port = htonl((unsigned long) portnum);
}
#endif /* ndef _WIN32 */
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
for (rp = result; rp != NULL; rp = rp->ai_next)
{
fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
#else
fd = socket(AF_INET, SOCK_STREAM, 0);
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
#ifdef _WIN32
if (fd == JB_INVALID_SOCKET)
if (fd < 0)
#endif
{
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
continue;
#else
return(-1);
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
#endif /* ndef _WIN32 */
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
if (bind(fd, rp->ai_addr, rp->ai_addrlen) < 0)
#else
if (bind(fd, (struct sockaddr *)&inaddr, sizeof(inaddr)) < 0)
if (errno == EADDRINUSE)
#endif
{
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
freeaddrinfo(result);
#endif
close_socket(fd);
else
{
close_socket(fd);
-#ifndef HAVE_GETADDRINFO
+#ifndef HAVE_RFC2553
return(-1);
}
}
/* All bind()s failed */
return(-1);
}
-#endif /* ndef HAVE_GETADDRINFO */
+#endif /* ndef HAVE_RFC2553 */
while (listen(fd, MAX_LISTEN_BACKLOG) == -1)
{
*********************************************************************/
void get_host_information(jb_socket afd, char **ip_address, char **hostname)
{
-#ifdef HAVE_GETNAMEINFO
+#ifdef HAVE_RFC2553
struct sockaddr_storage server;
int retval;
#else
struct sockaddr_in server;
struct hostent *host = NULL;
-#endif /* HAVE_GETNAMEINFO */
+#endif /* HAVE_RFC2553 */
#if defined(_WIN32) || defined(__OS2__) || defined(__APPLE_CC__) || defined(AMIGA)
/* according to accept_connection() this fixes a warning. */
int s_length, s_length_provided;
#else
socklen_t s_length, s_length_provided;
#endif
-#ifndef HAVE_GETNAMEINFO
+#ifndef HAVE_RFC2553
#if defined(HAVE_GETHOSTBYADDR_R_8_ARGS) || defined(HAVE_GETHOSTBYADDR_R_7_ARGS) || defined(HAVE_GETHOSTBYADDR_R_5_ARGS)
struct hostent result;
#if defined(HAVE_GETHOSTBYADDR_R_5_ARGS)
int thd_err;
#endif /* def HAVE_GETHOSTBYADDR_R_5_ARGS */
#endif /* def HAVE_GETHOSTBYADDR_R_(8|7|5)_ARGS */
-#endif /* ifndef HAVE_GETNAMEINFO */
+#endif /* ifndef HAVE_RFC2553 */
s_length = s_length_provided = sizeof(server);
if (NULL != hostname)
log_error(LOG_LEVEL_ERROR, "getsockname() truncated server address");
return;
}
-#ifdef HAVE_GETNAMEINFO
+#ifdef HAVE_RFC2553
*ip_address = malloc(NI_MAXHOST);
retval = getnameinfo((struct sockaddr *) &server, s_length,
*ip_address, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
}
#else
*ip_address = strdup(inet_ntoa(server.sin_addr));
-#endif /* HAVE_GETNAMEINFO */
+#endif /* HAVE_RFC2553 */
if (NULL == hostname)
{
/*
return;
}
-#ifdef HAVE_GETNAMEINFO
+#ifdef HAVE_RFC2553
*hostname = malloc(NI_MAXHOST);
retval = getnameinfo((struct sockaddr *) &server, s_length,
*hostname, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
{
*hostname = strdup(host->h_name);
}
-#endif /* else def HAVE_GETNAMEINFO */
+#endif /* else def HAVE_RFC2553 */
}
return;
*********************************************************************/
int accept_connection(struct client_state * csp, jb_socket fd)
{
-#ifdef HAVE_GETNAMEINFO
+#ifdef HAVE_RFC2553
/* XXX: client is stored directly into csp->tcp_addr */
#define client (csp->tcp_addr)
int retval;
#endif
csp->cfd = afd;
-#ifdef HAVE_GETNAMEINFO
+#ifdef HAVE_RFC2553
csp->ip_addr_str = malloc(NI_MAXHOST);
retval = getnameinfo((struct sockaddr *) &client, c_length,
csp->ip_addr_str, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
#else
csp->ip_addr_str = strdup(inet_ntoa(client.sin_addr));
csp->ip_addr_long = ntohl(client.sin_addr.s_addr);
-#endif /* def HAVE_GETNAMEINFO */
+#endif /* def HAVE_RFC2553 */
return 1;
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.95 2009/04/17 11:34:34 fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.96 2009/04/17 11:38:28 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 1.96 2009/04/17 11:38:28 fabiankeil
+ * Add and use parse_forwarder_address() to reduce code duplication.
+ *
* Revision 1.95 2009/04/17 11:34:34 fabiankeil
* Style cosmetics for the IPv6 code.
*
break;
}
}
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
else
{
cur_acl->wildcard_dst = 1;
}
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
/*
* Add it to the list. Note we reverse the list to get the
break;
}
}
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
else
{
cur_acl->wildcard_dst = 1;
}
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
/*
* Add it to the list. Note we reverse the list to get the
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.130 2009/04/17 11:27:49 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.131 2009/04/17 11:34:35 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.131 2009/04/17 11:34:35 fabiankeil
+ * Style cosmetics for the IPv6 code.
+ *
* Revision 1.130 2009/04/17 11:27:49 fabiankeil
* Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
*
/* Needed for pcre choice */
#include "config.h"
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/* Need for struct sockaddr_storage */
#include <sys/socket.h>
#endif
/** Client PC's IP address, as reported by the accept() function.
As a string. */
char *ip_addr_str;
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
/** Client PC's TCP address, as reported by the accept() function.
As a sockaddr. */
struct sockaddr_storage tcp_addr;
/** Client PC's IP address, as reported by the accept() function.
As a number. */
unsigned long ip_addr_long;
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
/** The URL that was requested */
struct http_request http[1];
*/
struct access_control_addr
{
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
struct sockaddr_storage addr; /* <The TCP address in network order. */
struct sockaddr_storage mask; /* <The TCP mask in network order. */
#else
unsigned long addr; /**< The IP address as an integer. */
unsigned long mask; /**< The network mask as an integer. */
unsigned long port; /**< The port number. */
-#endif /* HAVE_GETADDRINFO */
+#endif /* HAVE_RFC2553 */
};
/**
{
struct access_control_addr src[1]; /**< Client IP address */
struct access_control_addr dst[1]; /**< Website or parent proxy IP address */
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
int wildcard_dst; /** < dst address is wildcard */
#endif