--enable-carp
CARP support is now built by default.
- --disable-carp can be used to build without it.
+ --disable-carp can be used to buidl without it.
--enable-htcp
HTCP protocol support is now built by default.
Index: squid3/errors/list
===================================================================
RCS file: /cvsroot/squid-sf//squid3/errors/list,v
retrieving revision 1.1.70.2
retrieving revision 1.1.70.3
diff -u -r1.1.70.2 -r1.1.70.3
--- squid3/errors/list 25 Jan 2008 02:33:34 -0000 1.1.70.2
+++ squid3/errors/list 27 Jan 2008 18:08:33 -0000 1.1.70.3
@@ -18,6 +18,7 @@
ERR_ONLY_IF_CACHED_MISS
ERR_READ_ERROR
ERR_READ_TIMEOUT
+ERR_SECURE_CONNECT_FAIL
ERR_SOCKET_FAILURE
ERR_UNSUP_REQ
ERR_URN_RESOLVE
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Armenian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Azerbaijani/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Bulgarian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Catalan/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Czech/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Danish/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Dutch/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/English/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Estonian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Finnish/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/French/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/German/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Greek/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Hebrew/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Hungarian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Italian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Japanese/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Korean/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Lithuanian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Polish/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Portuguese/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Romanian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Russian-1251/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Russian-koi8-r/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Serbian/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Simplify_Chinese/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Slovak/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Spanish/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
Index: squid3/errors/Swedish/ERR_ESI
===================================================================
RCS file: /cvsroot/squid-sf//squid3/errors/Swedish/ERR_ESI,v
retrieving revision 1.2.48.1
retrieving revision 1.2.48.2
diff -u -r1.2.48.1 -r1.2.48.2
--- squid3/errors/Swedish/ERR_ESI 25 Jan 2008 02:33:35 -0000 1.2.48.1
+++ squid3/errors/Swedish/ERR_ESI 27 Jan 2008 18:08:40 -0000 1.2.48.2
@@ -1,33 +1,29 @@
-
-FEL: Begärd URL kunde inte hämtas
-
+
+ERROR: The requested URL could not be retrieved
+
-Begärd URL kunde inte hämtas
+The requested URL could not be retrieved
-Vid försöket att hämta URL:
+While trying to retrieve the URL:
%U
-Mottogs följande fel:
+The following error was encountered:
-ESI bearbetning misslyckades.
-%H
+ESI Processing failed.
-
-ESI motorn returnerade:
+The ESI processor returned:
-%z
+%Z
-Detta betyder att:
+This means that:
- Surrogat servern kunde inte bearbeta ESI mallen.
- Vänligen kontakta den ansvariga för webbservern ifråga.
+ The surrogate was not able to process the ESI template. Please report this error to the webmaster.
-
-Addressen till ansvarig administratör är %w.
-
+Your webmaster is %w.
+This page is in english because a translation has not been made. If you are able to, please create a translation and contact the squid project to get it included.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Swedish/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Traditional_Chinese/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/errors/Turkish/ERR_SECURE_CONNECT_FAIL Wed Feb 6 01:24:19 2008
@@ -0,0 +1,31 @@
+
+
+ERROR: The requested URL could not be retrieved
+
+
+ERROR
+The requested URL could not be retrieved
+
+
+While trying to retrieve the URL:
+%U
+
+The following error was encountered:
+
+-
+
+Failed to establish a secure connection to %I
+
+
+
+
+The system returned:
+
%E
+
+
+This proxy and the remote host failed to negotiate a mutually acceptable
+security settings for handling your request. It is possible that the remote
+host does not support secure connections, or the proxy is not satisfied with
+the host security credentials.
+
+
Your cache administrator is %w.
Index: squid3/helpers/digest_auth/eDirectory/edir_ldapext.c
===================================================================
RCS file: /cvsroot/squid-sf//squid3/helpers/digest_auth/eDirectory/edir_ldapext.c,v
retrieving revision 1.5.10.1
retrieving revision 1.5.10.2
diff -u -r1.5.10.1 -r1.5.10.2
--- squid3/helpers/digest_auth/eDirectory/edir_ldapext.c 25 Jan 2008 02:33:35 -0000 1.5.10.1
+++ squid3/helpers/digest_auth/eDirectory/edir_ldapext.c 27 Jan 2008 18:08:40 -0000 1.5.10.2
@@ -1,31 +1,27 @@
/*
- * NDS LDAP helper functions
- * Copied From Samba-3.0.24 pdb_nds.c and trimmed down to the
- * limited functionality needed to access the plain text password only
+ * Copyright (C) 2002-2004 Novell, Inc.
*
- * Original copyright & license follows:
- *
- * Copyright (C) Vince Brimhall 2004-2005
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * edir_ldapext.c LDAP extension for reading eDirectory universal password
*
-*/
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
#include "digest_common.h"
-#ifdef _SQUID_MSWIN_ /* Native Windows port and MinGW */
+#ifdef _SQUID_MSWIN_ /* Native Windows port and MinGW */
#define snprintf _snprintf
#include
@@ -47,591 +43,282 @@
#include
#endif
-#include
#include "edir_ldapext.h"
-#define NMASLDAP_GET_LOGIN_CONFIG_REQUEST "2.16.840.1.113719.1.39.42.100.3"
-#define NMASLDAP_GET_LOGIN_CONFIG_RESPONSE "2.16.840.1.113719.1.39.42.100.4"
-#define NMASLDAP_SET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.11"
-#define NMASLDAP_SET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.12"
-#define NMASLDAP_GET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.13"
-#define NMASLDAP_GET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.14"
-
-#define NMAS_LDAP_EXT_VERSION 1
-
-#define SMB_MALLOC_ARRAY(type, nelem) calloc(sizeof(type), nelem)
-#define DEBUG(level, args)
-
-/**********************************************************************
- Take the request BER value and input data items and BER encodes the
- data into the BER value
-**********************************************************************/
-
-static int berEncodePasswordData(
- struct berval **requestBV,
- const char *objectDN,
- const char *password,
- const char *password2)
-{
- int err = 0, rc=0;
- BerElement *requestBer = NULL;
+/* NMAS error codes */
+#define NMAS_E_BASE (-1600)
- const char * utf8ObjPtr = NULL;
- int utf8ObjSize = 0;
- const char * utf8PwdPtr = NULL;
- int utf8PwdSize = 0;
- const char * utf8Pwd2Ptr = NULL;
- int utf8Pwd2Size = 0;
-
-
- /* Convert objectDN and tag strings from Unicode to UTF-8 */
- utf8ObjSize = strlen(objectDN)+1;
- utf8ObjPtr = objectDN;
-
- if (password != NULL)
- {
- utf8PwdSize = strlen(password)+1;
- utf8PwdPtr = password;
- }
+#define NMAS_SUCCESS 0
+#define NMAS_E_SUCCESS NMAS_SUCCESS /* Alias */
+#define NMAS_OK NMAS_SUCCESS /* Alias */
+
+#define NMAS_E_FRAG_FAILURE (NMAS_E_BASE-31) /* -1631 0xFFFFF9A1 */
+#define NMAS_E_BUFFER_OVERFLOW (NMAS_E_BASE-33) /* -1633 0xFFFFF99F */
+#define NMAS_E_SYSTEM_RESOURCES (NMAS_E_BASE-34) /* -1634 0xFFFFF99E */
+#define NMAS_E_INSUFFICIENT_MEMORY (NMAS_E_BASE-35) /* -1635 0xFFFFF99D */
+#define NMAS_E_NOT_SUPPORTED (NMAS_E_BASE-36) /* -1636 0xFFFFF99C */
+#define NMAS_E_INVALID_PARAMETER (NMAS_E_BASE-43) /* -1643 0xFFFFF995 */
+#define NMAS_E_INVALID_VERSION (NMAS_E_BASE-52) /* -1652 0xFFFFF98C */
+
+/* OID of LDAP extenstion calls to read Universal Password */
+#define NMASLDAP_GET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.13"
+#define NMASLDAP_GET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.14"
+
+#define NMAS_LDAP_EXT_VERSION 1
- if (password2 != NULL)
- {
- utf8Pwd2Size = strlen(password2)+1;
- utf8Pwd2Ptr = password2;
- }
- /* Allocate a BerElement for the request parameters. */
- if((requestBer = ber_alloc()) == NULL)
- {
- err = LDAP_ENCODING_ERROR;
- goto Cleanup;
- }
-
- if (password != NULL && password2 != NULL)
- {
- /* BER encode the NMAS Version, the objectDN, and the password */
- rc = ber_printf(requestBer, "{iooo}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize, utf8PwdPtr, utf8PwdSize, utf8Pwd2Ptr, utf8Pwd2Size);
- }
- else if (password != NULL)
- {
- /* BER encode the NMAS Version, the objectDN, and the password */
- rc = ber_printf(requestBer, "{ioo}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize, utf8PwdPtr, utf8PwdSize);
- }
- else
- {
- /* BER encode the NMAS Version and the objectDN */
- rc = ber_printf(requestBer, "{io}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize);
- }
-
- if (rc < 0)
- {
- err = LDAP_ENCODING_ERROR;
- goto Cleanup;
- }
- else
- {
- err = 0;
- }
- /* Convert the BER we just built to a berval that we'll send with the extended request. */
- if(ber_flatten(requestBer, requestBV) == LBER_ERROR)
- {
- err = LDAP_ENCODING_ERROR;
- goto Cleanup;
- }
-
-Cleanup:
-
- if(requestBer)
- {
- ber_free(requestBer, 1);
- }
-
- return err;
-}
-
-/**********************************************************************
- Take the request BER value and input data items and BER encodes the
- data into the BER value
-**********************************************************************/
-
-static int berEncodeLoginData(
- struct berval **requestBV,
- char *objectDN,
- unsigned int methodIDLen,
- unsigned int *methodID,
- char *tag,
- size_t putDataLen,
- void *putData)
+/* ------------------------------------------------------------------------
+ * berEncodePasswordData
+ * ==============================
+ * RequestBer contents:
+ * clientVersion INTEGER
+ * targetObjectDN OCTET STRING
+ * password1 OCTET STRING
+ * password2 OCTET STRING
+ *
+ * Description:
+ * This function takes the request BER value and input data items
+ * and BER encodes the data into the BER value
+ *
+ * ------------------------------------------------------------------------ */
+int
+berEncodePasswordData(
+ struct berval **requestBV,
+ char *objectDN,
+ char *password,
+ char *password2)
{
- int err = 0;
- BerElement *requestBer = NULL;
-
- unsigned int i;
- unsigned int elemCnt = methodIDLen / sizeof(unsigned int);
-
- char *utf8ObjPtr=NULL;
- int utf8ObjSize = 0;
-
- char *utf8TagPtr = NULL;
- int utf8TagSize = 0;
-
- utf8ObjPtr = objectDN;
- utf8ObjSize = strlen(utf8ObjPtr)+1;
-
- utf8TagPtr = tag;
- utf8TagSize = strlen(utf8TagPtr)+1;
-
- /* Allocate a BerElement for the request parameters. */
- if((requestBer = ber_alloc()) == NULL)
- {
- err = LDAP_ENCODING_ERROR;
- goto Cleanup;
- }
+ int err = 0, rc = 0;
+ BerElement *requestBer = NULL;
+ char *utf8ObjPtr = NULL;
+ int utf8ObjSize = 0;
+ char *utf8PwdPtr = NULL;
+ int utf8PwdSize = 0;
+ char *utf8Pwd2Ptr = NULL;
+ int utf8Pwd2Size = 0;
+
+
+ utf8ObjSize = strlen(objectDN) + 1;
+ utf8ObjPtr = objectDN;
+
+ if (password != NULL) {
+ utf8PwdSize = strlen(password) + 1;
+ utf8PwdPtr = password;
+ }
+ if (password2 != NULL) {
+ utf8Pwd2Size = strlen(password2) + 1;
+ utf8Pwd2Ptr = password2;
+ }
+ /* Allocate a BerElement for the request parameters. */
+ if ((requestBer = ber_alloc()) == NULL) {
+ err = NMAS_E_FRAG_FAILURE;
+ goto Cleanup;
+ }
+ if (password != NULL && password2 != NULL) {
+ /* BER encode the NMAS Version, the objectDN, and the password */
+ rc = ber_printf(requestBer, "{iooo}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize, utf8PwdPtr, utf8PwdSize, utf8Pwd2Ptr, utf8Pwd2Size);
+ } else if (password != NULL) {
+ /* BER encode the NMAS Version, the objectDN, and the password */
+ rc = ber_printf(requestBer, "{ioo}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize, utf8PwdPtr, utf8PwdSize);
+ } else {
/* BER encode the NMAS Version and the objectDN */
- err = (ber_printf(requestBer, "{io", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize) < 0) ? LDAP_ENCODING_ERROR : 0;
-
- /* BER encode the MethodID Length and value */
- if (!err)
- {
- err = (ber_printf(requestBer, "{i{", methodIDLen) < 0) ? LDAP_ENCODING_ERROR : 0;
- }
-
- for (i = 0; !err && i < elemCnt; i++)
- {
- err = (ber_printf(requestBer, "i", methodID[i]) < 0) ? LDAP_ENCODING_ERROR : 0;
- }
-
- if (!err)
- {
- err = (ber_printf(requestBer, "}}", 0) < 0) ? LDAP_ENCODING_ERROR : 0;
- }
-
- if(putData)
- {
- /* BER Encode the the tag and data */
- err = (ber_printf(requestBer, "oio}", utf8TagPtr, utf8TagSize, putDataLen, putData, putDataLen) < 0) ? LDAP_ENCODING_ERROR : 0;
- }
- else
- {
- /* BER Encode the the tag */
- err = (ber_printf(requestBer, "o}", utf8TagPtr, utf8TagSize) < 0) ? LDAP_ENCODING_ERROR : 0;
- }
-
- if (err)
- {
- goto Cleanup;
- }
-
- /* Convert the BER we just built to a berval that we'll send with the extended request. */
- if(ber_flatten(requestBer, requestBV) == LBER_ERROR)
- {
- err = LDAP_ENCODING_ERROR;
- goto Cleanup;
- }
-
-Cleanup:
-
- if(requestBer)
- {
- ber_free(requestBer, 1);
- }
-
- return err;
-}
-
-/**********************************************************************
- Takes the reply BER Value and decodes the NMAS server version and
- return code and if a non null retData buffer was supplied, tries to
- decode the the return data and length
-**********************************************************************/
-
-static int berDecodeLoginData(
- struct berval *replyBV,
- int *serverVersion,
- size_t *retDataLen,
- void *retData )
-{
- int err = 0;
- BerElement *replyBer = NULL;
- char *retOctStr = NULL;
- size_t retOctStrLen = 0;
-
- if((replyBer = ber_init(replyBV)) == NULL)
- {
- err = LDAP_OPERATIONS_ERROR;
- goto Cleanup;
- }
-
- if(retData)
- {
- retOctStrLen = *retDataLen + 1;
- retOctStr = SMB_MALLOC_ARRAY(char, retOctStrLen);
- if(!retOctStr)
- {
- err = LDAP_OPERATIONS_ERROR;
- goto Cleanup;
- }
-
- if(ber_scanf(replyBer, "{iis}", serverVersion, &err, retOctStr, &retOctStrLen) != -1)
- {
- if (*retDataLen >= retOctStrLen)
- {
- memcpy(retData, retOctStr, retOctStrLen);
- }
- else if (!err)
- {
- err = LDAP_NO_MEMORY;
- }
-
- *retDataLen = retOctStrLen;
- }
- else if (!err)
- {
- err = LDAP_DECODING_ERROR;
- }
- }
- else
- {
- if(ber_scanf(replyBer, "{ii}", serverVersion, &err) == -1)
- {
- if (!err)
- {
- err = LDAP_DECODING_ERROR;
- }
- }
- }
-
-Cleanup:
-
- if(replyBer)
- {
- ber_free(replyBer, 1);
- }
-
- if (retOctStr != NULL)
- {
- memset(retOctStr, 0, retOctStrLen);
- free(retOctStr);
- }
-
- return err;
-}
-
-/**********************************************************************
- Retrieves data in the login configuration of the specified object
- that is tagged with the specified methodID and tag.
-**********************************************************************/
-
-static int getLoginConfig(
- LDAP *ld,
- char *objectDN,
- unsigned int methodIDLen,
- unsigned int *methodID,
- char *tag,
- size_t *dataLen,
- void *data )
-{
- int err = 0;
- struct berval *requestBV = NULL;
- char *replyOID = NULL;
- struct berval *replyBV = NULL;
- int serverVersion = 0;
-
- /* Validate unicode parameters. */
- if((strlen(objectDN) == 0) || ld == NULL)
- {
- return LDAP_NO_SUCH_ATTRIBUTE;
- }
-
- err = berEncodeLoginData(&requestBV, objectDN, methodIDLen, methodID, tag, 0, NULL);
- if(err)
- {
- goto Cleanup;
- }
-
- /* Call the ldap_extended_operation (synchronously) */
- if((err = ldap_extended_operation_s(ld, NMASLDAP_GET_LOGIN_CONFIG_REQUEST,
- requestBV, NULL, NULL, &replyOID, &replyBV)))
- {
- goto Cleanup;
- }
-
- /* Make sure there is a return OID */
- if(!replyOID)
- {
- err = LDAP_NOT_SUPPORTED;
- goto Cleanup;
- }
-
- /* Is this what we were expecting to get back. */
- if(strcmp(replyOID, NMASLDAP_GET_LOGIN_CONFIG_RESPONSE))
- {
- err = LDAP_NOT_SUPPORTED;
- goto Cleanup;
- }
-
- /* Do we have a good returned berval? */
- if(!replyBV)
- {
- /* No; returned berval means we experienced a rather drastic error. */
- /* Return operations error. */
- err = LDAP_OPERATIONS_ERROR;
- goto Cleanup;
- }
-
- err = berDecodeLoginData(replyBV, &serverVersion, dataLen, data);
-
- if(serverVersion != NMAS_LDAP_EXT_VERSION)
- {
- err = LDAP_OPERATIONS_ERROR;
- goto Cleanup;
- }
-
-Cleanup:
-
- if(replyBV)
- {
- ber_bvfree(replyBV);
- }
-
- /* Free the return OID string if one was returned. */
- if(replyOID)
- {
- ldap_memfree(replyOID);
- }
+ rc = ber_printf(requestBer, "{io}", NMAS_LDAP_EXT_VERSION, utf8ObjPtr, utf8ObjSize);
+ }
- /* Free memory allocated while building the request ber and berval. */
- if(requestBV)
- {
- ber_bvfree(requestBV);
- }
-
- /* Return the appropriate error/success code. */
- return err;
-}
-
-/**********************************************************************
- Attempts to get the Simple Password
-**********************************************************************/
-
-static int nmasldap_get_simple_pwd(
- LDAP *ld,
- char *objectDN,
- size_t pwdLen,
- char *pwd )
+ if (rc < 0) {
+ err = NMAS_E_FRAG_FAILURE;
+ goto Cleanup;
+ } else {
+ err = 0;
+ }
+
+ /*
+ * Convert the BER we just built to a berval that we'll send with the extended request.
+ */
+ if (ber_flatten(requestBer, requestBV) == LBER_ERROR) {
+ err = NMAS_E_FRAG_FAILURE;
+ goto Cleanup;
+ }
+ Cleanup:
+
+ if (requestBer) {
+ ber_free(requestBer, 1);
+ }
+ return err;
+} /* End of berEncodePasswordData */
+
+/* ------------------------------------------------------------------------
+ * berDecodeLoginData()
+ * ==============================
+ * ResponseBer contents:
+ * serverVersion INTEGER
+ * error INTEGER
+ * data OCTET STRING
+ *
+ * Description:
+ * This function takes the reply BER Value and decodes the
+ * NMAS server version and return code and if a non null retData
+ * buffer was supplied, tries to decode the the return data and length
+ *
+ * ------------------------------------------------------------------------ */
+int
+berDecodeLoginData(
+ struct berval *replyBV,
+ int *serverVersion,
+ size_t * retDataLen,
+ void *retData)
{
- int err = 0;
- unsigned int methodID = 0;
- unsigned int methodIDLen = sizeof(methodID);
- char tag[] = {'P','A','S','S','W','O','R','D',' ','H','A','S','H',0};
- char *pwdBuf=NULL;
- size_t pwdBufLen, bufferLen;
-
- bufferLen = pwdBufLen = pwdLen+2;
- pwdBuf = SMB_MALLOC_ARRAY(char, pwdBufLen); /* digest and null */
- if(pwdBuf == NULL)
- {
- return LDAP_NO_MEMORY;
- }
-
- err = getLoginConfig(ld, objectDN, methodIDLen, &methodID, tag, &pwdBufLen, pwdBuf);
- if (err == 0)
- {
- if (pwdBufLen !=0)
- {
- pwdBuf[pwdBufLen] = 0; /* null terminate */
-
- switch (pwdBuf[0])
- {
- case 1: /* cleartext password */
- break;
- case 2: /* SHA1 HASH */
- case 3: /* MD5_ID */
- case 4: /* UNIXCrypt_ID */
- case 8: /* SSHA_ID */
- default: /* Unknown digest */
- err = LDAP_INAPPROPRIATE_AUTH; /* only return clear text */
- break;
- }
-
- if (!err)
- {
- if (pwdLen >= pwdBufLen-1)
- {
- memcpy(pwd, &pwdBuf[1], pwdBufLen-1); /* skip digest tag and include null */
- }
- else
- {
- err = LDAP_NO_MEMORY;
- }
- }
- }
- }
-
- if (pwdBuf != NULL)
- {
- memset(pwdBuf, 0, bufferLen);
- free(pwdBuf);
- }
-
- return err;
-}
-
-
-/**********************************************************************
- Attempts to get the Universal Password
-**********************************************************************/
-
-static int nmasldap_get_password(
- LDAP *ld,
- char *objectDN,
- size_t *pwdSize, /* in bytes */
- unsigned char *pwd )
+ int rc = 0, err = 0;
+ BerElement *replyBer = NULL;
+ char *retOctStr = NULL;
+ size_t retOctStrLen = 0;
+
+ if ((replyBer = ber_init(replyBV)) == NULL) {
+ err = NMAS_E_SYSTEM_RESOURCES;
+ goto Cleanup;
+ }
+ if (retData) {
+ retOctStrLen = *retDataLen + 1;
+ retOctStr = (char *) malloc(retOctStrLen);
+ if (!retOctStr) {
+ err = NMAS_E_SYSTEM_RESOURCES;
+ goto Cleanup;
+ }
+ if ((rc = ber_scanf(replyBer, "{iis}", serverVersion, &err, retOctStr, &retOctStrLen)) != -1) {
+ if (*retDataLen >= retOctStrLen) {
+ memcpy(retData, retOctStr, retOctStrLen);
+ } else if (!err) {
+ err = NMAS_E_BUFFER_OVERFLOW;
+ }
+ *retDataLen = retOctStrLen;
+ } else if (!err) {
+ err = NMAS_E_FRAG_FAILURE;
+ }
+ } else {
+ if ((rc = ber_scanf(replyBer, "{ii}", serverVersion, &err)) == -1) {
+ if (!err) {
+ err = NMAS_E_FRAG_FAILURE;
+ }
+ }
+ }
+
+ Cleanup:
+
+ if (replyBer) {
+ ber_free(replyBer, 1);
+ }
+ if (retOctStr != NULL) {
+ memset(retOctStr, 0, retOctStrLen);
+ free(retOctStr);
+ }
+ return err;
+} /* End of berDecodeLoginData */
+
+/* -----------------------------------------------------------------------
+ * nmasldap_get_password()
+ * ==============================
+ *
+ * Description:
+ * This API attempts to get the universal password
+ *
+ * ------------------------------------------------------------------------ */
+int
+nmasldap_get_password(
+ LDAP * ld,
+ char *objectDN,
+ size_t * pwdSize, // in bytes
+ char *pwd)
{
- int err = 0;
+ int err = 0;
- struct berval *requestBV = NULL;
- char *replyOID = NULL;
- struct berval *replyBV = NULL;
- int serverVersion;
- char *pwdBuf;
- size_t pwdBufLen, bufferLen;
-
- /* Validate char parameters. */
- if(objectDN == NULL || (strlen(objectDN) == 0) || pwdSize == NULL || ld == NULL)
- {
- return LDAP_NO_SUCH_ATTRIBUTE;
- }
+ struct berval *requestBV = NULL;
+ char *replyOID = NULL;
+ struct berval *replyBV = NULL;
+ int serverVersion;
+ char *pwdBuf;
+ size_t pwdBufLen, bufferLen;
- bufferLen = pwdBufLen = *pwdSize;
- pwdBuf = SMB_MALLOC_ARRAY(char, pwdBufLen+2);
- if(pwdBuf == NULL)
- {
- return LDAP_NO_MEMORY;
- }
-
- err = berEncodePasswordData(&requestBV, objectDN, NULL, NULL);
- if(err)
- {
- goto Cleanup;
- }
-
- /* Call the ldap_extended_operation (synchronously) */
- if((err = ldap_extended_operation_s(ld, NMASLDAP_GET_PASSWORD_REQUEST, requestBV, NULL, NULL, &replyOID, &replyBV)))
- {
- goto Cleanup;
- }
-
- /* Make sure there is a return OID */
- if(!replyOID)
- {
- err = LDAP_NOT_SUPPORTED;
- goto Cleanup;
- }
-
- /* Is this what we were expecting to get back. */
- if(strcmp(replyOID, NMASLDAP_GET_PASSWORD_RESPONSE))
- {
- err = LDAP_NOT_SUPPORTED;
- goto Cleanup;
- }
-
- /* Do we have a good returned berval? */
- if(!replyBV)
- {
- /* No; returned berval means we experienced a rather drastic error. */
- /* Return operations error. */
- err = LDAP_OPERATIONS_ERROR;
- goto Cleanup;
- }
-
- err = berDecodeLoginData(replyBV, &serverVersion, &pwdBufLen, pwdBuf);
-
- if(serverVersion != NMAS_LDAP_EXT_VERSION)
- {
- err = LDAP_OPERATIONS_ERROR;
- goto Cleanup;
- }
-
- if (!err && pwdBufLen != 0)
- {
- if (*pwdSize >= pwdBufLen+1 && pwd != NULL)
- {
- memcpy(pwd, pwdBuf, pwdBufLen);
- pwd[pwdBufLen] = 0; /* add null termination */
- }
- *pwdSize = pwdBufLen; /* does not include null termination */
- }
-
-Cleanup:
-
- if(replyBV)
- {
- ber_bvfree(replyBV);
- }
-
- /* Free the return OID string if one was returned. */
- if(replyOID)
- {
- ldap_memfree(replyOID);
- }
-
- /* Free memory allocated while building the request ber and berval. */
- if(requestBV)
- {
- ber_bvfree(requestBV);
- }
-
- if (pwdBuf != NULL)
- {
- memset(pwdBuf, 0, bufferLen);
- free(pwdBuf);
- }
-
- /* Return the appropriate error/success code. */
- return err;
-}
-
-/**********************************************************************
- Get the user's password from NDS.
- *********************************************************************/
-
-int nds_get_password(
- LDAP *ld,
- char *object_dn,
- size_t *pwd_len,
- char *pwd )
-{
- int rc = -1;
-
- rc = nmasldap_get_password(ld, object_dn, pwd_len, (unsigned char *)pwd);
- if (rc == LDAP_SUCCESS) {
-#ifdef DEBUG_PASSWORD
- DEBUG(100,("nmasldap_get_password returned %s for %s\n", pwd, object_dn));
-#endif
- DEBUG(5, ("NDS Universal Password retrieved for %s\n", object_dn));
- } else {
- DEBUG(3, ("NDS Universal Password NOT retrieved for %s\n", object_dn));
- }
+#ifdef NOT_N_PLAT_NLM
+ int currentThreadGroupID;
+#endif
- if (rc != LDAP_SUCCESS) {
- rc = nmasldap_get_simple_pwd(ld, object_dn, *pwd_len, pwd);
- if (rc == LDAP_SUCCESS) {
-#ifdef DEBUG_PASSWORD
- DEBUG(100,("nmasldap_get_simple_pwd returned %s for %s\n", pwd, object_dn));
-#endif
- DEBUG(5, ("NDS Simple Password retrieved for %s\n", object_dn));
- } else {
- /* We couldn't get the password */
- DEBUG(3, ("NDS Simple Password NOT retrieved for %s\n", object_dn));
- return LDAP_INVALID_CREDENTIALS;
- }
- }
+ /* Validate char parameters. */
+ if (objectDN == NULL || (strlen(objectDN) == 0) || pwdSize == NULL || ld == NULL) {
+ return NMAS_E_INVALID_PARAMETER;
+ }
+ bufferLen = pwdBufLen = *pwdSize;
+ pwdBuf = (char *) malloc(pwdBufLen + 2);
+ if (pwdBuf == NULL) {
+ return NMAS_E_INSUFFICIENT_MEMORY;
+ }
+#ifdef NOT_N_PLAT_NLM
+ currentThreadGroupID = SetThreadGroupID(nmasLDAPThreadGroupID);
+#endif
- /* We got the password */
- return LDAP_SUCCESS;
-}
+ err = berEncodePasswordData(&requestBV, objectDN, NULL, NULL);
+ if (err) {
+ goto Cleanup;
+ }
+ /* Call the ldap_extended_operation (synchronously) */
+ if ((err = ldap_extended_operation_s(ld, NMASLDAP_GET_PASSWORD_REQUEST, requestBV, NULL, NULL, &replyOID, &replyBV))) {
+ goto Cleanup;
+ }
+ /* Make sure there is a return OID */
+ if (!replyOID) {
+ err = NMAS_E_NOT_SUPPORTED;
+ goto Cleanup;
+ }
+ /* Is this what we were expecting to get back. */
+ if (strcmp(replyOID, NMASLDAP_GET_PASSWORD_RESPONSE)) {
+ err = NMAS_E_NOT_SUPPORTED;
+ goto Cleanup;
+ }
+ /* Do we have a good returned berval? */
+ if (!replyBV) {
+ /*
+ * No; returned berval means we experienced a rather drastic error.
+ * Return operations error.
+ */
+ err = NMAS_E_SYSTEM_RESOURCES;
+ goto Cleanup;
+ }
+ err = berDecodeLoginData(replyBV, &serverVersion, &pwdBufLen, pwdBuf);
+
+ if (serverVersion != NMAS_LDAP_EXT_VERSION) {
+ err = NMAS_E_INVALID_VERSION;
+ goto Cleanup;
+ }
+ if (!err && pwdBufLen != 0) {
+ if (*pwdSize >= pwdBufLen + 1 && pwd != NULL) {
+ memcpy(pwd, pwdBuf, pwdBufLen);
+ pwd[pwdBufLen] = 0; /* add null termination */
+ }
+ *pwdSize = pwdBufLen; /* does not include null termination */
+ }
+ Cleanup:
+
+ if (replyBV) {
+ ber_bvfree(replyBV);
+ }
+ /* Free the return OID string if one was returned. */
+ if (replyOID) {
+ ldap_memfree(replyOID);
+ }
+ /* Free memory allocated while building the request ber and berval. */
+ if (requestBV) {
+ ber_bvfree(requestBV);
+ }
+ if (pwdBuf != NULL) {
+ memset(pwdBuf, 0, bufferLen);
+ free(pwdBuf);
+ }
+#ifdef NOT_N_PLAT_NLM
+ SetThreadGroupID(currentThreadGroupID);
+#endif
+ /* Return the appropriate error/success code. */
+ return err;
+} /* end of nmasldap_get_password */
Index: squid3/helpers/digest_auth/eDirectory/edir_ldapext.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/helpers/digest_auth/eDirectory/edir_ldapext.h,v
retrieving revision 1.3.10.1
retrieving revision 1.3.10.2
diff -u -r1.3.10.1 -r1.3.10.2
--- squid3/helpers/digest_auth/eDirectory/edir_ldapext.h 25 Jan 2008 02:33:35 -0000 1.3.10.1
+++ squid3/helpers/digest_auth/eDirectory/edir_ldapext.h 27 Jan 2008 18:08:41 -0000 1.3.10.2
@@ -1 +1,14 @@
-int nds_get_password(LDAP *ld, char *object_dn, size_t * pwd_len, char *pwd);
+/*
+ * edir_ldapext.h
+ *
+ * AUTHOR: Guy Antony Halse
+ *
+ * stubs for FreeRadius's edir_ldapext.h
+ *
+ */
+#define UNIVERSAL_PASS_LEN 256
+#define NMAS_SUCCESS 0
+
+extern int berEncodePasswordData(struct berval **requestBV, char *objectDN, char *password, char *password2);
+extern int berDecodeLoginData(struct berval *replyBV, int *serverVersion, size_t * retDataLen, void *retData);
+extern int nmasldap_get_password(LDAP * ld, char *objectDN, size_t * pwdSize, char *pwd);
Index: squid3/helpers/digest_auth/eDirectory/ldap_backend.c
===================================================================
RCS file: /cvsroot/squid-sf//squid3/helpers/digest_auth/eDirectory/ldap_backend.c,v
retrieving revision 1.5.10.1
retrieving revision 1.5.10.2
diff -u -r1.5.10.1 -r1.5.10.2
--- squid3/helpers/digest_auth/eDirectory/ldap_backend.c 25 Jan 2008 02:33:35 -0000 1.5.10.1
+++ squid3/helpers/digest_auth/eDirectory/ldap_backend.c 27 Jan 2008 18:08:41 -0000 1.5.10.2
@@ -198,7 +198,7 @@
char filter[8192];
char searchbase[8192];
char *universal_password = NULL;
- size_t universal_password_len = 256;
+ size_t universal_password_len = UNIVERSAL_PASS_LEN;
int nmas_res = 0;
int rc = -1;
if (ld) {
@@ -262,8 +262,8 @@
values = malloc(sizeof(char *));
/* actually talk to NMAS to get a password */
- nmas_res = nds_get_password(ld, ldap_get_dn(ld, entry), &universal_password_len, universal_password);
- if (nmas_res == LDAP_SUCCESS && universal_password) {
+ nmas_res = nmasldap_get_password(ld, ldap_get_dn(ld, entry), &universal_password_len, universal_password);
+ if (nmas_res == NMAS_SUCCESS && universal_password) {
if (debug)
printf("NMAS returned value %s\n", universal_password);
values[0] = universal_password;
Index: squid3/helpers/negotiate_auth/squid_kerb_auth/Makefile.am
===================================================================
RCS file: /cvsroot/squid-sf//squid3/helpers/negotiate_auth/squid_kerb_auth/Makefile.am,v
retrieving revision 1.1.30.1
retrieving revision 1.1.30.2
diff -u -r1.1.30.1 -r1.1.30.2
--- squid3/helpers/negotiate_auth/squid_kerb_auth/Makefile.am 25 Jan 2008 02:33:35 -0000 1.1.30.1
+++ squid3/helpers/negotiate_auth/squid_kerb_auth/Makefile.am 27 Jan 2008 18:08:41 -0000 1.1.30.2
@@ -1,7 +1,7 @@
#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.am,v 1.1.30.1 2008/01/25 02:33:35 valexey_eykon Exp $
+# $Id: Makefile.am,v 1.1.30.2 2008/01/27 18:08:41 rousskov Exp $
#
libexec_PROGRAMS = squid_kerb_auth
@@ -12,8 +12,10 @@
squid_kerb_auth_SOURCES = $(SOURCE) $(SPNEGO)
-CPPFLAGS = $(KERBINC) -I$(srcdir)/spnegohelp -I. -I$(top_srcdir)/include
-LDADD = -L$(top_builddir)/lib -lmiscutil $(XTRA_LIBS) $(KERBLIBS)
+CPPFLAGS = $(KERBINC) -I$(srcdir)/spnegohelp -I.
+#-I$(top_srcdir)/include -I$(top_srcdir)/src
+LDADD = $(KERBLIBS)
+#-L$(top_builddir)/lib -lmiscutil $(XTRA_LIBS)
# HEIMDAL
#KERBINC = -DHEIMDAL -I/usr/include/heimdal
Index: squid3/helpers/negotiate_auth/squid_kerb_auth/squid_kerb_auth.c
===================================================================
RCS file: /cvsroot/squid-sf//squid3/helpers/negotiate_auth/squid_kerb_auth/squid_kerb_auth.c,v
retrieving revision 1.1.30.1
retrieving revision 1.1.30.2
diff -u -r1.1.30.1 -r1.1.30.2
--- squid3/helpers/negotiate_auth/squid_kerb_auth/squid_kerb_auth.c 25 Jan 2008 02:33:35 -0000 1.1.30.1
+++ squid3/helpers/negotiate_auth/squid_kerb_auth/squid_kerb_auth.c 27 Jan 2008 18:08:41 -0000 1.1.30.2
@@ -32,9 +32,6 @@
#include
#include
-#include "getaddrinfo.h"
-#include "getnameinfo.h"
-
#include "base64.h"
#ifndef HAVE_SPNEGO
#include "spnegohelp.h"
@@ -81,7 +78,6 @@
return buf;
}
-// AYJ: this looks like a duplicate of the lib/gethostname function */
char *gethost_name(void) {
char hostname[MAXHOSTNAMELEN];
struct addrinfo *hres=NULL, *hres_list;
@@ -93,10 +89,9 @@
fprintf(stderr, "%s| %s: error while resolving hostname '%s'\n", LogTime(), PROGRAM, hostname);
return NULL;
}
- rc = xgetaddrinfo(hostname,NULL,NULL,&hres);
+ rc = getaddrinfo(hostname,NULL,NULL,&hres);
if (rc != 0) {
- fprintf(stderr, "%s| %s: error while resolving hostname with getaddrinfo: %s\n", LogTime(), PROGRAM, xgai_strerror(rc));
- xfreeaddrinfo(hres);
+ fprintf(stderr, "%s| %s: error while resolving hostname with getaddrinfo: %s\n", LogTime(), PROGRAM, gai_strerror(rc));
return NULL;
}
hres_list=hres;
@@ -105,14 +100,14 @@
count++;
hres_list=hres_list->ai_next;
}
- rc = xgetnameinfo(hres->ai_addr, hres->ai_addrlen,hostname, sizeof (hostname), NULL, 0, 0);
+ rc = getnameinfo (hres->ai_addr, hres->ai_addrlen,hostname, sizeof (hostname), NULL, 0, 0);
if (rc != 0) {
- fprintf(stderr, "%s| %s: error while resolving ip address with getnameinfo: %s\n", LogTime(), PROGRAM, xgai_strerror(rc));
- xfreeaddrinfo(hres);
+ fprintf(stderr, "%s| %s: error while resolving ip address with getnameinfo: %s\n", LogTime(), PROGRAM, gai_strerror(rc));
+ freeaddrinfo(hres);
return NULL ;
}
- xfreeaddrinfo(hres);
+ freeaddrinfo(hres);
hostname[MAXHOSTNAMELEN]='\0';
return(strdup(hostname));
}
Index: squid3/helpers/ntlm_auth/SMB/smbval/rfcnb-priv.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/helpers/ntlm_auth/SMB/smbval/rfcnb-priv.h,v
retrieving revision 1.2.40.1
retrieving revision 1.2.40.2
diff -u -r1.2.40.1 -r1.2.40.2
--- squid3/helpers/ntlm_auth/SMB/smbval/rfcnb-priv.h 25 Jan 2008 02:33:35 -0000 1.2.40.1
+++ squid3/helpers/ntlm_auth/SMB/smbval/rfcnb-priv.h 27 Jan 2008 18:08:41 -0000 1.2.40.2
@@ -59,7 +59,7 @@
struct redirect_addr {
- struct in_addr ip_addr;
+ struct IN_ADDR ip_addr;
int port;
redirect_ptr next;
--- squid3/include/IPAddress.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,432 +0,0 @@
-/*
- * $Id: IPAddress.h,v 1.1.32.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * DEBUG: section 14 IP Storage and Handling
- * AUTHOR: Amos Jeffries
- *
- * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from the
- * Internet community. Development is led by Duane Wessels of the
- * National Laboratory for Applied Network Research and funded by the
- * National Science Foundation. Squid is Copyrighted (C) 1998 by
- * the Regents of the University of California. Please see the
- * COPYRIGHT file for full details. Squid incorporates software
- * developed and/or copyrighted by other sources. Please see the
- * CREDITS file for full details.
- *
- * This IPAddress code is copyright (C) 2007 by Treehouse Networks Ltd
- * of New Zealand. It is published and Lisenced as an extension of
- * squid under the same conditions as the main squid application.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#ifndef _INC_IPADDRESS_H
-#define _INC_IPADDRESS_H
-
-#if HAVE_SYS_SOCKET_H
-#include
-#endif
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#ifdef _SQUID_MSWIN_
-#include
-#endif
-#if HAVE_NETDB_H && !defined(_SQUID_NETDB_H_) /* protect NEXTSTEP */
-#define _SQUID_NETDB_H_
-#ifdef _SQUID_NEXT_
-#include
-#endif
-#include
-#endif
-
-
-#include
-#include
-
-#include "getaddrinfo.h"
-#include "getnameinfo.h"
-#include "inet_ntop.h"
-#include "inet_pton.h"
-
-/* FreeBSD hack:
- * This OS has at least one version that defines these as private
- * kernel macros commented as being 'non-standard'.
- * We need to use them, much nicer than the OS-provided __u*_*[]
- */
-#if USE_IPV6 && defined(_SQUID_FREEBSD_)
-#define s6_addr8 __u6_addr.__u6_addr8
-#define s6_addr16 __u6_addr.__u6_addr16
-#define s6_addr32 __u6_addr.__u6_addr32
-#endif
-
-/// Length of buffer that needs to be allocated to old a null-terminated IP-string
-// Yuck. But there are still structures that need it to be an 'integer constant'.
-#define MAX_IPSTRLEN 75
-
-/**
- * Holds and manipulates IPv4, IPv6, and Socket Addresses.
- */
-
-class IPAddress
-{
-
-public:
- /** @name Constructors and Destructor */
- /*@{*/
- IPAddress();
- IPAddress(const IPAddress &);
-
- /**
- * This constructor takes its own copy of the object pointed to for memory-safe usage later.
- * The caller must itself perform and ptr memory-management needed.
- *
- \deprecated Use of pointers can be nasty. Consider this a last-resort.
- * Prefer the by-reference (&) version instead.
- */
- IPAddress(IPAddress *);
-
- IPAddress(const struct in_addr &);
-
- IPAddress(const struct sockaddr_in &);
-#if USE_IPV6
-
- IPAddress(const struct in6_addr &);
-
- IPAddress(const struct sockaddr_in6 &);
-#endif
-
- IPAddress(const struct hostent &);
- IPAddress(const struct addrinfo &);
- IPAddress(const char*);
- /// Default destructor.
- ~IPAddress();
- /*@}*/
-
- /** @name Assignment Operators */
- /*@{*/
- IPAddress& operator =(const IPAddress &s);
- IPAddress& operator =(IPAddress *s);
-
- IPAddress& operator =(struct sockaddr_in const &s);
-
- IPAddress& operator =(struct in_addr const &s);
-#if USE_IPV6
-
- IPAddress& operator =(struct in6_addr const &s);
-
- IPAddress& operator =(struct sockaddr_in6 const &s);
-#endif
-
- bool operator =(const struct hostent &s);
- bool operator =(const struct addrinfo &s);
- bool operator =(const char *s);
- /*@}*/
-
- /** @name Boolean Operators */
- /*@{*/
- bool operator ==(IPAddress const &s) const;
- bool operator !=(IPAddress const &s) const;
- bool operator >=(IPAddress const &rhs) const;
- bool operator <=(IPAddress const &rhs) const;
- bool operator >(IPAddress const &rhs) const;
- bool operator <(IPAddress const &rhs) const;
-
-public:
- /* methods */
-
- /** Test whether content can be used as an IPv4 address
- * \retval true if content was received as an IPv4 address
- * \retval true if content was received as an IPv4-Mapped address
- * \retval false if content was received as a non-mapped IPv6 native address.
- */
- bool IsIPv4() const;
-
- /** Test whether content can be used as an IPv6 address.
- * \retval true if --enable-ipv6 has been compiled.
- * \retval false if --disable-ipv6 has been compiled.
- * \retval false if --with-ipv6-split-stack has been compiled AND content is IPv4-mapped.
- */
- bool IsIPv6() const;
-
- /** Test whether content can be used as a Socket address.
- * \retval true if address AND port are both set
- * \retval true if content was received as a Socket address with port
- * \retval false if port in unset (zero)
- */
- bool IsSockAddr() const;
-
- /** Content-neutral test for whether the specific IP case ANY_ADDR is stored.
- * This is the default content of a new undefined IPAddress object.
- * \retval true IPv4 0.0.0.0
- * \retval true IPv6 ::
- * \retval false anything else.
- */
- bool IsAnyAddr() const;
-
- /** Content-neutral test for whether the specific IP case NO_ADDR is stored.
- * \retval true IPv4 255.255.255.255
- * \retval true IPv6 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
- * \retval false anything else.
- */
- bool IsNoAddr() const;
-
- /** Content-neutral test for whether the specific IP case LOCALHOST is stored.
- * This is the default content of a new undefined IPAddress object.
- * \retval true IPv4 127.0.0.1
- * \retval true IPv6 ::1
- * \retval false anything else.
- */
- bool IsLocalhost() const;
-
- /*@}*/
-
- /** Retrieve the Port if stored.
- * \retval 0 Port is unset or an error occured.
- * \retval n Port associated with this address in host native -endian.
- */
- u_short GetPort() const;
-
- /** Set the Port value for an address.
- * Replaces any previously existing Port value.
- * \param port Port being assigned in host native -endian.
- * \retval 0 Port is unset or an error occured.
- * \retval n Port associated with this address in host native -endian.
- */
- u_short SetPort(u_short port);
-
- /// Set object to contain the specific IP case ANY_ADDR (format-neutral).
- /// see IsAnyAddr() for more detail.
- void SetAnyAddr();
-
- /// Set object to contain the specific IP case NO_ADDR (format-neutral).
- /// see \link IsNoAddr() for more detail.
- void SetNoAddr();
-
- /// Set object to contain the specific IP case LOCALHOST (format-neutral).
- /// see \link IsLocalhost() for more detail.
- void SetLocalhost();
-
- /// Fast reset of the stored content to what would be after default constructor.
- void SetEmpty();
-
- /** Require an IPv4-only address for this usage.
- * Converts the object to prefer only IPv4 output.
- \retval true Content can be IPv4
- \retval false Content CANNOT be IPv4
- */
- bool SetIPv4();
-
- /**
- * Valid results IF and only IF the stored IP address is actually a network bitmask
- * \retval N number of bits which are set in the bitmask stored.
- */
- int GetCIDR();
-
- /** Apply a mask to the stored address.
- * \param mask Netmask format to be bit-mask-AND'd over the stored address.
- */
- const int ApplyMask(const IPAddress &mask);
-
- /** Apply a mask to the stored address.
- * CIDR will be converted appropriate to map the stored content.
- * \param cidr CIDR Mask being applied. As an integer in host format.
- * \param mtype Type of CIDR mask being applied (AF_INET or AF_INET6)
- */
- bool ApplyMask(const unsigned int cidr, int mtype = AF_UNSPEC);
-
-
- /** Return the ASCII equivalent of the address
- * Semantically equivalent to the IPv4 inet_ntoa()
- * eg. 127.0.0.1 (IPv4) or ::1 (IPv6)
- * But for memory safety it requires a buffer as input
- * instead of producing one magically.
- * If buffer is not large enough the data is truncated silently.
- * \param buf Allocated buffer to write address to
- * \param len byte length of buffer available for writing.
- * \param force (optional) require the IPA in a specific format.
- * \return pointer to buffer received.
- */
- char* NtoA(char *buf, unsigned int len, int force = AF_UNSPEC) const;
-
- /** Return the ASCII equivalent of the address:port combination
- * Provides a URL formatted version of the content.
- * If buffer is not large enough the data is truncated silently.
- * eg. 127.0.0.1:80 (IPv4) or [::1]:80 (IPv6)
- * \param buf Allocated buffer to write address:port to
- * \param len byte length of buffer available for writing.
- * \return pointer to buffer received.
- */
- char* ToURL(char *buf, unsigned int len) const;
-
- /** Return a properly hostname formatted copy of the address
- * Provides a URL formatted version of the content.
- * If buffer is not large enough the data is truncated silently.
- * eg. 127.0.0.1 (IPv4) or [::1] (IPv6)
- * \param buf Allocated buffer to write address to
- * \param len byte length of buffer available for writing.
- * \return pointer to buffer received.
- */
- unsigned int ToHostname(char *buf, const unsigned int len) const;
-
- /** \fn bool GetReverseString(char buf[], IPAddressType show_format)
- * Convert the content into a Reverse-DNS string.
- * The buffer sent MUST be allocated large enough to hold the resulting string.
- * Name truncation will occur if buf does not have enough space.
- * The constant MAX_IPSTRLEN is defined to provide for sizing arrays correctly.
- * \param show_format may be one of: AF_INET, AF_INET6 for the format of rDNS string wanted.
- * \param buf buffer to receive the text string output.
- */
- bool GetReverseString(char buf[], int show_format = AF_UNSPEC) const;
-
- /** Test how two IP relate to each other.
- * \retval 0 IP are equal
- * \retval 1 IP rhs is greater (numerically) than that stored.
- * \retval -1 IP rhs is less (numerically) than that stored.
- */
- int matchIPAddr(const IPAddress &rhs) const;
-
- /**
- * Get RFC 3493 addrinfo structure from the IPAddress data
- * for protocol-neutral socket operations.
- * Should be passed a NULL pointer of type struct addrinfo* it will
- * allocate memory for the structures involved. (see FreeAddrInfo to clear).
- * Defaults to a TCP streaming socket, if other values (such as UDP) are needed
- * the caller MUST override these default settings.
- * Some situations may also require an actual call to the system getaddrinfo()
- * to pull relevant OS details for the socket.
- *\par
- * IPAddress allocated objects MUST be destructed by IPAddress::FreeAddrInfo
- * System getaddrinfo() allocated objects MUST be freed with system freeaddrinfo()
- *\par
- * Some OS require that IPv4 addresses are pre-mapped by the client.
- * The configure option --with-ipv4-mapping=yes will enable this.
- *
- * \param ai structure to be filled out.
- * \param force a specific sockaddr type is needed. default: don't care.
- */
-#if IPV6_SPECIAL_V4MAPPING
- void GetAddrInfo(struct addrinfo *&ai, int force = AF_INET6) const;
-#else
- void GetAddrInfo(struct addrinfo *&ai, int force = AF_UNSPEC) const;
-#endif
-
- /**
- * Equivalent to the sysem call freeaddrinfo() but for IPAddress allocated data
- */
- void FreeAddrInfo(struct addrinfo *&ai) const;
-
- /**
- * Initializes an empty addrinfo properly for use.
- * It is intended for use in cases such as getsockopt() where the addrinfo is
- * about to be changed and the stored details may not match the new ones coming.
- * \param ai addrinfo struct to be initialized as AF_UNSPEC with large address buffer
- */
- void InitAddrInfo(struct addrinfo *&ai) const;
-
- /**
- * Lookup a Host by Name. Equivalent to system call gethostbyname(char*)
- * \param s The textual FQDN of teh host being located.
- * \retval true lookup was successful and an IPA was located.
- * \retval false lookup failed or FQDN has no IP associated.
- */
- bool GetHostByName(const char *s);
-
-public:
- /* FIXME: When C => C++ conversion is done will be fully private.
- * Legacy Transition Methods.
- * These are here solely to simplify the transition
- * when moving from converted code to unconverted
- * these functions can be used to convert this object
- * and pull out the data needed by the unconverted code
- * they are intentionaly hard to use, use GetAddrInfo() instead.
- * these functiosn WILL NOT be in the final public API after transition.
- */
-
- /// \deprecated Deprecated for public use. Use IPAddress::GetAddrInfo()
- void GetSockAddr(struct sockaddr_in &) const;
-
- /// \deprecated Deprecated for public use. Use IPAddress::GetAddrInfo()
- bool GetInAddr(struct in_addr &) const; /* false if could not convert IPv6 down to IPv4 */
-#if USE_IPV6
-
- /// \deprecated Deprecated for public use. Use IPAddress::GetAddrInfo()
- void GetSockAddr(struct sockaddr_in6 &) const;
-
- /// \deprecated Deprecated for public use. Use IPAddress::GetAddrInfo()
- void GetInAddr(struct in6_addr &) const;
-#endif
-
-private:
- /* Conversion for dual-type internals */
-
- bool GetReverseString4(char buf[], const struct in_addr &) const;
-
- void check4Mapped();
-
-#if USE_IPV6
-
- bool GetReverseString6(char buf[], const struct in6_addr &) const;
-
- void Map4to6(const struct in_addr &src, struct in6_addr &dest) const;
-
- void Map6to4(const struct in6_addr &src, struct in_addr &dest) const;
-#endif
-
- // Worker behind GetHostName and char* converters
- bool LookupHostIP(const char *s, bool nodns);
-
- /* variables */
-#if USE_IPV6
-
- struct sockaddr_in6 m_SocketAddr;
-#else
-
- struct sockaddr_in m_SocketAddr;
-#endif
-};
-
-inline std::ostream &
-operator << (std::ostream &os, const IPAddress &ipa)
-{
- char buf[MAX_IPSTRLEN];
- os << ipa.ToURL(buf,MAX_IPSTRLEN);
- return os;
-}
-
-
-// Macros for Old IPv4-Only code that still needs to use IN_ADDR
-#define ANY_ADDR (struct in_addr)0x00000000
-#define NO_ADDR (struct_in_addr)0xFFFFFFFF
-#define IN_ADDR in_addr
-
-// WAS _sockaddr_in_list in an earlier incarnation
-/* INET6 : this could possibly be an addrinfo structure now IFF it needs to be in a generic raw form. */
-class IPAddress_list
-{
-public:
- IPAddress_list() { next = NULL; };
- ~IPAddress_list() { if(next) delete next; next = NULL; };
-
- IPAddress s;
- IPAddress_list *next;
-};
-
-
-#endif /* _INC_IPADDRESS_H */
Index: squid3/include/cache_snmp.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/cache_snmp.h,v
retrieving revision 1.3.30.1
retrieving revision 1.3.30.2
diff -u -r1.3.30.1 -r1.3.30.2
--- squid3/include/cache_snmp.h 25 Jan 2008 02:33:36 -0000 1.3.30.1
+++ squid3/include/cache_snmp.h 27 Jan 2008 18:08:42 -0000 1.3.30.2
@@ -1,5 +1,5 @@
/*
- * $Id: cache_snmp.h,v 1.3.30.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: cache_snmp.h,v 1.3.30.2 2008/01/27 18:08:42 rousskov Exp $
*/
#ifndef SQUID_CACHE_SNMP_H
@@ -42,26 +42,26 @@
/* basic groups under .squid */
-#define SQ_SYS SQUIDMIB, 1 /* cacheSystem group { squid 1 } */
+#define SQ_SYS SQUIDMIB, 1
#define LEN_SQ_SYS LEN_SQUIDMIB+1
-#define SQ_CONF SQUIDMIB, 2 /* cacheConfig group { squid 2 } */
+#define SQ_CONF SQUIDMIB, 2
#define LEN_SQ_CONF LEN_SQUIDMIB+1
-#define SQ_PRF SQUIDMIB, 3 /* cachePerformance group { squid 3 } */
+#define SQ_PRF SQUIDMIB, 3
#define LEN_SQ_PRF LEN_SQUIDMIB+1
-#define SQ_NET SQUIDMIB, 4 /* cacheNetwork group { squid 4 } */
+#define SQ_NET SQUIDMIB, 4
#define LEN_SQ_NET LEN_SQUIDMIB+1
-#define SQ_MESH SQUIDMIB, 5 /* cacheMesh group { squid 5 } */
+#define SQ_MESH SQUIDMIB, 5
#define LEN_SQ_MESH LEN_SQUIDMIB+1
/*
- * cacheSystem group { squid 1 }
+ * cacheSystem group
*/
enum {
SYS_START,
- SYSVMSIZ, /* cacheSysVMsize */
- SYSSTOR, /* cacheSysStorage */
- SYS_UPTIME,/* cacheUptime */
+ SYSVMSIZ,
+ SYSSTOR,
+ SYS_UPTIME,
SYS_END
};
@@ -69,33 +69,29 @@
#define LEN_SYS_INST LEN_SQ_SYS + 2
/*
- * cacheConfig group { squid 2 }
+ * cacheConfig group
*/
enum {
CONF_START,
- CONF_ADMIN, /* cacheAdmin */
- CONF_VERSION, /* cacheSoftware */
- CONF_VERSION_ID, /* cacheVersionId */
- CONF_LOG_FAC, /* cacheLoggingFacility */
- CONF_STORAGE, /* cacheStorageConfig group */
- CONF_UNIQNAME, /* cacheUniqName */
+ CONF_ADMIN,
+ CONF_VERSION,
+ CONF_VERSION_ID,
+ CONF_LOG_FAC,
+ CONF_STORAGE,
+ CONF_UNIQNAME,
CONF_END
};
#define LEN_CONF LEN_SQ_CONF + 1
#define LEN_CONF_INST LEN_SQ_CONF + 2
-
-/*
- * cacheStorageConfig group { cacheConfig 5 }
- */
enum {
CONF_ST_START,
- CONF_ST_MMAXSZ, /* cacheMemMaxSize */
- CONF_ST_SWMAXSZ, /* cacheSwapMaxSize */
- CONF_ST_SWHIWM, /* cacheSwapHighWM */
- CONF_ST_SWLOWM, /* cacheSwapLowWM */
+ CONF_ST_MMAXSZ,
+ CONF_ST_SWMAXSZ,
+ CONF_ST_SWHIWM,
+ CONF_ST_SWLOWM,
CONF_ST_END
};
@@ -103,187 +99,164 @@
#define LEN_CONF_ST_INST LEN_CONF + 2
/*
- * Cache Performance Group {squid 3}
+ * cacheMesh group
*/
enum {
- PERF_START,
- PERF_SYS, /* cacheSysPerf */
- PERF_PROTO, /* cacheProtoStats */
- PERF_END
-};
-
-
-/* cacheSysPerf */
-enum {
- PERF_SYS_START,
- PERF_SYS_PF, /* cacheSysPageFaults */
- PERF_SYS_NUMR, /* cacheSysNumReads */
- PERF_SYS_MEMUSAGE, /* cacheMemUsage */
- PERF_SYS_CPUTIME, /* cacheCpuTime */
- PERF_SYS_CPUUSAGE, /* cacheCpuUsage */
- PERF_SYS_MAXRESSZ, /* cacheMaxResSize */
- PERF_SYS_NUMOBJCNT, /* cacheNumObjCount */
- PERF_SYS_CURLRUEXP, /* cacheCurrentLRUExpiration */
- PERF_SYS_CURUNLREQ, /* cacheCurrentUnlinkRequests */
- PERF_SYS_CURUNUSED_FD, /* cacheCurrentUnusedFDescrCnt */
- PERF_SYS_CURRESERVED_FD, /* cacheCurrentResFileDescrCnt */
- PERF_SYS_CURUSED_FD, /* cacheCurrentFileDescrCnt */
- PERF_SYS_CURMAX_FD, /* cacheCurrentFileDescrMax */
- PERF_SYS_END
-};
-
-/* cacheProtoStats */
-enum {
- PERF_PROTOSTAT_START,
- PERF_PROTOSTAT_AGGR, /* cacheProtoAggregateStats */
- PERF_PROTOSTAT_MEDIAN, /* cacheMedianSvcTable */
- PERF_PROTOSTAT_END
+ MESH_START,
+ MESH_PTBL,
+ MESH_CTBL,
+ MESH_END
};
-/* cacheProtoAggregateStats */
-enum {
- PERF_PROTOSTAT_AGGR_START,
- PERF_PROTOSTAT_AGGR_HTTP_REQ, /* cacheProtoClientHttpRequests */
- PERF_PROTOSTAT_AGGR_HTTP_HITS, /* cacheHttpHits */
- PERF_PROTOSTAT_AGGR_HTTP_ERRORS, /* cacheHttpErrors */
- PERF_PROTOSTAT_AGGR_HTTP_KBYTES_IN, /* cacheHttpInKb */
- PERF_PROTOSTAT_AGGR_HTTP_KBYTES_OUT, /* cacheHttpOutKb */
- PERF_PROTOSTAT_AGGR_ICP_S, /* cacheIcpPktsSent */
- PERF_PROTOSTAT_AGGR_ICP_R, /* cacheIcpPktsRecv */
- PERF_PROTOSTAT_AGGR_ICP_SKB, /* cacheIcpKbSent */
- PERF_PROTOSTAT_AGGR_ICP_RKB, /* cacheIcpKbRecv */
- PERF_PROTOSTAT_AGGR_REQ, /* cacheServerRequests */
- PERF_PROTOSTAT_AGGR_ERRORS, /* cacheServerErrors */
- PERF_PROTOSTAT_AGGR_KBYTES_IN, /* cacheServerInKb */
- PERF_PROTOSTAT_AGGR_KBYTES_OUT, /* cacheServerOutKb */
- PERF_PROTOSTAT_AGGR_CURSWAP, /* cacheCurrentSwapSize */
- PERF_PROTOSTAT_AGGR_CLIENTS, /* cacheClients */
- PERF_PROTOSTAT_AGGR_END
+enum { /* cachePeerTable */
+ MESH_PTBL_START,
+ MESH_PTBL_NAME,
+ MESH_PTBL_IP,
+ MESH_PTBL_HTTP,
+ MESH_PTBL_ICP,
+ MESH_PTBL_TYPE,
+ MESH_PTBL_STATE,
+ MESH_PTBL_SENT,
+ MESH_PTBL_PACKED,
+ MESH_PTBL_FETCHES,
+ MESH_PTBL_RTT,
+ MESH_PTBL_IGN,
+ MESH_PTBL_KEEPAL_S,
+ MESH_PTBL_KEEPAL_R,
+ MESH_PTBL_END
};
-
-/* CacheMedianSvcEntry */
-enum {
- PERF_MEDIAN_START,
- PERF_MEDIAN_TIME, /* cacheMedianTime */
- PERF_MEDIAN_HTTP_ALL, /* cacheHttpAllSvcTime */
- PERF_MEDIAN_HTTP_MISS, /* cacheHttpMissSvcTime */
- PERF_MEDIAN_HTTP_NM, /* cacheHttpNmSvcTime */
- PERF_MEDIAN_HTTP_HIT, /* cacheHttpHitSvcTime */
- PERF_MEDIAN_ICP_QUERY, /* cacheIcpQuerySvcTime */
- PERF_MEDIAN_ICP_REPLY, /* cacheIcpReplySvcTime */
- PERF_MEDIAN_DNS, /* cacheDnsSvcTime */
- PERF_MEDIAN_RHR, /* cacheRequestHitRatio */
- PERF_MEDIAN_BHR, /* cacheRequestByteRatio */
- PERF_MEDIAN_HTTP_NH, /* cacheHttpNhSvcTime */
- PERF_MEDIAN_END
+enum { /* cacheClientTable */
+ MESH_CTBL_START,
+ MESH_CTBL_ADDR,
+ MESH_CTBL_HTREQ,
+ MESH_CTBL_HTBYTES,
+ MESH_CTBL_HTHITS,
+ MESH_CTBL_HTHITBYTES,
+ MESH_CTBL_ICPREQ,
+ MESH_CTBL_ICPBYTES,
+ MESH_CTBL_ICPHITS,
+ MESH_CTBL_ICPHITBYTES,
+ MESH_CTBL_END
};
-
-
-
/*
- * cacheNetwork group { squid 4 }
+ * cacheNetwork group
*/
enum {
NET_START,
- NET_IP_CACHE, /* cacheIpCache */
- NET_FQDN_CACHE, /* cacheFqdnCache */
- NET_DNS_CACHE, /* cacheDns */
+ NET_IP_CACHE,
+ NET_FQDN_CACHE,
+ NET_DNS_CACHE,
NET_END
};
-/* cacheIpCache */
enum {
- IP_START,
- IP_ENT, /* cacheIpEntrie */
- IP_REQ, /* cacheIpRequests */
- IP_HITS, /* acheIpHits */
- IP_PENDHIT, /* cacheIpPendingHits */
- IP_NEGHIT, /* cacheIpNegativeHit */
- IP_MISS, /* cacheIpMisses */
- IP_GHBN, /* cacheBlockingGetHostByName */
- IP_LOC, /* cacheAttemptReleaseLckEntries */
+ IP_START,
+ IP_ENT,
+ IP_REQ,
+ IP_HITS,
+ IP_PENDHIT,
+ IP_NEGHIT,
+ IP_MISS,
+ IP_GHBN,
+ IP_LOC,
IP_END
};
-/* cacheFqdnCache */
enum {
FQDN_START,
- FQDN_ENT, /* cacheFqdnEntries */
- FQDN_REQ, /* cacheFqdnRequests */
- FQDN_HITS, /* cacheFqdnHits */
- FQDN_PENDHIT, /* cacheFqdnPendingHits */
- FQDN_NEGHIT, /* cacheFqdnNegativeHits */
- FQDN_MISS, /* cacheFqdnMisses */
- FQDN_GHBN, /* cacheBlockingGetHostByAddr */
+ FQDN_ENT,
+ FQDN_REQ,
+ FQDN_HITS,
+ FQDN_PENDHIT,
+ FQDN_NEGHIT,
+ FQDN_MISS,
+ FQDN_GHBN,
FQDN_END
};
-
-/* cacheDNS */
enum {
DNS_START,
- DNS_REQ, /* cacheDnsRequests */
- DNS_REP, /* cacheDnsReplies */
- DNS_SERVERS, /* cacheDnsNumberServers */
+ DNS_REQ,
+ DNS_REP,
+ DNS_SERVERS,
DNS_END
};
-
-
-
/*
- * cacheMesh group { squid 5 }
+ * Cache Performance Group
*/
enum {
- MESH_START,
- MESH_PTBL, /* cachePeerTable */
- MESH_CTBL, /* cacheClientTable */
- MESH_END
+ PERF_START,
+ PERF_SYS,
+ PERF_PROTO,
+ PERF_END
};
-/* cachePeerEntry */
-enum {
- MESH_PTBL_START,
- MESH_PTBL_INDEX, /* cachePeerIndex */
- MESH_PTBL_NAME, /* cachePeerName */
- MESH_PTBL_ADDR_TYPE, /* cachePeerAddressType */
- MESH_PTBL_ADDR, /* cachePeerAddress */
- MESH_PTBL_HTTP, /* cachePortHttp */
- MESH_PTBL_ICP, /* cachePeerPortIcp */
- MESH_PTBL_TYPE, /* cachePeerType */
- MESH_PTBL_STATE, /* cachePeerStat */
- MESH_PTBL_SENT, /* cachePeerPingsSent */
- MESH_PTBL_PACKED, /* cachePeerPingsAcked */
- MESH_PTBL_FETCHES, /* cachePeerFetches */
- MESH_PTBL_RTT, /* cachePeerRtt */
- MESH_PTBL_IGN, /* cachePeerIgnored */
- MESH_PTBL_KEEPAL_S, /* cachePeerKeepAlSent */
- MESH_PTBL_KEEPAL_R, /* cachePeerKeepAlRecv */
- MESH_PTBL_END
+enum {
+ PERF_SYS_START,
+ PERF_SYS_PF,
+ PERF_SYS_NUMR,
+ PERF_SYS_MEMUSAGE,
+ PERF_SYS_CPUTIME,
+ PERF_SYS_CPUUSAGE,
+ PERF_SYS_MAXRESSZ,
+ PERF_SYS_NUMOBJCNT,
+ PERF_SYS_CURLRUEXP,
+ PERF_SYS_CURUNLREQ,
+ PERF_SYS_CURUNUSED_FD,
+ PERF_SYS_CURRESERVED_FD,
+ PERF_SYS_CURUSED_FD,
+ PERF_SYS_CURMAX_FD,
+ PERF_SYS_END
};
-/* cacheClientEntry */
-enum {
- MESH_CTBL_START,
- MESH_CTBL_ADDR_TYPE, /* cacheClientAddressType */
- MESH_CTBL_ADDR, /* cacheClientAddress */
- MESH_CTBL_HTREQ, /* cacheClientHttpRequests */
- MESH_CTBL_HTBYTES, /* cacheClientHttpKb */
- MESH_CTBL_HTHITS, /* cacheClientHttpHits */
- MESH_CTBL_HTHITBYTES, /* cacheClientHTTPHitKb */
- MESH_CTBL_ICPREQ, /* cacheClientIcpRequests */
- MESH_CTBL_ICPBYTES, /* cacheClientIcpKb */
- MESH_CTBL_ICPHITS, /* cacheClientIcpHits */
- MESH_CTBL_ICPHITBYTES,/* cacheClientIcpHitKb */
- MESH_CTBL_END
+enum {
+ PERF_PROTOSTAT_START,
+ PERF_PROTOSTAT_AGGR,
+ PERF_PROTOSTAT_MEDIAN,
+ PERF_PROTOSTAT_END
};
+enum {
+ PERF_PROTOSTAT_AGGR_START,
+ PERF_PROTOSTAT_AGGR_HTTP_REQ,
+ PERF_PROTOSTAT_AGGR_HTTP_HITS,
+ PERF_PROTOSTAT_AGGR_HTTP_ERRORS,
+ PERF_PROTOSTAT_AGGR_HTTP_KBYTES_IN,
+ PERF_PROTOSTAT_AGGR_HTTP_KBYTES_OUT,
+ PERF_PROTOSTAT_AGGR_ICP_S,
+ PERF_PROTOSTAT_AGGR_ICP_R,
+ PERF_PROTOSTAT_AGGR_ICP_SKB,
+ PERF_PROTOSTAT_AGGR_ICP_RKB,
+ PERF_PROTOSTAT_AGGR_REQ,
+ PERF_PROTOSTAT_AGGR_ERRORS,
+ PERF_PROTOSTAT_AGGR_KBYTES_IN,
+ PERF_PROTOSTAT_AGGR_KBYTES_OUT,
+ PERF_PROTOSTAT_AGGR_CURSWAP,
+ PERF_PROTOSTAT_AGGR_CLIENTS,
+ PERF_PROTOSTAT_AGGR_END
+};
+enum {
+ PERF_MEDIAN_START,
+ PERF_MEDIAN_TIME,
+ PERF_MEDIAN_HTTP_ALL,
+ PERF_MEDIAN_HTTP_MISS,
+ PERF_MEDIAN_HTTP_NM,
+ PERF_MEDIAN_HTTP_HIT,
+ PERF_MEDIAN_ICP_QUERY,
+ PERF_MEDIAN_ICP_REPLY,
+ PERF_MEDIAN_DNS,
+ PERF_MEDIAN_RHR,
+ PERF_MEDIAN_BHR,
+ PERF_MEDIAN_HTTP_NH,
+ PERF_MEDIAN_END
+};
#endif /* SQUID_SNMP */
Index: squid3/include/config.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/config.h,v
retrieving revision 1.15.6.1
retrieving revision 1.15.6.2
diff -u -r1.15.6.1 -r1.15.6.2
--- squid3/include/config.h 25 Jan 2008 02:33:36 -0000 1.15.6.1
+++ squid3/include/config.h 27 Jan 2008 18:08:42 -0000 1.15.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: config.h,v 1.15.6.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: config.h,v 1.15.6.2 2008/01/27 18:08:42 rousskov Exp $
*
* AUTHOR: Duane Wessels
*
@@ -193,6 +193,14 @@
#define FD_SETSIZE SQUID_MAXFD
#endif
+
+
+/*
+ * This is hack to allow compiling IPv6-IPv4 version,
+ * not disturbing branches others than squid3-ipv6
+ */
+#define IN_ADDR in_addr
+
/* Typedefs for missing entries on a system */
#include "squid_types.h"
@@ -432,22 +440,12 @@
*/
#if WITH_VALGRIND
#include
-#undef VALGRIND_MAKE_NOACCESS
-#undef VALGRIND_MAKE_WRITABLE
-#undef VALGRIND_MAKE_READABLE
-/* A little glue for older valgrind version prior to 3.2.0 */
-#ifndef VALGRIND_MAKE_MEM_NOACCESS
-#define VALGRIND_MAKE_MEM_NOACCESS VALGRIND_MAKE_NOACCESS
-#define VALGRIND_MAKE_MEM_UNDEFINED VALGRIND_MAKE_WRITABLE
-#define VALGRIND_MAKE_MEM_DEFINED VALGRIND_MAKE_READABLE
-#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE VALGRIND_CHECK_WRITABLE
-#endif
-#else
-#define VALGRIND_MAKE_MEM_NOACCESS(a,b) (0)
-#define VALGRIND_MAKE_MEM_UNDEFINED(a,b) (0)
-#define VALGRIND_MAKE_MEM_DEFINED(a,b) (0)
-#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,b) (0)
-#define VALGRIND_CHECK_MEM_IS_DEFINED(a,b) (0)
+#else
+#define VALGRIND_MAKE_NOACCESS(a,b) (0)
+#define VALGRIND_MAKE_WRITABLE(a,b) (0)
+#define VALGRIND_MAKE_READABLE(a,b) (0)
+#define VALGRIND_CHECK_WRITABLE(a,b) (0)
+#define VALGRIND_CHECK_READABLE(a,b) (0)
#define VALGRIND_MALLOCLIKE_BLOCK(a,b,c,d)
#define VALGRIND_FREELIKE_BLOCK(a,b)
#define RUNNING_ON_VALGRIND 0
--- squid3/include/getaddrinfo.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,115 +0,0 @@
-#ifndef _getaddrinfo_h
-#define _getaddrinfo_h
-
-/*
- * Shamelessly duplicated from the fetchmail public sources
- * for use by the Squid Project under GNU Public License.
- *
- * Update/Maintenance History:
- *
- * 15-Aug-2007 : Copied from fetchmail 6.3.8
- * - added protection around libray headers
- *
- * 16-Aug-2007 : Altered configure checks
- * Un-hacked slightly to use system gethostbyname()
- *
- * Squid CVS $Id: getaddrinfo.h,v 1.1.8.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * Original License and code follows.
- */
-
-#include "config.h"
-
-/*
- * This file is part of libESMTP, a library for submission of RFC 2822
- * formatted electronic mail messages using the SMTP protocol described
- * in RFC 2821.
- *
- * Copyright (C) 2001,2002 Brian Stafford
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Structure and prototypes taken from RFC 2553 */
-
-#ifdef HAVE_GETADDRINFO
-
- /* These functions are provided by the OS */
-#define xgetaddrinfo getaddrinfo
-#define xfreeaddrinfo freeaddrinfo
-#define xgai_strerror gai_strerror
-
-#else /* !HAVE_GETADDRINFO */
-
-/* SG 23/09/2007:
- On Windows the following definitions are already available, may be that
- this could be needed on some other platform */
-#if 0
-struct addrinfo
- {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for nodename */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
- };
-
-/* Supposed to be defined in */
-#define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
-#define AI_CANONNAME 2 /* Request for canonical name. */
-#define AI_NUMERICHOST 4 /* Don't use name resolution. */
-
-/* Supposed to be defined in */
-#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with nodename */
-#define EAI_NONAME 8 /* nodename nor servname provided, or not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#endif
-#ifndef EAI_SYSTEM
-/* Not defined on mingw32. */
-#define EAI_SYSTEM 11 /* System error returned in `errno'. */
-#endif
-#ifndef EAI_OVERFLOW
-/* Not defined on mingw32. */
-#define EAI_OVERFLOW 12 /* Argument buffer overflow. */
-#endif
-
-#ifndef IN_EXPERIMENTAL
-#define IN_EXPERIMENTAL(a) \
- ((((long int) (a)) & 0xf0000000) == 0xf0000000)
-#endif
-
-/* RFC 2553 / Posix resolver */
-SQUIDCEXTERN int xgetaddrinfo (const char *nodename, const char *servname,
- const struct addrinfo *hints, struct addrinfo **res);
-
-/* Free addrinfo structure and associated storage */
-SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai);
-
-/* Convert error return from getaddrinfo() to string */
-SQUIDCEXTERN const char *xgai_strerror (int code);
-
-#endif /* HAVE_GETADDRINFO */
-
-#endif
--- squid3/include/getnameinfo.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,30 +0,0 @@
-#ifndef _getnameinfo_h
-#define _getnameinfo_h
-/*
- * Reconstructed from KAME getnameinfo.c (in lib/)
- *
- * $Id: getnameinfo.h,v 1.1.8.1 2008/01/25 02:33:36 valexey_eykon Exp $
- */
-
-#include "config.h"
-
-#ifdef HAVE_GETNAMEINFO
-
- /* These functions are provided by the OS */
-#define xgetnameinfo getnameinfo
-
-#else /* !HAVE_GETNAMEINFO */
-
-/* RFC 2553 / Posix resolver */
-SQUIDCEXTERN int xgetnameinfo(const struct sockaddr *sa,
- socklen_t salen,
- char *host,
- size_t hostlen,
- char *serv,
- size_t servlen,
- int flags );
-
-
-#endif /* HAVE_GETNAMEINFO */
-
-#endif
--- squid3/include/inet_ntop.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,23 +0,0 @@
-#ifndef _INC_INET_NTOP_H
-#define _INC_INET_NTOP_H
-
-#if HAVE_INET_NTOP
-
-/* Use the system provided version where possible */
-#define xinet_ntop inet_ntop
-
-#else
-
-/* char *
- * inet_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
- * return:
- * pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- * Paul Vixie, 1996.
- */
-SQUIDCEXTERN const char * xinet_ntop(int af, const void *src, char *dst, size_t size);
-
-#endif
-
-#endif /* _INC_INET_NTOP_H */
--- squid3/include/inet_pton.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,26 +0,0 @@
-#ifndef _INC_INET_PTON_H
-#define _INC_INET_PTON_H
-
-#if HAVE_INET_PTON
-
-/* Use the system provided version where possible */
-#define xinet_pton inet_pton
-
-#else
-
-/* int
- * inet_pton(af, src, dst)
- * convert from presentation format (which usually means ASCII printable)
- * to network format (which is usually some kind of binary format).
- * return:
- * 1 if the address was valid for the specified address family
- * 0 if the address wasn't valid (`dst' is untouched in this case)
- * -1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- * Paul Vixie, 1996.
- */
-SQUIDCEXTERN int xinet_pton(int af, const char *src, void *dst);
-
-#endif
-
-#endif /* _INC_INET_NTOP_H */
Index: squid3/include/profiling.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/profiling.h,v
retrieving revision 1.21.30.2
retrieving revision 1.21.30.3
diff -u -r1.21.30.2 -r1.21.30.3
--- squid3/include/profiling.h 25 Jan 2008 02:33:36 -0000 1.21.30.2
+++ squid3/include/profiling.h 27 Jan 2008 18:08:42 -0000 1.21.30.3
@@ -156,7 +156,8 @@
XPROF_HttpHeaderParse,
XPROF_HttpHeaderClean,
XPROF_StringInitBuf,
- XPROF_StringAllocAndFill,
+ XPROF_StringInit,
+ XPROF_StringLimitInit,
XPROF_StringClean,
XPROF_StringReset,
XPROF_StringAppend,
Index: squid3/include/rfc1035.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/rfc1035.h,v
retrieving revision 1.8.6.1
retrieving revision 1.8.6.2
diff -u -r1.8.6.1 -r1.8.6.2
--- squid3/include/rfc1035.h 25 Jan 2008 02:33:36 -0000 1.8.6.1
+++ squid3/include/rfc1035.h 27 Jan 2008 18:08:42 -0000 1.8.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: rfc1035.h,v 1.8.6.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: rfc1035.h,v 1.8.6.2 2008/01/27 18:08:42 rousskov Exp $
*
* AUTHOR: Duane Wessels
*
@@ -95,8 +95,7 @@
size_t sz,
rfc1035_message ** answer);
SQUIDCEXTERN int rfc1035QueryCompare(const rfc1035_query *, const rfc1035_query *);
-SQUIDCEXTERN void rfc1035RRDestroy(rfc1035_rr ** rr, int n);
-SQUIDCEXTERN void rfc1035MessageDestroy(rfc1035_message ** message);
+SQUIDCEXTERN void rfc1035MessageDestroy(rfc1035_message * message);
SQUIDCEXTERN int rfc1035_errno;
SQUIDCEXTERN const char *rfc1035_error_message;
--- squid3/include/rfc3596.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,86 +0,0 @@
-/*
- * $Id: rfc3596.h,v 1.1.32.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * AUTHOR: Amos Jeffries, Rafael Martinez Torres
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This code is copyright (C) 2007 by Treehouse Networks Ltd of
- * New Zealand. It is published and Lisenced as an extension of
- * squid under the same conditions as the main squid application.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#ifndef SQUID_RFC3596_H
-#define SQUID_RFC3596_H
-
-#include "config.h"
-
-/* RFC 3596 extends RFC 1035 */
-#include "rfc1035.h"
-
-SQUIDCEXTERN ssize_t rfc3596BuildAQuery(const char *hostname,
- char *buf,
- size_t sz,
- unsigned short qid,
- rfc1035_query * query);
-
-SQUIDCEXTERN ssize_t rfc3596BuildAAAAQuery(const char *hostname,
- char *buf,
- size_t sz,
- unsigned short qid,
- rfc1035_query * query);
-
-SQUIDCEXTERN ssize_t rfc3596BuildPTRQuery4(const struct in_addr,
- char *buf,
- size_t sz,
- unsigned short qid,
- rfc1035_query * query);
-
-SQUIDCEXTERN ssize_t rfc3596BuildPTRQuery6(const struct in6_addr,
- char *buf,
- size_t sz,
- unsigned short qid,
- rfc1035_query * query);
-
-/* RFC3596 library implements RFC1035 generic host interface */
-SQUIDCEXTERN ssize_t rfc3596BuildHostQuery(const char *hostname,
- char *buf,
- size_t sz,
- unsigned short qid,
- rfc1035_query * query,
- int qtype);
-
-/* RFC3596 section 2.1 defines new RR type AAAA as 28 */
-#define RFC1035_TYPE_AAAA 28
-
-/* rfc3596 library wraps rfc1035 errno and error_message */
-#define rfc3596_errno rfc1035_errno
-#define rfc3596_error_message rfc1035_error_message
-
-
-#endif /* SQUID_RFC3596_H */
Index: squid3/include/snmp_vars.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/snmp_vars.h,v
retrieving revision 1.1.70.1
retrieving revision 1.1.70.2
diff -u -r1.1.70.1 -r1.1.70.2
--- squid3/include/snmp_vars.h 25 Jan 2008 02:33:36 -0000 1.1.70.1
+++ squid3/include/snmp_vars.h 27 Jan 2008 18:08:43 -0000 1.1.70.2
@@ -25,7 +25,7 @@
*
* Author: Ryan Troll
*
- * $Id: snmp_vars.h,v 1.1.70.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: snmp_vars.h,v 1.1.70.2 2008/01/27 18:08:43 rousskov Exp $
*
**********************************************************************/
@@ -71,47 +71,9 @@
#define SMI_TIMETICKS (ASN_APPLICATION | 3) /* INTEGER */
#define SMI_OPAQUE (ASN_APPLICATION | 4) /* OCTET STRING */
#define SMI_COUNTER64 (ASN_APPLICATION | 6) /* INTEGER */
-
-
-/* constants for enums for the MIB nodes
- * cachePeerAddressType (InetAddressType / ASN_INTEGER)
- * cacheClientAddressType (InetAddressType / ASN_INTEGER)
- * Defined Types
- */
-
-#ifndef INETADDRESSTYPE_ENUMS
-#define INETADDRESSTYPE_ENUMS
-
-#define INETADDRESSTYPE_UNKNOWN 0
-#define INETADDRESSTYPE_IPV4 1
-#define INETADDRESSTYPE_IPV6 2
-#define INETADDRESSTYPE_IPV4Z 3
-#define INETADDRESSTYPE_IPV6Z 4
-#define INETADDRESSTYPE_DNS 16
-
-#endif /* INETADDRESSTYPE_ENUMS */
-
-
-/*
- * RFC 1905: Protocol Operations for SNMPv2
- *
- * Variable binding.
- *
- * VarBind ::=
- * SEQUENCE {
- * name ObjectName
- * CHOICE {
- * value ObjectSyntax
- * unSpecified NULL
- * noSuchObject[0] NULL
- * noSuchInstance[1] NULL
- * endOfMibView[2] NULL
- * }
- * }
- */
-#define SMI_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* noSuchObject[0] */
-#define SMI_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* noSuchInstance[1] */
-#define SMI_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* endOfMibView[2] */
+#define SMI_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
+#define SMI_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
+#define SMI_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
typedef struct variable variable;
typedef struct variable_list variable_list;
Index: squid3/include/squid_mswin.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/squid_mswin.h,v
retrieving revision 1.7.6.1
retrieving revision 1.7.6.2
diff -u -r1.7.6.1 -r1.7.6.2
--- squid3/include/squid_mswin.h 25 Jan 2008 02:33:36 -0000 1.7.6.1
+++ squid3/include/squid_mswin.h 27 Jan 2008 18:08:43 -0000 1.7.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: squid_mswin.h,v 1.7.6.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: squid_mswin.h,v 1.7.6.2 2008/01/27 18:08:43 rousskov Exp $
*
* AUTHOR: Andrey Shorin
* AUTHOR: Guido Serassio
@@ -212,14 +212,6 @@
#include
#include
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
-#include
-#endif
-#include
-#if (EAI_NODATA == EAI_NONAME)
-#undef EAI_NODATA
-#define EAI_NODATA WSANO_DATA
-#endif
-#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
/* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
#pragma warning (push)
#pragma warning (disable:4142)
@@ -251,7 +243,6 @@
#define ECONNRESET WSAECONNRESET
#define ENOTCONN WSAENOTCONN
#define ERESTART WSATRY_AGAIN
-#define EAFNOSUPPORT WSAEAFNOSUPPORT
#undef h_errno
#define h_errno errno /* we'll set it ourselves */
@@ -401,10 +392,10 @@
namespace Squid {
inline
-int accept(int s, struct sockaddr * a, size_t * l)
+int accept(int s, struct sockaddr * a, int * l)
{
SOCKET result;
- if ((result = ::accept(_get_osfhandle(s), a, (int *)l)) == INVALID_SOCKET) {
+ if ((result = ::accept(_get_osfhandle(s), a, l)) == INVALID_SOCKET) {
if (WSAEMFILE == (errno = WSAGetLastError()))
errno = EMFILE;
return -1;
@@ -467,9 +458,9 @@
#define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
inline
-int getsockname(int s, struct sockaddr * n, size_t * l)
+int getsockname(int s, struct sockaddr * n, int * l)
{
- if ((::getsockname(_get_osfhandle(s), n, (int *)l)) == SOCKET_ERROR) {
+ if ((::getsockname(_get_osfhandle(s), n, l)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
@@ -550,10 +541,10 @@
}
inline
-int recvfrom(int s, void * b, size_t l, int f, struct sockaddr * fr, size_t * fl)
+int recvfrom(int s, void * b, size_t l, int f, struct sockaddr * fr, int * fl)
{
int result;
- if ((result = ::recvfrom(_get_osfhandle(s), (char *)b, l, f, fr, (int *)fl)) == SOCKET_ERROR) {
+ if ((result = ::recvfrom(_get_osfhandle(s), (char *)b, l, f, fr, fl)) == SOCKET_ERROR) {
errno = WSAGetLastError();
return -1;
}
Index: squid3/include/util.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/include/util.h,v
retrieving revision 1.19.6.1
retrieving revision 1.19.6.2
diff -u -r1.19.6.1 -r1.19.6.2
--- squid3/include/util.h 25 Jan 2008 02:33:36 -0000 1.19.6.1
+++ squid3/include/util.h 27 Jan 2008 18:08:43 -0000 1.19.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: util.h,v 1.19.6.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: util.h,v 1.19.6.2 2008/01/27 18:08:43 rousskov Exp $
*
* AUTHOR: Harvest Derived
*
@@ -45,9 +45,6 @@
#if HAVE_SYS_TIME_H
#include
#endif
-#if HAVE_ARPA_INET_H
-#include
-#endif
#if !defined(SQUIDHOSTNAMELEN)
#define SQUIDHOSTNAMELEN 256
@@ -128,6 +125,8 @@
extern void xmalloc_find_leaks(void);
#endif
+typedef struct IN_ADDR SIA;
+SQUIDCEXTERN int safe_inet_addr(const char *, SIA *);
SQUIDCEXTERN time_t parse_iso3307_time(const char *buf);
SQUIDCEXTERN char *base64_decode(const char *coded);
SQUIDCEXTERN const char *base64_encode(const char *decoded);
@@ -144,13 +143,6 @@
SQUIDCEXTERN double drand48(void);
#endif
-#ifndef xmax
-#define xmax(a,b) ((a) < (b) ? (b) : (a))
-#endif
-#ifndef xmin
-#define xmin(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
typedef struct {
size_t count;
size_t bytes;
Index: squid3/lib/GNUregex.c
===================================================================
RCS file: /cvsroot/squid-sf//squid3/lib/GNUregex.c,v
retrieving revision 1.6.40.1
retrieving revision 1.6.40.2
diff -u -r1.6.40.1 -r1.6.40.2
--- squid3/lib/GNUregex.c 25 Jan 2008 02:33:36 -0000 1.6.40.1
+++ squid3/lib/GNUregex.c 27 Jan 2008 18:08:43 -0000 1.6.40.2
@@ -1,5 +1,5 @@
/*
- * $Id: GNUregex.c,v 1.6.40.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: GNUregex.c,v 1.6.40.2 2008/01/27 18:08:43 rousskov Exp $
*/
/* Extended regular expression matching and search library,
@@ -247,9 +247,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#if !defined(__MINGW32__) /* MinGW defines boolean */
typedef char boolean;
-#endif
#define false 0
#define true 1
--- squid3/lib/IPAddress.cc Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,1200 +0,0 @@
-/*
- * $Id: IPAddress.cc,v 1.1.32.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * DEBUG: section 14 IP Storage and Handling
- * AUTHOR: Amos Jeffries
- *
- * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from the
- * Internet community. Development is led by Duane Wessels of the
- * National Laboratory for Applied Network Research and funded by the
- * National Science Foundation. Squid is Copyrighted (C) 1998 by
- * the Regents of the University of California. Please see the
- * COPYRIGHT file for full details. Squid incorporates software
- * developed and/or copyrighted by other sources. Please see the
- * CREDITS file for full details.
- *
- * This IPAddress code is copyright (C) 2007 by Treehouse Networks Ltd
- * of New Zealand. It is published and Lisenced as an extension of
- * squid under the same conditions as the main squid application.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#include "config.h"
-
-#include "IPAddress.h"
-
-#if HAVE_ASSERT_H
-#include
-#endif
-#if HAVE_STDLIB_H
-#include
-#endif
-#if HAVE_STRING_H
-#include
-#endif
-#if HAVE_ARPA_INET_H
-#include /* inet_ntoa() */
-#endif
-
-#include "util.h"
-
-#ifdef INET6
-#error "INET6 defined but has been deprecated! Try running bootstrap and configure again."
-#endif
-
-/* We want to use the debug routines when running as module of squid. */
-/* otherwise fallback to printf if those are not available. */
-#ifndef SQUID_DEBUG
-# define debugs(a,b,c) // drop.
-#else
-#warning "IPAddress built with Debugs!!"
-# include "../src/Debug.h"
-#endif
-
-#if !USE_IPV6
-// So there are some places where I will drop to using Macros too.
-// At least I can restrict them to this file so they don't corrupt the app with C code.
-# define sin6_addr sin_addr
-# define sin6_port sin_port
-# define sin6_family sin_family
-#undef s6_addr
-# define s6_addr s_addr
-#endif
-
-static const unsigned int STRLEN_IP4A = 16; // aaa.bbb.ccc.ddd\0
-static const unsigned int STRLEN_IP4R = 28; // ddd.ccc.bbb.aaa.in-addr.arpa.\0
-static const unsigned int STRLEN_IP4S = 21; // ddd.ccc.bbb.aaa:ppppp\0
-static const unsigned int MAX_IP4_STRLEN = STRLEN_IP4R;
-static const unsigned int STRLEN_IP6A = 42; // [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]/0
-static const unsigned int STRLEN_IP6R = 75; // f.f.f.f f.f.f.f f.f.f.f f.f.f.f f.f.f.f f.f.f.f f.f.f.f f.f.f.f ipv6.arpa./0
-static const unsigned int STRLEN_IP6S = 48; // [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:00000/0
-static const unsigned int MAX_IP6_STRLEN = STRLEN_IP6R;
-
-
-/* Debugging only. Dump the address content when a fatal assert is encountered. */
-#if USE_IPV6
-#define IASSERT(a,b) \
- if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \
- printf("IPAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \
- printf("ADDRESS:"); \
- for(unsigned int i = 0; i < sizeof(m_SocketAddr.sin6_addr); i++) { \
- printf(" %x", m_SocketAddr.sin6_addr.s6_addr[i]); \
- } printf("\n"); assert(b); \
- }
-#else
-#define IASSERT(a,b) \
- if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \
- printf("IPAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \
- printf("ADDRESS: %x\n", (unsigned int)m_SocketAddr.sin_addr.s_addr); \
- assert(b); \
- }
-#endif
-
-IPAddress::IPAddress()
-{
- SetEmpty();
-}
-
-IPAddress::~IPAddress()
-{
- memset(this,0,sizeof(IPAddress));
-}
-
-int
-IPAddress::GetCIDR()
-{
- uint8_t shift,byte;
- uint8_t bit,caught;
- int len = 0;
-#if USE_IPV6
- uint8_t *ptr= m_SocketAddr.sin6_addr.s6_addr;
-#else
- uint8_t *ptr= (uint8_t *)&m_SocketAddr.sin_addr.s_addr;
-#endif
-
- /* Let's scan all the bits from Most Significant to Least */
- /* Until we find an "0" bit. Then, we return */
- shift=0;
-
-#if USE_IPV6
- /* return IPv4 CIDR for any Mapped address */
- /* Thus only check the mapped bit */
-
- if( !IsIPv6() ) {
- shift = 12;
- }
-
-#endif
-
- for (;shift 128)
- return false;
-
- if (cidr > 32 && mtype == AF_INET)
- return false;
-
- clearbits = (uint8_t)( (mtype==AF_INET6?128:32) -cidr);
-
- // short-cut
- if(clearbits == 0)
- return true;
-
-#if USE_IPV6
-
- p = (uint8_t*)(&m_SocketAddr.sin6_addr) + 15;
-
-#else
-
- p = (uint8_t*)(&m_SocketAddr.sin_addr) + 3;
-
-#endif
-
- for (; clearbits>0 && p >= (uint8_t*)&m_SocketAddr.sin6_addr ; p-- ) {
- if(clearbits < 8) {
- *p &= ((0xFF << clearbits) & 0xFF);
- clearbits = 0;
- } else {
- *p &= 0x00;
- clearbits -= 8;
- }
- }
-
- return true;
-}
-
-bool IPAddress::IsSockAddr() const
-{
- return (m_SocketAddr.sin6_port != 0);
-}
-
-bool IPAddress::IsIPv4() const
-{
-#if USE_IPV6
-
- return IsAnyAddr() || IsNoAddr() ||
-#if IPV6_SPECIAL_LOCALHOST
- IsLocalhost() ||
-#endif
- ( m_SocketAddr.sin6_addr.s6_addr32[0] == htonl(0x00000000) &&
- m_SocketAddr.sin6_addr.s6_addr32[1] == htonl(0x00000000) &&
- m_SocketAddr.sin6_addr.s6_addr32[2] == htonl(0x0000FFFF)
- );
-
-#else
- return true; // enforce IPv4 in IPv4-only mode.
-#endif
-}
-
-bool IPAddress::IsIPv6() const
-{
-#if USE_IPV6
-
- return IsAnyAddr() || IsNoAddr() ||
-#if IPV6_SPECIAL_LOCALHOST
- IsLocalhost() ||
-#endif
- !( m_SocketAddr.sin6_addr.s6_addr32[0] == htonl(0x00000000) &&
- m_SocketAddr.sin6_addr.s6_addr32[1] == htonl(0x00000000) &&
- m_SocketAddr.sin6_addr.s6_addr32[2] == htonl(0x0000FFFF)
- );
-#else
- return false; // enforce IPv4 in IPv4-only mode.
-#endif
-}
-
-bool IPAddress::IsAnyAddr() const
-{
-#if USE_IPV6
- return m_SocketAddr.sin6_addr.s6_addr32[0] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[1] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[2] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[3] == 0
- ;
-#else
-
- return (INADDR_ANY == m_SocketAddr.sin_addr.s_addr);
-#endif
-}
-
-/// NOTE: Does NOT clear the Port stored. Ony the Address and Type.
-void IPAddress::SetAnyAddr()
-{
-#if USE_IPV6
- memset(&m_SocketAddr.sin6_addr, 0, sizeof(struct in6_addr) );
-#else
- memset(&m_SocketAddr.sin_addr, 0, sizeof(struct in_addr) );
-#endif
-}
-
-/// NOTE: completely empties the IPAddress structure. Address, Port, Type, everything.
-void IPAddress::SetEmpty()
-{
- memset(&m_SocketAddr, 0, sizeof(m_SocketAddr) );
-}
-
-bool IPAddress::SetIPv4()
-{
-#if USE_IPV6
-
-#if !IPV6_SPECIAL_LOCALHOST
- if( IsLocalhost() ) {
- m_SocketAddr.sin6_addr.s6_addr32[2] = htonl(0xffff);
- m_SocketAddr.sin6_addr.s6_addr32[3] = htonl(0x7F000001);
- return true;
- }
-#endif
-
- if( IsAnyAddr() ) {
- m_SocketAddr.sin6_addr.s6_addr32[2] = htonl(0xffff);
- return true;
- }
-
- if( IsIPv4())
- return true;
-
- // anything non-IPv4 and non-convertable is BAD.
- return false;
-#else
- return true; // Always IPv4 in IPv4-only builds.
-#endif
-}
-
-bool IPAddress::IsLocalhost() const
-{
-#if USE_IPV6
- return m_SocketAddr.sin6_addr.s6_addr32[0] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[1] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[2] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[3] == htonl(0x1)
-
-#if !IPV6_SPECIAL_LOCALHOST
- || m_SocketAddr.sin6_addr.s6_addr32[0] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[1] == 0
- && m_SocketAddr.sin6_addr.s6_addr32[2] == htonl(0xffff)
- && m_SocketAddr.sin6_addr.s6_addr32[3] == htonl(0x7F000001)
-#endif
- ;
-#else
-
- return (htonl(0x7F000001) == m_SocketAddr.sin_addr.s_addr);
-#endif
-}
-
-void IPAddress::SetLocalhost()
-{
-#if USE_IPV6
- SetAnyAddr();
- m_SocketAddr.sin6_addr.s6_addr[15] = 0x1;
- m_SocketAddr.sin6_family = AF_INET6;
-
-#else
- m_SocketAddr.sin_addr.s_addr = htonl(0x7F000001);
- m_SocketAddr.sin_family = AF_INET;
-#endif
-}
-
-bool IPAddress::IsNoAddr() const
-{
- // IFF the address == 0xff..ff (all ones)
-#if USE_IPV6
- return m_SocketAddr.sin6_addr.s6_addr32[0] == 0xFFFFFFFF
- && m_SocketAddr.sin6_addr.s6_addr32[1] == 0xFFFFFFFF
- && m_SocketAddr.sin6_addr.s6_addr32[2] == 0xFFFFFFFF
- && m_SocketAddr.sin6_addr.s6_addr32[3] == 0xFFFFFFFF
- ;
-#else
-
- return 0xFFFFFFFF == m_SocketAddr.sin_addr.s_addr;
-#endif
-}
-
-void IPAddress::SetNoAddr()
-{
-#if USE_IPV6
- memset(&m_SocketAddr.sin6_addr, 0xFFFFFFFF, sizeof(struct in6_addr) );
- m_SocketAddr.sin6_family = AF_INET6;
-#else
- memset(&m_SocketAddr.sin_addr, 0xFFFFFFFF, sizeof(struct in_addr) );
- m_SocketAddr.sin_family = AF_INET;
-#endif
-}
-
-#if USE_IPV6
-
-bool IPAddress::GetReverseString6(char buf[MAX_IPSTRLEN], const struct in6_addr &dat) const
-{
- char *p = buf;
- unsigned char const *r = dat.s6_addr;
-
- /* RFC1886 says: */
- /* 4321:0:1:2:3:4:567:89ab */
- /* must be sent */
- /* b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.ip6.int. */
-
- /* Work from the binary field. Anything else may have representation changes. */
- /* The sin6_port and sin6_addr members shall be in network byte order. */
-
- /* Compile Err: 'Too many arguments for format. */
-
- for(int i = 15; i >= 0; i--, p+=4)
- {
- snprintf(p, 5, "%x.%x.", ((r[i])&0xf), (((r[i])>>4)&0xf) );
- }
-
- /* RFC3152 says: */
- /* ip6.int is now deprecated TLD, use ip6.arpa instead. */
- snprintf(p,10,"ip6.arpa.");
-
- return true;
-}
-
-#endif
-
-bool IPAddress::GetReverseString4(char buf[MAX_IPSTRLEN], const struct in_addr &dat) const
-{
- unsigned int i = (unsigned int) ntohl(dat.s_addr);
- snprintf(buf, 32, "%u.%u.%u.%u.in-addr.arpa.",
- i & 255,
- (i >> 8) & 255,
- (i >> 16) & 255,
- (i >> 24) & 255);
- return true;
-}
-
-bool IPAddress::GetReverseString(char buf[MAX_IPSTRLEN], int show_type) const
-{
-
- if(show_type == AF_UNSPEC) {
-#if USE_IPV6
- show_type = IsIPv6() ? AF_INET6 : AF_INET ;
-#else
- show_type = AF_INET;
-#endif
- }
-
- if (show_type == AF_INET && IsIPv4()) {
-#if USE_IPV6
-
- return GetReverseString4(buf, *(struct in_addr*)&m_SocketAddr.sin6_addr.s6_addr32[3] );
- } else if ( show_type == AF_INET6 && IsIPv6() ) {
- return GetReverseString6(buf, m_SocketAddr.sin6_addr);
-#else
- return GetReverseString4(buf, m_SocketAddr.sin_addr);
-#endif
- }
-
- debugs(14,0, "Unable to convert '" << NtoA(buf,MAX_IPSTRLEN) << "' to the rDNS type requested.");
-
- buf[0] = '\0';
-
- return false;
-}
-
-IPAddress& IPAddress::operator =(const IPAddress &s)
-{
- memcpy(this, &s, sizeof(IPAddress));
- return *this;
-};
-
-IPAddress::IPAddress(const char*s)
-{
- SetEmpty();
- operator=(s);
-}
-
-bool IPAddress::operator =(const char* s)
-{
- return LookupHostIP(s, true);
-}
-
-bool IPAddress::GetHostByName(const char* s)
-{
- return LookupHostIP(s, false);
-}
-
-bool IPAddress::LookupHostIP(const char *s, bool nodns)
-{
- int err = 0;
-
- short port = 0;
-
- struct addrinfo *res = NULL;
-
- struct addrinfo want;
-
- memset(&want, 0, sizeof(struct addrinfo));
- if(nodns) {
- want.ai_flags = AI_NUMERICHOST; // prevent actual DNS lookups!
- }
-#if !USE_IPV6
- want.ai_family = AF_INET;
-#endif
-
- if ( (err = xgetaddrinfo(s, NULL, &want, &res)) != 0) {
- debugs(14,1, HERE << "Given Bad IP '" << s << "': " << xgai_strerror(err) );
- /* free the memory xgetaddrinfo() dynamically allocated. */
- if(res) {
- xfreeaddrinfo(res);
- res = NULL;
- }
- return false;
- }
-
- /*
- * NP: =(sockaddr_*) may alter the port. we don't want that.
- * all we have been given as input was an IPA.
- */
- port = GetPort();
- operator=(*res);
- SetPort(port);
-
- /* free the memory xgetaddrinfo() dynamically allocated. */
- xfreeaddrinfo(res);
-
- res = NULL;
-
- return true;
-}
-
-IPAddress::IPAddress(struct sockaddr_in const &s)
-{
- SetEmpty();
- operator=(s);
-};
-
-IPAddress& IPAddress::operator =(struct sockaddr_in const &s)
-{
-#if USE_IPV6
- Map4to6((const in_addr)s.sin_addr, m_SocketAddr.sin6_addr);
- m_SocketAddr.sin6_port = s.sin_port;
- m_SocketAddr.sin6_family = AF_INET6;
-#else
-
- memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in));
-#endif
-
- /* maintain stored family values properly */
- check4Mapped();
-
- return *this;
-};
-
-void IPAddress::check4Mapped()
-{
- // obsolete.
- // TODO use this NOW to set the sin6_family properly on exporting. not on import.
-}
-
-#if USE_IPV6
-IPAddress::IPAddress(sockaddr_in6 const &s)
-{
- SetEmpty();
- operator=(s);
-};
-
-IPAddress& IPAddress::operator =(sockaddr_in6 const &s)
-{
- memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in6));
-
- /* maintain address family properly */
- check4Mapped();
- return *this;
-};
-
-#endif
-
-IPAddress::IPAddress(in_addr const &s)
-{
- SetEmpty();
- operator=(s);
-};
-
-IPAddress& IPAddress::operator =(struct in_addr const &s)
-{
-#if USE_IPV6
- Map4to6((const in_addr)s, m_SocketAddr.sin6_addr);
- m_SocketAddr.sin6_family = AF_INET6;
-
-#else
-
- memcpy(&m_SocketAddr.sin_addr, &s, sizeof(struct in_addr));
-
-#endif
-
- /* maintain stored family type properly */
- check4Mapped();
-
- return *this;
-};
-
-#if USE_IPV6
-
-IPAddress::IPAddress(struct in6_addr const &s)
-{
- SetEmpty();
- operator=(s);
-};
-
-IPAddress& IPAddress::operator =(struct in6_addr const &s)
-{
-
- memcpy(&m_SocketAddr.sin6_addr, &s, sizeof(struct in6_addr));
- m_SocketAddr.sin6_family = AF_INET6;
-
- /* maintain address family type properly */
- check4Mapped();
-
- return *this;
-};
-
-#endif
-
-IPAddress::IPAddress(const IPAddress &s)
-{
- SetEmpty();
- operator=(s);
-}
-
-IPAddress::IPAddress(IPAddress *s)
-{
- SetEmpty();
- operator=(s);
-}
-
-IPAddress& IPAddress::operator =(IPAddress *s)
-{
- IPAddress *tmp = NULL;
- if(!s) return *this;
- tmp = dynamic_cast(s);
- if(!tmp) return *this;
- return operator=(*tmp);
-}
-
-IPAddress::IPAddress(const struct hostent &s)
-{
- SetEmpty();
- operator=(s);
-}
-
-bool IPAddress::operator =(const struct hostent &s)
-{
-
- struct in_addr* ipv4 = NULL;
-
- struct in6_addr* ipv6 = NULL;
-
- //struct hostent {
- // char *h_name; /* official name of host */
- // char **h_aliases; /* alias list */
- // int h_addrtype; /* host address type */
- // int h_length; /* length of address */
- // char **h_addr_list; /* list of addresses */
- //}
-
- switch(s.h_addrtype)
- {
-
- case AF_INET:
- ipv4 = (in_addr*)(s.h_addr_list[0]);
- /* this */
- operator=(*ipv4);
- break;
-
- case AF_INET6:
- ipv6 = (in6_addr*)(s.h_addr_list[0]);
-#if USE_IPV6
- /* this */
- operator=(*ipv6);
-#else
-
- debugs(14,1, HERE << "Discarded IPv6 Address. Protocol disabled.");
-
- // FIXME see if there is another address in the list that might be usable ??
- return false;
-#endif
-
- break;
-
- default:
- IASSERT("false",false);
- return false;
- }
-
- return true;
-}
-
-IPAddress::IPAddress(const struct addrinfo &s)
-{
- SetEmpty();
- operator=(s);
-}
-
-bool IPAddress::operator =(const struct addrinfo &s)
-{
-
- struct sockaddr_in* ipv4 = NULL;
-
- struct sockaddr_in6* ipv6 = NULL;
-
- //struct addrinfo {
- // int ai_flags; /* input flags */
- // int ai_family; /* protocol family for socket */
- // int ai_socktype; /* socket type */
- // int ai_protocol; /* protocol for socket */
- // socklen_t ai_addrlen; /* length of socket-address */
- // struct sockaddr *ai_addr; /* socket-address for socket */
- // char *ai_canonname; /* canonical name for service location */
- // struct addrinfo *ai_next; /* pointer to next in list */
- //}
-
- switch(s.ai_family)
- {
-
- case AF_INET:
- ipv4 = (sockaddr_in*)(s.ai_addr);
- /* this */
- assert(ipv4);
- operator=(*ipv4);
- break;
-
- case AF_INET6:
- ipv6 = (sockaddr_in6*)(s.ai_addr);
-#if USE_IPV6
- /* this */
- assert(ipv6);
- operator=(*ipv6);
-#else
-
- debugs(14,1, HERE << "Discarded IPv6 Address. Protocol disabled.");
-
- // see if there is another address in the list that might be usable ??
-
- if (s.ai_next)
- return operator=(*s.ai_next);
- else
- return false;
-
-#endif
- break;
-
- case AF_UNSPEC:
- default:
- // attempt to handle partially initialised addrinfo.
- // such as those where data only comes from getsockopt()
- if(s.ai_addr != NULL) {
-#if USE_IPV6
- if(s.ai_addrlen == sizeof(struct sockaddr_in6)) {
- operator=(*((struct sockaddr_in6*)s.ai_addr));
- return true;
- }
- else
-#endif
- if(s.ai_addrlen == sizeof(struct sockaddr_in)) {
- operator=(*((struct sockaddr_in*)s.ai_addr));
- return true;
- }
- }
- return false;
- }
-
- return true;
-}
-
-void IPAddress::GetAddrInfo(struct addrinfo *&dst, int force) const
-{
- if(dst == NULL)
- {
- dst = new addrinfo;
- }
-
- memset(dst, 0, sizeof(struct addrinfo));
-
- // set defaults
- dst->ai_flags = AI_NUMERICHOST;
-
- if(dst->ai_socktype == 0)
- dst->ai_socktype = SOCK_STREAM;
-
- if(dst->ai_socktype == SOCK_STREAM // implies TCP
- && dst->ai_protocol == 0)
- dst->ai_protocol = IPPROTO_TCP;
-
- if(dst->ai_socktype == SOCK_DGRAM // implies UDP
- && dst->ai_protocol == 0)
- dst->ai_protocol = IPPROTO_UDP;
-
-#if USE_IPV6
- if( force == AF_INET6 || force == AF_UNSPEC && IsIPv6() )
- {
- dst->ai_addr = (struct sockaddr*)new sockaddr_in6;
-
- memset(dst->ai_addr,0,sizeof(struct sockaddr_in6));
-
- GetSockAddr(*((struct sockaddr_in6*)dst->ai_addr));
-
- dst->ai_addrlen = sizeof(struct sockaddr_in6);
-
- dst->ai_family = ((struct sockaddr_in6*)dst->ai_addr)->sin6_family;
- dst->ai_protocol = IPPROTO_IPV6;
- } else
-#endif
- if( force == AF_INET || force == AF_UNSPEC && IsIPv4() )
- {
-
- dst->ai_addr = (struct sockaddr*)new sockaddr_in;
-
- memset(dst->ai_addr,0,sizeof(struct sockaddr_in));
-
- GetSockAddr(*((struct sockaddr_in*)dst->ai_addr));
-
- dst->ai_addrlen = sizeof(struct sockaddr_in);
-
- dst->ai_family = ((struct sockaddr_in*)dst->ai_addr)->sin_family;
- } else
- {
- IASSERT("false",false);
- }
-}
-
-void IPAddress::InitAddrInfo(struct addrinfo *&ai) const
-{
- if(ai == NULL) {
- ai = new addrinfo;
- memset(ai,0,sizeof(struct addrinfo));
- }
-
- // remove any existing data.
- if(ai->ai_addr) delete ai->ai_addr;
-
- ai->ai_addr = (struct sockaddr*)new sockaddr_in6;
- memset(ai->ai_addr, 0, sizeof(struct sockaddr_in6));
-
- ai->ai_addrlen = sizeof(struct sockaddr_in6);
-
-}
-
-void IPAddress::FreeAddrInfo(struct addrinfo *&ai) const
-{
- if(ai == NULL) return;
-
- if(ai->ai_addr) delete ai->ai_addr;
-
- ai->ai_addr = NULL;
-
- ai->ai_addrlen = 0;
-
- // NP: name fields are NOT allocated at present.
- delete ai;
-
- ai = NULL;
-}
-
-int IPAddress::matchIPAddr(const IPAddress &rhs) const
-{
-#if USE_IPV6
- uint8_t *l = (uint8_t*)m_SocketAddr.sin6_addr.s6_addr;
- uint8_t *r = (uint8_t*)rhs.m_SocketAddr.sin6_addr.s6_addr;
-#else
- uint8_t *l = (uint8_t*)&m_SocketAddr.sin_addr.s_addr;
- uint8_t *r = (uint8_t*)&rhs.m_SocketAddr.sin_addr.s_addr;
-#endif
-
- // loop a byte-wise compare
- // NP: match MUST be R-to-L : L-to-R produces inconsistent gt/lt results at varying CIDR
- // expected difference on CIDR is gt/eq or lt/eq ONLY.
- for(unsigned int i = 0 ; i < sizeof(m_SocketAddr.sin6_addr) ; i++) {
-
- if(l[i] < r[i])
- return -1;
-
- if(l[i] > r[i])
- return 1;
- }
-
- return 0;
-}
-
-bool IPAddress::operator ==(const IPAddress &s) const
-{
- return (0 == matchIPAddr(s));
-}
-
-bool IPAddress::operator !=(const IPAddress &s) const
-{
- return ! ( operator==(s) );
-}
-
-bool IPAddress::operator <=(const IPAddress &rhs) const
-{
- if(IsAnyAddr() && !rhs.IsAnyAddr())
- return true;
-
- return (matchIPAddr(rhs) <= 0);
-}
-
-bool IPAddress::operator >=(const IPAddress &rhs) const
-{
- if(IsNoAddr() && !rhs.IsNoAddr())
- return true;
-
- return ( matchIPAddr(rhs) >= 0);
-}
-
-bool IPAddress::operator >(const IPAddress &rhs) const
-{
- if(IsNoAddr() && !rhs.IsNoAddr())
- return true;
-
- return ( matchIPAddr(rhs) > 0);
-}
-
-bool IPAddress::operator <(const IPAddress &rhs) const
-{
- if(IsNoAddr() && !rhs.IsNoAddr())
- return true;
-
- return ( matchIPAddr(rhs) < 0);
-}
-
-u_short IPAddress::GetPort() const
-{
- return ntohs( m_SocketAddr.sin6_port );
-}
-
-u_short IPAddress::SetPort(u_short prt)
-{
- m_SocketAddr.sin6_port = htons(prt);
-
- return prt;
-}
-
-/**
- * NtoA Given a buffer writes a readable ascii version of the IPA and/or port stored
- *
- * Buffer must be of a size large enough to hold the converted address.
- * This size is provided in the form of a global defined variable MAX_IPSTRLEN
- * Should a buffer shorter be provided the string result will be truncated
- * at the length of the available buffer.
- *
- * A copy of the buffer is also returned for simple immediate display.
- */
-char* IPAddress::NtoA(char* buf, const unsigned int blen, int force) const
-{
- // Ensure we have a buffer.
- if(buf == NULL) {
- return NULL;
- }
-
- /* some external code may have blindly memset a parent. */
- /* thats okay, our default is known */
- if( IsAnyAddr() ) {
-#if USE_IPV6
- memcpy(buf,"::\0", xmin(3,blen));
-#else
- memcpy(buf,"0.0.0.0\0", xmin(8,blen));
-#endif
- return buf;
- }
-
- memset(buf,0,blen); // clear buffer before write
-
- /* Pure-IPv6 CANNOT be displayed in IPv4 format. */
- /* However IPv4 CAN. */
- if( force == AF_INET && !IsIPv4() ) {
- if( IsIPv6() ) {
- memcpy(buf, "{!IPv4}\0", xmin(8,blen));
- }
- return buf;
- }
-
-#if USE_IPV6
- if( force == AF_INET6 || (force == AF_UNSPEC && IsIPv6()) ) {
-
- xinet_ntop(AF_INET6, &m_SocketAddr.sin6_addr, buf, blen);
-
- } else if ( force == AF_INET || (force == AF_UNSPEC && IsIPv4()) ) {
-
- struct in_addr tmp;
- GetInAddr(tmp);
- xinet_ntop(AF_INET, &tmp, buf, blen);
-#else
- if ( force == AF_UNSPEC || (force == AF_INET && IsIPv4()) ) {
- xinet_ntop(AF_INET, &m_SocketAddr.sin_addr, buf, blen);
-#endif
- } else {
- debugs(14,0,"WARNING: Corrupt IP Address details OR required to display in unknown format (" <<
- force << "). accepted={" << AF_UNSPEC << "," << AF_INET << "," << AF_INET6 << "}");
- fprintf(stderr,"WARNING: Corrupt IP Address details OR required to display in unknown format (%d). accepted={%d,%d,%d} ",
- force, AF_UNSPEC, AF_INET, AF_INET6);
- memcpy(buf,"dead:beef::\0", xmin(13,blen));
- assert(false);
- }
-
- return buf;
-}
-
-unsigned int IPAddress::ToHostname(char *buf, const unsigned int blen) const
-{
- char *p = buf;
-
- if(IsIPv6() && blen > 0) {
- *p = '[';
- p++;
- }
-
- /* 7 being space for [,], and port */
- if( IsIPv6() )
- NtoA(p, blen-7, AF_INET6);
- else
- NtoA(p, blen-7, AF_INET);
-
- // find the end of the new string
- while(*p != '\0' && p < buf+blen)
- p++;
-
- if(IsIPv6() && p < buf+blen-1) {
- *p = ']';
- p++;
- }
-
- /* terminate just in case. */
- *p = '\0';
-
- /* return size of buffer now used */
- return (p - buf);
-}
-
-char* IPAddress::ToURL(char* buf, unsigned int blen) const
-{
- char *p = buf;
-
- // Ensure we have a buffer.
-
- if(buf == NULL) {
- return NULL;
- }
-
- p += ToHostname(p, blen);
-
- if(m_SocketAddr.sin6_port > 0 && p < buf+blen-6) {
- /* 6 is max length of expected ':port' (short int) */
- snprintf(p, 6,":%d", GetPort() );
- }
-
- // force a null-terminated string
- buf[blen-1] = '\0';
-
- return buf;
-}
-
-void IPAddress::GetSockAddr(struct sockaddr_in &buf) const
-{
-#if USE_IPV6
-
- if( IsIPv4() )
- {
- buf.sin_family = AF_INET;
- buf.sin_port = m_SocketAddr.sin6_port;
- Map6to4( m_SocketAddr.sin6_addr, buf.sin_addr);
- } else
- {
- debugs(14,1, HERE << "IPAddress::GetSockAddr : Cannot convert non-IPv4 to IPv4.");
-
- memset(&buf,0xFFFFFFFF,sizeof(struct sockaddr_in));
- assert(false);
- }
-
-#else
-
- memcpy(&buf, &m_SocketAddr, sizeof(struct sockaddr_in));
-
- if(buf.sin_family == 0)
- {
- buf.sin_family = AF_INET;
- }
-
-#endif
-}
-
-#if USE_IPV6
-
-void IPAddress::GetSockAddr(struct sockaddr_in6 &buf) const
-{
- memcpy(&buf, &m_SocketAddr, sizeof(struct sockaddr_in6));
- /* maintain address family. It may have changed inside us. */
- buf.sin6_family = AF_INET6;
-}
-
-#endif
-
-#if USE_IPV6
-
-void IPAddress::Map4to6(const struct in_addr &in, struct in6_addr &out) const
-{
- /* check for special cases */
-
- if( in.s_addr == 0x00000000)
- {
- /* ANYADDR */
-
- memset(&out, 0, sizeof(struct in6_addr));
- } else if( in.s_addr == 0xFFFFFFFF)
- {
- /* NOADDR */
-
- out.s6_addr32[0] = 0xFFFFFFFF;
- out.s6_addr32[1] = 0xFFFFFFFF;
- out.s6_addr32[2] = 0xFFFFFFFF;
- out.s6_addr32[3] = 0xFFFFFFFF;
-
-#if IPV6_SPECIAL_LOCALHOST
- } else if( in.s_addr == htonl(0x7F000001))
- {
- /* LOCALHOST */
-
- memset(&out, 0, sizeof(struct in6_addr));
- out.s6_addr32[3] = htonl(0x1);
-#endif
-
- } else
- {
- /* general */
-
- memset(&out, 0, sizeof(struct in6_addr));
- out.s6_addr32[2] = htonl(0xFFFF);
- out.s6_addr32[3] = in.s_addr;
- }
-}
-
-void IPAddress::Map6to4(const struct in6_addr &in, struct in_addr &out) const
-{
- /* ANYADDR */
- /* NOADDR */
- /* general */
-
- memset(&out, 0, sizeof(struct in_addr));
- out.s_addr = in.s6_addr32[3];
-
-#if IPV6_SPECIAL_LOCALHOST
- /* LOCALHOST */
-
- if( IsLocalhost() )
- {
- out.s_addr = htonl(0x7F000001);
- }
-#endif
-
-}
-
-#endif
-
-#if USE_IPV6
-void IPAddress::GetInAddr(in6_addr &buf) const
-{
- memcpy(&buf, &m_SocketAddr.sin6_addr, sizeof(struct in6_addr));
-}
-
-#endif
-
-bool IPAddress::GetInAddr(struct in_addr &buf) const
-{
-
-#if USE_IPV6
- if( IsIPv4() ) {
- Map6to4((const in6_addr)m_SocketAddr.sin6_addr, buf);
- return true;
- }
-#else
-
- if( IsIPv4() ) {
- memcpy(&buf, &m_SocketAddr.sin_addr, sizeof(struct in_addr));
- return true;
- }
-#endif
-
- // default:
- // non-compatible IPv6 Pure Address
-
- debugs(14,1, HERE << "IPAddress::GetInAddr : Cannot convert non-IPv4 to IPv4. IPA=" << *this);
- memset(&buf,0xFFFFFFFF,sizeof(struct in_addr));
- assert(false);
- return false;
-}
Index: squid3/lib/Makefile.am
===================================================================
RCS file: /cvsroot/squid-sf//squid3/lib/Makefile.am,v
retrieving revision 1.22.6.2
retrieving revision 1.22.6.3
diff -u -r1.22.6.2 -r1.22.6.3
--- squid3/lib/Makefile.am 25 Jan 2008 02:33:36 -0000 1.22.6.2
+++ squid3/lib/Makefile.am 27 Jan 2008 18:08:44 -0000 1.22.6.3
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
#
-# $Id: Makefile.am,v 1.22.6.2 2008/01/25 02:33:36 valexey_eykon Exp $
+# $Id: Makefile.am,v 1.22.6.3 2008/01/27 18:08:44 rousskov Exp $
#
DIST_SUBDIRS = libTrie
@@ -58,7 +58,6 @@
hash.c \
heap.c \
html_quote.c \
- IPAddress.cc \
iso3307.c \
md5.c \
radix.c \
@@ -66,7 +65,7 @@
rfc1123.c \
rfc1738.c \
rfc2617.c \
- rfc3596.c \
+ safe_inet_addr.c \
$(SNPRINTFSOURCE) \
Splay.cc \
$(STRSEPSOURCE) \
@@ -98,15 +97,7 @@
TESTS=$(check_PROGRAMS)
check_PROGRAMS=tests/testAll
-tests_testAll_SOURCES= \
- tests/testArray.h \
- tests/testArray.cc \
- tests/testIPAddress.h \
- tests/testIPAddress.cc \
- IPAddress.cc \
- tests/testRFC1035.h \
- tests/testRFC1035.cc \
- tests/testMain.cc \
+tests_testAll_SOURCES= tests/testArray.cc tests/testMain.cc tests/testArray.h \
$(XPROF_STATS_SOURCE) \
$(WIN32SRC) \
util.c assert.c
Index: squid3/lib/MemPool.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/lib/MemPool.cc,v
retrieving revision 1.8.6.2
retrieving revision 1.8.6.3
diff -u -r1.8.6.2 -r1.8.6.3
--- squid3/lib/MemPool.cc 25 Jan 2008 02:33:36 -0000 1.8.6.2
+++ squid3/lib/MemPool.cc 27 Jan 2008 18:08:44 -0000 1.8.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: MemPool.cc,v 1.8.6.2 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: MemPool.cc,v 1.8.6.3 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 63 Low Level Memory Pool Management
* AUTHOR: Alex Rousskov, Andres Kroonmaa, Robert Collins
@@ -211,7 +211,7 @@
for (int i = 1; i < pool->chunk_capacity; i++) {
*Free = (void *) ((char *) Free + pool->obj_size);
void **nextFree = (void **)*Free;
- (void) VALGRIND_MAKE_MEM_NOACCESS(Free, pool->obj_size);
+ (void) VALGRIND_MAKE_NOACCESS(Free, pool->obj_size);
Free = nextFree;
}
nextFreeChunk = pool->nextFreeChunk;
@@ -277,7 +277,7 @@
Free = (void **)obj;
*Free = freeCache;
freeCache = obj;
- (void) VALGRIND_MAKE_MEM_NOACCESS(obj, obj_size);
+ (void) VALGRIND_MAKE_NOACCESS(obj, obj_size);
}
/*
@@ -294,7 +294,7 @@
/* first, try cache */
if (freeCache) {
Free = (void **)freeCache;
- (void) VALGRIND_MAKE_MEM_DEFINED(Free, obj_size);
+ (void) VALGRIND_MAKE_READABLE(Free, obj_size);
freeCache = *Free;
*Free = NULL;
return Free;
@@ -317,7 +317,7 @@
/* last free in this chunk, so remove us from perchunk freelist chain */
nextFreeChunk = chunk->nextFreeChunk;
}
- (void) VALGRIND_MAKE_MEM_DEFINED(Free, obj_size);
+ (void) VALGRIND_MAKE_READABLE(Free, obj_size);
return Free;
}
@@ -557,7 +557,7 @@
MemImplementingAllocator::free(void *obj)
{
assert(obj != NULL);
- (void) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(obj, obj_size);
+ (void) VALGRIND_CHECK_WRITABLE(obj, obj_size);
deallocate(obj);
++free_calls;
}
@@ -602,10 +602,10 @@
assert(splayLastResult == 0);
assert(chunk->inuse_count > 0);
chunk->inuse_count--;
- (void) VALGRIND_MAKE_MEM_DEFINED(Free, sizeof(void *));
+ (void) VALGRIND_MAKE_READABLE(Free, sizeof(void *));
freeCache = *(void **)Free; /* remove from global cache */
*(void **)Free = chunk->freeList; /* stuff into chunks freelist */
- (void) VALGRIND_MAKE_MEM_NOACCESS(Free, sizeof(void *));
+ (void) VALGRIND_MAKE_NOACCESS(Free, sizeof(void *));
chunk->freeList = Free;
chunk->lastref = squid_curtime;
}
--- squid3/lib/getaddrinfo.c Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,346 +0,0 @@
-/*
- * Shamelessly duplicated from the fetchmail public sources
- * for use by the Squid Project under GNU Public License.
- *
- * Update/Maintenance History:
- *
- * 15-Aug-2007 : Copied from fetchmail 6.3.8
- * - added protection around libray headers
- *
- * 16-Aug-2007 : Altered configure checks
- * Un-hacked slightly to use system gethostbyname()
- *
- * 06-Oct-2007 : Various fixes to allow the build on MinGW
- *
- * Squid CVS $Id: getaddrinfo.c,v 1.1.8.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * Original License and code follows.
- */
-#include "config.h"
-
-/*
- * This file is part of libESMTP, a library for submission of RFC 2822
- * formatted electronic mail messages using the SMTP protocol described
- * in RFC 2821.
- *
- * Copyright (C) 2001,2002 Brian Stafford
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* An emulation of the RFC 2553 / Posix getaddrinfo resolver interface.
- */
-
-#ifndef HAVE_GETADDRINFO
-
-/* Need to turn off Posix features in glibc to build this */
-#undef _POSIX_C_SOURCE
-#undef _XOPEN_SOURCE
-
-#if HAVE_STDLIB_H
-#include
-#endif
-#if HAVE_STRING_H
-#include
-#endif
-#if HAVE_CTYPE_H
-#include
-#endif
-#if HAVE_ERRNO_H
-#include
-#endif
-
-#if HAVE_SYS_SOCKET_H
-#include
-#endif
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if HAVE_ARPA_INET_H
-#include
-#endif
-#if HAVE_NETDB_H
-#include
-#endif
-#ifdef _SQUID_MSWIN_
-#undef IN_ADDR
-#include
-#endif
-
-#include "getaddrinfo.h"
-
-static struct addrinfo *
-dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen)
-{
- struct addrinfo *ret;
-
- ret = malloc (sizeof (struct addrinfo));
- if (ret == NULL)
- return NULL;
- memcpy (ret, info, sizeof (struct addrinfo));
- ret->ai_addr = malloc (addrlen);
- if (ret->ai_addr == NULL)
- {
- free (ret);
- return NULL;
- }
- memcpy (ret->ai_addr, addr, addrlen);
- ret->ai_addrlen = addrlen;
- return ret;
-}
-
-int
-xgetaddrinfo (const char *nodename, const char *servname,
- const struct addrinfo *hints, struct addrinfo **res)
-{
- struct hostent *hp;
- struct servent *servent;
- const char *socktype;
- int port;
- struct addrinfo hint, result;
- struct addrinfo *ai, *sai, *eai;
- char **addrs;
-
- if (servname == NULL && nodename == NULL)
- return EAI_NONAME;
-
- memset (&result, 0, sizeof result);
-
- /* default for hints */
- if (hints == NULL)
- {
- memset (&hint, 0, sizeof hint);
- hint.ai_family = PF_UNSPEC;
- hints = &hint;
- }
-
- if (servname == NULL)
- port = 0;
- else {
- /* check for tcp or udp sockets only */
- if (hints->ai_socktype == SOCK_STREAM)
- socktype = "tcp";
- else if (hints->ai_socktype == SOCK_DGRAM)
- socktype = "udp";
- else
- return EAI_SERVICE;
- result.ai_socktype = hints->ai_socktype;
-
- /* Note: maintain port in host byte order to make debugging easier */
- if (isdigit (*servname))
- port = strtol (servname, NULL, 10);
- else if ((servent = getservbyname (servname, socktype)) != NULL)
- port = ntohs (servent->s_port);
- else
- return EAI_NONAME;
- }
-
- /* if nodename == NULL refer to the local host for a client or any
- for a server */
- if (nodename == NULL)
- {
- struct sockaddr_in sin;
-
- /* check protocol family is PF_UNSPEC or PF_INET - could try harder
- for IPv6 but that's more code than I'm prepared to write */
- if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
- result.ai_family = AF_INET;
- else
- return EAI_FAMILY;
-
- sin.sin_family = result.ai_family;
- sin.sin_port = htons (port);
- if (hints->ai_flags & AI_PASSIVE)
- sin.sin_addr.s_addr = htonl (INADDR_ANY);
- else
- sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- /* Duplicate result and addr and return */
- *res = dup_addrinfo (&result, &sin, sizeof sin);
- return (*res == NULL) ? EAI_MEMORY : 0;
- }
-
- /* If AI_NUMERIC is specified, use inet_addr to translate numbers and
- dots notation. */
- if (hints->ai_flags & AI_NUMERICHOST)
- {
- struct sockaddr_in sin;
-
- /* check protocol family is PF_UNSPEC or PF_INET */
- if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
- result.ai_family = AF_INET;
- else
- return EAI_FAMILY;
-
- sin.sin_family = result.ai_family;
- sin.sin_port = htons (port);
- sin.sin_addr.s_addr = inet_addr (nodename);
- /* Duplicate result and addr and return */
- *res = dup_addrinfo (&result, &sin, sizeof sin);
- return (*res == NULL) ? EAI_MEMORY : 0;
- }
-
- h_errno = 0;
- errno = 0;
- hp = gethostbyname(nodename);
- if (hp == NULL)
- {
-#ifdef EAI_SYSTEM
- if (errno != 0) {
- return EAI_SYSTEM;
- }
-#endif
- switch (h_errno)
- {
- case HOST_NOT_FOUND: return EAI_NODATA;
- case NO_DATA: return EAI_NODATA;
-#if defined(NO_ADDRESS) && NO_ADDRESS != NO_DATA
- case NO_ADDRESS: return EAI_NODATA;
-#endif
- case NO_RECOVERY: return EAI_FAIL;
- case TRY_AGAIN: return EAI_AGAIN;
- default: return EAI_FAIL;
- }
- return EAI_FAIL;
- }
-
- /* Check that the address family is acceptable.
- */
- switch (hp->h_addrtype)
- {
- case AF_INET:
- if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET))
- return EAI_FAMILY;
- break;
-#if USE_IPV6
- case AF_INET6:
- if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET6))
- return EAI_FAMILY;
- break;
-#endif
- default:
- return EAI_FAMILY;
- }
-
- /* For each element pointed to by hp, create an element in the
- result linked list. */
- sai = eai = NULL;
- for (addrs = hp->h_addr_list; *addrs != NULL; addrs++)
- {
- struct sockaddr sa;
- size_t addrlen;
-
- if (hp->h_length < 1)
- continue;
- sa.sa_family = hp->h_addrtype;
- switch (hp->h_addrtype)
- {
- case AF_INET:
- ((struct sockaddr_in *) &sa)->sin_port = htons (port);
- memcpy (&((struct sockaddr_in *) &sa)->sin_addr,
- *addrs, hp->h_length);
- addrlen = sizeof (struct sockaddr_in);
- break;
-#if USE_IPV6
- case AF_INET6:
-#if SIN6_LEN
- ((struct sockaddr_in6 *) &sa)->sin6_len = hp->h_length;
-#endif
- ((struct sockaddr_in6 *) &sa)->sin6_port = htons (port);
- memcpy (&((struct sockaddr_in6 *) &sa)->sin6_addr,
- *addrs, hp->h_length);
- addrlen = sizeof (struct sockaddr_in6);
- break;
-#endif
- default:
- continue;
- }
-
- result.ai_family = hp->h_addrtype;
- ai = dup_addrinfo (&result, &sa, addrlen);
- if (ai == NULL)
- {
- xfreeaddrinfo (sai);
- return EAI_MEMORY;
- }
- if (sai == NULL)
- sai = ai;
- else
- eai->ai_next = ai;
- eai = ai;
- }
-
- if (sai == NULL)
- {
- return EAI_NODATA;
- }
-
- if (hints->ai_flags & AI_CANONNAME)
- {
- sai->ai_canonname = malloc (strlen (hp->h_name) + 1);
- if (sai->ai_canonname == NULL)
- {
- xfreeaddrinfo (sai);
- return EAI_MEMORY;
- }
- strcpy (sai->ai_canonname, hp->h_name);
- }
-
- *res = sai;
- return 0;
-}
-
-void
-xfreeaddrinfo (struct addrinfo *ai)
-{
- struct addrinfo *next;
-
- while (ai != NULL)
- {
- next = ai->ai_next;
- if (ai->ai_canonname != NULL)
- free (ai->ai_canonname);
- if (ai->ai_addr != NULL)
- free (ai->ai_addr);
- free (ai);
- ai = next;
- }
-}
-
-const char *
-xgai_strerror (int ecode)
-{
- static const char *eai_descr[] =
- {
- "no error",
- "address family for nodename not supported", /* EAI_ADDRFAMILY */
- "temporary failure in name resolution", /* EAI_AGAIN */
- "invalid value for ai_flags", /* EAI_BADFLAGS */
- "non-recoverable failure in name resolution", /* EAI_FAIL */
- "ai_family not supported", /* EAI_FAMILY */
- "memory allocation failure", /* EAI_MEMORY */
- "no address associated with nodename", /* EAI_NODATA */
- "nodename nor servname provided, or not known", /* EAI_NONAME */
- "servname not supported for ai_socktype", /* EAI_SERVICE */
- "ai_socktype not supported", /* EAI_SOCKTYPE */
- "system error returned in errno", /* EAI_SYSTEM */
- "argument buffer overflow", /* EAI_OVERFLOW */
- };
-
- if (ecode < 0 || ecode > (int) (sizeof eai_descr/ sizeof eai_descr[0]))
- return "unknown error";
- return eai_descr[ecode];
-}
-
-#endif /* HAVE_GETADDRINFO */
--- squid3/lib/getnameinfo.c Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,428 +0,0 @@
-/*
- * Shamelessly duplicated from the fetchmail public sources
- * for use by the Squid Project under GNU Public License.
- *
- * Update/Maintenance History:
- *
- * 16-Aug-2007 : Copied from fetchmail 6.3.8
- * - added protection around libray headers
- * - added use of alternative name xgetnameinfo
- * to split from any OS-provided.
- *
- * 06-Oct-2007 : Various fixes to allow the build on MinGW
- * - use srtncpy instead of strlcpy
- * - use xinet_ntop instead of inet_ntop
- * - use SQUIDHOSTNAMELEN instead of MAXHOSTNAMELEN
- *
- * Squid CVS $Id: getnameinfo.c,v 1.1.8.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * Original License and code follows.
- */
-#include "config.h"
-
-/* KAME: getnameinfo.c,v 1.72 2005/01/13 04:12:03 itojun Exp */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Issues to be discussed:
- * - RFC2553 says that we should raise error on short buffer. X/Open says
- * we need to truncate the result. We obey RFC2553 (and X/Open should be
- * modified). ipngwg rough consensus seems to follow RFC2553. RFC3493 says
- * nothing about it, but defines a new error code EAI_OVERFLOW which seems
- * to be intended the code for this case.
- * - What is "local" in NI_NOFQDN? (see comments in the code)
- * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
- * - (KAME extension) always attach textual scopeid (fe80::1%lo0), if
- * sin6_scope_id is filled - standardization status?
- * - what should we do if we should do getservbyport("sctp")?
- */
-
-/*
- * Considerations about thread-safeness
- * The code in this file is thread-safe, and so the thread-safeness of
- * getnameinfo() depends on the property of backend functions.
- * - getservbyport() is not thread safe for most systems we are targeting.
- * - getipnodebyaddr() is thread safe. However, many resolver libraries
- * used in the function are not thread safe.
- * - gethostbyaddr() is usually not thread safe.
- */
-
-#ifndef HAVE_GETNAMEINFO
-
-#if HAVE_SYS_TYPES_H
-#include
-#endif
-#if HAVE_STDIO_H
-#include
-#endif
-#if HAVE_SYS_SOCKET_H
-#include
-#endif
-#if HAVE_NET_IF_H
-#include
-#endif
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if HAVE_ARPA_INET_H
-#include
-#endif
-#if HAVE_ARPA_NAMESER_H
-#include
-#endif
-#if HAVE_NETDB_H
-#include
-#endif
-#if HAVE_RESOLV_H
-#include
-#endif
-#if HAVE_STRING_H
-#include
-#endif
-#if HAVE_STDDEF_H
-#include
-#endif
-#if HAVE_ERRNO_H
-#include
-#endif
-#if HAVE_INTTYPES_H
-#include
-#endif
-
-#ifdef _SQUID_MSWIN_
-#undef IN_ADDR
-#include
-#endif
-
-#include "getaddrinfo.h"
-
-#if !HAVE_INET_NTOP
-#include "inet_ntop.h"
-#endif
-
-static const struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
- int a_portoff;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr),
- offsetof(struct sockaddr_in6, sin6_port)},
-#endif
- {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr),
- offsetof(struct sockaddr_in, sin_port)},
- {0, 0, 0, 0, 0},
-};
-
-#ifdef INET6
-static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
- size_t, int));
-static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
-#endif
-
-int
-xgetnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- socklen_t salen;
- char *host;
- size_t hostlen;
- char *serv;
- size_t servlen;
- int flags;
-{
- const struct afd *afd;
- struct servent *sp;
- struct hostent *hp;
- u_short port;
- int family, i;
- const char *addr;
- u_int32_t v4a;
- int h_error;
- char numserv[512];
-
- if (sa == NULL)
- return EAI_FAIL;
-
-#ifdef HAVE_SA_LEN /*XXX*/
- if (sa->sa_len != salen)
- return EAI_FAIL;
-#endif
-
- family = sa->sa_family;
- for (i = 0; afdl[i].a_af; i++)
- if (afdl[i].a_af == family) {
- afd = &afdl[i];
- goto found;
- }
- return EAI_FAMILY;
-
- found:
- if (salen != afd->a_socklen)
- return EAI_FAIL;
-
- /* network byte order */
- memcpy(&port, (const char *)sa + afd->a_portoff, sizeof(port));
- addr = (const char *)sa + afd->a_off;
-
- if (serv == NULL || servlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC3493 says that serv == NULL OR servlen == 0
- * means that the caller does not want the result.
- */
- } else {
- if (flags & NI_NUMERICSERV)
- sp = NULL;
- else {
- sp = getservbyport(port,
- (flags & NI_DGRAM) ? "udp" : "tcp");
- }
- if (sp) {
- if (strlen(sp->s_name) + 1 > servlen)
- return EAI_OVERFLOW;
- strncpy(serv, sp->s_name, servlen);
- } else {
- snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
- if (strlen(numserv) + 1 > servlen)
- return EAI_OVERFLOW;
- strncpy(serv, numserv, servlen);
- }
- }
-
- switch (sa->sa_family) {
- case AF_INET:
- v4a = (u_int32_t)
- ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags |= NI_NUMERICHOST;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0)
- flags |= NI_NUMERICHOST;
- break;
-#ifdef INET6
- case AF_INET6:
- {
- const struct sockaddr_in6 *sin6;
- sin6 = (const struct sockaddr_in6 *)sa;
- switch (sin6->sin6_addr.s6_addr[0]) {
- case 0x00:
- if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- ;
- else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
- ;
- else
- flags |= NI_NUMERICHOST;
- break;
- default:
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- break;
- }
- }
- break;
-#endif
- }
- if (host == NULL || hostlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC3493 says that host == NULL or hostlen == 0
- * means that the caller does not want the result.
- */
- } else if (flags & NI_NUMERICHOST) {
- /* NUMERICHOST and NAMEREQD conflicts with each other */
- if (flags & NI_NAMEREQD)
- return EAI_NONAME;
-
- goto numeric;
- } else {
-#ifdef USE_GETIPNODEBY
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#ifdef HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif
-
- if (hp) {
-#if 0
- if (flags & NI_NOFQDN) {
- /*
- * According to RFC3493 section 6.2, NI_NOFQDN
- * means "node name portion of the FQDN shall
- * be returned for local hosts." The following
- * code tries to implement it by returning the
- * first label (the part before the first
- * period) of the FQDN. However, it is not
- * clear if this always makes sense, since the
- * given address may be outside of "local
- * hosts." Due to the unclear description, we
- * disable the code in this implementation.
- */
- char *p;
- p = strchr(hp->h_name, '.');
- if (p)
- *p = '\0';
- }
-#endif
- if (strlen(hp->h_name) + 1 > hostlen) {
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- return EAI_OVERFLOW;
- }
- strncpy(host, hp->h_name, hostlen);
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- } else {
- if (flags & NI_NAMEREQD)
- return EAI_NONAME;
-
- numeric:
- switch(afd->a_af) {
-#ifdef INET6
- case AF_INET6:
- {
- int error;
-
- if ((error = ip6_parsenumeric(sa, addr, host,
- hostlen,
- flags)) != 0)
- return(error);
- break;
- }
-#endif
- default:
- if (xinet_ntop(afd->a_af, addr, host,
- hostlen) == NULL)
- return EAI_SYSTEM;
- break;
- }
- }
- }
- return(0);
-}
-
-#ifdef INET6
-static int
-ip6_parsenumeric(sa, addr, host, hostlen, flags)
- const struct sockaddr *sa;
- const char *addr;
- char *host;
- size_t hostlen;
- int flags;
-{
- int numaddrlen;
- char numaddr[512];
-
- if (xinet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
- return EAI_SYSTEM;
-
- numaddrlen = strlen(numaddr);
- if (numaddrlen + 1 > hostlen) /* don't forget terminator */
- return EAI_OVERFLOW;
- strncpy(host, numaddr, hostlen);
-
- if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
- char zonebuf[SQUIDHOSTNAMELEN];
- int zonelen;
-
- zonelen = ip6_sa2str(
- (const struct sockaddr_in6 *)(const void *)sa,
- zonebuf, sizeof(zonebuf), flags);
- if (zonelen < 0)
- return EAI_OVERFLOW;
- if (zonelen + 1 + numaddrlen + 1 > hostlen)
- return EAI_OVERFLOW;
-
- /* construct */
- memcpy(host + numaddrlen + 1, zonebuf,
- (size_t)zonelen);
- host[numaddrlen] = SCOPE_DELIMITER;
- host[numaddrlen + 1 + zonelen] = '\0';
- }
-
- return 0;
-}
-
-/* ARGSUSED */
-static int
-ip6_sa2str(sa6, buf, bufsiz, flags)
- const struct sockaddr_in6 *sa6;
- char *buf;
- size_t bufsiz;
- int flags;
-{
- unsigned int ifindex;
- const struct in6_addr *a6;
- int n;
-
- ifindex = (unsigned int)sa6->sin6_scope_id;
- a6 = &sa6->sin6_addr;
-
-#ifdef NI_NUMERICSCOPE
- if ((flags & NI_NUMERICSCOPE) != 0) {
- n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
- if (n < 0 || n >= bufsiz)
- return -1;
- else
- return n;
- }
-#endif
-
- /* if_indextoname() does not take buffer size. not a good api... */
- if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||
- IN6_IS_ADDR_MC_NODELOCAL(a6)) && bufsiz >= IF_NAMESIZE) {
- char *p = if_indextoname(ifindex, buf);
- if (p)
- return (strlen(p));
- }
-
- /* last resort */
- n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
- if (n < 0 || n >= bufsiz)
- return -1;
- else
- return n;
-}
-#endif /* INET6 */
-#endif
--- squid3/lib/inet_ntop.c Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,256 +0,0 @@
-/*
- * Shamelessly duplicated from the bind9 public sources
- * for use by the Squid Project under ISC written permission
- * included "as found" below.
- *
- * Update/Maintenance History:
- *
- * 24-Sep-2007 : Copied from bind 9.3.3
- * - Added protection around libray headers
- * - Altered configure checks
- * - Un-hacked slightly to use system gethostbyname()
- *
- * 06-Oct-2007 : Various fixes to allow the build on MinGW
- *
- * 28-Oct-2007: drop some dead code. now tested working without.
- *
- * Squid CVS $Id: inet_ntop.c,v 1.1.8.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * Original License and code follows.
- */
-
-#include "config.h"
-
-#ifndef HAVE_INET_NTOP
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "inet_ntop.c,v 1.1.2.1.8.2 2005/11/03 23:08:40 marka Exp";
-#endif /* LIBC_SCCS and not lint */
-
-#if HAVE_SYS_PARAM_H
-#include
-#endif
-#if HAVE_SYS_TYPES_H
-#include
-#endif
-#if HAVE_SYS_SOCKET_H
-#include
-#endif
-
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if HAVE_ARPA_INET_H
-#include
-#endif
-#if HAVE_ARPA_NAMESER_H
-#include
-#endif
-
-#if HAVE_ERRNO_H
-#include
-#endif
-#if HAVE_STDIO_H
-#include
-#endif
-#if HAVE_STRING_H
-#include
-#endif
-
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
-#if ! defined(NS_INADDRSZ)
-#define NS_INADDRSZ 4
-#endif
-#if ! defined(NS_IN6ADDRSZ)
-#define NS_IN6ADDRSZ 16
-#endif
-#if ! defined(NS_INT16SZ)
-#define NS_INT16SZ 2
-#endif
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4 (const u_char *src, char *dst, size_t size);
-static const char *inet_ntop6 (const u_char *src, char *dst, size_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
- * return:
- * pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- * Paul Vixie, 1996.
- */
-const char *
-xinet_ntop(af, src, dst, size)
- int af;
- const void *src;
- char *dst;
- size_t size;
-{
- switch (af) {
- case AF_INET:
- return (inet_ntop4(src, dst, size));
- case AF_INET6:
- return (inet_ntop6(src, dst, size));
- default:
- errno = EAFNOSUPPORT;
- return (NULL);
- }
- /* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- * format an IPv4 address
- * return:
- * `dst' (as a const)
- * notes:
- * (1) uses no statics
- * (2) takes a u_char* not an in_addr as input
- * author:
- * Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(src, dst, size)
- const u_char *src;
- char *dst;
- size_t size;
-{
- static const char fmt[] = "%u.%u.%u.%u";
- char tmp[sizeof "255.255.255.255"];
-
- if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) {
- errno = ENOSPC;
- return (NULL);
- }
- strcpy(dst, tmp);
- return (dst);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- * convert IPv6 binary address into presentation (printable) format
- * author:
- * Paul Vixie, 1996.
- */
-static const char *
-inet_ntop6(src, dst, size)
- const u_char *src;
- char *dst;
- size_t size;
-{
- /*
- * Note that int32_t and int16_t need only be "at least" large enough
- * to contain a value of the specified size. On some systems, like
- * Crays, there is no such thing as an integer variable with 16 bits.
- * Keep this in mind if you think this function should have been coded
- * to use pointer overlays. All the world's not a VAX.
- */
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
- struct { int base, len; } best, cur;
- u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
- int i;
-
- /*
- * Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
- */
- memset(words, '\0', sizeof words);
- for (i = 0; i < NS_IN6ADDRSZ; i++)
- words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
- best.base = -1;
- best.len = 0;
- cur.base = -1;
- cur.len = 0;
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
- if (words[i] == 0) {
- if (cur.base == -1)
- cur.base = i, cur.len = 1;
- else
- cur.len++;
- } else {
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
- }
- }
- }
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- }
- if (best.base != -1 && best.len < 2)
- best.base = -1;
-
- /*
- * Format the result.
- */
- tp = tmp;
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
- /* Are we inside the best run of 0x00's? */
- if (best.base != -1 && i >= best.base &&
- i < (best.base + best.len)) {
- if (i == best.base)
- *tp++ = ':';
- continue;
- }
- /* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
- *tp++ = ':';
- /* Is this address an encapsulated IPv4? */
- if (i == 6 && best.base == 0 && (best.len == 6 ||
- (best.len == 7 && words[7] != 0x0001) ||
- (best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
- tp += strlen(tp);
- break;
- }
- tp += SPRINTF((tp, "%x", words[i]));
- }
- /* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) ==
- (NS_IN6ADDRSZ / NS_INT16SZ))
- *tp++ = ':';
- *tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
- if ((size_t)(tp - tmp) > size) {
- errno = ENOSPC;
- return (NULL);
- }
- strcpy(dst, tmp);
- return (dst);
-}
-
-#endif /* HAVE_INET_NTOP */
--- squid3/lib/inet_pton.c Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,271 +0,0 @@
-/*
- * Shamelessly duplicated from the bind9 public sources
- * for use by the Squid Project under ISC written permission
- * included "as found" below.
- *
- * Update/Maintenance History:
- *
- * 24-Sep-2007 : Copied from bind 9.3.3
- * - Added protection around libray headers
- * - Altered configure checks to import
- *
- * 06-Oct-2007 : Various fixes to allow the build on MinGW
- *
- * 28-Oct-2007: drop some dead code. now tested working without.
- *
- * Squid CVS $Id: inet_pton.c,v 1.1.8.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * Original License and code follows.
- */
-
-#include "config.h"
-
-#ifndef HAVE_INET_PTON
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "inet_pton.c,v 1.2.206.2 2005/07/28 07:43:18 marka Exp";
-#endif /* LIBC_SCCS and not lint */
-
-#if HAVE_SYS_PARAM_H
-#include
-#endif
-#if HAVE_SYS_TYPES_H
-#include
-#endif
-#if HAVE_SYS_SOCKET_H
-#include
-#endif
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if ARPA_INET_H
-#include
-#endif
-#if HAVE_ARPA_NAMESER_H
-#include
-#endif
-#if HAVE_STRING_H
-#include
-#endif
-#if HAVE_ERRNO_H
-#include
-#endif
-
-#if ! defined(NS_INADDRSZ)
-#define NS_INADDRSZ 4
-#endif
-#if ! defined(NS_IN6ADDRSZ)
-#define NS_IN6ADDRSZ 16
-#endif
-#if ! defined(NS_INT16SZ)
-#define NS_INT16SZ 2
-#endif
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static int inet_pton4 (const char *src, u_char *dst);
-static int inet_pton6 (const char *src, u_char *dst);
-
-/* int
- * inet_pton(af, src, dst)
- * convert from presentation format (which usually means ASCII printable)
- * to network format (which is usually some kind of binary format).
- * return:
- * 1 if the address was valid for the specified address family
- * 0 if the address wasn't valid (`dst' is untouched in this case)
- * -1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- * Paul Vixie, 1996.
- */
-int
-xinet_pton(af, src, dst)
- int af;
- const char *src;
- void *dst;
-{
- switch (af) {
- case AF_INET:
- return (inet_pton4(src, dst));
- case AF_INET6:
- return (inet_pton6(src, dst));
- default:
- errno = EAFNOSUPPORT;
- return (-1);
- }
- /* NOTREACHED */
-}
-
-/* int
- * inet_pton4(src, dst)
- * like inet_aton() but without all the hexadecimal and shorthand.
- * return:
- * 1 if `src' is a valid dotted quad, else 0.
- * notice:
- * does not touch `dst' unless it's returning 1.
- * author:
- * Paul Vixie, 1996.
- */
-static int
-inet_pton4(src, dst)
- const char *src;
- u_char *dst;
-{
- static const char digits[] = "0123456789";
- int saw_digit, octets, ch;
- u_char tmp[NS_INADDRSZ], *tp;
-
- saw_digit = 0;
- octets = 0;
- *(tp = tmp) = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr(digits, ch)) != NULL) {
- u_int new = *tp * 10 + (pch - digits);
-
- if (saw_digit && *tp == 0)
- return (0);
- if (new > 255)
- return (0);
- *tp = new;
- if (!saw_digit) {
- if (++octets > 4)
- return (0);
- saw_digit = 1;
- }
- } else if (ch == '.' && saw_digit) {
- if (octets == 4)
- return (0);
- *++tp = 0;
- saw_digit = 0;
- } else
- return (0);
- }
- if (octets < 4)
- return (0);
- memcpy(dst, tmp, NS_INADDRSZ);
- return (1);
-}
-
-/* int
- * inet_pton6(src, dst)
- * convert presentation level address to network order binary form.
- * return:
- * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- * (1) does not touch `dst' unless it's returning 1.
- * (2) :: in a full address is silently ignored.
- * credit:
- * inspired by Mark Andrews.
- * author:
- * Paul Vixie, 1996.
- */
-static int
-inet_pton6(src, dst)
- const char *src;
- u_char *dst;
-{
- static const char xdigits_l[] = "0123456789abcdef",
- xdigits_u[] = "0123456789ABCDEF";
- u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
- const char *xdigits, *curtok;
- int ch, seen_xdigits;
- u_int val;
-
- memset((tp = tmp), '\0', NS_IN6ADDRSZ);
- endp = tp + NS_IN6ADDRSZ;
- colonp = NULL;
- /* Leading :: requires some special handling. */
- if (*src == ':')
- if (*++src != ':')
- return (0);
- curtok = src;
- seen_xdigits = 0;
- val = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
- pch = strchr((xdigits = xdigits_u), ch);
- if (pch != NULL) {
- val <<= 4;
- val |= (pch - xdigits);
- if (++seen_xdigits > 4)
- return (0);
- continue;
- }
- if (ch == ':') {
- curtok = src;
- if (!seen_xdigits) {
- if (colonp)
- return (0);
- colonp = tp;
- continue;
- } else if (*src == '\0') {
- return (0);
- }
- if (tp + NS_INT16SZ > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
- seen_xdigits = 0;
- val = 0;
- continue;
- }
- if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
- inet_pton4(curtok, tp) > 0) {
- tp += NS_INADDRSZ;
- seen_xdigits = 0;
- break; /* '\0' was seen by inet_pton4(). */
- }
- return (0);
- }
- if (seen_xdigits) {
- if (tp + NS_INT16SZ > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
- }
- if (colonp != NULL) {
- /*
- * Since some memmove()'s erroneously fail to handle
- * overlapping regions, we'll do the shift by hand.
- */
- const int n = tp - colonp;
- int i;
-
- if (tp == endp)
- return (0);
- for (i = 1; i <= n; i++) {
- endp[- i] = colonp[n - i];
- colonp[n - i] = 0;
- }
- tp = endp;
- }
- if (tp != endp)
- return (0);
- memcpy(dst, tmp, NS_IN6ADDRSZ);
- return (1);
-}
-
-#endif /* HAVE_INET_PTON */
Index: squid3/lib/rfc1035.c
===================================================================
RCS file: /cvsroot/squid-sf//squid3/lib/rfc1035.c,v
retrieving revision 1.15.6.2
retrieving revision 1.15.6.3
diff -u -r1.15.6.2 -r1.15.6.3
--- squid3/lib/rfc1035.c 25 Jan 2008 02:33:36 -0000 1.15.6.2
+++ squid3/lib/rfc1035.c 27 Jan 2008 18:08:44 -0000 1.15.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: rfc1035.c,v 1.15.6.2 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: rfc1035.c,v 1.15.6.3 2008/01/27 18:08:44 rousskov Exp $
*
* Low level DNS protocol routines
* AUTHOR: Duane Wessels
@@ -402,9 +402,7 @@
}
RR->rdlength = rdlength;
switch (RR->type) {
-#if DNS_CNAME
case RFC1035_TYPE_CNAME:
-#endif
case RFC1035_TYPE_PTR:
RR->rdata = (char*)xmalloc(RFC1035_MAXHOSTNAMESZ);
rdata_off = *off;
@@ -473,19 +471,17 @@
}
}
-void
-rfc1035RRDestroy(rfc1035_rr ** rr, int n)
+static void
+rfc1035RRDestroy(rfc1035_rr * rr, int n)
{
- if (*rr == NULL || n < 1) {
+ if (rr == NULL)
return;
- }
-
+ assert(n > 0);
while (n--) {
- if ((*rr)[n].rdata)
- xfree((*rr)[n].rdata);
+ if (rr[n].rdata)
+ xfree(rr[n].rdata);
}
- xfree(*rr);
- *rr = NULL;
+ xfree(rr);
}
/*
@@ -521,16 +517,15 @@
}
void
-rfc1035MessageDestroy(rfc1035_message ** msg)
+rfc1035MessageDestroy(rfc1035_message * msg)
{
- if (!*msg)
+ if (!msg)
return;
- if ((*msg)->query)
- xfree((*msg)->query);
- if ((*msg)->answer)
- rfc1035RRDestroy(&(*msg)->answer, (*msg)->ancount);
- xfree(*msg);
- *msg = NULL;
+ if (msg->query)
+ xfree(msg->query);
+ if (msg->answer)
+ rfc1035RRDestroy(msg->answer, msg->ancount);
+ xfree(msg);
}
/*
@@ -607,7 +602,7 @@
if (rfc1035QueryUnpack(buf, sz, &off, &querys[j])) {
RFC1035_UNPACK_DEBUG;
rfc1035SetErrno(rfc1035_unpack_error);
- rfc1035MessageDestroy(&msg);
+ rfc1035MessageDestroy(msg);
return -rfc1035_unpack_error;
}
}
@@ -620,7 +615,7 @@
if (msg->ancount == 0)
return 0;
i = (unsigned int) msg->ancount;
- recs = msg->answer = (rfc1035_rr*)xcalloc(i, sizeof(*recs));
+ recs = msg->answer = xcalloc(i, sizeof(*recs));
for (j = 0; j < i; j++) {
if (off >= sz) { /* corrupt packet */
RFC1035_UNPACK_DEBUG;
@@ -637,7 +632,7 @@
* we expected to unpack some answers (ancount != 0), but
* didn't actually get any.
*/
- rfc1035MessageDestroy(&msg);
+ rfc1035MessageDestroy(msg);
*answer = NULL;
rfc1035SetErrno(rfc1035_unpack_error);
return -rfc1035_unpack_error;
@@ -771,7 +766,7 @@
strtok(input, "\r\n");
memset(buf, '\0', 512);
sz = 512;
- if (inet_pton(AF_INET, input, &junk)) {
+ if (inet_aton(input, &junk)) {
sid = rfc1035BuildPTRQuery(junk, buf, &sz);
} else {
sid = rfc1035BuildAQuery(input, buf, &sz);
@@ -809,7 +804,7 @@
printf("%d answers\n", n);
for (i = 0; i < n; i++) {
if (answers[i].type == RFC1035_TYPE_A) {
- struct in_addr a;
+ struct IN_ADDR a;
memcpy(&a, answers[i].rdata, 4);
printf("A\t%d\t%s\n", answers[i].ttl, inet_ntoa(a));
} else if (answers[i].type == RFC1035_TYPE_PTR) {
Index: squid3/lib/rfc2617.c
===================================================================
RCS file: /cvsroot/squid-sf//squid3/lib/rfc2617.c,v
retrieving revision 1.5.30.2
retrieving revision 1.5.30.3
diff -u -r1.5.30.2 -r1.5.30.3
--- squid3/lib/rfc2617.c 25 Jan 2008 02:33:36 -0000 1.5.30.2
+++ squid3/lib/rfc2617.c 27 Jan 2008 18:08:44 -0000 1.5.30.3
@@ -13,7 +13,7 @@
/*
- * $Id: rfc2617.c,v 1.5.30.2 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: rfc2617.c,v 1.5.30.3 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG:
* AUTHOR: RFC 2617 & Robert Collins
@@ -94,7 +94,7 @@
else
Bin[i / 2] |= n;
}
- for (i = i / 2; i < HASHLEN; i++) {
+ for (; i <= HASHHEXLEN; i++) {
Bin[i] = '\0';
}
}
--- squid3/lib/rfc3596.c Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,375 +0,0 @@
-
-/*
- * $Id: rfc3596.c,v 1.1.32.1 2008/01/25 02:33:36 valexey_eykon Exp $
- *
- * Low level DNS protocol routines
- * AUTHOR: Amos Jeffries, Rafael Martinez Torres
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This code is copyright (C) 2007 by Treehouse Networks Ltd of
- * New Zealand. It is published and Lisenced as an extension of
- * squid under the same conditions as the main squid application.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-/*
- * KNOWN BUGS:
- *
- * UDP replies with TC set should be retried via TCP
- */
-
-/**
- * April 2007
- *
- * Provides RFC3596 functions to handle purely IPv6 DNS.
- * Adds AAAA and IPv6 PTR records.
- * Other IPv6 records are not mentioned by this RFC.
- *
- * IPv4 equivalents are taken care of by the RFC1035 library.
- * Where one protocol lookup must be followed by another, the caller
- * is resposible for the order and handling of the lookups.
- *
- */
-
-#include "config.h"
-#include "util.h"
-
-#if HAVE_STDIO_H
-#include
-#endif
-#if HAVE_UNISTD_H
-#include
-#endif
-#if HAVE_STDLIB_H
-#include
-#endif
-#if HAVE_MEMORY_H
-#include
-#endif
-#if HAVE_SYS_TYPES_H
-#include
-#endif
-#if HAVE_ASSERT_H
-#include
-#endif
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if HAVE_STRINGS_H
-#include
-#endif
-
-#include "rfc3596.h"
-
-#ifndef SQUID_RFC1035_H
-#error RFC3596 Library depends on RFC1035
-#endif
-
-/**
- * Builds a message buffer with a QUESTION to lookup records
- * for a hostname. Caller must allocate 'buf' which should
- * probably be at least 512 octets. The 'szp' initially
- * specifies the size of the buffer, on return it contains
- * the size of the message (i.e. how much to write).
- * Returns the size of the query
- */
-ssize_t
-rfc3596BuildHostQuery(const char *hostname, char *buf, size_t sz, unsigned short qid, rfc1035_query * query, int qtype)
-{
- static rfc1035_message h;
- size_t offset = 0;
- memset(&h, '\0', sizeof(h));
- h.id = qid;
- h.qr = 0;
- h.rd = 1;
- h.opcode = 0; /* QUERY */
- h.qdcount = (unsigned int) 1;
- offset += rfc1035HeaderPack(buf + offset, sz - offset, &h);
- offset += rfc1035QuestionPack(buf + offset,
- sz - offset,
- hostname,
- qtype,
- RFC1035_CLASS_IN);
-
- if (query) {
- query->qtype = qtype;
- query->qclass = RFC1035_CLASS_IN;
- xstrncpy(query->name, hostname, sizeof(query->name));
- }
-
- assert(offset <= sz);
- return offset;
-}
-
-/**
- * Builds a message buffer with a QUESTION to lookup A records
- * for a hostname. Caller must allocate 'buf' which should
- * probably be at least 512 octets. The 'szp' initially
- * specifies the size of the buffer, on return it contains
- * the size of the message (i.e. how much to write).
- * \return the size of the query
- */
-ssize_t
-rfc3596BuildAQuery(const char *hostname, char *buf, size_t sz, unsigned short qid, rfc1035_query * query)
-{
- return rfc3596BuildHostQuery(hostname, buf, sz, qid, query, RFC1035_TYPE_A);
-}
-
-/**
- * Builds a message buffer with a QUESTION to lookup AAAA records
- * for a hostname. Caller must allocate 'buf' which should
- * probably be at least 512 octets. The 'szp' initially
- * specifies the size of the buffer, on return it contains
- * the size of the message (i.e. how much to write).
- * \return the size of the query
- */
-ssize_t
-rfc3596BuildAAAAQuery(const char *hostname, char *buf, size_t sz, unsigned short qid, rfc1035_query * query)
-{
- return rfc3596BuildHostQuery(hostname, buf, sz, qid, query, RFC1035_TYPE_AAAA);
-}
-
-
-/**
- * Builds a message buffer with a QUESTION to lookup PTR records
- * for an address. Caller must allocate 'buf' which should
- * probably be at least 512 octets. The 'szp' initially
- * specifies the size of the buffer, on return it contains
- * the size of the message (i.e. how much to write).
- * \return the size of the query
- */
-ssize_t
-
-rfc3596BuildPTRQuery4(const struct in_addr addr, char *buf, size_t sz, unsigned short qid, rfc1035_query * query)
-{
- static char rev[RFC1035_MAXHOSTNAMESZ];
- unsigned int i;
-
- i = (unsigned int) ntohl(addr.s_addr);
- snprintf(rev, RFC1035_MAXHOSTNAMESZ, "%u.%u.%u.%u.in-addr.arpa.",
- i & 255,
- (i >> 8) & 255,
- (i >> 16) & 255,
- (i >> 24) & 255);
-
- return rfc3596BuildHostQuery(rev, buf, sz, qid, query, RFC1035_TYPE_PTR);
-}
-
-ssize_t
-
-rfc3596BuildPTRQuery6(const struct in6_addr addr, char *buf, size_t sz, unsigned short qid, rfc1035_query * query)
-{
- static char rev[RFC1035_MAXHOSTNAMESZ];
- const uint8_t* r = addr.s6_addr;
- char* p = rev;
- int i; // NP: MUST allow signed for loop termination.
-
- /* work from the raw addr field. anything else may have representation changes. */
- /* The sin6_port and sin6_addr members shall be in network byte order. */
- for(i = 15; i >= 0; i--, p+=4)
- {
- snprintf(p, 5, "%1x.%1x.", ((r[i]>>4)&0xf), (r[i])&0xf );
- }
-
- snprintf(p,10,"ip6.arpa.");
-
- return rfc3596BuildHostQuery(rev, buf, sz, qid, query, RFC1035_TYPE_PTR);
-}
-
-
-#if DRIVER
-
-/* driver needs the rfc1035 code _without_ the main() */
-# define main(a,b) rfc1035_main(a,b)
-# include "rfc1035.c"
-# undef main(a,b)
-
-#include
-#include
-
-int
-main(int argc, char *argv[])
-{
- char input[512];
- char buf[512];
- char rbuf[512];
- size_t sz = 512;
- unsigned short sid, sidb;
- int s;
- int rl;
-
- struct sockaddr* S;
- int var = 1;
-
- if ( argc < 3 || argc > 4) {
- fprintf(stderr, "usage: %s [-6|-4] ip port\n", argv[0]);
- return 1;
- }
-
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
- if(argv[var][0] == '-') {
- if(argv[var][1] == '4')
- prefer = AF_INET;
- else if(argv[var][1] == '6')
- prefer = AF_INET6;
- else {
- fprintf(stderr, "usage: %s [-6|-4] ip port\n", argv[0]);
- return 1;
- }
-
- var++;
- }
-
- s = socket(PF_INET, SOCK_DGRAM, 0);
-
- if (s < 0) {
- perror("socket");
- return 1;
- }
-
-
- memset(&S, '\0', sizeof(S));
-
- if(prefer == 6) {
- S = (struct sockaddr *) new sockaddr_in6;
- memset(S,0,sizeof(struct sockaddr_in6));
-
- ((struct sockaddr_in6 *)S)->sin6_family = AF_INET6;
- ((struct sockaddr_in6 *)S)->sin6_port = htons(atoi(argv[var+1]));
-
- if( ! xinet_pton(AF_INET6, argv[var], &((struct sockaddr_in6 *)S)->sin6_addr.s_addr) )
- perror("listen address");
- return 1;
- }
-
- s = socket(PF_INET6, SOCK_DGRAM, 0);
- } else {
- S = (struct sockaddr *) new sockaddr_in;
- memset(S,0,sizeof(struct sockaddr_in));
-
- ((struct sockaddr_in *)S)->sin_family = AF_INET;
- ((struct sockaddr_in *)S)->sin_port = htons(atoi(argv[var+1]));
-
- if( ! xinet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) )
- perror("listen address");
- return 1;
- }
- }
-
- while (fgets(input, 512, stdin)) {
-
- struct in6_addr junk6;
-
- struct in_addr junk4;
- strtok(input, "\r\n");
- memset(buf, '\0', 512);
- sz = 512;
-
- if (xinet_pton(AF_INET6, input, &junk6)) {
- sid = rfc1035BuildPTRQuery6(junk6, buf, &sz);
- sidb=0;
- } else if (xinet_pton(AF_INET, input, &junk4)) {
- sid = rfc1035BuildPTRQuery4(junk4, buf, &sz);
- sidb=0;
- } else {
- sid = rfc1035BuildAAAAQuery(input, buf, &sz);
- sidb = rfc1035BuildAQuery(input, buf, &sz);
- }
-
- sendto(s, buf, sz, 0, S, sizeof(*S));
-
- do {
- fd_set R;
-
- struct timeval to;
- FD_ZERO(&R);
- FD_SET(s, &R);
- to.tv_sec = 10;
- to.tv_usec = 0;
- rl = select(s + 1, &R, NULL, NULL, &to);
- } while (0);
-
- if (rl < 1) {
- printf("TIMEOUT\n");
- continue;
- }
-
- memset(rbuf, '\0', 512);
- rl = recv(s, rbuf, 512, 0);
- {
- unsigned short rid = 0;
- int i;
- int n;
- rfc1035_rr *answers = NULL;
- n = rfc1035AnswersUnpack(rbuf,
- rl,
- &answers,
- &rid);
-
- if (n < 0) {
- printf("ERROR %d\n", rfc1035_errno);
- } else if (rid != sid && rid != sidb) {
- printf("ERROR, ID mismatch (%#hx, %#hx)\n", sid, rid);
- printf("ERROR, ID mismatch (%#hx, %#hx)\n", sidb, rid);
- } else {
- printf("%d answers\n", n);
-
- for (i = 0; i < n; i++) {
- if (answers[i].type == RFC1035_TYPE_A) {
-
- struct in_addr a;
- memcpy(&a, answers[i].rdata, 4);
- printf("A\t%d\t%s\n", answers[i].ttl, inet_ntoa(a));
- } else if (answers[i].type == RFC1035_TYPE_AAAA) {
-
- struct in6_addr a;
- memcpy(&a, answers[i].rdata, 16);
- printf("AAAA\t%d\t%s\n", answers[i].ttl, inet_ntoa(a));
- } else if (answers[i].type == RFC1035_TYPE_PTR) {
- char ptr[RFC1035_MAXHOSTNAMESZ];
- strncpy(ptr, answers[i].rdata, answers[i].rdlength);
- printf("PTR\t%d\t%s\n", answers[i].ttl, ptr);
- } else if (answers[i].type == RFC1035_TYPE_CNAME) {
- char ptr[RFC1035_MAXHOSTNAMESZ];
- strncpy(ptr, answers[i].rdata, answers[i].rdlength);
- printf("CNAME\t%d\t%s\n", answers[i].ttl, ptr);
- } else {
- fprintf(stderr, "can't print answer type %d\n",
- (int) answers[i].type);
- }
- }
- }
- }
- }
-
- return 0;
-}
-
-#endif
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/lib/safe_inet_addr.c Wed Feb 6 01:24:19 2008
@@ -0,0 +1,65 @@
+
+/*
+ * $Id: safe_inet_addr.c,v 1.4.40.3 2008/01/27 18:08:44 rousskov Exp $
+ */
+
+#include "config.h"
+#include "util.h"
+
+#if HAVE_STDIO_H
+#include
+#endif
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_UNISTD_H
+#include
+#endif
+#if HAVE_SYS_TYPES_H
+#include
+#endif
+#if HAVE_SYS_SOCKET_H
+#include
+#endif
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_ARPA_INET_H
+#include
+#endif
+
+
+int
+safe_inet_addr(const char *buf, struct IN_ADDR *addr)
+{
+ static char addrbuf[32];
+ int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
+ struct IN_ADDR A;
+ char x;
+#if defined(_SQUID_HPUX_)
+ /*
+ * MIYOSHI Tsutomu says scanning 'buf'
+ * causes a bus error on hppa1.1-hp-hpux9.07, so we
+ * have a broad hack for all HP systems.
+ */
+ static char buftmp[32];
+ snprintf(buftmp, 32, "%s", buf);
+ if (sscanf(buftmp, "%d.%d.%d.%d%c", &a1, &a2, &a3, &a4, &x) != 4)
+#else
+ if (sscanf(buf, "%d.%d.%d.%d%c", &a1, &a2, &a3, &a4, &x) != 4)
+#endif
+ return 0;
+ if (a1 < 0 || a1 > 255)
+ return 0;
+ if (a2 < 0 || a2 > 255)
+ return 0;
+ if (a3 < 0 || a3 > 255)
+ return 0;
+ if (a4 < 0 || a4 > 255)
+ return 0;
+ snprintf(addrbuf, 32, "%d.%d.%d.%d", a1, a2, a3, a4);
+ A.s_addr = inet_addr(addrbuf);
+ if (addr)
+ addr->s_addr = A.s_addr;
+ return 1;
+}
--- squid3/lib/tests/testIPAddress.cc Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,674 +0,0 @@
-#include
-
-#include
-#include
-#include
-#include
-
-#include "config.h"
-#include "testIPAddress.h"
-#include "IPAddress.h"
-
-CPPUNIT_TEST_SUITE_REGISTRATION( testIPAddress );
-
-
-void
-testIPAddress::testDefaults()
-{
- IPAddress anIPA;
-
- /* test stored values */
- CPPUNIT_ASSERT( anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
-#if USE_IPV6
- CPPUNIT_ASSERT( anIPA.IsIPv6() );
-#else
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-#endif
-}
-
-void
-testIPAddress::testInAddrConstructor()
-{
- struct in_addr inval;
- struct in_addr outval;
-
- inval.s_addr = htonl(0xC0A8640C);
- outval.s_addr = htonl(0x00000000);
-
- IPAddress anIPA(inval);
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp(&inval, &outval, sizeof(struct in_addr)) == 0 );
-}
-
-#if USE_IPV6
-void
-testIPAddress::testInAddr6Constructor()
-{
- struct in6_addr inval;
- struct in6_addr outval = IN6ADDR_ANY_INIT;
-
- inval.s6_addr32[0] = htonl(0xC0A8640C);
- inval.s6_addr32[1] = htonl(0xFFFFFFFF);
- inval.s6_addr32[2] = htonl(0xFFFFFFFF);
- inval.s6_addr32[3] = htonl(0xFFFFFFFF);
-
- IPAddress anIPA(inval);
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( !anIPA.IsIPv4() );
- CPPUNIT_ASSERT( anIPA.IsIPv6() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &inval, &outval, sizeof(struct in6_addr)) == 0 );
-}
-#endif
-
-void
-testIPAddress::testSockAddrConstructor()
-{
- struct sockaddr_in insock;
- struct sockaddr_in outsock;
-
- memset(&insock, 0, sizeof(struct sockaddr_in));
- memset(&outsock, 0, sizeof(struct sockaddr_in));
-
- insock.sin_family = AF_INET;
- insock.sin_port = htons(80);
- insock.sin_addr.s_addr = htonl(0xC0A8640C);
-
- IPAddress anIPA((const struct sockaddr_in)insock);
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT( anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 80 , anIPA.GetPort() );
- anIPA.GetSockAddr(outsock);
- CPPUNIT_ASSERT( memcmp( &insock, &outsock, sizeof(struct sockaddr_in)) == 0 );
-}
-
-#if USE_IPV6
-void
-testIPAddress::testSockAddr6Constructor()
-{
- struct sockaddr_in6 insock;
- struct sockaddr_in6 outsock;
-
- memset(&insock, 0, sizeof(struct sockaddr_in6));
- memset(&outsock, 0, sizeof(struct sockaddr_in6));
-
- insock.sin6_family = AF_INET6;
- insock.sin6_port = htons(80);
- insock.sin6_addr.s6_addr32[0] = htonl(0xFFFFFFFF);
- insock.sin6_addr.s6_addr32[1] = htonl(0x00000000);
- insock.sin6_addr.s6_addr32[2] = htonl(0x0000FFFF);
- insock.sin6_addr.s6_addr32[3] = htonl(0xC0A8640C);
-
- IPAddress anIPA((const struct sockaddr_in6)insock);
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( !anIPA.IsIPv4() );
- CPPUNIT_ASSERT( anIPA.IsIPv6() );
- CPPUNIT_ASSERT( anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 80 , anIPA.GetPort() );
- anIPA.GetSockAddr(outsock);
- CPPUNIT_ASSERT( memcmp( &insock, &outsock, sizeof(struct sockaddr_in6)) == 0 );
-}
-#endif
-
-
-void
-testIPAddress::testCopyConstructor()
-{
- struct sockaddr_in insock;
- struct sockaddr_in outsock;
-
- memset(&insock, 0, sizeof(struct sockaddr_in));
- memset(&outsock, 0, sizeof(struct sockaddr_in));
-
- insock.sin_family = AF_INET;
- insock.sin_port = htons(80);
- insock.sin_addr.s_addr = htonl(0xC0A8640C);
-
- IPAddress inIPA(insock);
- IPAddress outIPA(inIPA);
-
-
- /* test stored values */
- CPPUNIT_ASSERT( !outIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !outIPA.IsNoAddr() );
- CPPUNIT_ASSERT( outIPA.IsIPv4() );
- CPPUNIT_ASSERT( !outIPA.IsIPv6() );
- CPPUNIT_ASSERT( outIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 80 , outIPA.GetPort() );
- outIPA.GetSockAddr(outsock);
- CPPUNIT_ASSERT( memcmp( &insock, &outsock, sizeof(struct sockaddr_in)) == 0 );
-}
-
-void
-testIPAddress::testHostentConstructor()
-{
- struct hostent *hp = NULL;
- struct in_addr outval;
- struct in_addr expectval;
-
- expectval.s_addr = htonl(0xC0A8640C);
-
- hp = gethostbyname("192.168.100.12");
- CPPUNIT_ASSERT( hp != NULL /* gethostbyname failure.*/ );
-
- IPAddress anIPA(*hp);
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
-}
-
-void
-testIPAddress::testStringConstructor()
-{
- struct in_addr outval;
- struct in_addr expectval;
-
- expectval.s_addr = htonl(0xC0A8640C);
-
- IPAddress anIPA = "192.168.100.12";
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
-
-#if USE_IPV6
- struct in6_addr expectv6;
- struct in6_addr outval6;
-
- expectv6.s6_addr32[0] = htonl(0x20000800);
- expectv6.s6_addr32[1] = htonl(0x00000000);
- expectv6.s6_addr32[2] = htonl(0x00000000);
- expectv6.s6_addr32[3] = htonl(0x00000045);
-
- IPAddress bnIPA = "2000:800::45";
-
- /* test stored values */
- CPPUNIT_ASSERT( !bnIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !bnIPA.IsNoAddr() );
- CPPUNIT_ASSERT( !bnIPA.IsIPv4() );
- CPPUNIT_ASSERT( bnIPA.IsIPv6() );
- CPPUNIT_ASSERT( !bnIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , bnIPA.GetPort() );
- bnIPA.GetInAddr(outval6);
- CPPUNIT_ASSERT( memcmp( &expectv6, &outval6, sizeof(struct in6_addr)) == 0 );
-
- /* test IPv6 as an old netmask format. This is invalid but sometimes use. */
- IPAddress cnIPA = "ffff:ffff:fff0::";
-
- expectv6.s6_addr32[0] = htonl(0xFFFFFFFF);
- expectv6.s6_addr32[1] = htonl(0xFFF00000);
- expectv6.s6_addr32[2] = htonl(0x00000000);
- expectv6.s6_addr32[3] = htonl(0x00000000);
-
- /* test stored values */
- CPPUNIT_ASSERT( !cnIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !cnIPA.IsNoAddr() );
- CPPUNIT_ASSERT( !cnIPA.IsIPv4() );
- CPPUNIT_ASSERT( cnIPA.IsIPv6() );
- CPPUNIT_ASSERT( !cnIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , cnIPA.GetPort() );
- cnIPA.GetInAddr(outval6);
- CPPUNIT_ASSERT( memcmp( &expectv6, &outval6, sizeof(struct in6_addr)) == 0 );
-#endif
-}
-
-void
-testIPAddress::testSetEmpty()
-{
- IPAddress anIPA;
- struct in_addr inval;
-
- inval.s_addr = htonl(0xC0A8640C);
-
- anIPA = inval;
-
- /* test stored values before empty */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
-
- anIPA.SetEmpty();
-
- /* test stored values after empty */
- CPPUNIT_ASSERT( anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
-#if USE_IPV6
- CPPUNIT_ASSERT( anIPA.IsIPv6() );
-#else
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-#endif
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
-}
-
-void
-testIPAddress::testBooleans()
-{
- IPAddress lhsIPA;
- IPAddress rhsIPA;
- struct in_addr valLow;
- struct in_addr valHigh;
-
- valLow.s_addr = htonl(0xC0A8640C);
- valHigh.s_addr = htonl(0xC0A8640F);
-
- /* test equality */
- lhsIPA = valLow;
- rhsIPA = valLow;
- CPPUNIT_ASSERT( lhsIPA.matchIPAddr(rhsIPA) == 0 );
- CPPUNIT_ASSERT( ( lhsIPA == rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA != rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
-
- /* test inequality (less than) */
- lhsIPA = valLow;
- rhsIPA = valHigh;
- CPPUNIT_ASSERT( lhsIPA.matchIPAddr(rhsIPA) < 0 );
- CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA >= rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA < rhsIPA ) );
-
- /* test inequality (greater than) */
- lhsIPA = valHigh;
- rhsIPA = valLow;
- CPPUNIT_ASSERT( lhsIPA.matchIPAddr(rhsIPA) > 0 );
- CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
- CPPUNIT_ASSERT( ( lhsIPA > rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA <= rhsIPA ) );
- CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
-
-}
-
-void
-testIPAddress::testNtoA()
-{
- struct in_addr inval;
- char buf[MAX_IPSTRLEN];
- IPAddress anIPA;
-
- anIPA.SetAnyAddr();
-
- /* test AnyAddr display values */
-#if USE_IPV6
- CPPUNIT_ASSERT( memcmp("::", anIPA.NtoA(buf,MAX_IPSTRLEN), 2) == 0 );
-#else
- CPPUNIT_ASSERT( memcmp("0.0.0.0",anIPA.NtoA(buf,MAX_IPSTRLEN), 7) == 0 );
-#endif
-
- inval.s_addr = htonl(0xC0A8640C);
- anIPA = inval;
-
- /* test IP display */
- CPPUNIT_ASSERT( memcmp("192.168.100.12",anIPA.NtoA(buf,MAX_IPSTRLEN), 14) == 0 );
-
- anIPA.SetNoAddr();
-
- /* test NoAddr display values */
-#if USE_IPV6
- CPPUNIT_ASSERT( memcmp("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",anIPA.NtoA(buf,MAX_IPSTRLEN), 39) == 0 );
-#else
- CPPUNIT_ASSERT( memcmp("255.255.255.255",anIPA.NtoA(buf,MAX_IPSTRLEN), 15) == 0 );
-#endif
-}
-
-void
-testIPAddress::testToURL_fromInAddr()
-{
- char buf[MAX_IPSTRLEN]; buf[0] = '\0';
- struct in_addr inval;
-
- inval.s_addr = htonl(0xC0A8640C);
-
- IPAddress anIPA(inval);
-
- /* test values */
- anIPA.ToURL(buf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( memcmp("192.168.100.12", buf, 14) == 0 );
-
-#if USE_IPV6
-
- /* test output when constructed from in6_addr with IPv6 */
- struct in6_addr ip6val;
-
- ip6val.s6_addr32[0] = htonl(0xC0A8640C);
- ip6val.s6_addr32[1] = htonl(0xFFFFFFFF);
- ip6val.s6_addr32[2] = htonl(0xFFFFFFFF);
- ip6val.s6_addr32[3] = htonl(0xFFFFFFFF);
-
- IPAddress bnIPA(ip6val);
-
- bnIPA.ToURL(buf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( memcmp("[c0a8:640c:ffff:ffff:ffff:ffff:ffff:ffff]", buf, 41) == 0 );
-
-#endif
-}
-
-void
-testIPAddress::testToURL_fromSockAddr()
-{
- struct sockaddr_in sock;
- sock.sin_addr.s_addr = htonl(0xC0A8640C);
- sock.sin_port = htons(80);
- sock.sin_family = AF_INET;
- IPAddress anIPA(sock);
- char buf[MAX_IPSTRLEN];
-
- /* test values */
- anIPA.ToURL(buf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( memcmp("192.168.100.12:80", buf, 17) == 0 );
-
-#if USE_IPV6
-
- /* test output when constructed from in6_addr with IPv6 */
- struct sockaddr_in6 ip6val;
-
- ip6val.sin6_addr.s6_addr32[0] = htonl(0xC0A8640C);
- ip6val.sin6_addr.s6_addr32[1] = htonl(0xFFFFFFFF);
- ip6val.sin6_addr.s6_addr32[2] = htonl(0xFFFFFFFF);
- ip6val.sin6_addr.s6_addr32[3] = htonl(0xFFFFFFFF);
- ip6val.sin6_port = htons(80);
- ip6val.sin6_family = AF_INET6;
-
- IPAddress bnIPA(ip6val);
-
- bnIPA.ToURL(buf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( memcmp("[c0a8:640c:ffff:ffff:ffff:ffff:ffff:ffff]:80", buf, 44) == 0 );
-
-#endif
-
-}
-
-void
-testIPAddress::testGetReverseString()
-{
- char buf[MAX_IPSTRLEN];
-
- struct in_addr ipv4val;
- ipv4val.s_addr = htonl(0xC0A8640C);
-
- IPAddress v4IPA(ipv4val);
-
- /* test IPv4 output */
- v4IPA.GetReverseString(buf);
- CPPUNIT_ASSERT( memcmp("12.100.168.192.in-addr.arpa.",buf, 28) == 0 );
-
- v4IPA.GetReverseString(buf,AF_INET);
- CPPUNIT_ASSERT( memcmp("12.100.168.192.in-addr.arpa.",buf, 28) == 0 );
-
- v4IPA.GetReverseString(buf,AF_INET6);
- CPPUNIT_ASSERT( memcmp("",buf, 1) == 0 );
-
-
-#if USE_IPV6
- struct in6_addr ip6val;
-
- ip6val.s6_addr32[0] = htonl(0xC0A8640C);
- ip6val.s6_addr32[1] = htonl(0xFFFFFFFF);
- ip6val.s6_addr32[2] = htonl(0xFFFFFFFF);
- ip6val.s6_addr32[3] = htonl(0xFFFFFFFF);
-
- IPAddress v6IPA(ip6val);
-
- /* test IPv6 output */
- v6IPA.GetReverseString(buf);
- CPPUNIT_ASSERT( memcmp("f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.c.0.4.6.8.a.0.c.ip6.arpa.",buf,73) == 0 );
-
-#endif
-
-}
-
-void
-testIPAddress::testMasking()
-{
- char buf[MAX_IPSTRLEN];
- IPAddress anIPA;
- IPAddress maskIPA;
-
- /* Test Basic CIDR Routine */
- anIPA.SetAnyAddr();
- CPPUNIT_ASSERT_EQUAL( 0 ,anIPA.GetCIDR() );
-
- anIPA.SetNoAddr();
-#if USE_IPV6
- CPPUNIT_ASSERT_EQUAL( 128 , anIPA.GetCIDR() );
-#else
- CPPUNIT_ASSERT_EQUAL( 32 , anIPA.GetCIDR() );
-#endif
-
- /* Test Numeric ApplyCIDR */
- anIPA.SetNoAddr();
- CPPUNIT_ASSERT( !anIPA.ApplyMask(129) );
-#if !USE_IPV6
- CPPUNIT_ASSERT( !anIPA.ApplyMask(33) );
-#endif
- CPPUNIT_ASSERT( anIPA.ApplyMask(31) );
- CPPUNIT_ASSERT_EQUAL( 31 , anIPA.GetCIDR() );
-
- anIPA.SetNoAddr();
- anIPA.ApplyMask(31, AF_INET);
-#if USE_IPV6
- CPPUNIT_ASSERT_EQUAL( 127 , anIPA.GetCIDR() );
-#else
- CPPUNIT_ASSERT_EQUAL( 31 , anIPA.GetCIDR() );
-#endif
-
-#if USE_IPV6
- anIPA.SetNoAddr();
- anIPA.ApplyMask(80,AF_INET6);
- CPPUNIT_ASSERT_EQUAL( 80 , anIPA.GetCIDR() );
- /* BUG Check: test values by display. */
- CPPUNIT_ASSERT( anIPA.NtoA(buf,MAX_IPSTRLEN) != NULL );
- CPPUNIT_ASSERT( memcmp("ffff:ffff:ffff:ffff:ffff::", buf, 26) == 0 );
-#endif
-
- /* Test Network Bitmask from IPAddress */
- anIPA.SetNoAddr();
- maskIPA = "255.255.240.0";
- CPPUNIT_ASSERT_EQUAL( 20 , maskIPA.GetCIDR() );
- anIPA.ApplyMask(maskIPA);
- CPPUNIT_ASSERT_EQUAL( 20 , anIPA.GetCIDR() );
-
- /* BUG Check: test values memory after masking. */
- struct in_addr btest;
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- anIPA.GetInAddr(btest);
- CPPUNIT_ASSERT_EQUAL( (uint32_t)htonl(0xFFFFF000) , btest.s_addr );
-
- /* BUG Check failing test. Masked values for display. */
- CPPUNIT_ASSERT( memcmp("255.255.240.0",anIPA.NtoA(buf,MAX_IPSTRLEN), 13) == 0 );
-
-
-#if USE_IPV6
- anIPA.SetNoAddr();
- maskIPA.SetNoAddr();
-
- /* IPv6 masks MUST be CIDR representations. */
- /* however as with IPv4 they can technically be represented as a bitmask */
- maskIPA = "ffff:ffff:fff0::";
- CPPUNIT_ASSERT( !maskIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !maskIPA.IsNoAddr() );
- anIPA.ApplyMask(maskIPA);
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT_EQUAL( 44 , anIPA.GetCIDR() );
-
- anIPA.SetNoAddr();
- maskIPA.SetNoAddr();
-
- /* IPv4 masks represented in IPv6 as IPv4 bitmasks. */
- maskIPA = "::ffff:ffff:f000";
- CPPUNIT_ASSERT( !maskIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !maskIPA.IsNoAddr() );
- CPPUNIT_ASSERT( maskIPA.IsIPv4() );
- CPPUNIT_ASSERT( !maskIPA.IsIPv6() );
- anIPA.ApplyMask(maskIPA);
- CPPUNIT_ASSERT( !maskIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !maskIPA.IsNoAddr() );
- CPPUNIT_ASSERT( maskIPA.IsIPv4() );
- CPPUNIT_ASSERT( !maskIPA.IsIPv6() );
- CPPUNIT_ASSERT_EQUAL( 20 , anIPA.GetCIDR() );
-#endif
-
-}
-
-void
-testIPAddress::testAddrInfo()
-{
- struct addrinfo *expect;
- struct addrinfo *ipval = NULL;
- struct addrinfo hints;
-
- memset(&hints, 0, sizeof(struct addrinfo));
-
- hints.ai_flags = AI_NUMERICHOST;
-
- IPAddress anIP = "127.0.0.1";
-
- /* assert this just to check that getaddrinfo is working properly */
- CPPUNIT_ASSERT( xgetaddrinfo("127.0.0.1", NULL, &hints, &expect ) == 0 );
-
- anIP.GetAddrInfo(ipval);
-
- /* display a byte-by-byte hex comparison of the addr cores */
- unsigned int *p;
- p = (unsigned int*)expect;
- printf("\nADDRINFO: %x %x %x %x %x %x ",
- p[0],p[1],p[2],p[3],p[4],p[5] );
-
- p = (unsigned int*)ipval;
- printf("\nADDRINFO: %x %x %x %x %x %x ",
- p[0],p[1],p[2],p[3],p[4],p[5] );
- printf("\n");
-
- // check the addrinfo object core. (BUT not the two ptrs at the tail)
- CPPUNIT_ASSERT( memcmp( expect, ipval, sizeof(struct addrinfo)-(sizeof(void*)*3) ) == 0 );
- // check the sockaddr it points to.
- CPPUNIT_ASSERT_EQUAL( expect->ai_addrlen, ipval->ai_addrlen );
- CPPUNIT_ASSERT( memcmp( expect, ipval, expect->ai_addrlen ) == 0 );
-
- xfreeaddrinfo(expect);
-}
-
-void
-testIPAddress::testBugNullingDisplay()
-{
- // Weird Bug: address set to empty during string conversion somewhere.
- // initial string gets created and returned OK.
- // but at the end of the process m_SocketAddr is left NULL'ed
-
- char ntoabuf[MAX_IPSTRLEN];
- char hostbuf[MAX_IPSTRLEN];
- char urlbuf[MAX_IPSTRLEN];
-
- struct in_addr outval;
- struct in_addr expectval;
-
- expectval.s_addr = htonl(0xC0A8640C);
-
- IPAddress anIPA = "192.168.100.12";
-
-
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
-
-
- /* POKE NtoA display function to see what it is doing */
- anIPA.NtoA(ntoabuf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
-
-
-
- /* POKE ToHostname display function to see what it is doing */
- anIPA.ToHostname(hostbuf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
-
-
- /* POKE ToURL display function to see what it is doing */
- anIPA.ToURL(urlbuf,MAX_IPSTRLEN);
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- /* test stored values */
- CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
- CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
- CPPUNIT_ASSERT( anIPA.IsIPv4() );
- CPPUNIT_ASSERT( !anIPA.IsIPv6() );
- CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
- CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
- anIPA.GetInAddr(outval);
- CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
-
-}
--- squid3/lib/tests/testIPAddress.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,70 +0,0 @@
-#ifndef SQUID_SRC_TEST_IPADDRESS_H
-#define SQUID_SRC_TEST_IPADDRESS_H
-
-#include
-
-/*
- * test the IP storage type
- */
-
-class testIPAddress : public CPPUNIT_NS::TestFixture
-{
- CPPUNIT_TEST_SUITE( testIPAddress );
- CPPUNIT_TEST( testDefaults );
- CPPUNIT_TEST( testInAddrConstructor );
-#if USE_IPV6
- CPPUNIT_TEST( testInAddr6Constructor );
-#endif
- CPPUNIT_TEST( testSockAddrConstructor );
-#if USE_IPV6
- CPPUNIT_TEST( testSockAddr6Constructor );
-#endif
- CPPUNIT_TEST( testHostentConstructor );
- CPPUNIT_TEST( testStringConstructor );
- CPPUNIT_TEST( testCopyConstructor );
- CPPUNIT_TEST( testSetEmpty );
- CPPUNIT_TEST( testBooleans );
- CPPUNIT_TEST( testAddrInfo );
- CPPUNIT_TEST( testNtoA );
- CPPUNIT_TEST( testToURL_fromInAddr );
- CPPUNIT_TEST( testToURL_fromSockAddr );
- CPPUNIT_TEST( testGetReverseString );
- CPPUNIT_TEST( testMasking );
-
- CPPUNIT_TEST( testBugNullingDisplay );
- CPPUNIT_TEST_SUITE_END();
-
-public:
-
-protected:
- void testDefaults();
-
- void testInAddrConstructor();
-#if USE_IPV6
- void testInAddr6Constructor();
-#endif
- void testSockAddrConstructor();
-#if USE_IPV6
- void testSockAddr6Constructor();
-#endif
- void testHostentConstructor();
- void testStringConstructor();
- void testCopyConstructor();
-
- void testSetEmpty();
- void testBooleans();
-
- void testAddrInfo();
-
- void testNtoA();
- void testToURL_fromInAddr();
- void testToURL_fromSockAddr();
- void testGetReverseString();
- void testMasking();
-
- // bugs.
- void testBugNullingDisplay();
-
-};
-
-#endif /* SQUID_SRC_TEST_IPADDRESS_H */
--- squid3/lib/tests/testRFC1035.cc Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,110 +0,0 @@
-#include "config.h"
-
-#if HAVE_ASSERT_H
-#include
-#endif
-
-#include "testRFC1035.h"
-
-/* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */
-#include "rfc1035.c"
-
-CPPUNIT_TEST_SUITE_REGISTRATION( testRFC1035 );
-
-// TODO Test each function in the Library independently
-// Just because we can for global functions.
-// It's good for the code too.
-
-void testRFC1035::testHeaderUnpack()
-{
- /* Setup a buffer with the known-content packet */
- const char *buf = "\x76\xb1\x81\x80\x00\x01\x00\x01\x00\x02\x00\x02\x03\x77\x77\x77\x07\x67\x61\x6d\x65\x64\x65\x76\x03\x6e\x65\x74\x00\x00\x01\x00\x01\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\xef\x00\x04\xd8\xb9\x60\xea\xc0\x10\x00\x02\x00\x01\x00\x00\x00\xef\x00\x0f\x03\x6e\x73\x32\x05\x7a\x77\x61\x76\x65\x03\x63\x6f\x6d\x00\xc0\x10\x00\x02\x00\x01\x00\x00\x00\xef\x00\x06\x03\x6e\x73\x31\xc0\x41\xc0\x3d\x00\x01\x00\x01\x00\x00\x29\x6b\x00\x04\xd8\xea\xee\x4a\xc0\x58\x00\x01\x00\x01\x00\x00\x29\x6b\x00\x04\xd8\xea\xee\x4b";
- size_t len = 126;
- rfc1035_message *msg = NULL;
- int res = 0;
- unsigned int off = 0;
-
- /* Test the HeaderUnpack function */
- msg = new rfc1035_message;
- res = rfc1035HeaderUnpack(buf, len, &off, msg);
- CPPUNIT_ASSERT(res == 0);
- CPPUNIT_ASSERT_EQUAL((short unsigned int)0x76b1, msg->id);
- CPPUNIT_ASSERT(msg->qr == 1);
- /* flags */
- CPPUNIT_ASSERT_EQUAL((unsigned int)0, msg->opcode);
- CPPUNIT_ASSERT_EQUAL((unsigned int)0, msg->aa);
- CPPUNIT_ASSERT_EQUAL((unsigned int)0, msg->tc);
- CPPUNIT_ASSERT_EQUAL((unsigned int)1, msg->rd);
- CPPUNIT_ASSERT_EQUAL((unsigned int)1, msg->ra);
- CPPUNIT_ASSERT_EQUAL((unsigned int)0, msg->rcode);
- /* RR counts */
- CPPUNIT_ASSERT_EQUAL((unsigned short)1, msg->qdcount);
- CPPUNIT_ASSERT_EQUAL((unsigned short)1, msg->ancount);
- CPPUNIT_ASSERT_EQUAL((unsigned short)2, msg->nscount);
- CPPUNIT_ASSERT_EQUAL((unsigned short)2, msg->arcount);
-
- /* cleanup */
- delete msg; msg = NULL;
-}
-
-void testRFC1035::testParseAPacket()
-{
- /* Setup a buffer with the known-content packet */
- const char *buf = "\x76\xb1\x81\x80\x00\x01\x00\x01\x00\x02\x00\x02\x03\x77\x77\x77\x07\x67\x61\x6d\x65\x64\x65\x76\x03\x6e\x65\x74\x00\x00\x01\x00\x01\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\xef\x00\x04\xd8\xb9\x60\xea\xc0\x10\x00\x02\x00\x01\x00\x00\x00\xef\x00\x0f\x03\x6e\x73\x32\x05\x7a\x77\x61\x76\x65\x03\x63\x6f\x6d\x00\xc0\x10\x00\x02\x00\x01\x00\x00\x00\xef\x00\x06\x03\x6e\x73\x31\xc0\x41\xc0\x3d\x00\x01\x00\x01\x00\x00\x29\x6b\x00\x04\xd8\xea\xee\x4a\xc0\x58\x00\x01\x00\x01\x00\x00\x29\x6b\x00\x04\xd8\xea\xee\x4b";
- size_t len = 126;
- rfc1035_message *msg = NULL;
- int res = 0;
-
- /* Test the MessageUnpack function itself */
- res = rfc1035MessageUnpack(buf, len, &msg);
-
- CPPUNIT_ASSERT_EQUAL(1, res);
- CPPUNIT_ASSERT(msg != NULL);
- /* cleanup */
- rfc1035MessageDestroy(&msg);
- CPPUNIT_ASSERT(msg == NULL);
-}
-
-void testRFC1035::testBugPacketEndingOnCompressionPtr()
-{
- /* Setup a buffer with the known-to-fail packet */
- const char *buf = "\xec\x7b\x81\x80\x00\x01\x00\x01\x00\x00\x00\x00\x05\x62\x75\x72\x73\x74\x02\x74\x65\x06\x74\x61\x63\x6f\x64\x61\x03\x6e\x65\x74\x00\x00\x1c\x00\x01\xc0\x0c\x00\x05\x00\x01\x00\x00\x19\xe5\x00\x0a\x02\x74\x65\x04\x67\x73\x6c\x62\xc0\x15";
- size_t len = 59;
- rfc1035_message *msg = NULL;
- int res = 0;
- unsigned int off = 0;
-
-
- /* Test the HeaderUnpack function results */
- msg = new rfc1035_message;
- res = rfc1035HeaderUnpack(buf, len, &off, msg);
- CPPUNIT_ASSERT(0 == res);
- CPPUNIT_ASSERT(0xec7b == msg->id);
- CPPUNIT_ASSERT(1 == msg->qr);
- /* flags */
- CPPUNIT_ASSERT(0 == msg->opcode);
- CPPUNIT_ASSERT(0 == msg->aa);
- CPPUNIT_ASSERT(0 == msg->tc);
- CPPUNIT_ASSERT(1 == msg->rd);
- CPPUNIT_ASSERT(1 == msg->ra);
- CPPUNIT_ASSERT(0 == msg->rcode);
- /* RR counts */
- CPPUNIT_ASSERT(1 == msg->qdcount);
- CPPUNIT_ASSERT(1 == msg->ancount);
- CPPUNIT_ASSERT(0 == msg->nscount);
- CPPUNIT_ASSERT(0 == msg->arcount);
- CPPUNIT_ASSERT(12 == off);
- printf("\n Header : OK");
- /* cleanup */
- delete msg; msg = NULL;
-
-// TODO explicitly test RR and Name unpack functions for this packet.
-
- /* Test the MessageUnpack function itself */
- res = rfc1035MessageUnpack(buf, len, &msg);
-
- CPPUNIT_ASSERT_EQUAL((const char*)NULL, rfc1035_error_message);
- CPPUNIT_ASSERT_EQUAL(1, res);
- CPPUNIT_ASSERT(msg != NULL);
- rfc1035MessageDestroy(&msg);
-}
--- squid3/lib/tests/testRFC1035.h Wed Feb 6 01:24:19 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,29 +0,0 @@
-#ifndef SQUID_SRC_TEST_RFC1035_H
-#define SQUID_SRC_TEST_RFC1035_H
-
-#include
-
-/*
- * test the DNS resolver RFC 1035 Engine
- */
-
-class testRFC1035 : public CPPUNIT_NS::TestFixture
-{
- CPPUNIT_TEST_SUITE( testRFC1035 );
- CPPUNIT_TEST( testHeaderUnpack );
- CPPUNIT_TEST( testParseAPacket );
-
- CPPUNIT_TEST( testBugPacketEndingOnCompressionPtr );
- CPPUNIT_TEST_SUITE_END();
-
-public:
-
-protected:
- void testHeaderUnpack();
- void testParseAPacket();
-
- // bugs.
- void testBugPacketEndingOnCompressionPtr();
-};
-
-#endif /* SQUID_SRC_TEST_IPADDRESS_H */
Index: squid3/src/ACLARP.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLARP.cc,v
retrieving revision 1.19.22.1
retrieving revision 1.19.22.2
diff -u -r1.19.22.1 -r1.19.22.2
--- squid3/src/ACLARP.cc 25 Jan 2008 02:33:36 -0000 1.19.22.1
+++ squid3/src/ACLARP.cc 27 Jan 2008 18:08:44 -0000 1.19.22.2
@@ -1,6 +1,5 @@
-
/*
- * $Id: ACLARP.cc,v 1.19.22.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: ACLARP.cc,v 1.19.22.2 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -40,14 +39,13 @@
#include
#endif
#include "squid.h"
-#include "IPAddress.h"
#ifdef _SQUID_WIN32_
struct arpreq
{
- IPAddress arp_pa; /* protocol address */
+ struct sockaddr arp_pa; /* protocol address */
struct sockaddr arp_ha; /* hardware address */
int arp_flags; /* flags */
@@ -85,7 +83,7 @@
#endif
static void aclParseArpList(SplayNode **curlist);
static int decode_eth(const char *asc, char *eth);
-static int aclMatchArp(SplayNode **dataptr, IPAddress &c);
+static int aclMatchArp(SplayNode **dataptr, struct IN_ADDR c);
static SplayNode::SPLAYCMP aclArpCompare;
static SplayNode::SPLAYWALKEE aclDumpArpListWalkee;
@@ -226,13 +224,6 @@
int
ACLARP::match(ACLChecklist *checklist)
{
- /* IPv6 does not do ARP */
- if(!checklist->src_addr.IsIPv4())
- {
- debugs(14, 3, "ACLARP::match: IPv4 Required for ARP Lookups. Skipping " << checklist->src_addr );
- return 0;
- }
-
return aclMatchArp(&data, checklist->src_addr);
}
@@ -240,21 +231,20 @@
/* aclMatchArp */
/***************/
int
-aclMatchArp(SplayNode **dataptr, IPAddress &c)
+aclMatchArp(SplayNode **dataptr, struct IN_ADDR c)
{
+#if defined(_SQUID_LINUX_)
+
struct arpreq arpReq;
- IPAddress ipAddr = c;
-
-#if defined(_SQUID_LINUX_)
+ struct sockaddr_in ipAddr;
unsigned char ifbuffer[sizeof(struct ifreq) * 64];
+
struct ifconf ifc;
- struct sockaddr_in *sa = NULL;
struct ifreq *ifr;
int offset;
-
SplayNode **Top = dataptr;
/*
* The linux kernel 2.2 maintains per interface ARP caches and
@@ -267,14 +257,15 @@
* name first. If that does not succeed, the try each interface
* in turn
*/
-
/*
* Set up structures for ARP lookup with blank interface name
*/
+ ipAddr.sin_family = AF_INET;
+ ipAddr.sin_port = 0;
+ ipAddr.sin_addr = c;
memset(&arpReq, '\0', sizeof(arpReq));
- sa = (sockaddr_in*)&arpReq.arp_pa;
- ipAddr.GetSockAddr(*sa);
+ xmemcpy(&arpReq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
/* Query ARP table */
if (ioctl(HttpSockets[0], SIOCGARP, &arpReq) != -1) {
@@ -296,7 +287,7 @@
acl_arp_data X;
memcpy (X.eth, arpReq.arp_ha.sa_data, 6);
*Top = (*Top)->splay(&X, aclArpCompare);
- debugs(28, 3, "aclMatchArp: '" << c << "' " << (splayLastResult ? "NOT found" : "found"));
+ debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found"));
return (0 == splayLastResult);
}
@@ -330,14 +321,18 @@
if (NULL != strchr(ifr->ifr_name, ':'))
continue;
- debugs(28, 4, "Looking up ARP address for " << c << " on " << ifr->ifr_name);
+ debugs(28, 4, "Looking up ARP address for " << inet_ntoa(c) << " on " << ifr->ifr_name);
/* Set up structures for ARP lookup */
+ ipAddr.sin_family = AF_INET;
+
+ ipAddr.sin_port = 0;
+
+ ipAddr.sin_addr = c;
memset(&arpReq, '\0', sizeof(arpReq));
- sa = (sockaddr_in*)&arpReq.arp_pa;
- ipAddr.GetSockAddr(*sa);
+ xmemcpy(&arpReq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
strncpy(arpReq.arp_dev, ifr->ifr_name, sizeof(arpReq.arp_dev) - 1);
@@ -382,7 +377,7 @@
/* Return if match, otherwise continue to other interfaces */
if (0 == splayLastResult) {
- debugs(28, 3, "aclMatchArp: " << c << " found on " << ifr->ifr_name);
+ debugs(28, 3, "aclMatchArp: " << inet_ntoa(c) << " found on " << ifr->ifr_name);
return 1;
}
@@ -394,15 +389,24 @@
#elif defined(_SQUID_SOLARIS_)
+ struct arpreq arpReq;
+
+ struct sockaddr_in ipAddr;
+
SplayNode **Top = dataptr;
/*
* Set up structures for ARP lookup with blank interface name
*/
+ ipAddr.sin_family = AF_INET;
+
+ ipAddr.sin_port = 0;
+
+ ipAddr.sin_addr = c;
memset(&arpReq, '\0', sizeof(arpReq));
- ipAddr.GetSockAddr(arpReq.arp_pa);
+ xmemcpy(&arpReq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
/* Query ARP table */
if (ioctl(HttpSockets[0], SIOCGARP, &arpReq) != -1) {
@@ -429,13 +433,17 @@
/* Do lookup */
*Top = (*Top)->splay((acl_arp_data *)&arpReq.arp_ha.sa_data, aclArpCompare);
- debugs(28, 3, "aclMatchArp: '" << c << "' " << (splayLastResult ? "NOT found" : "found"));
+ debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found"));
return (0 == splayLastResult);
}
#elif defined(_SQUID_FREEBSD_) || defined(_SQUID_NETBSD_) || defined(_SQUID_OPENBSD_)
+ struct arpreq arpReq;
+
+ struct sockaddr_in ipAddr;
+
SplayNode **Top = dataptr;
int mib[6];
@@ -453,10 +461,15 @@
/*
* Set up structures for ARP lookup with blank interface name
*/
+ ipAddr.sin_family = AF_INET;
+
+ ipAddr.sin_port = 0;
+
+ ipAddr.sin_addr = c;
memset(&arpReq, '\0', sizeof(arpReq));
- ipAddr.GetSockAddr(arpReq.arp_pa);
+ xmemcpy(&arpReq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
/* Query ARP table */
mib[0] = CTL_NET;
@@ -501,7 +514,7 @@
sdl = (struct sockaddr_dl *)((char *) sin + ROUNDUP(sin->sin_len));
- if (c == sin->sin_addr) {
+ if (c.s_addr == sin->sin_addr.s_addr) {
if (sdl->sdl_alen) {
arpReq.arp_ha.sa_len = sizeof(struct sockaddr);
@@ -529,7 +542,7 @@
/* Do lookup */
*Top = (*Top)->splay((acl_arp_data *)&arpReq.arp_ha.sa_data, aclArpCompare);
- debugs(28, 3, "aclMatchArp: '" << c << "' " << (splayLastResult ? "NOT found" : "found"));
+ debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found"));
return (0 == splayLastResult);
@@ -545,6 +558,8 @@
SplayNode **Top = dataptr;
+ struct arpreq arpReq;
+
memset(&arpReq, '\0', sizeof(arpReq));
/* Get size of Windows ARP table */
@@ -568,9 +583,7 @@
/* Find MAC address from net table */
for (i = 0 ; i < NetTable->dwNumEntries ; i++) {
- in_addr a;
- a.s_addr = NetTable->table[i].dwAddr;
- if (c == a && (NetTable->table[i].dwType > 2)) {
+ if ((c.s_addr == NetTable->table[i].dwAddr) && (NetTable->table[i].dwType > 2)) {
arpReq.arp_ha.sa_family = AF_UNSPEC;
memcpy(arpReq.arp_ha.sa_data, NetTable->table[i].bPhysAddr, NetTable->table[i].dwPhysAddrLen);
}
@@ -594,7 +607,7 @@
/* Do lookup */
*Top = (*Top)->splay((acl_arp_data *)&arpReq.arp_ha.sa_data, aclArpCompare);
- debugs(28, 3, "aclMatchArp: '" << c << "' " << (splayLastResult ? "NOT found" : "found"));
+ debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found"));
return (0 == splayLastResult);
@@ -606,7 +619,7 @@
/*
* Address was not found on any interface
*/
- debugs(28, 3, "aclMatchArp: " << c << " NOT found");
+ debugs(28, 3, "aclMatchArp: " << inet_ntoa(c) << " NOT found");
return 0;
}
Index: squid3/src/ACLASN.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLASN.h,v
retrieving revision 1.8.34.1
retrieving revision 1.8.34.2
diff -u -r1.8.34.1 -r1.8.34.2
--- squid3/src/ACLASN.h 25 Jan 2008 02:33:36 -0000 1.8.34.1
+++ squid3/src/ACLASN.h 27 Jan 2008 18:08:44 -0000 1.8.34.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLASN.h,v 1.8.34.1 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: ACLASN.h,v 1.8.34.2 2008/01/27 18:08:44 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -39,18 +39,17 @@
#include "List.h"
#include "ACLStrategised.h"
#include "ACLChecklist.h"
-#include "IPAddress.h"
/* forward decls */
class CacheManager;
-SQUIDCEXTERN int asnMatchIp(List *, IPAddress &);
+SQUIDCEXTERN int asnMatchIp(List *, struct IN_ADDR);
SQUIDCEXTERN void asnInit(void);
extern void asnRegisterWithCacheManager(CacheManager & manager);
SQUIDCEXTERN void asnFreeMemory(void);
-class ACLASN : public ACLData
+class ACLASN : public ACLData
{
public:
@@ -58,18 +57,18 @@
virtual ~ACLASN();
- virtual bool match(IPAddress);
+ virtual bool match(struct IN_ADDR);
virtual wordlist *dump();
virtual void parse();
bool empty() const;
- virtual ACLData *clone() const;
+ virtual ACLData *clone() const;
virtual void prepareForUse();
private:
static ACL::Prototype SourceRegistryProtoype;
- static ACLStrategised SourceRegistryEntry_;
+ static ACLStrategised SourceRegistryEntry_;
static ACL::Prototype DestinationRegistryProtoype;
- static ACLStrategised DestinationRegistryEntry_;
+ static ACLStrategised DestinationRegistryEntry_;
List *data;
};
Index: squid3/src/ACLCertificate.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLCertificate.cc,v
retrieving revision 1.2.48.2
retrieving revision 1.2.48.3
diff -u -r1.2.48.2 -r1.2.48.3
--- squid3/src/ACLCertificate.cc 25 Jan 2008 02:33:36 -0000 1.2.48.2
+++ squid3/src/ACLCertificate.cc 27 Jan 2008 18:08:44 -0000 1.2.48.3
@@ -1,5 +1,5 @@
/*
- * $Id: ACLCertificate.cc,v 1.2.48.2 2008/01/25 02:33:36 valexey_eykon Exp $
+ * $Id: ACLCertificate.cc,v 1.2.48.3 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -35,12 +35,6 @@
*/
#include "squid.h"
-
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the SSL code from compile process when not needed.
- */
-#if USE_SSL
-
#include "ACLCertificate.h"
#include "ACLChecklist.h"
#include "ACLCertificateData.h"
@@ -55,7 +49,9 @@
int
ACLCertificateStrategy::match (ACLData * &data, ACLChecklist *checklist)
{
- SSL *ssl = fd_table[checklist->conn()->fd].ssl;
+ const int fd = checklist->fd();
+ const bool goodDescriptor = 0 <= fd && fd <= Biggest_FD;
+ SSL *ssl = goodDescriptor ? fd_table[fd].ssl : 0;
return data->match (ssl);
}
@@ -66,5 +62,3 @@
}
ACLCertificateStrategy ACLCertificateStrategy::Instance_;
-
-#endif /* USE_SSL */
Index: squid3/src/ACLChecklist.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLChecklist.cc,v
retrieving revision 1.39.6.2
retrieving revision 1.39.6.3
diff -u -r1.39.6.2 -r1.39.6.3
--- squid3/src/ACLChecklist.cc 25 Jan 2008 02:33:37 -0000 1.39.6.2
+++ squid3/src/ACLChecklist.cc 27 Jan 2008 18:08:44 -0000 1.39.6.3
@@ -1,5 +1,5 @@
/*
- * $Id: ACLChecklist.cc,v 1.39.6.2 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLChecklist.cc,v 1.39.6.3 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -356,18 +356,20 @@
cbdataFree(t);
}
-ACLChecklist::ACLChecklist() :
- accessList (NULL),
- request (NULL),
+ACLChecklist::ACLChecklist() : accessList (NULL), my_port (0), request (NULL),
reply (NULL),
auth_user_request (NULL),
#if SQUID_SNMP
snmp_community(NULL),
#endif
+#if USE_SSL
+ ssl_error(0),
+#endif
callback (NULL),
callback_data (NULL),
extacl_entry (NULL),
conn_(NULL),
+ fd_(-1),
async_(false),
finished_(false),
allow_(ACCESS_DENIED),
@@ -376,9 +378,12 @@
sourceDomainChecked_(false),
lastACLResult_(false)
{
- my_addr.SetEmpty();
- src_addr.SetEmpty();
- dst_addr.SetEmpty();
+
+ memset (&src_addr, '\0', sizeof (struct IN_ADDR));
+
+ memset (&dst_addr, '\0', sizeof (struct IN_ADDR));
+
+ memset (&my_addr, '\0', sizeof (struct IN_ADDR));
rfc931[0] = '\0';
}
@@ -398,7 +403,6 @@
* If this fails, then we'll need a backup UNLOCK call in the
* destructor.
*/
- /* AYJ: It fails in builds without any Authentication configured */
assert(auth_user_request == NULL);
conn_ = NULL;
@@ -422,6 +426,19 @@
conn_ = aConn;
}
+int
+ACLChecklist::fd() const
+{
+ return conn_ != NULL ? conn_->fd : fd_;
+}
+
+void
+ACLChecklist::fd(int aDescriptor)
+{
+ assert(!conn() || conn()->fd == aDescriptor);
+ fd_ = aDescriptor;
+}
+
void
ACLChecklist::AsyncState::changeState (ACLChecklist *checklist, AsyncState *newState) const
{
@@ -573,6 +590,7 @@
checklist->request = HTTPMSGLOCK(request);
checklist->src_addr = request->client_addr;
checklist->my_addr = request->my_addr;
+ checklist->my_port = request->my_port;
}
#if USE_IDENT
Index: squid3/src/ACLChecklist.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLChecklist.h,v
retrieving revision 1.28.6.2
retrieving revision 1.28.6.3
diff -u -r1.28.6.2 -r1.28.6.3
--- squid3/src/ACLChecklist.h 25 Jan 2008 02:33:37 -0000 1.28.6.2
+++ squid3/src/ACLChecklist.h 27 Jan 2008 18:08:44 -0000 1.28.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: ACLChecklist.h,v 1.28.6.2 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLChecklist.h,v 1.28.6.3 2008/01/27 18:08:44 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -97,8 +97,14 @@
void checkCallback(allow_t answer);
void preCheck();
_SQUID_INLINE_ bool matchAclListFast(const ACLList * list);
+
ConnStateData::Pointer conn();
+ int fd() const; // uses conn() if available
+
+ // set either conn or FD
void conn(ConnStateData::Pointer);
+ void fd(int aDescriptor);
+
int authenticated();
bool asyncInProgress() const;
@@ -115,12 +121,12 @@
const acl_access *accessList;
- IPAddress src_addr;
+ struct IN_ADDR src_addr;
- IPAddress dst_addr;
-
- IPAddress my_addr;
+ struct IN_ADDR dst_addr;
+ struct IN_ADDR my_addr;
+ unsigned short my_port;
HttpRequest *request;
/* for acls that look at reply data */
HttpReply *reply;
@@ -131,6 +137,10 @@
char *snmp_community;
#endif
+#if USE_SSL
+ int ssl_error;
+#endif
+
PF *callback;
void *callback_data;
ExternalACLEntry *extacl_entry;
@@ -144,6 +154,7 @@
void matchAclListSlow(const ACLList * list);
CBDATA_CLASS(ACLChecklist);
ConnStateData::Pointer conn_; /* hack for ident and NTLM */
+ int fd_; // may be available when conn_ is not
bool async_;
bool finished_;
allow_t allow_;
Index: squid3/src/ACLDestinationASN.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationASN.h,v
retrieving revision 1.2.40.1
retrieving revision 1.2.40.2
diff -u -r1.2.40.1 -r1.2.40.2
--- squid3/src/ACLDestinationASN.h 25 Jan 2008 02:33:37 -0000 1.2.40.1
+++ squid3/src/ACLDestinationASN.h 27 Jan 2008 18:08:44 -0000 1.2.40.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLDestinationASN.h,v 1.2.40.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLDestinationASN.h,v 1.2.40.2 2008/01/27 18:08:44 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -37,9 +37,8 @@
#define SQUID_ACLDESTINATIONASN_H
#include "ACLASN.h"
#include "ACLStrategy.h"
-#include "IPAddress.h"
-class ACLDestinationASNStrategy : public ACLStrategy
+class ACLDestinationASNStrategy : public ACLStrategy
{
public:
Index: squid3/src/ACLDestinationDomain.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationDomain.cc,v
retrieving revision 1.15.6.2
retrieving revision 1.15.6.3
diff -u -r1.15.6.2 -r1.15.6.3
--- squid3/src/ACLDestinationDomain.cc 25 Jan 2008 02:33:37 -0000 1.15.6.2
+++ squid3/src/ACLDestinationDomain.cc 27 Jan 2008 18:08:44 -0000 1.15.6.3
@@ -1,5 +1,5 @@
/*
- * $Id: ACLDestinationDomain.cc,v 1.15.6.2 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLDestinationDomain.cc,v 1.15.6.3 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -76,16 +76,13 @@
int
ACLDestinationDomainStrategy::match (ACLData * &data, ACLChecklist *checklist)
{
- assert(checklist != NULL && checklist->request != NULL);
-
const ipcache_addrs *ia = NULL;
const char *fqdn = NULL;
- if (data->match(checklist->request->GetHost()))
+ if (data->match(checklist->request->host))
return 1;
- /* numeric IPA? */
- if ((ia = ipcacheCheckNumeric(checklist->request->GetHost())) == NULL)
+ if ((ia = ipcacheCheckNumeric(checklist->request->host)) == NULL)
return 0;
checklist->dst_addr = ia->in_addrs[0];
@@ -95,7 +92,7 @@
return data->match(fqdn);
} else if (!checklist->destinationDomainChecked()) {
/* FIXME: Using AclMatchedName here is not OO correct. Should find a way to the current acl */
- debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << checklist->request->GetHost() << "'");
+ debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << checklist->request->host << "'");
checklist->changeState(DestinationDomainLookup::Instance());
return 0;
}
Index: squid3/src/ACLDestinationIP.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationIP.cc,v
retrieving revision 1.8.22.1
retrieving revision 1.8.22.2
diff -u -r1.8.22.1 -r1.8.22.2
--- squid3/src/ACLDestinationIP.cc 25 Jan 2008 02:33:37 -0000 1.8.22.1
+++ squid3/src/ACLDestinationIP.cc 27 Jan 2008 18:08:44 -0000 1.8.22.2
@@ -1,5 +1,5 @@
/*
- * $Id: ACLDestinationIP.cc,v 1.8.22.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLDestinationIP.cc,v 1.8.22.2 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -47,7 +47,7 @@
int
ACLDestinationIP::match(ACLChecklist *checklist)
{
- const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->GetHost(), IP_LOOKUP_IF_MISS);
+ const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->host, IP_LOOKUP_IF_MISS);
if (ia) {
/* Entry in cache found */
@@ -60,7 +60,7 @@
return 0;
} else if (!checklist->request->flags.destinationIPLookedUp()) {
/* No entry in cache, lookup not attempted */
- debugs(28, 3, "aclMatchAcl: Can't yet compare '" << name << "' ACL for '" << checklist->request->GetHost() << "'");
+ debugs(28, 3, "aclMatchAcl: Can't yet compare '" << name << "' ACL for '" << checklist->request->host << "'");
checklist->changeState (DestinationIPLookup::Instance());
return 0;
} else {
@@ -80,7 +80,7 @@
DestinationIPLookup::checkForAsync(ACLChecklist *checklist)const
{
checklist->asyncInProgress(true);
- ipcache_nbgethostbyname(checklist->request->GetHost(), LookupDone, checklist);
+ ipcache_nbgethostbyname(checklist->request->host, LookupDone, checklist);
}
void
Index: squid3/src/ACLIP.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLIP.cc,v
retrieving revision 1.20.6.1
retrieving revision 1.20.6.2
diff -u -r1.20.6.1 -r1.20.6.2
--- squid3/src/ACLIP.cc 25 Jan 2008 02:33:37 -0000 1.20.6.1
+++ squid3/src/ACLIP.cc 27 Jan 2008 18:08:44 -0000 1.20.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: ACLIP.cc,v 1.20.6.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLIP.cc,v 1.20.6.2 2008/01/27 18:08:44 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -55,17 +55,16 @@
void
ACLIP::DumpIpListWalkee(acl_ip_data * const & ip, void *state)
{
- char tmpbuf[MAX_IPSTRLEN];
MemBuf mb;
wordlist **W = static_cast(state);
mb.init();
- mb.Printf("%s", ip->addr1.NtoA(tmpbuf,MAX_IPSTRLEN));
+ mb.Printf("%s", inet_ntoa(ip->addr1));
- if (!ip->addr2.IsAnyAddr())
- mb.Printf("-%s", ip->addr2.NtoA(tmpbuf,MAX_IPSTRLEN));
+ if (ip->addr2.s_addr != any_addr.s_addr)
+ mb.Printf("-%s", inet_ntoa(ip->addr2));
- if (!ip->mask.IsNoAddr())
- mb.Printf("/%s", ip->mask.NtoA(tmpbuf,MAX_IPSTRLEN));
+ if (ip->mask.s_addr != no_addr.s_addr)
+ mb.Printf("/%s", inet_ntoa(ip->mask));
wordlistAdd(W, mb.buf);
@@ -79,33 +78,22 @@
void
acl_ip_data::toStr(char *buf, int len) const
{
- char *b1 = buf;
- char *b2 = NULL;
- char *b3 = NULL;
- int rlen = 0;
-
- addr1.NtoA(b1, len - rlen );
- rlen = strlen(buf);
- b2 = buf + rlen;
+ char b1[20];
+ char b2[20];
+ char b3[20];
+ snprintf(b1, 20, "%s", inet_ntoa(addr1));
- if (!addr2.IsAnyAddr())
- {
- b2[0] = '-'; rlen++;
- addr2.NtoA(&(b2[1]), len - rlen );
- rlen = strlen(buf);
- }
+ if (addr2.s_addr != any_addr.s_addr)
+ snprintf(b2, 20, "-%s", inet_ntoa(addr2));
else
b2[0] = '\0';
- b3 = buf + rlen;
-
- if (!mask.IsNoAddr())
- {
- b3[0] = '/'; rlen++;
- mask.NtoA(&(b3[1]), len - rlen );
- }
+ if (mask.s_addr != no_addr.s_addr)
+ snprintf(b3, 20, "/%s", inet_ntoa(mask));
else
b3[0] = '\0';
+
+ snprintf(buf, len, "%s%s%s", b1, b2, b3);
}
/*
@@ -118,21 +106,30 @@
int
aclIpAddrNetworkCompare(acl_ip_data * const &p, acl_ip_data * const &q)
{
- IPAddress A = p->addr1;
- /* apply netmask */
- A.ApplyMask(q->mask);
+ struct IN_ADDR A = p->addr1;
+
+ const struct IN_ADDR B = q->addr1;
- if (q->addr2.IsAnyAddr()) { /* single address check */
+ const struct IN_ADDR C = q->addr2;
+ A.s_addr &= q->mask.s_addr; /* apply netmask */
- return A.matchIPAddr( q->addr1 );
+ if (C.s_addr == 0) { /* single address check */
- } else { /* range address check */
+ if (ntohl(A.s_addr) > ntohl(B.s_addr))
+ return 1;
+ else if (ntohl(A.s_addr) < ntohl(B.s_addr))
+ return -1;
+ else
+ return 0;
+ } else { /* range address check */
- if ( (A >= q->addr1) && (A <= q->addr2) )
- return 0; /* valid. inside range. */
+ if (ntohl(A.s_addr) > ntohl(C.s_addr))
+ return 1;
+ else if (ntohl(A.s_addr) < ntohl(B.s_addr))
+ return -1;
else
- return A.matchIPAddr( q->addr1 ); /* outside of range, 'less than' */
+ return 0;
}
}
@@ -150,27 +147,26 @@
acl_ip_data::NetworkCompare(acl_ip_data * const & a, acl_ip_data * const &b)
{
int ret;
- bool bina = true;
ret = aclIpAddrNetworkCompare(b, a);
if (ret != 0) {
- bina = false;
ret = aclIpAddrNetworkCompare(a, b);
}
if (ret == 0) {
- char buf_n1[3*(MAX_IPSTRLEN+1)];
- char buf_n2[3*(MAX_IPSTRLEN+1)];
- if(bina) {
- b->toStr(buf_n1, 3*(MAX_IPSTRLEN+1));
- a->toStr(buf_n2, 3*(MAX_IPSTRLEN+1));
- } else {
- a->toStr(buf_n1, 3*(MAX_IPSTRLEN+1));
- b->toStr(buf_n2, 3*(MAX_IPSTRLEN+1));
- }
- debugs(28, 0, "WARNING: (" << (bina?'B':'A') << ") '" << buf_n1 << "' is a subnetwork of (" << (bina?'A':'B') << ") '" << buf_n2 << "'");
- debugs(28, 0, "WARNING: because of this '" << (bina?buf_n2:buf_n1) << "' is ignored to keep splay tree searching predictable");
- debugs(28, 0, "WARNING: You should probably remove '" << buf_n1 << "' from the ACL named '" << AclMatchedName << "'");
+ char buf_n1[60];
+ char buf_n2[60];
+ char buf_a[60];
+ b->toStr(buf_n1, 60);
+ a->toStr(buf_n2, 60);
+ a->toStr(buf_a, 60);
+ /* TODO: this warning may display the wrong way around */
+ debugs(28, 0, "WARNING: '" << buf_n1 <<
+ "' is a subnetwork of '" << buf_n2 << "'");
+ debugs(28, 0, "WARNING: because of this '" << buf_a <<
+ "' is ignored to keep splay tree searching predictable");
+ debugs(28, 0, "WARNING: You should probably remove '" << buf_n1 <<
+ "' from the ACL named '" << AclMatchedName << "'");
}
return ret;
@@ -182,221 +178,138 @@
* This function should NOT be called if 'asc' is a hostname!
*/
bool
-acl_ip_data::DecodeMask(const char *asc, IPAddress &mask, int ctype)
+acl_ip_data::DecodeMask(const char *asc, struct IN_ADDR *mask)
{
char junk;
int a1 = 0;
- /* default is a mask that doesn't change any IP */
- mask.SetNoAddr();
-
if (!asc || !*asc)
{
+ mask->s_addr = htonl(0xFFFFFFFFul);
return true;
}
- /* An int mask 128, 32 */
- if ((sscanf(asc, "%d%c", &a1, &junk)==1) &&
- (a1 <= 128) && (a1 >= 0)
- )
- {
- return mask.ApplyMask(a1, ctype);
+ if (sscanf(asc, "%d%c", &a1, &junk) == 1 && a1 >= 0 && a1 < 33)
+ { /* a significant bits value for a mask */
+ mask->s_addr = a1 ? htonl(0xfffffffful << (32 - a1)) : 0;
+ return true;
}
/* dotted notation */
- /* assignment returns true if asc contained an IP address as text */
- if ((mask = asc))
+ if (safe_inet_addr(asc, mask))
return true;
return false;
}
-/* Handle either type of address, IPv6 will be discarded with a warning if disabled */
-#define SCAN_ACL1_6 "%[0123456789ABCDEFabcdef:]-%[0123456789ABCDEFabcdef:]/%[0123456789]"
-#define SCAN_ACL2_6 "%[0123456789ABCDEFabcdef:]-%[0123456789ABCDEFabcdef:]%c"
-#define SCAN_ACL3_6 "%[0123456789ABCDEFabcdef:]/%[0123456789]"
-#define SCAN_ACL4_6 "%[0123456789ABCDEFabcdef:]/%c"
-/* We DO need to know which is which though, for proper CIDR masking. */
-#define SCAN_ACL1_4 "%[0123456789.]-%[0123456789.]/%[0123456789.]"
-#define SCAN_ACL2_4 "%[0123456789.]-%[0123456789.]%c"
-#define SCAN_ACL3_4 "%[0123456789.]/%[0123456789.]"
-#define SCAN_ACL4_4 "%[0123456789.]/%c"
+#define SCAN_ACL1 "%[0123456789.]-%[0123456789.]/%[0123456789.]"
+#define SCAN_ACL2 "%[0123456789.]-%[0123456789.]%c"
+#define SCAN_ACL3 "%[0123456789.]/%[0123456789.]"
+#define SCAN_ACL4 "%[0123456789.]%c"
acl_ip_data *
acl_ip_data::FactoryParse(const char *t)
{
- LOCAL_ARRAY(char, addr1, 256);
LOCAL_ARRAY(char, addr2, 256);
LOCAL_ARRAY(char, mask, 256);
- acl_ip_data *r = NULL;
- acl_ip_data **Q = NULL;
- IPAddress temp;
+ acl_ip_data *r;
+ acl_ip_data **Q;
+ char **x;
char c;
- unsigned int changed;
+ debugs(28, 5, "aclParseIpData: " << t);
acl_ip_data *q = new acl_ip_data;
- int iptype = AF_UNSPEC;
- debugs(28, 5, "aclIpParseIpData: " << t);
-
- /* Special ACL RHS "all" matches entire Internet */
- if (strcasecmp(t, "all") == 0) {
- q->addr1.SetAnyAddr();
- q->addr2.SetEmpty();
- q->mask.SetAnyAddr();
+ if (!strcasecmp(t, "all")) {
+ q->addr1.s_addr = 0;
+ q->addr2.s_addr = 0;
+ q->mask.s_addr = 0;
return q;
}
-#if USE_IPV6
- /* Special ACL RHS "ipv6" matches IPv6-Unicast Internet */
- if (strcasecmp(t, "ipv6") == 0) {
- t = "2000::/3";
- }
-#endif
-
-// IPv4
- if (sscanf(t, SCAN_ACL1_4, addr1, addr2, mask) == 3) {
- iptype=AF_INET;
- } else if (sscanf(t, SCAN_ACL2_4, addr1, addr2, &c) >= 2) {
- mask[0] = '\0';
- iptype=AF_INET;
- } else if (sscanf(t, SCAN_ACL3_4, addr1, mask) == 2) {
- addr2[0] = '\0';
- iptype=AF_INET;
- } else if (sscanf(t, SCAN_ACL4_4, addr1,&c) == 2) {
- addr2[0] = '\0';
- mask[0] = '\0';
- iptype=AF_INET;
+ LOCAL_ARRAY(char, addr1, 256);
-// IPv6
- } else if (sscanf(t, SCAN_ACL1_6, addr1, addr2, mask) == 3) {
- iptype=AF_INET6;
- } else if (sscanf(t, SCAN_ACL2_6, addr1, addr2, &c) >= 2) {
+ if (sscanf(t, SCAN_ACL1, addr1, addr2, mask) == 3) {
+ (void) 0;
+ } else if (sscanf(t, SCAN_ACL2, addr1, addr2, &c) == 2) {
mask[0] = '\0';
- iptype=AF_INET6;
- } else if (sscanf(t, SCAN_ACL3_6, addr1, mask) == 2) {
+ } else if (sscanf(t, SCAN_ACL3, addr1, mask) == 2) {
addr2[0] = '\0';
- iptype=AF_INET6;
- } else if (sscanf(t, SCAN_ACL4_6, addr1, mask) == 2) {
- addr2[0] = '\0';
- iptype=AF_INET6;
-
-// Neither
+ } else if (sscanf(t, SCAN_ACL4, addr1, &c) == 1) {
+ addr2[0] = '\0';
+ mask[0] = '\0';
} else if (sscanf(t, "%[^/]/%s", addr1, mask) == 2) {
addr2[0] = '\0';
} else if (sscanf(t, "%s", addr1) == 1) {
+
/*
- * Note, must use plain xgetaddrinfo() here because at startup
+ * Note, must use plain gethostbyname() here because at startup
* ipcache hasn't been initialized
- * TODO: offload this to one of the IPAddress lookups.
*/
- debugs(28, 5, "aclIpParseIpData: Lookup Host/IP " << addr1);
- struct addrinfo *hp = NULL, *x = NULL;
- struct addrinfo hints;
- IPAddress *prev_addr = NULL;
-
- memset(&hints, 0, sizeof(struct addrinfo));
-
- if( iptype != AF_UNSPEC ) {
- hints.ai_flags |= AI_NUMERICHOST;
- }
+ struct hostent *hp;
-#if 0 && USE_IPV6 && !IPV6_SPECIAL_SPLITSTACK
- hints.ai_flags |= AI_V4MAPPED | AI_ALL;
-#endif
-
- int errcode = xgetaddrinfo(addr1,NULL,&hints,&hp);
- if (hp == NULL) {
- debugs(28, 0, "aclIpParseIpData: Bad host/IP: '" << addr1 <<
- "' in '" << t << "', flags=" << hints.ai_flags <<
- " : (" << errcode << ") " << xgai_strerror(errcode) );
+ if ((hp = gethostbyname(addr1)) == NULL) {
+ debugs(28, 0, "aclParseIpData: Bad host/IP: '" << t << "'");
self_destruct();
- return NULL;
}
Q = &q;
- for (x = hp; x != NULL;) {
+ for (x = hp->h_addr_list; x != NULL && *x != NULL; x++) {
if ((r = *Q) == NULL)
r = *Q = new acl_ip_data;
- /* getaddrinfo given a host has a nasty tendency to return duplicate addr's */
- /* BUT sorted fortunately, so we can drop most of them easily */
- r->addr1 = *x;
- x = x->ai_next;
- if( prev_addr && r->addr1 == *prev_addr) {
- debugs(28, 3, "aclIpParseIpData: Duplicate host/IP: '" << r->addr1 << "' dropped.");
- delete r;
- *Q = NULL;
- continue;
- }
- else
- prev_addr = &r->addr1;
+ xmemcpy(&r->addr1.s_addr, *x, sizeof(r->addr1.s_addr));
- debugs(28, 3, "aclIpParseIpData: Located host/IP: '" << r->addr1 << "'");
-
- r->addr2.SetAnyAddr();
- r->mask.SetNoAddr();
+ r->addr2.s_addr = 0;
+ DecodeMask(NULL, &r->mask);
Q = &r->next;
- debugs(28, 3, "" << addr1 << " --> " << r->addr1 );
+ debugs(28, 3, "" << addr1 << " --> " << inet_ntoa(r->addr1));
}
if (*Q != NULL) {
- debugs(28, 0, "aclIpParseIpData: Bad host/IP: '" << t << "'");
+ debugs(28, 0, "aclParseIpData: Bad host/IP: '" << t << "'");
self_destruct();
- return NULL;
}
- xfreeaddrinfo(hp);
-
return q;
}
-#if !USE_IPV6
- /* ignore IPv6 addresses when built with IPv4-only */
- if( iptype == AF_INET6 ) {
- debugs(28, 0, "aclIpParseIpData: IPv6 has not been enabled. build with '--enable-ipv6'");
- return NULL;
- }
-#endif
-
/* Decode addr1 */
- if (!*addr1) {
- debugs(28, 0, "aclIpParseIpData: unknown first address in '" << t << "'");
+ if (!safe_inet_addr(addr1, &q->addr1)) {
+ debugs(28, 0, "aclParseIpData: unknown first address in '" << t << "'");
delete q;
self_destruct();
return NULL;
}
- else q->addr1 = addr1;
/* Decode addr2 */
- if (*addr2 && !(q->addr2=addr2) ) {
- debugs(28, 0, "aclIpParseIpData: unknown second address in '" << t << "'");
+ if (*addr2 && !safe_inet_addr(addr2, &q->addr2)) {
+ debugs(28, 0, "aclParseIpData: unknown second address in '" << t << "'");
delete q;
self_destruct();
return NULL;
}
- else q->addr2 = addr2;
/* Decode mask (NULL or empty means a exact host mask) */
- if (!DecodeMask(mask, q->mask, iptype)) {
+ if (!DecodeMask(mask, &q->mask)) {
debugs(28, 0, "aclParseIpData: unknown netmask '" << mask << "' in '" << t << "'");
delete q;
self_destruct();
return NULL;
}
- changed = 0;
- changed += q->addr1.ApplyMask(q->mask);
- changed += q->addr2.ApplyMask(q->mask);
+ if ((q->addr1.s_addr & q->mask.s_addr) != q->addr1.s_addr ||
+ (q->addr2.s_addr & q->mask.s_addr) != q->addr2.s_addr)
+ debugs(28, 0, "aclParseIpData: WARNING: Netmask masks away part of the specified IP in '" << t << "'");
+
+ q->addr1.s_addr &= q->mask.s_addr;
- if (changed)
- debugs(28, 0, "aclIpParseIpData: WARNING: Netmask masks away part of the specified IP in '" << t << "'");
+ q->addr2.s_addr &= q->mask.s_addr;
/* 1.2.3.4/255.255.255.0 --> 1.2.3.0 */
- /* Same as IPv6 (not so trivial to depict) */
return q;
}
@@ -436,24 +349,24 @@
}
int
-ACLIP::match(IPAddress &clientip)
+
+ACLIP::match(struct IN_ADDR &clientip)
{
- static acl_ip_data ClientAddress;
+ static acl_ip_data ClientAddress (any_addr, any_addr, no_addr, NULL);
/*
* aclIpAddrNetworkCompare() takes two acl_ip_data pointers as
* arguments, so we must create a fake one for the client's IP
- * address. Since we are scanning for a single IP mask and addr2
- * MUST be set to empty.
+ * address, and use a /32 netmask. However, the current code
+ * probably only accesses the addr1 element of this argument,
+ * so it might be possible to leave addr2 and mask unset.
*/
ClientAddress.addr1 = clientip;
- ClientAddress.addr2.SetEmpty();
- ClientAddress.mask.SetEmpty();
-
- data = data->splay(&ClientAddress, aclIpAddrNetworkCompare);
- debugs(28, 3, "aclIpMatchIp: '" << clientip << "' " << (splayLastResult ? "NOT found" : "found"));
+ acl_ip_data *ClientAddressPointer = &ClientAddress;
+ data = data->splay(ClientAddressPointer, aclIpAddrNetworkCompare);
+ debugs(28, 3, "aclMatchIp: '" << inet_ntoa(clientip) << "' " << (splayLastResult ? "NOT found" : "found"));
return !splayLastResult;
}
-acl_ip_data::acl_ip_data () :addr1(), addr2(), mask(), next (NULL) {}
+acl_ip_data::acl_ip_data () :addr1(any_addr), addr2(any_addr), mask (any_addr), next (NULL) {}
-acl_ip_data::acl_ip_data (IPAddress const &anAddress1, IPAddress const &anAddress2, IPAddress const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext){}
+acl_ip_data::acl_ip_data (struct IN_ADDR const &anAddress1, struct IN_ADDR const &anAddress2, struct IN_ADDR const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext){}
Index: squid3/src/ACLIP.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLIP.h,v
retrieving revision 1.8.40.1
retrieving revision 1.8.40.2
diff -u -r1.8.40.1 -r1.8.40.2
--- squid3/src/ACLIP.h 25 Jan 2008 02:33:37 -0000 1.8.40.1
+++ squid3/src/ACLIP.h 27 Jan 2008 18:08:45 -0000 1.8.40.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLIP.h,v 1.8.40.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLIP.h,v 1.8.40.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -37,7 +37,6 @@
#define SQUID_ACLIP_H
#include "ACL.h"
#include "splay.h"
-#include "IPAddress.h"
class acl_ip_data
{
@@ -49,20 +48,19 @@
acl_ip_data ();
- acl_ip_data (IPAddress const &, IPAddress const &, IPAddress const &, acl_ip_data *);
+ acl_ip_data (struct IN_ADDR const &, struct IN_ADDR const &, struct IN_ADDR const &, acl_ip_data *);
void toStr(char *buf, int len) const;
- IPAddress addr1;
+ struct IN_ADDR addr1; /* if addr2 non-zero then its a range */
- IPAddress addr2;
-
- IPAddress mask; /* This should perhapse be stored as a CIDR range now instead of a full IP mask. */
+ struct IN_ADDR addr2;
+ struct IN_ADDR mask;
acl_ip_data *next; /* used for parsing, not for storing */
private:
- static bool DecodeMask(const char *asc, IPAddress &mask, int string_format_type);
+ static bool DecodeMask(const char *asc, struct IN_ADDR *mask);
};
MEMPROXY_CLASS_INLINE(acl_ip_data)
@@ -89,7 +87,7 @@
protected:
- int match(IPAddress &);
+ int match(struct IN_ADDR &);
IPSplay *data;
private:
Index: squid3/src/ACLIdent.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLIdent.cc,v
retrieving revision 1.15.22.1
retrieving revision 1.15.22.2
diff -u -r1.15.22.1 -r1.15.22.2
--- squid3/src/ACLIdent.cc 25 Jan 2008 02:33:37 -0000 1.15.22.1
+++ squid3/src/ACLIdent.cc 27 Jan 2008 18:08:45 -0000 1.15.22.2
@@ -1,5 +1,5 @@
/*
- * $Id: ACLIdent.cc,v 1.15.22.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLIdent.cc,v 1.15.22.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -128,7 +128,7 @@
if (checklist->conn() != NULL) {
debugs(28, 3, "IdentLookup::checkForAsync: Doing ident lookup" );
checklist->asyncInProgress(true);
- identStart(checklist->conn()->me, checklist->conn()->peer,
+ identStart(&checklist->conn()->me, &checklist->conn()->peer,
LookupDone, checklist);
} else {
debugs(28, 1, "IdentLookup::checkForAsync: Can't start ident lookup. No client connection" );
Index: squid3/src/ACLMaxUserIP.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMaxUserIP.cc,v
retrieving revision 1.13.22.1
retrieving revision 1.13.22.2
diff -u -r1.13.22.1 -r1.13.22.2
--- squid3/src/ACLMaxUserIP.cc 25 Jan 2008 02:33:37 -0000 1.13.22.1
+++ squid3/src/ACLMaxUserIP.cc 27 Jan 2008 18:08:45 -0000 1.13.22.2
@@ -1,5 +1,5 @@
/*
- * $Id: ACLMaxUserIP.cc,v 1.13.22.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLMaxUserIP.cc,v 1.13.22.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -117,7 +117,7 @@
int
ACLMaxUserIP::match(AuthUserRequest * auth_user_request,
- IPAddress const &src_addr)
+ struct IN_ADDR const &src_addr)
{
/*
* the logic for flush the ip list when the limit is hit vs keep
Index: squid3/src/ACLMaxUserIP.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMaxUserIP.h,v
retrieving revision 1.9.22.1
retrieving revision 1.9.22.2
diff -u -r1.9.22.1 -r1.9.22.2
--- squid3/src/ACLMaxUserIP.h 25 Jan 2008 02:33:37 -0000 1.9.22.1
+++ squid3/src/ACLMaxUserIP.h 27 Jan 2008 18:08:45 -0000 1.9.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLMaxUserIP.h,v 1.9.22.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLMaxUserIP.h,v 1.9.22.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -66,7 +66,7 @@
static Prototype RegistryProtoype;
static ACLMaxUserIP RegistryEntry_;
- int match(AuthUserRequest *, IPAddress const &);
+ int match(AuthUserRequest *, struct IN_ADDR const &);
char const *class_;
int maximum;
Index: squid3/src/ACLMethod.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMethod.cc,v
retrieving revision 1.3.48.1
retrieving revision 1.3.48.2
diff -u -r1.3.48.1 -r1.3.48.2
--- squid3/src/ACLMethod.cc 25 Jan 2008 02:33:37 -0000 1.3.48.1
+++ squid3/src/ACLMethod.cc 27 Jan 2008 18:08:45 -0000 1.3.48.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLMethod.cc,v 1.3.48.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLMethod.cc,v 1.3.48.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -41,13 +41,13 @@
/* explicit template instantiation required for some systems */
-template class ACLStrategised
+template class ACLStrategised
;
ACL::Prototype ACLMethod::RegistryProtoype(&ACLMethod::RegistryEntry_, "method");
-ACLStrategised ACLMethod::RegistryEntry_(new ACLMethodData, ACLMethodStrategy::Instance(), "method");
+ACLStrategised ACLMethod::RegistryEntry_(new ACLMethodData, ACLMethodStrategy::Instance(), "method");
int
ACLMethodStrategy::match (ACLData * &data, ACLChecklist *checklist)
Index: squid3/src/ACLMethod.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMethod.h,v
retrieving revision 1.1.52.1
retrieving revision 1.1.52.2
diff -u -r1.1.52.1 -r1.1.52.2
--- squid3/src/ACLMethod.h 25 Jan 2008 02:33:37 -0000 1.1.52.1
+++ squid3/src/ACLMethod.h 27 Jan 2008 18:08:45 -0000 1.1.52.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLMethod.h,v 1.1.52.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLMethod.h,v 1.1.52.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -38,7 +38,7 @@
#include "ACLStrategy.h"
#include "ACLStrategised.h"
-class ACLMethodStrategy : public ACLStrategy
+class ACLMethodStrategy : public ACLStrategy
{
public:
@@ -63,7 +63,7 @@
private:
static ACL::Prototype RegistryProtoype;
- static ACLStrategised RegistryEntry_;
+ static ACLStrategised RegistryEntry_;
};
#endif /* SQUID_ACLMETHOD_H */
Index: squid3/src/ACLMethodData.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMethodData.cc,v
retrieving revision 1.8.34.1
retrieving revision 1.8.34.2
diff -u -r1.8.34.1 -r1.8.34.2
--- squid3/src/ACLMethodData.cc 25 Jan 2008 02:33:37 -0000 1.8.34.1
+++ squid3/src/ACLMethodData.cc 27 Jan 2008 18:08:45 -0000 1.8.34.2
@@ -1,5 +1,5 @@
/*
- * $Id: ACLMethodData.cc,v 1.8.34.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLMethodData.cc,v 1.8.34.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -55,24 +55,24 @@
}
bool
-ACLMethodData::match(HttpRequestMethod toFind)
+ACLMethodData::match(method_t toFind)
{
return values->findAndTune (toFind);
}
/* explicit instantiation required for some systems */
-template cbdata_type List
+template cbdata_type List
::CBDATA_List;
wordlist *
ACLMethodData::dump()
{
wordlist *W = NULL;
- List *data = values;
+ List *data = values;
while (data != NULL) {
- wordlistAdd(&W, RequestMethodStr(data->element));
+ wordlistAdd(&W, RequestMethodStr[data->element]);
data = data->next;
}
@@ -82,14 +82,14 @@
void
ACLMethodData::parse()
{
- List **Tail;
+ List **Tail;
char *t = NULL;
for (Tail = &values; *Tail; Tail = &((*Tail)->next))
;
while ((t = strtokFile())) {
- List *q = new List (HttpRequestMethod(t));
+ List *q = new List (HttpRequestMethod(t));
*(Tail) = q;
Tail = &q->next;
}
@@ -101,7 +101,7 @@
return values == NULL;
}
-ACLData *
+ACLData *
ACLMethodData::clone() const
{
assert (!values);
Index: squid3/src/ACLMethodData.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMethodData.h,v
retrieving revision 1.4.40.1
retrieving revision 1.4.40.2
diff -u -r1.4.40.1 -r1.4.40.2
--- squid3/src/ACLMethodData.h 25 Jan 2008 02:33:37 -0000 1.4.40.1
+++ squid3/src/ACLMethodData.h 27 Jan 2008 18:08:45 -0000 1.4.40.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLMethodData.h,v 1.4.40.1 2008/01/25 02:33:37 valexey_eykon Exp $
+ * $Id: ACLMethodData.h,v 1.4.40.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -39,7 +39,7 @@
#include "ACLData.h"
#include "List.h"
-class ACLMethodData : public ACLData
+class ACLMethodData : public ACLData
{
public:
@@ -49,13 +49,13 @@
ACLMethodData(ACLMethodData const &);
ACLMethodData &operator= (ACLMethodData const &);
virtual ~ACLMethodData();
- bool match(HttpRequestMethod);
+ bool match(method_t);
wordlist *dump();
void parse();
bool empty() const;
- virtual ACLData *clone() const;
+ virtual ACLData *clone() const;
- List *values;
+ List *values;
};
MEMPROXY_CLASS_INLINE(ACLMethodData)
Index: squid3/src/ACLMyPort.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLMyPort.cc,v
retrieving revision 1.2.48.1
retrieving revision 1.2.48.2
diff -u -r1.2.48.1 -r1.2.48.2
--- squid3/src/ACLMyPort.cc 25 Jan 2008 02:33:38 -0000 1.2.48.1
+++ squid3/src/ACLMyPort.cc 27 Jan 2008 18:08:45 -0000 1.2.48.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLMyPort.cc,v 1.2.48.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: ACLMyPort.cc,v 1.2.48.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -51,7 +51,7 @@
int
ACLMyPortStrategy::match (ACLData * &data, ACLChecklist *checklist)
{
- return data->match (checklist->my_addr.GetPort());
+ return data->match (checklist->my_port);
}
ACLMyPortStrategy *
Index: squid3/src/ACLSourceASN.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLSourceASN.h,v
retrieving revision 1.2.40.1
retrieving revision 1.2.40.2
diff -u -r1.2.40.1 -r1.2.40.2
--- squid3/src/ACLSourceASN.h 25 Jan 2008 02:33:38 -0000 1.2.40.1
+++ squid3/src/ACLSourceASN.h 27 Jan 2008 18:08:45 -0000 1.2.40.2
@@ -1,6 +1,6 @@
/*
- * $Id: ACLSourceASN.h,v 1.2.40.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: ACLSourceASN.h,v 1.2.40.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -37,9 +37,8 @@
#define SQUID_ACLSOURCEASN_H
#include "ACLASN.h"
#include "ACLStrategy.h"
-#include "IPAddress.h"
-class ACLSourceASNStrategy : public ACLStrategy
+class ACLSourceASNStrategy : public ACLStrategy
{
public:
Index: squid3/src/ACLSourceDomain.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ACLSourceDomain.cc,v
retrieving revision 1.6.6.1
retrieving revision 1.6.6.2
diff -u -r1.6.6.1 -r1.6.6.2
--- squid3/src/ACLSourceDomain.cc 25 Jan 2008 02:33:38 -0000 1.6.6.1
+++ squid3/src/ACLSourceDomain.cc 27 Jan 2008 18:08:45 -0000 1.6.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: ACLSourceDomain.cc,v 1.6.6.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: ACLSourceDomain.cc,v 1.6.6.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -82,7 +82,7 @@
return data->match(fqdn);
} else if (!checklist->sourceDomainChecked()) {
/* FIXME: Using AclMatchedName here is not OO correct. Should find a way to the current acl */
- debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << checklist->src_addr << "'");
+ debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << inet_ntoa(checklist->src_addr) << "'");
checklist->changeState(SourceDomainLookup::Instance());
return 0;
}
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/src/ACLSslError.cc Wed Feb 6 01:24:20 2008
@@ -0,0 +1,33 @@
+
+/*
+ * $Id: ACLSslError.cc,v 1.1.2.4 2008/01/27 18:08:45 rousskov Exp $
+ */
+
+#include "squid.h"
+#include "ACLSslError.h"
+#include "ACLSslErrorData.h"
+#include "ACLChecklist.h"
+
+/* explicit template instantiation required for some systems */
+
+template class ACLStrategised
+
+;
+
+ACL::Prototype ACLSslError::RegistryProtoype(&ACLSslError::RegistryEntry_, "ssl_error");
+
+ACLStrategised ACLSslError::RegistryEntry_(new ACLSslErrorData, ACLSslErrorStrategy::Instance(), "ssl_error");
+
+int
+ACLSslErrorStrategy::match (ACLData * &data, ACLChecklist *checklist)
+{
+ return data->match (checklist->ssl_error);
+}
+
+ACLSslErrorStrategy *
+ACLSslErrorStrategy::Instance()
+{
+ return &Instance_;
+}
+
+ACLSslErrorStrategy ACLSslErrorStrategy::Instance_;
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/src/ACLSslError.h Wed Feb 6 01:24:20 2008
@@ -0,0 +1,37 @@
+
+/*
+ * $Id: ACLSslError.h,v 1.1.2.4 2008/01/27 18:08:45 rousskov Exp $
+ */
+
+#ifndef SQUID_ACLSSL_ERROR_H
+#define SQUID_ACLSSL_ERROR_H
+#include "ACLStrategy.h"
+#include "ACLStrategised.h"
+
+class ACLSslErrorStrategy : public ACLStrategy
+{
+
+public:
+ virtual int match (ACLData * &, ACLChecklist *);
+ static ACLSslErrorStrategy *Instance();
+ /* Not implemented to prevent copies of the instance. */
+ /* Not private to prevent brain dead g+++ warnings about
+ * private constructors with no friends */
+ ACLSslErrorStrategy(ACLSslErrorStrategy const &);
+
+private:
+ static ACLSslErrorStrategy Instance_;
+ ACLSslErrorStrategy(){}
+
+ ACLSslErrorStrategy&operator=(ACLSslErrorStrategy const &);
+};
+
+class ACLSslError
+{
+
+private:
+ static ACL::Prototype RegistryProtoype;
+ static ACLStrategised RegistryEntry_;
+};
+
+#endif /* SQUID_ACLSSL_ERROR_H */
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/src/ACLSslErrorData.cc Wed Feb 6 01:24:20 2008
@@ -0,0 +1,76 @@
+/*
+ * $Id: ACLSslErrorData.cc,v 1.1.2.3 2008/01/27 18:08:45 rousskov Exp $
+ */
+
+#include "squid.h"
+#include "ACLSslErrorData.h"
+#include "ACLChecklist.h"
+#include "wordlist.h"
+
+ACLSslErrorData::ACLSslErrorData() : values (NULL)
+{}
+
+ACLSslErrorData::ACLSslErrorData(ACLSslErrorData const &old) : values (NULL)
+{
+ assert (!old.values);
+}
+
+ACLSslErrorData::~ACLSslErrorData()
+{
+ if (values)
+ delete values;
+}
+
+bool
+ACLSslErrorData::match(ssl_error_t toFind)
+{
+ return values->findAndTune (toFind);
+}
+
+/* explicit instantiation required for some systems */
+
+template cbdata_type List::CBDATA_List;
+
+wordlist *
+ACLSslErrorData::dump()
+{
+ wordlist *W = NULL;
+ List *data = values;
+
+ while (data != NULL) {
+ wordlistAdd(&W, sslFindErrorString(data->element));
+ data = data->next;
+ }
+
+ return W;
+}
+
+void
+ACLSslErrorData::parse()
+{
+ List **Tail;
+ char *t = NULL;
+
+ for (Tail = &values; *Tail; Tail = &((*Tail)->next))
+
+ ;
+ while ((t = strtokFile())) {
+ List *q = new List(sslParseErrorString(t));
+ *(Tail) = q;
+ Tail = &q->next;
+ }
+}
+
+bool
+ACLSslErrorData::empty() const
+{
+ return values == NULL;
+}
+
+ACLData *
+ACLSslErrorData::clone() const
+{
+ /* Splay trees don't clone yet. */
+ assert (!values);
+ return new ACLSslErrorData(*this);
+}
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/src/ACLSslErrorData.h Wed Feb 6 01:24:20 2008
@@ -0,0 +1,34 @@
+
+/*
+ * $Id: ACLSslErrorData.h,v 1.1.2.3 2008/01/27 18:08:45 rousskov Exp $
+ */
+
+#ifndef SQUID_ACLSSL_ERRORDATA_H
+#define SQUID_ACLSSL_ERRORDATA_H
+#include "ACL.h"
+#include "ACLData.h"
+#include "List.h"
+#include "ssl_support.h"
+
+class ACLSslErrorData : public ACLData
+{
+
+public:
+ MEMPROXY_CLASS(ACLSslErrorData);
+
+ ACLSslErrorData();
+ ACLSslErrorData(ACLSslErrorData const &);
+ ACLSslErrorData &operator= (ACLSslErrorData const &);
+ virtual ~ACLSslErrorData();
+ bool match(ssl_error_t);
+ wordlist *dump();
+ void parse();
+ bool empty() const;
+ virtual ACLData *clone() const;
+
+ List *values;
+};
+
+MEMPROXY_CLASS_INLINE(ACLSslErrorData);
+
+#endif /* SQUID_ACLSSL_ERRORDATA_H */
Index: squid3/src/AccessLogEntry.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/AccessLogEntry.h,v
retrieving revision 1.8.6.1
retrieving revision 1.8.6.2
diff -u -r1.8.6.1 -r1.8.6.2
--- squid3/src/AccessLogEntry.h 25 Jan 2008 02:33:38 -0000 1.8.6.1
+++ squid3/src/AccessLogEntry.h 27 Jan 2008 18:08:45 -0000 1.8.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: AccessLogEntry.h,v 1.8.6.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: AccessLogEntry.h,v 1.8.6.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -37,7 +37,6 @@
#include "HttpVersion.h"
#include "HierarchyLogEntry.h"
-#include "IPAddress.h"
/* forward decls */
@@ -57,7 +56,7 @@
public:
HttpDetails() : method(METHOD_NONE), code(0), content_type(NULL) {}
- HttpRequestMethod method;
+ method_t method;
int code;
const char *content_type;
HttpVersion version;
@@ -80,8 +79,7 @@
{
public:
- CacheDetails() : caddr(),
- size(0),
+ CacheDetails() : size(0),
highOffset(0),
objectSize(0),
code (LOG_TAG_NONE),
@@ -93,10 +91,10 @@
,ssluser(NULL)
#endif
{
- ;
+ memset(&caddr, '\0', sizeof(caddr));
}
- IPAddress caddr;
+ struct IN_ADDR caddr;
int64_t size;
int64_t highOffset;
int64_t objectSize;
Index: squid3/src/AuthUser.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/AuthUser.cc,v
retrieving revision 1.9.16.1
retrieving revision 1.9.16.2
diff -u -r1.9.16.1 -r1.9.16.2
--- squid3/src/AuthUser.cc 25 Jan 2008 02:33:38 -0000 1.9.16.1
+++ squid3/src/AuthUser.cc 27 Jan 2008 18:08:45 -0000 1.9.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: AuthUser.cc,v 1.9.16.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: AuthUser.cc,v 1.9.16.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 29 Authenticator
* AUTHOR: Robert Collins
@@ -240,7 +240,7 @@
}
void
-AuthUser::removeIp(IPAddress ipaddr)
+AuthUser::removeIp(struct IN_ADDR ipaddr)
{
auth_user_ip_t *ipdata = (auth_user_ip_t *) ip_list.head;
@@ -248,7 +248,7 @@
{
/* walk the ip list */
- if (ipdata->ipaddr == ipaddr) {
+ if (ipdata->ipaddr.s_addr == ipaddr.s_addr) {
/* remove the node */
dlinkDelete(&ipdata->node, &ip_list);
cbdataFree(ipdata);
@@ -264,9 +264,10 @@
}
void
-AuthUser::addIp(IPAddress ipaddr)
+AuthUser::addIp(struct IN_ADDR ipaddr)
{
auth_user_ip_t *ipdata = (auth_user_ip_t *) ip_list.head;
+ char *ip1;
int found = 0;
CBDATA_INIT_TYPE(auth_user_ip_t);
@@ -281,8 +282,8 @@
auth_user_ip_t *tempnode = (auth_user_ip_t *) ipdata->node.next;
/* walk the ip list */
- if (ipdata->ipaddr == ipaddr) {
- /* This ip has already been seen. */
+ if (ipdata->ipaddr.s_addr == ipaddr.s_addr) {
+ /* This ip has alreadu been seen. */
found = 1;
/* update IP ttl */
ipdata->ip_expiretime = squid_curtime;
@@ -312,7 +313,11 @@
ipcount++;
- debugs(29, 2, "authenticateAuthUserAddIp: user '" << username() << "' has been seen at a new IP address (" << ipaddr << ")");
+ ip1 = xstrdup(inet_ntoa(ipaddr));
+
+ debugs(29, 2, "authenticateAuthUserAddIp: user '" << username() << "' has been seen at a new IP address (" << ip1 << ")");
+
+ safe_free(ip1);
}
Index: squid3/src/AuthUser.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/AuthUser.h,v
retrieving revision 1.5.22.1
retrieving revision 1.5.22.2
diff -u -r1.5.22.1 -r1.5.22.2
--- squid3/src/AuthUser.h 25 Jan 2008 02:33:38 -0000 1.5.22.1
+++ squid3/src/AuthUser.h 27 Jan 2008 18:08:45 -0000 1.5.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: AuthUser.h,v 1.5.22.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: AuthUser.h,v 1.5.22.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -35,8 +35,6 @@
#ifndef SQUID_AUTHUSER_H
#define SQUID_AUTHUSER_H
-#include "IPAddress.h"
-
class AuthUserRequest;
class AuthUser
@@ -72,8 +70,8 @@
_SQUID_INLINE_ char const *username() const;
_SQUID_INLINE_ void username(char const *);
void clearIp();
- void removeIp(IPAddress);
- void addIp(IPAddress);
+ void removeIp(struct IN_ADDR);
+ void addIp(struct IN_ADDR);
_SQUID_INLINE_ void addRequest(AuthUserRequest *);
void lock()
Index: squid3/src/AuthUserRequest.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/AuthUserRequest.cc,v
retrieving revision 1.19.6.1
retrieving revision 1.19.6.2
diff -u -r1.19.6.1 -r1.19.6.2
--- squid3/src/AuthUserRequest.cc 25 Jan 2008 02:33:38 -0000 1.19.6.1
+++ squid3/src/AuthUserRequest.cc 27 Jan 2008 18:08:45 -0000 1.19.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: AuthUserRequest.cc,v 1.19.6.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: AuthUserRequest.cc,v 1.19.6.2 2008/01/27 18:08:45 rousskov Exp $
*
* DO NOT MODIFY NEXT 2 LINES:
* arch-tag: 6803fde1-d5a2-4c29-9034-1c0c9f650eb4
@@ -200,7 +200,7 @@
}
static void
-authenticateAuthUserRequestSetIp(AuthUserRequest * auth_user_request, IPAddress &ipaddr)
+authenticateAuthUserRequestSetIp(AuthUserRequest * auth_user_request, struct IN_ADDR ipaddr)
{
auth_user_t *auth_user = auth_user_request->user();
@@ -211,7 +211,7 @@
}
void
-authenticateAuthUserRequestRemoveIp(AuthUserRequest * auth_user_request, IPAddress const &ipaddr)
+authenticateAuthUserRequestRemoveIp(AuthUserRequest * auth_user_request, struct IN_ADDR ipaddr)
{
auth_user_t *auth_user = auth_user_request->user();
@@ -329,7 +329,7 @@
*/
auth_acl_t
-AuthUserRequest::authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData::Pointer conn, IPAddress &src_addr)
+AuthUserRequest::authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData::Pointer conn, struct IN_ADDR src_addr)
{
const char *proxy_auth;
assert(headertype != 0);
@@ -402,7 +402,7 @@
debugs(29, 1, "authenticateAuthenticate: Unexpected change of authentication scheme from '" <<
conn->auth_user_request->user()->config->type() <<
"' to '" << proxy_auth << "' (client " <<
- src_addr << ")");
+ inet_ntoa(src_addr) << ")");
AUTHUSERREQUESTUNLOCK(conn->auth_user_request, "conn");
conn->auth_type = AUTH_UNKNOWN;
@@ -508,7 +508,7 @@
auth_acl_t
-AuthUserRequest::tryToAuthenticateAndSetAuthUser(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData::Pointer conn, IPAddress &src_addr)
+AuthUserRequest::tryToAuthenticateAndSetAuthUser(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData::Pointer conn, struct IN_ADDR src_addr)
{
/* If we have already been called, return the cached value */
AuthUserRequest *t = authTryGetUser (auth_user_request, conn, request);
Index: squid3/src/AuthUserRequest.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/AuthUserRequest.h,v
retrieving revision 1.8.22.1
retrieving revision 1.8.22.2
diff -u -r1.8.22.1 -r1.8.22.2
--- squid3/src/AuthUserRequest.h 25 Jan 2008 02:33:38 -0000 1.8.22.1
+++ squid3/src/AuthUserRequest.h 27 Jan 2008 18:08:45 -0000 1.8.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: AuthUserRequest.h,v 1.8.22.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: AuthUserRequest.h,v 1.8.22.2 2008/01/27 18:08:45 rousskov Exp $
*
* DO NOT MODIFY NEXT 2 LINES:
* arch-tag: 674533af-8b21-4641-b71a-74c4639072a0
@@ -49,7 +49,7 @@
dlink_node node;
/* IP addr this user authenticated from */
- IPAddress ipaddr;
+ struct IN_ADDR ipaddr;
time_t ip_expiretime;
};
@@ -78,7 +78,7 @@
virtual void user (AuthUser *aUser) {_auth_user=aUser;}
- static auth_acl_t tryToAuthenticateAndSetAuthUser(AuthUserRequest **, http_hdr_type, HttpRequest *, ConnStateData::Pointer, IPAddress &);
+ static auth_acl_t tryToAuthenticateAndSetAuthUser(AuthUserRequest **, http_hdr_type, HttpRequest *, ConnStateData::Pointer, struct IN_ADDR);
static void addReplyAuthHeader(HttpReply * rep, AuthUserRequest * auth_user_request, HttpRequest * request, int accelerated, int internal);
AuthUserRequest();
@@ -105,7 +105,7 @@
private:
- static auth_acl_t authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData::Pointer conn, IPAddress &src_addr);
+ static auth_acl_t authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData::Pointer conn, struct IN_ADDR src_addr);
/* return a message on the 407 error pages */
char *message;
@@ -126,7 +126,7 @@
extern void authenticateFixHeader(HttpReply *, AuthUserRequest *, HttpRequest *, int, int);
extern void authenticateAddTrailer(HttpReply *, AuthUserRequest *, HttpRequest *, int);
-extern void authenticateAuthUserRequestRemoveIp(AuthUserRequest *, IPAddress const &);
+extern void authenticateAuthUserRequestRemoveIp(AuthUserRequest *, struct IN_ADDR);
extern void authenticateAuthUserRequestClearIp(AuthUserRequest *);
extern int authenticateAuthUserRequestIPCount(AuthUserRequest *);
extern int authenticateDirection(AuthUserRequest *);
--- squid3/src/ChunkedCodingParser.cc Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,232 +0,0 @@
-#include "squid.h"
-#include "Parsing.h"
-#include "TextException.h"
-#include "ChunkedCodingParser.h"
-#include "MemBuf.h"
-
-ChunkedCodingParser::Step ChunkedCodingParser::psChunkBeg = &ChunkedCodingParser::parseChunkBeg;
-ChunkedCodingParser::Step ChunkedCodingParser::psChunkBody = &ChunkedCodingParser::parseChunkBody;
-ChunkedCodingParser::Step ChunkedCodingParser::psChunkEnd = &ChunkedCodingParser::parseChunkEnd;
-ChunkedCodingParser::Step ChunkedCodingParser::psTrailer = &ChunkedCodingParser::parseTrailer;
-ChunkedCodingParser::Step ChunkedCodingParser::psMessageEnd = &ChunkedCodingParser::parseMessageEnd;
-
-ChunkedCodingParser::ChunkedCodingParser()
-{
- reset();
-}
-
-void ChunkedCodingParser::reset()
-{
- theStep = psChunkBeg;
- theChunkSize = theLeftBodySize = 0;
- doNeedMoreData = false;
- theIn = theOut = NULL;
-}
-
-bool ChunkedCodingParser::parse(MemBuf *rawData, MemBuf *parsedContent)
-{
- Must(rawData && parsedContent);
- theIn = rawData;
- theOut = parsedContent;
-
- // we must reset this all the time so that mayContinue() lets us
- // output more content if we stopped due to needsMoreSpace() before
- doNeedMoreData = !theIn->hasContent();
-
- while (mayContinue()) {
- (this->*theStep)();
- }
-
- return theStep == psMessageEnd;
-}
-
-bool ChunkedCodingParser::needsMoreData() const
-{
- return doNeedMoreData;
-}
-
-bool ChunkedCodingParser::needsMoreSpace() const
-{
- assert(theOut);
- return theStep == psChunkBody && !theOut->hasPotentialSpace();
-}
-
-bool ChunkedCodingParser::mayContinue() const
-{
- return !needsMoreData() && !needsMoreSpace() && theStep != psMessageEnd;
-}
-
-void ChunkedCodingParser::parseChunkBeg()
-{
- Must(theChunkSize <= 0); // Should(), really
-
- size_t crlfBeg = 0;
- size_t crlfEnd = 0;
-
- if (findCrlf(crlfBeg, crlfEnd)) {
- debugs(94,7, "found chunk-size end: " << crlfBeg << "-" << crlfEnd);
- int64_t size = -1;
- const char *p = 0;
-
- if (StringToInt64(theIn->content(), size, &p, 16)) {
- if (size < 0) {
- throw TexcHere("negative chunk size");
- return;
- }
-
- theIn->consume(crlfEnd);
- theChunkSize = theLeftBodySize = size;
- debugs(94,7, "found chunk: " << theChunkSize);
- theStep = theChunkSize == 0 ? psTrailer : psChunkBody;
- return;
- }
-
- throw TexcHere("corrupted chunk size");
- }
-
- doNeedMoreData = true;
-}
-
-void ChunkedCodingParser::parseChunkBody()
-{
- Must(theLeftBodySize > 0); // Should, really
-
- const size_t availSize = XMIN(theLeftBodySize, (uint64_t)theIn->contentSize());
- const size_t safeSize = XMIN(availSize, (size_t)theOut->potentialSpaceSize());
-
- doNeedMoreData = availSize < theLeftBodySize;
- // and we may also need more space
-
- theOut->append(theIn->content(), safeSize);
- theIn->consume(safeSize);
- theLeftBodySize -= safeSize;
-
- if (theLeftBodySize == 0)
- theStep = psChunkEnd;
- else
- Must(needsMoreData() || needsMoreSpace());
-}
-
-void ChunkedCodingParser::parseChunkEnd()
-{
- Must(theLeftBodySize == 0); // Should(), really
-
- size_t crlfBeg = 0;
- size_t crlfEnd = 0;
-
- if (findCrlf(crlfBeg, crlfEnd)) {
- if (crlfBeg != 0) {
- throw TexcHere("found data bewteen chunk end and CRLF");
- return;
- }
-
- theIn->consume(crlfEnd);
- theChunkSize = 0; // done with the current chunk
- theStep = psChunkBeg;
- return;
- }
-
- doNeedMoreData = true;
-}
-
-void ChunkedCodingParser::parseTrailer()
-{
- Must(theChunkSize == 0); // Should(), really
-
- while (mayContinue())
- parseTrailerHeader();
-}
-
-void ChunkedCodingParser::parseTrailerHeader()
-{
- size_t crlfBeg = 0;
- size_t crlfEnd = 0;
-
- if (findCrlf(crlfBeg, crlfEnd)) {
- if (crlfBeg > 0)
-
- ; //theTrailer.append(theIn->content(), crlfEnd);
-
- theIn->consume(crlfEnd);
-
- if (crlfBeg == 0)
- theStep = psMessageEnd;
-
- return;
- }
-
- doNeedMoreData = true;
-}
-
-void ChunkedCodingParser::parseMessageEnd()
-{
- // termination step, should not be called
- Must(false); // Should(), really
-}
-
-// finds next CRLF
-bool ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd)
-{
- // XXX: This code was copied, with permission, from another software.
- // There is a similar and probably better code inside httpHeaderParse
- // but it seems difficult to isolate due to parsing-unrelated bloat.
- // Such isolation should probably be done before this class is used
- // for handling of traffic "more external" than ICAP.
-
- const char *buf = theIn->content();
- size_t size = theIn->contentSize();
-
- ssize_t crOff = -1;
- bool quoted = false;
- bool slashed = false;
-
- for (size_t i = 0; i < size; ++i) {
- if (slashed) {
- slashed = false;
- continue;
- }
-
- const char c = buf[i];
-
- // handle quoted strings
- if (quoted) {
- if (c == '\\')
- slashed = true;
- else
- if (c == '"')
- quoted = false;
-
- continue;
- } else
- if (c == '"') {
- quoted = true;
- crOff = -1;
- continue;
- }
-
- if (crOff < 0) { // looking for the first CR or LF
-
- if (c == '\n') {
- crlfBeg = i;
- crlfEnd = ++i;
- return true;
- }
-
- if (c == '\r')
- crOff = i;
- } else { // skipping CRs, looking for the first LF
-
- if (c == '\n') {
- crlfBeg = crOff;
- crlfEnd = ++i;
- return true;
- }
-
- if (c != '\r')
- crOff = -1;
- }
- }
-
- return false;
-}
-
--- squid3/src/ChunkedCodingParser.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,89 +0,0 @@
-
-/*
- * $Id: ChunkedCodingParser.h,v 1.1.40.1 2008/01/25 02:33:38 valexey_eykon Exp $
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#ifndef SQUID_CHUNKEDCODINGPARSER_H
-#define SQUID_CHUNKEDCODINGPARSER_H
-
-#include "RefCount.h"
-
-// ChunkedCodingParser is an incremental parser for chunked transfer coding
-// used by HTTP and ICAP. The parser shovels content bytes from the raw
-// input buffer into the content output buffer, both caller-supplied.
-// Ignores chunk extensions except for ICAP's ieof.
-// Has a trailer-handling placeholder.
-
-class ChunkedCodingParser
-{
-
-public:
- ChunkedCodingParser();
-
- void reset();
-
- // true = complete success; false == needs more data
- bool parse(MemBuf *rawData, MemBuf *parsedContent); // throws on error
-
- bool needsMoreData() const;
- bool needsMoreSpace() const;
-
-private:
- typedef void (ChunkedCodingParser::*Step)();
-
-private:
- bool mayContinue() const;
-
- void parseChunkBeg();
- void parseChunkBody();
- void parseChunkEnd();
- void parseTrailer();
- void parseTrailerHeader();
- void parseMessageEnd();
-
- bool findCrlf(size_t &crlfBeg, size_t &crlfEnd);
-
-private:
- static Step psChunkBeg;
- static Step psChunkBody;
- static Step psChunkEnd;
- static Step psTrailer;
- static Step psMessageEnd;
-
- MemBuf *theIn;
- MemBuf *theOut;
-
- Step theStep;
- uint64_t theChunkSize;
- uint64_t theLeftBodySize;
- bool doNeedMoreData;
-};
-
-#endif /* SQUID_CHUNKEDCODINGPARSER_H */
Index: squid3/src/CompositePoolNode.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/CompositePoolNode.h,v
retrieving revision 1.8.16.1
retrieving revision 1.8.16.2
diff -u -r1.8.16.1 -r1.8.16.2
--- squid3/src/CompositePoolNode.h 25 Jan 2008 02:33:38 -0000 1.8.16.1
+++ squid3/src/CompositePoolNode.h 27 Jan 2008 18:08:45 -0000 1.8.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: CompositePoolNode.h,v 1.8.16.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: CompositePoolNode.h,v 1.8.16.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 77 Delay Pools
* AUTHOR: Robert Collins
@@ -47,7 +47,6 @@
#include "DelayPools.h"
#include "DelayIdComposite.h"
#include "CommRead.h"
-#include "IPAddress.h"
class StoreEntry;
@@ -77,7 +76,7 @@
public:
CompositeSelectionDetails() {}
- IPAddress src_addr;
+ struct IN_ADDR src_addr;
AuthUserRequest *user;
String tag;
};
Index: squid3/src/ConnectionDetail.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ConnectionDetail.h,v
retrieving revision 1.3.48.1
retrieving revision 1.3.48.2
diff -u -r1.3.48.1 -r1.3.48.2
--- squid3/src/ConnectionDetail.h 25 Jan 2008 02:33:38 -0000 1.3.48.1
+++ squid3/src/ConnectionDetail.h 27 Jan 2008 18:08:45 -0000 1.3.48.2
@@ -1,5 +1,5 @@
/*
- * $Id: ConnectionDetail.h,v 1.3.48.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: ConnectionDetail.h,v 1.3.48.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Robert Collins
@@ -37,8 +37,6 @@
#ifndef _SQUIDCONNECTIONDETAIL_H_
#define _SQUIDCONNECTIONDETAIL_H_
-#include "IPAddress.h"
-
class ConnectionDetail
{
@@ -46,9 +44,9 @@
ConnectionDetail();
- IPAddress me;
+ struct sockaddr_in me;
- IPAddress peer;
+ struct sockaddr_in peer;
};
#endif
Index: squid3/src/Debug.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Debug.h,v
retrieving revision 1.10.6.1
retrieving revision 1.10.6.2
diff -u -r1.10.6.1 -r1.10.6.2
--- squid3/src/Debug.h 25 Jan 2008 02:33:38 -0000 1.10.6.1
+++ squid3/src/Debug.h 27 Jan 2008 18:08:45 -0000 1.10.6.2
@@ -1,5 +1,6 @@
+
/*
- * $Id: Debug.h,v 1.10.6.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: Debug.h,v 1.10.6.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
@@ -52,12 +53,6 @@
#define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
#endif
-/* defined names for Debug Levels */
-#define DBG_CRITICAL 0 /**< critical messages always shown when they occur */
-#define DBG_IMPORTANT 1 /**< important messages always shown when their section is being checked */
-/* levels 2-8 are still being discussed amongst the developers */
-#define DBG_DATA 9 /**< output is a large data dump only necessary for advanced debugging */
-
class Debug
{
@@ -86,9 +81,9 @@
*
* debugs(1,1, HERE << "some message");
*/
-#define HERE __FILE__<<"("<<__LINE__<<") "<<__FUNCTION__<<": "
+#define HERE __FILE__<<"("<<__LINE__<<") "
-/* some uint8_t do not like streaming control-chars (values 0-31, 127+) */
+/* AYJ: some uint8_t do not like streaming control-chars (values 0-31, 127+) */
inline std::ostream& operator <<(std::ostream &os, const uint8_t d) {
return (os << (int)d);
}
Index: squid3/src/DelayConfig.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/DelayConfig.h,v
retrieving revision 1.3.34.1
retrieving revision 1.3.34.2
diff -u -r1.3.34.1 -r1.3.34.2
--- squid3/src/DelayConfig.h 25 Jan 2008 02:33:38 -0000 1.3.34.1
+++ squid3/src/DelayConfig.h 27 Jan 2008 18:08:45 -0000 1.3.34.2
@@ -1,8 +1,7 @@
+
/*
- * $Id: DelayConfig.h,v 1.3.34.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: DelayConfig.h,v 1.3.34.2 2008/01/27 18:08:45 rousskov Exp $
*
- * DEBUG: section 3 Configuration Settings
- * AUTHOR: Robert Collins
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* ----------------------------------------------------------
Index: squid3/src/DelayId.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/DelayId.cc,v
retrieving revision 1.21.6.1
retrieving revision 1.21.6.2
diff -u -r1.21.6.1 -r1.21.6.2
--- squid3/src/DelayId.cc 25 Jan 2008 02:33:38 -0000 1.21.6.1
+++ squid3/src/DelayId.cc 27 Jan 2008 18:08:45 -0000 1.21.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: DelayId.cc,v 1.21.6.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: DelayId.cc,v 1.21.6.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 77 Delay Pools
* AUTHOR: Robert Collins
@@ -39,11 +39,9 @@
#include "config.h"
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the delay pools code from compile process when not needed.
- */
-#if DELAY_POOLS
-
+#if !DELAY_POOLS
+#error DELAY_POOLS not enabled
+#endif
#include "squid.h"
#include "DelayId.h"
#include "client_side_request.h"
@@ -100,8 +98,8 @@
assert(http);
r = http->request;
- if (r->client_addr.IsNoAddr()) {
- debugs(77, 2, "delayClient: WARNING: Called with 'NO_ADDR' address, ignoring");
+ if (r->client_addr.s_addr == INADDR_BROADCAST) {
+ debugs(77, 2, "delayClient: WARNING: Called with 'allones' address, ignoring");
return DelayId();
}
@@ -109,6 +107,7 @@
ACLChecklist ch;
ch.src_addr = r->client_addr;
ch.my_addr = r->my_addr;
+ ch.my_port = r->my_port;
if (http->getConn() != NULL)
ch.conn(http->getConn());
@@ -188,5 +187,3 @@
compositeId->delayRead(aRead);
}
-
-#endif /* DELAY_POOLS */
Index: squid3/src/ESI.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v
retrieving revision 1.26.6.1
retrieving revision 1.26.6.2
diff -u -r1.26.6.1 -r1.26.6.2
--- squid3/src/ESI.cc 25 Jan 2008 02:33:38 -0000 1.26.6.1
+++ squid3/src/ESI.cc 27 Jan 2008 18:08:45 -0000 1.26.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: ESI.cc,v 1.26.6.1 2008/01/25 02:33:38 valexey_eykon Exp $
+ * $Id: ESI.cc,v 1.26.6.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 86 ESI processing
* AUTHOR: Robert Collins
@@ -35,12 +35,6 @@
*/
#include "squid.h"
-
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the ESI code from compile process when not needed.
- */
-#if (USE_SQUID_ESI == 1)
-
#include "ESI.h"
#include "clientStream.h"
#include "client_side_request.h"
@@ -59,7 +53,6 @@
#include "ESIExpression.h"
#include "HttpRequest.h"
#include "MemBuf.h"
-#include "IPAddress.h"
/* quick reference on behaviour here.
* The ESI specification 1.0 requires the ESI processor to be able to
@@ -1458,7 +1451,7 @@
/* don't touch incoming, it's a pointer into buffered anyway */
}
-extern ErrorState *clientBuildError (err_type, http_status, char const *, IPAddress &, HttpRequest *);
+extern ErrorState *clientBuildError (err_type, http_status, char const *, struct IN_ADDR *, HttpRequest *);
/* This can ONLY be used before we have sent *any* data to the client */
@@ -1476,7 +1469,8 @@
/* don't honour range requests - for errors we send it all */
flags.error = 1;
/* create an error object */
- ErrorState * err = clientBuildError(errorpage, errorstatus, NULL, http->getConn()->peer, http->request);
+ ErrorState * err = clientBuildError(errorpage, errorstatus, NULL,
+ http->getConn().getRaw() != NULL ? &http->getConn()->peer.sin_addr : &no_addr, http->request);
err->err_msg = errormessage;
errormessage = NULL;
rep = errorBuildReply (err);
@@ -1566,7 +1560,7 @@
assert (s);
buffer = new ESISegment;
ESISegment::Pointer local = buffer;
- size_t start = 0;
+ off_t start = 0;
int remainingCharacters = numberOfCharacters;
while (remainingCharacters > 0) {
@@ -2465,4 +2459,4 @@
return rv;
}
-#endif /* USE_SQUID_ESI == 1 */
+
Index: squid3/src/ESIAssign.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ESIAssign.cc,v
retrieving revision 1.6.16.1
retrieving revision 1.6.16.2
diff -u -r1.6.16.1 -r1.6.16.2
--- squid3/src/ESIAssign.cc 25 Jan 2008 02:33:42 -0000 1.6.16.1
+++ squid3/src/ESIAssign.cc 27 Jan 2008 18:08:45 -0000 1.6.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: ESIAssign.cc,v 1.6.16.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: ESIAssign.cc,v 1.6.16.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 86 ESI processing
* AUTHOR: Robert Collins
@@ -34,12 +34,6 @@
*/
#include "squid.h"
-
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the ESI code from compile process when not needed.
- */
-#if (USE_SQUID_ESI == 1)
-
#include "ESIAssign.h"
#include "ESIContext.h"
#include "ESISequence.h"
@@ -196,5 +190,3 @@
/* XXX: Implement evaluation of the expression */
ESISegment::ListAppend (state.getOutput(), expression.buf(), expression.size());
}
-
-#endif /* USE_SQUID_ESI == 1 */
Index: squid3/src/ESIContext.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ESIContext.cc,v
retrieving revision 1.4.22.1
retrieving revision 1.4.22.2
diff -u -r1.4.22.1 -r1.4.22.2
--- squid3/src/ESIContext.cc 25 Jan 2008 02:33:42 -0000 1.4.22.1
+++ squid3/src/ESIContext.cc 27 Jan 2008 18:08:45 -0000 1.4.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: ESIContext.cc,v 1.4.22.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: ESIContext.cc,v 1.4.22.2 2008/01/27 18:08:45 rousskov Exp $
*
* DEBUG: section 86 ESI processing
* AUTHOR: Robert Collins
@@ -34,12 +34,6 @@
*/
#include "squid.h"
-
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the ESI code from compile process when not needed.
- */
-#if (USE_SQUID_ESI == 1)
-
#include "ESIContext.h"
#include "Store.h"
#include "client_side_request.h"
@@ -112,5 +106,3 @@
if (!errormessage)
errormessage = xstrdup (anError);
}
-
-#endif /* USE_SQUID_ESI == 1 */
Index: squid3/src/ESIContext.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ESIContext.h,v
retrieving revision 1.5.50.1
retrieving revision 1.5.50.2
diff -u -r1.5.50.1 -r1.5.50.2
--- squid3/src/ESIContext.h 25 Jan 2008 02:33:42 -0000 1.5.50.1
+++ squid3/src/ESIContext.h 27 Jan 2008 18:08:45 -0000 1.5.50.2
@@ -1,5 +1,5 @@
/*
- * $Id: ESIContext.h,v 1.5.50.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: ESIContext.h,v 1.5.50.2 2008/01/27 18:08:45 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -133,8 +133,8 @@
* for some reason
*/
size_t outbound_offset;
- int64_t readpos; /* the logical position we are reading from */
- int64_t pos; /* the logical position of outbound_offset in the data stream */
+ off_t readpos; /* the logical position we are reading from */
+ off_t pos; /* the logical position of outbound_offset in the data stream */
class ParserState
{
Index: squid3/src/ESIInclude.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ESIInclude.cc,v
retrieving revision 1.14.6.1
retrieving revision 1.14.6.2
diff -u -r1.14.6.1 -r1.14.6.2
--- squid3/src/ESIInclude.cc 25 Jan 2008 02:33:42 -0000 1.14.6.1
+++ squid3/src/ESIInclude.cc 27 Jan 2008 18:08:46 -0000 1.14.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: ESIInclude.cc,v 1.14.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: ESIInclude.cc,v 1.14.6.2 2008/01/27 18:08:46 rousskov Exp $
*
* DEBUG: section 86 ESI processing
* AUTHOR: Robert Collins
@@ -35,12 +35,6 @@
*/
#include "squid.h"
-
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the ESI code from compile process when not needed.
- */
-#if (USE_SQUID_ESI == 1)
-
#include "ESIInclude.h"
#include "ESIVarState.h"
#include "client_side_request.h"
@@ -320,7 +314,7 @@
ESIInclude::prepareRequestHeaders(HttpHeader &tempheaders, ESIVarState *vars)
{
tempheaders.update (&vars->header(), NULL);
- tempheaders.removeHopByHopEntries();
+ tempheaders.removeConnectionHeaderEntries();
}
@@ -597,4 +591,3 @@
}
}
-#endif /* USE_SQUID_ESI == 1 */
Index: squid3/src/ESISequence.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ESISequence.cc,v
retrieving revision 1.6.22.1
retrieving revision 1.6.22.2
diff -u -r1.6.22.1 -r1.6.22.2
--- squid3/src/ESISequence.cc 25 Jan 2008 02:33:42 -0000 1.6.22.1
+++ squid3/src/ESISequence.cc 27 Jan 2008 18:08:46 -0000 1.6.22.2
@@ -1,5 +1,5 @@
/*
- * $Id: ESISequence.cc,v 1.6.22.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: ESISequence.cc,v 1.6.22.2 2008/01/27 18:08:46 rousskov Exp $
*
* DEBUG: section 86 ESI processing
* AUTHOR: Robert Collins
@@ -34,12 +34,6 @@
*/
#include "squid.h"
-
-/* MS Visual Studio Projects are monolithic, so we need the following
- * #if to exclude the ESI code from compile process when not needed.
- */
-#if (USE_SQUID_ESI == 1)
-
#include "ESISequence.h"
#include "ESILiteral.h"
#include "ESIAttempt.h"
@@ -398,4 +392,3 @@
return result;
}
-#endif /* USE_SQUID_ESI == 1 */
Index: squid3/src/HttpHeader.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpHeader.cc,v
retrieving revision 1.49.6.2
retrieving revision 1.49.6.3
diff -u -r1.49.6.2 -r1.49.6.3
--- squid3/src/HttpHeader.cc 25 Jan 2008 02:33:42 -0000 1.49.6.2
+++ squid3/src/HttpHeader.cc 27 Jan 2008 18:08:46 -0000 1.49.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: HttpHeader.cc,v 1.49.6.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpHeader.cc,v 1.49.6.3 2008/01/27 18:08:46 rousskov Exp $
*
* DEBUG: section 55 HTTP Header
* AUTHOR: Alex Rousskov
@@ -236,12 +236,6 @@
HDR_USER_AGENT, HDR_X_FORWARDED_FOR, HDR_SURROGATE_CAPABILITY
};
-static http_hdr_type HopByHopHeadersArr[] =
- {
- HDR_CONNECTION, HDR_KEEP_ALIVE, HDR_PROXY_AUTHENTICATE, HDR_PROXY_AUTHORIZATION,
- HDR_TE, HDR_TRAILERS, HDR_TRANSFER_ENCODING, HDR_UPGRADE
- };
-
/* header accounting */
static HttpHeaderStat HttpHeaderStats[] =
{
@@ -1769,18 +1763,6 @@
}
void
-HttpHeader::removeHopByHopEntries()
-{
- removeConnectionHeaderEntries();
-
- int count = countof(HopByHopHeadersArr);
-
- for (int i=0; i entries; /* parsed fields in raw format */
HttpHeaderMask mask; /* bit set <=> entry present */
http_hdr_owner_type owner; /* request or reply */
int len; /* length when packed, not counting terminating '\0' */
-protected:
- void removeConnectionHeaderEntries();
-
private:
HttpHeaderEntry *findLastEntry(http_hdr_type id) const;
// Make it non-copyable. Our destructor is a bit nasty...
Index: squid3/src/HttpMsg.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpMsg.cc,v
retrieving revision 1.31.6.1
retrieving revision 1.31.6.2
diff -u -r1.31.6.1 -r1.31.6.2
--- squid3/src/HttpMsg.cc 25 Jan 2008 02:33:42 -0000 1.31.6.1
+++ squid3/src/HttpMsg.cc 27 Jan 2008 18:08:46 -0000 1.31.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: HttpMsg.cc,v 1.31.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpMsg.cc,v 1.31.6.2 2008/01/27 18:08:46 rousskov Exp $
*
* DEBUG: section 74 HTTP Message
* AUTHOR: Alex Rousskov
@@ -153,14 +153,6 @@
// TODO: Remove? httpReplyParseStep() should do similar checks
const size_t hdr_len = headersEnd(buf->content(), buf->contentSize());
- // TODO: move to httpReplyParseStep()
- if (hdr_len > Config.maxReplyHeaderSize || hdr_len <= 0 && (size_t)buf->contentSize() > Config.maxReplyHeaderSize) {
- debugs(58, 1, "HttpMsg::parse: Too large reply header (" <<
- hdr_len << " > " << Config.maxReplyHeaderSize);
- *error = HTTP_HEADER_TOO_LARGE;
- return false;
- }
-
if (hdr_len <= 0) {
debugs(58, 3, "HttpMsg::parse: failed to find end of headers " <<
"(eof: " << eof << ") in '" << buf->content() << "'");
@@ -171,6 +163,14 @@
return false;
}
+ // TODO: move to httpReplyParseStep()
+ if (hdr_len > Config.maxReplyHeaderSize) {
+ debugs(58, 1, "HttpMsg::parse: Too large reply header (" <<
+ hdr_len << " > " << Config.maxReplyHeaderSize);
+ *error = HTTP_HEADER_TOO_LARGE;
+ return false;
+ }
+
if (!sanityCheckStartLine(buf, error)) {
debugs(58,1, HERE << "first line of HTTP message is invalid");
*error = HTTP_INVALID_HEADER;
Index: squid3/src/HttpMsg.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpMsg.h,v
retrieving revision 1.15.6.1
retrieving revision 1.15.6.2
diff -u -r1.15.6.1 -r1.15.6.2
--- squid3/src/HttpMsg.h 25 Jan 2008 02:33:42 -0000 1.15.6.1
+++ squid3/src/HttpMsg.h 27 Jan 2008 18:08:46 -0000 1.15.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: HttpMsg.h,v 1.15.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpMsg.h,v 1.15.6.2 2008/01/27 18:08:46 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -86,7 +86,7 @@
virtual int httpMsgParseError();
- virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const = 0;
+ virtual bool expectingBody(method_t, int64_t&) const = 0;
void firstLineBuf(MemBuf&);
Index: squid3/src/HttpReply.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.cc,v
retrieving revision 1.43.6.2
retrieving revision 1.43.6.3
diff -u -r1.43.6.2 -r1.43.6.3
--- squid3/src/HttpReply.cc 25 Jan 2008 02:33:42 -0000 1.43.6.2
+++ squid3/src/HttpReply.cc 27 Jan 2008 18:08:46 -0000 1.43.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: HttpReply.cc,v 1.43.6.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpReply.cc,v 1.43.6.3 2008/01/27 18:08:46 rousskov Exp $
*
* DEBUG: section 58 HTTP Reply (Response)
* AUTHOR: Alex Rousskov
@@ -416,7 +416,7 @@
* Returns the body size of a HTTP response
*/
int64_t
-HttpReply::bodySize(const HttpRequestMethod& method) const
+HttpReply::bodySize(method_t method) const
{
if (sline.version.major < 1)
return -1;
@@ -470,7 +470,7 @@
* along with this response
*/
bool
-HttpReply::expectingBody(const HttpRequestMethod& req_method, int64_t& theSize) const
+HttpReply::expectingBody(method_t req_method, int64_t& theSize) const
{
bool expectBody = true;
Index: squid3/src/HttpReply.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.h,v
retrieving revision 1.21.6.1
retrieving revision 1.21.6.2
diff -u -r1.21.6.1 -r1.21.6.2
--- squid3/src/HttpReply.h 25 Jan 2008 02:33:42 -0000 1.21.6.1
+++ squid3/src/HttpReply.h 27 Jan 2008 18:08:46 -0000 1.21.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: HttpReply.h,v 1.21.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpReply.h,v 1.21.6.2 2008/01/27 18:08:46 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -97,7 +97,7 @@
public:
virtual int httpMsgParseError();
- virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const;
+ virtual bool expectingBody(method_t, int64_t&) const;
void updateOnNotModified(HttpReply const *other);
@@ -116,7 +116,7 @@
void redirect(http_status, const char *);
- int64_t bodySize(const HttpRequestMethod&) const;
+ int64_t bodySize(method_t) const;
int validatorsMatch (HttpReply const *other) const;
Index: squid3/src/HttpRequest.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.cc,v
retrieving revision 1.43.6.1
retrieving revision 1.43.6.2
diff -u -r1.43.6.1 -r1.43.6.2
--- squid3/src/HttpRequest.cc 25 Jan 2008 02:33:42 -0000 1.43.6.1
+++ squid3/src/HttpRequest.cc 27 Jan 2008 18:08:46 -0000 1.43.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: HttpRequest.cc,v 1.43.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpRequest.cc,v 1.43.6.2 2008/01/27 18:08:46 rousskov Exp $
*
* DEBUG: section 73 HTTP Request
* AUTHOR: Duane Wessels
@@ -46,7 +46,7 @@
init();
}
-HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) : HttpMsg(hoRequest)
+HttpRequest::HttpRequest(method_t aMethod, protocol_t aProtocol, const char *aUrlpath) : HttpMsg(hoRequest)
{
init();
initHTTP(aMethod, aProtocol, aUrlpath);
@@ -58,7 +58,7 @@
}
void
-HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath)
+HttpRequest::initHTTP(method_t aMethod, protocol_t aProtocol, const char *aUrlpath)
{
method = aMethod;
protocol = aProtocol;
@@ -82,8 +82,10 @@
imslen = 0;
lastmod = -1;
max_forwards = -1;
- client_addr.SetEmpty();
- my_addr.SetEmpty();
+ client_addr = no_addr;
+ my_addr = no_addr;
+ my_port = 0;
+ client_port = 0;
body_pipe = NULL;
// hier
errType = ERR_NONE;
@@ -238,7 +240,7 @@
assert(p);
/* pack request-line */
packerPrintf(p, "%s %s HTTP/1.0\r\n",
- RequestMethodStr(method), urlpath.buf());
+ RequestMethodStr[method], urlpath.buf());
/* headers */
header.packInto(p);
/* trailer */
@@ -259,7 +261,7 @@
int
HttpRequest::prefixLen()
{
- return strlen(RequestMethodStr(method)) + 1 +
+ return strlen(RequestMethodStr[method]) + 1 +
urlpath.size() + 1 +
4 + 1 + 3 + 2 +
header.len + 2;
@@ -358,7 +360,7 @@
{
// form HTTP request-line
packerPrintf(p, "%s %s HTTP/%d.%d\r\n",
- RequestMethodStr(method),
+ RequestMethodStr[method],
packableURI(full_uri),
http_ver.major, http_ver.minor);
}
@@ -368,7 +370,7 @@
* along with this request
*/
bool
-HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t& theSize) const
+HttpRequest::expectingBody(method_t unused, int64_t& theSize) const
{
bool expectBody = false;
@@ -407,7 +409,7 @@
* If the request cannot be created cleanly, NULL is returned
*/
HttpRequest *
-HttpRequest::CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method)
+HttpRequest::CreateFromUrlAndMethod(char * url, method_t method)
{
return urlParse(method, url, NULL);
}
@@ -437,9 +439,17 @@
* The below looks questionable: what non HTTP protocols use connect,
* trace, put and post? RC
*/
-
- if (!method.isCacheble())
- return false;
+ if (method == METHOD_CONNECT)
+ return 0;
+
+ if (method == METHOD_TRACE)
+ return 0;
+
+ if (method == METHOD_PUT)
+ return 0;
+
+ if (method == METHOD_POST)
+ return 0;
/*
* XXX POST may be cached sometimes.. ignored
@@ -449,7 +459,7 @@
return gopherCachable(this);
if (protocol == PROTO_CACHEOBJ)
- return false;
+ return 0;
- return true;
+ return 1;
}
Index: squid3/src/HttpRequest.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.h,v
retrieving revision 1.30.6.1
retrieving revision 1.30.6.2
diff -u -r1.30.6.1 -r1.30.6.2
--- squid3/src/HttpRequest.h 25 Jan 2008 02:33:42 -0000 1.30.6.1
+++ squid3/src/HttpRequest.h 27 Jan 2008 18:08:47 -0000 1.30.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: HttpRequest.h,v 1.30.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpRequest.h,v 1.30.6.2 2008/01/27 18:08:47 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -53,7 +53,7 @@
public:
MEMPROXY_CLASS(HttpRequest);
HttpRequest();
- HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath);
+ HttpRequest(method_t aMethod, protocol_t aProtocol, const char *aUrlpath);
~HttpRequest();
virtual void reset();
@@ -63,44 +63,22 @@
return static_cast(HttpMsg::_lock());
};
- void initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath);
+ void initHTTP(method_t aMethod, protocol_t aProtocol, const char *aUrlpath);
/* are responses to this request potentially cachable */
bool cacheable() const;
- /* Now that we care what host contains it is better off being protected. */
- /* HACK: These two methods are only inline to get around Makefile dependancies */
- /* caused by HttpRequest being used in places it really shouldn't. */
- /* ideally they would be methods of URL instead. */
- inline void SetHost(const char *src)
- {
- host_addr.SetEmpty();
- host_addr = src;
- if( host_addr.IsAnyAddr() ) {
- xstrncpy(host, src, SQUIDHOSTNAMELEN);
- }
- else {
- host_addr.ToHostname(host, SQUIDHOSTNAMELEN);
- debugs(23, 3, "HttpRequest::SetHost() given IP: " << host_addr);
- }
- };
- inline const char* GetHost(void) const { return host; };
-
protected:
void clean();
void init();
public:
- HttpRequestMethod method;
+ method_t method;
char login[MAX_LOGIN_SZ];
-private:
- char host[SQUIDHOSTNAMELEN];
-
-public:
- IPAddress host_addr;
+ char host[SQUIDHOSTNAMELEN + 1];
AuthUserRequest *auth_user_request;
@@ -120,9 +98,15 @@
int max_forwards;
- IPAddress client_addr;
+ /* these in_addr's could probably be sockaddr_in's */
+
+ struct IN_ADDR client_addr;
+
+ struct IN_ADDR my_addr;
+
+ unsigned short my_port;
- IPAddress my_addr;
+ unsigned short client_port;
HierarchyLogEntry hier;
@@ -151,7 +135,7 @@
int parseHeader(const char *parse_start, int len);
- virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
+ virtual bool expectingBody(method_t unused, int64_t&) const;
bool bodyNibbled() const; // the request has a [partially] consumed body
@@ -163,7 +147,7 @@
static void httpRequestPack(void *obj, Packer *p);
- static HttpRequest * CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method);
+ static HttpRequest * CreateFromUrlAndMethod(char * url, method_t method);
static HttpRequest * CreateFromUrl(char * url);
Index: squid3/src/HttpRequestMethod.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpRequestMethod.cc,v
retrieving revision 1.4.22.1
retrieving revision 1.4.22.2
diff -u -r1.4.22.1 -r1.4.22.2
--- squid3/src/HttpRequestMethod.cc 25 Jan 2008 02:33:42 -0000 1.4.22.1
+++ squid3/src/HttpRequestMethod.cc 27 Jan 2008 18:08:47 -0000 1.4.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: HttpRequestMethod.cc,v 1.4.22.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpRequestMethod.cc,v 1.4.22.2 2008/01/27 18:08:47 rousskov Exp $
*
* DEBUG: section 73 HTTP Request
* AUTHOR: Duane Wessels
@@ -38,7 +38,7 @@
#include "HttpRequestMethod.h"
#include "wordlist.h"
-const char* HttpRequestMethod::RequestMethodStr[] =
+const char *RequestMethodStr[] =
{
"NONE",
"GET",
@@ -94,10 +94,10 @@
};
static
-_method_t &operator++ (_method_t &aMethod)
+method_t &operator++ (method_t &aMethod)
{
int tmp = (int)aMethod;
- aMethod = (_method_t)(++tmp);
+ aMethod = (method_t)(++tmp);
return aMethod;
}
@@ -127,27 +127,20 @@
*/
if (NULL == end)
end = begin + strcspn(begin, w_space);
-
- if (end == begin) {
- theMethod = METHOD_NONE;
- return;
- }
-
+
for (++theMethod; theMethod < METHOD_ENUM_END; ++theMethod) {
- if (0 == strncasecmp(begin, RequestMethodStr[theMethod], end-begin)) {
+ if (0 == strncasecmp(begin, RequestMethodStr[theMethod], end-begin))
return;
- }
}
- // if method not found and method string is not null then it is other method
- theMethod = METHOD_OTHER;
- theImage.limitInit(begin,end-begin);
+ /* reset to none */
+ theMethod = METHOD_NONE;
}
void
HttpRequestMethod::AddExtension(const char *mstr)
{
- _method_t method = METHOD_NONE;
+ method_t method = METHOD_NONE;
for (++method; method < METHOD_ENUM_END; ++method) {
if (0 == strcmp(mstr, RequestMethodStr[method])) {
@@ -185,38 +178,3 @@
w = w->next;
}
}
-
-char const*
-HttpRequestMethod::image() const
-{
- if (METHOD_OTHER != theMethod) {
- return RequestMethodStr[theMethod];
- }
- else {
- if (theImage.size()>0)
- return theImage.buf();
- else
- return "METHOD_OTHER";
- }
-}
-
-bool
-HttpRequestMethod::isCacheble() const
-{
- if (theMethod == METHOD_CONNECT)
- return false;
-
- if (theMethod == METHOD_TRACE)
- return false;
-
- if (theMethod == METHOD_PUT)
- return false;
-
- if (theMethod == METHOD_POST)
- return false;
-
- if (theMethod == METHOD_OTHER)
- return false;
-
- return true;
-}
Index: squid3/src/HttpRequestMethod.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpRequestMethod.h,v
retrieving revision 1.2.30.2
retrieving revision 1.2.30.3
diff -u -r1.2.30.2 -r1.2.30.3
--- squid3/src/HttpRequestMethod.h 25 Jan 2008 02:33:42 -0000 1.2.30.2
+++ squid3/src/HttpRequestMethod.h 27 Jan 2008 18:08:47 -0000 1.2.30.3
@@ -1,6 +1,6 @@
/*
- * $Id: HttpRequestMethod.h,v 1.2.30.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: HttpRequestMethod.h,v 1.2.30.3 2008/01/27 18:08:47 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -35,7 +35,6 @@
#define SQUID_HTTPREQUESTMETHOD_H
#include
-#include "SquidString.h"
enum _method_t {
METHOD_NONE, /* 000 */
@@ -88,10 +87,13 @@
METHOD_EXT17,
METHOD_EXT18,
METHOD_EXT19,
- METHOD_OTHER,
- METHOD_ENUM_END // MUST be last, (yuck) this is used as an array-initialization index constant!
+ METHOD_ENUM_END
};
+typedef enum _method_t method_t;
+
+extern const char *RequestMethodStr[];
+
/* forward decls */
typedef struct _SquidConfig SquidConfig;
@@ -111,76 +113,33 @@
HttpRequestMethod() : theMethod(METHOD_NONE) {}
- HttpRequestMethod(_method_t const aMethod) : theMethod(aMethod) {}
+ HttpRequestMethod(method_t const aMethod) : theMethod(aMethod) {}
HttpRequestMethod(char const * begin, char const * end=0);
- operator _method_t() const {return theMethod; }
-
- HttpRequestMethod & operator = (const HttpRequestMethod& aMethod)
- {
- theMethod = aMethod.theMethod;
- theImage = aMethod.theImage;
- return *this;
- }
+ operator method_t() const {return theMethod; }
- HttpRequestMethod & operator = (_method_t const aMethod)
+ HttpRequestMethod & operator = (method_t const aMethod)
{
theMethod = aMethod;
- theImage.clean();
return *this;
}
- bool operator != (_method_t const & aMethod) { return theMethod != aMethod;}
- bool operator != (HttpRequestMethod const & aMethod)
- {
- return ( (theMethod != aMethod) || (theImage != aMethod.theImage) );
- }
-
- HttpRequestMethod& operator++()
- {
- if (METHOD_OTHER!=theMethod)
- {
- int tmp = (int)theMethod;
- _method_t tmp_m = (_method_t)(++tmp);
-
- if (METHOD_ENUM_END >= tmp_m)
- theMethod = tmp_m;
- }
- return *this;
- }
-
+ bool operator != (method_t const & aMethod) { return theMethod != aMethod;}
/* Get a char string representation of the method. */
- char const* image() const;
-
- bool isCacheble() const;
+ char const *const_str() const { return RequestMethodStr[theMethod]; }
private:
- static const char *RequestMethodStr[];
-
- _method_t theMethod; ///< Method type
- String theImage; ///< Used for store METHOD_OTHER only
-};
+ method_t theMethod;
+};
inline std::ostream &
operator << (std::ostream &os, HttpRequestMethod const &method)
{
- os << method.image();
+ os << method.const_str();
return os;
}
-inline const char*
-RequestMethodStr(const _method_t m)
-{
- return HttpRequestMethod(m).image();
-}
-
-inline const char*
-RequestMethodStr(const HttpRequestMethod& m)
-{
- return m.image();
-}
-
#endif /* SQUID_HTTPREQUESTMETHOD_H */
--- squid3/src/ICMP.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,153 +0,0 @@
-/*
- * $Id: ICMP.h,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-#ifndef _INCLUDE_ICMP_H
-#define _INCLUDE_ICMP_H
-
-#include "config.h"
-#include "IPAddress.h"
-
-#define PINGER_PAYLOAD_SZ 8192
-
-#define MAX_PAYLOAD 256 // WAS: SQUIDHOSTNAMELEN
-#define MAX_PKT4_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmphdr) + 1)
-#if USE_IPV6
-#define MAX_PKT6_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmp6_hdr) + 1)
-#endif
-
-#if USE_ICMP
-
-/* This is a line-data format struct. DO NOT alter. */
-struct pingerEchoData
-{
- IPAddress to;
- unsigned char opcode;
- int psize;
- char payload[PINGER_PAYLOAD_SZ];
-};
-
-/* This is a line-data format struct. DO NOT alter. */
-struct pingerReplyData
-{
- IPAddress from;
- unsigned char opcode;
- int rtt;
- int hops;
- int psize;
- char payload[PINGER_PAYLOAD_SZ];
-};
-
-struct icmpEchoData
-{
- struct timeval tv;
- unsigned char opcode;
- char payload[MAX_PAYLOAD];
-};
-
-SQUIDCEXTERN int icmp_pkts_sent;
-
-#endif /* USE_ICMP */
-
-
-/**
- * Implements the squid interface to access ICMP operations
- *
- \par
- * Child implementations define specific parts of these operations
- * using these methods as a naming and parameter template.
- *
- * ICMPSquid - implements the squid side of squid-pinger interface
- * ICMPPinger - implements the pinger side of the squid-pinger interface
- * ICMPv4 - implements pinger helper for ICMPv4
- * ICMPv6 - implements pinger helper for ICMPv6
- */
-class ICMP
-{
-public:
- ICMP();
- virtual ~ICMP() {};
-
- /// Start pinger helper and initiate control channel
- virtual int Open() =0;
-
- /// Shutdown pinger helper and control channel
- virtual void Close();
-
-#if USE_ICMP
-
- /**
- * Construct and Send an ECHO request
- *
- \param to Destination address being 'pinged'
- \param opcode Specific code for ECHO request, see RFC ????.
- \param payload A payload MAY be sent in the ICMP message.
- * Content longer than MAX_PAYLOAD will be truncated.
- \param len Length of the payload in bytes if any is to be sent or 0.
- */
- virtual void SendEcho(IPAddress &to, int opcode, const char *payload=NULL, int len=0) =0;
-
- /// Handle ICMP responses.
- virtual void Recv(void) =0;
-
-protected:
- /* shared internal methods */
-
- /// Calculate a packet checksum
- int CheckSum(unsigned short *ptr, int size);
-
- /**
- * Translate TTL to a hop distance
- *
- \param ttl negative : n > 33
- \param ttl n(0...32) : 32 >= n >= 1
- \param ttl n(33...62) : 32 >= n >= 1
- \param ttl n(63...64) : 2 >= n >= 1
- \param ttl n(65...128) : 64 >= n >= 1
- \param ttl n(129...192) : 64 >= n >= 1
- \param ttl n(193...) : n < 255
- *
- \bug BUG? ttl<0 can produce high hop values
- \bug BUG? ttl>255 can produce zero or negative hop values
- */
- int ipHops(int ttl);
-
- /// Log the packet.
- void Log(const IPAddress &addr, const u_int8_t type, const char* pkt_str, const int rtt, const int hops);
-
- /* no use wasting memory */
- int icmp_sock;
- int icmp_ident;
-#endif /* USE_ICMP */
-};
-
-#endif
--- squid3/src/ICMPPinger.cc Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,237 +0,0 @@
-/*
- * $Id: ICMPPinger.cc,v 1.1.4.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 42 ICMP Pinger program
- * AUTHOR: Duane Wessels
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#define SQUID_HELPER 1
-
-#include "squid.h"
-
-#if USE_ICMP
-
-#include "SquidTime.h"
-#include "ICMPPinger.h"
-#include "ICMPv4.h"
-#include "ICMPv6.h"
-#include "Debug.h"
-
-ICMPPinger::ICMPPinger() : ICMP()
-{
- // these start invalid. Setup properly in Open()
- socket_from_squid = -1;
- socket_to_squid = -1;
-}
-
-ICMPPinger::~ICMPPinger()
-{
- Close();
-}
-
-int
-ICMPPinger::Open(void)
-{
-#ifdef _SQUID_MSWIN_
-
- WSADATA wsaData;
- WSAPROTOCOL_INFO wpi;
- char buf[sizeof(wpi)];
- int x;
-
- struct sockaddr_in PS;
-
- WSAStartup(2, &wsaData);
-
- getCurrentTime();
- _db_init(NULL, "ALL,1");
- setmode(0, O_BINARY);
- setmode(1, O_BINARY);
- x = read(0, buf, sizeof(wpi));
-
- if (x < (int)sizeof(wpi)) {
- getCurrentTime();
- debugs(42, 0, HERE << "read: FD 0: " << xstrerror());
- write(1, "ERR\n", 4);
- return -1;
- }
-
- xmemcpy(&wpi, buf, sizeof(wpi));
-
- write(1, "OK\n", 3);
- x = read(0, buf, sizeof(PS));
-
- if (x < (int)sizeof(PS)) {
- getCurrentTime();
- debugs(42, 0, HERE << "read: FD 0: " << xstrerror());
- write(1, "ERR\n", 4);
- return -1;
- }
-
- xmemcpy(&PS, buf, sizeof(PS));
-
- icmp_sock = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, &wpi, 0, 0);
-
- if (icmp_sock == -1) {
- getCurrentTime();
- debugs(42, 0, HERE << "WSASocket: " << xstrerror());
- write(1, "ERR\n", 4);
- return -1;
- }
-
- x = connect(icmp_sock, (struct sockaddr *) &PS, sizeof(PS));
-
- if (SOCKET_ERROR == x) {
- getCurrentTime();
- debugs(42, 0, HERE << "connect: " << xstrerror());
- write(1, "ERR\n", 4);
- return -1;
- }
-
- write(1, "OK\n", 3);
- memset(buf, 0, sizeof(buf));
- x = recv(icmp_sock, (void *) buf, sizeof(buf), 0);
-
- if (x < 3) {
- debugs(42, 0, HERE << "recv: " << xstrerror());
- return -1;
- }
-
- x = send(icmp_sock, (const void *) buf, strlen(buf), 0);
-
- if (x < 3 || strncmp("OK\n", buf, 3)) {
- debugs(42, 0, HERE << "recv: " << xstrerror());
- return -1;
- }
-
- getCurrentTime();
- debugs(42, 1, "pinger: Squid socket opened");
-
- /* windows uses a socket stream as a dual-direction channel */
- socket_to_squid = icmp_sock;
- socket_from_squid = icmp_sock;
-
- return icmp_sock;
-
-#else /* !_SQUID_MSWIN_ */
-
- /* non-windows apps use stdin/out pipes as the squid channel(s) */
- socket_from_squid = 0; // use STDIN macro ??
- socket_to_squid = 1; // use STDOUT macro ??
- return socket_to_squid;
-#endif
-}
-
-void
-ICMPPinger::Close(void)
-{
-#ifdef _SQUID_MSWIN_
-
- shutdown(icmp_sock, SD_BOTH);
- close(icmp_sock);
- icmp_sock = -1;
-#endif
-
- /* also shutdown the helper engines */
- icmp4.Close();
-#if USE_IPV6
- icmp6.Close();
-#endif
-}
-
-void
-ICMPPinger::Recv(void)
-{
- static pingerEchoData pecho;
- int n;
- int guess_size;
-
- memset(&pecho, '\0', sizeof(pecho));
- n = recv(socket_from_squid, &pecho, sizeof(pecho), 0);
-
- if (n < 0) {
- debugs(42, 1, "Pinger exiting.");
- Close();
- exit(1);
- }
-
- if (0 == n) {
- /* EOF indicator */
- debugs(42, 0, HERE << "EOF encountered. Pinger exiting.\n");
- errno = 0;
- Close();
- exit(1);
- }
-
- guess_size = n - (sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ);
-
- if (guess_size != pecho.psize) {
- debugs(42, 2, HERE << "size mismatch, guess=" << guess_size << ", psize=" << pecho.psize);
- /* don't process this message, but keep running */
- return;
- }
-
-#if USE_IPV6
- /* pass request for ICMPv6 handing */
- if(pecho.to.IsIPv6()) {
- debugs(42, 2, HERE << " Pass " << pecho.to << " off to ICMPv6 module.");
- icmp6.SendEcho(pecho.to,
- pecho.opcode,
- pecho.payload,
- pecho.psize);
- }
-#endif
-
- /* pass the packet for ICMP handling */
- else if(pecho.to.IsIPv4()) {
- debugs(42, 2, HERE << " Pass " << pecho.to << " off to ICMPv4 module.");
- icmp4.SendEcho(pecho.to,
- pecho.opcode,
- pecho.payload,
- pecho.psize);
- }
- else {
- debugs(42, 1, HERE << " IP has unknown Type. " << pecho.to );
- }
-}
-
-void
-ICMPPinger::SendResult(pingerReplyData &preply, int len)
-{
- debugs(42, 2, HERE << "return result to squid. len=" << len);
-
- if (send(socket_to_squid, &preply, len, 0) < 0) {
- debugs(42, 0, "pinger: FATAL error on send: " << xstrerror());
- Close();
- exit(1);
- }
-}
-
-#endif /* USE_ICMP */
--- squid3/src/ICMPPinger.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,83 +0,0 @@
-/*
- * $Id: ICMPPinger.h,v 1.1.4.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-#ifndef _INCLUDE_ICMPPINGER_H
-#define _INCLUDE_ICMPPINGER_H
-
-#include "config.h"
-#include "ICMP.h"
-
-/**
- * Implements the interface to squid for ICMP operations
- */
-class ICMPPinger : public ICMP
-{
-public:
- ICMPPinger();
- virtual ~ICMPPinger();
-
- /// Start and initiate control channel to squid
- virtual int Open();
-
- /// Shutdown pinger helper and control channel
- virtual void Close();
-
-#if USE_ICMP
-
- /// Send ICMP results back to squid.
- void SendResult(pingerReplyData &preply, int len);
-
- /// Handle ICMP requests from squid, passing to helpers.
- virtual void Recv(void);
-
-private:
- // unused in ICMPPinger
- virtual void SendEcho(IPAddress &to, int opcode, const char *payload, int len) {};
-
- /**
- * Control channel(s) to squid.
- * May be STDIN/STDOUT pipes or an IP socket depending on the OS
- */
- int socket_from_squid;
- int socket_to_squid;
-#endif /* USE_ICMP */
-};
-
-#if USE_ICMP
-
-/// pinger helper contains one of these as a global object.
-SQUIDCEXTERN ICMPPinger control;
-
-#endif
-
-#endif
--- squid3/src/ICMPSquid.cc Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,303 +0,0 @@
-/*
- * $Id: ICMPSquid.cc,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#include "squid.h"
-#include "ICMPSquid.h"
-#include "comm.h"
-#include "SquidTime.h"
-
-// Instance global to be available in main() and elsewhere.
-ICMPSquid icmpEngine;
-
-#if USE_ICMP
-
-#define S_ICMP_ECHO 1
-#if DEAD_CODE
-#define S_ICMP_ICP 2
-#endif
-#define S_ICMP_DOM 3
-
-static void * hIpc;
-static pid_t pid;
-
-#endif /* USE_ICMP */
-
-
-ICMPSquid::ICMPSquid() : ICMP()
-{
- ; // nothing new.
-}
-
-ICMPSquid::~ICMPSquid()
-{
- Close();
-}
-
-
-#if USE_ICMP
-
-void
-ICMPSquid::SendEcho(IPAddress &to, int opcode, const char *payload, int len)
-{
- static pingerEchoData pecho;
- int x, slen;
-
- /** \li Does nothing if the pinger socket is not available. */
- if(icmp_sock < 0) {
- debugs(37, 2, HERE << " Socket Closed. Aborted send to " << pecho.to << ", opcode " << opcode << ", len " << pecho.psize);
- return;
- }
-
- /** \li If no payload is given or is set as NULL it will ignore payload and len */
- if(!payload)
- len = 0;
-
- /** \li Otherwise if len is 0, uses strlen() to detect length of payload.
- \bug This will result in part of the payload being truncated if it contains a NULL character.
- \bug Or it may result in a buffer over-run if the payload is not nul-terminated properly.
- */
- else if (payload && len == 0)
- len = strlen(payload);
-
- /** \li
- \bug If length specified or auto-detected is greater than the possible payload squid will die with an assert.
- \todo This should perhapse be reduced to a truncated payload? or no payload. A WARNING is due anyway.
- */
- assert(len <= PINGER_PAYLOAD_SZ);
-
- pecho.to = to;
-
- pecho.opcode = (unsigned char) opcode;
-
- pecho.psize = len;
-
- if(len > 0)
- xmemcpy(pecho.payload, payload, len);
-
- slen = sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ + pecho.psize;
-
- debugs(37, 2, HERE << "to " << pecho.to << ", opcode " << opcode << ", len " << pecho.psize);
-
- x = comm_udp_send(icmp_sock, (char *)&pecho, slen, 0);
-
- if (x < 0) {
- debugs(37, 1, HERE << "send: " << xstrerror());
-
- /** \li If the send results in ECONNREFUSED or EPIPE errors from helper, will cleanly shutdown the module. */
- /** \todo This should try restarting the helper a few times?? before giving up? */
- if (errno == ECONNREFUSED || errno == EPIPE) {
- Close();
- return;
- }
- /** All other send errors are ignored. */
- } else if (x != len) {
- debugs(37, 1, HERE << "Wrote " << x << " of " << slen << " bytes");
- }
-}
-
-// static Callback to wrap the squid-side ICMP handler.
-// the ICMPSquid::Recv cannot be declared both static and virtual.
-static void
-icmpSquidRecv(int unused1, void *unused2)
-{
- icmpEngine.Recv();
-}
-
-void
-ICMPSquid::Recv()
-{
- int n;
- static int fail_count = 0;
- pingerReplyData preply;
- static IPAddress F;
-
- commSetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
- memset(&preply, '\0', sizeof(pingerReplyData));
- n = comm_udp_recv(icmp_sock,
- (char *) &preply,
- sizeof(pingerReplyData),
- 0);
-
- if (n < 0 && EAGAIN != errno) {
- debugs(37, 1, HERE << "recv: " << xstrerror());
-
- if (errno == ECONNREFUSED)
- Close();
-
- if (errno == ECONNRESET)
- Close();
-
- if (++fail_count == 10)
- Close();
-
- return;
- }
-
- fail_count = 0;
-
- /** If its a test probe from the pinger. Do nothing. */
- if (n == 0) {
- return;
- }
-
- F = preply.from;
-
- F.SetPort(0);
-
- switch (preply.opcode) {
-
- case S_ICMP_ECHO:
- debugs(37,4, HERE << " ICMP_ECHO of " << preply.from << " gave: hops=" << preply.hops <<", rtt=" << preply.rtt);
- break;
-
- case S_ICMP_DOM:
- debugs(37,4, HERE << " DomainPing of " << preply.from << " gave: hops=" << preply.hops <<", rtt=" << preply.rtt);
- netdbHandlePingReply(F, preply.hops, preply.rtt);
- break;
-
- default:
- debugs(37, 1, HERE << "Bad opcode: " << preply.opcode << " from " << F);
- break;
- }
-}
-
-#endif /* USE_ICMP */
-
-void
-ICMPSquid::DomainPing(IPAddress &to, const char *domain)
-{
-#if USE_ICMP
- debugs(37, 4, HERE << "'" << domain << "' (" << to << ")");
- SendEcho(to, S_ICMP_DOM, domain, 0);
-#endif
-}
-
-int
-ICMPSquid::Open(void)
-{
-#if USE_ICMP
- const char *args[2];
- int rfd;
- int wfd;
- IPAddress localhost;
-
- /* User configured disabled. */
- if(!Config.pinger.enable) {
- Close();
- return -1;
- }
-
- args[0] = "(pinger)";
- args[1] = NULL;
- localhost.SetLocalhost();
-
- /*
- * Do NOT use IPC_DGRAM (=IPC_UNIX_DGRAM) here because you can't
- * send() more than 4096 bytes on a socketpair() socket (at
- * least on FreeBSD).
- */
- pid = ipcCreate(IPC_UDP_SOCKET,
- Config.pinger.program,
- args,
- "Pinger Socket",
- localhost,
- &rfd,
- &wfd,
- &hIpc);
-
- if (pid < 0)
- return -1;
-
- assert(rfd == wfd);
-
- icmp_sock = rfd;
-
- fd_note(icmp_sock, "pinger");
-
- commSetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
-
- commSetTimeout(icmp_sock, -1, NULL, NULL);
-
- debugs(37, 1, HERE << "Pinger socket opened on FD " << icmp_sock);
-
- /* Tests the pinger immediately using localhost */
-#if USE_IPV6
- SendEcho(localhost, S_ICMP_ECHO, "ip6-localhost");
-#endif
- if(localhost.SetIPv4())
- SendEcho(localhost, S_ICMP_ECHO, "localhost");
-
-#ifdef _SQUID_MSWIN_
-
- debugs(37, 4, HERE << "Pinger handle: 0x" << std::hex << hIpc << std::dec << ", PID: " << pid);
-
-#endif /* _SQUID_MSWIN_ */
-#endif /* USE_ICMP */
- return icmp_sock;
-}
-
-void
-ICMPSquid::Close(void)
-{
-#if USE_ICMP
-
- if (icmp_sock < 0)
- return;
-
- debugs(37, 1, HERE << "Closing Pinger socket on FD " << icmp_sock);
-
-#ifdef _SQUID_MSWIN_
-
- send(icmp_sock, (const void *) "$shutdown\n", 10, 0);
-
-#endif
-
- comm_close(icmp_sock);
-
-#ifdef _SQUID_MSWIN_
-
- if (hIpc) {
- if (WaitForSingleObject(hIpc, 12000) != WAIT_OBJECT_0) {
- getCurrentTime();
- debugs(37, 0, HERE << "WARNING: (pinger," << pid << ") didn't exit in 12 seconds");
- }
-
- CloseHandle(hIpc);
- }
-
-#endif
- icmp_sock = -1;
-
-#endif
-}
--- squid3/src/ICMPSquid.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,69 +0,0 @@
-/*
- * $Id: ICMPSquid.h,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-#ifndef _INCLUDE_ICMPSQUID_H
-#define _INCLUDE_ICMPSQUID_H
-
-#include "config.h"
-#include "ICMP.h"
-#include "IPAddress.h"
-
-/**
- * Implements a non-blocking pseudo-ICMP engine for squid internally.
- *
- * Rather than doing all the work itself it passes each request off to
- * an external pinger helper and returns results form that helper to squid.
- *
- * Provides ECHO-REQUEST, ECHO-REPLY in a protocol-neutral manner.
- */
-class ICMPSquid : public ICMP
-{
-public:
- ICMPSquid();
- virtual ~ICMPSquid();
-
- virtual int Open();
- virtual void Close();
-
- void DomainPing(IPAddress &to, const char *domain);
-
-#if USE_ICMP
- virtual void SendEcho(IPAddress &to, int opcode, const char* payload=NULL, int len=0);
- virtual void Recv(void);
-#endif
-};
-
-// global engine within squid.
-SQUIDCEXTERN ICMPSquid icmpEngine;
-
-#endif /* _INCLUDE_ICMPSQUID_H */
--- squid3/src/ICMPv4.cc Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,249 +0,0 @@
-/*
- * $Id: ICMPv4.cc,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 42 ICMP Pinger program
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-//#define SQUID_HELPER 1
-
-#include "squid.h"
-
-#if USE_ICMP
-
-#include "SquidTime.h"
-#include "ICMPv4.h"
-#include "ICMPPinger.h"
-#include "Debug.h"
-
-const char *icmpPktStr[] =
- {
- "Echo Reply",
- "ICMP 1",
- "ICMP 2",
- "Destination Unreachable",
- "Source Quench",
- "Redirect",
- "ICMP 6",
- "ICMP 7",
- "Echo",
- "ICMP 9",
- "ICMP 10",
- "Time Exceeded",
- "Parameter Problem",
- "Timestamp",
- "Timestamp Reply",
- "Info Request",
- "Info Reply",
- "Out of Range Type"
- };
-
-ICMPv4::ICMPv4() : ICMP()
-{
- ;
-}
-
-ICMPv4::~ICMPv4()
-{
- Close();
-}
-
-int
-ICMPv4::Open(void)
-{
- icmp_sock = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
-
- if (icmp_sock < 0) {
- debugs(50, 0, HERE << " icmp_sock: " << xstrerror());
- return -1;
- }
-
- icmp_ident = getpid() & 0xffff;
- debugs(42, 1, "pinger: ICMP socket opened.");
-
- return icmp_sock;
-}
-
-void
-ICMPv4::SendEcho(IPAddress &to, int opcode, const char *payload, int len)
-{
- int x;
- LOCAL_ARRAY(char, pkt, MAX_PKT4_SZ);
-
- struct icmphdr *icmp = NULL;
- icmpEchoData *echo;
- size_t icmp_pktsize = sizeof(struct icmphdr);
- struct addrinfo *S = NULL;
-
- memset(pkt, '\0', MAX_PKT4_SZ);
-
- icmp = (struct icmphdr *) (void *) pkt;
-
- /*
- * cevans - beware signed/unsigned issues in untrusted data from
- * the network!!
- */
- if (len < 0)
- {
- len = 0;
- }
-
- // Construct ICMP packet header
- icmp->icmp_type = ICMP_ECHO;
- icmp->icmp_code = 0;
- icmp->icmp_cksum = 0;
- icmp->icmp_id = icmp_ident;
- icmp->icmp_seq = (u_short) icmp_pkts_sent++;
-
- // Construct ICMP packet data content
- echo = (icmpEchoData *) (icmp + 1);
- echo->opcode = (unsigned char) opcode;
- memcpy(&echo->tv, ¤t_time, sizeof(struct timeval));
-
- icmp_pktsize += sizeof(struct timeval) + sizeof(char);
-
- if (payload)
- {
- if (len > MAX_PAYLOAD)
- len = MAX_PAYLOAD;
-
- xmemcpy(echo->payload, payload, len);
-
- icmp_pktsize += len;
- }
-
- icmp->icmp_cksum = CheckSum((u_short *) icmp, icmp_pktsize);
-
- to.GetAddrInfo(S);
- ((sockaddr_in*)S->ai_addr)->sin_port = 0;
- assert(icmp_pktsize <= MAX_PKT4_SZ);
-
- debugs(42, 2, HERE << "Send ICMP packet to " << to << ".");
-
- x = sendto(icmp_sock,
- (const void *) pkt,
- icmp_pktsize,
- 0,
- S->ai_addr,
- S->ai_addrlen);
-
- if(x < 0) {
- debugs(42, 1, HERE << "Error sending to ICMP packet to " << to << ". ERR: " << xstrerror());
- }
-
- Log(to, ' ', NULL, 0, 0);
-}
-
-void
-ICMPv4::Recv(void)
-{
- int n;
- struct addrinfo *from = NULL;
- int iphdrlen = sizeof(iphdr);
- struct iphdr *ip = NULL;
- struct icmphdr *icmp = NULL;
- static char *pkt = NULL;
- struct timeval now;
- icmpEchoData *echo;
- static pingerReplyData preply;
-
- if(icmp_sock < 0) {
- debugs(42, 0, HERE << "No socket! Recv() should not be called.");
- return;
- }
-
- if (pkt == NULL)
- pkt = (char *)xmalloc(MAX_PKT4_SZ);
-
- preply.from.InitAddrInfo(from);
- n = recvfrom(icmp_sock,
- (void *)pkt,
- MAX_PKT4_SZ,
- 0,
- from->ai_addr,
- &from->ai_addrlen);
-
- preply.from = *from;
-
-#if GETTIMEOFDAY_NO_TZP
-
- gettimeofday(&now);
-
-#else
-
- gettimeofday(&now, NULL);
-
-#endif
-
- debugs(42, 8, HERE << n << " bytes from " << preply.from);
-
- ip = (struct iphdr *) (void *) pkt;
-
-#if HAVE_STRUCT_IPHDR_IP_HL
-
- iphdrlen = ip->ip_hl << 2;
-
-#else /* HAVE_STRUCT_IPHDR_IP_HL */
-#if WORDS_BIGENDIAN
-
- iphdrlen = (ip->ip_vhl >> 4) << 2;
-
-#else
-
- iphdrlen = (ip->ip_vhl & 0xF) << 2;
-
-#endif
-#endif /* HAVE_STRUCT_IPHDR_IP_HL */
-
- icmp = (struct icmphdr *) (void *) (pkt + iphdrlen);
-
- if (icmp->icmp_type != ICMP_ECHOREPLY)
- return;
-
- if (icmp->icmp_id != icmp_ident)
- return;
-
- echo = (icmpEchoData *) (void *) (icmp + 1);
-
- preply.opcode = echo->opcode;
-
- preply.hops = ipHops(ip->ip_ttl);
-
- struct timeval tv;
- memcpy(&tv, &echo->tv, sizeof(struct timeval));
- preply.rtt = tvSubMsec(tv, now);
-
- preply.psize = n - iphdrlen - (sizeof(icmpEchoData) - MAX_PKT4_SZ);
-
- control.SendResult(preply, (sizeof(pingerReplyData) - MAX_PKT4_SZ + preply.psize) );
-
- Log(preply.from, icmp->icmp_type, icmpPktStr[icmp->icmp_type], preply.rtt, preply.hops);
-}
-
-#endif /* USE_ICMP */
--- squid3/src/ICMPv4.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,179 +0,0 @@
-/*
- * $Id: ICMPv4.h,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-#ifndef _INCLUDE_ICMPV4_H
-#define _INCLUDE_ICMPV4_H
-
-#include "config.h"
-#include "ICMP.h"
-#include "IPAddress.h"
-
-#if HAVE_NETINET_IN_SYSTM_H
-#include
-#endif
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if HAVE_NETINET_IP_H
-#include
-#endif
-#if HAVE_NETINET_IP_ICMP_H
-#include
-#endif
-
-/* Linux uses its own field names. */
-#if defined (_SQUID_LINUX_)
-#ifdef icmp_id
-#undef icmp_id
-#endif
-#ifdef icmp_seq
-#undef icmp_seq
-#endif
-#define icmp_type type
-#define icmp_code code
-#define icmp_cksum checksum
-#define icmp_id un.echo.id
-#define icmp_seq un.echo.sequence
-#define ip_hl ihl
-#define ip_v version
-#define ip_tos tos
-#define ip_len tot_len
-#define ip_id id
-#define ip_off frag_off
-#define ip_ttl ttl
-#define ip_p protocol
-#define ip_sum check
-#define ip_src saddr
-#define ip_dst daddr
-#endif
-
-
-/* Native Windows port doesn't have netinet support, so we emulate it.
- At this time, Cygwin lacks icmp support in its include files, so we need
- to use the native Windows port definitions.
- */
-
-#ifdef _SQUID_WIN32_
-
-#include "fde.h"
-
-#ifdef _SQUID_MSWIN_
-
-#include
-#include
-
-#endif
-
-/* IP Header */
-typedef struct iphdr
-{
-
-u_int8_t ip_vhl:
- 4; /* Length of the header in dwords */
-
-u_int8_t version:
- 4; /* Version of IP */
- u_int8_t tos; /* Type of service */
- u_int16_t total_len; /* Length of the packet in dwords */
- u_int16_t ident; /* unique identifier */
- u_int16_t flags; /* Flags */
- u_int8_t ip_ttl; /* Time to live */
- u_int8_t proto; /* Protocol number (TCP, UDP etc) */
- u_int16_t checksum; /* IP checksum */
- u_int32_t source_ip;
- u_int32_t dest_ip;
-}
-iphdr;
-
-/* ICMP header */
-typedef struct icmphdr
-{
- u_int8_t icmp_type; /* ICMP packet type */
- u_int8_t icmp_code; /* Type sub code */
- u_int16_t icmp_cksum;
- u_int16_t icmp_id;
- u_int16_t icmp_seq;
- u_int32_t timestamp; /* not part of ICMP, but we need it */
-}
-icmphdr;
-
-#endif /* _SQUID_MSWIN_ */
-
-#ifndef ICMP_ECHO
-#define ICMP_ECHO 8
-#endif
-
-#ifndef ICMP_ECHOREPLY
-#define ICMP_ECHOREPLY 0
-#endif
-
-#ifndef IPPROTO_ICMP
-#define IPPROTO_ICMP 1
-#endif
-
-/* some OS apparently define icmp instead of icmphdr */
-#if !defined(icmphdr) && defined(icmp)
-#define icmphdr icmp
-#endif
-
-/* some OS apparently define ip instead of iphdr */
-#if !defined(iphdr) && defined(ip)
-#define iphdr ip
-#endif
-
-/**
- * Class partially implementing RFC 792 - ICMP for IP version 4.
- * Provides ECHO-REQUEST, ECHO-REPLY (secion 4.1)
- */
-class ICMPv4 : public ICMP
-{
-public:
- ICMPv4();
- virtual ~ICMPv4();
-
- virtual int Open();
-
-#if USE_ICMP
- virtual void SendEcho(IPAddress &, int, const char*, int);
- virtual void Recv(void);
-#endif
-};
-
-#if USE_ICMP
-
-/// pinger helper contains one of these as a global object.
-SQUIDCEXTERN ICMPv4 icmp4;
-
-#endif /* USE_ICMP && SQUID_HELPER */
-
-#endif
--- squid3/src/ICMPv6.cc Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,345 +0,0 @@
-/*
- * $Id: ICMPv6.cc,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 42 ICMP Pinger program
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-//#define SQUID_HELPER 1
-
-#include "squid.h"
-
-#if USE_ICMP && USE_IPV6
-
-#include "SquidTime.h"
-#include "Debug.h"
-#include "ICMPv6.h"
-#include "ICMPPinger.h"
-
-// Some system headers are only neeed internally here.
-// They should not be included via the header.
-
-#if HAVE_NETINET_IP6_H
-#include
-#endif
-
-// ICMPv6 OP-Codes
-// see http://www.iana.org/assignments/icmpv6-parameters
-// NP: LowPktStr is for codes 0-127
-static const char *icmp6LowPktStr[] =
- {
- "ICMP 0", // 0
- "Destination Unreachable", // 1 - RFC2463
- "Packet Too Big", // 2 - RFC2463
- "Time Exceeded", // 3 - RFC2463
- "Parameter Problem", // 4 - RFC2463
- "ICMP 5", // 5
- "ICMP 6", // 6
- "ICMP 7", // 7
- "ICMP 8", // 8
- "ICMP 9", // 9
- "ICMP 10" // 10
- };
-
-// NP: HighPktStr is for codes 128-255
-static const char *icmp6HighPktStr[] =
- {
- "Echo Request", // 128 - RFC2463
- "Echo Reply", // 129 - RFC2463
- "Multicast Listener Query", // 130 - RFC2710
- "Multicast Listener Report", // 131 - RFC2710
- "Multicast Listener Done", // 132 - RFC2710
- "Router Solicitation", // 133 - RFC4861
- "Router Advertisement", // 134 - RFC4861
- "Neighbor Solicitation", // 135 - RFC4861
- "Neighbor Advertisement", // 136 - RFC4861
- "Redirect Message", // 137 - RFC4861
- "Router Renumbering", // 138 - Crawford
- "ICMP Node Information Query", // 139 - RFC4620
- "ICMP Node Information Response", // 140 - RFC4620
- "Inverse Neighbor Discovery Solicitation", // 141 - RFC3122
- "Inverse Neighbor Discovery Advertisement", // 142 - RFC3122
- "Version 2 Multicast Listener Report", // 143 - RFC3810
- "Home Agent Address Discovery Request", // 144 - RFC3775
- "Home Agent Address Discovery Reply", // 145 - RFC3775
- "Mobile Prefix Solicitation", // 146 - RFC3775
- "Mobile Prefix Advertisement", // 147 - RFC3775
- "Certification Path Solicitation", // 148 - RFC3971
- "Certification Path Advertisement", // 149 - RFC3971
- "ICMP Experimental (150)", // 150 - RFC4065
- "Multicast Router Advertisement", // 151 - RFC4286
- "Multicast Router Solicitation", // 152 - RFC4286
- "Multicast Router Termination", // 153 - [RFC4286]
- "ICMP 154",
- "ICMP 155",
- "ICMP 156",
- "ICMP 157",
- "ICMP 158",
- "ICMP 159",
- "ICMP 160"
- };
-
-ICMPv6::ICMPv6() : ICMP()
-{
- ; // nothing new.
-}
-
-ICMPv6::~ICMPv6()
-{
- Close();
-}
-
-int
-ICMPv6::Open(void)
-{
- icmp_sock = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
-
- if (icmp_sock < 0) {
- debugs(50, 0, HERE << " icmp_sock: " << xstrerror());
- return -1;
- }
-
- icmp_ident = getpid() & 0xffff;
- debugs(42, 1, "pinger: ICMPv6 socket opened");
-
- return icmp_sock;
-}
-
-/**
- * Generates an RFC 4443 ICMPv6 ECHO Packet and sends into the network.
- */
-void
-ICMPv6::SendEcho(IPAddress &to, int opcode, const char *payload, int len)
-{
- int x;
- LOCAL_ARRAY(char, pkt, MAX_PKT6_SZ);
- struct icmp6_hdr *icmp = NULL;
- icmpEchoData *echo = NULL;
- struct addrinfo *S = NULL;
- size_t icmp6_pktsize = 0;
-
- memset(pkt, '\0', MAX_PKT6_SZ);
- icmp = (struct icmp6_hdr *)pkt;
-
- /*
- * cevans - beware signed/unsigned issues in untrusted data from
- * the network!!
- */
- if (len < 0) {
- len = 0;
- }
-
- // Construct ICMPv6 ECHO header
- icmp->icmp6_type = ICMP6_ECHO_REQUEST;
- icmp->icmp6_code = 0;
- icmp->icmp6_cksum = 0;
- icmp->icmp6_id = icmp_ident;
- icmp->icmp6_seq = (u_short) icmp_pkts_sent++;
-
- icmp6_pktsize = sizeof(struct icmp6_hdr);
-
-
- // Fill ICMPv6 ECHO data content
- echo = (icmpEchoData *) (pkt + sizeof(icmp6_hdr));
- echo->opcode = (unsigned char) opcode;
- memcpy(&echo->tv, ¤t_time, sizeof(struct timeval));
-
- icmp6_pktsize += sizeof(struct timeval) + sizeof(char);
-
- if (payload)
- {
- if (len > MAX_PAYLOAD)
- len = MAX_PAYLOAD;
-
- xmemcpy(echo->payload, payload, len);
-
- icmp6_pktsize += len;
- }
-
- icmp->icmp6_cksum = CheckSum((u_short *) icmp, icmp6_pktsize);
-
- to.GetAddrInfo(S);
- ((sockaddr_in6*)S->ai_addr)->sin6_port = 0;
-
- assert(icmp6_pktsize <= MAX_PKT6_SZ);
-
- debugs(42, 5, HERE << "Send ICMPv6 packet to " << to << ".");
-
- x = sendto(icmp_sock,
- (const void *) pkt,
- icmp6_pktsize,
- 0,
- S->ai_addr,
- S->ai_addrlen);
-
- if(x < 0) {
- debugs(42, 1, HERE << "Error sending to ICMPv6 packet to " << to << ". ERR: " << xstrerror());
- }
- debugs(42,9, HERE << "x=" << x);
-
- Log(to, 0, NULL, 0, 0);
-}
-
-/**
- * Reads an RFC 4443 ICMPv6 ECHO-REPLY Packet from the network.
- */
-void
-ICMPv6::Recv(void)
-{
- int n;
- struct addrinfo *from = NULL;
-// struct ip6_hdr *ip = NULL;
- static char *pkt = NULL;
- struct icmp6_hdr *icmp6 = NULL;
- icmpEchoData *echo = NULL;
- struct timeval now;
- static pingerReplyData preply;
-
- if(icmp_sock < 0) {
- debugs(42,0, HERE << "dropping ICMPv6 read. No socket!?");
- return;
- }
-
- if (pkt == NULL) {
- pkt = (char *)xmalloc(MAX_PKT6_SZ);
- }
-
- preply.from.InitAddrInfo(from);
-
- n = recvfrom(icmp_sock,
- (void *)pkt,
- MAX_PKT6_SZ,
- 0,
- from->ai_addr,
- &from->ai_addrlen);
-
- preply.from = *from;
-
-#if GETTIMEOFDAY_NO_TZP
-
- gettimeofday(&now);
-
-#else
-
- gettimeofday(&now, NULL);
-
-#endif
-
- debugs(42, 8, HERE << n << " bytes from " << preply.from);
-
-// FIXME INET6 : The IPv6 Header (ip6_hdr) is not availble directly >:-(
-//
-// TTL still has to come from the IP header somewhere.
-// still need to strip and process it properly.
-// probably have to rely on RTT as given by timestamp in data sent and current.
-/* IPv6 Header Structures (linux)
-struct ip6_hdr
-
-// fields (via simple define)
-#define ip6_vfc // N.A
-#define ip6_flow // N/A
-#define ip6_plen // payload length.
-#define ip6_nxt // expect to be type 0x3a - ICMPv6
-#define ip6_hlim // MAX hops (always 64, but no guarantee)
-#define ip6_hops // HOPS!!! (can it be true??)
-
-
- ip = (struct ip6_hdr *) pkt;
- pkt += sizeof(ip6_hdr);
-
-debugs(42,0, HERE << "ip6_nxt=" << ip->ip6_nxt <<
- ", ip6_plen=" << ip->ip6_plen <<
- ", ip6_hlim=" << ip->ip6_hlim <<
- ", ip6_hops=" << ip->ip6_hops <<
- " ::: 40 == sizef(ip6_hdr) == " << sizeof(ip6_hdr)
-);
-*/
-
- icmp6 = (struct icmp6_hdr *) pkt;
- pkt += sizeof(icmp6_hdr);
-
- if (icmp6->icmp6_type != ICMP6_ECHO_REPLY) {
-
- switch(icmp6->icmp6_type) {
- case 134:
- case 135:
- case 136:
- /* ignore Router/Neighbour Advertisements */
- break;
-
- default:
- debugs(42, 8, HERE << preply.from << " said: " << icmp6->icmp6_type << "/" << (int)icmp6->icmp6_code << " " <<
- ( icmp6->icmp6_type&0x80 ? icmp6HighPktStr[(int)(icmp6->icmp6_type&0x7f)] : icmp6LowPktStr[(int)(icmp6->icmp6_type&0x7f)] )
- );
- }
- return;
- }
-
- if (icmp6->icmp6_id != icmp_ident) {
- debugs(42, 8, HERE << "dropping ICMPv6 read. IDENT check failed. ident=='" << icmp_ident << "'=='" << icmp6->icmp6_id << "'");
- return;
- }
-
- echo = (icmpEchoData *) pkt;
-
- preply.opcode = echo->opcode;
-
- struct timeval tv;
- memcpy(&tv, &echo->tv, sizeof(struct timeval));
- preply.rtt = tvSubMsec(tv, now);
-
-/*
- * FIXME INET6: Without access to the IPv6-Hops header we must rely on the total RTT
- * and could caculate the hops from that, but it produces some weird value mappings using ipHops
- * for now everything is 1 v6 hop away with variant RTT
- * WANT: preply.hops = ip->ip6_hops; // ipHops(ip->ip_hops);
- */
- preply.hops = 1;
-
- preply.psize = n - /* sizeof(ip6_hdr) - */ sizeof(icmp6_hdr) - (sizeof(icmpEchoData) - MAX_PKT6_SZ);
-
- /* Ensure the response packet has safe payload size */
- if( preply.psize > (unsigned short) MAX_PKT6_SZ) {
- preply.psize = MAX_PKT6_SZ;
- }
- else if( preply.psize < (unsigned short)0) {
- preply.psize = 0;
- }
-
- Log(preply.from,
- icmp6->icmp6_type,
- ( icmp6->icmp6_type&0x80 ? icmp6HighPktStr[(int)(icmp6->icmp6_type&0x7f)] : icmp6LowPktStr[(int)(icmp6->icmp6_type&0x7f)] ),
- preply.rtt,
- preply.hops);
-
- /* send results of the lookup back to squid.*/
- control.SendResult(preply, (sizeof(pingerReplyData) - PINGER_PAYLOAD_SZ + preply.psize) );
-}
-
-#endif /* USE_ICMP && USE_IPV6 */
--- squid3/src/ICMPv6.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,96 +0,0 @@
-/*
- * $Id: ICMPv6.h,v 1.1.8.1 2008/01/25 02:33:42 valexey_eykon Exp $
- *
- * DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-#ifndef _INCLUDE_ICMPV6_H
-#define _INCLUDE_ICMPV6_H
-
-#include "config.h"
-
-#if USE_IPV6
-
-#include "ICMP.h"
-#include "IPAddress.h"
-
-#if HAVE_NETINET_IN_H
-#include
-#endif
-#if HAVE_NETINET_ICMP6_H
-#include
-#endif
-#if HAVE_NETINET_IP6_H
-#include
-#endif
-
-/* see RFC 4443 section 2.1 */
-#ifndef ICMP6_ECHOREQUEST
-#define ICMP6_ECHOREQUEST 128
-#endif
-
-/* see RFC 4443 section 2.1 */
-#ifndef ICMP6_ECHOREPLY
-#define ICMP6_ECHOREPLY 129
-#endif
-
-/* see RFC 4443 section 2.1 */
-#ifndef IPPROTO_ICMPV6
-#define IPPROTO_ICMPV6 58
-#endif
-
-/**
- * Class partially implementing RFC 4443 - ICMPv6 for IP version 6.
- * Provides ECHO-REQUEST, ECHO-REPLY (secion 4)
- */
-class ICMPv6 : public ICMP
-{
-public:
- ICMPv6();
- virtual ~ICMPv6();
-
- virtual int Open();
-
-#if USE_ICMP
- virtual void SendEcho(IPAddress &, int, const char*, int);
- virtual void Recv(void);
-#endif
-};
-
-#if USE_ICMP
-
-/// pinger helper contains one of these as a global object.
-SQUIDCEXTERN ICMPv6 icmp6;
-
-#endif /* USE_ICMP && SQUID_HELPER */
-
-#endif /* USE_IPV6 */
-
-#endif /* _INCLUDE_ICMPV6_H */
Index: squid3/src/ICP.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ICP.h,v
retrieving revision 1.8.6.2
retrieving revision 1.8.6.3
diff -u -r1.8.6.2 -r1.8.6.3
--- squid3/src/ICP.h 25 Jan 2008 02:33:42 -0000 1.8.6.2
+++ squid3/src/ICP.h 27 Jan 2008 18:08:48 -0000 1.8.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: ICP.h,v 1.8.6.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: ICP.h,v 1.8.6.3 2008/01/27 18:08:48 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -55,7 +55,7 @@
_icp_common_t();
_icp_common_t(char *buf, unsigned int len);
- void handleReply(char *buf, IPAddress &from);
+ void handleReply(char *buf, struct sockaddr_in *from);
static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
icp_opcode getOpCode() const;
#endif
@@ -82,7 +82,7 @@
HttpRequest *request;
int fd;
- IPAddress from;
+ struct sockaddr_in from;
char *url;
};
@@ -90,7 +90,8 @@
struct icpUdpData
{
- IPAddress address;
+
+ struct sockaddr_in address;
void *msg;
size_t len;
icpUdpData *next;
@@ -105,21 +106,21 @@
};
-HttpRequest* icpGetRequest(char *url, int reqnum, int fd, IPAddress &from);
+HttpRequest* icpGetRequest(char *url, int reqnum, int fd, struct sockaddr_in *from);
-int icpAccessAllowed(IPAddress &from, HttpRequest * icp_request);
+int icpAccessAllowed(struct sockaddr_in *from, HttpRequest * icp_request);
-SQUIDCEXTERN void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const IPAddress &from);
+SQUIDCEXTERN void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const struct sockaddr_in *from);
extern icp_opcode icpGetCommonOpcode();
-SQUIDCEXTERN int icpUdpSend(int, const IPAddress &, icp_common_t *, log_type, int);
+SQUIDCEXTERN int icpUdpSend(int, const struct sockaddr_in *, icp_common_t *, log_type, int);
SQUIDCEXTERN log_type icpLogFromICPCode(icp_opcode opcode);
-void icpDenyAccess(IPAddress &from, char *url, int reqnum, int fd);
+void icpDenyAccess(struct sockaddr_in *from, char *url, int reqnum, int fd);
SQUIDCEXTERN PF icpHandleUdp;
SQUIDCEXTERN PF icpUdpSendQueue;
-SQUIDCEXTERN void icpHandleIcpV3(int, IPAddress &, char *, int);
+SQUIDCEXTERN void icpHandleIcpV3(int, struct sockaddr_in, char *, int);
SQUIDCEXTERN int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
SQUIDCEXTERN void icpConnectionsOpen(void);
SQUIDCEXTERN void icpConnectionShutdown(void);
Index: squid3/src/IPInterception.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/IPInterception.cc,v
retrieving revision 1.12.18.2
retrieving revision 1.12.18.3
diff -u -r1.12.18.2 -r1.12.18.3
--- squid3/src/IPInterception.cc 25 Jan 2008 02:33:42 -0000 1.12.18.2
+++ squid3/src/IPInterception.cc 27 Jan 2008 18:08:48 -0000 1.12.18.3
@@ -1,6 +1,6 @@
/*
- * $Id: IPInterception.cc,v 1.12.18.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: IPInterception.cc,v 1.12.18.3 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 89 NAT / IP Interception
* AUTHOR: Robert Collins
@@ -91,11 +91,8 @@
#if IPF_TRANSPARENT
int
-clientNatLookup(int fd, const IPAddress &me, const IPAddress &peer, IPAddress &dst)
+clientNatLookup(int fd, struct sockaddr_in me, struct sockaddr_in peer, struct sockaddr_in *dst)
{
- dst = me;
- if( !me.IsIPv4() ) return -1;
- if( !peer.IsIPv4() ) return -1;
#if defined(IPFILTER_VERSION) && (IPFILTER_VERSION >= 4000027)
@@ -120,10 +117,10 @@
obj.ipfo_offset = 0;
#endif
- natLookup.nl_inport = htons(me.GetPort());
- natLookup.nl_outport = htons(peer.GetPort());
- me.GetInAddr(natLookup.nl_inip);
- peer.GetInAddr(natLookup.nl_outip);
+ natLookup.nl_inport = me.sin_port;
+ natLookup.nl_outport = peer.sin_port;
+ natLookup.nl_inip = me.sin_addr;
+ natLookup.nl_outip = peer.sin_addr;
natLookup.nl_flags = IPN_TCP;
if (natfd < 0)
@@ -189,12 +186,12 @@
return -1;
} else
{
- if (me != natLookup.nl_realip) {
- dst = natLookup.nl_realip;
+ if (me.sin_addr.s_addr != natLookup.nl_realip.s_addr)
+ dst->sin_family = AF_INET;
- dst.SetPort(ntohs(natLookup.nl_realport));
- }
- // else. we already copied it.
+ dst->sin_port = natLookup.nl_realport;
+
+ dst->sin_addr = natLookup.nl_realip;
return 0;
}
@@ -202,21 +199,15 @@
#elif LINUX_NETFILTER
int
-clientNatLookup(int fd, const IPAddress &me, const IPAddress &peer, IPAddress &dst)
-{
- dst = me;
- if( !me.IsIPv4() ) return -1;
- if( !peer.IsIPv4() ) return -1;
+clientNatLookup(int fd, struct sockaddr_in me, struct sockaddr_in peer, struct sockaddr_in *dst)
+{
static time_t last_reported = 0;
- struct addrinfo *lookup = NULL;
-
- dst.GetAddrInfo(lookup,AF_INET);
+ socklen_t sock_sz = sizeof(*dst);
+ memcpy(dst, &me, sizeof(*dst));
- if (getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, lookup->ai_addr, &lookup->ai_addrlen) != 0)
+ if (getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, dst, &sock_sz) != 0)
{
- dst.FreeAddrInfo(lookup);
-
if (squid_curtime - last_reported > 60) {
debugs(89, 1, "clientNatLookup: NF getsockopt(SO_ORIGINAL_DST) failed: " << xstrerror());
last_reported = squid_curtime;
@@ -224,13 +215,10 @@
return -1;
}
- dst = *lookup;
- dst.FreeAddrInfo(lookup);
+ debugs(89, 5, "clientNatLookup: addr = " << inet_ntoa(dst->sin_addr) << "");
- debugs(89, 5, "clientNatLookup: addr = " << dst << "");
-
- if (me != dst)
+ if (me.sin_addr.s_addr != dst->sin_addr.s_addr)
return 0;
else
return -1;
@@ -239,16 +227,13 @@
#elif PF_TRANSPARENT
int
-clientNatLookup(int fd, const IPAddress &me, const IPAddress &peer, IPAddress dst)
+clientNatLookup(int fd, struct sockaddr_in me, struct sockaddr_in peer, struct sockaddr_in *dst)
{
struct pfioc_natlook nl;
static int pffd = -1;
static time_t last_reported = 0;
- if( !me.IsIPv4() ) return -1;
- if( !peer.IsIPv4() ) return -1;
-
if (pffd < 0)
pffd = open("/dev/pf", O_RDWR);
@@ -263,15 +248,13 @@
}
- dst.SetEmpty();
+ memset(dst, 0, sizeof(*dst));
memset(&nl, 0, sizeof(struct pfioc_natlook));
- peer.GetInAddr(nl.saddr.v4);
- nl.sport = htons(peer.GetPort());
-
- me.GetInAddr(nl.daddr.v4);
- nl.dport = htons(me.GetPort());
-
+ nl.saddr.v4.s_addr = peer.sin_addr.s_addr;
+ nl.sport = peer.sin_port;
+ nl.daddr.v4.s_addr = me.sin_addr.s_addr;
+ nl.dport = me.sin_port;
nl.af = AF_INET;
nl.proto = IPPROTO_TCP;
nl.direction = PF_OUT;
@@ -291,9 +274,10 @@
return -1;
} else
{
- int natted = (me != nl.rdaddr.v4);
- dst = nl.rdaddr.v4;
- dst.SetPort(ntohs(nl.rdport));
+ int natted = me.sin_addr.s_addr != nl.rdaddr.v4.s_addr;
+ dst->sin_family = AF_INET;
+ dst->sin_port = nl.rdport;
+ dst->sin_addr = nl.rdaddr.v4;
if (natted)
return 0;
@@ -304,40 +288,27 @@
#elif IPFW_TRANSPARENT
int
-clientNatLookup(int fd, const IPAddress &me, const IPAddress &peer, IPAddress &dst)
+clientNatLookup(int fd, struct sockaddr_in me, struct sockaddr_in peer, struct sockaddr_in *dst)
{
- int ret;
- struct addrinfo *lookup = NULL;
-
- if( !me.IsIPv4() ) return -1;
- if( !peer.IsIPv4() ) return -1;
-
- dst.GetAddrInfo(lookup,AF_INET);
-
- ret = getsockname(fd, lookup->ai_addr, &lookup->ai_addrlen);
-
- if (ret < 0) {
-
- dst.FreeAddrInfo(lookup);
-
- debugs(89, 1, "clientNatLookup: getpeername failed (fd " << fd << "), errstr " << xstrerror());
-
- return -1;
- }
-
- dst = *lookup;
-
- dst.FreeAddrInfo(lookup);
-
- return 0;
+ int ret;
+ struct sockaddr_in s;
+ int slen = sizeof(struct sockaddr_in);
+
+ ret = getsockname(fd, (struct sockaddr *) &s, (socklen_t * )&slen);
+ if (ret < 0) {
+ debugs(89, 1, "clientNatLookup: getpeername failed (fd " << fd << "), errstr " << xstrerror());
+ return -1;
+ }
+ *dst = s;
+ return 0;
}
#else
int
-clientNatLookup(int fd, const IPAddress &me, const IPAddress &peer, IPAddress &dst)
+clientNatLookup(int fd, struct sockaddr_in me, struct sockaddr_in peer, struct sockaddr_in *dst)
{
- debugs(89, 1, "WARNING: transparent proxying not supported");
- return -1;
+ debugs(89, 1, "WARNING: transparent proxying not supported");
+ return -1;
}
#endif
Index: squid3/src/IPInterception.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/IPInterception.h,v
retrieving revision 1.2.50.1
retrieving revision 1.2.50.2
diff -u -r1.2.50.1 -r1.2.50.2
--- squid3/src/IPInterception.h 25 Jan 2008 02:33:42 -0000 1.2.50.1
+++ squid3/src/IPInterception.h 27 Jan 2008 18:08:48 -0000 1.2.50.2
@@ -1,6 +1,6 @@
/*
- * $Id: IPInterception.h,v 1.2.50.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: IPInterception.h,v 1.2.50.2 2008/01/27 18:08:48 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -34,9 +34,8 @@
#ifndef SQUID_IPINTERCEPTION_H
#define SQUID_IPINTERCEPTION_H
-#include "IPAddress.h"
-
SQUIDCEXTERN int
-clientNatLookup(int fd, const IPAddress &me, const IPAddress &peer, IPAddress &dst);
+
+clientNatLookup(int fd, struct sockaddr_in me, struct sockaddr_in peer, struct sockaddr_in *dst);
#endif /* SQUID_IPINTERCEPTION_H */
Index: squid3/src/Makefile.am
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v
retrieving revision 1.131.6.4
retrieving revision 1.131.6.5
diff -u -r1.131.6.4 -r1.131.6.5
--- squid3/src/Makefile.am 25 Jan 2008 02:33:42 -0000 1.131.6.4
+++ squid3/src/Makefile.am 27 Jan 2008 18:08:48 -0000 1.131.6.5
@@ -1,7 +1,7 @@
#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.am,v 1.131.6.4 2008/01/25 02:33:42 valexey_eykon Exp $
+# $Id: Makefile.am,v 1.131.6.5 2008/01/27 18:08:48 rousskov Exp $
#
# Uncomment and customize the following to suit your needs:
#
@@ -127,22 +127,17 @@
PINGER =
endif
-# Squid Internal ICMP sources
-ICMPSOURCE = \
- ICMP.h \
- icmp.cc \
- ICMPConfig.h \
- ICMPSquid.h \
- ICMPSquid.cc
-
SSL_ALL_SOURCE = \
ACLCertificateData.cc \
ACLCertificateData.h \
ACLCertificate.cc \
ACLCertificate.h \
+ ACLSslError.cc \
+ ACLSslError.h \
+ ACLSslErrorData.cc \
+ ACLSslErrorData.h \
ssl_support.cc \
ssl_support.h
-
if ENABLE_SSL
SSL_SOURCE = $(SSL_ALL_SOURCE)
else
@@ -243,6 +238,7 @@
fs/aufs/StoreFSaufs.cc \
fs/coss/StoreFScoss.cc \
fs/diskd/StoreFSdiskd.cc \
+ fs/null/StoreFSnull.cc \
fs/ufs/StoreFSufs.cc
all_DISKIOMODULES = \
@@ -337,8 +333,6 @@
ACLMyIP.h \
ACLMyPort.cc \
ACLMyPort.h \
- ACLMyPortName.cc \
- ACLMyPortName.h \
ACLProtocol.cc \
ACLProtocol.h \
ACLProtocolData.cc \
@@ -428,14 +422,14 @@
authenticate.cc \
authenticate.h \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
CacheDigest.cc \
cache_manager.cc \
CacheManager.h \
carp.cc \
cbdata.cc \
cbdata.h \
- ChunkedCodingParser.cc \
- ChunkedCodingParser.h \
client_db.cc \
client_side.cc \
client_side.h \
@@ -519,7 +513,7 @@
HttpRequestMethod.cc \
HttpRequestMethod.h \
HttpVersion.h \
- $(ICMPSOURCE) \
+ icmp.cc \
ICP.h \
icp_v2.cc \
icp_v3.cc \
@@ -613,8 +607,6 @@
structs.h \
SwapDir.cc \
SwapDir.h \
- TextException.cc \
- TextException.h \
time.cc \
tools.cc \
tunnel.cc \
@@ -687,6 +679,8 @@
ICAP_libicap_a_SOURCES = \
ICAP/AsyncJob.cc \
ICAP/AsyncJob.h \
+ ICAP/ChunkedCodingParser.cc \
+ ICAP/ChunkedCodingParser.h \
ICAP/ICAPClient.cc \
ICAP/ICAPClient.h \
ICAP/ICAPInitiator.cc \
@@ -709,22 +703,14 @@
ICAP/ICAPServiceRep.cc \
ICAP/ICAPServiceRep.h \
ICAP/ICAPXaction.cc \
- ICAP/ICAPXaction.h
+ ICAP/ICAPXaction.h \
+ ICAP/TextException.cc \
+ ICAP/TextException.h
unlinkd_SOURCES = unlinkd_daemon.cc SquidNew.cc
-## NP: the pinger contains the squid-external helper code
-## $(ICMPSOURCE) contains the interface bit to go inside squid
pinger_SOURCES = \
- ICMP.h \
- icmp.cc \
- ICMPPinger.h \
- ICMPPinger.cc \
- ICMPv4.h \
- ICMPv4.cc \
- ICMPv6.h \
- ICMPv6.cc \
pinger.cc \
debug.cc \
time.cc \
@@ -742,6 +728,7 @@
## ACLProxyAuth.cc wants ACLRegexData
## cache_cf.cc wants libauth.la
## cache_cf.cc wants Swapdir
+## cache_cf.cc wants ProtoPort
## client_side wants client_db
## client_db wants SNMP_SOURCE
## snmp_core wants ACLStringData
@@ -781,12 +768,12 @@
ACLStringData.cc \
authenticate.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
cache_manager.cc \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
- ChunkedCodingParser.h \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -834,7 +821,7 @@
HttpReply.cc \
HttpRequest.cc \
HttpRequestMethod.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -889,8 +876,6 @@
store_swapout.cc \
structs.h \
SwapDir.cc \
- TextException.cc \
- TextException.h \
tools.cc \
typedefs.h \
$(UNLINKDSOURCE) \
@@ -1015,7 +1000,6 @@
DEFAULT_ACCESS_LOG = $(DEFAULT_LOG_PREFIX)/access.log
DEFAULT_STORE_LOG = $(DEFAULT_LOG_PREFIX)/store.log
DEFAULT_PID_FILE = $(DEFAULT_LOG_PREFIX)/squid.pid
-DEFAULT_NETDB_FILE = $(DEFAULT_LOG_PREFIX)/netdb.state
DEFAULT_SWAP_DIR = $(localstatedir)/cache
DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'`
DEFAULT_UNLINKD = $(libexecdir)/`echo unlinkd | sed '$(transform);s/$$/$(EXEEXT)/'`
@@ -1073,7 +1057,6 @@
s%@DEFAULT_ACCESS_LOG@%$(DEFAULT_ACCESS_LOG)%g;\
s%@DEFAULT_STORE_LOG@%$(DEFAULT_STORE_LOG)%g;\
s%@DEFAULT_PID_FILE@%$(DEFAULT_PID_FILE)%g;\
- s%@DEFAULT_NETDB_FILE@%$(DEFAULT_NETDB_FILE)%g;\
s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g;\
s%@DEFAULT_ICON_DIR@%$(DEFAULT_ICON_DIR)%g;\
s%@DEFAULT_MIB_PATH@%$(DEFAULT_MIB_PATH)%g;\
@@ -1147,7 +1130,6 @@
tests/testHeaders \
tests/test_http_range \
tests/testHttpRequest \
- tests/testICMP \
tests/testStore \
tests/testString \
tests/testURL \
@@ -1324,10 +1306,11 @@
BodyPipe.cc \
cache_manager.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -1365,7 +1348,7 @@
HttpMsg.cc \
HttpReply.cc \
HttpStatusLine.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -1418,7 +1401,6 @@
StoreMetaURL.cc \
StoreMetaVary.cc \
StoreSwapLogData.cc \
- TextException.cc \
tools.cc \
tunnel.cc \
SwapDir.cc \
@@ -1492,10 +1474,11 @@
BodyPipe.cc \
cache_manager.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -1533,7 +1516,7 @@
HttpMsg.cc \
HttpReply.cc \
HttpStatusLine.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -1585,7 +1568,6 @@
StoreMetaURL.cc \
StoreMetaVary.cc \
StoreSwapLogData.cc \
- TextException.cc \
tools.cc \
tunnel.cc \
SwapDir.cc \
@@ -1646,10 +1628,11 @@
BodyPipe.cc \
cache_manager.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -1687,7 +1670,7 @@
HttpMsg.cc \
HttpReply.cc \
HttpStatusLine.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -1739,7 +1722,6 @@
StoreMetaURL.cc \
StoreMetaVary.cc \
StoreSwapLogData.cc \
- TextException.cc \
tools.cc \
tunnel.cc \
SwapDir.cc \
@@ -1823,11 +1805,12 @@
authenticate.cc \
BodyPipe.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
cache_manager.cc \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -1869,7 +1852,7 @@
HttpRequest.cc \
HttpRequestMethod.cc \
HttpStatusLine.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -1923,7 +1906,6 @@
StoreSwapLogData.cc \
String.cc \
SwapDir.cc \
- TextException.cc \
time.cc \
tools.cc \
tunnel.cc \
@@ -1985,10 +1967,11 @@
BodyPipe.cc \
cache_manager.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -2026,7 +2009,7 @@
HttpMsg.cc \
HttpReply.cc \
HttpStatusLine.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -2079,7 +2062,6 @@
StoreMetaURL.cc \
StoreMetaVary.cc \
StoreSwapLogData.cc \
- TextException.cc \
tools.cc \
tunnel.cc \
SwapDir.cc \
@@ -2112,24 +2094,6 @@
@SQUID_CPPUNIT_LA@ \
@ICAP_LIBS@
-## Tests of the ICMP base module.
-# Its used by pinger so SHOULD NOT require more dependancies! :-(
-tests_testICMP_SOURCES=\
- ICMP.h \
- icmp.cc \
- tests/testICMP.h \
- tests/testICMP.cc \
- tests/testMain.cc \
- SquidTime.h \
- time.cc \
- $(TESTSOURCES)
-tests_testICMP_LDFLAGS = $(LIBADD_DL)
-tests_testICMP_LDADD=\
- @SQUID_CPPUNIT_LIBS@ \
- @SQUID_CPPUNIT_LA@ \
- -L../lib -lmiscutil
-tests_testICMP_DEPENDENCIES= @SQUID_CPPUNIT_LA@ \
- $(top_builddir)/lib/libmiscutil.a
# TODO:mime.cc drags in HttpReply.cc
# delay pools need client_side_request.cc
@@ -2343,10 +2307,11 @@
BodyPipe.cc \
cache_manager.cc \
cache_cf.cc \
+ ProtoPort.cc \
+ ProtoPort.h \
CacheDigest.cc \
carp.cc \
cbdata.cc \
- ChunkedCodingParser.cc \
client_db.cc \
client_side.cc \
client_side_reply.cc \
@@ -2384,7 +2349,7 @@
HttpMsg.cc \
HttpReply.cc \
HttpStatusLine.cc \
- $(ICMPSOURCE) \
+ icmp.cc \
icp_v2.cc \
icp_v3.cc \
$(IDENT_SOURCE) \
@@ -2436,7 +2401,6 @@
StoreMetaURL.cc \
StoreMetaVary.cc \
StoreSwapLogData.cc \
- TextException.cc \
tools.cc \
tunnel.cc \
SwapDir.cc \
Index: squid3/src/Mem.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Mem.h,v
retrieving revision 1.5.34.1
retrieving revision 1.5.34.2
diff -u -r1.5.34.1 -r1.5.34.2
--- squid3/src/Mem.h 25 Jan 2008 02:33:42 -0000 1.5.34.1
+++ squid3/src/Mem.h 27 Jan 2008 18:08:48 -0000 1.5.34.2
@@ -1,6 +1,6 @@
/*
- * $Id: Mem.h,v 1.5.34.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: Mem.h,v 1.5.34.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 13 High Level Memory Pool Management
* AUTHOR: Harvest Derived
@@ -47,7 +47,6 @@
public:
static void Init();
- static void Report();
static void RegisterWithCacheManager(CacheManager & manager);
static void Stats(StoreEntry *);
static void CleanIdlePools(void *unused);
Index: squid3/src/MemBuf.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/MemBuf.h,v
retrieving revision 1.8.34.1
retrieving revision 1.8.34.2
diff -u -r1.8.34.1 -r1.8.34.2
--- squid3/src/MemBuf.h 25 Jan 2008 02:33:42 -0000 1.8.34.1
+++ squid3/src/MemBuf.h 27 Jan 2008 18:08:48 -0000 1.8.34.2
@@ -1,7 +1,7 @@
/*
- * $Id: MemBuf.h,v 1.8.34.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: MemBuf.h,v 1.8.34.2 2008/01/27 18:08:48 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -60,7 +60,6 @@
// these space-related methods assume no growth and allow 0-termination
char *space() { return buf + size; } // space to add data
- char *space(mb_size_t required) { if (size + required > capacity) grow(size + required); return buf + size; } // space to add data
mb_size_t spaceSize() const;
bool hasSpace() const { return size+1 < capacity; }
Index: squid3/src/MemObject.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/MemObject.cc,v
retrieving revision 1.28.6.2
retrieving revision 1.28.6.3
diff -u -r1.28.6.2 -r1.28.6.3
--- squid3/src/MemObject.cc 25 Jan 2008 02:33:42 -0000 1.28.6.2
+++ squid3/src/MemObject.cc 27 Jan 2008 18:08:48 -0000 1.28.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: MemObject.cc,v 1.28.6.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: MemObject.cc,v 1.28.6.3 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 19 Store Memory Primitives
* AUTHOR: Robert Collins
@@ -214,7 +214,7 @@
MemObject::stat (MemBuf * mb) const
{
mb->Printf("\t%s %s\n",
- RequestMethodStr(method), log_url);
+ RequestMethodStr[method], log_url);
mb->Printf("\tinmem_lo: %"PRId64"\n", inmem_lo);
mb->Printf("\tinmem_hi: %"PRId64"\n", data_hdr.endOffset());
mb->Printf("\tswapout: %"PRId64" bytes queued\n",
Index: squid3/src/MemObject.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/MemObject.h,v
retrieving revision 1.15.6.1
retrieving revision 1.15.6.2
diff -u -r1.15.6.1 -r1.15.6.2
--- squid3/src/MemObject.h 25 Jan 2008 02:33:42 -0000 1.15.6.1
+++ squid3/src/MemObject.h 27 Jan 2008 18:08:48 -0000 1.15.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: MemObject.h,v 1.15.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: MemObject.h,v 1.15.6.2 2008/01/27 18:08:48 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -90,7 +90,7 @@
void checkUrlChecksum() const;
#endif
- HttpRequestMethod method;
+ method_t method;
char *url;
mem_hdr data_hdr;
int64_t inmem_lo;
Index: squid3/src/PeerSelectState.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/PeerSelectState.h,v
retrieving revision 1.2.34.1
retrieving revision 1.2.34.2
diff -u -r1.2.34.1 -r1.2.34.2
--- squid3/src/PeerSelectState.h 25 Jan 2008 02:33:42 -0000 1.2.34.1
+++ squid3/src/PeerSelectState.h 27 Jan 2008 18:08:48 -0000 1.2.34.2
@@ -1,6 +1,6 @@
/*
- * $Id: PeerSelectState.h,v 1.2.34.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: PeerSelectState.h,v 1.2.34.2 2008/01/27 18:08:48 rousskov Exp $
*
* AUTHOR: Robert Collins
*
@@ -38,7 +38,6 @@
#include "cbdata.h"
#include "PingData.h"
-#include "IPAddress.h"
class ps_state
{
@@ -55,22 +54,27 @@
void *callback_data;
FwdServer *servers;
/*
- * Why are these IPAddress instead of peer *? Because a
+ * Why are these struct sockaddr_in instead of peer *? Because a
* peer structure can become invalid during the peer selection
* phase, specifically after a reconfigure. Thus we need to lookup
* the peer * based on the address when we are finally ready to
* reference the peer structure.
*/
- IPAddress first_parent_miss;
+ struct sockaddr_in first_parent_miss;
- IPAddress closest_parent_miss;
+ struct sockaddr_in closest_parent_miss;
/*
- * ->hit can be peer* because it should only be
- * accessed during the thread when it is set
+ * ->hit and ->secho can be peer* because they should only be
+ * accessed during the thread when they are set
*/
peer *hit;
peer_t hit_type;
+#if ALLOW_SOURCE_PING
+
+ peer *secho;
+#endif
+
ping_data ping;
ACLChecklist *acl_checklist;
private:
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/src/ProtoPort.cc Wed Feb 6 01:24:20 2008
@@ -0,0 +1,43 @@
+
+/*
+ * $Id: ProtoPort.cc,v 1.1.2.4 2008/01/27 18:08:48 rousskov Exp $
+ *
+ */
+
+#include "squid.h"
+#include "ProtoPort.h"
+
+http_port_list::http_port_list(const char *aProtocol)
+#if USE_SSL
+ : http(*this)
+#endif
+{
+ protocol = xstrdup(aProtocol);
+}
+
+http_port_list::~http_port_list()
+{
+ safe_free(name);
+ safe_free(defaultsite);
+ safe_free(protocol);
+
+#if USE_SSL
+ safe_free(cert);
+ safe_free(key);
+ safe_free(options);
+ safe_free(cipher);
+ safe_free(cafile);
+ safe_free(capath);
+ safe_free(dhfile);
+ safe_free(sslflags);
+#endif
+}
+
+
+#if USE_SSL
+
+https_port_list::https_port_list(): http_port_list("https")
+{
+}
+
+#endif
--- /dev/null Wed Feb 6 01:24:19 2008
+++ squid3/src/ProtoPort.h Wed Feb 6 01:24:20 2008
@@ -0,0 +1,75 @@
+
+/*
+ * $Id: ProtoPort.h,v 1.1.2.5 2008/01/27 18:08:48 rousskov Exp $
+ */
+
+#ifndef SQUID_PROTO_PORT_H
+#define SQUID_PROTO_PORT_H
+
+//#include "typedefs.h"
+#include "cbdata.h"
+
+struct http_port_list
+{
+ http_port_list(const char *aProtocol);
+ ~http_port_list();
+
+ http_port_list *next;
+
+ struct sockaddr_in s;
+ char *protocol; /* protocol name */
+ char *name; /* visible name */
+ char *defaultsite; /* default web site */
+
+unsigned int transparent:
+ 1; /* transparent proxy */
+
+unsigned int accel:
+ 1; /* HTTP accelerator */
+
+unsigned int vhost:
+ 1; /* uses host header */
+
+unsigned int sslBump:
+ 1; /* intercepts CONNECT requests */
+
+ int vport; /* virtual port support, -1 for dynamic, >0 static*/
+ int disable_pmtu_discovery;
+#if LINUX_TPROXY
+unsigned int tproxy:
+ 1; /* spoof client ip using tproxy */
+#endif
+
+#if USE_SSL
+ // XXX: temporary hack to ease move of SSL options to http_port
+ http_port_list &http;
+
+ char *cert;
+ char *key;
+ int version;
+ char *cipher;
+ char *options;
+ char *clientca;
+ char *cafile;
+ char *capath;
+ char *crlfile;
+ char *dhfile;
+ char *sslflags;
+ char *sslcontext;
+ SSL_CTX *sslContext;
+#endif
+
+ CBDATA_CLASS2(http_port_list);
+};
+
+
+#if USE_SSL
+
+struct https_port_list: public http_port_list
+{
+ https_port_list();
+};
+
+#endif
+
+#endif /* SQUID_PROTO_PORT_H */
Index: squid3/src/Server.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Server.h,v
retrieving revision 1.10.6.1
retrieving revision 1.10.6.2
diff -u -r1.10.6.1 -r1.10.6.2
--- squid3/src/Server.h 25 Jan 2008 02:33:42 -0000 1.10.6.1
+++ squid3/src/Server.h 27 Jan 2008 18:08:48 -0000 1.10.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: Server.h,v 1.10.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: Server.h,v 1.10.6.2 2008/01/27 18:08:48 rousskov Exp $
*
* AUTHOR: Duane Wessels
*
@@ -163,7 +163,7 @@
size_t replyBodySpace(size_t space = 4096 * 10);
// These should be private
- int64_t currentOffset; // Our current offset in the StoreEntry
+ off_t currentOffset; // Our current offset in the StoreEntry
MemBuf *responseBodyBuffer; // Data temporarily buffered for ICAP
public: // should not be
Index: squid3/src/SquidString.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/SquidString.h,v
retrieving revision 1.11.6.2
retrieving revision 1.11.6.3
diff -u -r1.11.6.2 -r1.11.6.3
--- squid3/src/SquidString.h 25 Jan 2008 02:33:42 -0000 1.11.6.2
+++ squid3/src/SquidString.h 27 Jan 2008 18:08:48 -0000 1.11.6.3
@@ -1,5 +1,6 @@
+
/*
- * $Id: SquidString.h,v 1.11.6.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: SquidString.h,v 1.11.6.3 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 67 String
* AUTHOR: Duane Wessels
@@ -35,7 +36,6 @@
#ifndef SQUID_STRING_H
#define SQUID_STRING_H
-
/* forward decls */
class CacheManager;
@@ -90,15 +90,12 @@
bool operator ==(String const &) const;
bool operator !=(String const &) const;
- /**
- * Retrieve a single character in the string.
- \param pos Position of character to retrieve.
- */
- _SQUID_INLINE_ char &operator [](unsigned int pos);
-
_SQUID_INLINE_ int size() const;
_SQUID_INLINE_ char const * buf() const;
- void limitInit(const char *str, int len); // TODO: rename to assign()
+ void buf(char *);
+ void init (char const *);
+ void initBuf(size_t sz);
+ void limitInit(const char *str, int len);
void clean();
void reset(char const *str);
void append(char const *buf, int len);
@@ -115,19 +112,10 @@
_SQUID_INLINE_ int caseCmp (char const *) const;
_SQUID_INLINE_ int caseCmp (char const *, size_t count) const;
- /** \deprecated Use assignment to [] position instead.
- * ie str[0] = 'h';
- */
_SQUID_INLINE_ void set(char const *loc, char const ch);
- /** \deprecated Use assignment to [] position instead.
- * ie str[newLength] = '\0';
- */
_SQUID_INLINE_ void cut(size_t newLength);
- /** \deprecated Use assignment to [] position instead.
- * ie str[newLength] = '\0';
- */
_SQUID_INLINE_ void cutPointer(char const *loc);
#if DEBUGSTRINGS
@@ -136,13 +124,7 @@
#endif
-
-
private:
- void allocAndFill(const char *str, int len);
- void allocBuffer(size_t sz);
- void setBuffer(char *buf, size_t sz);
-
/* never reference these directly! */
unsigned short int size_; /* buffer size; 64K limit */
Index: squid3/src/SquidTime.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/SquidTime.h,v
retrieving revision 1.2.38.2
retrieving revision 1.2.38.3
diff -u -r1.2.38.2 -r1.2.38.3
--- squid3/src/SquidTime.h 25 Jan 2008 02:33:42 -0000 1.2.38.2
+++ squid3/src/SquidTime.h 27 Jan 2008 18:08:48 -0000 1.2.38.3
@@ -1,5 +1,5 @@
/*
- * $Id: SquidTime.h,v 1.2.38.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: SquidTime.h,v 1.2.38.3 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 21 Time Functions
* AUTHOR: Harvest Derived
@@ -36,10 +36,6 @@
#include "squid.h"
-/* globals for accessing time */
-extern struct timeval current_time;
-extern double current_dtime;
-
extern time_t squid_curtime; /* 0 */
time_t getCurrentTime(void);
Index: squid3/src/Store.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Store.h,v
retrieving revision 1.36.6.2
retrieving revision 1.36.6.3
diff -u -r1.36.6.2 -r1.36.6.3
--- squid3/src/Store.h 25 Jan 2008 02:33:42 -0000 1.36.6.2
+++ squid3/src/Store.h 27 Jan 2008 18:08:48 -0000 1.36.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: Store.h,v 1.36.6.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: Store.h,v 1.36.6.3 2008/01/27 18:08:48 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -153,9 +153,9 @@
public:
static size_t inUseCount();
- static void getPublicByRequestMethod(StoreClient * aClient, HttpRequest * request, const HttpRequestMethod& method);
+ static void getPublicByRequestMethod(StoreClient * aClient, HttpRequest * request, const method_t method);
static void getPublicByRequest(StoreClient * aClient, HttpRequest * request);
- static void getPublic(StoreClient * aClient, const char *uri, const HttpRequestMethod& method);
+ static void getPublic(StoreClient * aClient, const char *uri, const method_t method);
virtual bool isNull()
{
@@ -301,13 +301,16 @@
typedef RefCount StorePointer;
SQUIDCEXTERN size_t storeEntryInUse();
+#if UNUSED_CODE_20070420
+SQUIDCEXTERN off_t storeLowestMemReaderOffset(const StoreEntry * entry);
+#endif
SQUIDCEXTERN const char *storeEntryFlags(const StoreEntry *);
extern void storeEntryReplaceObject(StoreEntry *, HttpReply *);
-SQUIDCEXTERN StoreEntry *storeGetPublic(const char *uri, const HttpRequestMethod& method);
+SQUIDCEXTERN StoreEntry *storeGetPublic(const char *uri, const method_t method);
SQUIDCEXTERN StoreEntry *storeGetPublicByRequest(HttpRequest * request);
-SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& method);
-SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, const HttpRequestMethod&);
+SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(HttpRequest * request, const method_t method);
+SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, method_t);
SQUIDCEXTERN void storeInit(void);
extern void storeRegisterWithCacheManager(CacheManager & manager);
SQUIDCEXTERN void storeConfigure(void);
Index: squid3/src/StoreMeta.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/StoreMeta.cc,v
retrieving revision 1.7.6.1
retrieving revision 1.7.6.2
diff -u -r1.7.6.1 -r1.7.6.2
--- squid3/src/StoreMeta.cc 25 Jan 2008 02:33:42 -0000 1.7.6.1
+++ squid3/src/StoreMeta.cc 27 Jan 2008 18:08:48 -0000 1.7.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: StoreMeta.cc,v 1.7.6.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: StoreMeta.cc,v 1.7.6.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 20 Storage Manager Swapfile Metadata
* AUTHOR: Kostas Anagnostakis
@@ -48,16 +48,9 @@
StoreMeta::validType(char type)
{
/* VOID is reserved, and new types have to be added as classes */
- if (type <= STORE_META_VOID || type >= STORE_META_END + 10) {
- debugs(20, 0, "storeSwapMetaUnpack: bad type (" << type << ")!");
- return false;
- }
- /* Not yet implemented */
- if (type >= STORE_META_END ||
- type == STORE_META_STOREURL ||
- type == STORE_META_VARY_ID) {
- debugs(20, 3, "storeSwapMetaUnpack: Not yet implemented (" << type << ") in disk metadata");
+ if (type <= STORE_META_VOID || type >= STORE_META_END) {
+ debugs(20, 0, "storeSwapMetaUnpack: bad type (" << type << ")!");
return false;
}
Index: squid3/src/StoreMetaUnpacker.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/StoreMetaUnpacker.cc,v
retrieving revision 1.6.22.1
retrieving revision 1.6.22.2
diff -u -r1.6.22.1 -r1.6.22.2
--- squid3/src/StoreMetaUnpacker.cc 25 Jan 2008 02:33:42 -0000 1.6.22.1
+++ squid3/src/StoreMetaUnpacker.cc 27 Jan 2008 18:08:48 -0000 1.6.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: StoreMetaUnpacker.cc,v 1.6.22.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: StoreMetaUnpacker.cc,v 1.6.22.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 20 Storage Manager Swapfile Unpacker
* AUTHOR: Robert Collins
@@ -37,7 +37,7 @@
#include "StoreMetaUnpacker.h"
#include "StoreMeta.h"
-int const StoreMetaUnpacker::MinimumBufferLength = sizeof(char) + sizeof(int);
+off_t const StoreMetaUnpacker::MinimumBufferLength = sizeof(char) + sizeof(int);
bool
StoreMetaUnpacker::isBufferSane()
@@ -98,8 +98,10 @@
StoreMeta *newNode = StoreMeta::Factory(type, length, &buf[position]);
- if (newNode)
- tail = StoreMeta::Add (tail, newNode);
+ if (!newNode)
+ return false;
+
+ tail = StoreMeta::Add (tail, newNode);
position += length;
Index: squid3/src/StoreMetaUnpacker.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/StoreMetaUnpacker.h,v
retrieving revision 1.3.50.1
retrieving revision 1.3.50.2
diff -u -r1.3.50.1 -r1.3.50.2
--- squid3/src/StoreMetaUnpacker.h 25 Jan 2008 02:33:42 -0000 1.3.50.1
+++ squid3/src/StoreMetaUnpacker.h 27 Jan 2008 18:08:48 -0000 1.3.50.2
@@ -1,6 +1,6 @@
/*
- * $Id: StoreMetaUnpacker.h,v 1.3.50.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: StoreMetaUnpacker.h,v 1.3.50.2 2008/01/27 18:08:48 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -45,7 +45,7 @@
bool isBufferSane();
private:
- static int const MinimumBufferLength;
+ static off_t const MinimumBufferLength;
void getBufferLength();
void getType();
@@ -57,7 +57,7 @@
char const * const buf;
ssize_t buflen;
int *hdr_len;
- int position;
+ off_t position;
char type;
int length;
StoreMeta **tail;
Index: squid3/src/String.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/String.cc,v
retrieving revision 1.15.16.1
retrieving revision 1.15.16.2
diff -u -r1.15.16.1 -r1.15.16.2
--- squid3/src/String.cc 25 Jan 2008 02:33:42 -0000 1.15.16.1
+++ squid3/src/String.cc 27 Jan 2008 18:08:48 -0000 1.15.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: String.cc,v 1.15.16.1 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: String.cc,v 1.15.16.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 67 String
* AUTHOR: Duane Wessels
@@ -36,33 +36,32 @@
#include "squid.h"
#include "Store.h"
-// low-level buffer allocation,
-// does not free old buffer and does not adjust or look at len_
void
-String::allocBuffer(size_t sz)
+String::initBuf(size_t sz)
{
PROF_start(StringInitBuf);
- assert (buf_ == NULL);
- char *newBuffer = (char*)memAllocString(sz, &sz);
- setBuffer(newBuffer, sz);
+ buf((char *)memAllocString(sz, &sz));
+ assert(sz < 65536);
+ size_ = sz;
PROF_stop(StringInitBuf);
}
-// low-level buffer assignment
-// does not free old buffer and does not adjust or look at len_
void
-String::setBuffer(char *aBuf, size_t aSize)
+String::init(char const *str)
{
- assert(!buf_);
- assert(aSize < 65536);
- buf_ = aBuf;
- size_ = aSize;
+ assert(this);
+
+ PROF_start(StringInit);
+ if (str)
+ limitInit(str, strlen(str));
+ else
+ clean();
+ PROF_stop(StringInit);
}
String::String (char const *aString) : size_(0), len_(0), buf_(NULL)
{
- if (aString)
- allocAndFill(aString, strlen(aString));
+ init (aString);
#if DEBUGSTRINGS
StringRegistry::Instance().add(this);
@@ -72,16 +71,19 @@
String &
String::operator =(char const *aString)
{
- reset(aString);
+ clean();
+ init (aString);
return *this;
}
String &
String::operator = (String const &old)
{
- clean(); // TODO: optimize to avoid cleaning the buffer we can use
- if (old.size() > 0)
- allocAndFill(old.buf(), old.size());
+ clean ();
+
+ if (old.len_)
+ limitInit (old.buf(), old.len_);
+
return *this;
}
@@ -103,32 +105,21 @@
return true;
}
-// public interface, makes sure that we clean the old buffer first
void
String::limitInit(const char *str, int len)
{
- clean(); // TODO: optimize to avoid cleaning the buffer we can use
- allocAndFill(str, len);
-}
-
-// Allocates the buffer to fit the supplied string and fills it.
-// Does not clean.
-void
-String::allocAndFill(const char *str, int len)
-{
- PROF_start(StringAllocAndFill);
+ PROF_start(StringLimitInit);
assert(this && str);
- allocBuffer(len + 1);
+ initBuf(len + 1);
len_ = len;
xmemcpy(buf_, str, len);
buf_[len] = '\0';
- PROF_stop(StringAllocAndFill);
+ PROF_stop(StringLimitInit);
}
String::String (String const &old) : size_(0), len_(0), buf_(NULL)
{
- if (old.size() > 0)
- allocAndFill(old.buf(), old.size());
+ init (old.buf());
#if DEBUGSTRINGS
StringRegistry::Instance().add(this);
@@ -165,9 +156,8 @@
String::reset(const char *str)
{
PROF_start(StringReset);
- clean(); // TODO: optimize to avoid cleaning the buffer if we can reuse it
- if (str)
- allocAndFill(str, strlen(str));
+ clean();
+ init(str);
PROF_stop(StringReset);
}
@@ -182,12 +172,11 @@
strncat(buf_, str, len);
len_ += len;
} else {
- // Create a temporary string and absorb it later.
String snew;
snew.len_ = len_ + len;
- snew.allocBuffer(snew.len_ + 1);
+ snew.initBuf(snew.len_ + 1);
- if (len_)
+ if (buf_)
xmemcpy(snew.buf_, buf(), len_);
if (len)
@@ -226,13 +215,21 @@
String::absorb(String &old)
{
clean();
- setBuffer(old.buf_, old.size_);
+ size_ = old.size_;
+ buf (old.buf_);
len_ = old.len_;
old.size_ = 0;
old.buf_ = NULL;
old.len_ = 0;
}
+void
+String::buf(char *newBuf)
+{
+ assert (buf_ == NULL);
+ buf_ = newBuf;
+}
+
#if DEBUGSTRINGS
void
String::stat(StoreEntry *entry) const
Index: squid3/src/String.cci
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/String.cci,v
retrieving revision 1.9.16.2
retrieving revision 1.9.16.3
diff -u -r1.9.16.2 -r1.9.16.3
--- squid3/src/String.cci 25 Jan 2008 02:33:42 -0000 1.9.16.2
+++ squid3/src/String.cci 27 Jan 2008 18:08:48 -0000 1.9.16.3
@@ -1,5 +1,6 @@
+
/*
- * $Id: String.cci,v 1.9.16.2 2008/01/25 02:33:42 valexey_eykon Exp $
+ * $Id: String.cci,v 1.9.16.3 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 67 String
* AUTHOR: Duane Wessels
@@ -51,14 +52,6 @@
return buf_;
}
-char&
-String::operator [](unsigned int pos)
-{
- assert(pos < size_);
-
- return buf_[pos];
-}
-
const char *
String::pos(char const *aString) const
{
--- squid3/src/TextException.cc Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,27 +0,0 @@
-#include "squid.h"
-#include "TextException.h"
-
-TextException::TextException(const char *aMsg, const char *aFileName, int aLineNo):
- message(xstrdup(aMsg)), theFileName(aFileName), theLineNo(aLineNo)
-{}
-
-TextException::~TextException()
-{
- xfree(message);
-}
-
-void Throw(const char *message, const char *fileName, int lineNo)
-{
-
- // or should we let the exception recepient print the exception instead?
-
- if (fileName) {
- debugs(0, 3, fileName << ':' << lineNo << ": exception" <<
- (message ? ": " : ".") << (message ? message : ""));
- } else {
- debugs(0, 3, "exception" <<
- (message ? ": " : ".") << (message ? message : ""));
- }
-
- throw TextException(message, fileName, lineNo);
-}
--- squid3/src/TextException.h Wed Feb 6 01:24:20 2008
+++ /dev/null Wed Feb 6 01:24:19 2008
@@ -1,46 +0,0 @@
-#ifndef SQUID__TEXTEXCEPTION_H
-#define SQUID__TEXTEXCEPTION_H
-
-// Origin: xstd/TextException
-
-
-// simple exception to report custom errors
-// we may want to change the interface to be able to report system errors
-
-class TextException
-{
-
-public:
- TextException(const char *aMessage, const char *aFileName = 0, int aLineNo = -1);
- ~TextException();
-
- // ostream &print(ostream &os) const;
-
-public:
- char *message; // read-only
-
-protected:
- // optional location information
- const char *theFileName;
- int theLineNo;
-};
-
-//inline
-//ostream &operator <<(ostream &os, const TextException &exx) {
-// return exx.print(os);
-//}
-
-#if !defined(TexcHere)
-# define TexcHere(msg) TextException((msg), __FILE__, __LINE__)
-#endif
-
-extern void Throw(const char *message, const char *fileName, int lineNo);
-
-// Must(condition) is like assert(condition) but throws an exception instead
-#if !defined(Must)
-# define Must(cond) ((cond) ? \
- (void)0 : \
- (void)Throw(#cond, __FILE__, __LINE__))
-#endif
-
-#endif /* SQUID__TEXTEXCEPTION_H */
Index: squid3/src/WinSvc.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/WinSvc.cc,v
retrieving revision 1.4.22.1
retrieving revision 1.4.22.2
diff -u -r1.4.22.1 -r1.4.22.2
--- squid3/src/WinSvc.cc 25 Jan 2008 02:33:44 -0000 1.4.22.1
+++ squid3/src/WinSvc.cc 27 Jan 2008 18:08:48 -0000 1.4.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: WinSvc.cc,v 1.4.22.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: WinSvc.cc,v 1.4.22.2 2008/01/27 18:08:48 rousskov Exp $
*
* Windows support
* AUTHOR: Guido Serassio
@@ -69,11 +69,6 @@
#endif
static int Squid_Aborting = 0;
-static HANDLE NotifyAddrChange_thread = INVALID_HANDLE_VALUE;
-
-#undef NotifyAddrChange
-typedef DWORD(WINAPI * PFNotifyAddrChange) (OUT PHANDLE, IN LPOVERLAPPED);
-#define NOTIFYADDRCHANGE "NotifyAddrChange"
#if USE_WIN32_SERVICE
static SERVICE_STATUS svcStatus;
@@ -391,17 +386,6 @@
}
void
-WIN32_IpAddrChangeMonitorExit()
-{
- DWORD status = ERROR_SUCCESS;
-
- if (NotifyAddrChange_thread == INVALID_HANDLE_VALUE) {
- TerminateThread(NotifyAddrChange_thread, status);
- CloseHandle(NotifyAddrChange_thread);
- }
-}
-
-void
WIN32_Exit()
{
#ifdef _SQUID_MSWIN_
@@ -422,57 +406,12 @@
DeleteCriticalSection(dbg_mutex);
WIN32_ExceptionHandlerCleanup();
- WIN32_IpAddrChangeMonitorExit();
#endif
_exit(0);
}
-#ifdef _SQUID_MSWIN_
-static DWORD WINAPI
-WIN32_IpAddrChangeMonitor(LPVOID lpParam)
-{
- DWORD Result;
- HMODULE IPHLPAPIHandle;
- PFNotifyAddrChange NotifyAddrChange;
-
- if ((IPHLPAPIHandle = GetModuleHandle("IPHLPAPI")) == NULL)
- IPHLPAPIHandle = LoadLibrary("IPHLPAPI");
- NotifyAddrChange = (PFNotifyAddrChange) GetProcAddress(IPHLPAPIHandle, NOTIFYADDRCHANGE);
-
- while (1) {
- Result = NotifyAddrChange(NULL, NULL);
- if (Result != NO_ERROR) {
- debug(1, 1) ("NotifyAddrChange error %ld\n", Result);
- return 1;
- }
- debug(1, 1) ("Notification of IP address change received, requesting Squid reconfiguration ...\n");
- reconfigure(SIGHUP);
- }
- return 0;
-}
-
-DWORD
-WIN32_IpAddrChangeMonitorInit()
-{
- DWORD status = ERROR_SUCCESS;
- DWORD threadID = 0, ThrdParam = 0;
-
- if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) {
- NotifyAddrChange_thread = CreateThread(NULL, 0, WIN32_IpAddrChangeMonitor,
- &ThrdParam, 0, &threadID);
- if (NotifyAddrChange_thread == NULL) {
- status = GetLastError();
- NotifyAddrChange_thread = INVALID_HANDLE_VALUE;
- debug(1, 1) ("Failed to start IP monitor thread.\n");
- } else
- debug(1, 2) ("Starting IP monitor thread [%li] ...\n", threadID);
- }
- return status;
-}
-#endif
-
int WIN32_Subsystem_Init(int * argc, char *** argv)
{
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
Index: squid3/src/access_log.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/access_log.cc,v
retrieving revision 1.49.6.1
retrieving revision 1.49.6.2
diff -u -r1.49.6.1 -r1.49.6.2
--- squid3/src/access_log.cc 25 Jan 2008 02:33:44 -0000 1.49.6.1
+++ squid3/src/access_log.cc 27 Jan 2008 18:08:48 -0000 1.49.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: access_log.cc,v 1.49.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: access_log.cc,v 1.49.6.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 46 Access Log
* AUTHOR: Duane Wessels
@@ -545,22 +545,20 @@
break;
case LFT_CLIENT_IP_ADDRESS:
- if (!out) {
- out = al->cache.caddr.NtoA(tmp,1024);
- }
+ out = inet_ntoa(al->cache.caddr);
break;
case LFT_CLIENT_FQDN:
out = fqdncache_gethostbyaddr(al->cache.caddr, FQDN_LOOKUP_IF_MISS);
- if (!out) {
- out = al->cache.caddr.NtoA(tmp,1024);
- }
+
+ if (!out)
+ out = inet_ntoa(al->cache.caddr);
break;
case LFT_CLIENT_PORT:
if (al->request) {
- outint = al->request->client_addr.GetPort();
+ outint = al->request->client_port;
doint = 1;
}
break;
@@ -575,15 +573,14 @@
/* case LFT_SERVER_PORT: */
case LFT_LOCAL_IP:
- if (al->request) {
- out = al->request->my_addr.NtoA(tmp,1024);
- }
+ if (al->request)
+ out = inet_ntoa(al->request->my_addr);
break;
case LFT_LOCAL_PORT:
if (al->request) {
- outint = al->request->my_addr.GetPort();
+ outint = al->request->my_port;
doint = 1;
}
@@ -1272,15 +1269,12 @@
{
const char *client = NULL;
const char *user = NULL;
- char buf[MAX_IPSTRLEN];
- if (Config.onoff.log_fqdn) {
+ if (Config.onoff.log_fqdn)
client = fqdncache_gethostbyaddr(al->cache.caddr, FQDN_LOOKUP_IF_MISS);
- }
- if (client == NULL) {
- client = al->cache.caddr.NtoA(buf,MAX_IPSTRLEN);
- }
+ if (client == NULL)
+ client = inet_ntoa(al->cache.caddr);
user = accessLogFormatName(al->cache.authuser);
@@ -1348,15 +1342,12 @@
{
const char *client = NULL;
char *user1 = NULL, *user2 = NULL;
- char buf[MAX_IPSTRLEN];
- if (Config.onoff.log_fqdn) {
+ if (Config.onoff.log_fqdn)
client = fqdncache_gethostbyaddr(al->cache.caddr, 0);
- }
- if (client == NULL) {
- client = al->cache.caddr.NtoA(buf,MAX_IPSTRLEN);
- }
+ if (client == NULL)
+ client = inet_ntoa(al->cache.caddr);
user1 = accessLogFormatName(al->cache.authuser);
@@ -1408,7 +1399,7 @@
if (al->icp.opcode)
al->_private.method_str = icp_opcode_str[al->icp.opcode];
else
- al->_private.method_str = RequestMethodStr(al->http.method);
+ al->_private.method_str = RequestMethodStr[al->http.method];
if (al->hier.host[0] == '\0')
xstrncpy(al->hier.host, dash_str, SQUIDHOSTNAMELEN);
@@ -1783,7 +1774,7 @@
#if HEADERS_LOG
void
-headersLog(int cs, int pq, const HttpRequestMethod& method, void *data)
+headersLog(int cs, int pq, method_t method, void *data)
{
HttpReply *rep;
HttpRequest *req;
Index: squid3/src/acl.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/acl.cc,v
retrieving revision 1.32.6.2
retrieving revision 1.32.6.3
diff -u -r1.32.6.2 -r1.32.6.3
--- squid3/src/acl.cc 25 Jan 2008 02:33:44 -0000 1.32.6.2
+++ squid3/src/acl.cc 27 Jan 2008 18:08:48 -0000 1.32.6.3
@@ -1,5 +1,5 @@
/*
- * $Id: acl.cc,v 1.32.6.2 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: acl.cc,v 1.32.6.3 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
@@ -330,7 +330,7 @@
for (; a; a = a->next) {
for (b = a->aclList; b; b = b->next) {
- ACLStrategised *tempAcl = dynamic_cast *>(b->_acl);
+ ACLStrategised *tempAcl = dynamic_cast *>(b->_acl);
if (!tempAcl) {
debugs(28, 7, "acl_access::containsPURGE: can't create tempAcl");
Index: squid3/src/asn.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/asn.cc,v
retrieving revision 1.31.6.1
retrieving revision 1.31.6.2
diff -u -r1.31.6.1 -r1.31.6.2
--- squid3/src/asn.cc 25 Jan 2008 02:33:44 -0000 1.31.6.1
+++ squid3/src/asn.cc 27 Jan 2008 18:08:48 -0000 1.31.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: asn.cc,v 1.31.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: asn.cc,v 1.31.6.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 53 AS Number handling
* AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -53,15 +53,12 @@
/* BEGIN of definitions for radix tree entries */
-
-/* 32/128 bits address in memory with length */
-class m_ADDR {
-public:
- uint8_t len;
- IPAddress addr;
-
- m_ADDR() : len(sizeof(IPAddress)) {};
-};
+/* int in memory with length */
+typedef u_char m_int[1 + sizeof(unsigned int)];
+#define store_m_int(i, m) \
+ (i = htonl(i), m[0] = sizeof(m_int), xmemcpy(m+1, &i, sizeof(unsigned int)))
+#define get_m_int(i, m) \
+ (xmemcpy(&i, m+1, sizeof(unsigned int)), ntohl(i))
/* END of definitions for radix tree entries */
@@ -92,7 +89,7 @@
store_client *sc;
HttpRequest *request;
int as_number;
- int64_t offset;
+ off_t offset;
int reqofs;
char reqbuf[AS_REQBUF_SZ];
bool dataRead;
@@ -103,8 +100,8 @@
{
struct squid_radix_node e_nodes[2];
as_info *e_info;
- m_ADDR e_addr;
- m_ADDR e_mask;
+ m_int e_addr;
+ m_int e_mask;
};
static int asnAddNet(char *, int);
@@ -128,28 +125,30 @@
/* PUBLIC */
int
-asnMatchIp(List *data, IPAddress &addr)
+asnMatchIp(List *data, struct IN_ADDR addr)
{
+ unsigned long lh;
+
struct squid_radix_node *rn;
as_info *e;
- m_ADDR m_addr;
+ m_int m_addr;
List *a = NULL;
List *b = NULL;
-
- debugs(53, 3, "asnMatchIp: Called for " << addr );
+ lh = ntohl(addr.s_addr);
+ debugs(53, 3, "asnMatchIp: Called for " << inet_ntoa(addr) << ".");
if (AS_tree_head == NULL)
return 0;
- if (addr.IsNoAddr())
+ if (addr.s_addr == no_addr.s_addr)
return 0;
- if (addr.IsAnyAddr())
+ if (addr.s_addr == any_addr.s_addr)
return 0;
- m_addr.addr = addr;
+ store_m_int(lh, m_addr);
- rn = squid_rn_match(&m_addr, AS_tree_head);
+ rn = squid_rn_match(m_addr, AS_tree_head);
if (rn == NULL) {
debugs(53, 3, "asnMatchIp: Address not in as db.");
@@ -300,7 +299,7 @@
*/
s = buf;
- while ((size_t)(s - buf) < result.length + asState->reqofs && *s != '\0') {
+ while (s - buf < (off_t)(result.length + asState->reqofs) && *s != '\0') {
while (*s && xisspace(*s))
s++;
@@ -390,12 +389,13 @@
rtentry_t *e;
struct squid_radix_node *rn;
+ char dbg1[32], dbg2[32];
List **Tail = NULL;
List *q = NULL;
as_info *asinfo = NULL;
- IPAddress mask;
- IPAddress addr;
+ struct IN_ADDR in_a, in_m;
+ long mask, addr;
char *t;
int bitl;
@@ -407,40 +407,50 @@
}
*t = '\0';
- addr = as_string;
+ addr = inet_addr(as_string);
bitl = atoi(t + 1);
if (bitl < 0)
bitl = 0;
- // INET6 TODO : find a better way of identifying the base IPA family for mask than this.
- t = strchr(as_string, '.');
+ if (bitl > 32)
+ bitl = 32;
+
+ mask = bitl ? 0xfffffffful << (32 - bitl) : 0;
- // generate Netbits Format Mask
- mask.SetNoAddr();
- mask.ApplyMask(bitl, (t!=NULL?AF_INET:AF_INET6) );
+ in_a.s_addr = addr;
- debugs(53, 3, "asnAddNet: called for " << addr << "/" << mask );
+ in_m.s_addr = mask;
+
+ xstrncpy(dbg1, inet_ntoa(in_a), 32);
+
+ xstrncpy(dbg2, inet_ntoa(in_m), 32);
+
+ addr = ntohl(addr);
+
+ /*mask = ntohl(mask); */
+ debugs(53, 3, "asnAddNet: called for " << dbg1 << "/" << dbg2);
e = (rtentry_t *)xmalloc(sizeof(rtentry_t));
memset(e, '\0', sizeof(rtentry_t));
- e->e_addr.addr = addr;
+ store_m_int(addr, e->e_addr);
- e->e_mask.addr = mask;
+ store_m_int(mask, e->e_mask);
- rn = squid_rn_lookup(&e->e_addr, &e->e_mask, AS_tree_head);
+ rn = squid_rn_lookup(e->e_addr, e->e_mask, AS_tree_head);
if (rn != NULL) {
asinfo = ((rtentry_t *) rn)->e_info;
if (asinfo->as_number->find(as_number)) {
- debugs(53, 3, "asnAddNet: Ignoring repeated network '" << addr << "/" << bitl << "' for AS " << as_number);
+ debugs(53, 3, "asnAddNet: Ignoring repeated network '" << dbg1 << "/" << bitl << "' for AS " << as_number);
} else {
debugs(53, 3, "asnAddNet: Warning: Found a network with multiple AS numbers!");
for (Tail = &asinfo->as_number; *Tail; Tail = &(*Tail)->next)
+
;
q = new List (as_number);
@@ -452,8 +462,8 @@
q = new List (as_number);
asinfo = (as_info *)xmalloc(sizeof(as_info));
asinfo->as_number = q;
- rn = squid_rn_addroute(&e->e_addr, &e->e_mask, AS_tree_head, e->e_nodes);
- rn = squid_rn_match(&e->e_addr, AS_tree_head);
+ rn = squid_rn_addroute(e->e_addr, e->e_mask, AS_tree_head, e->e_nodes);
+ rn = squid_rn_match(e->e_addr, AS_tree_head);
assert(rn != NULL);
e->e_info = asinfo;
}
@@ -471,6 +481,7 @@
}
static int
+
destroyRadixNode(struct squid_radix_node *rn, void *w)
{
@@ -508,23 +519,39 @@
}
static int
+mask_len(u_long mask)
+{
+ int len = 32;
+
+ if (mask == 0)
+ return 0;
+
+ while ((mask & 1) == 0) {
+ len--;
+ mask >>= 1;
+ }
+
+ return len;
+}
+
+static int
+
printRadixNode(struct squid_radix_node *rn, void *_sentry)
{
StoreEntry *sentry = (StoreEntry *)_sentry;
rtentry_t *e = (rtentry_t *) rn;
List *q;
as_info *asinfo;
- char buf[MAX_IPSTRLEN];
- IPAddress addr;
- IPAddress mask;
+ struct IN_ADDR addr;
+
+ struct IN_ADDR mask;
assert(e);
assert(e->e_info);
- addr = e->e_addr.addr;
- mask = e->e_mask.addr;
- storeAppendPrintf(sentry, "%s/%d\t",
- addr.NtoA(buf, MAX_IPSTRLEN),
- mask.GetCIDR() );
+ (void) get_m_int(addr.s_addr, e->e_addr);
+ (void) get_m_int(mask.s_addr, e->e_mask);
+ storeAppendPrintf(sentry, "%15s/%d\t",
+ inet_ntoa(addr), mask_len(ntohl(mask.s_addr)));
asinfo = e->e_info;
assert(asinfo->as_number);
@@ -544,7 +571,7 @@
bool
-ACLASN::match(IPAddress toMatch)
+ACLASN::match(struct IN_ADDR toMatch)
{
return asnMatchIp(data, toMatch);
}
@@ -589,7 +616,7 @@
}
}
-ACLData *
+ACLData *
ACLASN::clone() const
{
if (data)
@@ -600,20 +627,20 @@
/* explicit template instantiation required for some systems */
-template class ACLStrategised
+template class ACLStrategised
;
ACL::Prototype ACLASN::SourceRegistryProtoype(&ACLASN::SourceRegistryEntry_, "src_as");
-ACLStrategised ACLASN::SourceRegistryEntry_(new ACLASN, ACLSourceASNStrategy::Instance(), "src_as");
+ACLStrategised ACLASN::SourceRegistryEntry_(new ACLASN, ACLSourceASNStrategy::Instance(), "src_as");
ACL::Prototype ACLASN::DestinationRegistryProtoype(&ACLASN::DestinationRegistryEntry_, "dst_as");
-ACLStrategised ACLASN::DestinationRegistryEntry_(new ACLASN, ACLDestinationASNStrategy::Instance(), "dst_as");
+ACLStrategised ACLASN::DestinationRegistryEntry_(new ACLASN, ACLDestinationASNStrategy::Instance(), "dst_as");
int
-ACLSourceASNStrategy::match (ACLData * &data, ACLChecklist *checklist)
+ACLSourceASNStrategy::match (ACLData * &data, ACLChecklist *checklist)
{
return data->match(checklist->src_addr);
}
@@ -630,7 +657,7 @@
int
ACLDestinationASNStrategy::match (ACLData * &data, ACLChecklist *checklist)
{
- const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->GetHost(), IP_LOOKUP_IF_MISS);
+ const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->host, IP_LOOKUP_IF_MISS);
if (ia) {
for (int k = 0; k < (int) ia->count; k++) {
@@ -639,15 +666,13 @@
}
return 0;
-
} else if (!checklist->request->flags.destinationIPLookedUp()) {
/* No entry in cache, lookup not attempted */
/* XXX FIXME: allow accessing the acl name here */
- debugs(28, 3, "asnMatchAcl: Can't yet compare '" << "unknown" /*name*/ << "' ACL for '" << checklist->request->GetHost() << "'");
+ debugs(28, 3, "asnMatchAcl: Can't yet compare '" << "unknown" /*name*/ << "' ACL for '" << checklist->request->host << "'");
checklist->changeState (DestinationIPLookup::Instance());
} else {
- IPAddress noaddr; noaddr.SetNoAddr();
- return data->match(noaddr);
+ return data->match(no_addr);
}
return 0;
Index: squid3/src/cache_cf.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/cache_cf.cc,v
retrieving revision 1.92.6.6
retrieving revision 1.92.6.7
diff -u -r1.92.6.6 -r1.92.6.7
--- squid3/src/cache_cf.cc 25 Jan 2008 02:33:44 -0000 1.92.6.6
+++ squid3/src/cache_cf.cc 27 Jan 2008 18:08:48 -0000 1.92.6.7
@@ -1,6 +1,6 @@
/*
- * $Id: cache_cf.cc,v 1.92.6.6 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: cache_cf.cc,v 1.92.6.7 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
@@ -35,6 +35,7 @@
#include "squid.h"
#include "authenticate.h"
+#include "ProtoPort.h"
#include "AuthConfig.h"
#include "AuthScheme.h"
#include "CacheManager.h"
@@ -127,11 +128,11 @@
static void free_denyinfo(acl_deny_info_list ** var);
#if USE_WCCPv2
-static void parse_IPAddress_list(IPAddress_list **);
-static void dump_IPAddress_list(StoreEntry *, const char *, const IPAddress_list *);
-static void free_IPAddress_list(IPAddress_list **);
+static void parse_sockaddr_in_list(sockaddr_in_list **);
+static void dump_sockaddr_in_list(StoreEntry *, const char *, const sockaddr_in_list *);
+static void free_sockaddr_in_list(sockaddr_in_list **);
#if CURRENTLY_UNUSED
-static int check_null_IPAddress_list(const IPAddress_list *);
+static int check_null_sockaddr_in_list(const sockaddr_in_list *);
#endif /* CURRENTLY_UNUSED */
#endif /* USE_WCCPv2 */
@@ -151,8 +152,6 @@
static void parse_b_size_t(size_t * var);
static void parse_b_int64_t(int64_t * var);
-static int parseOneConfigFile(const char *file_name, unsigned int depth);
-
/*
* LegacyParser is a parser for legacy code that uses the global
* approach. This is static so that it is only exposed to cache_cf.
@@ -205,36 +204,17 @@
return s;
}
-static int
-parseManyConfigFiles(char* files, int depth)
-{
- int error_count = 0;
- char* saveptr = NULL;
- char* file = strwordtok(files, &saveptr);
- while (file != NULL) {
- error_count += parseOneConfigFile(file, depth);
- file = strwordtok(NULL, &saveptr);
- }
- return error_count;
-}
-
-static int
-parseOneConfigFile(const char *file_name, unsigned int depth)
+int
+parseConfigFile(const char *file_name, CacheManager & manager)
{
FILE *fp = NULL;
- const char *orig_cfg_filename = cfg_filename;
- const int orig_config_lineno = config_lineno;
char *token = NULL;
char *tmp_line = NULL;
int tmp_line_len = 0;
int err_count = 0;
int is_pipe = 0;
-
- debugs(3, 1, "Processing Configuration File: " << file_name << " (depth " << depth << ")");
- if (depth > 16) {
- fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name);
- return 1;
- }
+ configFreeMemory();
+ default_all();
if (file_name[0] == '!' || file_name[0] == '|') {
fp = popen(file_name + 1, "r");
@@ -244,7 +224,8 @@
}
if (fp == NULL)
- fatalf("Unable to open configuration file: %s: %s", file_name, xstrerror());
+ fatalf("Unable to open configuration file: %s: %s",
+ file_name, xstrerror());
#ifdef _SQUID_WIN32_
@@ -290,6 +271,13 @@
*token = '\0';
cfg_filename = new_file_name;
+
+#if PROBABLY_NOT_WANTED_HERE
+
+ SetConfigFilename(cfg_filename, false);
+
+#endif
+
}
config_lineno = new_lineno;
@@ -319,13 +307,11 @@
debugs(3, 5, "Processing: '" << tmp_line << "'");
- /* Handle includes here */
- if (tmp_line_len >= 9 && strncmp(tmp_line, "include", 7) == 0 && xisspace(tmp_line[7])) {
- err_count += parseManyConfigFiles(tmp_line + 8, depth + 1);
- } else if (!parse_line(tmp_line)) {
- debugs(3, 0, HERE << cfg_filename << ":" << config_lineno << " unrecognized: '" << tmp_line << "'");
- err_count++;
- }
+ if (!parse_line(tmp_line)) {
+ debugs(3, 0, "parseConfigFile: '" << cfg_filename << "' line " <<
+ config_lineno << " unrecognized: '" << config_input_line << "'");
+ err_count++;
+ }
safe_free(tmp_line);
tmp_line_len = 0;
@@ -341,23 +327,6 @@
fclose(fp);
}
- cfg_filename = orig_cfg_filename;
- config_lineno = orig_config_lineno;
-
- return err_count;
-}
-
-int
-parseConfigFile(const char *file_name, CacheManager & manager)
-{
- int err_count = 0;
-
- configFreeMemory();
-
- default_all();
-
- err_count = parseOneConfigFile(file_name, 0);
-
defaults_if_none();
/*
@@ -383,7 +352,6 @@
return err_count;
}
-
static void
configDoConfigure(void)
{
@@ -392,6 +360,9 @@
memConfigure();
/* Sanity checks */
+ if (Config.cacheSwap.swapDirs == NULL)
+ fatal("No cache_dir's specified in config file");
+
#if SIZEOF_OFF_T <= 4
if (Config.Store.maxObjectSize > 0x7FFF0000) {
debugs(3, 0, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB");
@@ -664,10 +635,28 @@
{
+ http_port_list *s;
+
+ for (s = Config.Sockaddr.http; s != NULL; s = (http_port_list *) s->next) {
+ if (!s->cert && !s->key)
+ continue;
+
+ debugs(3, 1, "Initializing http_port " <<
+ inet_ntoa(s->http.s.sin_addr) << ":" <<
+ ntohs(s->http.s.sin_port) << " SSL context");
+
+ s->sslContext = sslCreateServerContext(s->cert, s->key, s->version, s->cipher, s->options, s->sslflags, s->clientca, s->cafile, s->capath, s->crlfile, s->dhfile, s->sslcontext);
+ }
+ }
+
+ {
+
https_port_list *s;
for (s = Config.Sockaddr.https; s != NULL; s = (https_port_list *) s->http.next) {
- debugs(3, 1, "Initializing https_port " << s->http.s << " SSL context");
+ debugs(3, 1, "Initializing https_port " <<
+ inet_ntoa(s->http.s.sin_addr) << ":" <<
+ ntohs(s->http.s.sin_port) << " SSL context");
s->sslContext = sslCreateServerContext(s->cert, s->key, s->version, s->cipher, s->options, s->sslflags, s->clientca, s->cafile, s->capath, s->crlfile, s->dhfile, s->sslcontext);
}
@@ -933,15 +922,18 @@
}
static void
-dump_address(StoreEntry * entry, const char *name, IPAddress &addr)
+
+dump_address(StoreEntry * entry, const char *name, struct IN_ADDR addr)
{
- char buf[MAX_IPSTRLEN];
- storeAppendPrintf(entry, "%s %s\n", name, addr.NtoA(buf,MAX_IPSTRLEN) );
+ storeAppendPrintf(entry, "%s %s\n", name, inet_ntoa(addr));
}
static void
-parse_address(IPAddress *addr)
+
+parse_address(struct IN_ADDR *addr)
{
+
+ const struct hostent *hp;
char *token = strtok(NULL, w_space);
if (!token) {
@@ -949,24 +941,20 @@
return;
}
- if (!strcmp(token,"any_addr"))
- {
- addr->SetAnyAddr();
- (void) 0;
- }
- else if ( (!strcmp(token,"no_addr")) || (!strcmp(token,"full_mask")) )
- {
- addr->SetNoAddr();
- (void) 0;
- }
+ if (safe_inet_addr(token, addr) == 1)
+ (void) 0;
+ else if ((hp = gethostbyname(token))) /* dont use ipcache */
+ *addr = inaddrFromHostent(hp);
else
- *addr = token;
+ self_destruct();
}
static void
-free_address(IPAddress *addr)
+
+free_address(struct IN_ADDR *addr)
{
- addr->SetEmpty();
+
+ memset(addr, '\0', sizeof(struct IN_ADDR));
}
CBDATA_TYPE(acl_address);
@@ -974,12 +962,11 @@
static void
dump_acl_address(StoreEntry * entry, const char *name, acl_address * head)
{
- char buf[MAX_IPSTRLEN];
acl_address *l;
for (l = head; l; l = l->next) {
- if (!l->addr.IsAnyAddr())
- storeAppendPrintf(entry, "%s %s", name, l->addr.NtoA(buf,MAX_IPSTRLEN));
+ if (l->addr.s_addr != INADDR_ANY)
+ storeAppendPrintf(entry, "%s %s", name, inet_ntoa(l->addr));
else
storeAppendPrintf(entry, "%s autoselect", name);
@@ -1358,6 +1345,12 @@
}
static int
+check_null_cachedir(_SquidConfig::_cacheSwap swap)
+{
+ return swap.swapDirs == NULL;
+}
+
+static int
check_null_string(char *s)
{
return s == NULL;
@@ -1622,7 +1615,7 @@
self_destruct();
p->host = xstrdup(token);
-
+
p->name = xstrdup(token);
if ((token = strtok(NULL, w_space)) == NULL)
@@ -1795,14 +1788,13 @@
}
#endif
-
- p->index = ++Config.npeers;
-
while (*head != NULL)
head = &(*head)->next;
*head = p;
+ Config.npeers++;
+
peerClearRR(p);
}
@@ -2389,6 +2381,18 @@
#define dump_eol dump_string
#define free_eol free_string
+void
+parse_debug(char *volatile *var)
+{
+ parse_eol(var);
+ safe_free(debug_options)
+ debug_options = xstrdup(Config.debugOptions);
+ Debug::parseOptions(Config.debugOptions);
+}
+
+#define dump_debug dump_string
+#define free_debug free_string
+
static void
dump_time_t(StoreEntry * entry, const char *name, time_t var)
{
@@ -2680,32 +2684,19 @@
#if USE_WCCPv2
void
-parse_IPAddress_list_token(IPAddress_list ** head, char *token)
+parse_sockaddr_in_list_token(sockaddr_in_list ** head, char *token)
{
char *t;
char *host;
char *tmp;
- IPAddress ipa;
+ const struct hostent *hp;
unsigned short port;
- IPAddress_list *s;
+ sockaddr_in_list *s;
host = NULL;
port = 0;
-#if USE_IPV6
- if (*token == '[') {
- /* [host]:port */
- host = token + 1;
- t = strchr(host, ']');
- if (!t)
- self_destruct();
- *t++ = '\0';
- if (*t != ':')
- self_destruct();
- port = xatos(t + 1);
- } else
-#endif
if ((t = strchr(token, ':'))) {
/* host:port */
host = token;
@@ -2721,52 +2712,55 @@
port = 0;
}
+ s = static_cast(xcalloc(1, sizeof(*s)));
+ s->s.sin_port = htons(port);
+
if (NULL == host)
- ipa.SetAnyAddr();
- else if ( ipa.GetHostByName(host) ) /* dont use ipcache. Accept either FQDN or IPA. */
+ s->s.sin_addr = any_addr;
+ else if (1 == safe_inet_addr(host, &s->s.sin_addr))
(void) 0;
+ else if ((hp = gethostbyname(host))) /* dont use ipcache */
+ s->s.sin_addr = inaddrFromHostent(hp);
else
self_destruct();
- /* port MUST be set after the IPA lookup/conversion is perofrmed. */
- ipa.SetPort(port);
-
while (*head)
head = &(*head)->next;
- s = static_cast(xcalloc(1, sizeof(*s)));
- s->s = ipa;
-
*head = s;
}
static void
-parse_IPAddress_list(IPAddress_list ** head)
+parse_sockaddr_in_list(sockaddr_in_list ** head)
{
char *token;
while ((token = strtok(NULL, w_space))) {
- parse_IPAddress_list_token(head, token);
+ parse_sockaddr_in_list_token(head, token);
}
}
static void
-dump_IPAddress_list(StoreEntry * e, const char *n, const IPAddress_list * s)
+dump_sockaddr_in_list(StoreEntry * e, const char *n, const sockaddr_in_list * s)
{
- char ntoabuf[MAX_IPSTRLEN];
-
while (s) {
- storeAppendPrintf(e, "%s %s\n",
+ storeAppendPrintf(e, "%s %s:%d\n",
n,
- s->s.NtoA(ntoabuf,MAX_IPSTRLEN));
+ inet_ntoa(s->s.sin_addr),
+ ntohs(s->s.sin_port));
s = s->next;
}
}
static void
-free_IPAddress_list(IPAddress_list ** head)
+free_sockaddr_in_list(sockaddr_in_list ** head)
{
- if(*head) delete *head; *head = NULL;
+ sockaddr_in_list *s;
+
+ while ((s = *head) != NULL) {
+ *head = s->next;
+ xfree(s);
+ }
}
#if CURRENTLY_UNUSED
@@ -2774,7 +2768,7 @@
* be used by icp_port and htcp_port
*/
static int
-check_null_IPAddress_list(const IPAdress_list * s)
+check_null_sockaddr_in_list(const sockaddr_in_list * s)
{
return NULL == s;
}
@@ -2782,73 +2776,44 @@
#endif /* CURRENTLY_UNUSED */
#endif /* USE_WCCPv2 */
+CBDATA_CLASS_INIT(http_port_list);
+
static void
parse_http_port_specification(http_port_list * s, char *token)
{
char *host = NULL;
+
+ const struct hostent *hp;
unsigned short port = 0;
- char *t = NULL;
- char *junk = NULL;
+ char *t;
s->disable_pmtu_discovery = DISABLE_PMTU_OFF;
- s->name = strdup(token);
-#if USE_IPV6
- if (*token == '[') {
- /* [ipv6]:port */
- host = token + 1;
- t = strchr(host, ']');
- if (!t) {
- debugs(3, 0, "http(s)_port: missing ']' on IPv6 address: " << token);
- self_destruct();
- }
- *t++ = '\0';
- if (*t != ':') {
- debugs(3, 0, "http(s)_port: missing Port in: " << token);
- self_destruct();
- }
- port = xatos(t + 1);
- } else
-#endif
if ((t = strchr(token, ':'))) {
/* host:port */
- /* ipv4:port */
host = token;
*t = '\0';
port = xatos(t + 1);
-
- } else if ((port = strtol(token, &junk, 10)), !*junk) {
- /* port */
- debugs(3, 3, "http(s)_port: found Listen on Port: " << port);
} else {
- debugs(3, 0, "http(s)_port: missing Port: " << token);
- self_destruct();
+ /* port */
+ port = xatos(token);
}
- if (port == 0) {
- debugs(3, 0, "http(s)_port: Port cannot be 0: " << token);
+ if (port == 0)
self_destruct();
- }
- if (NULL == host) {
- s->s.SetAnyAddr();
- s->s.SetPort(port);
- debugs(3, 3, "http(s)_port: found Listen on wildcard address: " << s->s);
- }
- else if ( s->s = host ) { /* check/parse numeric IPA */
- s->s.SetPort(port);
- debugs(3, 3, "http(s)_port: Listen on Host/IP: " << host << " --> " << s->s);
- }
- else if ( s->s.GetHostByName(host) ) { /* check/parse for FQDN */
+ s->s.sin_port = htons(port);
+
+ if (NULL == host)
+ s->s.sin_addr = any_addr;
+ else if (1 == safe_inet_addr(host, &s->s.sin_addr))
+ (void) 0;
+ else if ((hp = gethostbyname(host))) {
/* dont use ipcache */
+ s->s.sin_addr = inaddrFromHostent(hp);
s->defaultsite = xstrdup(host);
- s->s.SetPort(port);
- debugs(3, 3, "http(s)_port: found Listen as Host " << s->defaultsite << " on IP: " << s->s);
- }
- else {
- debugs(3, 0, "http(s)_port: failed to resolve Host/IP: " << host);
+ } else
self_destruct();
- }
}
static void
@@ -2863,13 +2828,6 @@
s->name = xstrdup(token + 5);
} else if (strcmp(token, "transparent") == 0) {
s->transparent = 1;
-#if USE_IPV6
- /* INET6: until transparent REDIRECT works on IPv6 SOCKET, force wildcard to IPv4 */
- if( !s->s.SetIPv4() ) {
- debugs(3, 0, "http(s)_port: IPv6 addresses cannot be 'transparent' (protocol does not provide NAT)" << s->s );
- self_destruct();
- }
-#endif
} else if (strcmp(token, "vhost") == 0) {
s->vhost = 1;
s->accel = 1;
@@ -2899,48 +2857,58 @@
} else if (strcmp(token, "tproxy") == 0) {
s->tproxy = 1;
need_linux_tproxy = 1;
-#if USE_IPV6
- /* INET6: until transparent REDIRECT works on IPv6 SOCKET, force wildcard to IPv4 */
- if( s->s.IsIPv6() && !s->s.SetIPv4() ) {
- debugs(3, 0, "http(s)_port: IPv6 addresses cannot be transparent (protocol does not provide NAT)" << s->s );
- self_destruct();
- }
#endif
-#endif
- } else if (strcmp(token, "ipv4") == 0) {
-#if USE_IPV6
- if( !s->s.SetIPv4() ) {
- debugs(3, 0, "http(s)_port: IPv6 addresses cannot be used a IPv4-Only." << s->s );
+#if USE_SSL
+ } else if (strncmp(token, "cert=", 5) == 0) {
+ safe_free(s->cert);
+ s->cert = xstrdup(token + 5);
+ } else if (strncmp(token, "key=", 4) == 0) {
+ safe_free(s->key);
+ s->key = xstrdup(token + 4);
+ } else if (strncmp(token, "version=", 8) == 0) {
+ s->version = xatoi(token + 8);
+
+ if (s->version < 1 || s->version > 4)
self_destruct();
- }
+ } else if (strncmp(token, "options=", 8) == 0) {
+ safe_free(s->options);
+ s->options = xstrdup(token + 8);
+ } else if (strncmp(token, "cipher=", 7) == 0) {
+ safe_free(s->cipher);
+ s->cipher = xstrdup(token + 7);
+ } else if (strncmp(token, "clientca=", 9) == 0) {
+ safe_free(s->clientca);
+ s->clientca = xstrdup(token + 9);
+ } else if (strncmp(token, "cafile=", 7) == 0) {
+ safe_free(s->cafile);
+ s->cafile = xstrdup(token + 7);
+ } else if (strncmp(token, "capath=", 7) == 0) {
+ safe_free(s->capath);
+ s->capath = xstrdup(token + 7);
+ } else if (strncmp(token, "crlfile=", 8) == 0) {
+ safe_free(s->crlfile);
+ s->crlfile = xstrdup(token + 8);
+ } else if (strncmp(token, "dhparams=", 9) == 0) {
+ safe_free(s->dhfile);
+ s->dhfile = xstrdup(token + 9);
+ } else if (strncmp(token, "sslflags=", 9) == 0) {
+ safe_free(s->sslflags);
+ s->sslflags = xstrdup(token + 9);
+ } else if (strncmp(token, "sslcontext=", 11) == 0) {
+ safe_free(s->sslcontext);
+ s->sslcontext = xstrdup(token + 11);
+ } else if (strcmp(token, "sslBump") == 0) {
+ s->sslBump = 1; // accelerated when bumped, otherwise not
#endif
} else {
self_destruct();
}
}
-static void
-free_generic_http_port_data(http_port_list * s)
-{
- safe_free(s->name);
- safe_free(s->defaultsite);
- safe_free(s->protocol);
-}
-
-static void
-cbdataFree_http_port(void *data)
-{
- free_generic_http_port_data((http_port_list *)data);
-}
-
static http_port_list *
create_http_port(char *portspec)
{
- CBDATA_TYPE(http_port_list);
- CBDATA_INIT_TYPE_FREECB(http_port_list, cbdataFree_http_port);
-
- http_port_list *s = cbdataAlloc(http_port_list);
- s->protocol = xstrdup("http");
+ http_port_list *s = new http_port_list("http");
parse_http_port_specification(s, portspec);
return s;
}
@@ -2979,11 +2947,10 @@
static void
dump_generic_http_port(StoreEntry * e, const char *n, const http_port_list * s)
{
- char buf[MAX_IPSTRLEN];
-
- storeAppendPrintf(e, "%s %s",
+ storeAppendPrintf(e, "%s %s:%d",
n,
- s->s.ToURL(buf,MAX_IPSTRLEN));
+ inet_ntoa(s->s.sin_addr),
+ ntohs(s->s.sin_port));
if (s->defaultsite)
storeAppendPrintf(e, " defaultsite=%s", s->defaultsite);
@@ -3007,6 +2974,44 @@
storeAppendPrintf(e, " disable-pmtu-discovery=%s", pmtu);
}
+
+#if USE_SSL
+ if (s->cert)
+ storeAppendPrintf(e, " cert=%s", s->cert);
+
+ if (s->key)
+ storeAppendPrintf(e, " key=%s", s->key);
+
+ if (s->version)
+ storeAppendPrintf(e, " version=%d", s->version);
+
+ if (s->options)
+ storeAppendPrintf(e, " options=%s", s->options);
+
+ if (s->cipher)
+ storeAppendPrintf(e, " cipher=%s", s->cipher);
+
+ if (s->cafile)
+ storeAppendPrintf(e, " cafile=%s", s->cafile);
+
+ if (s->capath)
+ storeAppendPrintf(e, " capath=%s", s->capath);
+
+ if (s->crlfile)
+ storeAppendPrintf(e, " crlfile=%s", s->crlfile);
+
+ if (s->dhfile)
+ storeAppendPrintf(e, " dhparams=%s", s->dhfile);
+
+ if (s->sslflags)
+ storeAppendPrintf(e, " sslflags=%s", s->sslflags);
+
+ if (s->sslcontext)
+ storeAppendPrintf(e, " sslcontext=%s", s->sslcontext);
+
+ if (s->sslBump)
+ storeAppendPrintf(e, " sslBump");
+#endif
}
static void
@@ -3026,87 +3031,30 @@
while ((s = *head) != NULL) {
*head = s->next;
- cbdataFree(s);
+ delete s;
}
}
#if USE_SSL
-static void
-cbdataFree_https_port(void *data)
-{
- https_port_list *s = (https_port_list *)data;
- free_generic_http_port_data(&s->http);
- safe_free(s->cert);
- safe_free(s->key);
- safe_free(s->options);
- safe_free(s->cipher);
- safe_free(s->cafile);
- safe_free(s->capath);
- safe_free(s->dhfile);
- safe_free(s->sslflags);
-}
+// TODO: merge better with parse_http_port_list
static void
parse_https_port_list(https_port_list ** head)
{
- CBDATA_TYPE(https_port_list);
char *token;
https_port_list *s;
- CBDATA_INIT_TYPE_FREECB(https_port_list, cbdataFree_https_port);
+
token = strtok(NULL, w_space);
if (!token)
self_destruct();
- s = cbdataAlloc(https_port_list);
-
- s->http.protocol = xstrdup("https");
-
+ s = new https_port_list;
parse_http_port_specification(&s->http, token);
/* parse options ... */
while ((token = strtok(NULL, w_space))) {
- if (strncmp(token, "cert=", 5) == 0) {
- safe_free(s->cert);
- s->cert = xstrdup(token + 5);
- } else if (strncmp(token, "key=", 4) == 0) {
- safe_free(s->key);
- s->key = xstrdup(token + 4);
- } else if (strncmp(token, "version=", 8) == 0) {
- s->version = xatoi(token + 8);
-
- if (s->version < 1 || s->version > 4)
- self_destruct();
- } else if (strncmp(token, "options=", 8) == 0) {
- safe_free(s->options);
- s->options = xstrdup(token + 8);
- } else if (strncmp(token, "cipher=", 7) == 0) {
- safe_free(s->cipher);
- s->cipher = xstrdup(token + 7);
- } else if (strncmp(token, "clientca=", 9) == 0) {
- safe_free(s->clientca);
- s->clientca = xstrdup(token + 9);
- } else if (strncmp(token, "cafile=", 7) == 0) {
- safe_free(s->cafile);
- s->cafile = xstrdup(token + 7);
- } else if (strncmp(token, "capath=", 7) == 0) {
- safe_free(s->capath);
- s->capath = xstrdup(token + 7);
- } else if (strncmp(token, "crlfile=", 8) == 0) {
- safe_free(s->crlfile);
- s->crlfile = xstrdup(token + 8);
- } else if (strncmp(token, "dhparams=", 9) == 0) {
- safe_free(s->dhfile);
- s->dhfile = xstrdup(token + 9);
- } else if (strncmp(token, "sslflags=", 9) == 0) {
- safe_free(s->sslflags);
- s->sslflags = xstrdup(token + 9);
- } else if (strncmp(token, "sslcontext=", 11) == 0) {
- safe_free(s->sslcontext);
- s->sslcontext = xstrdup(token + 11);
- } else {
- parse_http_port_option(&s->http, token);
- }
+ parse_http_port_option(s, token);
}
while (*head) {
@@ -3120,57 +3068,13 @@
static void
dump_https_port_list(StoreEntry * e, const char *n, const https_port_list * s)
{
- while (s) {
- dump_generic_http_port(e, n, &s->http);
-
- if (s->cert)
- storeAppendPrintf(e, " cert=%s", s->cert);
-
- if (s->key)
- storeAppendPrintf(e, " key=%s", s->key);
-
- if (s->version)
- storeAppendPrintf(e, " version=%d", s->version);
-
- if (s->options)
- storeAppendPrintf(e, " options=%s", s->options);
-
- if (s->cipher)
- storeAppendPrintf(e, " cipher=%s", s->cipher);
-
- if (s->cafile)
- storeAppendPrintf(e, " cafile=%s", s->cafile);
-
- if (s->capath)
- storeAppendPrintf(e, " capath=%s", s->capath);
-
- if (s->crlfile)
- storeAppendPrintf(e, " crlfile=%s", s->crlfile);
-
- if (s->dhfile)
- storeAppendPrintf(e, " dhparams=%s", s->dhfile);
-
- if (s->sslflags)
- storeAppendPrintf(e, " sslflags=%s", s->sslflags);
-
- if (s->sslcontext)
- storeAppendPrintf(e, " sslcontext=%s", s->sslcontext);
-
- storeAppendPrintf(e, "\n");
-
- s = (https_port_list *) s->http.next;
- }
+ dump_http_port_list(e, n, s);
}
static void
free_https_port_list(https_port_list ** head)
{
- https_port_list *s;
-
- while ((s = *head) != NULL) {
- *head = (https_port_list *) s->http.next;
- cbdataFree(s);
- }
+ free_http_port_list((http_port_list**)head);
}
#if 0
Index: squid3/src/carp.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/carp.cc,v
retrieving revision 1.6.22.1
retrieving revision 1.6.22.2
diff -u -r1.6.22.1 -r1.6.22.2
--- squid3/src/carp.cc 25 Jan 2008 02:33:44 -0000 1.6.22.1
+++ squid3/src/carp.cc 27 Jan 2008 18:08:48 -0000 1.6.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: carp.cc,v 1.6.22.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: carp.cc,v 1.6.22.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 39 Cache Array Routing Protocol
* AUTHOR: Henrik Nordstrom
@@ -104,7 +104,7 @@
/* calculate this peers hash */
p->carp.hash = 0;
- for (t = p->name; *t != 0; t++)
+ for (t = p->host; *t != 0; t++)
p->carp.hash += ROTATE_LEFT(p->carp.hash, 19) + (unsigned int) *t;
p->carp.hash += p->carp.hash * 0x62531965;
@@ -189,7 +189,7 @@
combined_hash += combined_hash * 0x62531965;
combined_hash = ROTATE_LEFT(combined_hash, 21);
score = combined_hash * tp->carp.load_multiplier;
- debugs(39, 3, "carpSelectParent: " << tp->name << " combined_hash " << combined_hash <<
+ debugs(39, 3, "carpSelectParent: " << tp->host << " combined_hash " << combined_hash <<
" score " << std::setprecision(0) << score);
if ((score > high_score) && peerHTTPOkay(tp, request)) {
@@ -199,7 +199,7 @@
}
if (p)
- debugs(39, 2, "carpSelectParent: selected " << p->name);
+ debugs(39, 2, "carpSelectParent: selected " << p->host);
return p;
}
@@ -221,7 +221,7 @@
for (p = Config.peers; p; p = p->next) {
storeAppendPrintf(sentry, "%24s %10x %10f %10f %10f\n",
- p->name, p->carp.hash,
+ p->host, p->carp.hash,
p->carp.load_multiplier,
p->carp.load_factor,
sumfetches ? (double) p->stats.fetches / sumfetches : -1.0);
Index: squid3/src/cf.data.depend
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/cf.data.depend,v
retrieving revision 1.1.18.1
retrieving revision 1.1.18.2
diff -u -r1.1.18.1 -r1.1.18.2
--- squid3/src/cf.data.depend 25 Jan 2008 02:33:44 -0000 1.1.18.1
+++ squid3/src/cf.data.depend 27 Jan 2008 18:08:48 -0000 1.1.18.2
@@ -38,7 +38,7 @@
refreshpattern
removalpolicy
size_t
-IPAddress_list
+sockaddr_in_list
string
string
time_t
Index: squid3/src/cf.data.pre
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/cf.data.pre,v
retrieving revision 1.157.2.7
retrieving revision 1.157.2.8
diff -u -r1.157.2.7 -r1.157.2.8
--- squid3/src/cf.data.pre 25 Jan 2008 02:33:44 -0000 1.157.2.7
+++ squid3/src/cf.data.pre 27 Jan 2008 18:08:48 -0000 1.157.2.8
@@ -1,6 +1,6 @@
#
-# $Id: cf.data.pre,v 1.157.2.7 2008/01/25 02:33:44 valexey_eykon Exp $
+# $Id: cf.data.pre,v 1.157.2.8 2008/01/27 18:08:48 rousskov Exp $
#
# SQUID Web Proxy Cache http://www.squid-cache.org/
# ----------------------------------------------------------
@@ -368,11 +368,6 @@
cached entry should be initiated without needing to
wait for a new reply. (default 0 for no grace period)
protocol=2.5 Compatibility mode for Squid-2.5 external acl helpers
- ipv4 / ipv6 IP-mode used to communicate to this helper.
- For compatability with older configurations and helpers
- 'ipv4' is the default unless --with-localhost-ipv6 is used.
- --with-localhost-ipv6 changes the default to 'ipv6'.
- SPECIAL NOTE: these options override --with-localhost-ipv6
FORMAT specifications
@@ -493,7 +488,6 @@
acl aclname port 80 70 21 ...
acl aclname port 0-1024 ... # ranges allowed
acl aclname myport 3128 ... # (local socket TCP port)
- acl aclname myportname 3128 ... # http(s)_port name
acl aclname proto HTTP FTP ...
acl aclname method GET POST ...
acl aclname browser [-i] regexp ...
@@ -926,8 +920,18 @@
sporadically hang or never complete requests set
disable-pmtu-discovery option to 'transparent'.
- name= Specifies a internal name for the port. Defaults to
- the port specification (port or addr:port)
+ sslBump Intercept each CONNECT request, establish secure
+ connection with the client and with the server,
+ decrypt HTTP messages as they pass through Squid, and
+ treat them as unencrypted HTTP messages, becoming the
+ man-in-the-middle.
+
+ When this option is enabled, additional options become
+ available to specify SSL-related properties of the
+ client-side connection: cert, key, version, cipher,
+ options, clientca, cafile, capath, crlfile, dhparams,
+ sslflags, and sslcontext. See the https_port directive
+ for more information on these options.
If you run Squid on a dual-homed machine with an internal
and an external interface we recommend you to specify the
@@ -1041,9 +1045,6 @@
vport=NN As above, but uses specified port number rather
than the https_port number. Implies accel.
- name= Specifies a internal name for the port. Defaults to
- the port specification (port or addr:port)
-
DOC_END
NAME: tcp_outgoing_tos tcp_outgoing_ds tcp_outgoing_dscp
@@ -1109,11 +1110,11 @@
source address 10.1.0.2 and the rest will be forwarded with
source address 10.1.0.3.
- acl normal_service_net src 10.0.0.0/24
- acl good_service_net src 10.0.2.0/24
- tcp_outgoing_address 10.1.0.1 normal_service_net
- tcp_outgoing_address 10.1.0.2 good_service_net
- tcp_outgoing_address 10.1.0.3
+ acl normal_service_net src 10.0.0.0/255.255.255.0
+ acl good_service_net src 10.0.1.0/255.255.255.0
+ tcp_outgoing_address 10.0.0.1 normal_service_net
+ tcp_outgoing_address 10.0.0.2 good_service_net
+ tcp_outgoing_address 10.0.0.3
Processing proceeds in the order specified, and stops at first fully
matching line.
@@ -1122,28 +1123,6 @@
incompatible with the use of server side persistent connections. To
ensure correct results it is best to set server_persistent_connections
to off when using this directive in such configurations.
-
-
- IPv6 Magic:
-
- Squid is built with a capability of bridging the IPv4 and IPv6 internets.
- tcp_outgoing_address as exampled above breaks this bridging by forcing
- all outbound traffic through a certain IPv4 which may be on the wrong
- side of the IPv4/IPv6 boundary.
-
- To operate with tcp_outgoing_address and keep the bridging benefits
- an additional ACL needs to be used which ensures the IPv6-bound traffic
- is never forced or permitted out the IPv4 interface.
-
- acl to_ipv6 dst ipv6
- tcp_outgoing_address 2002::c001 good_service_net to_ipv6
- tcp_outgoing_address 10.1.0.2 good_service_net !to_ipv6
-
- tcp_outgoing_address 2002::beef normal_service_net to_ipv6
- tcp_outgoing_address 10.1.0.1 normal_service_net !to_ipv6
-
- tcp_outgoing_address 2002::1 to_ipv6
- tcp_outgoing_address 10.1.0.3 !to_ipv6
DOC_END
COMMENT_START
@@ -1243,12 +1222,48 @@
TYPE: string
DOC_START
Various flags modifying the use of SSL while proxying https:// URLs:
- DONT_VERIFY_PEER Accept certificates even if they fail to
- verify.
+ DONT_VERIFY_PEER Accept certificates that fail verification.
+ For refined control, see sslproxy_cert_error.
NO_DEFAULT_CA Don't use the default CA list built in
to OpenSSL.
DOC_END
+
+NAME: sslproxy_cert_error
+IFDEF: USE_SSL
+DEFAULT: none
+LOC: Config.ssl_client.cert_error
+TYPE: acl_access
+DOC_START
+ Use this ACL to bypass server certificate validation errors.
+
+ For example, the following lines will bypass all validation errors
+ when talking to servers located at 172.16.0.0/16. All other
+ validation errors will result in ERR_SECURE_CONNECT_FAIL error.
+
+ acl BrokenServersAtTrustedIP dst 172.16.0.0/16
+ sslproxy_cert_error allow BrokenServersAtTrustedIP
+ sslproxy_cert_error deny all
+
+ This option must use fast ACL expressions only. Expressions that use
+ external lookups or communication result in unpredictable behavior or
+ crashes.
+
+ Without this option, all server certificate validation errors
+ terminate the transaction. Bypassing validation errors is dangerous
+ because an error usually implies that the server cannot be trusted and
+ the connection may be insecure.
+
+ See also: sslproxy_flags and DONT_VERIFY_PEER.
+
+NOCOMMENT_START
+#Default setting:
+# sslproxy_cert_error deny all
+NOCOMMENT_END
+DOC_END
+
+
+
NAME: sslpassword_program
IFDEF: USE_SSL
DEFAULT: none
@@ -1751,6 +1766,7 @@
NAME: cache_dir
TYPE: cachedir
DEFAULT: none
+DEFAULT_IF_NONE: ufs @DEFAULT_SWAP_DIR@ 100 16 256
LOC: Config.cacheSwap
DOC_START
Usage:
@@ -1838,6 +1854,10 @@
called 'stripe' in the directory names in the config - and
this will be created by squid -z.
+ The null store type:
+
+ no options are allowed or required
+
Common options:
no-store, no new objects should be stored to this cache_dir
@@ -1851,9 +1871,6 @@
Note for coss, max-size must be less than COSS_MEMBUF_SZ,
which can be changed with the --with-coss-membuf-size=N configure
option.
-NOCOMMENT_START
-DEFAULT_IF_NONE: ufs @DEFAULT_SWAP_DIR@ 100 16 256
-NOCOMMENT_END
DOC_END
NAME: store_dir_select_algorithm
@@ -2210,7 +2227,7 @@
DOC_END
NAME: debug_options
-TYPE: eol
+TYPE: debug
DEFAULT: ALL,1
LOC: Config.debugOptions
DOC_START
@@ -2279,16 +2296,6 @@
enabled in which case performance will suffer badly anyway..).
DOC_END
-NAME: netdb_filename
-TYPE: string
-DEFAULT: @DEFAULT_NETDB_FILE@
-LOC: Config.netdbFilename
-IFDEF: USE_ICMP
-DOC_START
- A filename where Squid stores it's netdb state between restarts.
- To disable, enter "none".
-DOC_END
-
COMMENT_START
OPTIONS FOR FTP GATEWAYING
-----------------------------------------------------------------------------
@@ -2327,29 +2334,6 @@
DOC_START
If your firewall does not allow Squid to use passive
connections, turn off this option.
-
- Use of ftp_epsv_all option requires this to be ON.
-DOC_END
-
-NAME: ftp_epsv_all
-TYPE: onoff
-DEFAULT: off
-LOC: Config.Ftp.epsv_all
-DOC_START
- FTP Protocol extensions permit the use of a special "EPSV ALL" command.
-
- NATs may be able to put the connection on a "fast path" through the
- translator, as the EPRT command will never be used and therefore,
- translation of the data portion of the segments will never be needed.
-
- When a client only expects to do two-way FTP transfers this may be useful.
- If squid finds that it must do a three-way FTP transfer after issuing
- an EPSV ALL command, the FTP session will fail.
-
- If you have any doubts about this option do not use it.
- Squid will nicely attempt all other connection methods.
-
- Requires ftp_passive to be ON (default)
DOC_END
NAME: ftp_sanitycheck
@@ -2408,23 +2392,12 @@
NAME: pinger_program
TYPE: string
DEFAULT: @DEFAULT_PINGER@
-LOC: Config.pinger.program
+LOC: Config.Program.pinger
IFDEF: USE_ICMP
DOC_START
Specify the location of the executable for the pinger process.
DOC_END
-NAME: pinger_enable
-TYPE: onoff
-DEFAULT: on
-LOC: Config.pinger.enable
-IFDEF: USE_ICMP
-DOC_START
- Control whether the pinger is active at run-time.
- Enables turning ICMP pinger on and off with a simple squid -k reconfigure.
-DOC_END
-
-
COMMENT_START
OPTIONS FOR URL REWRITING
-----------------------------------------------------------------------------
@@ -3679,7 +3652,7 @@
IFDEF: USE_WCCP
DOC_NONE
NAME: wccp2_router
-TYPE: IPAddress_list
+TYPE: sockaddr_in_list
LOC: Config.Wccp2.router
DEFAULT: none
IFDEF: USE_WCCPv2
@@ -5121,26 +5094,6 @@
nameservers by setting this option to 'off'.
DOC_END
-NAME: dns_v4_fallback
-TYPE: onoff
-DEFAULT: on
-LOC: Config.onoff.dns_require_A
-DOC_START
- Standard practice with DNS is to lookup either A or AAAA records
- and use the results if it succeeds. Only looking up the other if
- the first attempt fails or otherwise produces no results.
-
- That policy however will cause squid to produce error pages for some
- servers that advertise AAAA but are unreachable over IPv6.
-
- If this is ON squid will always lookup both AAAA and A, using both.
- If this is OFF squid will lookup AAAA and only try A if none found.
-
- WARNING: There are some possibly unwanted side-effects with this on:
- *) Doubles the load placed by squid on the DNS network.
- *) May negatively impact connection delay times.
-DOC_END
-
NAME: ipcache_size
COMMENT: (number of entries)
TYPE: int
@@ -5445,17 +5398,14 @@
NAME: balance_on_multiple_ip
TYPE: onoff
LOC: Config.onoff.balance_on_multiple_ip
-DEFAULT: off
+DEFAULT: on
DOC_START
- Modern IP resolvers in squid sort lookup results by preferred access.
- By default squid will use these IP in order and only rotates to
- the next listed when the most preffered fails.
-
Some load balancing servers based on round robin DNS have been
found not to preserve user session state across requests
to different IP addresses.
- Enabling this directive Squid rotates IP's per request.
+ By default Squid rotates IP's per request. By disabling
+ this directive only connection failure triggers rotation.
DOC_END
NAME: pipeline_prefetch
Index: squid3/src/client_db.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_db.cc,v
retrieving revision 1.14.6.1
retrieving revision 1.14.6.2
diff -u -r1.14.6.1 -r1.14.6.2
--- squid3/src/client_db.cc 25 Jan 2008 02:33:44 -0000 1.14.6.1
+++ squid3/src/client_db.cc 27 Jan 2008 18:08:48 -0000 1.14.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: client_db.cc,v 1.14.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_db.cc,v 1.14.6.2 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 0 Client Database
* AUTHOR: Duane Wessels
@@ -42,7 +42,7 @@
static hash_table *client_table = NULL;
-static ClientInfo *clientdbAdd(const IPAddress &addr);
+static ClientInfo *clientdbAdd(struct IN_ADDR addr);
static FREE clientdbFreeItem;
static void clientdbStartGC(void);
static void clientdbScheduledGC(void *);
@@ -56,12 +56,11 @@
static ClientInfo *
-clientdbAdd(const IPAddress &addr)
+clientdbAdd(struct IN_ADDR addr)
{
ClientInfo *c;
- char *buf = new char[MAX_IPSTRLEN];
c = (ClientInfo *)memAllocate(MEM_CLIENT_INFO);
- c->hash.key = addr.NtoA(buf,MAX_IPSTRLEN);
+ c->hash.key = xstrdup(inet_ntoa(addr));
c->addr = addr;
hash_join(client_table, &c->hash);
statCounter.client_http.clients++;
@@ -95,15 +94,15 @@
void
-clientdbUpdate(const IPAddress &addr, log_type ltype, protocol_t p, size_t size)
+clientdbUpdate(struct IN_ADDR addr, log_type ltype, protocol_t p, size_t size)
{
- char key[MAX_IPSTRLEN];
+ char *key;
ClientInfo *c;
if (!Config.onoff.client_db)
return;
- addr.NtoA(key,MAX_IPSTRLEN);
+ key = inet_ntoa(addr);
c = (ClientInfo *) hash_lookup(client_table, key);
@@ -141,21 +140,21 @@
* -1. To get the current value, simply call with delta = 0.
*/
int
-clientdbEstablished(const IPAddress &addr, int delta)
+
+clientdbEstablished(struct IN_ADDR addr, int delta)
{
- char key[MAX_IPSTRLEN];
+ char *key;
ClientInfo *c;
if (!Config.onoff.client_db)
return 0;
- addr.NtoA(key,MAX_IPSTRLEN);
+ key = inet_ntoa(addr);
c = (ClientInfo *) hash_lookup(client_table, key);
- if (c == NULL) {
+ if (c == NULL)
c = clientdbAdd(addr);
- }
if (c == NULL)
debug_trap("clientdbUpdate: Failed to add entry");
@@ -168,9 +167,9 @@
#define CUTOFF_SECONDS 3600
int
-clientdbCutoffDenied(const IPAddress &addr)
+clientdbCutoffDenied(struct IN_ADDR addr)
{
- char key[MAX_IPSTRLEN];
+ char *key;
int NR;
int ND;
double p;
@@ -179,7 +178,7 @@
if (!Config.onoff.client_db)
return 0;
- addr.NtoA(key,MAX_IPSTRLEN);
+ key = inet_ntoa(addr);
c = (ClientInfo *) hash_lookup(client_table, key);
@@ -385,35 +384,36 @@
#if SQUID_SNMP
-IPAddress *
-client_entry(IPAddress *current)
+struct in_addr*
+client_entry(struct IN_ADDR *current)
{
ClientInfo *c = NULL;
- char key[MAX_IPSTRLEN];
+ char *key;
if (current)
{
- current->NtoA(key,MAX_IPSTRLEN);
+ key = inet_ntoa(*current);
hash_first(client_table);
+
while ((c = (ClientInfo *) hash_next(client_table))) {
- if (!strcmp(key, hashKeyStr(&c->hash)))
+ if (!strcmp(key, hashKeyStr(&c->hash)))
break;
}
-
+
c = (ClientInfo *) hash_next(client_table);
} else
{
- hash_first(client_table);
- c = (ClientInfo *) hash_next(client_table);
+ hash_first(client_table);
+ c = (ClientInfo *) hash_next(client_table);
}
hash_last(client_table);
if (c)
- return (&c->addr);
+ return (&c->addr);
else
- return (NULL);
-
+ return (NULL);
+
}
variable_list *
@@ -423,12 +423,10 @@
static char key[16];
ClientInfo *c = NULL;
int aggr = 0;
-
log_type l;
*ErrP = SNMP_ERR_NOERROR;
debugs(49, 6, "snmp_meshCtblFn: Current : ");
snmpDebugOid(6, Var->name, Var->name_length);
- /* FIXME INET6 : This must implement the key for IPv6 address */
snprintf(key, sizeof(key), "%d.%d.%d.%d", Var->name[LEN_SQ_NET + 3], Var->name[LEN_SQ_NET + 4],
Var->name[LEN_SQ_NET + 5], Var->name[LEN_SQ_NET + 6]);
debugs(49, 5, "snmp_meshCtblFn: [" << key << "] requested!");
@@ -442,28 +440,12 @@
switch (Var->name[LEN_SQ_NET + 2]) {
- case MESH_CTBL_ADDR_TYPE:
- {
- int ival;
- ival = c->addr.IsIPv4() ? INETADDRESSTYPE_IPV4 : INETADDRESSTYPE_IPV6 ;
- Answer = snmp_var_new_integer(Var->name, Var->name_length,
- ival, SMI_INTEGER);
- }
- break;
-
case MESH_CTBL_ADDR:
- {
- Answer = snmp_var_new(Var->name, Var->name_length);
- // InetAddress doesn't have its own ASN.1 type,
- // like IpAddr does (SMI_IPADDRESS)
- // See: rfc4001.txt
- Answer->type = ASN_OCTET_STR;
- char client[MAX_IPSTRLEN];
- c->addr.NtoA(client,MAX_IPSTRLEN);
- Answer->val_len = strlen(client);
- Answer->val.string = (u_char *) xstrdup(client);
- }
+ Answer = snmp_var_new_integer(Var->name, Var->name_length,
+ (snint) c->addr.s_addr,
+ SMI_IPADDRESS);
break;
+
case MESH_CTBL_HTBYTES:
Answer = snmp_var_new_integer(Var->name, Var->name_length,
(snint) c->Http.kbytes_out.kb,
Index: squid3/src/client_side.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side.cc,v
retrieving revision 1.139.6.9
retrieving revision 1.139.6.10
diff -u -r1.139.6.9 -r1.139.6.10
--- squid3/src/client_side.cc 25 Jan 2008 02:33:44 -0000 1.139.6.9
+++ squid3/src/client_side.cc 27 Jan 2008 18:08:48 -0000 1.139.6.10
@@ -1,6 +1,6 @@
/*
- * $Id: client_side.cc,v 1.139.6.9 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_side.cc,v 1.139.6.10 2008/01/27 18:08:48 rousskov Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
@@ -58,6 +58,7 @@
#include "squid.h"
#include "client_side.h"
#include "clientStream.h"
+#include "ProtoPort.h"
#include "IPInterception.h"
#include "AuthUserRequest.h"
#include "Store.h"
@@ -130,7 +131,7 @@
static PF clientLifetimeTimeout;
static ClientSocketContext *parseHttpRequestAbort(ConnStateData::Pointer & conn,
const char *uri);
-static ClientSocketContext *parseHttpRequest(ConnStateData::Pointer &, HttpParser *, HttpRequestMethod *, HttpVersion *);
+static ClientSocketContext *parseHttpRequest(ConnStateData::Pointer &, HttpParser *, method_t *, HttpVersion *);
#if USE_IDENT
static IDCB clientIdentDone;
#endif
@@ -161,7 +162,8 @@
static int connKeepReadingIncompleteRequest(ConnStateData::Pointer & conn);
static void connCancelIncompleteRequests(ConnStateData::Pointer & conn);
-static ConnStateData *connStateCreate(const IPAddress &peer, const IPAddress &me, int fd, http_port_list *port);
+static ConnStateData *connStateCreate(struct sockaddr_in *peer, struct sockaddr_in *me, int fd, http_port_list *port);
+
int
ClientSocketContext::fd() const
@@ -492,9 +494,7 @@
if (loggingEntry() && loggingEntry()->mem_obj)
al.cache.objectSize = loggingEntry()->contentLen();
- al.cache.caddr.SetNoAddr();
-
- if(getConn() != NULL) al.cache.caddr = getConn()->log_addr;
+ al.cache.caddr = getConn() != NULL ? getConn()->log_addr : no_addr;
al.cache.size = out.size;
@@ -531,7 +531,7 @@
updateCounters();
if (getConn() != NULL)
- clientdbUpdate(getConn()->peer, logType, PROTO_HTTP, out.size);
+ clientdbUpdate(getConn()->peer.sin_addr, logType, PROTO_HTTP, out.size);
}
delete checklist;
@@ -606,7 +606,7 @@
openReference = NULL;
fd = -1;
flags.readMoreRequests = false;
- clientdbEstablished(peer, -1); /* decrement */
+ clientdbEstablished(peer.sin_addr, -1); /* decrement */
assert(areAllContextsForThisConnection());
freeAllContexts();
@@ -655,7 +655,7 @@
debugs(33, 3, "clientSetKeepaliveFlag: http_ver = " <<
request->http_ver.major << "." << request->http_ver.minor);
debugs(33, 3, "clientSetKeepaliveFlag: method = " <<
- RequestMethodStr(request->method));
+ RequestMethodStr[request->method]);
HttpVersion http_ver(1,0);
/* we are HTTP/1.0, no matter what the client requests... */
@@ -1722,7 +1722,6 @@
int vhost = conn->port->vhost;
int vport = conn->port->vport;
char *host;
- char ntoabuf[MAX_IPSTRLEN];
http->flags.accel = 1;
@@ -1755,12 +1754,18 @@
if (internalCheck(url)) {
/* prepend our name & port */
http->uri = xstrdup(internalLocalUri(NULL, url));
- } else if (vhost && (host = mime_get_header(req_hdr, "Host")) != NULL) {
+ return;
+ }
+
+ const bool switchedToHttps = conn->switchedToHttps();
+ const bool tryHostHeader = vhost || switchedToHttps;
+ if (tryHostHeader && (host = mime_get_header(req_hdr, "Host")) != NULL) {
int url_sz = strlen(url) + 32 + Config.appendDomainLen +
strlen(host);
http->uri = (char *)xcalloc(url_sz, 1);
- snprintf(http->uri, url_sz, "%s://%s%s",
- conn->port->protocol, host, url);
+ const char *protocol = switchedToHttps ?
+ "https" : conn->port->protocol;
+ snprintf(http->uri, url_sz, "%s://%s%s", protocol, host, url);
debugs(33, 5, "ACCEL VHOST REWRITE: '" << http->uri << "'");
} else if (conn->port->defaultsite) {
int url_sz = strlen(url) + 32 + Config.appendDomainLen +
@@ -1775,8 +1780,8 @@
http->uri = (char *)xcalloc(url_sz, 1);
snprintf(http->uri, url_sz, "%s://%s:%d%s",
http->getConn()->port->protocol,
- http->getConn()->me.NtoA(ntoabuf,MAX_IPSTRLEN),
- http->getConn()->me.GetPort(), url);
+ inet_ntoa(http->getConn()->me.sin_addr),
+ ntohs(http->getConn()->me.sin_port), url);
debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
} else if (vport > 0) {
/* Put the local socket IP address as the hostname, but static port */
@@ -1784,7 +1789,7 @@
http->uri = (char *)xcalloc(url_sz, 1);
snprintf(http->uri, url_sz, "%s://%s:%d%s",
http->getConn()->port->protocol,
- http->getConn()->me.NtoA(ntoabuf,MAX_IPSTRLEN),
+ inet_ntoa(http->getConn()->me.sin_addr),
vport, url);
debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
}
@@ -1794,7 +1799,6 @@
prepareTransparentURL(ConnStateData::Pointer & conn, ClientHttpRequest *http, char *url, const char *req_hdr)
{
char *host;
- char ntoabuf[MAX_IPSTRLEN];
http->flags.transparent = 1;
@@ -1816,8 +1820,8 @@
http->uri = (char *)xcalloc(url_sz, 1);
snprintf(http->uri, url_sz, "%s://%s:%d%s",
http->getConn()->port->protocol,
- http->getConn()->me.NtoA(ntoabuf,MAX_IPSTRLEN),
- http->getConn()->me.GetPort(), url);
+ inet_ntoa(http->getConn()->me.sin_addr),
+ ntohs(http->getConn()->me.sin_port), url);
debugs(33, 5, "TRANSPARENT REWRITE: '" << http->uri << "'");
}
}
@@ -1832,7 +1836,7 @@
* Sets result->flags.parsed_ok to 1 if we have a good request.
*/
static ClientSocketContext *
-parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, HttpRequestMethod * method_p, HttpVersion *http_ver)
+parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * method_p, HttpVersion *http_ver)
{
char *url = NULL;
char *req_hdr = NULL;
@@ -1891,7 +1895,7 @@
}
/* Set method_p */
- *method_p = HttpRequestMethod(&hp->buf[hp->m_start], &hp->buf[hp->m_end]+1);
+ *method_p = HttpRequestMethod(&hp->buf[hp->m_start], &hp->buf[hp->m_end]);
if (*method_p == METHOD_NONE) {
/* XXX need a way to say "this many character length string" */
@@ -1961,7 +1965,7 @@
/* Rewrite the URL in transparent or accelerator mode */
if (conn->transparent()) {
prepareTransparentURL(conn, http, url, req_hdr);
- } else if (conn->port->accel) {
+ } else if (conn->port->accel || conn->switchedToHttps()) {
prepareAcceleratedURL(conn, http, url, req_hdr);
} else if (internalCheck(url)) {
/* prepend our name & port */
@@ -2100,7 +2104,7 @@
assert (repContext);
repContext->setReplyToError(ERR_TOO_BIG,
HTTP_REQUEST_ENTITY_TOO_LARGE, METHOD_NONE, NULL,
- conn->peer, NULL, NULL, NULL);
+ &conn->peer.sin_addr, NULL, NULL, NULL);
context->registerWithConn();
context->pullData();
}
@@ -2136,7 +2140,7 @@
}
static void
-clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketContext *context, const HttpRequestMethod& method, HttpVersion http_ver)
+clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketContext *context, method_t method, HttpVersion http_ver)
{
ClientHttpRequest *http = context->http;
HttpRequest *request = NULL;
@@ -2151,7 +2155,8 @@
debugs(33, 1, "clientProcessRequest: Invalid Request");
clientReplyContext *repContext = dynamic_cast(node->data.getRaw());
assert (repContext);
- repContext->setReplyToError(ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, NULL, conn->peer, NULL, conn->in.buf, NULL);
+ repContext->setReplyToError(ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, NULL,
+ &conn->peer.sin_addr, NULL, conn->in.buf, NULL);
assert(context->http->out.offset == 0);
context->pullData();
conn->flags.readMoreRequests = false;
@@ -2163,7 +2168,9 @@
debugs(33, 5, "Invalid URL: " << http->uri);
clientReplyContext *repContext = dynamic_cast(node->data.getRaw());
assert (repContext);
- repContext->setReplyToError(ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, conn->peer, NULL, NULL, NULL);
+ repContext->setReplyToError(
+ ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri,
+ &conn->peer.sin_addr, NULL, NULL, NULL);
assert(context->http->out.offset == 0);
context->pullData();
conn->flags.readMoreRequests = false;
@@ -2178,7 +2185,9 @@
debugs(33, 5, "Failed to parse request headers:\n" << HttpParserHdrBuf(hp));
clientReplyContext *repContext = dynamic_cast(node->data.getRaw());
assert (repContext);
- repContext->setReplyToError(ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, conn->peer, NULL, NULL, NULL);
+ repContext->setReplyToError(
+ ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri,
+ &conn->peer.sin_addr, NULL, NULL, NULL);
assert(context->http->out.offset == 0);
context->pullData();
conn->flags.readMoreRequests = false;
@@ -2195,11 +2204,12 @@
#endif
if (internalCheck(request->urlpath.buf())) {
- if (internalHostnameIs(request->GetHost()) &&
+ if (internalHostnameIs(request->host) &&
request->port == getMyPort()) {
http->flags.internal = 1;
} else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.buf())) {
- request->SetHost(internalHostname());
+ xstrncpy(request->host, internalHostname(),
+ SQUIDHOSTNAMELEN);
request->port = getMyPort();
http->flags.internal = 1;
}
@@ -2212,8 +2222,10 @@
request->flags.internal = http->flags.internal;
setLogUri (http, urlCanonicalClean(request));
- request->client_addr = conn->peer;
- request->my_addr = conn->me;
+ request->client_addr = conn->peer.sin_addr;
+ request->client_port = ntohs(conn->peer.sin_port);
+ request->my_addr = conn->me.sin_addr;
+ request->my_port = ntohs(conn->me.sin_port);
request->http_ver = http_ver;
if (!urlCheckRequest(request) ||
@@ -2223,7 +2235,7 @@
assert (repContext);
repContext->setReplyToError(ERR_UNSUP_REQ,
HTTP_NOT_IMPLEMENTED, request->method, NULL,
- conn->peer, request, NULL, NULL);
+ &conn->peer.sin_addr, request, NULL, NULL);
assert(context->http->out.offset == 0);
context->pullData();
conn->flags.readMoreRequests = false;
@@ -2237,7 +2249,7 @@
assert (repContext);
repContext->setReplyToError(ERR_INVALID_REQ,
HTTP_LENGTH_REQUIRED, request->method, NULL,
- conn->peer, request, NULL, NULL);
+ &conn->peer.sin_addr, request, NULL, NULL);
assert(context->http->out.offset == 0);
context->pullData();
conn->flags.readMoreRequests = false;
@@ -2273,7 +2285,7 @@
assert (repContext);
repContext->setReplyToError(ERR_TOO_BIG,
HTTP_REQUEST_ENTITY_TOO_LARGE, METHOD_NONE, NULL,
- conn->peer, http->request, NULL, NULL);
+ &conn->peer.sin_addr, http->request, NULL, NULL);
assert(context->http->out.offset == 0);
context->pullData();
goto finish;
@@ -2356,7 +2368,7 @@
static bool
clientParseRequest(ConnStateData::Pointer conn, bool &do_next_read)
{
- HttpRequestMethod method;
+ method_t method;
ClientSocketContext *context;
bool parsed_req = false;
HttpVersion http_ver;
@@ -2445,7 +2457,6 @@
/* Bail out quickly on COMM_ERR_CLOSING - close handlers will tidy up */
if (flag == COMM_ERR_CLOSING) {
- debugs(33,5, HERE << " FD " << fd << " closing Bailout.");
return;
}
@@ -2663,7 +2674,8 @@
clientLifetimeTimeout(int fd, void *data)
{
ClientHttpRequest *http = (ClientHttpRequest *)data;
- debugs(33, 1, "WARNING: Closing client " << http->getConn()->peer << " connection due to lifetime timeout");
+ debugs(33, 1, "WARNING: Closing client " << inet_ntoa(http->getConn()->peer.sin_addr) <<
+ " connection due to lifetime timeout");
debugs(33, 1, "\t" << http->uri);
comm_close(fd);
}
@@ -2686,13 +2698,13 @@
ConnStateData *
-connStateCreate(const IPAddress &peer, const IPAddress &me, int fd, http_port_list *port)
+connStateCreate(struct sockaddr_in *peer, struct sockaddr_in *me, int fd, http_port_list *port)
{
ConnStateData *result = new ConnStateData;
- result->peer = peer;
- result->log_addr = peer;
- result->log_addr.ApplyMask(Config.Addrs.client_netmask.GetCIDR());
- result->me = me;
+ result->peer = *peer;
+ result->log_addr = peer->sin_addr;
+ result->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
+ result->me = *me;
result->fd = fd;
result->in.buf = (char *)memAllocBuf(CLIENT_REQ_BUF_SZ, &result->in.allocatedSize);
result->port = cbdataReference(port);
@@ -2700,10 +2712,10 @@
if (port->transparent)
{
- IPAddress dst;
+ struct sockaddr_in dst;
- if (clientNatLookup(fd, me, peer, dst) == 0) {
- result-> me = dst; /* XXX This should be moved to another field */
+ if (clientNatLookup(fd, *me, *peer, &dst) == 0) {
+ result->me = dst; /* XXX This should be moved to another field */
result->transparent(true);
}
}
@@ -2757,11 +2769,11 @@
debugs(33, 4, "httpAccept: FD " << newfd << ": accepted");
fd_note(newfd, "client http connect");
- connState = connStateCreate(details->peer, details->me, newfd, s);
+ connState = connStateCreate(&details->peer, &details->me, newfd, s);
comm_add_close_handler(newfd, connStateClosed, connState);
if (Config.onoff.log_fqdn)
- fqdncache_gethostbyaddr(details->peer, FQDN_LOOKUP_IF_MISS);
+ fqdncache_gethostbyaddr(details->peer.sin_addr, FQDN_LOOKUP_IF_MISS);
commSetTimeout(newfd, Config.Timeout.request, requestTimeout, connState);
@@ -2769,28 +2781,55 @@
ACLChecklist identChecklist;
- identChecklist.src_addr = details->peer;
+ identChecklist.src_addr = details->peer.sin_addr;
- identChecklist.my_addr = details->me;
+ identChecklist.my_addr = details->me.sin_addr;
+
+ identChecklist.my_port = ntohs(details->me.sin_port);
identChecklist.accessList = cbdataReference(Config.accessList.identLookup);
/* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */
if (identChecklist.fastCheck())
- identStart(details->me, details->peer, clientIdentDone, connState);
+ identStart(&details->me, &details->peer, clientIdentDone, connState);
+
#endif
connState->readSomeData();
- clientdbEstablished(details->peer, 1);
+ clientdbEstablished(details->peer.sin_addr, 1);
incoming_sockets_accepted++;
}
#if USE_SSL
+// Create SSL connection structure and update fd_table
+static SSL *
+httpsCreate(int newfd, ConnectionDetail *details, SSL_CTX *sslContext)
+{
+ SSL *ssl = SSL_new(sslContext);
+
+ if (!ssl) {
+ const int ssl_error = ERR_get_error();
+ debugs(83, 1, "httpsAccept: Error allocating handle: " << ERR_error_string(ssl_error, NULL) );
+ comm_close(newfd);
+ return NULL;
+ }
+
+ SSL_set_fd(ssl, newfd);
+ fd_table[newfd].ssl = ssl;
+ fd_table[newfd].read_method = &ssl_read_method;
+ fd_table[newfd].write_method = &ssl_write_method;
+
+ debugs(33, 5, "httpsCreate: will negotate SSL on FD " << newfd);
+ fd_note(newfd, "client https start");
+
+ return ssl;
+}
+
/* negotiate an SSL connection */
static void
clientNegotiateSSL(int fd, void *data)
@@ -2917,9 +2956,6 @@
{
https_port_list *s = (https_port_list *)data;
SSL_CTX *sslContext = s->sslContext;
- ConnStateData *connState = NULL;
- SSL *ssl;
- int ssl_error;
if (flag == COMM_ERR_CLOSING) {
return;
@@ -2937,25 +2973,16 @@
return;
}
- if ((ssl = SSL_new(sslContext)) == NULL) {
- ssl_error = ERR_get_error();
- debugs(83, 1, "httpsAccept: Error allocating handle: " << ERR_error_string(ssl_error, NULL) );
- comm_close(newfd);
+ SSL *ssl = NULL;
+ if (!(ssl = httpsCreate(newfd, details, sslContext)))
return;
- }
- SSL_set_fd(ssl, newfd);
- fd_table[newfd].ssl = ssl;
- fd_table[newfd].read_method = &ssl_read_method;
- fd_table[newfd].write_method = &ssl_write_method;
-
- debugs(33, 5, "httpsAccept: FD " << newfd << " accepted, starting SSL negotiation.");
- fd_note(newfd, "client https connect");
- connState = connStateCreate(details->peer, details->me, newfd, (http_port_list *)s);
+ ConnStateData *connState = connStateCreate(&details->peer, &details->me,
+ newfd, &s->http);
comm_add_close_handler(newfd, connStateClosed, connState);
if (Config.onoff.log_fqdn)
- fqdncache_gethostbyaddr(details->peer, FQDN_LOOKUP_IF_MISS);
+ fqdncache_gethostbyaddr(details->peer.sin_addr, FQDN_LOOKUP_IF_MISS);
commSetTimeout(newfd, Config.Timeout.request, requestTimeout, connState);
@@ -2963,34 +2990,69 @@
ACLChecklist identChecklist;
- identChecklist.src_addr = details->peer;
+ identChecklist.src_addr = details->peer.sin_addr;
+
+ identChecklist.my_addr = details->me.sin_addr;
- identChecklist.my_addr = details->me;
+ identChecklist.my_port = ntohs(details->me.sin_port);
identChecklist.accessList = cbdataReference(Config.accessList.identLookup);
/* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */
if (identChecklist.fastCheck())
- identStart(details->me, details->peer, clientIdentDone, connState);
+ identStart(&details->me, &details->peer, clientIdentDone, connState);
#endif
commSetSelect(newfd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0);
- clientdbEstablished(details->peer, 1);
+ clientdbEstablished(details->peer.sin_addr, 1);
incoming_sockets_accepted++;
}
+bool
+ConnStateData::switchToHttps()
+{
+ assert(!switchedToHttps_);
+
+ //HTTPMSGLOCK(currentobject->http->request);
+ assert(areAllContextsForThisConnection());
+ freeAllContexts();
+ //currentobject->connIsFinished();
+
+ debugs(33, 5, HERE << "converting FD " << fd << " to SSL");
+
+ // fake a ConnectionDetail object; XXX: make ConnState a ConnectionDetail?
+ ConnectionDetail detail;
+ detail.me = me;
+ detail.peer = peer;
+
+ SSL_CTX *sslContext = port->sslContext;
+ SSL *ssl = NULL;
+ if (!(ssl = httpsCreate(fd, &detail, sslContext)))
+ return false;
+
+ // commSetTimeout() was called for this request before we switched.
+
+ // Disable the client read handler until peer selection is complete
+ commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+
+ commSetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, this, 0);
+
+ switchedToHttps_ = true;
+ return true;
+}
+
#endif /* USE_SSL */
static void
clientHttpConnectionsOpen(void)
{
- http_port_list *s = NULL;
- int fd = -1;
+ http_port_list *s;
+ int fd;
for (s = Config.Sockaddr.http; s; s = s->next) {
if (MAXHTTPPORTS == NHttpSockets) {
@@ -2999,11 +3061,21 @@
continue;
}
+#if USE_SSL
+ if (s->sslBump && s->sslContext == NULL) {
+ debugs(1, 1, "Will not bump SSL at http_port " <<
+ inet_ntoa(s->http.s.sin_addr) << ':' <<
+ (int) ntohs(s->http.s.sin_port) <<
+ " due to SSL initialization failure.");
+ s->sslBump = 0;
+ }
+#endif
+
enter_suid();
fd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
- s->s,
- COMM_NONBLOCKING, "HTTP Socket");
+ s->s.sin_addr,
+ ntohs(s->s.sin_port), COMM_NONBLOCKING, "HTTP Socket");
leave_suid();
if (fd < 0)
@@ -3015,9 +3087,11 @@
debugs(1, 1, "Accepting " <<
(s->transparent ? "transparently proxied" :
- s->accel ? "accelerated" : "" )
- << " HTTP connections at " << s->s
- << ", FD " << fd << "." );
+ s->sslBump ? "bumpy" :
+ s->accel ? "accelerated" : "")
+ << " HTTP connections at "
+ << inet_ntoa(s->s.sin_addr) << ", port "
+ << (int) ntohs(s->s.sin_port) << ", FD " << fd << "." );
HttpSockets[NHttpSockets++] = fd;
}
@@ -3032,20 +3106,24 @@
for (s = Config.Sockaddr.https; s; s = (https_port_list *)s->http.next) {
if (MAXHTTPPORTS == NHttpSockets) {
- debugs(1, 1, "WARNING: You have too many 'https_port' lines.");
- debugs(1, 1, " The limit is " << MAXHTTPPORTS);
+ debugs(1, 1, "Ignoring 'https_port' lines exceeding the limit.");
+ debugs(1, 1, "The limit is " << MAXHTTPPORTS << " HTTPS ports.");
continue;
}
if (s->sslContext == NULL) {
- debugs(1, 1, "Can not accept HTTPS connections at " << s->http.s);
+ debugs(1, 1, "Ignoring https_port " <<
+ inet_ntoa(s->http.s.sin_addr) << ':' <<
+ (int) ntohs(s->http.s.sin_port) <<
+ " due to SSL initialization failure.");
+ continue;
}
enter_suid();
fd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
- s->http.s,
- COMM_NONBLOCKING, "HTTPS Socket");
+ s->http.s.sin_addr,
+ ntohs(s->http.s.sin_port), COMM_NONBLOCKING, "HTTPS Socket");
leave_suid();
if (fd < 0)
@@ -3055,7 +3133,9 @@
comm_accept(fd, httpsAccept, s);
- debugs(1, 1, "Accepting HTTPS connections at " << s->http.s << ", FD " << fd << ".");
+ debugs(1, 1, "Accepting HTTPS connections at " <<
+ inet_ntoa(s->http.s.sin_addr) << ", port " <<
+ (int) ntohs(s->http.s.sin_port) << ", FD " << fd << ".");
HttpSockets[NHttpSockets++] = fd;
}
Index: squid3/src/client_side.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side.h,v
retrieving revision 1.22.6.4
retrieving revision 1.22.6.5
diff -u -r1.22.6.4 -r1.22.6.5
--- squid3/src/client_side.h 25 Jan 2008 02:33:44 -0000 1.22.6.4
+++ squid3/src/client_side.h 27 Jan 2008 18:08:50 -0000 1.22.6.5
@@ -1,5 +1,5 @@
/*
- * $Id: client_side.h,v 1.22.6.4 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_side.h,v 1.22.6.5 2008/01/27 18:08:50 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -95,7 +95,7 @@
};
DeferredParams deferredparams;
- int64_t writtenToSocket;
+ off_t writtenToSocket;
void pullData();
int64_t getNextRangeOffset() const;
bool canPackMoreRanges() const;
@@ -177,11 +177,11 @@
*/
ClientSocketContext::Pointer currentobject;
- IPAddress peer;
+ struct sockaddr_in peer;
- IPAddress me;
+ struct sockaddr_in me;
- IPAddress log_addr;
+ struct IN_ADDR log_addr;
char rfc931[USER_IDENT_SZ];
int nrequests;
@@ -208,11 +208,19 @@
void handleReadData(char *buf, size_t size);
void handleRequestBodyData();
+#if USE_SSL
+ bool switchToHttps();
+ bool switchedToHttps() const { return switchedToHttps_; }
+#else
+ bool switchedToHttps() const { return false; }
+#endif
+
private:
CBDATA_CLASS2(ConnStateData);
bool transparent_;
bool reading_;
bool closing_;
+ bool switchedToHttps_;
Pointer openReference;
BodyPipe::Pointer bodyPipe; // set when we are reading request body
};
Index: squid3/src/client_side_reply.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side_reply.cc,v
retrieving revision 1.112.6.3
retrieving revision 1.112.6.4
diff -u -r1.112.6.3 -r1.112.6.4
--- squid3/src/client_side_reply.cc 25 Jan 2008 02:33:44 -0000 1.112.6.3
+++ squid3/src/client_side_reply.cc 27 Jan 2008 18:08:50 -0000 1.112.6.4
@@ -1,6 +1,6 @@
/*
- * $Id: client_side_reply.cc,v 1.112.6.3 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_side_reply.cc,v 1.112.6.4 2008/01/27 18:08:50 rousskov Exp $
*
* DEBUG: section 88 Client-side Reply Routines
* AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -60,7 +60,9 @@
/* Local functions */
extern "C" CSS clientReplyStatus;
-extern ErrorState *clientBuildError(err_type, http_status, char const *, IPAddress &, HttpRequest *);
+extern ErrorState *clientBuildError(err_type, http_status, char const *,
+
+ struct IN_ADDR *, HttpRequest *);
/* privates */
@@ -88,8 +90,8 @@
*/
void
clientReplyContext::setReplyToError(
- err_type err, http_status status, const HttpRequestMethod& method, char const *uri,
- IPAddress &addr, HttpRequest * failedrequest, char *unparsedrequest,
+ err_type err, http_status status, method_t method, char const *uri,
+ struct IN_ADDR *addr, HttpRequest * failedrequest, char *unparsedrequest,
AuthUserRequest * auth_user_request)
{
ErrorState *errstate =
@@ -657,7 +659,7 @@
char *url = http->uri;
HttpRequest *r = http->request;
ErrorState *err = NULL;
- debugs(88, 4, "clientProcessMiss: '" << RequestMethodStr(r->method) << " " << url << "'");
+ debugs(88, 4, "clientProcessMiss: '" << RequestMethodStr[r->method] << " " << url << "'");
/*
* We might have a left-over StoreEntry from a failed cache hit
* or IMS request.
@@ -677,11 +679,6 @@
purgeRequest();
return;
}
-
- if (METHOD_OTHER == r->method) {
- // invalidate all cache entries
- purgeAllCached();
- }
if (http->onlyIfCached()) {
processOnlyIfCachedMiss();
@@ -693,13 +690,15 @@
*/
if (http->flags.accel && r->flags.loopdetect) {
http->al.http.code = HTTP_FORBIDDEN;
- err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->peer, http->request);
+ err =
+ clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL,
+ &http->getConn()->peer.sin_addr, http->request);
createStoreEntry(r->method, request_flags());
errorAppendEntry(http->storeEntry(), err);
triggerInitialStoreRead();
return;
} else {
- assert(http->out.offset == 0);
+ assert(http->out.offset == 0);
createStoreEntry(r->method, r->flags);
triggerInitialStoreRead();
@@ -737,46 +736,23 @@
{
ErrorState *err = NULL;
debugs(88, 4, "clientProcessOnlyIfCachedMiss: '" <<
- RequestMethodStr(http->request->method) << " " << http->uri << "'");
+ RequestMethodStr[http->request->method] << " " << http->uri << "'");
http->al.http.code = HTTP_GATEWAY_TIMEOUT;
- err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT, NULL, http->getConn()->peer, http->request);
+ err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT, NULL,
+ &http->getConn()->peer.sin_addr, http->request);
removeClientStoreReference(&sc, http);
startError(err);
}
void
clientReplyContext::purgeRequestFindObjectToPurge()
-{
+{
/* Try to find a base entry */
http->flags.purging = 1;
lookingforstore = 1;
-
- // TODO: can we use purgeAllCached() here instead of doing the
- // getPublicByRequestMethod() dance?
StoreEntry::getPublicByRequestMethod(this, http->request, METHOD_GET);
}
-/*
- * We probably cannot purge Vary-affected responses because their MD5
- * keys depend on vary headers.
- */
-void
-clientReplyContext::purgeAllCached()
-{
- const char *url = urlCanonical(http->request);
-
- HttpRequestMethod m(METHOD_NONE);
- for (; m!=METHOD_ENUM_END; ++m) {
- if (m.isCacheble()) {
- if (StoreEntry *entry = storeGetPublic(url, m)) {
- debugs(88, 5, "purging " << RequestMethodStr(m) << ' ' << url);
- entry->release();
- }
- } // end if(isCacheble())
- } // end for
-
-} // purgeAllCached
-
void
clientReplyContext::created(StoreEntry *newEntry)
{
@@ -818,7 +794,9 @@
if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) {
http->logType = LOG_TCP_DENIED;
- ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->peer, http->request);
+ ErrorState *err =
+ clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL,
+ &http->getConn()->peer.sin_addr, http->request);
startError(err);
return;
}
@@ -858,13 +836,15 @@
if (!Config2.onoff.enable_purge) {
http->logType = LOG_TCP_DENIED;
- ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->peer, http->request);
+ ErrorState *err =
+ clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL,
+ &http->getConn()->peer.sin_addr, http->request);
startError(err);
return;
}
/* Release both IP cache */
- ipcacheInvalidate(http->request->GetHost());
+ ipcacheInvalidate(http->request->host);
if (!http->flags.purging)
purgeRequestFindObjectToPurge();
@@ -1074,7 +1054,7 @@
#if SIZEOF_INT64_T == 4
if (http->out.size > 0x7FFF0000) {
debugs(88, 1, "WARNING: closing FD " << fd << " to prevent out.size counter overflow");
- debugs(88, 1, "\tclient " << http->getConn()->peer);
+ debugs(88, 1, "\tclient " << (inet_ntoa(http->getConn() != NULL ? http->getConn()->peer.sin_addr : no_addr)));
debugs(88, 1, "\treceived " << http->out.size << " bytes");
debugs(88, 1, "\tURI " << http->log_uri);
return 1;
@@ -1084,7 +1064,7 @@
#if SIZEOF_INT64_T == 4
if (http->out.offset > 0x7FFF0000) {
debugs(88, 1, "WARNING: closing FD " << fd < " to prevent out.offset counter overflow");
- debugs(88, 1, "\tclient " << http->getConn()->peer);
+ debugs(88, 1, "\tclient " << (inet_ntoa(http->getConn() != NULL ? http->getConn()->peer.sin_addr : no_addr)));
debugs(88, 1, "\treceived " << http->out.size << " bytes, offset " << http->out.offset);
debugs(88, 1, "\tURI " << http->log_uri);
return 1;
@@ -1234,7 +1214,10 @@
if (is_hit)
hdr->delById(HDR_SET_COOKIE);
- reply->header.removeHopByHopEntries();
+ /*
+ * Be sure to obey the Connection header
+ */
+ reply->header.removeConnectionHeaderEntries();
// if (request->range)
// clientBuildRangeHeader(http, reply);
@@ -1331,9 +1314,6 @@
#endif
- /* Check whether we should send keep-alive */
- // TODO: disable proxy_keepalive only once
-
if (reply->bodySize(request->method) < 0) {
debugs(88, 3, "clientBuildReplyHeader: can't keep-alive, unknown body size" );
request->flags.proxy_keepalive = 0;
@@ -1352,11 +1332,6 @@
if (!Config.onoff.client_pconns && !request->flags.must_keepalive)
request->flags.proxy_keepalive = 0;
- if (request->flags.proxy_keepalive && shutting_down) {
- debugs(88, 3, "clientBuildReplyHeader: Shutting down, don't keep-alive.");
- request->flags.proxy_keepalive = 0;
- }
-
/* Append VIA */
if (Config.onoff.via) {
LOCAL_ARRAY(char, bbuf, MAX_URL + 32);
@@ -1456,11 +1431,11 @@
#if USE_DNSSERVERS
- ipcacheInvalidate(r->GetHost());
+ ipcacheInvalidate(r->host);
#else
- ipcacheInvalidateNegative(r->GetHost());
+ ipcacheInvalidateNegative(r->host);
#endif /* USE_DNSSERVERS */
@@ -1472,11 +1447,11 @@
#if USE_DNSSERVERS
- ipcacheInvalidate(r->GetHost());
+ ipcacheInvalidate(r->host);
#else
- ipcacheInvalidateNegative(r->GetHost());
+ ipcacheInvalidateNegative(r->host);
#endif /* USE_DNSSERVERS */
@@ -1793,10 +1768,10 @@
}
if (http->isReplyBodyTooLarge(reply->content_length)) {
- IPAddress tmp_noaddr; tmp_noaddr.SetNoAddr();
- ErrorState *err = clientBuildError(ERR_TOO_BIG, HTTP_FORBIDDEN, NULL,
- http->getConn() != NULL ? http->getConn()->peer : tmp_noaddr,
- http->request);
+ ErrorState *err =
+ clientBuildError(ERR_TOO_BIG, HTTP_FORBIDDEN, NULL,
+ http->getConn() != NULL ? &http->getConn()->peer.sin_addr : &no_addr,
+ http->request);
removeClientStoreReference(&sc, http);
HTTPMSGUNLOCK(reply);
startError(err);
@@ -1826,7 +1801,7 @@
void
clientReplyContext::processReplyAccessResult(bool accessAllowed)
{
- debugs(88, 2, "The reply for " << RequestMethodStr(http->request->method)
+ debugs(88, 2, "The reply for " << RequestMethodStr[http->request->method]
<< " " << http->uri << " is "
<< ( accessAllowed ? "ALLOWED" : "DENIED")
<< ", because it matched '"
@@ -1842,9 +1817,9 @@
if (page_id == ERR_NONE)
page_id = ERR_ACCESS_DENIED;
- IPAddress tmp_noaddr; tmp_noaddr.SetNoAddr();
- err = clientBuildError(page_id, HTTP_FORBIDDEN, NULL,
- http->getConn() != NULL ? http->getConn()->peer : tmp_noaddr,
+ err =
+ clientBuildError(page_id, HTTP_FORBIDDEN, NULL,
+ http->getConn() != NULL ? &http->getConn()->peer.sin_addr : &no_addr,
http->request);
removeClientStoreReference(&sc, http);
@@ -1992,6 +1967,7 @@
}
buildReply(buf, reqofs);
+ ssize_t body_size = reqofs;
if (reply) {
@@ -2014,6 +1990,33 @@
} else if (reqofs < HTTP_REQBUF_SZ && entry->store_status == STORE_PENDING) {
waitForMoreData();
return;
+ } else if (http->request->method == METHOD_HEAD) {
+ /*
+ * If we are here, then store_status == STORE_OK and it
+ * seems we have a HEAD repsponse which is missing the
+ * empty end-of-headers line (home.mira.net, phttpd/0.99.72
+ * does this). Because buildReply() fails we just
+ * call this reply a body, set the done_copying flag and
+ * continue...
+ */
+ /* RBC: Note that this is seriously broken, as we *need* the
+ * metadata to allow further client modules to work. As such
+ * webservers are seriously broken, this is probably not
+ * going to get fixed.. perhapos we should remove it?
+ */
+ debugs(88, 0, "Broken head response - probably phttpd/0.99.72");
+ http->flags.done_copying = 1;
+ flags.complete = 1;
+ /*
+ * And as this is a malformed HTTP reply we cannot keep
+ * the connection persistent
+ */
+ http->request->flags.proxy_keepalive = 0;
+
+ assert(body_buf && body_size);
+ StoreIOBuffer tempBuffer (body_size, 0 ,body_buf);
+ clientStreamCallback((clientStreamNode *)http->client_stream.head->data,
+ http, NULL, tempBuffer);
} else {
debugs(88, 0, "clientReplyContext::sendMoreData: Unable to parse reply headers within a single HTTP_REQBUF_SZ length buffer");
StoreIOBuffer tempBuffer;
@@ -2030,7 +2033,7 @@
/* Using this breaks the client layering just a little!
*/
void
-clientReplyContext::createStoreEntry(const HttpRequestMethod& m, request_flags flags)
+clientReplyContext::createStoreEntry(method_t m, request_flags flags)
{
assert(http != NULL);
/*
@@ -2075,10 +2078,11 @@
ErrorState *
clientBuildError(err_type page_id, http_status status, char const *url,
- IPAddress &src_addr, HttpRequest * request)
+
+ struct IN_ADDR * src_addr, HttpRequest * request)
{
ErrorState *err = errorCon(page_id, status, request);
- err->src_addr = src_addr;
+ err->src_addr = *src_addr;
if (url)
err->url = xstrdup(url);
Index: squid3/src/client_side_reply.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side_reply.h,v
retrieving revision 1.17.22.1
retrieving revision 1.17.22.2
diff -u -r1.17.22.1 -r1.17.22.2
--- squid3/src/client_side_reply.h 25 Jan 2008 02:33:44 -0000 1.17.22.1
+++ squid3/src/client_side_reply.h 27 Jan 2008 18:08:50 -0000 1.17.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: client_side_reply.h,v 1.17.22.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_side_reply.h,v 1.17.22.2 2008/01/27 18:08:50 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -40,7 +40,7 @@
#include "clientStream.h"
#include "StoreClient.h"
#include "client_side_request.h"
-#include "IPAddress.h"
+
class ErrorState;
@@ -76,8 +76,8 @@
int storeOKTransferDone() const;
int storeNotOKTransferDone() const;
- void setReplyToError(err_type, http_status, const HttpRequestMethod&, char const *, IPAddress &, HttpRequest *, char *, AuthUserRequest *);
- void createStoreEntry(const HttpRequestMethod& m, request_flags flags);
+ void setReplyToError(err_type, http_status, method_t, char const *, struct IN_ADDR *, HttpRequest *, char *, AuthUserRequest *);
+ void createStoreEntry(method_t m, request_flags flags);
void removeStoreReference(store_client ** scp, StoreEntry ** ep);
void removeClientStoreReference(store_client **scp, ClientHttpRequest *http);
void startError(ErrorState * err);
@@ -98,7 +98,7 @@
StoreIOBuffer tempBuffer; /* For use in validating requests via IMS */
int old_reqsize; /* ... again, for the buffer */
size_t reqsize;
- size_t reqofs;
+ off_t reqofs;
char tempbuf[HTTP_REQBUF_SZ]; /* a temporary buffer if we need working storage */
#if USE_CACHE_DIGESTS
@@ -143,7 +143,6 @@
void triggerInitialStoreRead();
void sendClientOldEntry();
void buildMaxBodySize(HttpReply * reply);
- void purgeAllCached();
StoreEntry *old_entry;
Index: squid3/src/client_side_request.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.cc,v
retrieving revision 1.80.2.7
retrieving revision 1.80.2.8
diff -u -r1.80.2.7 -r1.80.2.8
--- squid3/src/client_side_request.cc 25 Jan 2008 02:33:44 -0000 1.80.2.7
+++ squid3/src/client_side_request.cc 27 Jan 2008 18:08:50 -0000 1.80.2.8
@@ -1,6 +1,6 @@
/*
- * $Id: client_side_request.cc,v 1.80.2.7 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_side_request.cc,v 1.80.2.8 2008/01/27 18:08:50 rousskov Exp $
*
* DEBUG: section 85 Client-side Request Routines
* AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -47,6 +47,7 @@
#include "client_side_request.h"
#include "AuthUserRequest.h"
#include "HttpRequest.h"
+#include "ProtoPort.h"
#include "ACLChecklist.h"
#include "ACL.h"
#include "client_side.h"
@@ -198,6 +199,7 @@
case ERR_DNS_FAIL:
case ERR_CONNECT_FAIL:
+ case ERR_SECURE_CONNECT_FAIL:
case ERR_READ_ERROR:
n_bad++;
@@ -271,7 +273,7 @@
* determined by the user
*/
int /* returns nonzero on failure */
-clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * streamcallback,
+clientBeginRequest(method_t method, char const *url, CSCB * streamcallback,
CSD * streamdetach, ClientStreamData streamdata, HttpHeader const *header,
char *tailbuf, size_t taillen)
{
@@ -334,11 +336,11 @@
/* Internally created requests cannot have bodies today */
request->content_length = 0;
- request->client_addr.SetNoAddr();
+ request->client_addr = no_addr;
- request->my_addr.SetNoAddr(); /* undefined for internal requests */
+ request->my_addr = no_addr; /* undefined for internal requests */
- request->my_addr.SetPort(0);
+ request->my_port = 0;
request->http_ver = http_ver;
@@ -400,7 +402,7 @@
err_type page_id;
http_status status;
debugs(85, 2, "The request " <<
- RequestMethodStr(http->request->method) << " " <<
+ RequestMethodStr[http->request->method] << " " <<
http->uri << " is " <<
(answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED") <<
", because it matched '" <<
@@ -452,15 +454,12 @@
clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->prev->data;
clientReplyContext *repContext = dynamic_cast(node->data.getRaw());
assert (repContext);
- IPAddress tmpnoaddr; tmpnoaddr.SetNoAddr();
repContext->setReplyToError(page_id, status,
http->request->method, NULL,
- http->getConn() != NULL ? http->getConn()->peer : tmpnoaddr,
- http->request,
- NULL,
- http->getConn() != NULL && http->getConn()->auth_user_request ?
- http->getConn()->auth_user_request : http->request->auth_user_request);
-
+ http->getConn() != NULL ? &http->getConn()->peer.sin_addr : &no_addr, http->request,
+ NULL, http->getConn() != NULL
+ && http->getConn()->auth_user_request ? http->getConn()->
+ auth_user_request : http->request->auth_user_request);
node = (clientStreamNode *)http->client_stream.tail->data;
clientStreamRead(node, http, node->readBuffer);
return;
@@ -553,7 +552,7 @@
{
const char *url = http->uri;
HttpRequest *request = http->request;
- HttpRequestMethod method = request->method;
+ method_t method = request->method;
const wordlist *p = NULL;
/*
@@ -656,10 +655,6 @@
}
}
}
-
- if (METHOD_OTHER == request->method) {
- no_cache++;
- }
#endif
if (no_cache) {
@@ -732,19 +727,15 @@
s.clean();
}
-/**
- \todo --enable-useragent-log and --enable-referer-log. We should
- probably drop those two as the custom log formats accomplish pretty much the same thing..
-*/
#if USE_USERAGENT_LOG
if ((str = req_hdr->getStr(HDR_USER_AGENT)))
- logUserAgent(fqdnFromAddr(http->getConn()->log_addr), str);
+ logUserAgent(fqdnFromAddr(http->getConn() != NULL ? http->getConn()->log_addr : no_addr), str);
#endif
#if USE_REFERER_LOG
if ((str = req_hdr->getStr(HDR_REFERER)))
- logReferer(fqdnFromAddr(http->getConn()->log_addr), str, http->log_uri);
+ logReferer(fqdnFromAddr(http->getConn() != NULL ? http->getConn()->log_addr : no_addr), str, http->log_uri);
#endif
#if FORW_VIA_DB
@@ -819,7 +810,9 @@
new_request->http_ver = old_request->http_ver;
new_request->header.append(&old_request->header);
new_request->client_addr = old_request->client_addr;
+ new_request->client_port = old_request->client_port;
new_request->my_addr = old_request->my_addr;
+ new_request->my_port = old_request->my_port;
new_request->flags = old_request->flags;
new_request->flags.redirected = 1;
@@ -886,7 +879,14 @@
void
ClientHttpRequest::processRequest()
{
- debugs(85, 4, "clientProcessRequest: " << RequestMethodStr(request->method) << " '" << uri << "'");
+ debugs(85, 4, "clientProcessRequest: " << RequestMethodStr[request->method] << " '" << uri << "'");
+
+#if USE_SSL
+ if (request->method == METHOD_CONNECT && getConn()->port->sslBump) {
+ sslBumpStart();
+ return;
+ }
+#endif
if (request->method == METHOD_CONNECT && !redirect.status) {
logType = LOG_TCP_MISS;
@@ -912,6 +912,51 @@
PROF_stop(httpStart);
}
+#if USE_SSL
+// call when comm_write has completed
+static void
+SslBumpEstablish(int, char *, size_t, comm_err_t errflag, int, void *data)
+{
+ ClientHttpRequest *r = static_cast(data);
+ debugs(85, 5, HERE << "responded to CONNECT: " << r << " ? " << errflag);
+
+ assert(r && cbdataReferenceValid(r));
+ r->sslBumpEstablish(errflag);
+}
+
+void
+ClientHttpRequest::sslBumpEstablish(comm_err_t errflag)
+{
+ // Bail out quickly on COMM_ERR_CLOSING - close handlers will tidy up
+ if (errflag == COMM_ERR_CLOSING)
+ return;
+
+ if (errflag) {
+ getConn()->startClosing("CONNECT response failure in SslBump");
+ return;
+ }
+
+ getConn()->switchToHttps();
+}
+
+void
+ClientHttpRequest::sslBumpStart()
+{
+ debugs(85, 5, HERE << "ClientHttpRequest::sslBumpStart");
+
+ // send an HTTP 200 response to kick client SSL negotiation
+ const int fd = getConn()->fd;
+ debugs(33, 7, HERE << "Confirming CONNECT tunnel on FD " << fd);
+
+ // TODO: Unify with tunnel.cc and add a Server(?) header
+ static const char *const conn_established =
+ "HTTP/1.0 200 Connection established\r\n\r\n";
+ comm_write(fd, conn_established, strlen(conn_established),
+ &SslBumpEstablish, this, NULL);
+}
+
+#endif
+
bool
ClientHttpRequest::gotEnough() const
{
@@ -1010,7 +1055,7 @@
assert(calloutContext);
if (!calloutContext->http_access_done) {
- debugs(83, 3, HERE << "Doing calloutContext->clientAccessCheck()");
+ debugs(83, 3, HERE << "Doing calloutContext->clientAccessCheck()");
calloutContext->http_access_done = true;
calloutContext->clientAccessCheck();
return;
@@ -1018,7 +1063,7 @@
#if ICAP_CLIENT
if (TheICAPConfig.onoff && !calloutContext->icap_acl_check_done) {
- debugs(83, 3, HERE << "Doing calloutContext->icapAccessCheck()");
+ debugs(83, 3, HERE << "Doing calloutContext->icapAccessCheck()");
calloutContext->icap_acl_check_done = true;
calloutContext->icapAccessCheck();
return;
@@ -1031,7 +1076,7 @@
assert(calloutContext->redirect_state == REDIRECT_NONE);
if (Config.Program.redirect) {
- debugs(83, 3, HERE << "Doing calloutContext->clientRedirectStart()");
+ debugs(83, 3, HERE << "Doing calloutContext->clientRedirectStart()");
calloutContext->redirect_state = REDIRECT_PENDING;
calloutContext->clientRedirectStart();
return;
@@ -1039,7 +1084,7 @@
}
if (!calloutContext->interpreted_req_hdrs) {
- debugs(83, 3, HERE << "Doing clientInterpretRequestHeaders()");
+ debugs(83, 3, HERE << "Doing clientInterpretRequestHeaders()");
calloutContext->interpreted_req_hdrs = 1;
clientInterpretRequestHeaders(this);
}
@@ -1048,7 +1093,7 @@
calloutContext->no_cache_done = true;
if (Config.accessList.noCache && request->flags.cachable) {
- debugs(83, 3, HERE << "Doing calloutContext->checkNoCache()");
+ debugs(83, 3, HERE << "Doing calloutContext->checkNoCache()");
calloutContext->checkNoCache();
return;
}
@@ -1056,15 +1101,16 @@
if (!calloutContext->clientside_tos_done) {
calloutContext->clientside_tos_done = true;
- if (getConn() != NULL) {
- ACLChecklist ch;
+ if (getConn() != NULL) {
+ ACLChecklist ch;
ch.src_addr = request->client_addr;
ch.my_addr = request->my_addr;
+ ch.my_port = request->my_port;
ch.request = HTTPMSGLOCK(request);
- int tos = aclMapTOS(Config.accessList.clientside_tos, &ch);
- if (tos)
- comm_set_tos(getConn()->fd, tos);
- }
+ int tos = aclMapTOS(Config.accessList.clientside_tos, &ch);
+ if (tos)
+ comm_set_tos(getConn()->fd, tos);
+ }
}
cbdataReferenceDone(calloutContext->http);
@@ -1242,12 +1288,10 @@
// The original author of the code also wanted to pass an errno to
// setReplyToError, but it seems unlikely that the errno reflects the
// true cause of the error at this point, so I did not pass it.
- IPAddress noAddr;
- noAddr.SetNoAddr();
ConnStateData::Pointer c = getConn();
repContext->setReplyToError(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR,
request->method, NULL,
- (c != NULL ? c->peer : noAddr), request, NULL,
+ (c != NULL ? &c->peer.sin_addr : &no_addr), request, NULL,
(c != NULL && c->auth_user_request ?
c->auth_user_request : request->auth_user_request));
Index: squid3/src/client_side_request.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.h,v
retrieving revision 1.30.6.3
retrieving revision 1.30.6.4
diff -u -r1.30.6.3 -r1.30.6.4
--- squid3/src/client_side_request.h 25 Jan 2008 02:33:44 -0000 1.30.6.3
+++ squid3/src/client_side_request.h 27 Jan 2008 18:08:50 -0000 1.30.6.4
@@ -1,6 +1,6 @@
/*
- * $Id: client_side_request.h,v 1.30.6.3 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: client_side_request.h,v 1.30.6.4 2008/01/27 18:08:50 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -50,7 +50,7 @@
#endif
/* client_side_request.c - client side request related routines (pure logic) */
-extern int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
+extern int clientBeginRequest(method_t, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
class MemObject;
@@ -158,6 +158,12 @@
StoreEntry *loggingEntry_;
ConnStateData::Pointer conn_;
+#if USE_SSL
+public:
+ void sslBumpStart();
+ void sslBumpEstablish(comm_err_t errflag);
+#endif
+
#if ICAP_CLIENT
public:
@@ -183,7 +189,7 @@
BodyPipe::Pointer icapBodySource;
bool request_satisfaction_mode;
- int64_t request_satisfaction_offset;
+ off_t request_satisfaction_offset;
#endif
};
Index: squid3/src/comm.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm.cc,v
retrieving revision 1.81.6.3
retrieving revision 1.81.6.4
diff -u -r1.81.6.3 -r1.81.6.4
--- squid3/src/comm.cc 25 Jan 2008 02:33:44 -0000 1.81.6.3
+++ squid3/src/comm.cc 27 Jan 2008 18:08:50 -0000 1.81.6.4
@@ -1,6 +1,5 @@
-
/*
- * $Id: comm.cc,v 1.81.6.3 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: comm.cc,v 1.81.6.4 2008/01/27 18:08:50 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
@@ -46,7 +45,6 @@
#include "MemBuf.h"
#include "pconn.h"
#include "SquidTime.h"
-#include "IPAddress.h"
#if defined(_SQUID_CYGWIN_)
#include
@@ -231,16 +229,13 @@
void connect();
void callCallback(comm_err_t status, int xerrno);
void defaults();
-
-// defaults given by client
char *host;
- u_short default_port;
- IPAddress default_addr;
- // NP: CANNOT store the default addr:port together as it gets set/reset differently.
+ u_short port;
- IPAddress S;
+ struct sockaddr_in S;
CallBack callback;
+ struct IN_ADDR in_addr;
int fd;
int tries;
int addrcount;
@@ -254,7 +249,7 @@
/* STATIC */
-static comm_err_t commBind(int s, struct addrinfo &);
+static comm_err_t commBind(int s, struct IN_ADDR, u_short port);
static void commSetReuseAddr(int);
static void commSetNoLinger(int);
#ifdef TCP_NODELAY
@@ -600,9 +595,10 @@
/* prevent those nasty RST packets */
char buf[SQUID_TCP_SO_RCVBUF];
- if (fd_table[fd].flags.nonblocking == 1) {
- while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0) {};
- }
+ if (fd_table[fd].flags.nonblocking == 1)
+ while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0)
+
+ ;
#endif
}
@@ -717,32 +713,17 @@
* synchronous wrapper around udp socket functions
*/
int
-comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, IPAddress &from)
+comm_udp_recvfrom(int fd, void *buf, size_t len, int flags,
+ struct sockaddr *from, socklen_t *fromlen)
{
statCounter.syscalls.sock.recvfroms++;
- int x = 0;
- struct addrinfo *AI = NULL;
-
- debugs(5,8, "comm_udp_recvfrom: FD " << fd << " from " << from);
-
- assert( NULL == AI );
-
- from.InitAddrInfo(AI);
-
- x = recvfrom(fd, buf, len, flags, AI->ai_addr, &AI->ai_addrlen);
-
- from = *AI;
-
- from.FreeAddrInfo(AI);
-
- return x;
+ return recvfrom(fd, buf, len, flags, from, fromlen);
}
int
comm_udp_recv(int fd, void *buf, size_t len, int flags)
{
- IPAddress nul;
- return comm_udp_recvfrom(fd, buf, len, flags, nul);
+ return comm_udp_recvfrom(fd, buf, len, flags, NULL, 0);
}
ssize_t
@@ -768,8 +749,9 @@
u_short
comm_local_port(int fd)
{
- IPAddress temp;
- struct addrinfo *addr = NULL;
+
+ struct sockaddr_in addr;
+ socklen_t addr_len = 0;
fde *F = &fd_table[fd];
/* If the fd is closed already, just return */
@@ -779,42 +761,38 @@
return 0;
}
- if (F->local_addr.GetPort())
- return F->local_addr.GetPort();
+ if (F->local_port)
+ return F->local_port;
- temp.InitAddrInfo(addr);
+ addr_len = sizeof(addr);
- if (getsockname(fd, addr->ai_addr, &(addr->ai_addrlen)) ) {
+ if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) {
debugs(50, 1, "comm_local_port: Failed to retrieve TCP/UDP port number for socket: FD " << fd << ": " << xstrerror());
- temp.FreeAddrInfo(addr);
return 0;
}
- temp = *addr;
- temp.FreeAddrInfo(addr);
-
- F->local_addr.SetPort(temp.GetPort());
-
- // grab default socket information for this address
- temp.GetAddrInfo(addr);
-
- F->sock_family = addr->ai_family;
-
- temp.FreeAddrInfo(addr);
-
- debugs(5, 6, "comm_local_port: FD " << fd << ": port " << F->local_addr.GetPort());
- return F->local_addr.GetPort();
+ F->local_port = ntohs(addr.sin_port);
+ debugs(5, 6, "comm_local_port: FD " << fd << ": port " << F->local_port);
+ return F->local_port;
}
static comm_err_t
-commBind(int s, struct addrinfo &inaddr)
+commBind(int s, struct IN_ADDR in_addr, u_short port)
{
+ struct sockaddr_in S;
+
+ memset(&S, '\0', sizeof(S));
+ S.sin_family = AF_INET;
+ S.sin_port = htons(port);
+ S.sin_addr = in_addr;
statCounter.syscalls.sock.binds++;
- if (bind(s, inaddr.ai_addr, inaddr.ai_addrlen) == 0)
+ if (bind(s, (struct sockaddr *) &S, sizeof(S)) == 0)
return COMM_OK;
- debugs(50, 0, "commBind: Cannot bind socket FD " << s << " to " << fd_table[s].local_addr << ": " << xstrerror());
+ debugs(50, 0, "commBind: Cannot bind socket FD " << s << " to " <<
+ (S.sin_addr.s_addr == INADDR_ANY ? "*" : inet_ntoa(S.sin_addr)) <<
+ ":" << (int) port << ": " << xstrerror());
return COMM_ERROR;
}
@@ -826,11 +804,12 @@
int
comm_open(int sock_type,
int proto,
- IPAddress &addr,
+ struct IN_ADDR addr,
+ u_short port,
int flags,
const char *note)
{
- return comm_openex(sock_type, proto, addr, flags, 0, note);
+ return comm_openex(sock_type, proto, addr, port, flags, 0, note);
}
static bool
@@ -853,17 +832,6 @@
#endif
}
-void
-comm_set_v6only(int fd, int tos)
-{
-#ifdef IPV6_V6ONLY
- if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &tos, sizeof(int)) < 0) {
- debugs(50, 1, "comm_open: setsockopt(IPV6_V6ONLY) on FD " << fd << ": " << xstrerror());
- }
-#else
- debugs(50, 0, "WARNING: comm_open: setsockopt(IPV6_V6ONLY) not supported on this platform");
-#endif /* sockopt */
-}
/**
* Create a socket. Default is blocking, stream (TCP) socket. IO_TYPE
@@ -872,29 +840,21 @@
int
comm_openex(int sock_type,
int proto,
- IPAddress &addr,
+ struct IN_ADDR addr,
+ u_short port,
int flags,
unsigned char TOS,
const char *note)
{
int new_socket;
- fde *F = NULL;
int tos = 0;
- struct addrinfo *AI = NULL;
+ fde *F = NULL;
PROF_start(comm_open);
/* Create socket for accepting new connections. */
statCounter.syscalls.sock.sockets++;
- /* Setup the socket addrinfo details for use */
- addr.GetAddrInfo(AI);
- AI->ai_socktype = sock_type;
- AI->ai_protocol = proto;
- AI->ai_flags = flags;
-
- debugs(50, 3, "comm_openex: Attempt open socket for: " << addr );
-
- if ((new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0)
+ if ((new_socket = socket(AF_INET, sock_type, proto)) < 0)
{
/* Increase the number of reserved fd's if calls to socket()
* are failing because the open file table is full. This
@@ -907,34 +867,28 @@
debugs(50, 0, "comm_open: socket failure: " << xstrerror());
}
- addr.FreeAddrInfo(AI);
-
PROF_stop(comm_open);
return -1;
}
- debugs(50, 3, "comm_openex: Opened socket FD " << new_socket << " : family=" << AI->ai_family << ", type=" << AI->ai_socktype << ", protocol=" << AI->ai_protocol );
-
/* set TOS if needed */
- if (TOS && comm_set_tos(new_socket, TOS) ) {
+ if (TOS)
+ {
+#ifdef IP_TOS
tos = TOS;
- }
-
-#if IPV6_SPECIAL_SPLITSTACK
-
- if( addr.IsIPv6() )
- comm_set_v6only(new_socket, tos);
-#endif
+ if (setsockopt(new_socket, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(int)) < 0) {
+ debugs(50, 1, "comm_open: setsockopt(IP_TOS) on FD " << new_socket << ": " << xstrerror());
+ }
-#if IPV6_SPECIAL_V4MAPPED && defined(_SQUID_MSWIN_)
+#else
- /* Windows Vista supports Dual-Sockets. BUT defaults them to V6ONLY. Turn it OFF. */
- if( addr.IsIPv6() )
- comm_set_v6only(new_socket, 0);
+ debugs(50, 0, "comm_open: setsockopt(IP_TOS) not supported on this platform");
#endif
+ }
+
/* update fdstat */
debugs(5, 5, "comm_open: FD " << new_socket << " is a new socket");
@@ -952,9 +906,7 @@
F->local_addr = addr;
- F->tos = TOS;
-
- F->sock_family = AI->ai_family;
+ F->tos = tos;
if (!(flags & COMM_NOCLOEXEC))
commSetCloseOnExec(new_socket);
@@ -962,7 +914,7 @@
if ((flags & COMM_REUSEADDR))
commSetReuseAddr(new_socket);
- if (addr.GetPort() > (u_short) 0)
+ if (port > (u_short) 0)
{
#ifdef _SQUID_MSWIN_
@@ -975,17 +927,16 @@
commSetReuseAddr(new_socket);
}
- if (!addr.IsNoAddr())
+ if (addr.s_addr != no_addr.s_addr)
{
- if (commBind(new_socket, *AI) != COMM_OK) {
+ if (commBind(new_socket, addr, port) != COMM_OK) {
comm_close(new_socket);
- addr.FreeAddrInfo(AI);
return -1;
PROF_stop(comm_open);
}
}
- addr.FreeAddrInfo(AI);
+ F->local_port = port;
if (flags & COMM_NONBLOCKING)
if (commSetNonBlocking(new_socket) == COMM_ERROR)
@@ -1031,7 +982,7 @@
cs = new ConnectStateData;
cs->fd = fd;
cs->host = xstrdup(host);
- cs->default_port = port;
+ cs->port = port;
cs->callback = CallBack(callback, data);
comm_add_close_handler(fd, commConnectFree, cs);
ipcache_nbgethostbyname(host, commConnectDnsHandle, cs);
@@ -1056,8 +1007,7 @@
}
assert(ia->cur < ia->count);
-
- cs->default_addr = ia->in_addrs[ia->cur];
+ cs->in_addr = ia->in_addrs[ia->cur];
if (Config.onoff.balance_on_multiple_ip)
ipcacheCycleAddr(cs->host, NULL);
@@ -1072,7 +1022,7 @@
void
ConnectStateData::callCallback(comm_err_t status, int xerrno)
{
- debugs(5, 3, "commConnectCallback: FD " << fd << ", data " << callback.data << ", status " << status);
+ debugs(5, 3, "commConnectCallback: FD " << fd << ", data " << callback.data);
comm_remove_close_handler(fd, commConnectFree, this);
CallBack aCallback = callback;
@@ -1119,20 +1069,12 @@
int
ConnectStateData::commResetFD()
{
- struct addrinfo *AI = NULL;
- IPAddress nul;
-
if (!cbdataReferenceValid(callback.data))
return 0;
statCounter.syscalls.sock.sockets++;
- /* setup a bare-bones addrinfo */
- nul.GetAddrInfo(AI);
-
- int fd2 = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
-
- nul.FreeAddrInfo(AI);
+ int fd2 = socket(AF_INET, SOCK_STREAM, 0);
if (fd2 < 0) {
debugs(5, 0, "commResetFD: socket: " << xstrerror());
@@ -1161,7 +1103,6 @@
return 0;
}
- commResetSelect(fd);
close(fd2);
fde *F = &fd_table[fd];
@@ -1171,26 +1112,18 @@
* the original socket
*/
- AI = NULL;
- F->local_addr.GetAddrInfo(AI);
-
- if (commBind(fd, *AI) != COMM_OK) {
+ if (commBind(fd, F->local_addr, F->local_port) != COMM_OK) {
debugs(5, 0, "commResetFD: bind: " << xstrerror());
- F->local_addr.FreeAddrInfo(AI);
return 0;
}
- F->local_addr.FreeAddrInfo(AI);
- if (F->tos)
- comm_set_tos(fd, F->tos);
-
-#if IPV6_SPECIAL_SPLITSTACK
-
- if( F->local_addr.IsIPv6() )
- comm_set_v6only(fd, F->tos);
+#ifdef IP_TOS
+ if (F->tos) {
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, (char *) &F->tos, sizeof(int)) < 0)
+ debugs(50, 1, "commResetFD: setsockopt(IP_TOS) on FD " << fd << ": " << xstrerror());
+ }
#endif
-
copyFDFlags (fd, F);
return 1;
@@ -1234,19 +1167,18 @@
void
ConnectStateData::defaults()
{
- S = default_addr;
- S.SetPort(default_port);
+ S.sin_family = AF_INET;
+ S.sin_addr = in_addr;
+ S.sin_port = htons(port);
}
void
ConnectStateData::connect()
{
- if (S.IsAnyAddr())
+ if (S.sin_addr.s_addr == 0)
defaults();
- debugs(5,5, "ConnectSateData::connect: to " << S);
-
- switch (comm_connect_addr(fd, S) ) {
+ switch (comm_connect_addr(fd, &S)) {
case COMM_INPROGRESS:
debugs(5, 5, "ConnectStateData::connect: FD " << fd << ": COMM_INPROGRESS");
@@ -1254,23 +1186,20 @@
break;
case COMM_OK:
- debugs(5, 5, "ConnectStateData::connect: FD " << fd << ": COMM_OK - connected");
- ipcacheMarkGoodAddr(host, S);
+ ipcacheMarkGoodAddr(host, S.sin_addr);
callCallback(COMM_OK, 0);
break;
default:
- debugs(5, 5, "ConnectStateData::connect: FD " << fd << ": * - try again");
tries++;
- ipcacheMarkBadAddr(host, S);
+ ipcacheMarkBadAddr(host, S.sin_addr);
if (Config.onoff.test_reachability)
- netdbDeleteAddrNetwork(S);
+ netdbDeleteAddrNetwork(S.sin_addr);
if (commRetryConnect()) {
eventAdd("commReconnect", commReconnect, this, this->addrcount == 1 ? 0.05 : 0.0, 0);
} else {
- debugs(5, 5, "ConnectStateData::connect: FD " << fd << ": * - ERR tried too many times already.");
callCallback(COMM_ERR_CONNECT, errno);
}
}
@@ -1303,23 +1232,16 @@
}
int
-comm_connect_addr(int sock, const IPAddress &address)
+
+comm_connect_addr(int sock, const struct sockaddr_in *address)
{
comm_err_t status = COMM_OK;
fde *F = &fd_table[sock];
- int x = 0;
+ int x;
int err = 0;
socklen_t errlen;
- struct addrinfo *AI = NULL;
+ assert(ntohs(address->sin_port) != 0);
PROF_start(comm_connect_addr);
-
- assert(address.GetPort() != 0);
-
- debugs(5, 9, "comm_connect_addr: connecting socket " << sock << " to " << address << " (want family: " << F->sock_family <<
- ") Old-State=" << fdc_table[sock].active);
-
- address.GetAddrInfo(AI, F->sock_family);
-
/* Establish connection. */
errno = 0;
@@ -1328,27 +1250,23 @@
F->flags.called_connect = 1;
statCounter.syscalls.sock.connects++;
- x = connect(sock, AI->ai_addr, AI->ai_addrlen);
+ x = connect(sock, (struct sockaddr *) address, sizeof(*address));
- if (x < 0)
- {
- debugs(5,5, "comm_connect_addr: sock=" << sock << ", addrinfo( " <<
- " flags=" << AI->ai_flags <<
- ", family=" << AI->ai_family <<
- ", socktype=" << AI->ai_socktype <<
- ", protocol=" << AI->ai_protocol <<
- ", &addr=" << AI->ai_addr <<
- ", addrlen=" << AI->ai_addrlen <<
- " )" );
- debugs(5, 9, "connect FD " << sock << ": (" << x << ") " << xstrerror());
- debugs(14,9, "connecting to: " << address );
+ // XXX: ICAP code refuses callbacks during a pending comm_ call
+ // Async calls development will fix this.
+ if (x == 0) {
+ x = -1;
+ errno = EINPROGRESS;
}
+
+ if (x < 0)
+ debugs(5, 9, "connect FD " << sock << ": " << xstrerror());
} else
{
#if defined(_SQUID_NEWSOS6_)
/* Makoto MATSUSHITA */
- connect(sock, AI->ai_addr, AI->ai_addrlen);
+ connect(sock, (struct sockaddr *) address, sizeof(*address));
if (errno == EINVAL) {
errlen = sizeof(err);
@@ -1381,20 +1299,6 @@
}
-#ifdef _SQUID_LINUX_
- /* 2007-11-27:
- * Linux Debian replaces our allocated AI pointer with garbage when
- * connect() fails. This leads to segmentation faults deallocating
- * the system-allocated memory when we go to clean up our pointer.
- * HACK: is to leak the memory returned since we can't deallocate.
- */
- if(errno != 0) {
- AI = NULL;
- }
-#endif
-
- address.FreeAddrInfo(AI);
-
PROF_stop(comm_connect_addr);
if (errno == 0 || errno == EISCONN)
@@ -1402,31 +1306,15 @@
else if (ignoreErrno(errno))
status = COMM_INPROGRESS;
else
-#if USE_IPV6
- if( address.IsIPv4() && F->sock_family == AF_INET6 ) {
-
- /* failover to trying IPv4-only link if an IPv6 one fails */
- /* to catch the edge case of apps listening on IPv4-localhost */
- F->sock_family = AF_INET;
- int res = comm_connect_addr(sock, address);
-
- /* if that fails too, undo our temporary socktype hack so the repeat works properly. */
- if(res == COMM_ERROR)
- F->sock_family = AF_INET6;
-
- return res;
- }
- else
-#endif
return COMM_ERROR;
- address.NtoA(F->ipaddr, MAX_IPSTRLEN);
+ xstrncpy(F->ipaddr, inet_ntoa(address->sin_addr), 16);
- F->remote_port = address.GetPort(); /* remote_port is HS */
+ F->remote_port = ntohs(address->sin_port);
if (status == COMM_OK)
{
- debugs(5, 10, "comm_connect_addr: FD " << sock << " connected to " << address);
+ debugs(5, 10, "comm_connect_addr: FD " << sock << " connected to " << F->ipaddr << ":" << F->remote_port);
} else if (status == COMM_INPROGRESS)
{
debugs(5, 10, "comm_connect_addr: FD " << sock << " connection pending");
@@ -1443,13 +1331,9 @@
PROF_start(comm_accept);
statCounter.syscalls.sock.accepts++;
int sock;
- struct addrinfo *gai = NULL;
- details.me.InitAddrInfo(gai);
-
- if ((sock = accept(fd, gai->ai_addr, &gai->ai_addrlen)) < 0) {
-
- details.me.FreeAddrInfo(gai);
+ socklen_t Slen = sizeof(details.peer);
+ if ((sock = accept(fd, (struct sockaddr *) &details.peer, &Slen)) < 0) {
PROF_stop(comm_accept);
if (ignoreErrno(errno))
@@ -1467,34 +1351,21 @@
}
}
- details.peer = *gai;
-
- details.me.InitAddrInfo(gai);
-
- details.me.SetEmpty();
- getsockname(sock, gai->ai_addr, &gai->ai_addrlen);
- details.me = *gai;
+ Slen = sizeof(details.me);
+ memset(&details.me, '\0', Slen);
+ getsockname(sock, (struct sockaddr *) &details.me, &Slen);
commSetCloseOnExec(sock);
-
/* fdstat update */
fd_open(sock, FD_SOCKET, "HTTP Request");
fdd_table[sock].close_file = NULL;
fdd_table[sock].close_line = 0;
fdc_table[sock].active = 1;
fde *F = &fd_table[sock];
- details.peer.NtoA(F->ipaddr,MAX_IPSTRLEN);
- F->remote_port = details.peer.GetPort();
- F->local_addr.SetPort(details.me.GetPort());
-#if USE_IPV6
- F->sock_family = AF_INET;
-#else
- F->sock_family = details.me.IsIPv4()?AF_INET:AF_INET6;
-#endif
- details.me.FreeAddrInfo(gai);
-
+ xstrncpy(F->ipaddr, inet_ntoa(details.peer.sin_addr), 16);
+ F->remote_port = htons(details.peer.sin_port);
+ F->local_port = htons(details.me.sin_port);
commSetNonBlocking(sock);
-
PROF_stop(comm_accept);
return sock;
}
@@ -1728,29 +1599,17 @@
/* Send a udp datagram to specified TO_ADDR. */
int
comm_udp_sendto(int fd,
- const IPAddress &to_addr,
+
+ const struct sockaddr_in *to_addr,
+ int addr_len,
const void *buf,
int len)
{
- int x = 0;
- struct addrinfo *AI = NULL;
-
+ int x;
PROF_start(comm_udp_sendto);
statCounter.syscalls.sock.sendtos++;
- debugs(50, 3, "comm_udp_sendto: Attempt to send UDP packet to " << to_addr <<
- " using FD " << fd << " using Port " << comm_local_port(fd) );
-
- /* BUG: something in the above macro appears to occasionally be setting AI to garbage. */
- /* AYJ: 2007-08-27 : or was it because I wasn't then setting 'fd_table[fd].sock_family' to fill properly. */
- assert( NULL == AI );
-
- to_addr.GetAddrInfo(AI, fd_table[fd].sock_family);
-
- x = sendto(fd, buf, len, 0, AI->ai_addr, AI->ai_addrlen);
-
- to_addr.FreeAddrInfo(AI);
-
+ x = sendto(fd, buf, len, 0, (struct sockaddr *) to_addr, addr_len);
PROF_stop(comm_udp_sendto);
if (x >= 0)
@@ -1761,7 +1620,9 @@
if (ECONNREFUSED != errno)
#endif
- debugs(50, 1, "comm_udp_sendto: FD " << fd << ", (family=" << fd_table[fd].sock_family << ") " << to_addr << ": " << xstrerror());
+ debugs(50, 1, "comm_udp_sendto: FD " << fd << ", " <<
+ inet_ntoa(to_addr->sin_addr) << ", port " <<
+ (int) htons(to_addr->sin_port) << ": " << xstrerror());
return COMM_ERROR;
}
@@ -2043,7 +1904,7 @@
/* A successful write, continue */
state->offset += len;
- if (state->offset < state->size) {
+ if (state->offset < (off_t)state->size) {
/* Not done, reinstall the write handler and write some more */
commSetSelect(fd,
COMM_SELECT_WRITE,
@@ -2289,10 +2150,9 @@
return;
}
- debugs(5, 5, HERE << "accepted: FD " << fd << " handler: " << (void*)accept.accept.callback.handler << " newfd: " << newfd << " from: " << accept.connDetails.peer);
+ debugs(5, 5, "fdc_t::acceptOne accepted: FD " << fd << " handler: " << (void*)accept.accept.callback.handler << " newfd: " << newfd);
assert(accept.accept.callback.handler);
-
accept.accept.doCallback(fd, newfd, COMM_OK, 0, &accept.connDetails);
/* If we weren't re-registed, don't bother trying again! */
@@ -2655,7 +2515,9 @@
cancelled = true;
}
-ConnectionDetail::ConnectionDetail() : me(), peer() {
+ConnectionDetail::ConnectionDetail() {
+ memset(&me, 0, sizeof(me));
+ memset(&peer, 0, sizeof(peer));
}
bool
Index: squid3/src/comm.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm.h,v
retrieving revision 1.26.6.1
retrieving revision 1.26.6.2
diff -u -r1.26.6.1 -r1.26.6.2
--- squid3/src/comm.h 25 Jan 2008 02:33:44 -0000 1.26.6.1
+++ squid3/src/comm.h 27 Jan 2008 18:08:50 -0000 1.26.6.2
@@ -6,7 +6,6 @@
#include "CompletionDispatcher.h"
#include "StoreIOBuffer.h"
#include "Array.h"
-#include "IPAddress.h"
#define COMMIO_FD_READCB(fd) (&commfd_table[(fd)].readcb)
#define COMMIO_FD_WRITECB(fd) (&commfd_table[(fd)].writecb)
@@ -47,20 +46,19 @@
#endif
SQUIDCEXTERN void commConnectStart(int fd, const char *, u_short, CNCB *, void *);
-SQUIDCEXTERN int comm_connect_addr(int sock, const IPAddress &addr);
+SQUIDCEXTERN int comm_connect_addr(int sock, const struct sockaddr_in *);
SQUIDCEXTERN void comm_init(void);
SQUIDCEXTERN void comm_exit(void);
-SQUIDCEXTERN int comm_open(int, int, IPAddress &, int, const char *note);
+SQUIDCEXTERN int comm_open(int, int, struct IN_ADDR, u_short port, int, const char *note);
-SQUIDCEXTERN int comm_openex(int, int, IPAddress &, int, unsigned char TOS, const char *);
+SQUIDCEXTERN int comm_openex(int, int, struct IN_ADDR, u_short, int, unsigned char TOS, const char *);
SQUIDCEXTERN u_short comm_local_port(int fd);
SQUIDCEXTERN int comm_set_tos(int fd, int tos);
SQUIDCEXTERN void commSetSelect(int, unsigned int, PF *, void *, time_t);
-SQUIDCEXTERN void commResetSelect(int);
-SQUIDCEXTERN int comm_udp_sendto(int sock, const IPAddress &to, const void *buf, int buflen);
+SQUIDCEXTERN int comm_udp_sendto(int, const struct sockaddr_in *, int, const void *, int);
extern void comm_write(int fd, const char *buf, int len, IOCB *callback, void *callback_data, FREE *func);
SQUIDCEXTERN void comm_write_mbuf(int fd, MemBuf *mb, IOCB * handler, void *handler_data);
SQUIDCEXTERN void commCallCloseHandlers(int fd);
@@ -88,7 +86,9 @@
extern void comm_read(int fd, char *buf, int len, IOCB *handler, void *data);
extern void comm_read_cancel(int fd, IOCB *callback, void *data);
extern void fdc_open(int fd, unsigned int type, char const *desc);
-extern int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, IPAddress &from);
+extern int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags,
+
+ struct sockaddr *from, socklen_t *fromlen);
extern int comm_udp_recv(int fd, void *buf, size_t len, int flags);
extern ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags);
extern void commMarkHalfClosed(int);
Index: squid3/src/comm_epoll.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm_epoll.cc,v
retrieving revision 1.18.6.1
retrieving revision 1.18.6.2
diff -u -r1.18.6.1 -r1.18.6.2
--- squid3/src/comm_epoll.cc 25 Jan 2008 02:33:44 -0000 1.18.6.1
+++ squid3/src/comm_epoll.cc 27 Jan 2008 18:08:50 -0000 1.18.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: comm_epoll.cc,v 1.18.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: comm_epoll.cc,v 1.18.6.2 2008/01/27 18:08:50 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
*
@@ -203,14 +203,6 @@
F->timeout = squid_curtime + timeout;
}
-void
-commResetSelect(int fd)
-{
- fde *F = &fd_table[fd];
- F->epoll_state = 0;
- commSetSelect(fd, 0, NULL, NULL, 0);
-}
-
static void commIncomingStats(StoreEntry * sentry);
Index: squid3/src/comm_kqueue.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm_kqueue.cc,v
retrieving revision 1.12.6.1
retrieving revision 1.12.6.2
diff -u -r1.12.6.1 -r1.12.6.2
--- squid3/src/comm_kqueue.cc 25 Jan 2008 02:33:44 -0000 1.12.6.1
+++ squid3/src/comm_kqueue.cc 27 Jan 2008 18:08:51 -0000 1.12.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: comm_kqueue.cc,v 1.12.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: comm_kqueue.cc,v 1.12.6.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
*
@@ -210,18 +210,6 @@
}
-void
-commResetSelect(int fd)
-{
- fde *F = &fd_table[fd];
- if (F->read_handler) {
- kq_update_events(fd, EVFILT_READ, (PF *)1);
- }
- if (F->write_handler) {
- kq_update_events(fd, EVFILT_WRITE, (PF *)1);
- }
-}
-
/*
* Check all connections for new connections and input data that is to be
* processed. Also check for connections with data queued and whether we can
Index: squid3/src/comm_poll.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm_poll.cc,v
retrieving revision 1.17.6.1
retrieving revision 1.17.6.2
diff -u -r1.17.6.1 -r1.17.6.2
--- squid3/src/comm_poll.cc 25 Jan 2008 02:33:44 -0000 1.17.6.1
+++ squid3/src/comm_poll.cc 27 Jan 2008 18:08:51 -0000 1.17.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: comm_poll.cc,v 1.17.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: comm_poll.cc,v 1.17.6.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
*
@@ -145,11 +145,6 @@
F->timeout = squid_curtime + timeout;
}
-void
-commResetSelect(int fd)
-{
-}
-
static int
fdIsIcp(int fd)
{
Index: squid3/src/comm_select.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm_select.cc,v
retrieving revision 1.19.16.1
retrieving revision 1.19.16.2
diff -u -r1.19.16.1 -r1.19.16.2
--- squid3/src/comm_select.cc 25 Jan 2008 02:33:44 -0000 1.19.16.1
+++ squid3/src/comm_select.cc 27 Jan 2008 18:08:51 -0000 1.19.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: comm_select.cc,v 1.19.16.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: comm_select.cc,v 1.19.16.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
*
@@ -156,10 +156,6 @@
F->timeout = squid_curtime + timeout;
}
-void
-commResetSelect(int fd)
-{
-}
static int
fdIsIcp(int fd)
@@ -231,11 +227,7 @@
getCurrentTime();
-#if USE_POLL
- statCounter.syscalls.polls++;
-#else
statCounter.syscalls.selects++;
-#endif
if (select(maxfd, &read_mask, &write_mask, NULL, &zero_tv) < 1)
return incoming_sockets_accepted;
@@ -446,11 +438,7 @@
for (;;) {
poll_time.tv_sec = msec / 1000;
poll_time.tv_usec = (msec % 1000) * 1000;
-#if USE_POLL
- statCounter.syscalls.polls++;
-#else
statCounter.syscalls.selects++;
-#endif
num = select(maxfd, &readfds, &writefds, NULL, &poll_time);
statCounter.select_loops++;
@@ -721,11 +709,7 @@
else
continue;
-#if USE_POLL
- statCounter.syscalls.polls++;
-#else
statCounter.syscalls.selects++;
-#endif
errno = 0;
Index: squid3/src/comm_select_win32.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/comm_select_win32.cc,v
retrieving revision 1.5.22.1
retrieving revision 1.5.22.2
diff -u -r1.5.22.1 -r1.5.22.2
--- squid3/src/comm_select_win32.cc 25 Jan 2008 02:33:44 -0000 1.5.22.1
+++ squid3/src/comm_select_win32.cc 27 Jan 2008 18:08:51 -0000 1.5.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: comm_select_win32.cc,v 1.5.22.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: comm_select_win32.cc,v 1.5.22.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 5 Socket Functions
*
@@ -156,11 +156,6 @@
F->timeout = squid_curtime + timeout;
}
-void
-commResetSelect(int fd)
-{
-}
-
static int
fdIsIcp(int fd)
Index: squid3/src/debug.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/debug.cc,v
retrieving revision 1.18.6.4
retrieving revision 1.18.6.5
diff -u -r1.18.6.4 -r1.18.6.5
--- squid3/src/debug.cc 25 Jan 2008 02:33:44 -0000 1.18.6.4
+++ squid3/src/debug.cc 27 Jan 2008 18:08:51 -0000 1.18.6.5
@@ -1,5 +1,5 @@
/*
- * $Id: debug.cc,v 1.18.6.4 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: debug.cc,v 1.18.6.5 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
@@ -173,7 +173,7 @@
vfprintf(debug_log, format, args);
-//*AYJ:*/ if (!Config.onoff.buffered_logs)
+ if (!Config.onoff.buffered_logs)
fflush(debug_log);
}
@@ -445,7 +445,7 @@
}
for (i = 0; i < MAX_DEBUG_SECTIONS; i++)
- Debug::Levels[i] = 0;
+ Debug::Levels[i] = -1;
if (options) {
p = xstrdup(options);
Index: squid3/src/defines.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/defines.h,v
retrieving revision 1.16.6.1
retrieving revision 1.16.6.2
diff -u -r1.16.6.1 -r1.16.6.2
--- squid3/src/defines.h 25 Jan 2008 02:33:44 -0000 1.16.6.1
+++ squid3/src/defines.h 27 Jan 2008 18:08:51 -0000 1.16.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: defines.h,v 1.16.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: defines.h,v 1.16.6.2 2008/01/27 18:08:51 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -205,6 +205,8 @@
#define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(uint64_t))
#define STORE_HDR_METASIZE_OLD (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(size_t))
+#define PINGER_PAYLOAD_SZ 8192
+
#define COUNT_INTERVAL 60
/*
* keep 60 minutes' worth of per-minute readings (+ current reading)
Index: squid3/src/delay_pools.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/delay_pools.cc,v
retrieving revision 1.21.22.2
retrieving revision 1.21.22.3
diff -u -r1.21.22.2 -r1.21.22.3
--- squid3/src/delay_pools.cc 25 Jan 2008 02:33:44 -0000 1.21.22.2
+++ squid3/src/delay_pools.cc 27 Jan 2008 18:08:51 -0000 1.21.22.3
@@ -1,6 +1,6 @@
/*
- * $Id: delay_pools.cc,v 1.21.22.2 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: delay_pools.cc,v 1.21.22.3 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 77 Delay Pools
* AUTHOR: Robert Collins
@@ -62,7 +62,6 @@
#include "DelayBucket.h"
#include "DelayUser.h"
#include "DelayTagged.h"
-#include "IPAddress.h"
long DelayPools::MemoryUsed = 0;
@@ -153,7 +152,7 @@
virtual char const *label() const = 0;
- virtual unsigned int makeKey (IPAddress &src_addr) const = 0;
+ virtual unsigned int makeKey (struct IN_ADDR &src_addr) const = 0;
DelaySpec spec;
@@ -183,7 +182,7 @@
protected:
virtual char const *label() const {return "Individual";}
- virtual unsigned int makeKey (IPAddress &src_addr) const;
+ virtual unsigned int makeKey (struct IN_ADDR &src_addr) const;
};
@@ -197,7 +196,7 @@
protected:
virtual char const *label() const {return "Network";}
- virtual unsigned int makeKey (IPAddress &src_addr) const;
+ virtual unsigned int makeKey (struct IN_ADDR &src_addr) const;
};
/* don't use remote storage for these */
@@ -240,9 +239,9 @@
virtual char const *label() const {return "Individual";}
- virtual unsigned int makeKey (IPAddress &src_addr) const;
+ virtual unsigned int makeKey (struct IN_ADDR &src_addr) const;
- unsigned char makeHostKey (IPAddress &src_addr) const;
+ unsigned char makeHostKey (struct IN_ADDR &src_addr) const;
DelaySpec spec;
VectorMap buckets;
@@ -844,17 +843,13 @@
theVector->buckets.values[theIndex].bytesIn (qty);
}
+
unsigned int
-IndividualPool::makeKey (IPAddress &src_addr) const
+IndividualPool::makeKey (struct IN_ADDR &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
- if( !src_addr.IsIPv4() )
- return 1;
-
- /* Temporary bypass for IPv4-only */
- struct in_addr host;
- src_addr.GetInAddr(host);
- return (ntohl(host.s_addr) & 0xff);
+ unsigned int host;
+ host = ntohl(src_addr.s_addr) & 0xff;
+ return host;
}
void *
@@ -872,16 +867,11 @@
}
unsigned int
-ClassCNetPool::makeKey (IPAddress &src_addr) const
+ClassCNetPool::makeKey (struct IN_ADDR &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
- if( !src_addr.IsIPv4() )
- return 1;
-
- /* Temporary bypass for IPv4-only */
- struct in_addr net;
- src_addr.GetInAddr(net);
- return ( (ntohl(net.s_addr) >> 8) & 0xff);
+ unsigned int net;
+ net = (ntohl(src_addr.s_addr) >> 8) & 0xff;
+ return net;
}
@@ -946,29 +936,19 @@
}
unsigned char
-ClassCHostPool::makeHostKey (IPAddress &src_addr) const
+ClassCHostPool::makeHostKey (struct IN_ADDR &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
- if( !src_addr.IsIPv4() )
- return 1;
-
- /* Temporary bypass for IPv4-only */
- struct in_addr host;
- src_addr.GetInAddr(host);
- return (ntohl(host.s_addr) & 0xff);
+ unsigned int host;
+ host = ntohl(src_addr.s_addr) & 0xff;
+ return host;
}
unsigned int
-ClassCHostPool::makeKey (IPAddress &src_addr) const
+ClassCHostPool::makeKey (struct IN_ADDR &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
- if( !src_addr.IsIPv4() )
- return 1;
-
- /* Temporary bypass for IPv4-only */
- struct in_addr net;
- src_addr.GetInAddr(net);
- return ( (ntohl(net.s_addr) >> 8) & 0xff);
+ unsigned int net;
+ net = (ntohl(src_addr.s_addr) >> 8) & 0xff;
+ return net;
}
DelayIdComposite::Pointer
Index: squid3/src/dns_internal.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/dns_internal.cc,v
retrieving revision 1.43.16.1
retrieving revision 1.43.16.2
diff -u -r1.43.16.1 -r1.43.16.2
--- squid3/src/dns_internal.cc 25 Jan 2008 02:33:44 -0000 1.43.16.1
+++ squid3/src/dns_internal.cc 27 Jan 2008 18:08:51 -0000 1.43.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: dns_internal.cc,v 1.43.16.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: dns_internal.cc,v 1.43.16.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c
* AUTHOR: Duane Wessels
@@ -51,7 +51,7 @@
#include
#endif
-/* MS Visual Studio Projects are monolithic, so we need the following
+/* MS VisualStudio Projects are monolithic, so we need the following
#ifndef to exclude the internal DNS code from compile process when
using external DNS process.
*/
@@ -116,11 +116,6 @@
idns_query *queue;
unsigned short domain;
unsigned short do_searchpath;
- bool need_A;
- struct {
- int count;
- rfc1035_rr *answers;
- } initial_AAAA;
};
struct _nsvc
@@ -136,7 +131,8 @@
struct _ns
{
- IPAddress S;
+
+ struct sockaddr_in S;
int nqueries;
int nreplies;
nsvc *vc;
@@ -180,7 +176,7 @@
static IOCB idnsReadVCHeader;
static void idnsDoSendQueryVC(nsvc *vc);
-static int idnsFromKnownNameserver(IPAddress const &from);
+static int idnsFromKnownNameserver(struct sockaddr_in *from);
static idns_query *idnsFindQuery(unsigned short id);
static void idnsGrokReply(const char *buf, size_t sz);
static PF idnsRead;
@@ -191,17 +187,18 @@
static void
idnsAddNameserver(const char *buf)
{
- IPAddress A;
- if (!(A = buf)) {
+ struct IN_ADDR A;
+
+ if (!safe_inet_addr(buf, &A)) {
debugs(78, 0, "WARNING: rejecting '" << buf << "' as a name server, because it is not a numeric IP address");
return;
}
- if (A.IsAnyAddr()) {
- debugs(78, 0, "WARNING: Squid does not accept " << A << " in DNS server specifications.");
- A = "127.0.0.1";
- debugs(78, 0, "Will be using " << A << " instead, assuming you meant that DNS is running on the same machine");
+ if (A.s_addr == 0) {
+ debugs(78, 0, "WARNING: Squid does not accept 0.0.0.0 in DNS server specifications.");
+ debugs(78, 0, "Will be using 127.0.0.1 instead, assuming you meant that DNS is running on the same machine");
+ safe_inet_addr("127.0.0.1", &A);
}
if (nns == nns_alloc) {
@@ -223,9 +220,10 @@
}
assert(nns < nns_alloc);
- A.SetPort(NS_DEFAULTPORT);
- nameservers[nns].S = A;
- debugs(78, 3, "idnsAddNameserver: Added nameserver #" << nns << " (" << A << ")");
+ nameservers[nns].S.sin_family = AF_INET;
+ nameservers[nns].S.sin_port = htons(NS_DEFAULTPORT);
+ nameservers[nns].S.sin_addr.s_addr = A.s_addr;
+ debugs(78, 3, "idnsAddNameserver: Added nameserver #" << nns << ": " << inet_ntoa(nameservers[nns].S.sin_addr));
nns++;
}
@@ -569,7 +567,6 @@
idns_query *q;
int i;
int j;
- char buf[MAX_IPSTRLEN];
storeAppendPrintf(sentry, "Internal DNS Statistics:\n");
storeAppendPrintf(sentry, "\nThe Queue:\n");
storeAppendPrintf(sentry, " DELAY SINCE\n");
@@ -585,12 +582,12 @@
}
storeAppendPrintf(sentry, "\nNameservers:\n");
- storeAppendPrintf(sentry, "IP ADDRESS # QUERIES # REPLIES\n");
- storeAppendPrintf(sentry, "---------------------------------------------- --------- ---------\n");
+ storeAppendPrintf(sentry, "IP ADDRESS # QUERIES # REPLIES\n");
+ storeAppendPrintf(sentry, "--------------- --------- ---------\n");
for (i = 0; i < nns; i++) {
- storeAppendPrintf(sentry, "%-45s %9d %9d\n", /* Let's take the maximum: (15 IPv4/45 IPv6) */
- nameservers[i].S.NtoA(buf,MAX_IPSTRLEN),
+ storeAppendPrintf(sentry, "%-15s %9d %9d\n",
+ inet_ntoa(nameservers[i].S.sin_addr),
nameservers[i].nqueries,
nameservers[i].nreplies);
}
@@ -703,14 +700,12 @@
static void
idnsInitVC(int ns)
{
- char buf[MAX_IPSTRLEN];
-
nsvc *vc = cbdataAlloc(nsvc);
nameservers[ns].vc = vc;
- IPAddress addr;
+ struct IN_ADDR addr;
- if (!Config.Addrs.udp_outgoing.IsNoAddr())
+ if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr)
addr = Config.Addrs.udp_outgoing;
else
addr = Config.Addrs.udp_incoming;
@@ -722,6 +717,7 @@
vc->fd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
addr,
+ 0,
COMM_NONBLOCKING,
"DNS TCP Socket");
@@ -732,7 +728,7 @@
vc->busy = 1;
- commConnectStart(vc->fd, nameservers[ns].S.NtoA(buf,MAX_IPSTRLEN), nameservers[ns].S.GetPort(), idnsInitVCConnected, vc);
+ commConnectStart(vc->fd, inet_ntoa(nameservers[ns].S.sin_addr), ntohs(nameservers[ns].S.sin_port), idnsInitVCConnected, vc);
}
static void
@@ -761,14 +757,12 @@
int ns;
if (DnsSocket < 0) {
- debugs(78, 1, "WARNING: idnsSendQuery: Can't send query, no DNS socket!");
+ debugs(78, 1, "idnsSendQuery: Can't send query, no DNS socket!");
return;
}
- if (nns <= 0) {
- debugs(78, 1, "WARNING: idnsSendQuery: Can't send query, no DNS nameservers known!");
- return;
- }
+ /* XXX Select nameserver */
+ assert(nns > 0);
assert(q->lru.next == NULL);
@@ -782,7 +776,8 @@
x = 0;
} else
x = comm_udp_sendto(DnsSocket,
- nameservers[ns].S,
+ &nameservers[ns].S,
+ sizeof(nameservers[ns].S),
q->buf,
q->sz);
@@ -806,16 +801,17 @@
}
static int
-idnsFromKnownNameserver(IPAddress const &from)
+
+idnsFromKnownNameserver(struct sockaddr_in *from)
{
int i;
for (i = 0; i < nns; i++)
{
- if (nameservers[i].S != from)
+ if (nameservers[i].S.sin_addr.s_addr != from->sin_addr.s_addr)
continue;
- if (nameservers[i].S.GetPort() != from.GetPort())
+ if (nameservers[i].S.sin_port != from->sin_port)
continue;
return i;
@@ -888,16 +884,6 @@
}
}
-void
-idnsDropMessage(rfc1035_message *message, idns_query *q)
-{
- rfc1035MessageDestroy(&message);
- if (q->hash.key) {
- hash_remove_link(idns_lookup_hash, &q->hash);
- q->hash.key = NULL;
- }
-}
-
static void
idnsGrokReply(const char *buf, size_t sz)
{
@@ -905,33 +891,34 @@
rfc1035_message *message = NULL;
idns_query *q;
- n = rfc1035MessageUnpack(buf, sz, &message);
+ n = rfc1035MessageUnpack(buf,
+ sz,
+ &message);
if (message == NULL) {
debugs(78, 1, "idnsGrokReply: Malformed DNS response");
return;
}
- debugs(78, 3, "idnsGrokReply: ID 0x" << std::hex << message->id << ", " << std::dec << n << " answers");
+ debugs(78, 3, "idnsGrokReply: ID 0x" << std::hex << message->id << ", " << std::dec << n << "answers");
q = idnsFindQuery(message->id);
if (q == NULL) {
debugs(78, 3, "idnsGrokReply: Late response");
- rfc1035MessageDestroy(&message);
+ rfc1035MessageDestroy(message);
return;
}
if (rfc1035QueryCompare(&q->query, message->query) != 0) {
debugs(78, 3, "idnsGrokReply: Query mismatch (" << q->query.name << " != " << message->query->name << ")");
- rfc1035MessageDestroy(&message);
+ rfc1035MessageDestroy(message);
return;
}
if (message->tc) {
- debugs(78, 3, HERE << "Resolver requested TC (" << q->query.name << ")");
dlinkDelete(&q->lru, &lru_list);
- rfc1035MessageDestroy(&message);
+ rfc1035MessageDestroy(message);
if (!q->need_vc) {
q->need_vc = 1;
@@ -958,8 +945,7 @@
* unable to process this query due to a problem with
* the name server."
*/
- debugs(78, 3, "idnsGrokReply: Query result: SERV_FAIL");
- rfc1035MessageDestroy(&message);
+ rfc1035MessageDestroy(message);
q->start_t = current_time;
q->id = idnsQueryID();
rfc1035SetQueryID(q->buf, q->id);
@@ -971,8 +957,6 @@
assert(NULL == message->answer);
strcpy(q->name, q->orig);
- debugs(78, 3, "idnsGrokReply: Query result: NXDOMAIN - " << q->name );
-
if (q->domain < npc) {
strcat(q->name, ".");
strcat(q->name, searchpath[q->domain].domain);
@@ -982,99 +966,26 @@
q->attempt++;
}
- idnsDropMessage(message, q);
-
+ rfc1035MessageDestroy(message);
+ if (q->hash.key) {
+ hash_remove_link(idns_lookup_hash, &q->hash);
+ q->hash.key = NULL;
+ }
q->start_t = current_time;
q->id = idnsQueryID();
rfc1035SetQueryID(q->buf, q->id);
-#if USE_IPV6
- if(q->query.qtype == RFC1035_TYPE_AAAA) {
- debugs(78, 3, "idnsGrokReply: Trying AAAA Query for " << q->name);
- q->sz = rfc3596BuildAAAAQuery(q->name, q->buf, sizeof(q->buf), q->id, &q->query);
- }
- else
-#endif
- {
- debugs(78, 3, "idnsGrokReply: Trying A Query for " << q->name);
- q->sz = rfc3596BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id, &q->query);
- }
+ q->sz = rfc1035BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id,
+ &q->query);
+
idnsCacheQuery(q);
idnsSendQuery(q);
return;
}
}
-#if USE_IPV6
- if(q->need_A && (Config.onoff.dns_require_A == 1 || n <= 0 ) )
- {
- /* ERROR or NO AAAA exist. Failover to A records. */
- /* Apparently its also a good idea to lookup and store the A records
- * just in case the AAAA are not available when we need them.
- * This could occur due to number of network failings beyond our control
- * thus the || above allowing the user to request always both.
- */
-
- if(n == 0)
- debugs(78, 3, "idnsGrokReply: " << q->name << " has no AAAA records. Looking up A record instead.");
- else if(q->need_A && n <= 0)
- debugs(78, 3, "idnsGrokReply: " << q->name << " AAAA query failed. Trying A now instead.");
- else // admin requested this.
- debugs(78, 3, "idnsGrokReply: " << q->name << " AAAA query done. Configured to retrieve A now also.");
-
- // move the initial message results into the failover query for merging later.
- if(n > 0) {
- q->initial_AAAA.count = message->ancount;
- q->initial_AAAA.answers = message->answer;
- message->answer = NULL;
- }
-
- // remove the hashed query info
- idnsDropMessage(message, q);
-
- q->start_t = current_time;
- q->id = idnsQueryID();
- rfc1035SetQueryID(q->buf, q->id);
- q->sz = rfc3596BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id, &q->query);
- q->need_A = false;
- idnsCacheQuery(q);
- idnsSendQuery(q);
- return;
- }
-#endif
-
- /** If there are two result sets from preceeding AAAA and A lookups merge them with a preference for AAAA */
- if(q->initial_AAAA.count > 0 && n > 0) {
- /* two sets of RR need merging */
- rfc1035_rr *result = (rfc1035_rr*) xmalloc( sizeof(rfc1035_rr)*(n + q->initial_AAAA.count) );
- rfc1035_rr *tmp = result;
-
- debugs(78, 6, HERE << "Merging DNS results " << q->name << " AAAA has " << q->initial_AAAA.count << " RR, A has " << n << " RR");
-
- memcpy(tmp, q->initial_AAAA.answers, (sizeof(rfc1035_rr)*(q->initial_AAAA.count)) );
- tmp += q->initial_AAAA.count;
- /* free the RR object without freeing its child strings (they are now taken by the copy above) */
- safe_free(q->initial_AAAA.answers);
-
- memcpy( tmp, message->answer, (sizeof(rfc1035_rr)*n) );
- /* free the RR object without freeing its child strings (they are now taken by the copy above) */
- safe_free(message->answer);
-
- message->answer = result;
- n += q->initial_AAAA.count;
- q->initial_AAAA.count=0;
- }
- else if(q->initial_AAAA.count > 0 && n <= 0) {
- /* initial of dual queries was the only result set. */
- debugs(78, 6, HERE << "Merging DNS results " << q->name << " AAAA has " << q->initial_AAAA.count << " RR, A has " << n << " RR");
- rfc1035RRDestroy(&(message->answer), n);
- message->answer = q->initial_AAAA.answers;
- n = q->initial_AAAA.count;
- }
- /* else initial results were empty. just use the final set as authoritative */
-
- debugs(78, 6, HERE << "Sending " << n << " DNS results to caller.");
idnsCallback(q, message->answer, n, q->error);
- rfc1035MessageDestroy(&message);
+ rfc1035MessageDestroy(message);
+
cbdataFree(q);
}
@@ -1083,26 +994,18 @@
{
int *N = &incoming_sockets_accepted;
int len;
+
+ struct sockaddr_in from;
+ socklen_t from_len;
int max = INCOMING_DNS_MAX;
static char rbuf[SQUID_UDP_SO_RCVBUF];
int ns;
- IPAddress from;
-
- debugs(78, 3, "idnsRead: starting with FD " << fd);
-
- /* BUG (UNRESOLVED)
- * two code lines after returning from comm_udprecvfrom()
- * something overwrites the memory behind the from parameter.
- * NO matter where in the stack declaration list above it is placed
- * The cause of this is still unknown, however copying the data appears
- * to allow it to be passed further without this erasure.
- */
- IPAddress bugbypass;
while (max--) {
- len = comm_udp_recvfrom(fd, rbuf, SQUID_UDP_SO_RCVBUF, 0, bugbypass);
+ from_len = sizeof(from);
+ memset(&from, '\0', from_len);
- from = bugbypass; // BUG BYPASS. see notes above.
+ len = comm_udp_recvfrom(fd, rbuf, sizeof(rbuf), 0, (struct sockaddr *) &from, &from_len);
if (len == 0)
break;
@@ -1127,11 +1030,8 @@
fd_bytes(DnsSocket, len, FD_READ);
assert(N);
(*N)++;
-
- debugs(78, 3, "idnsRead: FD " << fd << ": received " << len << " bytes from " << from);
-
- /* BUG: see above. Its here that it becomes apparent that the content of bugbypass is gone. */
- ns = idnsFromKnownNameserver(from);
+ debugs(78, 3, "idnsRead: FD " << fd << ": received " << len << " bytes from " << inet_ntoa(from.sin_addr) << ".");
+ ns = idnsFromKnownNameserver(&from);
if (ns >= 0) {
nameservers[ns].nreplies++;
@@ -1139,12 +1039,9 @@
static time_t last_warning = 0;
if (squid_curtime - last_warning > 60) {
- debugs(78, 1, "WARNING: Reply from unknown nameserver " << from);
+ debugs(78, 1, "WARNING: Reply from unknown nameserver [" << inet_ntoa(from.sin_addr) << "]");
last_warning = squid_curtime;
}
- else {
- debugs(78, 1, "WARNING: Reply from unknown nameserver " << from << " (retrying..." << (squid_curtime-last_warning) << "<=60)" );
- }
continue;
}
@@ -1221,7 +1118,7 @@
debugs(78, 3, "idnsReadVC: FD " << fd << ": received " <<
(int) vc->msg->contentSize() << " bytes via tcp from " <<
- nameservers[vc->ns].S << ".");
+ inet_ntoa(nameservers[vc->ns].S.sin_addr) << ".");
idnsGrokReply(vc->msg->buf, vc->msg->contentSize());
vc->msg->clean();
@@ -1287,9 +1184,9 @@
if (DnsSocket < 0) {
int port;
- IPAddress addr;
+ struct IN_ADDR addr;
- if (!Config.Addrs.udp_outgoing.IsNoAddr())
+ if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr)
addr = Config.Addrs.udp_outgoing;
else
addr = Config.Addrs.udp_incoming;
@@ -1297,11 +1194,10 @@
DnsSocket = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
addr,
+ 0,
COMM_NONBLOCKING,
"DNS Socket");
- debugs(78, 2, "idnsInit: attempt open DNS socket to: " << addr);
-
if (DnsSocket < 0)
fatal("Could not create a DNS socket");
@@ -1310,7 +1206,8 @@
*/
port = comm_local_port(DnsSocket);
- debugs(78, 1, "DNS Socket created at " << addr << ", FD " << DnsSocket);
+ debugs(78, 1, "DNS Socket created at " << inet_ntoa(addr) << ", port " <<
+ port << ", FD " << DnsSocket);
}
assert(0 == nns);
@@ -1442,13 +1339,8 @@
debugs(78, 3, "idnsALookup: searchpath used for " << q->name);
}
-#if USE_IPV6
- q->sz = rfc3596BuildAAAAQuery(q->name, q->buf, sizeof(q->buf), q->id, &q->query);
- q->need_A = true;
-#else
- q->sz = rfc3596BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id, &q->query);
- q->need_A = false;
-#endif
+ q->sz = rfc1035BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id,
+ &q->query);
if (q->sz < 0) {
/* problem with query data -- query not sent */
@@ -1472,34 +1364,18 @@
}
void
-idnsPTRLookup(const IPAddress &addr, IDNSCB * callback, void *data)
+
+idnsPTRLookup(const struct IN_ADDR addr, IDNSCB * callback, void *data)
{
idns_query *q;
- char ip[MAX_IPSTRLEN];
-
- addr.NtoA(ip,MAX_IPSTRLEN);
+ const char *ip = inet_ntoa(addr);
q = cbdataAlloc(idns_query);
q->id = idnsQueryID();
-#if USE_IPV6
- if( addr.IsIPv6() ) {
- struct in6_addr addr6;
- addr.GetInAddr(addr6);
- q->sz = rfc3596BuildPTRQuery6(addr6, q->buf, sizeof(q->buf), q->id, &q->query);
- }
- else
-#endif
- {
- struct in_addr addr4;
- addr.GetInAddr(addr4);
- q->sz = rfc3596BuildPTRQuery4(addr4, q->buf, sizeof(q->buf), q->id, &q->query);
- }
-
- /* PTR does not do inbound A/AAAA */
- q->need_A = false;
+ q->sz = rfc1035BuildPTRQuery(addr, q->buf, sizeof(q->buf), q->id, &q->query);
if (q->sz < 0)
{
Index: squid3/src/dnsserver.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/dnsserver.cc,v
retrieving revision 1.9.34.2
retrieving revision 1.9.34.3
diff -u -r1.9.34.2 -r1.9.34.3
--- squid3/src/dnsserver.cc 25 Jan 2008 02:33:44 -0000 1.9.34.2
+++ squid3/src/dnsserver.cc 27 Jan 2008 18:08:51 -0000 1.9.34.3
@@ -1,6 +1,6 @@
/*
- * $Id: dnsserver.cc,v 1.9.34.2 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: dnsserver.cc,v 1.9.34.3 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 0 DNS Resolver
* AUTHOR: Harvest Derived
@@ -140,38 +140,56 @@
#endif
#include "util.h"
-#include "IPAddress.h"
+
+#if !defined(_SQUID_AIX_) && !defined(_SQUID_MSWIN_)
+extern int h_errno;
+#endif
#if LIBRESOLV_DNS_TTL_HACK
extern int _dns_ttl_; /* this is a really *dirty* hack - bne */
#endif
-/*
- * res_init() is a macro re-definition of __res_init on: Debian
+#ifdef _SQUID_NEXT_
+/* This is a really bloody hack. frank@langen.bull.de
+ * Workaround bug in gethostbyname which sets h_errno wrong
+ * WARNING: This hack queries only the resolver and not NetInfo or YP
*/
-#if !defined(HAVE_RES_INIT) && defined(HAVE___RES_INIT)
-#ifndef res_init
-#define res_init __res_init
-#endif
-#define HAVE_RES_INIT HAVE___RES_INIT
-#endif
+struct hostent *_res_gethostbyname(char *name);
+#define gethostbyname _res_gethostbyname
+#endif /* _SQUID_NEXT_ */
+
+static struct IN_ADDR no_addr;
+
+/* error messages from gethostbyname() */
+static char *
+my_h_msgs(int x)
+{
+ if (x == HOST_NOT_FOUND)
+ return (char *)"Host not found (authoritative)";
+ else if (x == TRY_AGAIN)
+ return (char *)"Host not found (non-authoritative)";
+ else if (x == NO_RECOVERY)
+ return (char *)"Non recoverable errors";
+ else if (x == NO_DATA || x == NO_ADDRESS)
+ return (char *)"Valid name, no data record of requested type";
+ else
+ return (char *)"Unknown DNS problem";
+}
#define REQ_SZ 512
static void
lookup(const char *buf)
{
+
+ const struct hostent *result = NULL;
+ int reverse = 0;
int ttl = 0;
int retry = 0;
- unsigned int i = 0;
- IPAddress ipa;
- char ntoabuf[MAX_IPSTRLEN];
- struct addrinfo hints;
- struct addrinfo *AI = NULL;
- struct addrinfo *aiptr = NULL;
- struct addrinfo *prev_addr = NULL;
- int res = 0;
+ int i;
+
+ struct IN_ADDR addr;
if (0 == strcmp(buf, "$shutdown"))
exit(0);
@@ -181,19 +199,19 @@
return;
}
- /* setup 'hints' for the system lookup */
- memset(&hints, '\0', sizeof(struct addrinfo));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = AI_CANONNAME;
-
+ /* check if it's already an IP address in text form. */
for (;;) {
- xfreeaddrinfo(AI);
- AI = NULL;
+ if (safe_inet_addr(buf, &addr)) {
+ reverse = 1;
+ result = gethostbyaddr((char *) &addr.s_addr, 4, AF_INET);
+ } else {
+ result = gethostbyname(buf);
+ }
- if( 0 == (res = xgetaddrinfo(buf,NULL,&hints,&AI)) )
+ if (NULL != result)
break;
- if (res != EAI_AGAIN)
+ if (h_errno != TRY_AGAIN)
break;
if (++retry == 3)
@@ -202,243 +220,147 @@
sleep(1);
}
- /* check if it's already an IP address in text form. */
- ipa = buf;
- if( ipa.IsAnyAddr() ) {
- /* its a domain name. Use the forward-DNS lookup already done */
-
- if(res == 0) {
-#if LIBRESOLV_DNS_TTL_HACK
- /* DNS TTL handling - bne@CareNet.hu
- * for first try it's a dirty hack, by hacking getanswer
- * to place the ttl in a global variable */
- if (_dns_ttl_ > -1)
- ttl = _dns_ttl_;
-#endif
- printf("$addr %d", ttl);
-
- i = 0;
- aiptr = AI;
- while(NULL != aiptr && 32 >= i) {
- memset(ntoabuf, 0, MAX_IPSTRLEN);
-
- /* getaddrinfo given a host has a nasty tendency to return duplicate addr's */
- /* BUT sorted fortunately, so we can drop most of them easily */
- if( prev_addr &&
- prev_addr->ai_family==aiptr->ai_family &&
- memcmp(aiptr->ai_addr, prev_addr->ai_addr, aiptr->ai_addrlen)==0
- ) {
- prev_addr = aiptr;
- aiptr = aiptr->ai_next;
- continue;
- }
- else {
- prev_addr = aiptr;
- }
-
- /* annoying inet_ntop breaks the nice code by requiring the in*_addr */
- switch(aiptr->ai_family) {
- case AF_INET:
- xinet_ntop(aiptr->ai_family, &((struct sockaddr_in*)aiptr->ai_addr)->sin_addr, ntoabuf, MAX_IPSTRLEN);
- break;
-#if USE_IPV6
- case AF_INET6:
- xinet_ntop(aiptr->ai_family, &((struct sockaddr_in6*)aiptr->ai_addr)->sin6_addr, ntoabuf, MAX_IPSTRLEN);
- break;
-#endif
- default:
- aiptr = aiptr->ai_next;
- continue;
- }
- printf(" %s", ntoabuf);
- i++;
- aiptr = aiptr->ai_next;
- }
-
- prev_addr=NULL;
- printf("\n");
+ if (NULL == result) {
+ if (h_errno == TRY_AGAIN) {
+ printf("$fail Name Server for domain '%s' is unavailable.\n", buf);
+ } else {
+ printf("$fail DNS Domain '%s' is invalid: %s.\n",
+ buf, my_h_msgs(h_errno));
}
- }
- else /* its an IPA in text form. perform rDNS */
- {
- /* You'd expect getaddrinfo given AI_CANONNAME would do a lookup on
- * missing FQDN. But no, it only copies the input string to that
- * position regardless of its content.
- */
- if(NULL != AI && NULL != AI->ai_addr) {
- for(;;) {
- if( 0 == (res = xgetnameinfo(AI->ai_addr, AI->ai_addrlen, ntoabuf, MAX_IPSTRLEN, NULL,0,0)) )
- break;
-
- if (res != EAI_AGAIN)
- break;
-
- if (++retry == 3)
- break;
- sleep(1);
- }
- }
+ return;
+ }
- if(res == 0) {
#if LIBRESOLV_DNS_TTL_HACK
- /* DNS TTL handling - bne@CareNet.hu
- * for first try it's a dirty hack, by hacking getanswer
- * to place the ttl in a global variable */
- if (_dns_ttl_ > -1)
- ttl = _dns_ttl_;
+ /* DNS TTL handling - bne@CareNet.hu
+ * for first try it's a dirty hack, by hacking getanswer
+ * to place the ttl in a global variable */
+ if (_dns_ttl_ > -1)
+ ttl = _dns_ttl_;
+
#endif
- printf("$name %d %s\n", ttl, ntoabuf);
- }
+ if (reverse) {
+ printf("$name %d %s\n", ttl, result->h_name);
+ return;
}
- switch(res) {
- case 0:
- /* no error. */
- break;
+ printf("$addr %d", ttl);
- case EAI_AGAIN:
- printf("$fail Name Server for domain '%s' is unavailable.\n", buf);
+ for (i = 0; NULL != result->h_addr_list[i]; i++) {
+ if (32 == i)
break;
- case EAI_FAIL:
- printf("$fail DNS Domain/IP '%s' does not exist: %s.\n", buf, xgai_strerror(res));
- break;
+ xmemcpy(&addr, result->h_addr_list[i], sizeof(addr));
-#if defined(EAI_NODATA) || defined(EAI_NONAME)
-#ifdef EAI_NODATA
- /* deprecated. obsolete on some OS */
- case EAI_NODATA:
-#endif
-#ifdef EAI_NONAME
- case EAI_NONAME:
-#endif
- printf("$fail DNS Domain/IP '%s' exists without any FQDN/IPs: %s.\n", buf, xgai_strerror(res));
- break;
-#endif
- default:
- printf("$fail A system error occured looking up Domain/IP '%s': %s.\n", buf, xgai_strerror(res));
+ printf(" %s", inet_ntoa(addr));
}
- xfreeaddrinfo(AI);
+ printf("\n");
}
static void
usage(void)
{
- fprintf(stderr, "usage: dnsserver -hv -s nameserver\n"
+ fprintf(stderr, "usage: dnsserver -Dhv -s nameserver\n"
+ "\t-D Enable resolver RES_DEFNAMES and RES_DNSRCH options\n"
"\t-h Help\n"
"\t-v Version\n"
"\t-s nameserver Specify alternate name server(s). 'nameserver'\n"
- "\t must be an IPv4 address, -s option may be repeated\n"
- );
+ "\t must be an IP address, -s option may be repeated\n");
}
-#ifdef _SQUID_RES_NSADDR6_LARRAY
-#define _SQUID_RES_NSADDR6_LIST(i) _SQUID_RES_NSADDR6_LARRAY[i].sin6_addr
-#endif
-#ifdef _SQUID_RES_NSADDR6_LPTR
-#define _SQUID_RES_NSADDR6_LIST(i) _SQUID_RES_NSADDR6_LPTR[i]->sin6_addr
-#endif
-
int
main(int argc, char *argv[])
{
char request[512];
char *t = NULL;
int c;
-#if defined(_SQUID_FREEBSD_) && defined(_SQUID_RES_NSADDR6_COUNT)
- /* Only seems to be valid on FreeBSD 5.5 where _res_ext was provided without an ns6addr counter! */
- /* Gone again on FreeBSD 6.2 along with _res_ext itself in any form. */
- int ns6count = 0;
-#endif
#if HAVE_RES_INIT
- IPAddress ipa;
int opt_s = 0;
-#ifdef _SQUID_RES_NSADDR_LIST
+#if HAVE_RES_NSADDR_LIST || HAVE_RES_NS_LIST
extern char *optarg;
#endif
#endif
+ safe_inet_addr("255.255.255.255", &no_addr);
+
#if HAVE_RES_INIT
+
res_init();
+#ifdef RES_DEFAULT
+
+ _res.options = RES_DEFAULT;
#endif
+#ifdef RES_DEFNAMES
-#if USE_IPV6
- /* perform AAAA lookups *before* A lookups in IPv6 mode. */
- _res.options |= RES_USE_INET6;
+ _res.options &= ~RES_DEFNAMES;
+#endif
+#ifdef RES_DNSRCH
+
+ _res.options &= ~RES_DNSRCH;
+#endif
#endif
while ((c = getopt(argc, argv, "Dhs:v")) != -1) {
switch (c) {
case 'D':
- fprintf(stderr, "-D is now default behaviour from this tool.\n");
+#ifdef RES_DEFNAMES
+
+ _res.options |= RES_DEFNAMES;
+#endif
+#ifdef RES_DNSRCH
+
+ _res.options |= RES_DNSRCH;
+#endif
+
break;
case 's':
-#if HAVE_RES_INIT && (defined(_SQUID_RES_NSADDR_LIST) || defined(_SQUID_RES_NSADDR6_LIST))
+#if HAVE_RES_INIT
if (opt_s == 0) {
-#if defined(_SQUID_RES_NSADDR_COUNT)
- _SQUID_RES_NSADDR_COUNT = 0;
- /* because I don't trust the nscount super-count entirely, make sure these are ALL invalid */
- memset(_SQUID_RES_NSADDR_LIST, 0, sizeof(struct sockaddr_in)*MAXNS);
-#endif
-#if defined(_SQUID_RES_NSADDR6_COUNT)
- _SQUID_RES_NSADDR6_COUNT = 0;
+ _res.nscount = 0;
+ /*
+ * Setting RES_INIT here causes coredumps when -s is
+ * used with -D option. It looks to me like setting
+ * RES_INIT is wrong. The resolver code sets RES_INIT
+ * after calling res_init(). When we change the _res
+ * structure and set RES_INIT, some internal resolver
+ * structures get confused. -DW 2.1.p1
+ */
+#if SEEMS_WRONG
+
+ _res.options |= RES_INIT;
#endif
+
opt_s = 1;
+ } else if (_res.nscount == MAXNS) {
+ fprintf(stderr, "Too many -s options, only %d are allowed\n",
+ MAXNS);
+ break;
}
-/* AYJ:
- * I experimented with all the permutations of mixed/unmixed nscount/nscount6 IPv4/IPv6/Both/invalid
- *
- * I'm not sure if splitting them really helps.
- * I've seen no evidence of IPv4 resolver *ever* being used when some IPv6 are set (or not even)
- * BUT, have seen segfault when IPv4 is added to NSADDR6 list (_res._u._ext).
- * It also appears to not do ANY lookup when _res.nscount==0.
- *
- * BUT, even if _res.nsaddrs is memset to NULL, it resolves IFF IPv6 set in _ext.
- *
- * SO, am splittig the IPv4/v6 into the seperate _res fields
- * and making nscount a total of IPv4+IPv6 /w nscount6 the IPv6 sub-counter
- * ie. nscount = count(NSv4)+count(NSv6) & nscount6 = count(NSv6)
- *
- * If ANYONE knows better please let us know.
- *
- */
- if( !(ipa = optarg) ) {
- fprintf(stderr, "%s appears to be a bad nameserver FQDN/IP.\n",optarg);
- }
- else if( ipa.IsIPv4() ) {
- if (_SQUID_RES_NSADDR_COUNT == MAXNS) {
- fprintf(stderr, "Too many -s options, only %d are allowed\n", MAXNS);
- break;
- }
- _SQUID_RES_NSADDR_LIST[_SQUID_RES_NSADDR_COUNT] = _SQUID_RES_NSADDR_LIST[0];
- ipa.GetInAddr(_SQUID_RES_NSADDR_LIST[_SQUID_RES_NSADDR_COUNT++].sin_addr);
- }
- else if( ipa.IsIPv6() ) {
-#if USE_IPV6 && defined(_SQUID_RES_NSADDR6_LIST)
+#if HAVE_RES_NSADDR_LIST
+ _res.nsaddr_list[_res.nscount] = _res.nsaddr_list[0];
- /* because things NEVER seem to resolve in tests without _res.nscount being a total. */
- if (_SQUID_RES_NSADDR_COUNT == MAXNS) {
- fprintf(stderr, "Too many -s options, only %d are allowed\n", MAXNS);
- break;
- }
- _SQUID_RES_NSADDR_COUNT++;
-
- ipa.GetInAddr(_SQUID_RES_NSADDR6_LIST(_SQUID_RES_NSADDR6_COUNT++));
-#else
- fprintf(stderr, "IPv6 nameservers not supported on this resolver\n");
-#endif
- }
+ safe_inet_addr(optarg, &_res.nsaddr_list[_res.nscount++].sin_addr);
+
+#elif HAVE_RES_NS_LIST
+
+ _res.ns_list[_res.nscount] = _res.ns_list[0];
+
+ safe_inet_addr(optarg, &_res.ns_list[_res.nscount++].addr.sin_addr);
-#else /* !HAVE_RES_INIT || !defined(_SQUID_RES_NSADDR_LIST) */
+#else /* Unknown NS list format */
+
+ fprintf(stderr, "-s is not supported on this resolver\n");
+
+#endif
+#else /* !HAVE_RES_INIT */
fprintf(stderr, "-s is not supported on this resolver\n");
Index: squid3/src/enums.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/enums.h,v
retrieving revision 1.38.6.2
retrieving revision 1.38.6.3
diff -u -r1.38.6.2 -r1.38.6.3
--- squid3/src/enums.h 25 Jan 2008 02:33:44 -0000 1.38.6.2
+++ squid3/src/enums.h 27 Jan 2008 18:08:51 -0000 1.38.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: enums.h,v 1.38.6.2 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: enums.h,v 1.38.6.3 2008/01/27 18:08:51 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -69,6 +69,7 @@
ERR_WRITE_ERROR,
ERR_SHUTTING_DOWN,
ERR_CONNECT_FAIL,
+ ERR_SECURE_CONNECT_FAIL,
ERR_INVALID_REQ,
ERR_UNSUP_REQ,
ERR_INVALID_URL,
@@ -442,8 +443,6 @@
STORE_META_VARY_HEADERS, /* Stores Vary request headers */
STORE_META_STD_LFS, /* standard metadata in lfs format */
STORE_META_OBJSIZE, /* object size, not impleemented, squid26 compatibility */
- STORE_META_STOREURL, /* the store url, if different to the normal URL */
- STORE_META_VARY_ID, /* Unique ID linking variants */
STORE_META_END
};
Index: squid3/src/errorpage.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/errorpage.cc,v
retrieving revision 1.48.16.1
retrieving revision 1.48.16.2
diff -u -r1.48.16.1 -r1.48.16.2
--- squid3/src/errorpage.cc 25 Jan 2008 02:33:44 -0000 1.48.16.1
+++ squid3/src/errorpage.cc 27 Jan 2008 18:08:51 -0000 1.48.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: errorpage.cc,v 1.48.16.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: errorpage.cc,v 1.48.16.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
@@ -493,8 +493,6 @@
HttpRequest *r = err->request;
MemBuf str;
const char *p = NULL; /* takes priority over mb if set */
- char ntoabuf[MAX_IPSTRLEN];
-
str.reset();
/* email subject line */
str.Printf("CacheErrorInfo - %s", errorPageName(err->type));
@@ -522,7 +520,7 @@
str.Printf("TimeStamp: %s\r\n\r\n", mkrfc1123(squid_curtime));
/* - IP stuff */
- str.Printf("ClientIP: %s\r\n", err->src_addr.NtoA(ntoabuf,MAX_IPSTRLEN));
+ str.Printf("ClientIP: %s\r\n", inet_ntoa(err->src_addr));
if (r && r->hier.host) {
str.Printf("ServerIP: %s\r\n", r->hier.host);
@@ -535,7 +533,7 @@
if (NULL != r) {
Packer p;
str.Printf("%s %s HTTP/%d.%d\n",
- RequestMethodStr(r->method),
+ RequestMethodStr[r->method],
r->urlpath.size() ? r->urlpath.buf() : "/",
r->http_ver.major, r->http_ver.minor);
packerToMemInit(&p, &str);
@@ -606,7 +604,6 @@
static MemBuf mb;
const char *p = NULL; /* takes priority over mb if set */
int do_quote = 1;
- char ntoabuf[MAX_IPSTRLEN];
mb.reset();
@@ -680,14 +677,14 @@
if (r->hier.host)
p = r->hier.host;
else
- p = r->GetHost();
+ p = r->host;
} else
p = "[unknown host]";
break;
case 'i':
- mb.Printf("%s", err->src_addr.NtoA(ntoabuf,MAX_IPSTRLEN));
+ mb.Printf("%s", inet_ntoa(err->src_addr));
break;
@@ -714,7 +711,7 @@
break;
case 'M':
- p = r ? RequestMethodStr(r->method) : "[unknown method]";
+ p = r ? RequestMethodStr[r->method] : "[unknown method]";
break;
@@ -741,7 +738,7 @@
if (NULL != r) {
Packer p;
mb.Printf("%s %s HTTP/%d.%d\n",
- RequestMethodStr(r->method),
+ RequestMethodStr[r->method],
r->urlpath.size() ? r->urlpath.buf() : "/",
r->http_ver.major, r->http_ver.minor);
packerToMemInit(&p, &mb);
Index: squid3/src/errorpage.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/errorpage.h,v
retrieving revision 1.3.22.1
retrieving revision 1.3.22.2
diff -u -r1.3.22.1 -r1.3.22.2
--- squid3/src/errorpage.h 25 Jan 2008 02:33:44 -0000 1.3.22.1
+++ squid3/src/errorpage.h 27 Jan 2008 18:08:51 -0000 1.3.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: errorpage.h,v 1.3.22.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: errorpage.h,v 1.3.22.2 2008/01/27 18:08:51 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -37,7 +37,6 @@
#include "squid.h"
#include "cbdata.h"
-#include "IPAddress.h"
class AuthUserRequest;
@@ -56,7 +55,7 @@
char *dnsserver_msg;
time_t ttl;
- IPAddress src_addr;
+ struct IN_ADDR src_addr;
char *redirect_url;
ERCB *callback;
void *callback_data;
Index: squid3/src/event.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/event.cc,v
retrieving revision 1.16.6.1
retrieving revision 1.16.6.2
diff -u -r1.16.6.1 -r1.16.6.2
--- squid3/src/event.cc 25 Jan 2008 02:33:44 -0000 1.16.6.1
+++ squid3/src/event.cc 27 Jan 2008 18:08:51 -0000 1.16.6.2
@@ -1,5 +1,6 @@
+
/*
- * $Id: event.cc,v 1.16.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: event.cc,v 1.16.6.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 41 Event Processing
* AUTHOR: Henrik Nordstrom
@@ -35,7 +36,6 @@
#include "event.h"
#include "CacheManager.h"
#include "Store.h"
-#include "SquidTime.h"
/* The list of event processes */
@@ -268,14 +268,14 @@
if (last_event_ran)
storeAppendPrintf(sentry, "Last event to run: %s\n\n", last_event_ran);
- storeAppendPrintf(sentry, "%-25s\t%-15s\t%s\t%s\n",
+ storeAppendPrintf(sentry, "%s\t%s\t%s\t%s\n",
"Operation",
"Next Execution",
"Weight",
"Callback Valid?");
while (e != NULL) {
- storeAppendPrintf(sentry, "%-25s\t%0.3f sec\t%5d\t %s\n",
+ storeAppendPrintf(sentry, "%s\t%f seconds\t%d\t%s\n",
e->name, e->when ? e->when - current_dtime : 0, e->weight,
(e->arg && e->cbdata) ? cbdataReferenceValid(e->arg) ? "yes" : "no" : "N/A");
e = e->next;
Index: squid3/src/external_acl.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/external_acl.cc,v
retrieving revision 1.57.16.1
retrieving revision 1.57.16.2
diff -u -r1.57.16.1 -r1.57.16.2
--- squid3/src/external_acl.cc 25 Jan 2008 02:33:44 -0000 1.57.16.1
+++ squid3/src/external_acl.cc 27 Jan 2008 18:08:51 -0000 1.57.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: external_acl.cc,v 1.57.16.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: external_acl.cc,v 1.57.16.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 82 External ACL
* AUTHOR: Henrik Nordstrom, MARA Systems AB
@@ -129,8 +129,6 @@
}
quote;
-
- IPAddress local_addr;
};
struct _external_acl_format
@@ -222,13 +220,9 @@
a = cbdataAlloc(external_acl);
- /* set defaults */
a->ttl = DEFAULT_EXTERNAL_ACL_TTL;
a->negative_ttl = -1;
a->children = DEFAULT_EXTERNAL_ACL_CHILDREN;
- a->local_addr.SetLocalhost();
- a->quote = external_acl::QUOTE_METHOD_URL;
-
token = strtok(NULL, w_space);
@@ -239,6 +233,8 @@
token = strtok(NULL, w_space);
+ a->quote = external_acl::QUOTE_METHOD_URL;
+
/* Parse options */
while (token) {
if (strncmp(token, "ttl=", 4) == 0) {
@@ -261,22 +257,6 @@
a->quote = external_acl::QUOTE_METHOD_URL;
} else if (strcmp(token, "quote=shell") == 0) {
a->quote = external_acl::QUOTE_METHOD_SHELL;
-
- /* INET6: allow admin to configure some helpers explicitly to
- bind to IPv4/v6 localhost port. */
- } else if (strcmp(token, "ipv4") == 0) {
-#if IPV6_SPECIAL_LOCALHOST
- debugs(3, 0, "WARNING: --with-localhost-ipv6 conflicts with external ACL helper to using IPv4: " << a->name );
-#endif
- if( !a->local_addr.SetIPv4() ) {
- debugs(3, 0, "WARNING: Error converting " << a->local_addr << " to IPv4 in " << a->name );
- }
- } else if (strcmp(token, "ipv6") == 0) {
-#if !USE_IPV6
- debugs(3, 0, "WARNING: --enable-ipv6 required for external ACL helpers to use IPv6: " << a->name );
-#else
- (void)0;
-#endif
} else {
break;
}
@@ -426,11 +406,6 @@
for (node = list; node; node = node->next) {
storeAppendPrintf(sentry, "%s %s", name, node->name);
- if (!node->local_addr.IsIPv6())
- storeAppendPrintf(sentry, " ipv4");
- else
- storeAppendPrintf(sentry, " ipv6");
-
if (node->ttl != DEFAULT_EXTERNAL_ACL_TTL)
storeAppendPrintf(sentry, " ttl=%d", node->ttl);
@@ -810,20 +785,20 @@
#endif
case _external_acl_format::EXT_ACL_SRC:
- str = ch->src_addr.NtoA(buf,sizeof(buf));
+ str = inet_ntoa(ch->src_addr);
break;
case _external_acl_format::EXT_ACL_SRCPORT:
- snprintf(buf, sizeof(buf), "%d", request->client_addr.GetPort());
+ snprintf(buf, sizeof(buf), "%d", request->client_port);
str = buf;
break;
case _external_acl_format::EXT_ACL_MYADDR:
- str = request->my_addr.NtoA(buf, sizeof(buf));
+ str = inet_ntoa(request->my_addr);
break;
case _external_acl_format::EXT_ACL_MYPORT:
- snprintf(buf, sizeof(buf), "%d", request->my_addr.GetPort());
+ snprintf(buf, sizeof(buf), "%d", request->my_port);
str = buf;
break;
@@ -832,7 +807,7 @@
break;
case _external_acl_format::EXT_ACL_DST:
- str = request->GetHost();
+ str = request->host;
break;
case _external_acl_format::EXT_ACL_PROTO:
@@ -849,7 +824,7 @@
break;
case _external_acl_format::EXT_ACL_METHOD:
- str = RequestMethodStr(request->method);
+ str = RequestMethodStr[request->method];
break;
case _external_acl_format::EXT_ACL_HEADER:
@@ -1316,8 +1291,6 @@
p->theHelper->ipc_type = IPC_TCP_SOCKET;
- p->theHelper->addr = p->local_addr;
-
helperOpenServers(p->theHelper);
}
Index: squid3/src/fd.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/fd.cc,v
retrieving revision 1.17.6.1
retrieving revision 1.17.6.2
diff -u -r1.17.6.1 -r1.17.6.2
--- squid3/src/fd.cc 25 Jan 2008 02:33:44 -0000 1.17.6.1
+++ squid3/src/fd.cc 27 Jan 2008 18:08:51 -0000 1.17.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: fd.cc,v 1.17.6.1 2008/01/25 02:33:44 valexey_eykon Exp $
+ * $Id: fd.cc,v 1.17.6.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 51 Filedescriptor Functions
* AUTHOR: Duane Wessels
@@ -103,7 +103,7 @@
F->flags.open = 0;
fdUpdateBiggest(fd, 0);
Number_FD--;
- F->clear();
+ memset(F, '\0', sizeof(fde));
F->timeout = 0;
}
@@ -181,7 +181,7 @@
}
assert(!F->flags.open);
- debugs(51, 3, "fd_open() FD " << fd << " " << desc);
+ debugs(51, 3, "fd_open FD " << fd << " " << desc);
F->type = type;
F->flags.open = 1;
F->epoll_state = 0;
Index: squid3/src/fde.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/fde.h,v
retrieving revision 1.14.6.1
retrieving revision 1.14.6.2
diff -u -r1.14.6.1 -r1.14.6.2
--- squid3/src/fde.h 25 Jan 2008 02:33:46 -0000 1.14.6.1
+++ squid3/src/fde.h 27 Jan 2008 18:08:51 -0000 1.14.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: fde.h,v 1.14.6.1 2008/01/25 02:33:46 valexey_eykon Exp $
+ * $Id: fde.h,v 1.14.6.2 2008/01/27 18:08:51 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -33,9 +33,7 @@
#ifndef SQUID_FDE_H
#define SQUID_FDE_H
-
#include "comm.h"
-#include "IPAddress.h"
class PconnPool;
@@ -43,13 +41,6 @@
{
public:
- fde() { clear(); };
- /** Clear the fde class properly back to NULL equivalent. */
- inline void clear() {
- memset(this, 0, sizeof(fde));
- local_addr.SetEmpty(); // IPAddress likes to be setup nicely.
- }
-
/* NOTE: memset is used on fdes today. 20030715 RBC */
static void DumpStats (StoreEntry *);
@@ -59,12 +50,12 @@
void noteUse(PconnPool *);
unsigned int type;
+ u_short local_port;
u_short remote_port;
- IPAddress local_addr;
+ struct IN_ADDR local_addr;
unsigned char tos;
- int sock_family;
- char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
+ char ipaddr[16]; /* dotted decimal address of peer */
char desc[FD_DESC_SZ];
struct
Index: squid3/src/forward.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/forward.cc,v
retrieving revision 1.75.6.4
retrieving revision 1.75.6.5
diff -u -r1.75.6.4 -r1.75.6.5
--- squid3/src/forward.cc 25 Jan 2008 02:33:47 -0000 1.75.6.4
+++ squid3/src/forward.cc 27 Jan 2008 18:08:51 -0000 1.75.6.5
@@ -1,6 +1,6 @@
/*
- * $Id: forward.cc,v 1.75.6.4 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: forward.cc,v 1.75.6.5 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 17 Request Forwarding
* AUTHOR: Duane Wessels
@@ -207,13 +207,14 @@
* be allowed. yuck, I know.
*/
- if ( !request->client_addr.IsNoAddr() && request->protocol != PROTO_INTERNAL && request->protocol != PROTO_CACHEOBJ) {
+ if (request->client_addr.s_addr != no_addr.s_addr && request->protocol != PROTO_INTERNAL && request->protocol != PROTO_CACHEOBJ) {
/*
* Check if this host is allowed to fetch MISSES from us (miss_access)
*/
ACLChecklist ch;
ch.src_addr = request->client_addr;
ch.my_addr = request->my_addr;
+ ch.my_port = request->my_port;
ch.request = HTTPMSGLOCK(request);
ch.accessList = cbdataReference(Config.accessList.miss);
/* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */
@@ -270,8 +271,10 @@
FwdState::Pointer fwd = new FwdState(client_fd, entry, request);
#if LINUX_TPROXY
/* If we need to transparently proxy the request
- * then we need the client source protocol, address and port */
- fwd->src = request->client_addr;
+ * then we need the client source address and port */
+ fwd->src.sin_family = AF_INET;
+ fwd->src.sin_addr = request->client_addr;
+ fwd->src.sin_port = request->client_port;
#endif
fwd->start(fwd);
@@ -579,7 +582,7 @@
debugs(81, 1, "fwdNegotiateSSL: Error negotiating SSL connection on FD " << fd <<
": " << ERR_error_string(ERR_get_error(), NULL) << " (" << ssl_error <<
"/" << ret << "/" << errno << ")");
- ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *anErr = errorCon(ERR_SECURE_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
#ifdef EPROTO
anErr->xerrno = EPROTO;
@@ -657,7 +660,15 @@
SSL_set_session(ssl, peer->sslSession);
} else {
- SSL_set_ex_data(ssl, ssl_ex_index_server, (void*)request->GetHost());
+ SSL_set_ex_data(ssl, ssl_ex_index_server, request->host);
+ }
+
+ // Create the ACL check list now, while we have access to more info.
+ // The list is used in ssl_verify_cb() and is freed in ssl_free().
+ if (acl_access *acl = Config.ssl_client.cert_error) {
+ ACLChecklist *check = aclChecklistCreate(acl, request, dash_str);
+ check->fd(fd);
+ SSL_set_ex_data(ssl, ssl_ex_index_cert_error_check, check);
}
fd_table[fd].ssl = ssl;
@@ -687,7 +698,7 @@
if (NULL == fs->_peer)
flags.dont_retry = 1;
- debugs(17, 4, "fwdConnectDone: Unknown host: " << request->GetHost());
+ debugs(17, 4, "fwdConnectDone: Unknown host: " << request->host);
ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
@@ -769,10 +780,10 @@
struct in_tproxy itp;
#endif
- IPAddress outgoing;
+ struct IN_ADDR outgoing;
unsigned short tos;
- IPAddress client_addr;
+ struct IN_ADDR *client_addr = NULL;
assert(fs);
assert(server_fd == -1);
debugs(17, 3, "fwdConnectStart: " << url);
@@ -784,16 +795,16 @@
: Config.Timeout.peer_connect;
if (fs->_peer->options.originserver)
- domain = request->GetHost();
+ domain = request->host;
} else {
- host = request->GetHost();
+ host = request->host;
port = request->port;
ctimeout = Config.Timeout.connect;
}
#if LINUX_TPROXY
if (request->flags.tproxy)
- client_addr = request->client_addr;
+ client_addr = &request->client_addr;
#endif
@@ -828,17 +839,16 @@
tos = getOutgoingTOS(request);
- debugs(17, 3, "fwdConnectStart: got outgoing addr " << outgoing << ", tos " << tos);
+ debugs(17, 3, "fwdConnectStart: got addr " << inet_ntoa(outgoing) << ", tos " << tos);
fd = comm_openex(SOCK_STREAM,
IPPROTO_TCP,
outgoing,
+ 0,
COMM_NONBLOCKING,
tos,
url);
- debugs(17, 3, "fwdConnectStart: got TCP FD " << fd);
-
if (fd < 0) {
debugs(50, 4, "fwdConnectStart: " << xstrerror());
ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
@@ -876,9 +886,7 @@
#if LINUX_TPROXY
if (request->flags.tproxy) {
- IPAddress addr;
-
- src.GetInAddr(itp.v.addr.faddr);
+ itp.v.addr.faddr.s_addr = src.sin_addr.s_addr;
itp.v.addr.fport = 0;
/* If these syscalls fail then we just fallback to connecting
@@ -886,11 +894,10 @@
*/
itp.op = TPROXY_ASSIGN;
- addr = (struct in_addr)itp.v.addr.faddr;
- addr.SetPort(itp.v.addr.fport);
-
if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp, sizeof(itp)) == -1) {
- debugs(20, 1, "tproxy ip=" << addr << " ERROR ASSIGN");
+ debugs(20, 1, "tproxy ip=" << inet_ntoa(itp.v.addr.faddr) <<
+ ",0x" << std::hex << itp.v.addr.faddr.s_addr << std::dec <<
+ ",port=" << itp.v.addr.fport << " ERROR ASSIGN");
request->flags.tproxy = 0;
} else {
@@ -898,7 +905,9 @@
itp.v.flags = ITP_CONNECT;
if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp, sizeof(itp)) == -1) {
- debugs(20, 1, "tproxy ip=" << addr << " ERROR CONNECT");
+ debugs(20, 1, "tproxy ip=" << std::hex <<
+ itp.v.addr.faddr.s_addr << std::dec << ",port=" <<
+ itp.v.addr.fport << " ERROR CONNECT");
request->flags.tproxy = 0;
}
@@ -906,7 +915,7 @@
}
#endif
- hierarchyNote(&request->hier, fs->code, request->GetHost());
+ hierarchyNote(&request->hier, fs->code, request->host);
}
commConnectStart(fd, host, port, fwdConnectDoneWrapper, this);
@@ -939,7 +948,7 @@
FwdState::dispatch()
{
peer *p = NULL;
- debugs(17, 3, "fwdDispatch: FD " << client_fd << ": Fetching '" << RequestMethodStr(request->method) << " " << entry->url() << "'" );
+ debugs(17, 3, "fwdDispatch: FD " << client_fd << ": Fetching '" << RequestMethodStr[request->method] << " " << entry->url() << "'" );
/*
* Assert that server_fd is set. This is to guarantee that fwdState
* is attached to something and will be deallocated when server_fd
@@ -958,7 +967,7 @@
EBIT_SET(entry->flags, ENTRY_DISPATCHED);
- netdbPingSite(request->GetHost());
+ netdbPingSite(request->host);
if (servers && (p = servers->_peer)) {
p->stats.fetches++;
@@ -1135,7 +1144,7 @@
void
-FwdState::pconnPush(int fd, const char *host, int port, const char *domain, IPAddress &client_addr)
+FwdState::pconnPush(int fd, const char *host, int port, const char *domain, struct IN_ADDR *client_addr)
{
fwdPconnPool->push(fd, host, port, domain, client_addr);
}
@@ -1201,12 +1210,12 @@
memFree(fs, MEM_FWD_SERVER);
}
-static IPAddress
-aclMapAddr(acl_address * head, ACLChecklist * ch)
+static struct IN_ADDR
+ aclMapAddr(acl_address * head, ACLChecklist * ch)
{
acl_address *l;
- IPAddress addr;
+ struct IN_ADDR addr;
for (l = head; l; l = l->next)
{
@@ -1214,7 +1223,7 @@
return l->addr;
}
- addr.SetAnyAddr();
+ addr.s_addr = INADDR_ANY;
return addr;
}
@@ -1235,8 +1244,8 @@
return 0;
}
-IPAddress
-getOutgoingAddr(HttpRequest * request)
+struct IN_ADDR
+ getOutgoingAddr(HttpRequest * request)
{
ACLChecklist ch;
@@ -1244,6 +1253,7 @@
{
ch.src_addr = request->client_addr;
ch.my_addr = request->my_addr;
+ ch.my_port = request->my_port;
ch.request = HTTPMSGLOCK(request);
}
@@ -1258,6 +1268,7 @@
if (request) {
ch.src_addr = request->client_addr;
ch.my_addr = request->my_addr;
+ ch.my_port = request->my_port;
ch.request = HTTPMSGLOCK(request);
}
@@ -1296,7 +1307,7 @@
(int) current_time.tv_sec,
(int) current_time.tv_usec / 1000,
last_status,
- RequestMethodStr(request->method),
+ RequestMethodStr[request->method],
request->canonical);
}
Index: squid3/src/forward.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/forward.h,v
retrieving revision 1.12.16.1
retrieving revision 1.12.16.2
diff -u -r1.12.16.1 -r1.12.16.2
--- squid3/src/forward.h 25 Jan 2008 02:33:47 -0000 1.12.16.1
+++ squid3/src/forward.h 27 Jan 2008 18:08:51 -0000 1.12.16.2
@@ -7,7 +7,6 @@
class ErrorState;
#include "comm.h"
-#include "IPAddress.h"
class FwdServer
{
@@ -45,7 +44,7 @@
bool checkRetry();
bool checkRetriable();
void dispatch();
- void pconnPush(int fd, const char *host, int port, const char *domain, IPAddress &client_addr);
+ void pconnPush(int fd, const char *host, int port, const char *domain, struct IN_ADDR *client_addr);
bool dontRetry() { return flags.dont_retry; }
@@ -107,7 +106,7 @@
flags;
#if LINUX_NETFILTER
- IPAddress src;
+ struct sockaddr_in src;
#endif
};
Index: squid3/src/fqdncache.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/fqdncache.cc,v
retrieving revision 1.23.2.1
retrieving revision 1.23.2.2
diff -u -r1.23.2.1 -r1.23.2.2
--- squid3/src/fqdncache.cc 25 Jan 2008 02:33:47 -0000 1.23.2.1
+++ squid3/src/fqdncache.cc 27 Jan 2008 18:08:51 -0000 1.23.2.2
@@ -1,6 +1,6 @@
/*
- * $Id: fqdncache.cc,v 1.23.2.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: fqdncache.cc,v 1.23.2.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
@@ -440,17 +440,17 @@
}
void
-fqdncache_nbgethostbyaddr(IPAddress &addr, FQDNH * handler, void *handlerData)
+
+fqdncache_nbgethostbyaddr(struct IN_ADDR addr, FQDNH * handler, void *handlerData)
{
fqdncache_entry *f = NULL;
- char name[MAX_IPSTRLEN];
+ char *name = inet_ntoa(addr);
generic_cbdata *c;
assert(handler);
- addr.NtoA(name,MAX_IPSTRLEN);
debugs(35, 4, "fqdncache_nbgethostbyaddr: Name '" << name << "'.");
FqdncacheStats.requests++;
- if (name[0] == '\0')
+ if (name == NULL || name[0] == '\0')
{
debugs(35, 4, "fqdncache_nbgethostbyaddr: Invalid name!");
dns_error_message = "Invalid hostname";
@@ -499,6 +499,7 @@
dnsSubmit(hashKeyStr(&f->hash), fqdncacheHandleReply, c);
#else
+
idnsPTRLookup(addr, fqdncacheHandleReply, c);
#endif
}
@@ -542,13 +543,14 @@
}
const char *
-fqdncache_gethostbyaddr(IPAddress &addr, int flags)
+
+fqdncache_gethostbyaddr(struct IN_ADDR addr, int flags)
{
- char name[MAX_IPSTRLEN];
+ char *name = inet_ntoa(addr);
fqdncache_entry *f = NULL;
- assert(!addr.IsAnyAddr() && !addr.IsNoAddr());
- addr.NtoA(name,MAX_IPSTRLEN);
+ struct IN_ADDR ip;
+ assert(name);
FqdncacheStats.requests++;
f = fqdncache_get(name);
@@ -574,12 +576,15 @@
dns_error_message = NULL;
+ /* check if it's already a FQDN address in text form. */
+
+ if (!safe_inet_addr(name, &ip))
+ return name;
+
FqdncacheStats.misses++;
if (flags & FQDN_LOOKUP_IF_MISS)
- {
fqdncache_nbgethostbyaddr(addr, dummy_handler, NULL);
- }
return NULL;
}
@@ -615,14 +620,14 @@
storeAppendPrintf(sentry, "FQDN Cache Contents:\n\n");
- storeAppendPrintf(sentry, "%-45.45s %3s %3s %3s %s\n",
+ storeAppendPrintf(sentry, "%-15.15s %3s %3s %3s %s\n",
"Address", "Flg", "TTL", "Cnt", "Hostnames");
hash_first(fqdn_table);
while ((f = (fqdncache_entry *) hash_next(fqdn_table))) {
ttl = (f->flags.fromhosts ? -1 : (f->expires - squid_curtime));
- storeAppendPrintf(sentry, "%-45.45s %c%c %3.3d % 3d",
+ storeAppendPrintf(sentry, "%-15.15s %c%c %3.3d % 3d",
hashKeyStr(&f->hash),
f->flags.negcached ? 'N' : ' ',
f->flags.fromhosts ? 'H' : ' ',
@@ -643,17 +648,16 @@
}
const char *
-fqdnFromAddr(IPAddress &addr)
+
+fqdnFromAddr(struct IN_ADDR addr)
{
const char *n;
- static char buf[MAX_IPSTRLEN];
+ static char buf[32];
if (Config.onoff.log_fqdn && (n = fqdncache_gethostbyaddr(addr, 0)))
return n;
-/// \todo Perhaose this should use toHostname() instead of straight NtoA.
-/// that would wrap the IPv6 properly when raw.
- addr.NtoA(buf, MAX_IPSTRLEN);
+ xstrncpy(buf, inet_ntoa(addr), 32);
return buf;
}
Index: squid3/src/ftp.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ftp.cc,v
retrieving revision 1.89.6.1
retrieving revision 1.89.6.2
diff -u -r1.89.6.1 -r1.89.6.2
--- squid3/src/ftp.cc 25 Jan 2008 02:33:47 -0000 1.89.6.1
+++ squid3/src/ftp.cc 27 Jan 2008 18:08:51 -0000 1.89.6.2
@@ -1,5 +1,5 @@
/*
- * $Id: ftp.cc,v 1.89.6.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: ftp.cc,v 1.89.6.2 2008/01/27 18:08:51 rousskov Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
@@ -64,11 +64,7 @@
SENT_TYPE,
SENT_MDTM,
SENT_SIZE,
- SENT_EPRT,
SENT_PORT,
- SENT_EPSV_ALL,
- SENT_EPSV_1,
- SENT_EPSV_2,
SENT_PASV,
SENT_CWD,
SENT_LIST,
@@ -86,7 +82,6 @@
{
bool isdir;
bool pasv_supported;
- bool epsv_all_sent;
bool skip_whitespace;
bool rest_supported;
bool pasv_only;
@@ -260,8 +255,8 @@
ftpListParts;
-#define FTP_LOGIN_ESCAPED 1
-#define FTP_LOGIN_NOT_ESCAPED 0
+#define FTP_LOGIN_ESCAPED 1
+#define FTP_LOGIN_NOT_ESCAPED 0
/*
* State machine functions
@@ -280,12 +275,9 @@
static FTPSM ftpReadMdtm;
static FTPSM ftpSendSize;
static FTPSM ftpReadSize;
-static FTPSM ftpSendEPRT;
-static FTPSM ftpReadEPRT;
-static FTPSM ftpSendPORT;
-static FTPSM ftpReadPORT;
-static FTPSM ftpSendPassive;
-static FTPSM ftpReadEPSV;
+static FTPSM ftpSendPort;
+static FTPSM ftpReadPort;
+static FTPSM ftpSendPasv;
static FTPSM ftpReadPasv;
static FTPSM ftpTraverseDirectory;
static FTPSM ftpListDir;
@@ -310,20 +302,6 @@
static FTPSM ftpFail;
static FTPSM ftpSendQuit;
static FTPSM ftpReadQuit;
-
-/************************************************
-** Debugs Levels used here **
-*************************************************
-0 CRITICAL Events
-1 IMPORTANT Events
- Protocol and Transmission failures.
-2 FTP Protocol Chatter
-3 Logic Flows
-4 Data Parsing Flows
-5 Data Dumps
-7 ??
-************************************************/
-
/************************************************
** State Machine Description (excluding hacks) **
*************************************************
@@ -337,9 +315,9 @@
Cwd TraverseDirectory / Mkdir
GetFile Mdtm
Mdtm Size
-Size Epsv
-ListDir Epsv
-Epsv FileOrList
+Size Pasv
+ListDir Pasv
+Pasv FileOrList
FileOrList Rest / Retr / Nlst / List / Mkdir (PUT /xxx;type=d)
Rest Retr
Retr / Nlst / List DataRead* (on datachannel)
@@ -361,13 +339,9 @@
ftpReadType, /* SENT_TYPE */
ftpReadMdtm, /* SENT_MDTM */
ftpReadSize, /* SENT_SIZE */
- ftpReadEPRT, /* SENT_EPRT */
- ftpReadPORT, /* SENT_PORT */
- ftpReadEPSV, /* SENT_EPSV_ALL */
- ftpReadEPSV, /* SENT_EPSV_1 */
- ftpReadEPSV, /* SENT_EPSV_2 */
+ ftpReadPort, /* SENT_PORT */
ftpReadPasv, /* SENT_PASV */
- ftpReadCwd, /* SENT_CWD */
+ ftpReadCwd, /* SENT_CWD */
ftpReadList, /* SENT_LIST */
ftpReadList, /* SENT_NLST */
ftpReadRest, /* SENT_REST */
@@ -390,7 +364,7 @@
FtpStateData::FtpStateData(FwdState *theFwdState) : ServerStateData(theFwdState)
{
const char *url = entry->url();
- debugs(9, 3, HERE << "'" << url << "'" );
+ debugs(9, 3, "ftpStart: '" << url << "'" );
statCounter.server.all.requests++;
statCounter.server.ftp.requests++;
ctrl.fd = theFwdState->server_fd;
@@ -411,7 +385,7 @@
FtpStateData::~FtpStateData()
{
- debugs(9, 3, HERE << entry->url() );
+ debugs(9, 3, "~ftpStateData: " << entry->url() );
if (reply_hdr) {
memFree(reply_hdr, MEM_8K_BUF);
@@ -501,13 +475,13 @@
{
FtpStateData *ftpState = (FtpStateData *)data;
StoreEntry *entry = ftpState->entry;
- debugs(9, 4, HERE << "FD " << fd << ": '" << entry->url() << "'" );
+ debugs(9, 4, "ftpTimeout: FD " << fd << ": '" << entry->url() << "'" );
if (SENT_PASV == ftpState->state && fd == ftpState->data.fd) {
/* stupid ftp.netscape.com */
ftpState->fwd->dontRetry(false);
ftpState->fwd->ftpPasvFailed(true);
- debugs(9, DBG_IMPORTANT, "Timeout in SENT_PASV state" );
+ debugs(9, 1, "ftpTimeout: timeout in SENT_PASV state" );
}
ftpState->failed(ERR_READ_TIMEOUT, 0);
@@ -517,7 +491,7 @@
void
FtpStateData::listingStart()
{
- debugs(9,3, HERE);
+ debugs(9,3,HERE << "listingStart()");
wordlist *w;
char *dirup;
int i, j, k;
@@ -588,7 +562,7 @@
/* Error guard, or "assert" */
printfReplyBody("ERROR: Failed to parse URL: %s\n",
html_quote(title));
- debugs(9, DBG_CRITICAL, "Failed to parse URL: " << title);
+ debugs(9, 0, "Failed to parse URL: " << title);
break;
}
}
@@ -603,7 +577,7 @@
void
FtpStateData::listingFinish()
{
- debugs(9,3,HERE);
+ debugs(9,3,HERE << "listingFinish()");
entry->buffer();
printfReplyBody("\n");
@@ -1119,7 +1093,7 @@
size_t len = data.readBuf->contentSize();
if (!len) {
- debugs(9, 3, HERE << "no content to parse for " << e->url() );
+ debugs(9, 3, "ftpParseListing: no content to parse for " << e->url() );
return;
}
@@ -1135,15 +1109,15 @@
usable = end - sbuf;
- debugs(9, 3, HERE << "usable = " << usable);
+ debugs(9, 3, "ftpParseListing: usable = " << usable);
if (usable == 0) {
- debugs(9, 3, HERE << "didn't find end for " << e->url() );
+ debugs(9, 3, "ftpParseListing: didn't find end for " << e->url() );
xfree(sbuf);
return;
}
- debugs(9, 3, HERE << (unsigned long int)len << " bytes to play with");
+ debugs(9, 3, "ftpParseListing: " << (unsigned long int)len << " bytes to play with");
line = (char *)memAllocate(MEM_4K_BUF);
end++;
@@ -1152,7 +1126,7 @@
s += strspn(s, crlf);
for (; s < end; s += strcspn(s, crlf), s += strspn(s, crlf)) {
- debugs(9, 7, HERE << "s = {" << s << "}");
+ debugs(9, 3, "ftpParseListing: s = {" << s << "}");
linelen = strcspn(s, crlf) + 1;
if (linelen < 2)
@@ -1163,7 +1137,7 @@
xstrncpy(line, s, linelen);
- debugs(9, 7, HERE << "{" << line << "}");
+ debugs(9, 7, "ftpParseListing: {" << line << "}");
if (!strncmp(line, "total", 5))
continue;
@@ -1188,13 +1162,13 @@
void
FtpStateData::dataComplete()
{
- debugs(9, 3,HERE);
-
+ debugs(9, 3, "ftpDataComplete");
/* Connection closed; transfer done. */
+
if (data.fd > -1) {
- /**
- * Close data socket so it does not occupy resources while
- * we wait.
+ /*
+ * close data socket so it does not occupy resources while
+ * we wait
*/
comm_close(data.fd);
data.fd = -1;
@@ -1251,7 +1225,7 @@
int j;
int bin;
- debugs(9, 3, HERE << "FD " << fd << " Read " << len << " bytes");
+ debugs(9, 3, HERE << "ftpDataRead: FD " << fd << " Read " << len << " bytes");
if (len > 0) {
kb_incr(&statCounter.server.all.kbytes_in, len);
@@ -1300,7 +1274,7 @@
}
if (errflag != COMM_OK || len < 0) {
- debugs(50, ignoreErrno(xerrno) ? 3 : DBG_IMPORTANT, HERE << "read error: " << xstrerr(xerrno));
+ debugs(50, ignoreErrno(xerrno) ? 3 : 1, "ftpDataRead: read error: " << xstrerr(xerrno));
if (ignoreErrno(xerrno)) {
commSetTimeout(fd, Config.Timeout.read, ftpTimeout, this);
@@ -1316,7 +1290,7 @@
return;
}
} else if (len == 0) {
- debugs(9,3, HERE << "Calling dataComplete() because len == 0");
+ debugs(9,5,HERE << "Calling dataComplete() because len == 0");
/*
* DPW 2007-04-23
* Dangerous curves ahead. This call to dataComplete was
@@ -1336,7 +1310,7 @@
void
FtpStateData::processReplyBody()
{
- debugs(9, 3, HERE);
+ debugs(9, 5, HERE << "FtpStateData::processReplyBody starting.");
if (request->method == METHOD_HEAD && (flags.isdir || theSize != -1)) {
serverComplete();
@@ -1358,7 +1332,7 @@
#if ICAP_CLIENT
if (icapAccessCheckPending) {
- debugs(9,3, HERE << "returning from FtpStateData::processReplyBody due to icapAccessCheckPending");
+ debugs(9,3,HERE << "returning from FtpStateData::processReplyBody due to icapAccessCheckPending");
return;
}
@@ -1372,7 +1346,7 @@
} else
if (const int csize = data.readBuf->contentSize()) {
writeReplyBody(data.readBuf->content(), csize);
- debugs(9, 5, HERE << "consuming " << csize << " bytes of readBuf");
+ debugs(9,5,HERE << "consuming " << csize << " bytes of readBuf");
data.readBuf->consume(csize);
}
@@ -1465,7 +1439,7 @@
title_url.append("@");
}
- title_url.append(request->GetHost());
+ title_url.append(request->host);
if (request->port != urlDefaultPort(PROTO_FTP)) {
title_url.append(":");
@@ -1487,7 +1461,7 @@
base_href.append("@");
}
- base_href.append(request->GetHost());
+ base_href.append(request->host);
if (request->port != urlDefaultPort(PROTO_FTP)) {
base_href.append(":");
@@ -1531,7 +1505,7 @@
checkUrlpath();
buildTitleUrl();
- debugs(9, 5, HERE << "host=" << request->GetHost() << ", path=" <<
+ debugs(9, 5, "ftpStart: host=" << request->host << ", path=" <<
request->urlpath.buf() << ", user=" << user << ", passwd=" <<
password);
@@ -1576,8 +1550,7 @@
FtpStateData::writeCommand(const char *buf)
{
char *ebuf;
- /* trace FTP protocol communications at level 2 */
- debugs(9, 2, "ftp<< " << buf);
+ debugs(9, 5, "ftpWriteCommand: " << buf);
if (Config.Ftp.telnet)
ebuf = escapeIAC(buf);
@@ -1604,7 +1577,7 @@
{
FtpStateData *ftpState = (FtpStateData *)data;
- debugs(9, 5, HERE << "wrote " << size << " bytes");
+ debugs(9, 7, "ftpWriteCommandCallback: wrote " << size << " bytes");
if (size > 0) {
fd_bytes(fd, size, FD_WRITE);
@@ -1616,7 +1589,7 @@
return;
if (errflag) {
- debugs(9, DBG_IMPORTANT, HERE << "FD " << fd << ": " << xstrerr(xerrno));
+ debugs(9, 1, "ftpWriteCommandCallback: FD " << fd << ": " << xstrerr(xerrno));
ftpState->failed(ERR_WRITE_ERROR, xerrno);
/* failed closes ctrl.fd and frees ftpState */
return;
@@ -1637,7 +1610,7 @@
size_t offset;
size_t linelen;
int code = -1;
- debugs(9, 3, HERE);
+ debugs(9, 5, "ftpParseControlReply");
/*
* We need a NULL-terminated buffer for scanning, ick
*/
@@ -1650,15 +1623,15 @@
usable = end - sbuf;
- debugs(9, 3, HERE << "usable = " << usable);
+ debugs(9, 3, "ftpParseControlReply: usable = " << usable);
if (usable == 0) {
- debugs(9, 3, HERE << "didn't find end of line");
+ debugs(9, 3, "ftpParseControlReply: didn't find end of line");
safe_free(sbuf);
return NULL;
}
- debugs(9, 3, HERE << len << " bytes to play with");
+ debugs(9, 3, "ftpParseControlReply: " << len << " bytes to play with");
end++;
s = sbuf;
s += strspn(s, crlf);
@@ -1667,7 +1640,7 @@
if (complete)
break;
- debugs(9, 5, HERE << "s = {" << s << "}");
+ debugs(9, 3, "ftpParseControlReply: s = {" << s << "}");
linelen = strcspn(s, crlf) + 1;
@@ -1692,8 +1665,7 @@
xstrncpy(list->key, s + offset, linelen - offset);
- /* trace the FTP communication chat at level 2 */
- debugs(9, 2, "ftp>> " << code << " " << list->key);
+ debugs(9, 7, "" << code << " " << list->key);
*tail = list;
@@ -1720,7 +1692,7 @@
void
FtpStateData::scheduleReadControlReply(int buffered_ok)
{
- debugs(9, 3, HERE << "FD " << ctrl.fd);
+ debugs(9, 3, "scheduleReadControlReply: FD " << ctrl.fd);
if (buffered_ok && ctrl.offset > 0) {
/* We've already read some reply data */
@@ -1746,7 +1718,7 @@
{
FtpStateData *ftpState = (FtpStateData *)data;
StoreEntry *entry = ftpState->entry;
- debugs(9, 3, HERE "FD " << fd << ", Read " << len << " bytes");
+ debugs(9, 5, "ftpReadControlReply: FD " << fd << ", Read " << len << " bytes");
if (len > 0) {
kb_incr(&statCounter.server.all.kbytes_in, len);
@@ -1769,7 +1741,7 @@
if (errflag != COMM_OK || len < 0) {
- debugs(50, ignoreErrno(xerrno) ? 3 : DBG_IMPORTANT, "ftpReadControlReply: read error: " << xstrerr(xerrno));
+ debugs(50, ignoreErrno(xerrno) ? 3 : 1, "ftpReadControlReply: read error: " << xstrerr(xerrno));
if (ignoreErrno(xerrno)) {
ftpState->scheduleReadControlReply(0);
@@ -1844,7 +1816,7 @@
*/
wordlistAddWl(&cwd_message, ctrl.message);
- debugs(9, 3, HERE << "state=" << state << ", code=" << ctrl.replycode);
+ debugs(9, 8, "handleControlReply: state=" << state << ", code=" << ctrl.replycode);
FTP_SM_FUNCS[state] (this);
}
@@ -1855,7 +1827,7 @@
ftpReadWelcome(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "ftpReadWelcome");
if (ftpState->flags.pasv_only)
ftpState->login_att++;
@@ -1872,7 +1844,7 @@
ftpSendUser(ftpState);
} else if (code == 120) {
if (NULL != ftpState->ctrl.message)
- debugs(9, DBG_IMPORTANT, "FTP server is busy: " << ftpState->ctrl.message->key);
+ debugs(9, 3, "FTP server is busy: " << ftpState->ctrl.message->key);
return;
} else {
@@ -1890,7 +1862,7 @@
if (ftpState->proxy_host != NULL)
snprintf(cbuf, 1024, "USER %s@%s\r\n",
ftpState->user,
- ftpState->request->GetHost());
+ ftpState->request->host);
else
snprintf(cbuf, 1024, "USER %s\r\n", ftpState->user);
@@ -1903,7 +1875,7 @@
ftpReadUser(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "ftpReadUser");
if (code == 230) {
ftpReadPass(ftpState);
@@ -1930,7 +1902,7 @@
ftpReadPass(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "ftpReadPass");
if (code == 230) {
ftpSendType(ftpState);
@@ -1997,7 +1969,7 @@
int code = ftpState->ctrl.replycode;
char *path;
char *d, *p;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadType");
if (code == 200) {
p = path = xstrdup(ftpState->request->urlpath.buf());
@@ -2033,7 +2005,7 @@
ftpTraverseDirectory(FtpStateData * ftpState)
{
wordlist *w;
- debugs(9, 4, HERE << (ftpState->filepath ? ftpState->filepath : ""));
+ debugs(9, 4, "ftpTraverseDirectory " << (ftpState->filepath ? ftpState->filepath : ""));
safe_free(ftpState->dirpath);
ftpState->dirpath = ftpState->filepath;
@@ -2042,7 +2014,7 @@
/* Done? */
if (ftpState->pathcomps == NULL) {
- debugs(9, 3, HERE << "the final component was a directory");
+ debugs(9, 3, "the final component was a directory");
ftpListDir(ftpState);
return;
}
@@ -2060,7 +2032,7 @@
if (ftpState->pathcomps != NULL || ftpState->flags.isdir) {
ftpSendCwd(ftpState);
} else {
- debugs(9, 3, HERE << "final component is probably a file");
+ debugs(9, 3, "final component is probably a file");
ftpGetFile(ftpState);
return;
}
@@ -2075,7 +2047,7 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendCwd"))
return;
- debugs(9, 3, HERE);
+ debugs(9, 3, "ftpSendCwd");
path = ftpState->filepath;
@@ -2096,7 +2068,7 @@
ftpReadCwd(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadCwd");
if (code >= 200 && code < 300) {
/* CWD OK */
@@ -2132,7 +2104,7 @@
return;
path = ftpState->filepath;
- debugs(9, 3, HERE << "with path=" << path);
+ debugs(9, 3, "ftpSendMkdir: with path=" << path);
snprintf(cbuf, 1024, "MKD %s\r\n", path);
ftpState->writeCommand(cbuf);
ftpState->state = SENT_MKDIR;
@@ -2144,7 +2116,7 @@
char *path = ftpState->filepath;
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE << "path " << path << ", code " << code);
+ debugs(9, 3, "ftpReadMkdir: path " << path << ", code " << code);
if (code == 257) { /* success */
ftpSendCwd(ftpState);
@@ -2171,12 +2143,12 @@
ftpListDir(FtpStateData * ftpState)
{
if (ftpState->flags.dir_slash) {
- debugs(9, 3, HERE << "Directory path did not end in /");
+ debugs(9, 3, "Directory path did not end in /");
ftpState->title_url.append("/");
ftpState->flags.isdir = 1;
}
- ftpSendPassive(ftpState);
+ ftpSendPasv(ftpState);
}
static void
@@ -2196,7 +2168,7 @@
ftpReadMdtm(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadMdtm");
if (code == 213) {
ftpState->mdtm = parse_iso3307_time(ftpState->ctrl.last_reply);
@@ -2213,7 +2185,7 @@
ftpSendSize(FtpStateData * ftpState)
{
/* check the server control channel is still available */
- if(!ftpState || !ftpState->haveControlChannel("ftpSendSize"))
+ if(!ftpState || !ftpState->haveControlChannel("ftpSendPasv"))
return;
/* Only send SIZE for binary transfers. The returned size
@@ -2227,21 +2199,21 @@
ftpState->state = SENT_SIZE;
} else
/* Skip to next state no non-binary transfers */
- ftpSendPassive(ftpState);
+ ftpSendPasv(ftpState);
}
static void
ftpReadSize(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadSize");
if (code == 213) {
ftpState->unhack();
ftpState->theSize = strtoll(ftpState->ctrl.last_reply, NULL, 10);
if (ftpState->theSize == 0) {
- debugs(9, 2, "SIZE reported " <<
+ debugs(9, 2, "ftpReadSize: SIZE reported " <<
ftpState->ctrl.last_reply << " on " <<
ftpState->title_url.buf());
ftpState->theSize = -1;
@@ -2251,199 +2223,54 @@
return;
}
- ftpSendPassive(ftpState);
+ ftpSendPasv(ftpState);
}
static void
-ftpReadEPSV(FtpStateData* ftpState)
+ftpSendPasv(FtpStateData * ftpState)
{
- int code = ftpState->ctrl.replycode;
- char h1, h2, h3, h4;
- int n;
- u_short port;
- IPAddress ipa_remote;
- int fd = ftpState->data.fd;
- char *buf;
- debugs(9, 3, HERE);
-
- if (code != 229 && code != 522) {
- if(code == 200) {
- /* handle broken servers (RFC 2428 says OK code for EPSV MUST be 229 not 200) */
- /* vsftpd for one send '200 EPSV ALL ok.' without even port info.
- * Its okay to re-send EPSV 1/2 but nothing else. */
- debugs(9, DBG_IMPORTANT, "Broken FTP Server at " << fd_table[ftpState->ctrl.fd].ipaddr << ". Wrong accept code for EPSV");
- }
- else {
- debugs(9, 2, "EPSV not supported by remote end");
- ftpState->state = SENT_EPSV_1; /* simulate having failed EPSV 1 (last EPSV to try before shifting to PASV) */
- }
- ftpSendPassive(ftpState);
- return;
- }
-
- if(code == 522) {
- /* server response with list of supported methods */
- /* 522 Network protocol not supported, use (1) */
- /* 522 Network protocol not supported, use (1,2) */
- debugs(9, 5, HERE << "scanning: " << ftpState->ctrl.last_reply);
-
- buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "(1,2)");
- if(buf == NULL || *buf == '\0') {
- /* handle broken server (RFC 2428 says MUST specify supported protocols in 522) */
- debugs(9, DBG_IMPORTANT, "Broken FTP Server at " << fd_table[ftpState->ctrl.fd].ipaddr << ". 522 error missing protocol negotiation hints");
- ftpSendPassive(ftpState);
- }
- else if(strcmp(buf, "(1)") == 0) {
- ftpState->state = SENT_EPSV_2; /* simulate having sent and failed EPSV 2 */
- ftpSendPassive(ftpState);
- }
- else if(strcmp(buf, "(2)") == 0) {
-#if USE_IPV6
- /* If server only supports EPSV 2 and we have already tried that. Go straight to EPRT */
- if(ftpState->state == SENT_EPSV_2) {
- ftpSendEPRT(ftpState);
- }
- else {
- /* or try the next Passive mode down the chain. */
- ftpSendPassive(ftpState);
- }
-#else
- /* We do not support IPv6. Remote server requires it.
- So we must simulate having failed all EPSV methods. */
- ftpState->state = SENT_EPSV_1;
- ftpSendPassive(ftpState);
-#endif
- }
- return;
- }
-
- /* 229 Entering Extended Passive Mode (|||port|) */
- /* ANSI sez [^0-9] is undefined, it breaks on Watcom cc */
- debugs(9, 5, "scanning: " << ftpState->ctrl.last_reply);
-
- buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "(");
+ struct sockaddr_in addr;
+ socklen_t addr_len;
- n = sscanf(buf, "(%c%c%c%hu%c)", &h1, &h2, &h3, &port, &h4);
-
- if (h1 != h2 || h1 != h3 || h1 != h4) {
- debugs(9, DBG_IMPORTANT, "Invalid EPSV reply from " <<
- fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
- ftpState->ctrl.last_reply);
-
- ftpSendPassive(ftpState);
- return;
- }
-
- if (0 == port) {
- debugs(9, DBG_IMPORTANT, "Unsafe EPSV reply from " <<
- fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
- ftpState->ctrl.last_reply);
-
- ftpSendPassive(ftpState);
- return;
- }
-
- if (Config.Ftp.sanitycheck) {
- if (port < 1024) {
- debugs(9, DBG_IMPORTANT, "Unsafe EPSV reply from " <<
- fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
- ftpState->ctrl.last_reply);
-
- ftpSendPassive(ftpState);
- return;
- }
- }
-
- ftpState->data.port = port;
-
- ftpState->data.host = xstrdup(fd_table[ftpState->ctrl.fd].ipaddr);
-
- safe_free(ftpState->ctrl.last_command);
-
- safe_free(ftpState->ctrl.last_reply);
-
- ftpState->ctrl.last_command = xstrdup("Connect to server data port");
-
- debugs(9, 3, HERE << "connecting to " << ftpState->data.host << ", port " << ftpState->data.port);
-
- commConnectStart(fd, ftpState->data.host, port, FtpStateData::ftpPasvCallback, ftpState);
-}
-
-/**
- * Send Passive connection request.
- * Default method is to use modern EPSV request.
- * The failover mechanism should check for previous state and re-call with alternates on failure.
- */
-static void
-ftpSendPassive(FtpStateData * ftpState)
-{
- IPAddress addr;
- struct addrinfo *AI = NULL;
-
- /** Checks the server control channel is still available before running. */
- if(!ftpState || !ftpState->haveControlChannel("ftpSendPassive"))
+ /* check the server control channel is still available */
+ if(!ftpState || !ftpState->haveControlChannel("ftpSendPasv"))
return;
- debugs(9, 3, HERE);
-
- /** \par
- * Checks for EPSV ALL special conditions:
- * If enabled to be sent, squid MUST NOT request any other connect methods.
- * If 'ALL' is sent and fails the entire FTP Session fails.
- * NP: By my reading exact EPSV protocols maybe attempted, but only EPSV method. */
- if(Config.Ftp.epsv_all && ftpState->flags.epsv_all_sent && ftpState->state == SENT_EPSV_1 ) {
- debugs(9, DBG_IMPORTANT, "FTP does not allow PASV method after 'EPSV ALL' has been sent.");
- ftpFail(ftpState);
- return;
- }
+ debugs(9, 3, HERE << "ftpSendPasv started");
- /** \par
- * Checks for 'HEAD' method request and passes off for special handling by FtpStateData::processHeadResponse(). */
if (ftpState->request->method == METHOD_HEAD && (ftpState->flags.isdir || ftpState->theSize != -1)) {
ftpState->processHeadResponse(); // may call serverComplete
return;
}
- /** \par
- * Closes any old FTP-Data connection which may exist. */
if (ftpState->data.fd >= 0) {
+ /* Close old connection */
comm_close(ftpState->data.fd);
ftpState->data.fd = -1;
}
- /** \par
- * Checks for previous EPSV/PASV failures on this server/session.
- * Diverts to EPRT immediately if they are not working. */
if (!ftpState->flags.pasv_supported) {
- ftpSendEPRT(ftpState);
+ ftpSendPort(ftpState);
return;
}
- /** \par
- * Locates the Address of the remote server. */
- addr.InitAddrInfo(AI);
+ addr_len = sizeof(addr);
- if (getsockname(ftpState->ctrl.fd, AI->ai_addr, &AI->ai_addrlen)) {
- /** If it cannot be located the FTP Session is killed. */
- addr.FreeAddrInfo(AI);
- debugs(9, DBG_CRITICAL, HERE << "getsockname(" << ftpState->ctrl.fd << ",'" << addr << "',...): " << xstrerror());
+ if (getsockname(ftpState->ctrl.fd, (struct sockaddr *) &addr, &addr_len)) {
+ debugs(9, 0, "ftpSendPasv: getsockname(" << ftpState->ctrl.fd << ",..): " << xstrerror());
ftpFail(ftpState);
return;
}
- addr = *AI;
-
- addr.FreeAddrInfo(AI);
-
- /** Otherwise, Open data channel with the same local address as control channel (on a new random port!) */
- addr.SetPort(0);
+ /* Open data channel with the same local address as control channel */
int fd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
- addr,
+ addr.sin_addr,
+ 0,
COMM_NONBLOCKING,
ftpState->entry->url());
- debugs(9, 3, HERE << "Unconnected data socket created on FD " << fd << " to " << addr);
+ debugs(9, 3, "ftpSendPasv: Unconnected data socket created on FD " << fd);
if (fd < 0) {
ftpFail(ftpState);
@@ -2462,52 +2289,12 @@
*/
ftpState->data.fd = fd;
- /** \par
- * Send EPSV (ALL,2,1) or PASV on the control channel.
- *
- \item EPSV ALL is used if enabled.
- \item EPSV 2 is used if ALL is disabled and IPv6 is available.
- \item EPSV 1 is used if EPSV 2 (IPv6) fails or is not available.
- \item PASV is used if EPSV 1 fails.
- */
- switch(ftpState->state) {
- case SENT_EPSV_1: /* EPSV options exhausted. Try PASV now. */
- snprintf(cbuf, 1024, "PASV\r\n");
- ftpState->state = SENT_PASV;
- break;
-
- case SENT_EPSV_2: /* EPSV IPv6 failed. Try EPSV IPv4 */
- snprintf(cbuf, 1024, "EPSV 1\r\n");
- ftpState->state = SENT_EPSV_1;
- break;
-
- case SENT_EPSV_ALL: /* EPSV ALL resulted in a bad response. Try ther EPSV methods. */
- ftpState->flags.epsv_all_sent = true;
- snprintf(cbuf, 1024, "EPSV 2\r\n");
- ftpState->state = SENT_EPSV_2;
- break;
-
- default:
- if(Config.Ftp.epsv_all) {
- snprintf(cbuf, 1024, "EPSV ALL\r\n");
- ftpState->state = SENT_EPSV_ALL;
- /* block other non-EPSV connections being attempted */
- ftpState->flags.epsv_all_sent = true;
- }
- else {
-#if USE_IPV6
- snprintf(cbuf, 1024, "EPSV 2\r\n");
- ftpState->state = SENT_EPSV_2;
-#else
- snprintf(cbuf, 1024, "EPSV 1\r\n");
- ftpState->state = SENT_EPSV_1;
-#endif
- }
- break;
- }
+ snprintf(cbuf, 1024, "PASV\r\n");
ftpState->writeCommand(cbuf);
+ ftpState->state = SENT_PASV;
+
/*
* ugly hack for ftp servers like ftp.netscape.com that sometimes
* dont acknowledge PASV commands.
@@ -2534,7 +2321,7 @@
#if ICAP_CLIENT
if (icapAccessCheckPending) {
- debugs(9,3, HERE << "returning due to icapAccessCheckPending");
+ debugs(9,3,HERE << "returning from ftpSendPasv due to icapAccessCheckPending");
return;
}
#endif
@@ -2551,66 +2338,63 @@
int p1, p2;
int n;
u_short port;
- IPAddress ipa_remote;
int fd = ftpState->data.fd;
char *buf;
LOCAL_ARRAY(char, ipaddr, 1024);
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadPasv");
if (code != 227) {
- debugs(9, 2, "PASV not supported by remote end");
- ftpSendEPRT(ftpState);
+ debugs(9, 3, "PASV not supported by remote end");
+ ftpSendPort(ftpState);
return;
}
/* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */
/* ANSI sez [^0-9] is undefined, it breaks on Watcom cc */
- debugs(9, 5, HERE << "scanning: " << ftpState->ctrl.last_reply);
+ debugs(9, 5, "scanning: " << ftpState->ctrl.last_reply);
buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "0123456789");
n = sscanf(buf, "%d,%d,%d,%d,%d,%d", &h1, &h2, &h3, &h4, &p1, &p2);
if (n != 6 || p1 < 0 || p2 < 0 || p1 > 255 || p2 > 255) {
- debugs(9, DBG_IMPORTANT, "Unsafe PASV reply from " <<
+ debugs(9, 1, "Unsafe PASV reply from " <<
fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
ftpState->ctrl.last_reply);
- ftpSendEPRT(ftpState);
+ ftpSendPort(ftpState);
return;
}
snprintf(ipaddr, 1024, "%d.%d.%d.%d", h1, h2, h3, h4);
- ipa_remote = ipaddr;
-
- if( ipa_remote.IsAnyAddr() ) {
- debugs(9, DBG_IMPORTANT, "Unsafe PASV reply from " <<
+ if (!safe_inet_addr(ipaddr, NULL)) {
+ debugs(9, 1, "Unsafe PASV reply from " <<
fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
ftpState->ctrl.last_reply);
- ftpSendEPRT(ftpState);
+ ftpSendPort(ftpState);
return;
}
port = ((p1 << 8) + p2);
if (0 == port) {
- debugs(9, DBG_IMPORTANT, "Unsafe PASV reply from " <<
+ debugs(9, 1, "Unsafe PASV reply from " <<
fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
ftpState->ctrl.last_reply);
- ftpSendEPRT(ftpState);
+ ftpSendPort(ftpState);
return;
}
if (Config.Ftp.sanitycheck) {
if (port < 1024) {
- debugs(9, DBG_IMPORTANT, "Unsafe PASV reply from " <<
+ debugs(9, 1, "Unsafe PASV reply from " <<
fd_table[ftpState->ctrl.fd].ipaddr << ": " <<
ftpState->ctrl.last_reply);
- ftpSendEPRT(ftpState);
+ ftpSendPort(ftpState);
return;
}
}
@@ -2628,7 +2412,7 @@
ftpState->ctrl.last_command = xstrdup("Connect to server data port");
- debugs(9, 3, HERE << "connecting to " << ftpState->data.host << ", port " << ftpState->data.port);
+ debugs(9, 5, "ftpReadPasv: connecting to " << ftpState->data.host << ", port " << ftpState->data.port);
commConnectStart(fd, ipaddr, port, FtpStateData::ftpPasvCallback, ftpState);
}
@@ -2637,10 +2421,10 @@
FtpStateData::ftpPasvCallback(int fd, comm_err_t status, int xerrno, void *data)
{
FtpStateData *ftpState = (FtpStateData *)data;
- debugs(9, 3, HERE);
+ debugs(9, 3, "ftpPasvCallback");
if (status != COMM_OK) {
- debugs(9, 2, HERE << "Failed to connect. Retrying without PASV.");
+ debugs(9, 2, "ftpPasvCallback: failed to connect. Retrying without PASV.");
ftpState->fwd->dontRetry(false); /* this is a retryable error */
ftpState->fwd->ftpPasvFailed(true);
ftpState->failed(ERR_NONE, 0);
@@ -2656,10 +2440,10 @@
{
int fd;
- IPAddress addr;
- struct addrinfo *AI = NULL;
+ struct sockaddr_in addr;
+ socklen_t addr_len;
int on = 1;
- int x = 0;
+ u_short port = 0;
/*
* Tear down any old data connection if any. We are about to
* establish a new one.
@@ -2674,17 +2458,10 @@
* Set up a listen socket on the same local address as the
* control connection.
*/
+ addr_len = sizeof(addr);
- addr.InitAddrInfo(AI);
-
- x = getsockname(ftpState->ctrl.fd, AI->ai_addr, &AI->ai_addrlen);
-
- addr = *AI;
-
- addr.FreeAddrInfo(AI);
-
- if(x) {
- debugs(9, DBG_CRITICAL, HERE << "getsockname(" << ftpState->ctrl.fd << ",..): " << xstrerror());
+ if (getsockname(ftpState->ctrl.fd, (struct sockaddr *) &addr, &addr_len)) {
+ debugs(9, 0, "ftpOpenListenSocket: getsockname(" << ftpState->ctrl.fd << ",..): " << xstrerror());
return -1;
}
@@ -2694,21 +2471,19 @@
*/
if (fallback) {
setsockopt(ftpState->ctrl.fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on));
- }
- else {
- /* if not running in fallback mode a new port needs to be retrieved */
- addr.SetPort(0);
+ port = ntohs(addr.sin_port);
}
fd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
- addr,
+ addr.sin_addr,
+ port,
COMM_NONBLOCKING | (fallback ? COMM_REUSEADDR : 0),
ftpState->entry->url());
- debugs(9, 3, HERE << "Unconnected data socket created on FD " << fd );
+ debugs(9, 3, "ftpOpenListenSocket: Unconnected data socket created on FD " << fd );
if (fd < 0) {
- debugs(9, DBG_CRITICAL, HERE << "comm_open failed");
+ debugs(9, 0, "ftpOpenListenSocket: comm_open failed");
return -1;
}
@@ -2724,12 +2499,12 @@
}
static void
-ftpSendPORT(FtpStateData * ftpState)
+ftpSendPort(FtpStateData * ftpState)
{
int fd;
- IPAddress ipa;
- struct addrinfo *AI = NULL;
+ struct sockaddr_in addr;
+ socklen_t addr_len;
unsigned char *addrptr;
unsigned char *portptr;
@@ -2737,52 +2512,33 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendPort"))
return;
- if(Config.Ftp.epsv_all && ftpState->flags.epsv_all_sent) {
- debugs(9, DBG_IMPORTANT, "FTP does not allow PORT method after 'EPSV ALL' has been sent.");
- return;
- }
-
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpSendPort");
ftpState->flags.pasv_supported = 0;
fd = ftpOpenListenSocket(ftpState, 0);
- ipa.InitAddrInfo(AI);
+ addr_len = sizeof(addr);
- if (getsockname(fd, AI->ai_addr, &AI->ai_addrlen)) {
- ipa.FreeAddrInfo(AI);
- debugs(9, DBG_CRITICAL, HERE << "getsockname(" << fd << ",..): " << xstrerror());
+ if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) {
+ debugs(9, 0, "ftpSendPort: getsockname(" << fd << ",..): " << xstrerror());
/* XXX Need to set error message */
ftpFail(ftpState);
return;
}
-#if USE_IPV6
- if( AI->ai_addrlen != sizeof(struct sockaddr_in) ) {
- ipa.FreeAddrInfo(AI);
- /* IPv6 CANNOT send PORT command. */
- /* we got here by attempting and failing an EPRT */
- /* using the same reply code should simulate a PORT failure */
- ftpReadPORT(ftpState);
- return;
- }
-#endif
-
- addrptr = (unsigned char *) &((struct sockaddr_in*)AI->ai_addr)->sin_addr;
- portptr = (unsigned char *) &((struct sockaddr_in*)AI->ai_addr)->sin_port;
+ addrptr = (unsigned char *) &addr.sin_addr.s_addr;
+ portptr = (unsigned char *) &addr.sin_port;
snprintf(cbuf, 1024, "PORT %d,%d,%d,%d,%d,%d\r\n",
addrptr[0], addrptr[1], addrptr[2], addrptr[3],
portptr[0], portptr[1]);
ftpState->writeCommand(cbuf);
ftpState->state = SENT_PORT;
-
- ipa.FreeAddrInfo(AI);
}
static void
-ftpReadPORT(FtpStateData * ftpState)
+ftpReadPort(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadPort");
if (code != 200) {
/* Fall back on using the same port as the control connection */
@@ -2793,84 +2549,13 @@
ftpRestOrList(ftpState);
}
-static void
-ftpSendEPRT(FtpStateData * ftpState)
-{
- int fd;
- IPAddress addr;
- struct addrinfo *AI = NULL;
- char buf[MAX_IPSTRLEN];
-
- if(Config.Ftp.epsv_all && ftpState->flags.epsv_all_sent) {
- debugs(9, DBG_IMPORTANT, "FTP does not allow EPRT method after 'EPSV ALL' has been sent.");
- return;
- }
-
- debugs(9, 3, HERE);
- ftpState->flags.pasv_supported = 0;
- fd = ftpOpenListenSocket(ftpState, 0);
-
- addr.InitAddrInfo(AI);
-
- if (getsockname(fd, AI->ai_addr, &AI->ai_addrlen)) {
- addr.FreeAddrInfo(AI);
- debugs(9, DBG_CRITICAL, HERE << "getsockname(" << fd << ",..): " << xstrerror());
-
- /* XXX Need to set error message */
- ftpFail(ftpState);
- return;
- }
-
- addr = *AI;
-
- /* RFC 2428 defines EPRT as IPv6 equivalent to IPv4 PORT command. */
- /* Which can be used by EITHER protocol. */
- snprintf(cbuf, 1024, "EPRT |%d|%s|%d|\r\n",
- ( addr.IsIPv6() ? 2 : 1 ),
- addr.NtoA(buf,MAX_IPSTRLEN),
- addr.GetPort() );
-
- ftpState->writeCommand(cbuf);
- ftpState->state = SENT_EPRT;
-
- addr.FreeAddrInfo(AI);
-}
-
-static void
-ftpReadEPRT(FtpStateData * ftpState)
-{
- int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
-
- if (code != 200) {
- /* Failover to attempting old PORT command. */
- debugs(9, 3, "EPRT not supported by remote end");
- ftpSendPORT(ftpState);
- return;
- }
-
- ftpRestOrList(ftpState);
-}
-
-/**
- \ingroup FTPCallback
- \par
- * "read" handler to accept FTP data connections.
- *
- \param fd Handle/FD for the listening connection which has received a connect request.
- \param details Some state data for the listening connection
- \param newfd Handle/FD to the connection which has just been opened.
- \param flag Error details for the listening connection.
- \param xerrno ??
- \param data ??
- */
+/* "read" handler to accept data connection */
static void
ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details,
comm_err_t flag, int xerrno, void *data)
{
- char ntoapeer[MAX_IPSTRLEN];
FtpStateData *ftpState = (FtpStateData *)data;
- debugs(9, 3, HERE);
+ debugs(9, 3, "ftpAcceptDataConnection");
if (flag == COMM_ERR_CLOSING)
return;
@@ -2880,17 +2565,13 @@
return;
}
- /** \par
- * When squid.conf ftp_sanitycheck is enabled, check the new connection is actually being
- * made by the remote client which is connected to the FTP control socket.
- * This prevents third-party hacks, but also third-party load balancing handshakes.
- */
if (Config.Ftp.sanitycheck) {
- details->peer.NtoA(ntoapeer,MAX_IPSTRLEN);
+ char *ipaddr = inet_ntoa(details->peer.sin_addr);
- if (strcmp(fd_table[ftpState->ctrl.fd].ipaddr, ntoapeer) != 0) {
- debugs(9, DBG_IMPORTANT, "FTP data connection from unexpected server (" <<
- details->peer << "), expecting " << fd_table[ftpState->ctrl.fd].ipaddr);
+ if (strcmp(fd_table[ftpState->ctrl.fd].ipaddr, ipaddr) != 0) {
+ debugs(9, 1, "FTP data connection from unexpected server (" <<
+ ipaddr << ":" << (int) ntohs(details->peer.sin_port) <<
+ "), expecting " << fd_table[ftpState->ctrl.fd].ipaddr);
comm_close(newfd);
comm_accept(ftpState->data.fd, ftpAcceptDataConnection, ftpState);
@@ -2899,34 +2580,29 @@
}
if (flag != COMM_OK) {
- debugs(9, DBG_IMPORTANT, HERE << "Comm Error for FD " << newfd << ": " << xstrerr(xerrno));
- /** \todo XXX Need to set error message */
+ debugs(9, 1, "ftpHandleDataAccept: comm_accept(" << newfd << "): " << xstrerr(xerrno));
+ /* XXX Need to set error message */
ftpFail(ftpState);
return;
}
- /**\par
- * Replace the Listen socket with the accepted data socket */
- debugs(9, 3, HERE << "Connected data socket on FD " << newfd);
-
- /* remember that details is state for fd, it will be erased by the following comm_close() */
- ftpState->data.port = details->peer.GetPort();
-
- details->peer.NtoA(ftpState->data.host,SQUIDHOSTNAMELEN);
-
+ /* Replace the Listen socket with the accepted data socket */
comm_close(ftpState->data.fd);
+ debugs(9, 3, "ftpAcceptDataConnection: Connected data socket on FD " << newfd);
+
ftpState->data.fd = newfd;
- debugs(9, 3, "FTP connection to " << details->peer << " FD table says: " <<
- " ctrl-peer= " << fd_table[ftpState->ctrl.fd].ipaddr << ", " <<
- " data-peer= " << fd_table[ftpState->data.fd].ipaddr );
+ ftpState->data.port = ntohs(details->peer.sin_port);
+
+ ftpState->data.host = xstrdup(inet_ntoa(details->peer.sin_addr));
commSetTimeout(ftpState->ctrl.fd, -1, NULL, NULL);
- commSetTimeout(ftpState->data.fd, Config.Timeout.read, FtpStateData::ftpTimeout, ftpState);
+ commSetTimeout(ftpState->data.fd, Config.Timeout.read, FtpStateData::ftpTimeout,
+ ftpState);
- /*\todo XXX We should have a flag to track connect state...
+ /* XXX We should have a flag to track connect state...
* host NULL -> not connected, port == local port
* host set -> connected, port == remote port
*/
@@ -2937,7 +2613,7 @@
static void
ftpRestOrList(FtpStateData * ftpState)
{
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpRestOrList");
if (ftpState->typecode == 'D') {
ftpState->flags.isdir = 1;
@@ -2948,6 +2624,7 @@
ftpSendNlst(ftpState); /* GET name;type=d sec 3.2.2 of RFC 1738 */
}
} else if (ftpState->flags.put) {
+ debugs(9, 3, "ftpRestOrList: Sending STOR request...");
ftpSendStor(ftpState);
} else if (ftpState->flags.isdir)
ftpSendList(ftpState);
@@ -2964,8 +2641,6 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendStor"))
return;
- debugs(9, 3, HERE);
-
if (ftpState->filepath != NULL) {
/* Plain file upload */
snprintf(cbuf, 1024, "STOR %s\r\n", ftpState->filepath);
@@ -2990,7 +2665,7 @@
void FtpStateData::readStor() {
int code = ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadStor");
if (code == 125 || (code == 150 && data.host)) {
if (!startRequestBodyFlow()) { // register to receive body data
@@ -2998,11 +2673,10 @@
return;
}
- /*\par
- * When client status is 125, or 150 without a hostname, Begin data transfer. */
- debugs(9, 3, HERE << "starting data transfer");
+ /* Begin data transfer */
+ debugs(9, 3, "ftpReadStor: starting data transfer");
sendMoreRequestBody();
- /** \par
+ /*
* Cancel the timeout on the Control socket and
* establish one on the data socket.
*/
@@ -3011,14 +2685,13 @@
this);
state = WRITING_DATA;
- debugs(9, 3, HERE << "writing data channel");
+ debugs(9, 3, "ftpReadStor: writing data channel");
} else if (code == 150) {
- /*\par
- * When client code is 150 with a hostname, Accept data channel. */
- debugs(9, 3, HERE << "accepting data channel");
+ /* Accept data channel */
+ debugs(9, 3, "ftpReadStor: accepting data channel");
comm_accept(data.fd, ftpAcceptDataConnection, this);
} else {
- debugs(9, DBG_IMPORTANT, HERE << "Unexpected reply code "<< std::setfill('0') << std::setw(3) << code);
+ debugs(9, 3, "ftpReadStor: Unexpected reply code "<< std::setfill('0') << std::setw(3) << code);
ftpFail(this);
}
}
@@ -3030,8 +2703,6 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendRest"))
return;
- debugs(9, 3, HERE);
-
snprintf(cbuf, 1024, "REST %"PRId64"\r\n", ftpState->restart_offset);
ftpState->writeCommand(cbuf);
ftpState->state = SENT_REST;
@@ -3068,14 +2739,14 @@
ftpReadRest(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadRest");
assert(ftpState->restart_offset > 0);
if (code == 350) {
ftpState->restarted_offset = ftpState->restart_offset;
ftpSendRetr(ftpState);
} else if (code > 0) {
- debugs(9, 3, HERE << "REST not supported");
+ debugs(9, 3, "ftpReadRest: REST not supported");
ftpState->flags.rest_supported = 0;
ftpSendRetr(ftpState);
} else {
@@ -3090,8 +2761,6 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendList"))
return;
- debugs(9, 3, HERE);
-
if (ftpState->filepath) {
snprintf(cbuf, 1024, "LIST %s\r\n", ftpState->filepath);
} else {
@@ -3109,8 +2778,6 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendNlst"))
return;
- debugs(9, 3, HERE);
-
ftpState->flags.tried_nlst = 1;
if (ftpState->filepath) {
@@ -3127,7 +2794,7 @@
ftpReadList(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadList");
if (code == 125 || (code == 150 && ftpState->data.host)) {
/* Begin data transfer */
@@ -3165,8 +2832,6 @@
if(!ftpState || !ftpState->haveControlChannel("ftpSendRetr"))
return;
- debugs(9, 3, HERE);
-
assert(ftpState->filepath != NULL);
snprintf(cbuf, 1024, "RETR %s\r\n", ftpState->filepath);
ftpState->writeCommand(cbuf);
@@ -3177,11 +2842,11 @@
ftpReadRetr(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadRetr");
if (code == 125 || (code == 150 && ftpState->data.host)) {
/* Begin data transfer */
- debugs(9, 3, HERE << "reading data channel");
+ debugs(9, 3, "ftpReadRetr: reading data channel");
/* XXX what about Config.Timeout.read? */
ftpState->maybeReadVirginBody();
ftpState->state = READING_DATA;
@@ -3216,7 +2881,7 @@
ftpReadTransferDone(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpReadTransferDone");
if (code == 226 || code == 250) {
/* Connection closed; retrieval done. */
@@ -3226,7 +2891,7 @@
ftpSendQuit(ftpState);
} else { /* != 226 */
- debugs(9, DBG_IMPORTANT, HERE << "Got code " << code << " after reading data");
+ debugs(9, 1, "ftpReadTransferDone: Got code " << code << " after reading data");
ftpState->failed(ERR_FTP_FAILURE, 0);
/* failed closes ctrl.fd and frees ftpState */
return;
@@ -3238,7 +2903,7 @@
FtpStateData::handleRequestBodyProducerAborted()
{
ServerStateData::handleRequestBodyProducerAborted();
- debugs(9, 3, HERE << "ftpState=" << this);
+ debugs(9, 3, HERE << "noteBodyProducerAborted: ftpState=" << this);
failed(ERR_READ_ERROR, 0);
}
@@ -3255,10 +2920,10 @@
ftpWriteTransferDone(FtpStateData * ftpState)
{
int code = ftpState->ctrl.replycode;
- debugs(9, 3, HERE);
+ debugs(9, 3, "This is ftpWriteTransferDone");
if (!(code == 226 || code == 250)) {
- debugs(9, DBG_IMPORTANT, HERE << "Got code " << code << " after sending data");
+ debugs(9, 1, "ftpReadTransferDone: Got code " << code << " after sending data");
ftpState->failed(ERR_FTP_PUT_ERROR, 0);
return;
}
@@ -3293,8 +2958,6 @@
ftpState->flags.try_slash_hack = 1;
/* Free old paths */
- debugs(9, 3, HERE);
-
if (ftpState->pathcomps)
wordlistDestroy(&ftpState->pathcomps);
@@ -3315,8 +2978,6 @@
void
FtpStateData::unhack()
{
- debugs(9, 3, HERE);
-
if (old_request != NULL) {
safe_free(old_request);
safe_free(old_reply);
@@ -3331,8 +2992,6 @@
restart_offset = 0;
/* Save old error message & some state info */
- debugs(9, 3, HERE);
-
if (old_request == NULL) {
old_request = ctrl.last_command;
ctrl.last_command = NULL;
@@ -3350,9 +3009,9 @@
static void
ftpFail(FtpStateData *ftpState)
{
- debugs(9, 3, HERE);
-
+ debugs(9, 3, "ftpFail");
/* Try the / hack to support "Netscape" FTP URL's for retreiving files */
+
if (!ftpState->flags.isdir && /* Not a directory */
!ftpState->flags.try_slash_hack && /* Not in slash hack */
ftpState->mdtm <= 0 && ftpState->theSize < 0 && /* Not known as a file */
@@ -3476,10 +3135,10 @@
http_status http_code;
err_type err_code = ERR_NONE;
- debugs(9, 3, HERE << ftpState->entry->url() << ", code " << code);
+ debugs(9, 5, "ftpSendReply: " << ftpState->entry->url() << ", code " << code );
if (cbdataReferenceValid(ftpState))
- debugs(9, 5, HERE << "ftpState (" << ftpState << ") is valid!");
+ debugs(9, 5, "ftpSendReply: ftpState (" << ftpState << ") is valid!");
if (code == 226 || code == 250) {
err_code = (ftpState->mdtm > 0) ? ERR_FTP_PUT_MODIFIED : ERR_FTP_PUT_CREATED;
@@ -3521,7 +3180,7 @@
const char *t = NULL;
StoreEntry *e = entry;
- debugs(9, 3, HERE);
+ debugs(9, 3, HERE << "FtpStateData::appendSuccessHeader starting");
if (flags.http_header_sent)
return;
@@ -3573,7 +3232,7 @@
* not be seeing this condition any more because we'll only
* send REST if we know the theSize and if it is less than theSize.
*/
- debugs(0,DBG_CRITICAL,HERE << "Whoops! " <<
+ debugs(0,0,HERE << "Whoops! " <<
" restarted_offset=" << restarted_offset <<
", but theSize=" << theSize <<
". assuming full content response");
@@ -3627,35 +3286,44 @@
return newrep;
}
-/**
- * Construct an URI with leading / in PATH portion for use by CWD command
- * possibly others. FTP encodes absolute paths as beginning with '/'
- * after the initial URI path delimiter, which happens to be / itself.
- * This makes FTP absolute URI appear as: ftp:host:port//root/path
- * To encompass older software which compacts multiple // to / in transit
- * We use standard URI-encoding on the second / making it
- * ftp:host:port/%2froot/path AKA 'the FTP %2f hack'.
- */
-const char *
-ftpUrlWith2f(HttpRequest * request)
+char *
+ftpUrlWith2f(const HttpRequest * request)
{
- String newbuf = "%2f";
+ LOCAL_ARRAY(char, buf, MAX_URL);
+ LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1);
+ LOCAL_ARRAY(char, portbuf, 32);
+ char *t;
+ portbuf[0] = '\0';
if (request->protocol != PROTO_FTP)
return NULL;
- if( !strncmp(request->urlpath.buf(), "/", 1) ) {
- newbuf.append(request->urlpath);
- request->urlpath.absorb(newbuf);
- safe_free(request->canonical);
- }
- else if( !strncmp(request->urlpath.buf(), "%2f", 3) ) {
- newbuf.append(request->urlpath.buf() +1);
- request->urlpath.absorb(newbuf);
- safe_free(request->canonical);
+ if (request->port != urlDefaultPort(request->protocol))
+ snprintf(portbuf, 32, ":%d", request->port);
+
+ loginbuf[0] = '\0';
+
+ if ((int) strlen(request->login) > 0) {
+ xstrncpy(loginbuf, request->login, sizeof(loginbuf) - 2);
+
+ if ((t = strchr(loginbuf, ':')))
+ *t = '\0';
+
+ strcat(loginbuf, "@");
}
- return urlCanonical(request);
+ snprintf(buf, MAX_URL, "%s://%s%s%s%s%s",
+ ProtocolStr[request->protocol],
+ loginbuf,
+ request->host,
+ portbuf,
+ "/%2f",
+ request->urlpath.buf());
+
+ if ((t = strchr(buf, '?')))
+ *t = '\0';
+
+ return buf;
}
void
@@ -3676,7 +3344,7 @@
void
FtpStateData::writeReplyBody(const char *data, size_t len)
{
- debugs(9, 5, HERE << "writing " << len << " bytes to the reply");
+ debugs(9,5,HERE << "writing " << len << " bytes to the reply");
addVirginReplyBody(data, len);
}
@@ -3684,7 +3352,7 @@
void
FtpStateData::doneSendingRequestBody()
{
- debugs(9,3, HERE);
+ debugs(9,3,HERE << "doneSendingRequestBody");
ftpWriteTransferDone(this);
}
@@ -3695,7 +3363,7 @@
FtpStateData::completeForwarding()
{
if (fwd == NULL || flags.completed_forwarding) {
- debugs(9, 3, HERE << "completeForwarding avoids " <<
+ debugs(9,2,HERE << "completeForwarding avoids " <<
"double-complete on FD " << ctrl.fd << ", Data FD " << data.fd <<
", this " << this << ", fwd " << fwd);
return;
@@ -3709,7 +3377,7 @@
void
FtpStateData::closeServer()
{
- debugs(9,3, HERE << "closing FTP server FD " << ctrl.fd << ", Data FD " << data.fd << ", this " << this);
+ debugs(9,5, HERE << "closing FTP server FD " << ctrl.fd << ", Data FD " << data.fd << ", this " << this);
if (ctrl.fd > -1) {
fwd->unregister(ctrl.fd);
@@ -3739,7 +3407,7 @@
/* doneWithServer() only checks BOTH channels are closed. */
if(ctrl.fd < 0) {
- debugs(9, DBG_IMPORTANT, "WARNING! FTP Server Control channel is closed, but Data channel still active.");
+ debugs(9, 1, "WARNING! FTP Server Control channel is closed, but Data channel still active.");
debugs(9, 2, caller_name << ": attempted on a closed FTP channel.");
return false;
}
@@ -3753,7 +3421,7 @@
void
FtpStateData::abortTransaction(const char *reason)
{
- debugs(9, 3, HERE << "aborting transaction for " << reason <<
+ debugs(9,5,HERE << "aborting transaction for " << reason <<
"; FD " << ctrl.fd << ", Data FD " << data.fd << ", this " << this);
if (ctrl.fd >= 0) {
comm_close(ctrl.fd);
Index: squid3/src/globals.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/globals.h,v
retrieving revision 1.32.6.2
retrieving revision 1.32.6.3
diff -u -r1.32.6.2 -r1.32.6.3
--- squid3/src/globals.h 25 Jan 2008 02:33:47 -0000 1.32.6.2
+++ squid3/src/globals.h 27 Jan 2008 18:08:52 -0000 1.32.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: globals.h,v 1.32.6.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: globals.h,v 1.32.6.3 2008/01/27 18:08:52 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -55,6 +55,7 @@
extern const char *cfg_filename; /* NULL */
extern const char *const appname; /* "squid" */
extern const char *const dash_str; /* "-" */
+ extern const char *const localhost; /* "127.0.0.1" */
extern const char *const null_string; /* "" */
extern const char *const version_string; /* VERSION */
extern const char *const full_appname_string; /* PACKAGE "/" VERSION */
@@ -111,9 +112,17 @@
extern struct _acl_deny_info_list *DenyInfoList; /* NULL */
- extern IPAddress theOutICPAddr;
+ extern struct IN_ADDR any_addr;
- extern IPAddress theOutSNMPAddr;
+ extern struct IN_ADDR local_addr;
+
+ extern struct IN_ADDR no_addr;
+
+ extern struct IN_ADDR theOutICPAddr;
+
+ extern struct IN_ADDR theOutSNMPAddr;
+
+ extern struct timeval current_time;
extern struct timeval squid_start;
extern int shutting_down; /* 0 */
@@ -126,6 +135,7 @@
extern char *swap_log_op_str[];
extern char *lookup_t_str[];
extern double request_failure_ratio; /* 0.0 */
+ extern double current_dtime;
extern int store_hash_buckets; /* 0 */
extern hash_table *store_table; /* NULL */
extern dlink_list ClientActiveRequests;
@@ -169,6 +179,7 @@
extern int ssl_ex_index_server; /* -1 */
extern int ssl_ctx_ex_index_dont_verify_domain; /* -1 */
+ extern int ssl_ex_index_cert_error_check; /* -1 */
extern const char *external_acl_message; /* NULL */
extern int opt_send_signal; /* -1 */
Index: squid3/src/helper.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/helper.cc,v
retrieving revision 1.39.6.2
retrieving revision 1.39.6.3
diff -u -r1.39.6.2 -r1.39.6.3
--- squid3/src/helper.cc 25 Jan 2008 02:33:47 -0000 1.39.6.2
+++ squid3/src/helper.cc 27 Jan 2008 18:08:52 -0000 1.39.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: helper.cc,v 1.39.6.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: helper.cc,v 1.39.6.3 2008/01/27 18:08:52 rousskov Exp $
*
* DEBUG: section 84 Helper process maintenance
* AUTHOR: Harvest Derived?
@@ -120,7 +120,6 @@
progname,
args,
shortname,
- hlp->addr,
&rfd,
&wfd,
&hIpc);
@@ -137,7 +136,6 @@
srv->hIpc = hIpc;
srv->pid = pid;
srv->index = k;
- srv->addr = hlp->addr;
srv->rfd = rfd;
srv->wfd = wfd;
srv->rbuf = (char *)memAllocBuf(8192, &srv->rbuf_sz);
@@ -221,7 +219,6 @@
progname,
args,
shortname,
- hlp->addr,
&rfd,
&wfd,
&hIpc);
@@ -244,7 +241,6 @@
srv->stats.submits = 0;
srv->stats.releases = 0;
srv->index = k;
- srv->addr = hlp->addr;
srv->rfd = rfd;
srv->wfd = wfd;
srv->rbuf = (char *)memAllocBuf(8192, &srv->rbuf_sz);
Index: squid3/src/helper.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/helper.h,v
retrieving revision 1.8.22.1
retrieving revision 1.8.22.2
diff -u -r1.8.22.1 -r1.8.22.2
--- squid3/src/helper.h 25 Jan 2008 02:33:47 -0000 1.8.22.1
+++ squid3/src/helper.h 27 Jan 2008 18:08:52 -0000 1.8.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: helper.h,v 1.8.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: helper.h,v 1.8.22.2 2008/01/27 18:08:52 rousskov Exp $
*
* DEBUG: section 84 Helper process maintenance
* AUTHOR: Harvest Derived?
@@ -38,7 +38,6 @@
#include "squid.h"
#include "cbdata.h"
-#include "IPAddress.h"
class helper_request;
@@ -66,7 +65,6 @@
int n_running;
int n_active;
int ipc_type;
- IPAddress addr;
unsigned int concurrency;
time_t last_queue_warn;
time_t last_restart;
@@ -92,7 +90,6 @@
int n_running;
int n_active;
int ipc_type;
- IPAddress addr;
MemAllocator *datapool;
HLPSAVAIL *IsAvailable;
HLPSONEQ *OnEmptyQueue;
@@ -114,14 +111,13 @@
{
int index;
int pid;
- IPAddress addr;
int rfd;
int wfd;
MemBuf *wqueue;
MemBuf *writebuf;
char *rbuf;
size_t rbuf_sz;
- size_t roffset;
+ off_t roffset;
struct timeval dispatch_time;
@@ -153,7 +149,6 @@
}
stats;
-
void *hIpc;
};
@@ -163,14 +158,13 @@
{
int index;
int pid;
- IPAddress addr;
int rfd;
int wfd;
/* MemBuf wqueue; */
/* MemBuf writebuf; */
char *rbuf;
size_t rbuf_sz;
- size_t roffset;
+ off_t roffset;
struct timeval dispatch_time;
Index: squid3/src/htcp.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/htcp.cc,v
retrieving revision 1.33.22.2
retrieving revision 1.33.22.3
diff -u -r1.33.22.2 -r1.33.22.3
--- squid3/src/htcp.cc 25 Jan 2008 02:33:47 -0000 1.33.22.2
+++ squid3/src/htcp.cc 27 Jan 2008 18:08:52 -0000 1.33.22.3
@@ -1,6 +1,6 @@
/*
- * $Id: htcp.cc,v 1.33.22.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: htcp.cc,v 1.33.22.3 2008/01/27 18:08:52 rousskov Exp $
*
* DEBUG: section 31 Hypertext Caching Protocol
* AUTHOR: Duane Wesssels
@@ -182,7 +182,7 @@
void checkHit();
void checkedHit(StoreEntry *e);
- void setFrom (IPAddress &from);
+ void setFrom (struct sockaddr_in *from);
void setDataHeader (htcpDataHeader *);
char *method;
char *uri;
@@ -193,7 +193,7 @@
private:
HttpRequest *checkHitRequest;
- IPAddress from; // was a ptr. return to such IFF needed. otherwise copy should do.
+ struct sockaddr_in *from;
htcpDataHeader *dhdr;
};
@@ -263,7 +263,7 @@
static u_int32_t queried_id[N_QUERIED_KEYS];
static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH];
-static IPAddress queried_addr[N_QUERIED_KEYS];
+static struct sockaddr_in queried_addr[N_QUERIED_KEYS];
static MemAllocator *htcpDetailPool = NULL;
static int old_squid_format = 0;
@@ -282,26 +282,26 @@
static void htcpFreeSpecifier(htcpSpecifier * s);
static void htcpFreeDetail(htcpDetail * s);
-static void htcpHandle(char *buf, int sz, IPAddress &from);
+static void htcpHandle(char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleData(char *buf, int sz, IPAddress &from);
+static void htcpHandleData(char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, IPAddress &from);
+static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, IPAddress &from);
+static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, IPAddress &from);
+static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, IPAddress &from);
+static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
static void htcpRecv(int fd, void *data);
-static void htcpSend(const char *buf, int len, IPAddress &to);
+static void htcpSend(const char *buf, int len, struct sockaddr_in *to);
-static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, IPAddress &);
+static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, struct sockaddr_in *);
-static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, IPAddress &from);
+static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
-static void htcpHandleTstResponse(htcpDataHeader *, char *, int, IPAddress &);
+static void htcpHandleTstResponse(htcpDataHeader *, char *, int, struct sockaddr_in *);
static void
htcpHexdump(const char *tag, const char *s, int sz)
@@ -604,15 +604,15 @@
static void
-htcpSend(const char *buf, int len, IPAddress &to)
+htcpSend(const char *buf, int len, struct sockaddr_in *to)
{
int x;
-
- debugs(31, 3, "htcpSend: " << to );
+ debugs(31, 3, "htcpSend: " << inet_ntoa(to->sin_addr) << "/" << ntohs(to->sin_port));
htcpHexdump("htcpSend", buf, len);
-
x = comm_udp_sendto(htcpOutSocket,
to,
+
+ sizeof(struct sockaddr_in),
buf,
len);
@@ -628,7 +628,7 @@
void
-htcpSpecifier::setFrom (IPAddress &aSocket)
+htcpSpecifier::setFrom (struct sockaddr_in *aSocket)
{
from = aSocket;
}
@@ -661,7 +661,7 @@
htcpUnpackSpecifier(char *buf, int sz)
{
htcpSpecifier *s = new htcpSpecifier;
- HttpRequestMethod method;
+ method_t method;
/* Find length of METHOD */
u_int16_t l = ntohs(*(u_int16_t *) buf);
@@ -764,7 +764,7 @@
*/
method = HttpRequestMethod(s->method);
- s->request = HttpRequest::CreateFromUrlAndMethod(s->uri, method == METHOD_NONE ? HttpRequestMethod(METHOD_GET) : method);
+ s->request = HttpRequest::CreateFromUrlAndMethod(s->uri, method == METHOD_NONE ? METHOD_GET : method);
if (s->request)
HTTPMSGLOCK(s->request);
@@ -859,11 +859,11 @@
static int
-htcpAccessCheck(acl_access * acl, htcpSpecifier * s, IPAddress &from)
+htcpAccessCheck(acl_access * acl, htcpSpecifier * s, struct sockaddr_in *from)
{
ACLChecklist checklist;
- checklist.src_addr = from;
- checklist.my_addr.SetNoAddr();
+ checklist.src_addr = from->sin_addr;
+ checklist.my_addr = no_addr;
checklist.request = HTTPMSGLOCK(s->request);
checklist.accessList = cbdataReference(acl);
/* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */
@@ -873,7 +873,7 @@
static void
-htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, IPAddress &from)
+htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct sockaddr_in *from)
{
htcpStuff stuff;
static char pkt[8192];
@@ -962,7 +962,7 @@
static void
-htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, IPAddress &from)
+htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, struct sockaddr_in *from)
{
htcpStuff stuff;
static char pkt[8192];
@@ -1000,7 +1000,7 @@
static void
-htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from)
+htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
{
debugs(31, 3, "htcpHandleNop: Unimplemented");
}
@@ -1038,18 +1038,23 @@
if (e->isNull()) {
debugs(31, 3, "htcpCheckHit: NO; public object not found");
+ goto miss;
}
- else if (!e->validToSend()) {
+
+ if (!e->validToSend()) {
debugs(31, 3, "htcpCheckHit: NO; entry not valid to send" );
+ goto miss;
}
- else if (refreshCheckHTCP(e, checkHitRequest)) {
+
+ if (refreshCheckHTCP(e, checkHitRequest)) {
debugs(31, 3, "htcpCheckHit: NO; cached response is stale");
+ goto miss;
}
- else {
- debugs(31, 3, "htcpCheckHit: YES!?");
- hit = e;
- }
+ debugs(31, 3, "htcpCheckHit: YES!?");
+ hit = e;
+
+miss:
checkedHit (hit);
}
@@ -1100,7 +1105,7 @@
static void
-htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from)
+htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
{
debugs(31, 3, "htcpHandleTst: sz = " << sz);
@@ -1115,21 +1120,22 @@
static void
-htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from)
+htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
{
htcpReplyData htcpReply;
cache_key *key = NULL;
- IPAddress *peer;
+ struct sockaddr_in *peer;
htcpDetail *d = NULL;
char *t;
+
if (queried_id[hdr->msg_id % N_QUERIED_KEYS] != hdr->msg_id)
{
debugs(31, 2, "htcpHandleTstResponse: No matching query id '" <<
hdr->msg_id << "' (expected " <<
queried_id[hdr->msg_id % N_QUERIED_KEYS] << ") from '" <<
- from << "'");
+ inet_ntoa(from->sin_addr) << "'");
return;
}
@@ -1138,15 +1144,15 @@
if (!key)
{
- debugs(31, 1, "htcpHandleTstResponse: No query key for response id '" << hdr->msg_id << "' from '" << from << "'");
+ debugs(31, 1, "htcpHandleTstResponse: No query key for response id '" << hdr->msg_id << "' from '" << inet_ntoa(from->sin_addr) << "'");
return;
}
peer = &queried_addr[hdr->msg_id % N_QUERIED_KEYS];
- if ( *peer != from || peer->GetPort() != from.GetPort() )
+ if (peer->sin_addr.s_addr != from->sin_addr.s_addr || peer->sin_port != from->sin_port)
{
- debugs(31, 1, "htcpHandleTstResponse: Unexpected response source " << from );
+ debugs(31, 1, "htcpHandleTstResponse: Unexpected response source " << inet_ntoa(from->sin_addr));
return;
}
@@ -1193,7 +1199,7 @@
static void
-htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, IPAddress &from)
+htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_in *from)
{
/* buf should be a SPECIFIER */
htcpSpecifier *s;
@@ -1252,21 +1258,21 @@
static void
-htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from)
+htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
{
debugs(31, 3, "htcpHandleMon: Unimplemented");
}
static void
-htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from)
+htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
{
debugs(31, 3, "htcpHandleSet: Unimplemented");
}
static void
-htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from)
+htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
{
htcpSpecifier *s;
/* buf[0/1] is reserved and reason */
@@ -1325,7 +1331,7 @@
static void
-htcpHandleData(char *buf, int sz, IPAddress &from)
+htcpHandleData(char *buf, int sz, struct sockaddr_in *from)
{
htcpDataHeader hdr;
@@ -1358,7 +1364,7 @@
if (hdr.opcode >= HTCP_END)
{
- debugs(31, 1, "htcpHandleData: client " << from << ", opcode " << hdr.opcode << " out of range");
+ debugs(31, 1, "htcpHandleData: client " << inet_ntoa(from->sin_addr) << ", opcode " << hdr.opcode << " out of range");
return;
}
@@ -1418,7 +1424,7 @@
static void
-htcpHandle(char *buf, int sz, IPAddress &from)
+htcpHandle(char *buf, int sz, struct sockaddr_in *from)
{
htcpHeader htcpHdr;
assert (sz >= 0);
@@ -1445,14 +1451,17 @@
if (sz != htcpHdr.length)
{
debugs(31, 1, "htcpHandle: sz/" << sz << " != htcpHdr.length/" <<
- htcpHdr.length << " from " << from );
+ htcpHdr.length << " from " << inet_ntoa(from->sin_addr) << ":" <<
+ (int) ntohs(from->sin_port));
return;
}
if (htcpHdr.major != 0)
{
- debugs(31, 1, "htcpHandle: Unknown major version " << htcpHdr.major << " from " << from );
+ debugs(31, 1, "htcpHandle: Unknown major version " << htcpHdr.major <<
+ " from " << inet_ntoa(from->sin_addr) << ":" <<
+ (int) ntohs(from->sin_port));
return;
}
@@ -1467,18 +1476,22 @@
{
static char buf[8192];
int len;
- static IPAddress from;
- /* Receive up to 8191 bytes, leaving room for a null */
+ static struct sockaddr_in from;
+
+ socklen_t flen = sizeof(struct sockaddr_in);
+ memset(&from, '\0', flen);
- len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, from);
+ /* Receive up to 8191 bytes, leaving room for a null */
- debugs(31, 3, "htcpRecv: FD " << fd << ", " << len << " bytes from " << from );
+ len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &from, &flen);
+ debugs(31, 3, "htcpRecv: FD " << fd << ", " << len << " bytes from " <<
+ inet_ntoa(from.sin_addr) << ":" << ntohs(from.sin_port));
if (len)
statCounter.htcp.pkts_recv++;
- htcpHandle(buf, len, from);
+ htcpHandle(buf, len, &from);
commSetSelect(fd, COMM_SELECT_READ, htcpRecv, NULL, 0);
}
@@ -1492,19 +1505,16 @@
void
htcpInit(void)
{
- IPAddress sendOn;
-
if (Config.Port.htcp <= 0) {
debugs(31, 1, "HTCP Disabled.");
return;
}
- sendOn = Config.Addrs.udp_outgoing;
- sendOn.SetPort(Config.Port.htcp);
enter_suid();
htcpInSocket = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
- sendOn,
+ Config.Addrs.udp_incoming,
+ Config.Port.htcp,
COMM_NONBLOCKING,
"HTCP Socket");
leave_suid();
@@ -1516,11 +1526,12 @@
debugs(31, 1, "Accepting HTCP messages on port " << Config.Port.htcp << ", FD " << htcpInSocket << ".");
- if (!Config.Addrs.udp_outgoing.IsNoAddr()) {
+ if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr) {
enter_suid();
htcpOutSocket = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
- sendOn,
+ Config.Addrs.udp_outgoing,
+ Config.Port.htcp,
COMM_NONBLOCKING,
"Outgoing HTCP Socket");
leave_suid();
@@ -1575,7 +1586,7 @@
stuff.msg_id = ++msg_id_counter;
- stuff.S.method = (char *) RequestMethodStr(req->method);
+ stuff.S.method = (char *) RequestMethodStr[req->method];
stuff.S.uri = (char *) e->url();
@@ -1604,8 +1615,7 @@
return;
}
- htcpSend(pkt, (int) pktlen, p->in_addr);
-
+ htcpSend(pkt, (int) pktlen, &p->in_addr);
queried_id[stuff.msg_id % N_QUERIED_KEYS] = stuff.msg_id;
save_key = queried_keys[stuff.msg_id % N_QUERIED_KEYS];
storeKeyCopy(save_key, (const cache_key *)e->key);
Index: squid3/src/htcp.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/htcp.h,v
retrieving revision 1.4.48.1
retrieving revision 1.4.48.2
diff -u -r1.4.48.1 -r1.4.48.2
--- squid3/src/htcp.h 25 Jan 2008 02:33:47 -0000 1.4.48.1
+++ squid3/src/htcp.h 27 Jan 2008 18:08:52 -0000 1.4.48.2
@@ -1,6 +1,6 @@
/*
- * $Id: htcp.h,v 1.4.48.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: htcp.h,v 1.4.48.2 2008/01/27 18:08:52 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -36,7 +36,6 @@
#if USE_HTCP
#include "HttpHeader.h"
-#include "IPAddress.h"
class HtcpReplyData
{
@@ -61,7 +60,7 @@
typedef class HtcpReplyData htcpReplyData;
-SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const IPAddress &);
+SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const struct sockaddr_in *);
SQUIDCEXTERN void htcpInit(void);
SQUIDCEXTERN void htcpQuery(StoreEntry * e, HttpRequest * req, peer * p);
SQUIDCEXTERN void htcpSocketShutdown(void);
Index: squid3/src/http.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v
retrieving revision 1.122.6.2
retrieving revision 1.122.6.3
diff -u -r1.122.6.2 -r1.122.6.3
--- squid3/src/http.cc 25 Jan 2008 02:33:47 -0000 1.122.6.2
+++ squid3/src/http.cc 27 Jan 2008 18:08:52 -0000 1.122.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: http.cc,v 1.122.6.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: http.cc,v 1.122.6.3 2008/01/27 18:08:52 rousskov Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
@@ -56,16 +56,6 @@
#include "DelayPools.h"
#endif
#include "SquidTime.h"
-#include "TextException.h"
-
-#define SQUID_ENTER_THROWING_CODE() try {
-#define SQUID_EXIT_THROWING_CODE(status) \
- status = true; \
- } \
- catch (const TextException &e) { \
- debugs (11, 1, "Exception error:" << e.message); \
- status = false; \
- }
CBDATA_CLASS_INIT(HttpStateData);
@@ -78,7 +68,7 @@
HttpHeader * hdr_out, int we_do_ranges, http_state_flags);
HttpStateData::HttpStateData(FwdState *theFwdState) : ServerStateData(theFwdState),
- header_bytes_read(0), reply_bytes_read(0), httpChunkDecoder(NULL)
+ header_bytes_read(0), reply_bytes_read(0)
{
debugs(11,5,HERE << "HttpStateData " << this << " created");
ignoreCacheControl = false;
@@ -102,7 +92,7 @@
HttpRequest * proxy_req = new HttpRequest(orig_request->method,
orig_request->protocol, url);
- proxy_req->SetHost(_peer->host);
+ xstrncpy(proxy_req->host, _peer->host, SQUIDHOSTNAMELEN);
proxy_req->port = _peer->http_port;
@@ -129,6 +119,7 @@
entry->setNoDelay(_peer->options.no_delay);
#endif
+
}
/*
@@ -148,9 +139,6 @@
delete readBuf;
- if(httpChunkDecoder)
- delete httpChunkDecoder;
-
HTTPMSGUNLOCK(orig_request);
debugs(11,5, HERE << "HttpStateData " << this << " destroyed; FD " << fd);
@@ -171,11 +159,10 @@
}
int
-httpCachable(const HttpRequestMethod& method)
+httpCachable(method_t method)
{
/* GET and HEAD are cachable. Others are not. */
- // TODO: replase to HttpRequestMethod::isCachable() ?
if (method != METHOD_GET && method != METHOD_HEAD)
return 0;
@@ -685,7 +672,7 @@
int skew = abs((int)(reply->date - squid_curtime));
if (skew > 86400)
- debugs(11, 3, "" << request->GetHost() << "'s clock is skewed by " << skew << " seconds!");
+ debugs(11, 3, "" << request->host << "'s clock is skewed by " << skew << " seconds!");
}
}
@@ -748,12 +735,6 @@
readBuf->consume(header_bytes_read);
}
- flags.chunked = 0;
- if (newrep->header.hasListMember(HDR_TRANSFER_ENCODING, "chunked", ',')) {
- flags.chunked = 1;
- httpChunkDecoder = new ChunkedCodingParser;
- }
-
HttpReply *vrep = setVirginReply(newrep);
flags.headers_parsed = 1;
@@ -880,7 +861,7 @@
* connection.
*/
if (!flags.request_sent) {
- debugs(11, 1, "statusIfComplete: Request not yet fully sent \"" << RequestMethodStr(orig_request->method) << " " << entry->url() << "\"" );
+ debugs(11, 1, "statusIfComplete: Request not yet fully sent \"" << RequestMethodStr[orig_request->method] << " " << entry->url() << "\"" );
return COMPLETE_NONPERSISTENT_MSG;
}
@@ -915,13 +896,6 @@
if (!flags.headers_parsed)
return INCOMPLETE_MSG;
- /* In chunked responce we do not know the content length but we are absolutelly
- * sure about the end of response, so we are calling the statusIfComplete to
- * decide if we can be persistant
- */
- if (eof && flags.chunked)
- return statusIfComplete();
-
if (eof) // already reached EOF
return COMPLETE_NONPERSISTENT_MSG;
@@ -1124,31 +1098,10 @@
{
const char *data = readBuf->content();
int len = readBuf->contentSize();
+
addVirginReplyBody(data, len);
readBuf->consume(len);
-}
-bool
-HttpStateData::decodeAndWriteReplyBody()
-{
- const char *data = NULL;
- int len;
- bool status = false;
- assert(flags.chunked);
- assert(httpChunkDecoder);
- SQUID_ENTER_THROWING_CODE();
- MemBuf decodedData;
- decodedData.init();
- const bool done = httpChunkDecoder->parse(readBuf,&decodedData);
- len = decodedData.contentSize();
- data=decodedData.content();
- addVirginReplyBody(data, len);
- if (done) {
- eof = 1;
- flags.do_next_read = 0;
- }
- SQUID_EXIT_THROWING_CODE(status);
- return status;
}
/*
@@ -1162,7 +1115,7 @@
HttpStateData::processReplyBody()
{
- IPAddress client_addr;
+ struct IN_ADDR *client_addr = NULL;
if (!flags.headers_parsed) {
flags.do_next_read = 1;
@@ -1181,15 +1134,7 @@
* That means header content has been removed from readBuf and
* it contains only body data.
*/
- if(flags.chunked){
- if(!decodeAndWriteReplyBody()){
- flags.do_next_read = 0;
- serverComplete();
- return;
- }
- }
- else
- writeReplyBody();
+ writeReplyBody();
if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
/*
@@ -1225,17 +1170,17 @@
#if LINUX_TPROXY
if (orig_request->flags.tproxy)
- client_addr = orig_request->client_addr;
+ client_addr = &orig_request->client_addr;
#endif
if (_peer) {
if (_peer->options.originserver)
- fwd->pconnPush(fd, _peer->name, orig_request->port, orig_request->GetHost(), client_addr);
+ fwd->pconnPush(fd, _peer->name, orig_request->port, orig_request->host, client_addr);
else
fwd->pconnPush(fd, _peer->name, _peer->http_port, NULL, client_addr);
} else {
- fwd->pconnPush(fd, request->GetHost(), request->port, NULL, client_addr);
+ fwd->pconnPush(fd, request->host, request->port, NULL, client_addr);
}
fd = -1;
@@ -1268,16 +1213,12 @@
* handler until we get a notification from someone that
* its okay to read again.
*/
- if (read_sz < 2) {
- if (flags.headers_parsed)
- return;
- else
- read_sz = 1024;
- }
+ if (read_sz < 2)
+ return;
if (flags.do_next_read) {
- flags.do_next_read = 0;
- entry->delayAwareRead(fd, readBuf->space(read_sz), read_sz, ReadReplyWrapper, this);
+ flags.do_next_read = 0;
+ entry->delayAwareRead(fd, readBuf->space(), read_sz, ReadReplyWrapper, this);
}
}
@@ -1415,10 +1356,8 @@
/* append X-Forwarded-For */
strFwd = hdr_in->getList(HDR_X_FORWARDED_FOR);
- if (opt_forwarded_for && !orig_request->client_addr.IsNoAddr()) {
- orig_request->client_addr.NtoA(bbuf,MAX_IPSTRLEN);
- strListAdd(&strFwd, bbuf, ',');
- }
+ if (opt_forwarded_for && orig_request->client_addr.s_addr != no_addr.s_addr)
+ strListAdd(&strFwd, inet_ntoa(orig_request->client_addr), ',');
else
strListAdd(&strFwd, "unknown", ',');
@@ -1432,11 +1371,10 @@
hdr_out->putStr(HDR_HOST, orig_request->peer_domain);
} else if (orig_request->port == urlDefaultPort(orig_request->protocol)) {
/* use port# only if not default */
- hdr_out->putStr(HDR_HOST, orig_request->GetHost());
+ hdr_out->putStr(HDR_HOST, orig_request->host);
} else {
httpHeaderPutStrf(hdr_out, HDR_HOST, "%s:%d",
- orig_request->GetHost(),
- (int) orig_request->port);
+ orig_request->host, (int) orig_request->port);
}
}
@@ -1628,11 +1566,10 @@
/* use port# only if not default */
if (orig_request->port == urlDefaultPort(orig_request->protocol)) {
- hdr_out->putStr(HDR_HOST, orig_request->GetHost());
+ hdr_out->putStr(HDR_HOST, orig_request->host);
} else {
httpHeaderPutStrf(hdr_out, HDR_HOST, "%s:%d",
- orig_request->GetHost(),
- (int) orig_request->port);
+ orig_request->host, (int) orig_request->port);
}
}
@@ -1735,7 +1672,7 @@
const int offset = mb->size;
HttpVersion httpver(1, 0);
mb->Printf("%s %s HTTP/%d.%d\r\n",
- RequestMethodStr(request->method),
+ RequestMethodStr[request->method],
request->urlpath.size() ? request->urlpath.buf() : "/",
httpver.major,httpver.minor);
/* build and pack headers */
@@ -1819,7 +1756,7 @@
void
httpStart(FwdState *fwd)
{
- debugs(11, 3, "httpStart: \"" << RequestMethodStr(fwd->request->method) << " " << fwd->entry->url() << "\"" );
+ debugs(11, 3, "httpStart: \"" << RequestMethodStr[fwd->request->method] << " " << fwd->entry->url() << "\"" );
HttpStateData *httpState = new HttpStateData(fwd);
if (!httpState->sendRequest()) {
@@ -1881,7 +1818,7 @@
if (flags.headers_parsed && !flags.abuse_detected) {
flags.abuse_detected = 1;
- debugs(11, 1, "http handleMoreRequestBodyAvailable: Likely proxy abuse detected '" << orig_request->client_addr << "' -> '" << entry->url() << "'" );
+ debugs(11, 1, "http handleMoreRequestBodyAvailable: Likely proxy abuse detected '" << inet_ntoa(orig_request->client_addr) << "' -> '" << entry->url() << "'" );
if (virginReply()->sline.status == HTTP_INVALID_HEADER) {
comm_close(fd);
Index: squid3/src/http.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/http.h,v
retrieving revision 1.28.6.1
retrieving revision 1.28.6.2
diff -u -r1.28.6.1 -r1.28.6.2
--- squid3/src/http.h 25 Jan 2008 02:33:47 -0000 1.28.6.1
+++ squid3/src/http.h 27 Jan 2008 18:08:53 -0000 1.28.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: http.h,v 1.28.6.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: http.h,v 1.28.6.2 2008/01/27 18:08:53 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -38,7 +38,6 @@
#include "comm.h"
#include "forward.h"
#include "Server.h"
-#include "ChunkedCodingParser.h"
class HttpStateData : public ServerStateData
{
@@ -104,7 +103,6 @@
virtual void handleRequestBodyProducerAborted();
void writeReplyBody();
- bool decodeAndWriteReplyBody();
void doneSendingRequestBody();
void requestBodyHandler(MemBuf &);
virtual void sentRequestBody(int fd, size_t size, comm_err_t errflag);
@@ -115,7 +113,6 @@
http_state_flags flags);
static bool decideIfWeDoRanges (HttpRequest * orig_request);
- ChunkedCodingParser *httpChunkDecoder;
private:
CBDATA_CLASS2(HttpStateData);
};
Index: squid3/src/icmp.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/icmp.cc,v
retrieving revision 1.17.22.1
retrieving revision 1.17.22.2
diff -u -r1.17.22.1 -r1.17.22.2
--- squid3/src/icmp.cc 25 Jan 2008 02:33:47 -0000 1.17.22.1
+++ squid3/src/icmp.cc 27 Jan 2008 18:08:54 -0000 1.17.22.2
@@ -1,8 +1,9 @@
+
/*
- * $Id: icmp.cc,v 1.17.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: icmp.cc,v 1.17.22.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 37 ICMP Routines
- * AUTHOR: Duane Wessels, Amos Jeffries
+ * AUTHOR: Duane Wessels
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* ----------------------------------------------------------
@@ -31,90 +32,279 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
*/
+
+
#include "squid.h"
-#include "ICMP.h"
+#include "comm.h"
#include "SquidTime.h"
-#include "Debug.h"
-ICMP::ICMP()
-{
#if USE_ICMP
- icmp_sock = -1;
- icmp_ident = 0;
+
+#define S_ICMP_ECHO 1
+#if ALLOW_SOURCE_PING
+#define S_ICMP_ICP 2
#endif
+#define S_ICMP_DOM 3
+
+static PF icmpRecv;
+static void icmpSend(pingerEchoData * pkt, int len);
+#if ALLOW_SOURCE_PING
+
+static void icmpHandleSourcePing(const struct sockaddr_in *from, const char *buf);
+#endif
+
+static void * hIpc;
+static pid_t pid;
+
+static void
+
+icmpSendEcho(struct IN_ADDR to, int opcode, const char *payload, int len)
+{
+ static pingerEchoData pecho;
+
+ if (payload && len == 0)
+ len = strlen(payload);
+
+ assert(len <= PINGER_PAYLOAD_SZ);
+
+ pecho.to = to;
+
+ pecho.opcode = (unsigned char) opcode;
+
+ pecho.psize = len;
+
+ xmemcpy(pecho.payload, payload, len);
+
+ icmpSend(&pecho, sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ + len);
}
-void
-ICMP::Close()
+static void
+icmpRecv(int unused1, void *unused2)
{
-#if USE_ICMP
- if(icmp_sock > 0)
- close(icmp_sock);
- icmp_sock = -1;
- icmp_ident = 0;
+ int n;
+ static int fail_count = 0;
+ pingerReplyData preply;
+
+ static struct sockaddr_in F;
+ commSetSelect(icmp_sock, COMM_SELECT_READ, icmpRecv, NULL, 0);
+ memset(&preply, '\0', sizeof(pingerReplyData));
+ n = comm_udp_recv(icmp_sock,
+ (char *) &preply,
+ sizeof(pingerReplyData),
+ 0);
+
+ if (n < 0 && EAGAIN != errno) {
+ debugs(37, 1, "icmpRecv: recv: " << xstrerror());
+
+ if (errno == ECONNREFUSED)
+ icmpClose();
+
+ if (errno == ECONNRESET)
+ icmpClose();
+
+ if (++fail_count == 10)
+ icmpClose();
+
+ return;
+ }
+
+ fail_count = 0;
+
+ if (n == 0) /* test probe from pinger */
+ return;
+
+ F.sin_family = AF_INET;
+
+ F.sin_addr = preply.from;
+
+ F.sin_port = 0;
+
+ switch (preply.opcode) {
+
+ case S_ICMP_ECHO:
+ break;
+#if ALLOW_SOURCE_PING
+
+ case S_ICMP_ICP:
+ icmpHandleSourcePing(&F, preply.payload);
+ break;
#endif
-}
-#if USE_ICMP
+ case S_ICMP_DOM:
+ netdbHandlePingReply(&F, preply.hops, preply.rtt);
+ break;
+
+ default:
+ debugs(37, 1, "icmpRecv: Bad opcode: " << preply.opcode);
+ break;
+ }
+}
-int
-ICMP::CheckSum(unsigned short *ptr, int size)
+static void
+icmpSend(pingerEchoData * pkt, int len)
{
- long sum;
- unsigned short oddbyte;
- unsigned short answer;
+ int x;
- if(!ptr) return 65535; // bad input.
+ if (icmp_sock < 0)
+ return;
- sum = 0;
+ debugs(37, 2, "icmpSend: to " << inet_ntoa(pkt->to) << ", opcode " <<
+ (int) pkt->opcode << ", len " << pkt->psize);
- while (size > 1) {
- sum += *ptr++;
- size -= 2;
- }
+ x = comm_udp_send(icmp_sock, (char *) pkt, len, 0);
+
+ if (x < 0) {
+ debugs(37, 1, "icmpSend: send: " << xstrerror());
- if (size == 1) {
- oddbyte = 0;
- *((unsigned char *) &oddbyte) = *(unsigned char *) ptr;
- sum += oddbyte;
+ if (errno == ECONNREFUSED || errno == EPIPE) {
+ icmpClose();
+ return;
+ }
+ } else if (x != len) {
+ debugs(37, 1, "icmpSend: Wrote " << x << " of " << len << " bytes");
}
+}
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
- answer = (unsigned short) ~sum;
- return (answer);
+#if ALLOW_SOURCE_PING
+static void
+
+icmpHandleSourcePing(const struct sockaddr_in *from, const char *buf)
+{
+ const cache_key *key;
+ icp_common_t header;
+ const char *url;
+ xmemcpy(&header, buf, sizeof(icp_common_t));
+ url = buf + sizeof(icp_common_t);
+ key = icpGetCacheKey(url, (int) header.reqnum);
+ debugs(37, 3, "icmpHandleSourcePing: from " << inet_ntoa(from->sin_addr) << ", key '" << storeKeyText(key) << "'");
+
+ /* call neighborsUdpAck even if ping_status != PING_WAITING */
+ neighborsUdpAck(key, &header, from);
}
-int
-ICMP::ipHops(int ttl)
+#endif
+
+#endif /* USE_ICMP */
+
+#if ALLOW_SOURCE_PING
+void
+
+icmpSourcePing(struct IN_ADDR to, const icp_common_t * header, const char *url)
{
- if (ttl < 33)
- return 33 - ttl;
+#if USE_ICMP
+ char *payload;
+ int len;
+ int ulen;
+ debugs(37, 3, "icmpSourcePing: '" << url << "'");
+
+ if ((ulen = strlen(url)) > MAX_URL)
+ return;
+
+ payload = memAllocate(MEM_8K_BUF);
- if (ttl < 63)
- return 63 - ttl; /* 62 = (64+60)/2 */
+ len = sizeof(icp_common_t);
- if (ttl < 65)
- return 65 - ttl; /* 62 = (64+60)/2 */
+ xmemcpy(payload, header, len);
- if (ttl < 129)
- return 129 - ttl;
+ strcpy(payload + len, url);
- if (ttl < 193)
- return 193 - ttl;
+ len += ulen + 1;
- return 256 - ttl;
+ icmpSendEcho(to, S_ICMP_ICP, payload, len);
+
+ memFree(payload, MEM_8K_BUF);
+
+#endif
}
+#endif
+
void
-ICMP::Log(const IPAddress &addr, const u_int8_t type, const char* pkt_str, const int rtt, const int hops)
+
+icmpDomainPing(struct IN_ADDR to, const char *domain)
{
- debugs(42, 2, "pingerLog: " << std::setw(9) << current_time.tv_sec <<
- "." << std::setfill('0') << std::setw(6) <<
- current_time.tv_usec << " " << std::left << std::setfill(' ') <<
- std::setw(45) << addr << " " << type <<
- " " << std::setw(15) << pkt_str << " " << rtt <<
- "ms " << hops << " hops");
+#if USE_ICMP
+ debugs(37, 3, "icmpDomainPing: '" << domain << "'");
+ icmpSendEcho(to, S_ICMP_DOM, domain, 0);
+#endif
}
-#endif /* USE_ICMP */
+void
+icmpOpen(void)
+{
+#if USE_ICMP
+ const char *args[2];
+ int rfd;
+ int wfd;
+ args[0] = "(pinger)";
+ args[1] = NULL;
+ /*
+ * Do NOT use IPC_DGRAM (=IPC_UNIX_DGRAM) here because you can't
+ * send() more than 4096 bytes on a socketpair() socket (at
+ * least on FreeBSD).
+ */
+ pid = ipcCreate(IPC_UDP_SOCKET,
+ Config.Program.pinger,
+ args,
+ "Pinger Socket",
+ &rfd,
+ &wfd,
+ &hIpc);
+
+ if (pid < 0)
+ return;
+
+ assert(rfd == wfd);
+
+ icmp_sock = rfd;
+
+ fd_note(icmp_sock, "pinger");
+
+ commSetSelect(icmp_sock, COMM_SELECT_READ, icmpRecv, NULL, 0);
+
+ commSetTimeout(icmp_sock, -1, NULL, NULL);
+
+ debugs(37, 1, "Pinger socket opened on FD " << icmp_sock);
+
+#ifdef _SQUID_MSWIN_
+
+ debugs(37, 4, "Pinger handle: 0x" << std::hex << hIpc << std::dec << ", PID: " << pid);
+
+#endif
+#endif
+}
+
+void
+icmpClose(void)
+{
+#if USE_ICMP
+
+ if (icmp_sock < 0)
+ return;
+
+ debugs(37, 1, "Closing Pinger socket on FD " << icmp_sock);
+
+#ifdef _SQUID_MSWIN_
+
+ send(icmp_sock, (const void *) "$shutdown\n", 10, 0);
+
+#endif
+
+ comm_close(icmp_sock);
+
+#ifdef _SQUID_MSWIN_
+
+ if (hIpc) {
+ if (WaitForSingleObject(hIpc, 12000) != WAIT_OBJECT_0) {
+ getCurrentTime();
+ debugs(37, 1, "icmpClose: WARNING: (pinger," << pid << ") didn't exit in 12 seconds");
+ }
+
+ CloseHandle(hIpc);
+ }
+
+#endif
+ icmp_sock = -1;
+
+#endif
+}
Index: squid3/src/icp_v2.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/icp_v2.cc,v
retrieving revision 1.32.22.2
retrieving revision 1.32.22.3
diff -u -r1.32.22.2 -r1.32.22.3
--- squid3/src/icp_v2.cc 25 Jan 2008 02:33:47 -0000 1.32.22.2
+++ squid3/src/icp_v2.cc 27 Jan 2008 18:08:54 -0000 1.32.22.3
@@ -1,8 +1,8 @@
/*
- * $Id: icp_v2.cc,v 1.32.22.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: icp_v2.cc,v 1.32.22.3 2008/01/27 18:08:54 rousskov Exp $
*
- * DEBUG: section 12 Internet Cache Protocol (ICP)
+ * DEBUG: section 12 Internet Cache Protocol
* AUTHOR: Duane Wessels
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -45,9 +45,9 @@
#include "SquidTime.h"
#include "SwapDir.h"
-static void icpLogIcp(const IPAddress &, log_type, int, const char *, int);
+static void icpLogIcp(struct IN_ADDR, log_type, int, const char *, int);
-static void icpHandleIcpV2(int, IPAddress &, char *, int);
+static void icpHandleIcpV2(int, struct sockaddr_in, char *, int);
static void icpCount(void *, int, size_t, int);
/*
@@ -138,8 +138,8 @@
codeToSend = ICP_HIT;
} else {
if (Config.onoff.test_reachability && rtt == 0) {
- if ((rtt = netdbHostRtt(request->GetHost())) == 0)
- netdbPingSite(request->GetHost());
+ if ((rtt = netdbHostRtt(request->host)) == 0)
+ netdbPingSite(request->host);
}
if (icpGetCommonOpcode() != ICP_ERR)
@@ -150,7 +150,7 @@
codeToSend = ICP_MISS;
}
- icpCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, from);
+ icpCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, &from);
delete this;
}
@@ -158,7 +158,7 @@
static void
-icpLogIcp(const IPAddress &caddr, log_type logcode, int len, const char *url, int delay)
+icpLogIcp(struct IN_ADDR caddr, log_type logcode, int len, const char *url, int delay)
{
AccessLogEntry al;
@@ -198,7 +198,7 @@
while ((q = IcpQueueHead) != NULL) {
delay = tvSubUsec(q->queue_time, current_time);
/* increment delay to prevent looping */
- x = icpUdpSend(fd, q->address, (icp_common_t *) q->msg, q->logcode, ++delay);
+ x = icpUdpSend(fd, &q->address, (icp_common_t *) q->msg, q->logcode, ++delay);
IcpQueueHead = q->next;
safe_free(q);
@@ -240,7 +240,7 @@
headerp->pad = htonl(pad);
- theOutICPAddr.GetInAddr( *((struct in_addr*)&headerp->shostid) );
+ headerp->shostid = theOutICPAddr.s_addr;
urloffset = buf + sizeof(icp_common_t);
@@ -254,7 +254,8 @@
int
icpUdpSend(int fd,
- const IPAddress &to,
+
+ const struct sockaddr_in *to,
icp_common_t * msg,
log_type logcode,
int delay)
@@ -264,21 +265,22 @@
int len;
len = (int) ntohs(msg->length);
debugs(12, 5, "icpUdpSend: FD " << fd << " sending " <<
- icp_opcode_str[msg->opcode] << ", " << len << " bytes to " << to);
+ icp_opcode_str[msg->opcode] << ", " << len << " bytes to " <<
+ inet_ntoa(to->sin_addr) << ":" << ntohs(to->sin_port));
- x = comm_udp_sendto(fd, to, msg, len);
+ x = comm_udp_sendto(fd, to, sizeof(*to), msg, len);
if (x >= 0)
{
/* successfully written */
- icpLogIcp(to, logcode, len, (char *) (msg + 1), delay);
+ icpLogIcp(to->sin_addr, logcode, len, (char *) (msg + 1), delay);
icpCount(msg, SENT, (size_t) len, delay);
safe_free(msg);
} else if (0 == delay)
{
/* send failed, but queue it */
queue = (icpUdpData *) xcalloc(1, sizeof(icpUdpData));
- queue->address = to;
+ queue->address = *to;
queue->msg = msg;
queue->len = (int) ntohs(msg->length);
queue->queue_time = current_time;
@@ -366,7 +368,7 @@
void
-icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const IPAddress &from)
+icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const struct sockaddr_in *from)
{
icp_common_t *reply = _icp_common_t::createMessage(opcode, flags, url, reqnum, pad);
icpUdpSend(fd, from, reply, icpLogFromICPCode(opcode), 0);
@@ -374,17 +376,17 @@
void
-icpDenyAccess(IPAddress &from, char *url, int reqnum, int fd)
+icpDenyAccess(struct sockaddr_in *from, char *url, int reqnum, int fd)
{
- debugs(12, 2, "icpDenyAccess: Access Denied for " << from << " by " << AclMatchedName << ".");
+ debugs(12, 2, "icpDenyAccess: Access Denied for " << inet_ntoa(from->sin_addr) << " by " << AclMatchedName << ".");
- if (clientdbCutoffDenied(from))
+ if (clientdbCutoffDenied(from->sin_addr))
{
/*
* count this DENIED query in the clientdb, even though
* we're not sending an ICP reply...
*/
- clientdbUpdate(from, LOG_UDP_DENIED, PROTO_ICP, 0);
+ clientdbUpdate(from->sin_addr, LOG_UDP_DENIED, PROTO_ICP, 0);
} else
{
icpCreateAndSend(ICP_DENIED, 0, url, reqnum, 0, fd, from);
@@ -393,11 +395,11 @@
int
-icpAccessAllowed(IPAddress &from, HttpRequest * icp_request)
+icpAccessAllowed(struct sockaddr_in *from, HttpRequest * icp_request)
{
ACLChecklist checklist;
- checklist.src_addr = from;
- checklist.my_addr.SetNoAddr();
+ checklist.src_addr = from->sin_addr;
+ checklist.my_addr = no_addr;
checklist.request = HTTPMSGLOCK(icp_request);
checklist.accessList = cbdataReference(Config.accessList.icp);
/* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */
@@ -416,7 +418,7 @@
HttpRequest *
-icpGetRequest(char *url, int reqnum, int fd, IPAddress &from)
+icpGetRequest(char *url, int reqnum, int fd, struct sockaddr_in * from)
{
if (strpbrk(url, w_space))
{
@@ -436,31 +438,31 @@
static void
-doV2Query(int fd, IPAddress &from, char *buf, icp_common_t header)
+doV2Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header)
{
int rtt = 0;
int src_rtt = 0;
u_int32_t flags = 0;
/* We have a valid packet */
char *url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
- HttpRequest *icp_request = icpGetRequest(url, header.reqnum, fd, from);
+ HttpRequest *icp_request = icpGetRequest(url, header.reqnum, fd, &from);
if (!icp_request)
return;
HTTPMSGLOCK(icp_request);
- if (!icpAccessAllowed(from, icp_request))
+ if (!icpAccessAllowed(&from, icp_request))
{
- icpDenyAccess(from, url, header.reqnum, fd);
+ icpDenyAccess(&from, url, header.reqnum, fd);
HTTPMSGUNLOCK(icp_request);
return;
}
if (header.flags & ICP_FLAG_SRC_RTT)
{
- rtt = netdbHostRtt(icp_request->GetHost());
- int hops = netdbHostHops(icp_request->GetHost());
+ rtt = netdbHostRtt(icp_request->host);
+ int hops = netdbHostHops(icp_request->host);
src_rtt = ((hops & 0xFFFF) << 16) | (rtt & 0xFFFF);
if (rtt)
@@ -489,17 +491,17 @@
void
-_icp_common_t::handleReply(char *buf, IPAddress &from)
+_icp_common_t::handleReply(char *buf, struct sockaddr_in *from)
{
if (neighbors_do_private_keys && reqnum == 0)
{
- debugs(12, 0, "icpHandleIcpV2: Neighbor " << from << " returned reqnum = 0");
+ debugs(12, 0, "icpHandleIcpV2: Neighbor " << inet_ntoa(from->sin_addr) << " returned reqnum = 0");
debugs(12, 0, "icpHandleIcpV2: Disabling use of private keys");
neighbors_do_private_keys = 0;
}
char *url = buf + sizeof(icp_common_t);
- debugs(12, 3, "icpHandleIcpV2: " << icp_opcode_str[opcode] << " from " << from << " for '" << url << "'");
+ debugs(12, 3, "icpHandleIcpV2: " << icp_opcode_str[opcode] << " from " << inet_ntoa(from->sin_addr) << " for '" << url << "'");
const cache_key *key = icpGetCacheKey(url, (int) reqnum);
/* call neighborsUdpAck even if ping_status != PING_WAITING */
@@ -508,7 +510,7 @@
static void
-icpHandleIcpV2(int fd, IPAddress &from, char *buf, int len)
+icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
{
if (len <= 0)
{
@@ -536,6 +538,10 @@
break;
case ICP_HIT:
+#if ALLOW_SOURCE_PING
+
+ case ICP_SECHO:
+#endif
case ICP_DECHO:
@@ -544,7 +550,7 @@
case ICP_DENIED:
case ICP_MISS_NOFETCH:
- header.handleReply(buf, from);
+ header.handleReply(buf, &from);
break;
case ICP_INVALID:
@@ -553,7 +559,7 @@
break;
default:
- debugs(12, 0, "icpHandleIcpV2: UNKNOWN OPCODE: " << header.opcode << " from " << from);
+ debugs(12, 0, "icpHandleIcpV2: UNKNOWN OPCODE: " << header.opcode << " from " << inet_ntoa(from.sin_addr));
break;
}
@@ -564,15 +570,15 @@
icpPktDump(icp_common_t * pkt)
{
- IPAddress a;
+ struct IN_ADDR a;
debugs(12, 9, "opcode: " << std::setw(3) << pkt->opcode << " " << icp_opcode_str[pkt->opcode]);
debugs(12, 9, "version: "<< std::left << std::setw(8) << pkt->version);
debugs(12, 9, "length: "<< std::left << std::setw(8) << ntohs(pkt->length));
debugs(12, 9, "reqnum: "<< std::left << std::setw(8) << ntohl(pkt->reqnum));
debugs(12, 9, "flags: "<< std::left << std::hex << std::setw(8) << ntohl(pkt->flags));
- a = (struct in_addr)pkt->shostid;
- debugs(12, 9, "shostid: " << a );
+ a.s_addr = pkt->shostid;
+ debugs(12, 9, "shostid: " << inet_ntoa(a));
debugs(12, 9, "payload: " << (char *) pkt + sizeof(icp_common_t));
}
@@ -583,7 +589,8 @@
{
int *N = &incoming_sockets_accepted;
- IPAddress from;
+ struct sockaddr_in from;
+ socklen_t from_len;
LOCAL_ARRAY(char, buf, SQUID_UDP_SO_RCVBUF);
int len;
int icp_version;
@@ -591,11 +598,15 @@
commSetSelect(sock, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
while (max--) {
+ from_len = sizeof(from);
+ memset(&from, '\0', from_len);
len = comm_udp_recvfrom(sock,
buf,
SQUID_UDP_SO_RCVBUF - 1,
0,
- from);
+
+ (struct sockaddr *) &from,
+ &from_len);
if (len == 0)
break;
@@ -621,7 +632,8 @@
icpCount(buf, RECV, (size_t) len, 0);
buf[len] = '\0';
debugs(12, 4, "icpHandleUdp: FD " << sock << ": received " <<
- (unsigned long int)len << " bytes from " << from);
+ (unsigned long int)len << " bytes from " <<
+ inet_ntoa(from.sin_addr) << ".");
#ifdef ICP_PACKET_DUMP
@@ -641,7 +653,7 @@
icpHandleIcpV3(sock, from, buf, len);
else
debugs(12, 1, "WARNING: Unused ICP version " << icp_version <<
- " received from " << from);
+ " received from " << inet_ntoa(from.sin_addr) << ":" << ntohs(from.sin_port));
}
}
@@ -650,10 +662,11 @@
{
u_int16_t port;
- IPAddress addr;
+ struct IN_ADDR addr;
- struct addrinfo *xai = NULL;
+ struct sockaddr_in xaddr;
int x;
+ socklen_t len;
wordlist *s;
if ((port = Config.Port.icp) <= 0)
@@ -661,13 +674,13 @@
enter_suid();
- addr = Config.Addrs.udp_incoming;
- addr.SetPort(port);
theInIcpConnection = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
- addr,
+ Config.Addrs.udp_incoming,
+ port,
COMM_NONBLOCKING,
"ICP Socket");
+
leave_suid();
if (theInIcpConnection < 0)
@@ -682,16 +695,17 @@
for (s = Config.mcast_group_list; s; s = s->next)
ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
- debugs(12, 1, "Accepting ICP messages at " << addr << ", FD " << theInIcpConnection << ".");
+ debugs(12, 1, "Accepting ICP messages at " <<
+ inet_ntoa(Config.Addrs.udp_incoming) << ", port " << (int) port <<
+ ", FD " << theInIcpConnection << ".");
+
- addr.SetEmpty(); // clear for next use.
- addr = Config.Addrs.udp_outgoing;
- if ( !addr.IsNoAddr() ) {
+ if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) {
enter_suid();
- addr.SetPort(port);
theOutIcpConnection = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
addr,
+ port,
COMM_NONBLOCKING,
"ICP Port");
leave_suid();
@@ -705,7 +719,7 @@
NULL,
0);
- debugs(12, 1, "Outgoing ICP messages on port " << addr.GetPort() << ", FD " << theOutIcpConnection << ".");
+ debugs(12, 1, "Outgoing ICP messages on port " << port << ", FD " << theOutIcpConnection << ".");
fd_note(theOutIcpConnection, "Outgoing ICP socket");
@@ -714,18 +728,18 @@
theOutIcpConnection = theInIcpConnection;
}
- theOutICPAddr.SetEmpty();
+ memset(&theOutICPAddr, '\0', sizeof(struct IN_ADDR));
- theOutICPAddr.InitAddrInfo(xai);
+ len = sizeof(struct sockaddr_in);
+ memset(&xaddr, '\0', len);
+ x = getsockname(theOutIcpConnection,
- x = getsockname(theOutIcpConnection, xai->ai_addr, &xai->ai_addrlen);
+ (struct sockaddr *) &xaddr, &len);
if (x < 0)
debugs(50, 1, "theOutIcpConnection FD " << theOutIcpConnection << ": getsockname: " << xstrerror());
else
- theOutICPAddr = *xai;
-
- theOutICPAddr.FreeAddrInfo(xai);
+ theOutICPAddr = xaddr.sin_addr;
}
/*
Index: squid3/src/icp_v3.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/icp_v3.cc,v
retrieving revision 1.8.22.1
retrieving revision 1.8.22.2
diff -u -r1.8.22.1 -r1.8.22.2
--- squid3/src/icp_v3.cc 25 Jan 2008 02:33:47 -0000 1.8.22.1
+++ squid3/src/icp_v3.cc 27 Jan 2008 18:08:54 -0000 1.8.22.2
@@ -1,8 +1,8 @@
/*
- * $Id: icp_v3.cc,v 1.8.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: icp_v3.cc,v 1.8.22.2 2008/01/27 18:08:54 rousskov Exp $
*
- * DEBUG: section 12 Internet Cache Protocol (ICP)
+ * DEBUG: section 12 Internet Cache Protocol
* AUTHOR: Duane Wessels
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -52,18 +52,18 @@
static void
-doV3Query(int fd, IPAddress &from, char *buf, icp_common_t header)
+doV3Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header)
{
/* We have a valid packet */
char *url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
- HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, from);
+ HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, &from);
if (!icp_request)
return;
- if (!icpAccessAllowed(from, icp_request))
+ if (!icpAccessAllowed(&from, icp_request))
{
- icpDenyAccess (from, url, header.reqnum, fd);
+ icpDenyAccess (&from, url, header.reqnum, fd);
delete icp_request;
return;
}
@@ -97,7 +97,7 @@
else
codeToSend = icpGetCommonOpcode();
- icpCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, from);
+ icpCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, &from);
delete this;
}
@@ -105,7 +105,7 @@
/* Currently Harvest cached-2.x uses ICP_VERSION_3 */
void
-icpHandleIcpV3(int fd, IPAddress&from, char *buf, int len)
+icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
{
if (len <= 0)
{
@@ -128,10 +128,14 @@
{
case ICP_QUERY:
- doV3Query(fd, from, buf, header);
+ doV3Query(fd, from,buf, header);
break;
case ICP_HIT:
+#if ALLOW_SOURCE_PING
+
+ case ICP_SECHO:
+#endif
case ICP_DECHO:
@@ -140,7 +144,7 @@
case ICP_DENIED:
case ICP_MISS_NOFETCH:
- header.handleReply(buf, from);
+ header.handleReply(buf, &from);
break;
case ICP_INVALID:
@@ -149,7 +153,7 @@
break;
default:
- debugs(12, 0, "icpHandleIcpV3: UNKNOWN OPCODE: " << header.opcode << " from " << from);
+ debugs(12, 0, "icpHandleIcpV3: UNKNOWN OPCODE: " << header.opcode << " from " << inet_ntoa(from.sin_addr));
break;
}
}
Index: squid3/src/ident.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ident.cc,v
retrieving revision 1.18.16.1
retrieving revision 1.18.16.2
diff -u -r1.18.16.1 -r1.18.16.2
--- squid3/src/ident.cc 25 Jan 2008 02:33:47 -0000 1.18.16.1
+++ squid3/src/ident.cc 27 Jan 2008 18:08:54 -0000 1.18.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: ident.cc,v 1.18.16.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: ident.cc,v 1.18.16.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 30 Ident (RFC 931)
* AUTHOR: Duane Wessels
@@ -55,9 +55,9 @@
hash_link hash; /* must be first */
int fd; /* IDENT fd */
- IPAddress me;
+ struct sockaddr_in me;
- IPAddress my_peer;
+ struct sockaddr_in my_peer;
IdentClient *clients;
char buf[4096];
}
@@ -107,7 +107,7 @@
identTimeout(int fd, void *data)
{
IdentStateData *state = (IdentStateData *)data;
- debugs(30, 3, "identTimeout: FD " << fd << ", " << state->my_peer);
+ debugs(30, 3, "identTimeout: FD " << fd << ", " << inet_ntoa(state->my_peer.sin_addr));
comm_close(fd);
}
@@ -141,8 +141,8 @@
MemBuf mb;
mb.init();
mb.Printf("%d, %d\r\n",
- state->my_peer.GetPort(),
- state->me.GetPort());
+ ntohs(state->my_peer.sin_port),
+ ntohs(state->me.sin_port));
comm_write_mbuf(fd, &mb, NULL, state);
comm_read(fd, state->buf, BUFSIZ, identReadReply, state);
commSetTimeout(fd, Config.Timeout.ident, identTimeout, state);
@@ -212,17 +212,20 @@
* start a TCP connection to the peer host on port 113
*/
void
-identStart(IPAddress &me, IPAddress &my_peer, IDCB * callback, void *data)
+
+identStart(struct sockaddr_in *me, struct sockaddr_in *my_peer, IDCB * callback, void *data)
{
IdentStateData *state;
int fd;
char key1[IDENT_KEY_SZ];
char key2[IDENT_KEY_SZ];
char key[IDENT_KEY_SZ];
- char ntoabuf[MAX_IPSTRLEN];
-
- me.ToURL(key1, IDENT_KEY_SZ);
- my_peer.ToURL(key2, IDENT_KEY_SZ);
+ snprintf(key1, IDENT_KEY_SZ, "%s:%d",
+ inet_ntoa(me->sin_addr),
+ ntohs(me->sin_port));
+ snprintf(key2, IDENT_KEY_SZ, "%s:%d",
+ inet_ntoa(my_peer->sin_addr),
+ ntohs(my_peer->sin_port));
snprintf(key, IDENT_KEY_SZ, "%s,%s", key1, key2);
if ((state = (IdentStateData *)hash_lookup(ident_hash, key)) != NULL)
@@ -233,7 +236,8 @@
fd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
- me,
+ me->sin_addr,
+ 0,
COMM_NONBLOCKING,
"ident");
@@ -248,8 +252,8 @@
state = cbdataAlloc(IdentStateData);
state->hash.key = xstrdup(key);
state->fd = fd;
- state->me = me;
- state->my_peer = my_peer;
+ state->me = *me;
+ state->my_peer = *my_peer;
identClientAdd(state, callback, data);
hash_join(ident_hash, &state->hash);
comm_add_close_handler(fd,
@@ -257,7 +261,7 @@
state);
commSetTimeout(fd, Config.Timeout.ident, identTimeout, state);
commConnectStart(fd,
- state->my_peer.NtoA(ntoabuf,MAX_IPSTRLEN),
+ inet_ntoa(state->my_peer.sin_addr),
IDENT_PORT,
identConnectDone,
state);
Index: squid3/src/internal.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/internal.cc,v
retrieving revision 1.19.16.1
retrieving revision 1.19.16.2
diff -u -r1.19.16.1 -r1.19.16.2
--- squid3/src/internal.cc 25 Jan 2008 02:33:47 -0000 1.19.16.1
+++ squid3/src/internal.cc 27 Jan 2008 18:08:54 -0000 1.19.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: internal.cc,v 1.19.16.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: internal.cc,v 1.19.16.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 76 Internal Squid Object handling
* AUTHOR: Duane, Alex, Henrik
@@ -51,7 +51,7 @@
{
ErrorState *err;
const char *upath = request->urlpath.buf();
- debugs(76, 3, "internalStart: " << request->client_addr << " requesting '" << upath << "'");
+ debugs(76, 3, "internalStart: " << inet_ntoa(request->client_addr) << " requesting '" << upath << "'");
if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) {
netdbBinaryExchange(entry);
@@ -106,15 +106,6 @@
/* convert host name to lower case */
xstrncpy(lc_host, host, SQUIDHOSTNAMELEN);
Tolower(lc_host);
-
-#if USE_IPV6
- /* check for an IP address and format appropriately if found */
- IPAddress test = lc_host;
- if ( !test.IsAnyAddr() ) {
- test.ToHostname(lc_host,SQUIDHOSTNAMELEN);
- }
-#endif
-
/*
* append the domain in order to mirror the requests with appended
* domains
Index: squid3/src/ipc.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ipc.cc,v
retrieving revision 1.16.16.1
retrieving revision 1.16.16.2
diff -u -r1.16.16.1 -r1.16.16.2
--- squid3/src/ipc.cc 25 Jan 2008 02:33:47 -0000 1.16.16.1
+++ squid3/src/ipc.cc 27 Jan 2008 18:08:54 -0000 1.16.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: ipc.cc,v 1.16.16.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: ipc.cc,v 1.16.16.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 54 Interprocess Communication
* AUTHOR: Duane Wessels
@@ -36,7 +36,6 @@
#include "squid.h"
#include "comm.h"
#include "fde.h"
-#include "IPAddress.h"
static const char *hello_string = "hi there\n";
#define HELLO_BUF_SZ 32
@@ -75,18 +74,20 @@
}
pid_t
-ipcCreate(int type, const char *prog, const char *const args[], const char *name, IPAddress &local_addr, int *rfd, int *wfd, void **hIpc)
+ipcCreate(int type, const char *prog, const char *const args[], const char *name, int *rfd, int *wfd, void **hIpc)
{
pid_t pid;
- IPAddress ChS;
- IPAddress PaS;
- struct addrinfo *AI = NULL;
+
+ struct sockaddr_in ChS;
+
+ struct sockaddr_in PaS;
int crfd = -1;
int prfd = -1;
int cwfd = -1;
int pwfd = -1;
int fd;
int t1, t2, t3;
+ socklen_t len;
int x;
#if USE_POLL && defined(_SQUID_OSF_)
@@ -107,23 +108,27 @@
crfd = cwfd = comm_open(SOCK_STREAM,
0,
local_addr,
+ 0,
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_STREAM,
0, /* protocol */
local_addr,
+ 0, /* port */
0, /* blocking */
name);
} else if (type == IPC_UDP_SOCKET) {
crfd = cwfd = comm_open(SOCK_DGRAM,
0,
local_addr,
+ 0,
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_DGRAM,
0,
local_addr,
0,
+ 0,
name);
} else if (type == IPC_FIFO) {
int p2c[2];
@@ -192,33 +197,25 @@
}
if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) {
- PaS.InitAddrInfo(AI);
+ len = sizeof(PaS);
+ memset(&PaS, '\0', len);
- if (getsockname(pwfd, AI->ai_addr, &AI->ai_addrlen) < 0) {
- PaS.FreeAddrInfo(AI);
+ if (getsockname(pwfd, (struct sockaddr *) &PaS, &len) < 0) {
debugs(54, 0, "ipcCreate: getsockname: " << xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- PaS = *AI;
+ debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << inet_ntoa(PaS.sin_addr) << ":" << ntohs(PaS.sin_port));
- debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << PaS);
+ len = sizeof(ChS);
+ memset(&ChS, '\0', len);
- PaS.FreeAddrInfo(AI);
-
- ChS.InitAddrInfo(AI);
-
- if (getsockname(crfd, AI->ai_addr, &AI->ai_addrlen) < 0) {
- ChS.FreeAddrInfo(AI);
+ if (getsockname(crfd, (struct sockaddr *) &ChS, &len) < 0) {
debugs(54, 0, "ipcCreate: getsockname: " << xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- ChS = *AI;
-
- ChS.FreeAddrInfo(AI);
-
- debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << ChS );
+ debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << inet_ntoa(ChS.sin_addr) << ":" << ntohs(ChS.sin_port));
}
@@ -249,7 +246,7 @@
cwfd = crfd = -1;
if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) {
- if (comm_connect_addr(pwfd, ChS) == COMM_ERROR)
+ if (comm_connect_addr(pwfd, &ChS) == COMM_ERROR)
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
@@ -320,7 +317,7 @@
close(crfd);
cwfd = crfd = fd;
} else if (type == IPC_UDP_SOCKET) {
- if (comm_connect_addr(crfd, PaS) == COMM_ERROR)
+ if (comm_connect_addr(crfd, &PaS) == COMM_ERROR)
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
Index: squid3/src/ipc_win32.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ipc_win32.cc,v
retrieving revision 1.5.22.1
retrieving revision 1.5.22.2
diff -u -r1.5.22.1 -r1.5.22.2
--- squid3/src/ipc_win32.cc 25 Jan 2008 02:33:47 -0000 1.5.22.1
+++ squid3/src/ipc_win32.cc 27 Jan 2008 18:08:54 -0000 1.5.22.2
@@ -1,5 +1,6 @@
+
/*
- * $Id: ipc_win32.cc,v 1.5.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: ipc_win32.cc,v 1.5.22.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 54 Windows Interprocess Communication
* AUTHOR: Andrey Shorin
@@ -48,8 +49,8 @@
int type;
int crfd;
int cwfd;
- IPAddress local_addr;
- struct addrinfo PS;
+
+ struct sockaddr_in PS;
const char *prog;
char **args;
};
@@ -107,7 +108,7 @@
}
pid_t
-ipcCreate(int type, const char *prog, const char *const args[], const char *name, IPAddress &local_addr, int *rfd, int *wfd, void **hIpc)
+ipcCreate(int type, const char *prog, const char *const args[], const char *name, int *rfd, int *wfd, void **hIpc)
{
unsigned long thread;
@@ -117,14 +118,14 @@
DWORD ecode = 0;
pid_t pid;
- IPAddress tmp_addr;
- struct addrinfo *aiCS = NULL;
- struct addrinfo *aiPS = NULL;
+ struct sockaddr_in CS;
+ struct sockaddr_in PS;
int crfd = -1;
int prfd = -1;
int cwfd = -1;
int pwfd = -1;
+ socklen_t len;
int x;
requirePathnameExists(name, prog);
@@ -148,23 +149,27 @@
crfd = cwfd = comm_open(SOCK_STREAM,
IPPROTO_TCP,
local_addr,
+ 0,
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_STREAM,
IPPROTO_TCP, /* protocol */
local_addr,
+ 0, /* port */
0, /* blocking */
name);
} else if (type == IPC_UDP_SOCKET) {
crfd = cwfd = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
local_addr,
+ 0,
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_DGRAM,
IPPROTO_UDP,
local_addr,
0,
+ 0,
name);
} else if (type == IPC_FIFO) {
debugs(54, 0, "ipcCreate: " << prog << ": use IPC_TCP_SOCKET instead of IP_FIFO on Windows");
@@ -194,31 +199,25 @@
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
-// AYJ: these flags should be neutral, but if not IPv6 version needs adding
if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) {
+ len = sizeof(PS);
+ memset(&PS, '\0', len);
- tmp_addr.InitAddrInfo(aiPS);
-
- if (getsockname(pwfd, aiPS->ai_addr, &(aiPS->ai_addrlen) ) < 0) {
+ if (getsockname(pwfd, (struct sockaddr *) &PS, &len) < 0) {
debugs(54, 0, "ipcCreate: getsockname: " << xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- tmp_addr = *aiPS;
-
- debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << tmp_addr );
+ debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << inet_ntoa(PS.sin_addr) << ":" << ntohs(PS.sin_port));
+ len = sizeof(CS);
+ memset(&CS, '\0', len);
- tmp_addr.InitAddrInfo(aiCS);
-
- if (getsockname(crfd, aiCS->ai_addr, &(aiCS->ai_addrlen) ) < 0) {
+ if (getsockname(crfd, (struct sockaddr *) &CS, &len) < 0) {
debugs(54, 0, "ipcCreate: getsockname: " << xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- tmp_addr.SetEmpty();
- tmp_addr = *aiCS;
-
- debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << tmp_addr );
+ debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << inet_ntoa(CS.sin_addr) << ":" << ntohs(CS.sin_port));
}
if (type == IPC_TCP_SOCKET) {
@@ -239,9 +238,7 @@
params.cwfd = cwfd;
- params.PS = *aiPS;
-
- params.local_addr = local_addr;
+ params.PS = PS;
params.prog = prog;
@@ -254,8 +251,7 @@
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- /* NP: tmp_addr was left with eiether empty or aiCS in IPAddress format */
- if (comm_connect_addr(pwfd, tmp_addr) == COMM_ERROR) {
+ if (comm_connect_addr(pwfd, &CS) == COMM_ERROR) {
CloseHandle((HANDLE) thread);
return ipcCloseAllFD(prfd, pwfd, -1, -1);
}
@@ -373,7 +369,7 @@
struct thread_params thread_params;
ssize_t x;
- int fd = -1;
+ int tmp_s, fd = -1;
char *str;
STARTUPINFO si;
PROCESS_INFORMATION pi;
@@ -381,10 +377,7 @@
int prfd_ipc = -1, pwfd_ipc = -1, crfd_ipc = -1, cwfd_ipc = -1;
char *prog = NULL, *buf1 = NULL;
- IPAddress PS_ipc;
- IPAddress CS_ipc;
- struct addrinfo *aiPS_ipc = NULL;
- struct addrinfo *aiCS_ipc = NULL;
+ struct sockaddr_in CS_ipc, PS_ipc;
struct ipc_params *params = (struct ipc_params *) in_params;
int type = params->type;
@@ -392,9 +385,9 @@
int cwfd = params->cwfd;
char **args = params->args;
- IPAddress PS = params->PS;
- IPAddress local_addr = params->local_addr;
-
+ struct sockaddr_in PS = params->PS;
+
+
buf1 = (char *)xcalloc(1, 8192);
strcpy(buf1, params->prog);
prog = strtok(buf1, w_space);
@@ -422,7 +415,7 @@
fd_table[fd].flags.ipc = 1;
cwfd = crfd = fd;
} else if (type == IPC_UDP_SOCKET) {
- if (comm_connect_addr(crfd, params->PS) == COMM_ERROR)
+ if (comm_connect_addr(crfd, &PS) == COMM_ERROR)
goto cleanup;
}
@@ -464,7 +457,7 @@
if (type == IPC_UDP_SOCKET) {
snprintf(buf1, 8192, "%s(%ld) <-> ipc CHILD socket", prog, -1L);
- crfd_ipc = cwfd_ipc = comm_open(SOCK_DGRAM, IPPROTO_UDP, local_addr, 0, buf1);
+ crfd_ipc = cwfd_ipc = comm_open(SOCK_DGRAM, IPPROTO_UDP, local_addr, 0, 0, buf1);
if (crfd_ipc < 0) {
debugs(54, 0, "ipcCreate: CHILD: Failed to create child FD for " << prog << ".");
@@ -473,7 +466,7 @@
}
snprintf(buf1, 8192, "%s(%ld) <-> ipc PARENT socket", prog, -1L);
- prfd_ipc = pwfd_ipc = comm_open(SOCK_DGRAM, IPPROTO_UDP, local_addr, 0, buf1);
+ prfd_ipc = pwfd_ipc = comm_open(SOCK_DGRAM, IPPROTO_UDP, local_addr, 0, 0, buf1);
if (pwfd_ipc < 0) {
debugs(54, 0, "ipcCreate: CHILD: Failed to create server FD for " << prog << ".");
@@ -481,38 +474,36 @@
goto cleanup;
}
- PS_ipc.InitAddrInfo(aiPS_ipc);
+ tmp_s = sizeof(PS_ipc);
+ memset(&PS_ipc, '\0', tmp_s);
- if (getsockname(pwfd_ipc, aiPS_ipc->ai_addr, &(aiPS_ipc->ai_addrlen)) < 0) {
+ if (getsockname(pwfd_ipc, (struct sockaddr *) &PS_ipc, &tmp_s) < 0) {
debugs(54, 0, "ipcCreate: getsockname: " << xstrerror());
ipcSend(cwfd, err_string, strlen(err_string));
goto cleanup;
}
- PS_ipc = *aiPS_ipc;
-
- debugs(54, 3, "ipcCreate: FD " << pwfd_ipc << " sockaddr " << PS_ipc);
+ debugs(54, 3, "ipcCreate: FD " << pwfd_ipc << " sockaddr " << inet_ntoa(PS_ipc.sin_addr) << ":" << ntohs(PS_ipc.sin_port));
- CS_ipc.InitAddrInfo(aiCS_ipc);
+ tmp_s = sizeof(CS_ipc);
+ memset(&CS_ipc, '\0', tmp_s);
- if (getsockname(crfd_ipc, aiCS_ipc->ai_addr, &(aiCS_ipc->ai_addrlen)) < 0) {
+ if (getsockname(crfd_ipc, (struct sockaddr *) &CS_ipc, &tmp_s) < 0) {
debugs(54, 0, "ipcCreate: getsockname: " << xstrerror());
ipcSend(cwfd, err_string, strlen(err_string));
goto cleanup;
}
- CS_ipc = *aiCS_ipc;
-
- debugs(54, 3, "ipcCreate: FD " << crfd_ipc << " sockaddr " << CS_ipc);
+ debugs(54, 3, "ipcCreate: FD " << crfd_ipc << " sockaddr " << inet_ntoa(CS_ipc.sin_addr) << ":" << ntohs(CS_ipc.sin_port));
- if (comm_connect_addr(pwfd_ipc, CS_ipc) == COMM_ERROR) {
+ if (comm_connect_addr(pwfd_ipc, &CS_ipc) == COMM_ERROR) {
ipcSend(cwfd, err_string, strlen(err_string));
goto cleanup;
}
fd = crfd;
- if (comm_connect_addr(crfd_ipc, PS_ipc) == COMM_ERROR) {
+ if (comm_connect_addr(crfd_ipc, &PS_ipc) == COMM_ERROR) {
ipcSend(cwfd, err_string, strlen(err_string));
goto cleanup;
}
Index: squid3/src/ipcache.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ipcache.cc,v
retrieving revision 1.25.2.1
retrieving revision 1.25.2.2
diff -u -r1.25.2.1 -r1.25.2.2
--- squid3/src/ipcache.cc 25 Jan 2008 02:33:47 -0000 1.25.2.1
+++ squid3/src/ipcache.cc 27 Jan 2008 18:08:54 -0000 1.25.2.2
@@ -1,6 +1,6 @@
/*
- * $Id: ipcache.cc,v 1.25.2.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: ipcache.cc,v 1.25.2.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
@@ -40,7 +40,6 @@
#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
-#include "IPAddress.h"
typedef struct _ipcache_entry ipcache_entry;
@@ -57,9 +56,6 @@
struct timeval request_time;
dlink_node lru;
unsigned short locks;
-#if DNS_CNAME
- unsigned short cname_wait;
-#endif
struct
{
@@ -82,10 +78,6 @@
int misses;
int negative_hits;
int numeric_hits;
- int rr_a;
- int rr_aaaa;
- int rr_cname;
- int cname_only;
int invalid;
}
IpcacheStats;
@@ -98,7 +90,7 @@
#else
static IDNSCB ipcacheHandleReply;
#endif
-static IPH ipcacheHandleCnameRecurse;
+static IPH dummy_handler;
static int ipcacheExpiredEntry(ipcache_entry *);
static int ipcache_testname(void);
#if USE_DNSSERVERS
@@ -110,7 +102,7 @@
static void ipcacheLockEntry(ipcache_entry *);
static void ipcacheStatPrint(ipcache_entry *, StoreEntry *);
static void ipcacheUnlockEntry(ipcache_entry *);
-static void ipcacheRelease(ipcache_entry *, bool dofree = true);
+static void ipcacheRelease(ipcache_entry *);
static ipcache_addrs static_addrs;
static hash_table *ip_table = NULL;
@@ -141,24 +133,13 @@
/* removes the given ipcache entry */
static void
-ipcacheRelease(ipcache_entry * i, bool dofree)
+ipcacheRelease(ipcache_entry * i)
{
- if(!i) {
- debugs(14, 0, "ipcacheRelease: Releasing entry with i=");
- return;
- }
-
- if(!i || !i->hash.key) {
- debugs(14, 0, "ipcacheRelease: Releasing entry without hash link!");
- return;
- }
-
debugs(14, 3, "ipcacheRelease: Releasing entry for '" << (const char *) i->hash.key << "'");
hash_remove_link(ip_table, (hash_link *) i);
dlinkDelete(&i->lru, &lru_list);
- if(dofree)
- ipcacheFreeEntry(i);
+ ipcacheFreeEntry(i);
}
static ipcache_entry *
@@ -257,23 +238,10 @@
{
hash_link *e = (hash_link *)hash_lookup(ip_table, i->hash.key);
-#if DNS_CNAME
- /* INET6 : should NOT be adding this entry until all CNAME have been received. */
- assert(i->cname_wait == 0);
-#endif
-
if (NULL != e) {
/* avoid colission */
ipcache_entry *q = (ipcache_entry *) e;
-#if DNS_CNAME
- if(q == i) {
- /* can occur with Multiple-depth CNAME Recursion if parent returned early with additional */
- /* just need to drop from the hash without releasing actual memory */
- ipcacheRelease(q, false);
- }
- else
-#endif
- ipcacheRelease(q);
+ ipcacheRelease(q);
}
hash_join(ip_table, &i->hash);
@@ -286,7 +254,7 @@
ipcacheCallback(ipcache_entry * i)
{
IPH *callback = i->handler;
- void *cbdata = NULL;
+ void *cbdata;
i->lastref = squid_curtime;
if (!i->handler)
@@ -375,14 +343,11 @@
if (ipcount > 0) {
int j, k;
- i->addrs.in_addrs = (IPAddress *)xcalloc(ipcount, sizeof(IPAddress));
- for(int l = 0; l < ipcount; l++)
- i->addrs.in_addrs[l].SetEmpty(); // perform same init actions as constructor would.
+ i->addrs.in_addrs = (struct IN_ADDR *)xcalloc(ipcount, sizeof(struct IN_ADDR));
i->addrs.bad_mask = (unsigned char *)xcalloc(ipcount, sizeof(unsigned char));
- memset(i->addrs.bad_mask, 0, sizeof(unsigned char) * ipcount);
for (j = 0, k = 0; k < ipcount; k++) {
- if ( i->addrs.in_addrs[j] = A[k] )
+ if (safe_inet_addr(A[k], &i->addrs.in_addrs[j]))
j++;
else
debugs(14, 1, "ipcacheParse: Invalid IP address '" << A[k] << "' in response to '" << name << "'");
@@ -414,20 +379,15 @@
ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_message)
{
int k;
- int j = 0;
+ int j;
int na = 0;
int ttl = 0;
const char *name = (const char *)i->hash.key;
- int cname_found = 0;
-
i->expires = squid_curtime + Config.negativeDnsTtl;
i->flags.negcached = 1;
safe_free(i->addrs.in_addrs);
- assert(i->addrs.in_addrs == NULL);
safe_free(i->addrs.bad_mask);
- assert(i->addrs.bad_mask == NULL);
safe_free(i->error_message);
- assert(i->error_message == NULL);
i->addrs.count = 0;
if (nr < 0) {
@@ -439,129 +399,53 @@
if (nr == 0) {
debugs(14, 3, "ipcacheParse: No DNS records in response to '" << name << "'");
i->error_message = xstrdup("No DNS records");
- return -1;
+ return 0;
}
assert(answers);
for (k = 0; k < nr; k++) {
+ if (answers[k].type != RFC1035_TYPE_A)
+ continue;
-#if USE_IPV6
- if (answers[k].type == RFC1035_TYPE_AAAA) {
- if (answers[k].rdlength != sizeof(struct in6_addr)) {
- debugs(14, 1, "ipcacheParse: Invalid IPv6 address in response to '" << name << "'");
- continue;
- }
- na++;
- IpcacheStats.rr_aaaa++;
- continue;
- }
-#endif
-
- if (answers[k].type == RFC1035_TYPE_A) {
- if (answers[k].rdlength != sizeof(struct in_addr)) {
- debugs(14, 1, "ipcacheParse: Invalid IPv4 address in response to '" << name << "'");
- continue;
- }
- na++;
- IpcacheStats.rr_a++;
- continue;
- }
-
- /* With A and AAAA, the CNAME does not necessarily come with additional records to use. */
- if (answers[k].type == RFC1035_TYPE_CNAME) {
- cname_found=1;
- IpcacheStats.rr_cname++;
-
-#if DNS_CNAME
- debugs(14, 5, "ipcacheParse: " << name << " CNAME " << answers[k].rdata << " (checking destination: " << i << ").");
- const ipcache_addrs *res = ipcache_gethostbyname(answers[k].rdata, 0);
- if(res) {
- na += res->count;
- debugs(14, 5, "ipcacheParse: CNAME " << answers[k].rdata << " already has " << res->count << " IPs cached.");
- }
- else {
- /* keep going on this, but flag the fact that we need to wait for a CNAME lookup to finish */
- debugs(14, 5, "ipcacheParse: CNAME " << answers[k].rdata << " has no IPs! Recursing.");
- ipcache_nbgethostbyname(answers[k].rdata, ipcacheHandleCnameRecurse, new generic_cbdata(i) );
- i->cname_wait++;
- }
-#endif /* DNS_CNAME */
+ if (answers[k]._class != RFC1035_CLASS_IN)
+ continue;
+ if (answers[k].rdlength != 4) {
+ debugs(14, 1, "ipcacheParse: Invalid IP address in response to '" << name << "'");
continue;
}
- // otherwise its an unknown RR. debug at level 9 since we usually want to ignore these and they are common.
- debugs(14, 9, HERE << "Unknown RR type received: type=" << answers[k].type << " starting at " << &(answers[k]) );
- }
-
-#if DNS_CNAME
- if(na == 0 && i->cname_wait >0 ) {
- /* don't set any error message (yet). Allow recursion to do its work first. */
- IpcacheStats.cname_only++;
- return 0;
+ na++;
}
-#endif /* DNS_CNAME */
if (na == 0) {
debugs(14, 1, "ipcacheParse: No Address records in response to '" << name << "'");
i->error_message = xstrdup("No Address records");
- if(cname_found)
- IpcacheStats.cname_only++;
return 0;
}
- i->addrs.in_addrs = (IPAddress *)xcalloc(na, sizeof(IPAddress));
- for(int l = 0; l < na; l++)
- i->addrs.in_addrs[l].SetEmpty(); // perform same init actions as constructor would.
+ i->addrs.in_addrs = (struct IN_ADDR *)xcalloc(na, sizeof(struct IN_ADDR));
i->addrs.bad_mask = (unsigned char *)xcalloc(na, sizeof(unsigned char));
for (j = 0, k = 0; k < nr; k++) {
+ if (answers[k]._class != RFC1035_CLASS_IN)
+ continue;
if (answers[k].type == RFC1035_TYPE_A) {
- if (answers[k].rdlength != sizeof(struct in_addr))
+ if (answers[k].rdlength != 4)
continue;
- struct in_addr temp;
- xmemcpy(&temp, answers[k].rdata, sizeof(struct in_addr));
- i->addrs.in_addrs[j] = temp;
-
- debugs(14, 3, "ipcacheParse: " << name << " #" << j << " " << i->addrs.in_addrs[j]);
- j++;
-
-#if USE_IPV6
- } else if (answers[k].type == RFC1035_TYPE_AAAA) {
- if (answers[k].rdlength != sizeof(struct in6_addr))
- continue;
+ xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4);
- struct in6_addr temp;
- xmemcpy(&temp, answers[k].rdata, sizeof(struct in6_addr));
- i->addrs.in_addrs[j] = temp;
+ debugs(14, 3, "ipcacheParse: #" << j - 1 << " " << inet_ntoa(i->addrs.in_addrs[j - 1]));
- debugs(14, 3, "ipcacheParse: " << name << " #" << j << " " << i->addrs.in_addrs[j] );
- j++;
-#endif
- }
-#if DNS_CNAME
- else if (answers[k].type == RFC1035_TYPE_CNAME) {
- debugs(14, 3, "ipcacheParse: " << name << " #x CNAME " << answers[k].rdata);
- const ipcache_addrs *res = ipcache_gethostbyname(answers[k].rdata, 0);
- if(res) {
- /* NP: the results of *that* query need to be integrated in place of the CNAME */
- /* Ideally we should also integrate the min TTL of the above IPA's into ttl. */
- for(int l = 0; l < res->count; l++, j++) {
- i->addrs.in_addrs[j] = res->in_addrs[l];
- debugs(14, 3, "ipcacheParse: " << name << " #" << j << " " << i->addrs.in_addrs[j] );
- }
- }
- else {
- debugs(14, 9, "ipcacheParse: " << answers[k].rdata << " (CNAME) waiting on A/AAAA records.");
- }
- }
-#endif /* DNS_CNAME */
+ } else if (answers[k].type != RFC1035_TYPE_CNAME)
+ continue;
if (ttl == 0 || (int) answers[k].ttl < ttl)
ttl = answers[k].ttl;
+
}
assert(j == na);
@@ -581,15 +465,7 @@
i->flags.negcached = 0;
-#if DNS_CNAME
- /* SPECIAL CASE: may get here IFF CNAME received with Additional records */
- /* reurn 0/'wait for further details' value. */
- /* NP: 'No DNS Results' is a return -1 +msg */
- if(i->cname_wait)
- return 0;
- else
-#endif /* DNS_CNAME */
- return i->addrs.count;
+ return i->addrs.count;
}
#endif
@@ -601,7 +477,6 @@
ipcacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_message)
#endif
{
- int done;
ipcache_entry *i;
static_cast(data)->unwrap(&i);
IpcacheStats.replies++;
@@ -609,19 +484,14 @@
tvSubMsec(i->request_time, current_time));
#if USE_DNSSERVERS
- done = ipcacheParse(i, reply);
+ ipcacheParse(i, reply);
#else
- done = ipcacheParse(i, answers, na, error_message);
-
- /* If we have not produced either IPs or Error immediately, wait for recursion to finish. */
- if(done != 0 || error_message != NULL)
+ ipcacheParse(i, answers, na, error_message);
#endif
- {
- ipcacheAddEntry(i);
- ipcacheCallback(i);
- }
+ ipcacheAddEntry(i);
+ ipcacheCallback(i);
}
void
@@ -643,7 +513,6 @@
}
if ((addrs = ipcacheCheckNumeric(name))) {
- debugs(14, 4, "ipcache_nbgethostbyname: BYPASS for '" << name << "' (already numeric)");
dns_error_message = NULL;
IpcacheStats.numeric_hits++;
handler(addrs, handlerData);
@@ -713,8 +582,7 @@
memset(&static_addrs, '\0', sizeof(ipcache_addrs));
- static_addrs.in_addrs = (IPAddress *)xcalloc(1, sizeof(IPAddress));
- static_addrs.in_addrs->SetEmpty(); // properly setup the IPAddress!
+ static_addrs.in_addrs = (struct IN_ADDR *)xcalloc(1, sizeof(struct IN_ADDR));
static_addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char));
ipcache_high = (long) (((float) Config.ipcache.size *
(float) Config.ipcache.high) / (float) 100);
@@ -769,7 +637,7 @@
IpcacheStats.misses++;
if (flags & IP_LOOKUP_IF_MISS)
- ipcache_nbgethostbyname(name, ipcacheHandleCnameRecurse, NULL);
+ ipcache_nbgethostbyname(name, dummy_handler, NULL);
return NULL;
}
@@ -778,19 +646,6 @@
ipcacheStatPrint(ipcache_entry * i, StoreEntry * sentry)
{
int k;
- int count = i->addrs.count;
- char buf[MAX_IPSTRLEN];
-
- if(!sentry) {
- debugs(14, 0, HERE << "CRITICAL: sentry is NULL!");
- }
-
- if(!i) {
- debugs(14, 0, HERE << "CRITICAL: ipcache_entry is NULL!");
- storeAppendPrintf(sentry, "CRITICAL ERROR\n");
- return;
- }
-
storeAppendPrintf(sentry, " %-32.32s %c%c %6d %6d %2d(%2d)",
hashKeyStr(&i->hash),
i->flags.fromhosts ? 'H' : ' ',
@@ -800,27 +655,12 @@
(int) i->addrs.count,
(int) i->addrs.badcount);
- /** \par
- * Negative-cached entries have no IPs listed. */
- if(i->flags.negcached) {
- storeAppendPrintf(sentry, "\n");
- return;
+ for (k = 0; k < (int) i->addrs.count; k++) {
+ storeAppendPrintf(sentry, " %15s-%3s", inet_ntoa(i->addrs.in_addrs[k]),
+ i->addrs.bad_mask[k] ? "BAD" : "OK ");
}
- /** \par
- * Cached entries have IPs listed with a BNF of: '-' ('OK'|'BAD') */
- for (k = 0; k < count; k++) {
- /* Display tidy-up: IPv6 are so big make the list vertical */
- if(k == 0)
- storeAppendPrintf(sentry, " %45.45s-%3s\n",
- i->addrs.in_addrs[k].NtoA(buf,MAX_IPSTRLEN),
- i->addrs.bad_mask[k] ? "BAD" : "OK ");
- else
- storeAppendPrintf(sentry, "%s %45.45s-%3s\n",
- " ", /* blank-space indenting IP list */
- i->addrs.in_addrs[k].NtoA(buf,MAX_IPSTRLEN),
- i->addrs.bad_mask[k] ? "BAD" : "OK ");
- }
+ storeAppendPrintf(sentry, "\n");
}
/* process objects list */
@@ -842,245 +682,25 @@
IpcacheStats.numeric_hits);
storeAppendPrintf(sentry, "IPcache Misses: %d\n",
IpcacheStats.misses);
- storeAppendPrintf(sentry, "IPcache Retrieved A: %d\n",
- IpcacheStats.rr_a);
- storeAppendPrintf(sentry, "IPcache Retrieved AAAA: %d\n",
- IpcacheStats.rr_aaaa);
- storeAppendPrintf(sentry, "IPcache Retrieved CNAME: %d\n",
- IpcacheStats.rr_cname);
- storeAppendPrintf(sentry, "IPcache CNAME-Only Response: %d\n",
- IpcacheStats.cname_only);
storeAppendPrintf(sentry, "IPcache Invalid Request: %d\n",
IpcacheStats.invalid);
storeAppendPrintf(sentry, "\n\n");
storeAppendPrintf(sentry, "IP Cache Contents:\n\n");
- storeAppendPrintf(sentry, " %-31.31s %3s %6s %6s %4s\n",
+ storeAppendPrintf(sentry, " %-29.29s %3s %6s %6s %1s\n",
"Hostname",
"Flg",
"lstref",
"TTL",
- "N(b)");
+ "N");
- for (m = lru_list.head; m; m = m->next) {
- assert( m->next != m );
+ for (m = lru_list.head; m; m = m->next)
ipcacheStatPrint((ipcache_entry *)m->data, sentry);
- }
-}
-
-#if DNS_CNAME
-/**
- * Takes two IPAddress arrays and merges them into a single array
- * which is allocated dynamically to fit the number of unique addresses
- *
- \param aaddrs One list to merge
- \param alen Size of list aaddrs
- \param baddrs Other list to merge
- \param alen Size of list baddrs
- \param out Combined list of unique addresses (sorted with IPv6 first in IPv6-mode)
- \param outlen Size of list out
- */
-void
-ipcacheMergeIPLists(const IPAddress *aaddrs, const int alen,
- const IPAddress *baddrs, const int blen,
- IPAddress **out, int &outlen )
-{
- int fc=0, t=0, c=0;
-
- IPAddress const *ip4ptrs[255];
-#if USE_IPV6
- IPAddress const *ip6ptrs[255];
-#endif
- int num_ip4 = 0;
- int num_ip6 = 0;
-
- memset(ip4ptrs, 0, sizeof(IPAddress*)*255);
-#if USE_IPV6
- memset(ip6ptrs, 0, sizeof(IPAddress*)*255);
-#endif
-
- // for each unique address in list A - grab ptr
- for(t = 0; t < alen; t++) {
- if(aaddrs[t].IsIPv4()) {
- // check against IPv4 pruned list
- for(c = 0; c <= num_ip4; c++) {
- if(ip4ptrs[c] && aaddrs[t] == *(ip4ptrs[c]) ) break; // duplicate.
- }
- if(c > num_ip4) {
- ip4ptrs[num_ip4] = &aaddrs[t];
- num_ip4++;
- }
- }
-#if USE_IPV6
- else if(aaddrs[t].IsIPv6()) {
-debugs(14,8, HERE << "A[" << t << "]=IPv6 " << aaddrs[t]);
- // check against IPv6 pruned list
- for(c = 0; c <= num_ip6; c++) {
- if(ip6ptrs[c] && aaddrs[t] == *ip6ptrs[c]) break; // duplicate.
- }
- if(c > num_ip6) {
- ip6ptrs[num_ip6] = &aaddrs[t];
- num_ip6++;
- }
- }
-#endif
- }
-
- // for each unique address in list B - grab ptr
- for(t = 0; t < blen; t++) {
- if(baddrs[t].IsIPv4()) {
- // check against IPv4 pruned list
- for(c = 0; c <= num_ip4; c++) {
- if(ip4ptrs[c] && baddrs[t] == *ip4ptrs[c]) break; // duplicate.
- }
- if(c > num_ip4) {
- ip4ptrs[num_ip4] = &baddrs[t];
- num_ip4++;
- }
- }
-#if USE_IPV6
- else if(baddrs[t].IsIPv6()) {
- // check against IPv6 pruned list
- for(c = 0; c <= num_ip6; c++) {
- if(ip6ptrs[c] && baddrs[t] == *ip6ptrs[c]) break; // duplicate.
- }
- if(c > num_ip6) {
- ip6ptrs[num_ip6] = &baddrs[t];
- num_ip6++;
- }
- }
-#endif
- }
-
- fc = num_ip6 + num_ip4;
-
- assert(fc > 0);
-
- debugs(14, 5, "ipcacheMergeIPLists: Merge " << alen << "+" << blen << " into " << fc << " unique IPs.");
-
- // copy the old IPs into the new list buffer.
- (*out) = (IPAddress*)xcalloc(fc, sizeof(IPAddress));
- outlen=0;
-
- assert(out != NULL);
-
-#if USE_IPV6
- /* IPv6 are preferred (tried first) over IPv4 */
-
- for(int l = 0; outlen < num_ip6; l++, outlen++) {
- (*out)[outlen] = *ip6ptrs[l];
- debugs(14, 5, "ipcacheMergeIPLists: #" << outlen << " " << (*out)[outlen] );
- }
-#endif /* USE_IPV6 */
-
- for(int l = 0; outlen < num_ip4; l++, outlen++) {
- (*out)[outlen] = *ip4ptrs[l];
- debugs(14, 5, "ipcacheMergeIPLists: #" << outlen << " " << (*out)[outlen] );
- }
-
- assert(outlen == fc); // otherwise something broke badly!
}
-#endif /* DNS_CNAME */
static void
-ipcacheHandleCnameRecurse(const ipcache_addrs *addrs, void *cbdata)
+dummy_handler(const ipcache_addrs * addrsnotused, void *datanotused)
{
-#if DNS_CNAME
- ipcache_entry *i = NULL;
- char *pname = NULL;
- IPAddress *tmpbuf = NULL;
- int fc = 0;
- int ttl = 0;
- generic_cbdata* gcb = (generic_cbdata*)cbdata;
- // count of addrs at parent and child (REQ as .count is a char type!)
- int ccount = 0, pcount = 0;
-
- debugs(14, 5, "ipcacheHandleCnameRecurse: Handling basic A/AAAA response.");
-
- /* IFF no CNAME recursion being processed. do nothing. */
- if(cbdata == NULL)
- return;
-
- gcb->unwrap(&i);
- assert(i != NULL);
-
- // make sure we are actualy waiting for a CNAME callback to be run.
- assert(i->cname_wait > 0);
- // count this event. its being handled.
- i->cname_wait--;
-
- pname = (char*)i->hash.key;
- assert(pname != NULL);
-
- debugs(14, 5, "ipcacheHandleCnameRecurse: Handling CNAME recursion. CBDATA('" << gcb->data << "')='" << pname << "' -> " << std::hex << i);
-
- if(i == NULL) {
- return; // Parent has expired. Don't merge, just leave for future Ref:
- }
-
- /* IFF addrs is NULL (Usually an Error or Timeout occured on lookup.) */
- /* Ignore it and HOPE that we got some Additional records to use. */
- if(addrs == NULL)
- return;
-
- ccount = (0+ addrs->count);
- pcount = (0+ i->addrs.count);
- ttl = i->expires;
-
- /* IFF no CNAME results. do none of the processing BUT finish anyway. */
- if(addrs) {
-
- debugs(14, 5, "ipcacheHandleCnameRecurse: Merge IP Lists for " << pname << " (" << pcount << "+" << ccount << ")");
-
- /* add new IP records to entry */
- tmpbuf = i->addrs.in_addrs;
- i->addrs.in_addrs = NULL;
- ipcacheMergeIPLists(tmpbuf, pcount, addrs->in_addrs, ccount, &(i->addrs.in_addrs), fc);
- debugs(14,8, HERE << "in=" << tmpbuf << ", out=" << i->addrs.in_addrs );
- assert( (pcount>0 ? tmpbuf!=NULL : tmpbuf==NULL) );
- safe_free(tmpbuf);
-
- if( pcount > 0) {
- /* IFF the parent initial lookup was given Additional records with A */
- // clear the 'bad IP mask'
- safe_free(i->addrs.bad_mask);
- }
- // create a new bad IP mask to fit the new size needed.
- if(fc > 0) {
- i->addrs.bad_mask = (unsigned char*)xcalloc(fc, sizeof(unsigned char));
- memset(i->addrs.bad_mask, 0, sizeof(unsigned char)*fc);
- }
-
- if (fc < 256)
- i->addrs.count = (unsigned char) fc;
- else
- i->addrs.count = 255;
-
- if (ttl == 0 || ttl > Config.positiveDnsTtl)
- ttl = Config.positiveDnsTtl;
-
- if (ttl < Config.negativeDnsTtl)
- ttl = Config.negativeDnsTtl;
-
- i->expires = squid_curtime + ttl;
-
- i->flags.negcached = 0;
-
- i->addrs.cur = 0;
-
- i->addrs.badcount = 0;
- }
-
- if(fc == 0) {
- i->error_message = xstrdup("No DNS Records");
- }
-
- /* finish the lookup we were doing on parent when we got side-tracked for CNAME loop */
- if(i->cname_wait == 0) {
- ipcacheAddEntry(i);
- ipcacheCallback(i);
- }
- // else still more CNAME to be found.
-#endif /* DNS_CNAME */
+ return;
}
void
@@ -1120,29 +740,17 @@
ipcacheCheckNumeric(const char *name)
{
- IPAddress ip;
+ struct IN_ADDR ip;
/* check if it's already a IP address in text form. */
- /* it may be IPv6-wrapped */
- if(name[0] == '[') {
- char *tmp = xstrdup(&name[1]);
- tmp[strlen(tmp)-1] = '\0';
- if (!(ip = tmp)) {
- delete tmp;
- return NULL;
- }
- delete tmp;
- }
- else if (!(ip = name))
+ if (!safe_inet_addr(name, &ip))
return NULL;
- debugs(14, 4, "ipcacheCheckNumeric: HIT_BYPASS for '" << name << "' == " << ip );
-
static_addrs.count = 1;
static_addrs.cur = 0;
- static_addrs.in_addrs[0] = ip;
+ static_addrs.in_addrs[0].s_addr = ip.s_addr;
static_addrs.bad_mask[0] = FALSE;
@@ -1163,11 +771,7 @@
static void
ipcacheUnlockEntry(ipcache_entry * i)
{
- if(i->locks < 1) {
- debugs(14, 1, "WARNING: ipcacheEntry unlocked with no lock! locks=" << i->locks);
- return;
- }
-
+ assert(i->locks > 0);
i->locks--;
if (ipcacheExpiredEntry(i))
@@ -1211,7 +815,7 @@
ia->cur = 0;
}
- debugs(14, 3, "ipcacheCycleAddr: " << name << " now at " << ia->in_addrs[ia->cur] << " (" << ia->cur << " of " << ia->count << ")");
+ debugs(14, 3, "ipcacheCycleAddr: " << name << " now at " << inet_ntoa(ia->in_addrs[ia->cur]));
}
/*
@@ -1219,7 +823,8 @@
* advance the current pointer to the next OK address.
*/
void
-ipcacheMarkBadAddr(const char *name, IPAddress &addr)
+
+ipcacheMarkBadAddr(const char *name, struct IN_ADDR addr)
{
ipcache_entry *i;
ipcache_addrs *ia;
@@ -1232,7 +837,7 @@
for (k = 0; k < (int) ia->count; k++)
{
- if (addr == ia->in_addrs[k] )
+ if (ia->in_addrs[k].s_addr == addr.s_addr)
break;
}
@@ -1244,7 +849,7 @@
ia->bad_mask[k] = TRUE;
ia->badcount++;
i->expires = XMIN(squid_curtime + XMAX((time_t)60, Config.negativeDnsTtl), i->expires);
- debugs(14, 2, "ipcacheMarkBadAddr: " << name << " " << addr );
+ debugs(14, 2, "ipcacheMarkBadAddr: " << name << " [" << inet_ntoa(addr) << "]");
}
ipcacheCycleAddr(name, ia);
@@ -1252,7 +857,7 @@
void
-ipcacheMarkGoodAddr(const char *name, IPAddress &addr)
+ipcacheMarkGoodAddr(const char *name, struct IN_ADDR addr)
{
ipcache_entry *i;
ipcache_addrs *ia;
@@ -1265,7 +870,7 @@
for (k = 0; k < (int) ia->count; k++)
{
- if (addr == ia->in_addrs[k])
+ if (ia->in_addrs[k].s_addr == addr.s_addr)
break;
}
@@ -1279,7 +884,7 @@
ia->badcount--;
- debugs(14, 2, "ipcacheMarkGoodAddr: " << name << " " << addr );
+ debugs(14, 2, "ipcacheMarkGoodAddr: " << name << " [" << inet_ntoa(addr) << "]");
}
static void
@@ -1321,18 +926,14 @@
{
ipcache_entry *i;
- IPAddress ip;
+ struct IN_ADDR ip;
- if (!(ip = ipaddr)) {
-#if USE_IPV6
+ if (!safe_inet_addr(ipaddr, &ip)) {
if (strchr(ipaddr, ':') && strspn(ipaddr, "0123456789abcdefABCDEF:") == strlen(ipaddr)) {
debugs(14, 3, "ipcacheAddEntryFromHosts: Skipping IPv6 address '" << ipaddr << "'");
} else {
debugs(14, 1, "ipcacheAddEntryFromHosts: Bad IP address '" << ipaddr << "'");
}
-#else
- debugs(14, 1, "ipcacheAddEntryFromHosts: Bad IP address '" << ipaddr << "'");
-#endif
return 1;
}
@@ -1353,9 +954,9 @@
i->addrs.cur = 0;
i->addrs.badcount = 0;
- i->addrs.in_addrs = (IPAddress *)xcalloc(1, sizeof(IPAddress));
+ i->addrs.in_addrs = (struct IN_ADDR *)xcalloc(1, sizeof(struct IN_ADDR));
i->addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char));
- i->addrs.in_addrs[0] = ip;
+ i->addrs.in_addrs[0].s_addr = ip.s_addr;
i->addrs.bad_mask[0] = FALSE;
i->flags.fromhosts = 1;
ipcacheAddEntry(i);
Index: squid3/src/main.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/main.cc,v
retrieving revision 1.89.6.2
retrieving revision 1.89.6.3
diff -u -r1.89.6.2 -r1.89.6.3
--- squid3/src/main.cc 25 Jan 2008 02:33:47 -0000 1.89.6.2
+++ squid3/src/main.cc 27 Jan 2008 18:08:54 -0000 1.89.6.3
@@ -1,6 +1,6 @@
/*
- * $Id: main.cc,v 1.89.6.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: main.cc,v 1.89.6.3 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
@@ -72,7 +72,6 @@
#include "SwapDir.h"
#include "forward.h"
#include "MemPool.h"
-#include "ICMPSquid.h"
#if USE_WIN32_SERVICE
@@ -562,7 +561,7 @@
#endif
clientdbInit();
- icmpEngine.Open();
+ icmpOpen();
netdbInit();
asnInit();
ACL::Initialize();
@@ -584,7 +583,7 @@
htcpSocketShutdown();
#endif
- icmpEngine.Close();
+ icmpClose();
#ifdef SQUID_SNMP
snmpConnectionShutdown();
@@ -636,7 +635,6 @@
errorClean();
enter_suid(); /* root to read config file */
parseConfigFile(ConfigFile, manager);
- Mem::Report();
setEffectiveUser();
_db_init(Config.Log.log, Config.debugOptions);
ipcache_restart(); /* clear stuck entries */
@@ -695,7 +693,7 @@
static void
mainRotate(void)
{
- icmpEngine.Close();
+ icmpClose();
#if USE_DNSSERVERS
dnsShutdown();
@@ -715,7 +713,7 @@
fwdLogRotate();
#endif
- icmpEngine.Open();
+ icmpOpen();
#if USE_DNSSERVERS
dnsInit();
@@ -828,10 +826,6 @@
if (WIN32_Socks_initialized)
debugs(1, 1, "Windows sockets initialized");
- if (WIN32_OS_version > _WIN_OS_WINNT) {
- WIN32_IpAddrChangeMonitorInit();
- }
-
#endif
if (!configured_once)
@@ -1083,7 +1077,7 @@
sbrk_start = sbrk(0);
#endif
- Debug::parseOptions(NULL);
+ Debug::parseOptions("ALL,1");
debug_log = stderr;
#if defined(SQUID_MAXFD_LIMIT)
@@ -1130,6 +1124,18 @@
if (oldmask)
umask(oldmask);
+ memset(&local_addr, '\0', sizeof(struct IN_ADDR));
+
+ safe_inet_addr(localhost, &local_addr);
+
+ memset(&any_addr, '\0', sizeof(struct IN_ADDR));
+
+ safe_inet_addr("0.0.0.0", &any_addr);
+
+ memset(&no_addr, '\0', sizeof(struct IN_ADDR));
+
+ safe_inet_addr("255.255.255.255", &no_addr);
+
squid_srandom(time(NULL));
getCurrentTime();
@@ -1146,10 +1152,6 @@
mainParseOptions(argc, argv);
- if (opt_parse_cfg_only) {
- Debug::parseOptions("ALL,1");
- }
-
#if USE_WIN32_SERVICE
if (opt_install_service)
@@ -1197,8 +1199,6 @@
parse_err = parseConfigFile(ConfigFile, manager);
- Mem::Report();
-
if (opt_parse_cfg_only)
return parse_err;
@@ -1550,8 +1550,8 @@
pid, WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
syslog(LOG_NOTICE,
- "Squid Parent: child process %d exited due to signal %d with status %d",
- pid, WTERMSIG(status), WEXITSTATUS(status));
+ "Squid Parent: child process %d exited due to signal %d",
+ pid, WTERMSIG(status));
} else {
syslog(LOG_NOTICE, "Squid Parent: child process %d exited", pid);
}
Index: squid3/src/mem.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/mem.cc,v
retrieving revision 1.38.18.2
retrieving revision 1.38.18.3
diff -u -r1.38.18.2 -r1.38.18.3
--- squid3/src/mem.cc 25 Jan 2008 02:33:47 -0000 1.38.18.2
+++ squid3/src/mem.cc 27 Jan 2008 18:08:54 -0000 1.38.18.3
@@ -1,6 +1,6 @@
/*
- * $Id: mem.cc,v 1.38.18.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: mem.cc,v 1.38.18.3 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 13 High Level Memory Pool Management
* AUTHOR: Harvest Derived
@@ -382,6 +382,8 @@
* debug messages here at level 0 or 1 will always be printed
* on stderr.
*/
+ debugs(13, 3, "Memory pools are '" << ((Config.onoff.mem_pools ? "on" : "off")) << "'; limit: "<<
+ std::setprecision(3) << toMB(MemPools::GetInstance().idleLimit()) << " MB");
/* set all pointers to null */
memset(MemPools, '\0', sizeof(MemPools));
@@ -429,15 +431,6 @@
}
void
-Mem::Report()
-{
- debugs(13, 3, "Memory pools are '" <<
- (Config.onoff.mem_pools ? "on" : "off") << "'; limit: " <<
- std::setprecision(3) << toMB(MemPools::GetInstance().idleLimit()) <<
- " MB");
-}
-
-void
Mem::RegisterWithCacheManager(CacheManager & manager)
{
manager.registerAction("mem",
Index: squid3/src/mem_node.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/mem_node.cc,v
retrieving revision 1.11.6.1
retrieving revision 1.11.6.2
diff -u -r1.11.6.1 -r1.11.6.2
--- squid3/src/mem_node.cc 25 Jan 2008 02:33:47 -0000 1.11.6.1
+++ squid3/src/mem_node.cc 27 Jan 2008 18:08:54 -0000 1.11.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: mem_node.cc,v 1.11.6.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: mem_node.cc,v 1.11.6.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 19 Store Memory Primitives
* AUTHOR: Robert Collins
@@ -38,6 +38,7 @@
static int makeMemNodeDataOffset();
+unsigned long mem_node::store_mem_size;
static int _mem_node_data_offset = makeMemNodeDataOffset();
/*
@@ -69,18 +70,14 @@
{}
mem_node::~mem_node()
-{}
-
-size_t
-mem_node::InUseCount()
{
- return Pool().inUseCount();
+ store_mem_size -= nodeBuffer.length;
}
size_t
-mem_node::StoreMemSize()
+mem_node::InUseCount()
{
- return InUseCount() * SM_PAGE_SIZE;
+ return Pool().inUseCount();
}
int64_t
Index: squid3/src/mem_node.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/mem_node.h,v
retrieving revision 1.11.6.1
retrieving revision 1.11.6.2
diff -u -r1.11.6.1 -r1.11.6.2
--- squid3/src/mem_node.h 25 Jan 2008 02:33:47 -0000 1.11.6.1
+++ squid3/src/mem_node.h 27 Jan 2008 18:08:54 -0000 1.11.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: mem_node.h,v 1.11.6.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: mem_node.h,v 1.11.6.2 2008/01/27 18:08:54 rousskov Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
@@ -42,7 +42,7 @@
public:
static size_t InUseCount();
- static size_t StoreMemSize();
+ static unsigned long store_mem_size; /* 0 */
MEMPROXY_CLASS(mem_node);
mem_node(int64_t);
Index: squid3/src/mib.txt
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/mib.txt,v
retrieving revision 1.6.6.1
retrieving revision 1.6.6.2
diff -u -r1.6.6.1 -r1.6.6.2
--- squid3/src/mib.txt 25 Jan 2008 02:33:47 -0000 1.6.6.1
+++ squid3/src/mib.txt 27 Jan 2008 18:08:54 -0000 1.6.6.2
@@ -2,7 +2,7 @@
SQUID-MIB DEFINITIONS ::= BEGIN
--
--- $Id: mib.txt,v 1.6.6.1 2008/01/25 02:33:47 valexey_eykon Exp $
+-- $Id: mib.txt,v 1.6.6.2 2008/01/27 18:08:54 rousskov Exp $
--
IMPORTS
@@ -11,15 +11,12 @@
FROM SNMPv2-SMI
DisplayString
- FROM SNMPv2-TC
-
- InetAddressType, InetAddress
- FROM INET-ADDRESS-MIB;
+ FROM SNMPv2-TC;
nlanr OBJECT IDENTIFIER ::= { enterprises 3495 }
squid MODULE-IDENTITY
- LAST-UPDATED "9708120000Z"
+ LAST-UPDATED "9809220000Z"
ORGANIZATION "National Laboratory for Applied Network Research"
CONTACT-INFO
" Squid Developers
@@ -29,9 +26,6 @@
"Squid MIB defined for the management of the Squid
proxy server. See http://www.squid-cache.org/."
- REVISION "9708120000Z"
- DESCRIPTION
- "Added support for IPv6 Technology."
REVISION "9809220000Z"
DESCRIPTION
"Move to SMIv2. Prepare to split into proxy/squid."
@@ -53,7 +47,7 @@
--
--- cacheSystem group { squid 1 }
+-- cacheSystem group
--
cacheSysVMsize OBJECT-TYPE
@@ -81,7 +75,7 @@
::= { cacheSystem 3 }
--
--- cacheConfig group { squid 2 }
+-- config group
--
-- Contains configuration information including peers etc.
--
@@ -168,7 +162,7 @@
--
--- cachePerformance group { squid 3 }
+-- performance group { squid 3 }
--
cacheSysPerf OBJECT IDENTIFIER ::= { cachePerf 1 }
@@ -537,7 +531,7 @@
::= { cacheMedianSvcEntry 11 }
--
--- cacheNetwork group { squid 4 }
+-- cacheNetwork group
--
-- This material is probably best suited elsewhere, however for now it
-- will reside here until the both the Proxy and Squid MIBs are implimented.
@@ -704,7 +698,7 @@
::= { cacheDns 3 }
--
--- cacheMesh group { squid 5 }
+-- cacheMesh group
--
cachePeerTable OBJECT-TYPE
@@ -722,14 +716,12 @@
STATUS current
DESCRIPTION
" An entry in cachePeerTable "
- INDEX { cachePeerIndex }
+ INDEX { cachePeerAddr }
::= { cachePeerTable 1 }
CachePeerEntry ::= SEQUENCE {
- cachePeerIndex CachePeerIndex,
cachePeerName DisplayString,
- cachePeerAddressType InetAddressType,
- cachePeerAddress InetAddress,
+ cachePeerAddr IpAddress,
cachePeerPortHttp Integer32 (1..65535),
cachePeerPortIcp Integer32 (1..65535),
cachePeerType Integer32,
@@ -743,31 +735,6 @@
cachePeerKeepAlRecv Counter32
}
- CachePeerIndex ::= TEXTUAL-CONVENTION
- DISPLAY-HINT "d"
- STATUS current
- DESCRIPTION
- "A unique value, greater than zero for each
- cache peer instance in the managed
- system. It is recommended that values are assigned
- contiguously starting from 1. The value for each
- cache peer index must remain constant
- at least from one re-initialization of the entity's
- network management system to the next
- re-initialization."
- SYNTAX Integer32 (1..2147483647)
- END
-
-
- cachePeerIndex OBJECT-TYPE
- SYNTAX CachePeerIndex
- MAX-ACCESS read-only
- STATUS current
- DESCRIPTION
- "A unique non-zero value identifying
- the particular cache Peer."
- ::= { cachePeerEntry 1 }
-
cachePeerName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
@@ -775,43 +742,15 @@
DESCRIPTION
" The FQDN name or internal alias for the
peer cache "
- ::= { cachePeerEntry 2 }
-
- cachePeerAddressType OBJECT-TYPE
- SYNTAX InetAddressType
- MAX-ACCESS read-only
- STATUS current
- DESCRIPTION
- "The type of Internet address by which the peer
- cache is reachable."
-
- ::= { cachePeerEntry 3 }
-
- cachePeerAddress OBJECT-TYPE
- SYNTAX InetAddress (SIZE (1..64))
- MAX-ACCESS read-only
- STATUS current
- DESCRIPTION
- "The Internet address for the peer cache. The type of this
- address is determined by the value of the peerAddressType
- object. Note that implementations must limit themselves
- to a single entry in this table per reachable peer.
- The peerAddress may not be empty due to the SIZE
- restriction.
-
- If a row is created administratively by an SNMP
- operation and the address type value is dns(16), then
- the agent stores the DNS name internally. A DNS name
- lookup must be performed on the internally stored DNS
- name whenever it is being used to contact the peer.
-
- If a row is created by the managed entity itself and
- the address type value is dns(16), then the agent
- stores the IP address internally. A DNS reverse lookup
- must be performed on the internally stored IP address
- whenever the value is retrieved via SNMP."
- ::= { cachePeerEntry 4 }
+ ::= { cachePeerEntry 1 }
+ cachePeerAddr OBJECT-TYPE
+ SYNTAX IpAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ " The IP Address of the peer cache "
+ ::= { cachePeerEntry 2 }
cachePeerPortHttp OBJECT-TYPE
SYNTAX Integer32
@@ -819,7 +758,7 @@
STATUS current
DESCRIPTION
" The port the peer listens for HTTP requests "
- ::= { cachePeerEntry 5 }
+ ::= { cachePeerEntry 3 }
cachePeerPortIcp OBJECT-TYPE
SYNTAX Integer32
@@ -828,7 +767,7 @@
DESCRIPTION
" The port the peer listens for ICP requests
should be 0 if not configured to send ICP requests "
- ::= { cachePeerEntry 6 }
+ ::= { cachePeerEntry 4 }
cachePeerType OBJECT-TYPE
SYNTAX INTEGER
@@ -836,7 +775,7 @@
STATUS current
DESCRIPTION
" Peer Type "
- ::= { cachePeerEntry 7 }
+ ::= { cachePeerEntry 5 }
cachePeerState OBJECT-TYPE
SYNTAX INTEGER
@@ -844,7 +783,7 @@
STATUS current
DESCRIPTION
" The operational state of this peer "
- ::= { cachePeerEntry 8 }
+ ::= { cachePeerEntry 6 }
cachePeerPingsSent OBJECT-TYPE
SYNTAX Counter32
@@ -852,7 +791,7 @@
STATUS current
DESCRIPTION
" Number of pings sent to peer "
- ::= { cachePeerEntry 9 }
+ ::= { cachePeerEntry 7 }
cachePeerPingsAcked OBJECT-TYPE
SYNTAX Counter32
@@ -860,7 +799,7 @@
STATUS current
DESCRIPTION
" Number of pings received from peer "
- ::= { cachePeerEntry 10 }
+ ::= { cachePeerEntry 8 }
cachePeerFetches OBJECT-TYPE
SYNTAX Counter32
@@ -868,7 +807,7 @@
STATUS current
DESCRIPTION
" Number of times this peer was selected "
- ::= { cachePeerEntry 11 }
+ ::= { cachePeerEntry 9 }
cachePeerRtt OBJECT-TYPE
SYNTAX Integer32
@@ -876,7 +815,7 @@
STATUS current
DESCRIPTION
" Last known round-trip time to the peer (in ms) "
- ::= { cachePeerEntry 12 }
+ ::= { cachePeerEntry 10 }
cachePeerIgnored OBJECT-TYPE
SYNTAX Counter32
@@ -884,7 +823,7 @@
STATUS current
DESCRIPTION
" How many times this peer was ignored "
- ::= { cachePeerEntry 13 }
+ ::= { cachePeerEntry 11 }
cachePeerKeepAlSent OBJECT-TYPE
SYNTAX Counter32
@@ -892,7 +831,7 @@
STATUS current
DESCRIPTION
" Number of keepalives sent "
- ::= { cachePeerEntry 14 }
+ ::= { cachePeerEntry 12 }
cachePeerKeepAlRecv OBJECT-TYPE
SYNTAX Counter32
@@ -900,7 +839,7 @@
STATUS current
DESCRIPTION
" Number of keepalives received "
- ::= { cachePeerEntry 15 }
+ ::= { cachePeerEntry 13 }
---
--- Table of cache's clients, with statistics. Children caches can be identified
@@ -915,19 +854,17 @@
"A list of cache client entries."
::= { cacheMesh 2 }
-
cacheClientEntry OBJECT-TYPE
SYNTAX CacheClientEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"An entry in cacheClientTable "
- INDEX { cacheClientAddressType, cacheClientAddress }
+ INDEX { cacheClientAddr }
::= { cacheClientTable 1 }
CacheClientEntry ::= SEQUENCE {
- cacheClientAddressType InetAddressType,
- cacheClientAddress InetAddress,
+ cacheClientAddr IpAddress,
cacheClientHttpRequests Counter32,
cacheClientHttpKb Counter32,
cacheClientHttpHits Counter32,
@@ -938,46 +875,21 @@
cacheClientIcpHitKb Counter32
}
- cacheClientAddressType OBJECT-TYPE
- SYNTAX InetAddressType
+ cacheClientAddr OBJECT-TYPE
+ SYNTAX IpAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The client's IP address "
::= { cacheClientEntry 1 }
- cacheClientAddress OBJECT-TYPE
- SYNTAX InetAddress (SIZE (1..64))
- MAX-ACCESS read-only
- STATUS current
- DESCRIPTION
- "The Internet address for the client. The type of this
- address is determined by the value of the peerAddressType
- object. Note that implementations must limit themselves
- to a single entry in this table per reachable peer.
- The peerAddress may not be empty due to the SIZE
- restriction.
-
- If a row is created administratively by an SNMP
- operation and the address type value is dns(16), then
- the agent stores the DNS name internally. A DNS name
- lookup must be performed on the internally stored DNS
- name whenever it is being used to contact the peer.
-
- If a row is created by the managed entity itself and
- the address type value is dns(16), then the agent
- stores the IP address internally. A DNS reverse lookup
- must be performed on the internally stored IP address
- whenever the value is retrieved via SNMP."
- ::= { cacheClientEntry 2 }
-
cacheClientHttpRequests OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
" Number of HTTP requests received from client "
- ::= { cacheClientEntry 3 }
+ ::= { cacheClientEntry 2 }
cacheClientHttpKb OBJECT-TYPE
SYNTAX Counter32
@@ -985,7 +897,7 @@
STATUS current
DESCRIPTION
" Amount of total HTTP traffic to this client "
- ::= { cacheClientEntry 4 }
+ ::= { cacheClientEntry 3 }
cacheClientHttpHits OBJECT-TYPE
SYNTAX Counter32
@@ -993,7 +905,7 @@
STATUS current
DESCRIPTION
" Number of hits in response to this client's HTTP requests "
- ::= { cacheClientEntry 5 }
+ ::= { cacheClientEntry 4 }
cacheClientHTTPHitKb OBJECT-TYPE
SYNTAX Counter32
@@ -1001,7 +913,7 @@
STATUS current
DESCRIPTION
" Amount of HTTP hit traffic in KB "
- ::= { cacheClientEntry 6 }
+ ::= { cacheClientEntry 5 }
cacheClientIcpRequests OBJECT-TYPE
SYNTAX Counter32
@@ -1009,7 +921,7 @@
STATUS current
DESCRIPTION
" Number of ICP requests received from client "
- ::= { cacheClientEntry 7 }
+ ::= { cacheClientEntry 6 }
cacheClientIcpKb OBJECT-TYPE
SYNTAX Counter32
@@ -1017,7 +929,7 @@
STATUS current
DESCRIPTION
" Amount of total ICP traffic to this client (child) "
- ::= { cacheClientEntry 8 }
+ ::= { cacheClientEntry 7 }
cacheClientIcpHits OBJECT-TYPE
SYNTAX Counter32
@@ -1025,7 +937,7 @@
STATUS current
DESCRIPTION
" Number of hits in response to this client's ICP requests "
- ::= { cacheClientEntry 9 }
+ ::= { cacheClientEntry 8 }
cacheClientIcpHitKb OBJECT-TYPE
SYNTAX Counter32
Index: squid3/src/multicast.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/multicast.cc,v
retrieving revision 1.3.22.1
retrieving revision 1.3.22.2
diff -u -r1.3.22.1 -r1.3.22.2
--- squid3/src/multicast.cc 25 Jan 2008 02:33:47 -0000 1.3.22.1
+++ squid3/src/multicast.cc 27 Jan 2008 18:08:54 -0000 1.3.22.2
@@ -1,6 +1,6 @@
/*
- * $Id: multicast.cc,v 1.3.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: multicast.cc,v 1.3.22.2 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 7 Multicast
* AUTHOR: Martin Hamilton
@@ -66,23 +66,15 @@
}
for (i = 0; i < (int) ia->count; i++) {
- debugs(7, 10, "Listening for ICP requests on " << ia->in_addrs[i] );
-
-#if USE_IPV6
- if( ! ia->in_addrs[i].IsIPv4() ) {
- debugs(7, 10, "ERROR: IPv6 Multicast Listen has not been implemented!");
- continue;
- }
-#endif
-
- ia->in_addrs[i].GetInAddr(mr.imr_multiaddr);
-
+ debugs(7, 10, "Listening for ICP requests on " << inet_ntoa(*(ia->in_addrs + i)));
+ mr.imr_multiaddr.s_addr = (ia->in_addrs + i)->s_addr;
mr.imr_interface.s_addr = INADDR_ANY;
x = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+
(char *) &mr, sizeof(struct ip_mreq));
if (x < 0)
- debugs(7, 1, "comm_join_mcast_groups: FD " << fd << ", IP=" << ia->in_addrs[i]);
+ debugs(7, 1, "comm_join_mcast_groups: FD " << fd << ", [" << inet_ntoa(*(ia->in_addrs + i)) << "]");
x = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &c, 1);
Index: squid3/src/neighbors.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/neighbors.cc,v
retrieving revision 1.43.22.3
retrieving revision 1.43.22.4
diff -u -r1.43.22.3 -r1.43.22.4
--- squid3/src/neighbors.cc 25 Jan 2008 02:33:47 -0000 1.43.22.3
+++ squid3/src/neighbors.cc 27 Jan 2008 18:08:54 -0000 1.43.22.4
@@ -1,6 +1,6 @@
/*
- * $Id: neighbors.cc,v 1.43.22.3 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: neighbors.cc,v 1.43.22.4 2008/01/27 18:08:54 rousskov Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
@@ -34,6 +34,7 @@
*/
#include "squid.h"
+#include "ProtoPort.h"
#include "ACLChecklist.h"
#include "event.h"
#include "CacheManager.h"
@@ -45,7 +46,6 @@
#include "PeerSelectState.h"
#include "SquidTime.h"
#include "Store.h"
-#include "IPAddress.h"
/* count mcast group peers every 15 minutes */
#define MCAST_COUNT_RATE 900
@@ -67,7 +67,7 @@
static void peerCountMcastPeersSchedule(peer * p, time_t when);
static IRCB peerCountHandleIcpReply;
-static void neighborIgnoreNonPeer(const IPAddress &, icp_opcode);
+static void neighborIgnoreNonPeer(const struct sockaddr_in *, icp_opcode);
static OBJH neighborDumpPeers;
static OBJH neighborDumpNonPeers;
static void dump_peers(StoreEntry * sentry, peer * peers);
@@ -95,17 +95,20 @@
peer *
-whichPeer(const IPAddress &from)
+
+whichPeer(const struct sockaddr_in * from)
{
int j;
+ u_short port = ntohs(from->sin_port);
+ struct IN_ADDR ip = from->sin_addr;
peer *p = NULL;
- debugs(15, 3, "whichPeer: from " << from);
+ debugs(15, 3, "whichPeer: from " << inet_ntoa(ip) << " port " << port);
for (p = Config.peers; p; p = p->next)
{
for (j = 0; j < p->n_addresses; j++) {
- if (from == p->addresses[j] && from.GetPort() == p->icp.port) {
+ if (ip.s_addr == p->addresses[j].s_addr && port == p->icp.port) {
return p;
}
}
@@ -121,7 +124,7 @@
const struct _domain_type *d = NULL;
for (d = p->typelist; d; d = d->next) {
- if (0 == matchDomainName(request->GetHost(), d->domain))
+ if (0 == matchDomainName(request->host, d->domain))
if (d->type != PEER_NONE)
return d->type;
}
@@ -163,7 +166,7 @@
do_ping = 0;
for (d = p->peer_domain; d; d = d->next) {
- if (0 == matchDomainName(request->GetHost(), d->domain)) {
+ if (0 == matchDomainName(request->host, d->domain)) {
do_ping = d->do_ping;
break;
}
@@ -183,6 +186,8 @@
checklist.my_addr = request->my_addr;
+ checklist.my_port = request->my_port;
+
checklist.request = HTTPMSGLOCK(request);
checklist.accessList = cbdataReference(p->access);
@@ -235,8 +240,9 @@
if (squid_curtime - p->stats.last_query > Config.Timeout.deadPeer)
return 1;
- if (!neighborUp(p))
- return 0;
+ if (p->icp.port == echo_port)
+ if (!neighborUp(p))
+ return 0;
return 1;
}
@@ -485,31 +491,33 @@
void
neighbors_init(void)
{
- IPAddress nul;
- struct addrinfo *AI = NULL;
+
+ struct sockaddr_in name;
+
+ socklen_t len = sizeof(struct sockaddr_in);
+
struct servent *sep = NULL;
const char *me = getMyHostname();
- peer *thisPeer = NULL;
- peer *next = NULL;
+ peer *thisPeer;
+ peer *next;
int fd = theInIcpConnection;
- /* setup addrinfo for use */
- nul.InitAddrInfo(AI);
-
if (fd >= 0) {
- if (getsockname(fd, AI->ai_addr, &AI->ai_addrlen) < 0)
- debugs(15, 1, "getsockname(" << fd << "," << AI->ai_addr << "," << &AI->ai_addrlen << ") failed.");
+ memset(&name, '\0', sizeof(struct sockaddr_in));
+
+ if (getsockname(fd, (struct sockaddr *) &name, &len) < 0)
+ debugs(15, 1, "getsockname(" << fd << "," << &name << "," << &len << ") failed.");
for (thisPeer = Config.peers; thisPeer; thisPeer = next) {
- http_port_list *s = NULL;
+ http_port_list *s;
next = thisPeer->next;
if (0 != strcmp(thisPeer->host, me))
continue;
for (s = Config.Sockaddr.http; s; s = s->next) {
- if (thisPeer->http_port != s->s.GetPort())
+ if (thisPeer->http_port != ntohs(s->s.sin_port))
continue;
debugs(15, 1, "WARNING: Peer looks like this host");
@@ -519,6 +527,7 @@
"/" << thisPeer->http_port << "/" <<
thisPeer->icp.port);
+
neighborRemove(thisPeer);
}
}
@@ -533,14 +542,12 @@
echo_hdr.reqnum = 0;
echo_hdr.flags = 0;
echo_hdr.pad = 0;
- nul = *AI;
- nul.GetInAddr( *((struct in_addr*)&echo_hdr.shostid) );
+ echo_hdr.shostid = name.sin_addr.s_addr;
sep = getservbyname("echo", "udp");
echo_port = sep ? ntohs((u_short) sep->s_port) : 7;
}
first_ping = Config.peers;
- nul.FreeAddrInfo(AI);
}
void
@@ -634,7 +641,7 @@
echo_hdr.reqnum = reqnum;
query = _icp_common_t::createMessage(ICP_DECHO, 0, url, reqnum, 0);
icpUdpSend(theOutIcpConnection,
- p->in_addr,
+ &p->in_addr,
query,
LOG_ICP_QUERY,
0);
@@ -648,7 +655,7 @@
query = _icp_common_t::createMessage(ICP_QUERY, flags, url, reqnum, 0);
icpUdpSend(theOutIcpConnection,
- p->in_addr,
+ &p->in_addr,
query,
LOG_ICP_QUERY,
0);
@@ -695,6 +702,39 @@
if ((first_ping = first_ping->next) == NULL)
first_ping = Config.peers;
+#if ALLOW_SOURCE_PING
+ /* only do source_ping if we have neighbors */
+ if (Config.npeers) {
+ const ipcache_addrs *ia = NULL;
+
+ struct sockaddr_in to_addr;
+ char *host = request->host;
+
+ if (!Config.onoff.source_ping) {
+ debugs(15, 6, "neighborsUdpPing: Source Ping is disabled.");
+ } else if ((ia = ipcache_gethostbyname(host, 0))) {
+ debugs(15, 6, "neighborsUdpPing: Source Ping: to " << host << " for '" << url << "'");
+ echo_hdr.reqnum = reqnum;
+
+ if (icmp_sock != -1) {
+ icmpSourcePing(ia->in_addrs[ia->cur], &echo_hdr, url);
+ } else {
+ to_addr.sin_family = AF_INET;
+ to_addr.sin_addr = ia->in_addrs[ia->cur];
+ to_addr.sin_port = htons(echo_port);
+ query = _icp_common_t::createMessage(ICP_SECHO, 0, url, reqnum, 0);
+ icpUdpSend(theOutIcpConnection,
+ &to_addr,
+ query,
+ LOG_ICP_QUERY,
+ 0);
+ }
+ } else {
+ debugs(15, 6, "neighborsUdpPing: Source Ping: unknown host: " << host);
+ }
+ }
+
+#endif
/*
* How many replies to expect?
*/
@@ -928,16 +968,17 @@
static peer *non_peers = NULL;
static void
-neighborIgnoreNonPeer(const IPAddress &from, icp_opcode opcode)
+
+neighborIgnoreNonPeer(const struct sockaddr_in *from, icp_opcode opcode)
{
peer *np;
for (np = non_peers; np; np = np->next)
{
- if (np->in_addr != from)
+ if (np->in_addr.sin_addr.s_addr != from->sin_addr.s_addr)
continue;
- if (np->in_addr.GetPort() != from.GetPort())
+ if (np->in_addr.sin_port != from->sin_port)
continue;
break;
@@ -946,11 +987,11 @@
if (np == NULL)
{
np = (peer *)xcalloc(1, sizeof(peer));
- np->in_addr = from;
- np->icp.port = from.GetPort();
+ np->in_addr.sin_addr = from->sin_addr;
+ np->in_addr.sin_port = from->sin_port;
+ np->icp.port = ntohl(from->sin_port);
np->type = PEER_NONE;
- np->host = new char[MAX_IPSTRLEN];
- from.NtoA(np->host,MAX_IPSTRLEN);
+ np->host = xstrdup(inet_ntoa(from->sin_addr));
np->next = non_peers;
non_peers = np;
}
@@ -990,7 +1031,7 @@
*/
void
-neighborsUdpAck(const cache_key * key, icp_common_t * header, const IPAddress &from)
+neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct sockaddr_in *from)
{
peer *p = NULL;
StoreEntry *entry;
@@ -1092,8 +1133,14 @@
if (p) {
debugs(15, 1, "Ignoring SECHO from neighbor " << p->host);
neighborCountIgnored(p);
+#if ALLOW_SOURCE_PING
+
+ } else if (Config.onoff.source_ping) {
+ mem->ping_reply_callback(NULL, ntype, PROTO_ICP, header, mem->ircb_data);
+#endif
+
} else {
- debugs(15, 1, "Unsolicited SECHO from " << from);
+ debugs(15, 1, "Unsolicited SECHO from " << inet_ntoa(from->sin_addr));
}
} else if (opcode == ICP_DENIED)
{
@@ -1153,33 +1200,24 @@
neighborUp(const peer * p)
{
if (!p->tcp_up) {
- if (!peerProbeConnect((peer *) p)) {
- debugs(15, 8, "neighborUp: DOWN (probed): " << p->host << " (" << p->in_addr << ")");
+ if (!peerProbeConnect((peer *) p))
return 0;
- }
}
/*
* The peer can not be UP if we don't have any IP addresses
* for it.
*/
- if (0 == p->n_addresses) {
- debugs(15, 8, "neighborUp: DOWN (no-ip): " << p->host << " (" << p->in_addr << ")");
+ if (0 == p->n_addresses)
return 0;
- }
- if (p->options.no_query) {
- debugs(15, 8, "neighborUp: UP (no-query): " << p->host << " (" << p->in_addr << ")");
+ if (p->options.no_query)
return 1;
- }
if (p->stats.probe_start != 0 &&
- squid_curtime - p->stats.probe_start > Config.Timeout.deadPeer) {
- debugs(15, 8, "neighborUp: DOWN (dead): " << p->host << " (" << p->in_addr << ")");
+ squid_curtime - p->stats.probe_start > Config.Timeout.deadPeer)
return 0;
- }
- debugs(15, 8, "neighborUp: UP: " << p->host << " (" << p->in_addr << ")");
return 1;
}
@@ -1223,6 +1261,7 @@
{
peer *p = (peer *)data;
+ struct sockaddr_in *ap;
int j;
if (p->n_addresses == 0) {
@@ -1248,13 +1287,16 @@
for (j = 0; j < (int) ia->count && j < PEER_MAX_ADDRESSES; j++) {
p->addresses[j] = ia->in_addrs[j];
- debugs(15, 2, "--> IP address #" << j << ": " << p->addresses[j]);
+ debugs(15, 2, "--> IP address #" << j << ": " << inet_ntoa(p->addresses[j]));
p->n_addresses++;
}
- p->in_addr.SetEmpty();
- p->in_addr = p->addresses[0];
- p->in_addr.SetPort(p->icp.port);
+ ap = &p->in_addr;
+
+ memset(ap, '\0', sizeof(struct sockaddr_in));
+ ap->sin_family = AF_INET;
+ ap->sin_addr = p->addresses[0];
+ ap->sin_port = htons(p->icp.port);
if (p->type == PEER_MULTICAST)
peerCountMcastPeersSchedule(p, 10);
@@ -1351,9 +1393,8 @@
if (squid_curtime - p->stats.last_connect_probe == 0)
return ret;/* don't probe to often */
- IPAddress temp(getOutgoingAddr(NULL));
-
- fd = comm_open(SOCK_STREAM, IPPROTO_TCP, temp, COMM_NONBLOCKING, p->host);
+ fd = comm_open(SOCK_STREAM, IPPROTO_TCP, getOutgoingAddr(NULL),
+ 0, COMM_NONBLOCKING, p->host);
if (fd < 0)
return ret;
@@ -1415,9 +1456,7 @@
LOCAL_ARRAY(char, url, MAX_URL);
assert(p->type == PEER_MULTICAST);
p->mcast.flags.count_event_pending = 0;
- snprintf(url, MAX_URL, "http://");
- p->in_addr.ToURL(url+7, MAX_URL -8 );
- strcat(url, "/");
+ snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr));
fake = storeCreateEntry(url, url, request_flags(), METHOD_GET);
HttpRequest *req = HttpRequest::CreateFromUrl(url);
psstate = new ps_state;
@@ -1436,7 +1475,7 @@
reqnum = icpSetCacheKey((const cache_key *)fake->key);
query = _icp_common_t::createMessage(ICP_QUERY, 0, url, reqnum, 0);
icpUdpSend(theOutIcpConnection,
- p->in_addr,
+ &p->in_addr,
query,
LOG_ICP_QUERY,
0);
@@ -1596,7 +1635,7 @@
dump_peers(StoreEntry * sentry, peer * peers)
{
peer *e = NULL;
- char ntoabuf[MAX_IPSTRLEN];
+
struct _domain_ping *d = NULL;
icp_opcode op;
int i;
@@ -1618,7 +1657,7 @@
for (i = 0; i < e->n_addresses; i++) {
storeAppendPrintf(sentry, "Address[%d] : %s\n", i,
- e->addresses[i].NtoA(ntoabuf,MAX_IPSTRLEN) );
+ inet_ntoa(e->addresses[i]));
}
storeAppendPrintf(sentry, "Status : %s\n",
@@ -1704,7 +1743,7 @@
#if USE_HTCP
void
-neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const IPAddress &from)
+neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const struct sockaddr_in *from)
{
StoreEntry *e = Store::Root().get(key);
MemObject *mem = NULL;
Index: squid3/src/net_db.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/net_db.cc,v
retrieving revision 1.33.6.2
retrieving revision 1.33.6.3
diff -u -r1.33.6.2 -r1.33.6.3
--- squid3/src/net_db.cc 25 Jan 2008 02:33:47 -0000 1.33.6.2
+++ squid3/src/net_db.cc 27 Jan 2008 18:08:55 -0000 1.33.6.3
@@ -1,5 +1,6 @@
+
/*
- * $Id: net_db.cc,v 1.33.6.2 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: net_db.cc,v 1.33.6.3 2008/01/27 18:08:55 rousskov Exp $
*
* DEBUG: section 38 Network Measurement Database
* AUTHOR: Duane Wessels
@@ -53,10 +54,8 @@
#include "forward.h"
#include "SquidTime.h"
#include "wordlist.h"
-#include "IPAddress.h"
#if USE_ICMP
-#include "ICMPSquid.h"
#include "StoreClient.h"
#define NETDB_REQBUF_SZ 4096
@@ -73,7 +72,7 @@
StoreEntry *e;
store_client *sc;
HttpRequest *r;
- int64_t used;
+ off_t used;
size_t buf_sz;
char buf[NETDB_REQBUF_SZ];
int buf_ofs;
@@ -85,10 +84,10 @@
static hash_table *addr_table = NULL;
static hash_table *host_table = NULL;
-IPAddress networkFromInaddr(const IPAddress &a);
+static struct IN_ADDR networkFromInaddr(struct IN_ADDR a);
static void netdbRelease(netdbEntry * n);
-static void netdbHashInsert(netdbEntry * n, IPAddress &addr);
+static void netdbHashInsert(netdbEntry * n, struct IN_ADDR addr);
static void netdbHashDelete(const char *key);
static void netdbHostInsert(netdbEntry * n, const char *hostname);
static void netdbHostDelete(const net_db_name * x);
@@ -113,9 +112,10 @@
static wordlist *peer_names = NULL;
static void
-netdbHashInsert(netdbEntry * n, IPAddress &addr)
+
+netdbHashInsert(netdbEntry * n, struct IN_ADDR addr)
{
- networkFromInaddr(addr).NtoA(n->network, MAX_IPSTRLEN);
+ xstrncpy(n->network, inet_ntoa(networkFromInaddr(addr)), 16);
n->hash.key = n->network;
assert(hash_lookup(addr_table, n->network) == NULL);
hash_join(addr_table, &n->hash);
@@ -249,17 +249,18 @@
}
static netdbEntry *
-netdbLookupAddr(const IPAddress &addr)
+
+netdbLookupAddr(struct IN_ADDR addr)
{
netdbEntry *n;
- char *key = new char[MAX_IPSTRLEN];
- networkFromInaddr(addr).NtoA(key,MAX_IPSTRLEN);
+ char *key = inet_ntoa(networkFromInaddr(addr));
n = (netdbEntry *) hash_lookup(addr_table, key);
return n;
}
static netdbEntry *
-netdbAdd(IPAddress &addr)
+
+netdbAdd(struct IN_ADDR addr)
{
netdbEntry *n;
@@ -278,7 +279,8 @@
static void
netdbSendPing(const ipcache_addrs * ia, void *data)
{
- IPAddress addr;
+
+ struct IN_ADDR addr;
char *hostname = NULL;
static_cast(data)->unwrap(&hostname);
netdbEntry *n;
@@ -334,7 +336,7 @@
if (n->next_ping_time <= squid_curtime) {
debugs(38, 3, "netdbSendPing: pinging " << hostname);
- icmpEngine.DomainPing(addr, hostname);
+ icmpDomainPing(addr, hostname);
n->pings_sent++;
n->next_ping_time = squid_curtime + Config.Netdb.period;
n->last_use_time = squid_curtime;
@@ -343,28 +345,14 @@
xfree(hostname);
}
-IPAddress
-networkFromInaddr(const IPAddress &in)
-{
- IPAddress out;
-
- out = in;
-#if USE_IPV6
+static struct IN_ADDR
- /* in IPv6 the 'network' should be the routing section. */
-
- if( in.IsIPv6() )
- {
- out.ApplyMask(64, AF_INET6);
- debugs(14, 5, "networkFromInaddr : Masked IPv6 Address to " << in << "/64 routing part.");
- return out;
- }
-#endif
+ networkFromInaddr(struct IN_ADDR a)
+{
+ struct IN_ADDR b;
+ b.s_addr = ntohl(a.s_addr);
#if USE_CLASSFUL
- struct in_addr b;
-
- in.GetInAddr(b);
if (IN_CLASSC(b.s_addr))
b.s_addr &= IN_CLASSC_NET;
@@ -373,17 +361,15 @@
else if (IN_CLASSA(b.s_addr))
b.s_addr &= IN_CLASSA_NET;
- out = b;
+#else
+ /* use /24 for everything */
+ b.s_addr &= IN_CLASSC_NET;
#endif
- debugs(14, 5, "networkFromInaddr : Masked IPv4 Address to " << out << "/24.");
-
- /* use /24 for everything under IPv4 */
- out.ApplyMask(24, AF_INET);
- debugs(14, 5, "networkFromInaddr : Masked IPv4 Address to " << in << "/24.");
+ b.s_addr = htonl(b.s_addr);
- return out;
+ return b;
}
static int
@@ -464,17 +450,27 @@
}
static void
-netdbSaveState(void *foo)
+netdbPath(char *path)
{
- if (strcmp(Config.netdbFilename, "none") == 0)
- return;
+ /* this is completely wrong. the netdb location should be memoised
+ * separately from the cache dirs, and also be settable in
+ * squid.conf RBC 20041225
+ */
+ snprintf(path, SQUID_MAXPATHLEN, "%s/netdb_state",
+ dynamic_cast(Config.cacheSwap.swapDirs[0].getRaw())->path);
+}
+static void
+netdbSaveState(void *foo)
+{
+ LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN);
Logfile *lf;
netdbEntry *n;
net_db_name *x;
struct timeval start = current_time;
int count = 0;
+ netdbPath(path);
/*
* This was nicer when we were using stdio, but thanks to
* Solaris bugs, its a bad idea. fopen can fail if more than
@@ -484,11 +480,11 @@
* unlink() is here because there is currently no way to make
* logfileOpen() use O_TRUNC.
*/
- unlink(Config.netdbFilename);
- lf = logfileOpen(Config.netdbFilename, 4096, 0);
+ unlink(path);
+ lf = logfileOpen(path, 4096, 0);
if (NULL == lf) {
- debugs(50, 1, "netdbSaveState: " << Config.netdbFilename << ": " << xstrerror());
+ debugs(50, 1, "netdbSaveState: " << path << ": " << xstrerror());
return;
}
@@ -529,9 +525,7 @@
static void
netdbReloadState(void)
{
- if (strcmp(Config.netdbFilename, "none") == 0)
- return;
-
+ LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN);
char *s;
int fd;
int l;
@@ -540,16 +534,17 @@
netdbEntry *n;
netdbEntry N;
- IPAddress addr;
+ struct IN_ADDR addr;
int count = 0;
struct timeval start = current_time;
+ netdbPath(path);
/*
* This was nicer when we were using stdio, but thanks to
* Solaris bugs, its a bad idea. fopen can fail if more than
* 256 FDs are open.
*/
- fd = file_open(Config.netdbFilename, O_RDONLY | O_BINARY);
+ fd = file_open(path, O_RDONLY | O_BINARY);
if (fd < 0)
return;
@@ -581,7 +576,7 @@
if (NULL == q)
continue;
- if (! (addr = q) )
+ if (!safe_inet_addr(q, &addr))
continue;
if (netdbLookupAddr(addr) != NULL) /* no dups! */
@@ -681,13 +676,11 @@
static void
netdbExchangeHandleReply(void *data, StoreIOBuffer receivedData)
{
- IPAddress addr;
-
netdbExchangeState *ex = (netdbExchangeState *)data;
int rec_sz = 0;
- int o;
+ off_t o;
- struct in_addr line_addr;
+ struct IN_ADDR addr;
double rtt;
double hops;
char *p;
@@ -699,7 +692,7 @@
int oldbufofs = ex->buf_ofs;
rec_sz = 0;
- rec_sz += 1 + sizeof(struct in_addr);
+ rec_sz += 1 + sizeof(addr.s_addr);
rec_sz += 1 + sizeof(int);
rec_sz += 1 + sizeof(int);
debugs(38, 3, "netdbExchangeHandleReply: " << receivedData.length << " read bytes");
@@ -776,7 +769,7 @@
while (size >= rec_sz) {
debugs(38, 5, "netdbExchangeHandleReply: in parsing loop, size = " << size);
- addr.SetAnyAddr();
+ addr.s_addr = any_addr.s_addr;
hops = rtt = 0.0;
for (o = 0; o < rec_sz;) {
@@ -784,10 +777,8 @@
case NETDB_EX_NETWORK:
o++;
- /* FIXME INET6 : NetDB can still ony send IPv4 */
- xmemcpy(&line_addr, p + o, sizeof(struct in_addr));
- addr = line_addr;
- o += sizeof(struct in_addr);
+ xmemcpy(&addr.s_addr, p + o, sizeof(addr.s_addr));
+ o += sizeof(addr.s_addr);
break;
case NETDB_EX_RTT:
@@ -811,7 +802,7 @@
}
}
- if (!addr.IsAnyAddr() && rtt > 0)
+ if (addr.s_addr != any_addr.s_addr && rtt > 0)
netdbExchangeUpdatePeer(addr, ex->p, rtt, hops);
assert(o == rec_sz);
@@ -942,14 +933,15 @@
}
void
-netdbHandlePingReply(const IPAddress &from, int hops, int rtt)
+
+netdbHandlePingReply(const struct sockaddr_in *from, int hops, int rtt)
{
#if USE_ICMP
netdbEntry *n;
int N;
- debugs(38, 3, "netdbHandlePingReply: from " << from);
+ debugs(38, 3, "netdbHandlePingReply: from " << inet_ntoa(from->sin_addr));
- if ((n = netdbLookupAddr(from)) == NULL)
+ if ((n = netdbLookupAddr(from->sin_addr)) == NULL)
return;
N = ++n->pings_recv;
@@ -986,10 +978,9 @@
#endif
}
-
-#if 0 // AYJ: Looks to be unused code.
int
-netdbHops(IPAddress &addr)
+
+netdbHops(struct IN_ADDR addr)
{
#if USE_ICMP
netdbEntry *n = netdbLookupAddr(addr);
@@ -1003,7 +994,6 @@
#endif
return 256;
}
-#endif
void
netdbDump(StoreEntry * sentry)
@@ -1017,7 +1007,7 @@
int j;
net_db_peer *p;
storeAppendPrintf(sentry, "Network DB Statistics:\n");
- storeAppendPrintf(sentry, "%-46.46s %9s %7s %5s %s\n", /* Max between 16 (IPv4) or 46 (IPv6) */
+ storeAppendPrintf(sentry, "%-16.16s %9s %7s %5s %s\n",
"Network",
"recv/sent",
"RTT",
@@ -1041,7 +1031,7 @@
for (k = 0; k < i; k++) {
n = *(list + k);
- storeAppendPrintf(sentry, "%-46.46s %4d/%4d %7.1f %5.1f", /* Max between 16 (IPv4) or 46 (IPv6) */
+ storeAppendPrintf(sentry, "%-16.16s %4d/%4d %7.1f %5.1f",
n->network,
n->pings_recv,
n->pings_sent,
@@ -1129,11 +1119,11 @@
double rtt = (double) irtt;
double hops = (double) ihops;
net_db_peer *p;
- debugs(38, 3, "netdbUpdatePeer: '" << r->GetHost() << "', " << ihops << " hops, " << irtt << " rtt");
- n = netdbLookupHost(r->GetHost());
+ debugs(38, 3, "netdbUpdatePeer: '" << r->host << "', " << ihops << " hops, " << irtt << " rtt");
+ n = netdbLookupHost(r->host);
if (n == NULL) {
- debugs(38, 3, "netdbUpdatePeer: host '" << r->GetHost() << "' not found");
+ debugs(38, 3, "netdbUpdatePeer: host '" << r->host << "' not found");
return;
}
@@ -1158,20 +1148,16 @@
}
void
-netdbExchangeUpdatePeer(IPAddress &addr, peer * e, double rtt, double hops)
+
+netdbExchangeUpdatePeer(struct IN_ADDR addr, peer * e, double rtt, double hops)
{
#if USE_ICMP
netdbEntry *n;
net_db_peer *p;
- debugs(38, 5, "netdbExchangeUpdatePeer: '" << addr << "', "<<
+ debugs(38, 5, "netdbExchangeUpdatePeer: '" << inet_ntoa(addr) << "', "<<
std::setfill('0')<< std::setprecision(2) << hops << " hops, " <<
rtt << " rtt");
- if( !addr.IsIPv4() ) {
- debugs(38, 5, "netdbExchangeUpdatePeer: Aborting peer update for '" << addr << "', NetDB cannot handle IPv6.");
- return;
- }
-
n = netdbLookupAddr(addr);
if (n == NULL)
@@ -1201,7 +1187,7 @@
void
-netdbDeleteAddrNetwork(IPAddress &addr)
+netdbDeleteAddrNetwork(struct IN_ADDR addr)
{
#if USE_ICMP
netdbEntry *n = netdbLookupAddr(addr);
@@ -1222,21 +1208,19 @@
HttpReply *reply = new HttpReply;
#if USE_ICMP
- IPAddress addr;
-
netdbEntry *n;
int i;
int j;
int rec_sz;
char *buf;
- struct in_addr line_addr;
+ struct IN_ADDR addr;
s->buffer();
HttpVersion version(1, 0);
reply->setHeaders(version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2);
s->replaceHttpReply(reply);
rec_sz = 0;
- rec_sz += 1 + sizeof(struct in_addr);
+ rec_sz += 1 + sizeof(addr.s_addr);
rec_sz += 1 + sizeof(int);
rec_sz += 1 + sizeof(int);
buf = (char *)memAllocate(MEM_4K_BUF);
@@ -1250,19 +1234,14 @@
if (n->rtt > 60000) /* RTT > 1 MIN probably bogus */
continue;
- if (! (addr = n->network) )
- continue;
-
- /* FIXME INET6 : NetDB cannot yet handle IPv6 addresses. Ensure only IPv4 get sent. */
- if( !addr.IsIPv4() )
+ if (!safe_inet_addr(n->network, &addr))
continue;
buf[i++] = (char) NETDB_EX_NETWORK;
- addr.GetInAddr(line_addr);
- xmemcpy(&buf[i], &line_addr, sizeof(struct in_addr));
+ xmemcpy(&buf[i], &addr.s_addr, sizeof(addr.s_addr));
- i += sizeof(struct in_addr);
+ i += sizeof(addr.s_addr);
buf[i++] = (char) NETDB_EX_RTT;
@@ -1363,11 +1342,11 @@
const ipcache_addrs *ia;
net_db_peer *h;
int i;
- n = netdbLookupHost(request->GetHost());
+ n = netdbLookupHost(request->host);
if (NULL == n) {
/* try IP addr */
- ia = ipcache_gethostbyname(request->GetHost(), 0);
+ ia = ipcache_gethostbyname(request->host, 0);
if (NULL != ia)
n = netdbLookupAddr(ia->in_addrs[ia->cur]);
Index: squid3/src/pconn.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/pconn.cc,v
retrieving revision 1.19.16.1
retrieving revision 1.19.16.2
diff -u -r1.19.16.1 -r1.19.16.2
--- squid3/src/pconn.cc 25 Jan 2008 02:33:47 -0000 1.19.16.1
+++ squid3/src/pconn.cc 27 Jan 2008 18:08:55 -0000 1.19.16.2
@@ -1,6 +1,6 @@
/*
- * $Id: pconn.cc,v 1.19.16.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: pconn.cc,v 1.19.16.2 2008/01/27 18:08:55 rousskov Exp $
*
* DEBUG: section 48 Persistent Connections
* AUTHOR: Duane Wessels
@@ -139,7 +139,7 @@
{
assert(nfds);
- for (int i=nfds-1; i>=0; i--) {
+ for (int i = 0; i< nfds; i++) {
if (!comm_has_pending_read_callback(fds[i])) {
return fds[i];
}
@@ -175,17 +175,17 @@
/* ========== PconnPool PRIVATE FUNCTIONS ============================================ */
const char *
-PconnPool::key(const char *host, u_short port, const char *domain, IPAddress &client_address)
+
+PconnPool::key(const char *host, u_short port, const char *domain, struct IN_ADDR *client_address)
{
LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN * 2 + 10);
- char ntoabuf[MAX_IPSTRLEN];
- if (domain && !client_address.IsAnyAddr())
- snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d-%s/%s", host, (int) port, client_address.NtoA(ntoabuf,MAX_IPSTRLEN), domain);
- else if (domain && client_address.IsAnyAddr())
+ if (domain && client_address)
+ snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d-%s/%s", host, (int) port, inet_ntoa(*client_address), domain);
+ else if (domain && (!client_address))
snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d/%s", host, (int) port, domain);
- else if ((!domain) && !client_address.IsAnyAddr())
- snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d-%s", host, (int) port, client_address.NtoA(ntoabuf,MAX_IPSTRLEN));
+ else if ((!domain) && client_address)
+ snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d-%s", host, (int) port, inet_ntoa(*client_address));
else
snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d", host, (int) port);
@@ -227,7 +227,8 @@
}
void
-PconnPool::push(int fd, const char *host, u_short port, const char *domain, IPAddress &client_address)
+
+PconnPool::push(int fd, const char *host, u_short port, const char *domain, struct IN_ADDR *client_address)
{
IdleConnList *list;
@@ -274,7 +275,7 @@
*/
int
-PconnPool::pop(const char *host, u_short port, const char *domain, IPAddress &client_address, bool isRetriable)
+PconnPool::pop(const char *host, u_short port, const char *domain, struct IN_ADDR *client_address, bool isRetriable)
{
IdleConnList *list;
const char * aKey = key(host, port, domain, client_address);
@@ -283,7 +284,7 @@
if (list == NULL)
return -1;
- int fd = list->findUseableFD(); // search from the end. skip pending reads.
+ int fd = list->findUseableFD();
if (fd >= 0)
{
Index: squid3/src/pconn.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/pconn.h,v
retrieving revision 1.4.22.1
retrieving revision 1.4.22.2
diff -u -r1.4.22.1 -r1.4.22.2
--- squid3/src/pconn.h 25 Jan 2008 02:33:47 -0000 1.4.22.1
+++ squid3/src/pconn.h 27 Jan 2008 18:08:55 -0000 1.4.22.2
@@ -19,10 +19,10 @@
~IdleConnList();
int numIdle() { return nfds; }
- int findFDIndex(int fd); ///< search from the end of array
+ int findFDIndex(int fd);
void removeFD(int fd);
void push(int fd);
- int findUseableFD(); ///< find first from the end not pending read fd.
+ int findUseableFD();
void clearHandlers(int fd);
private:
@@ -48,15 +48,15 @@
PconnPool(const char *);
void moduleInit();
- void push(int fd, const char *host, u_short port, const char *domain, IPAddress &client_address);
- int pop(const char *host, u_short port, const char *domain, IPAddress &client_address, bool retriable);
+ void push(int fd, const char *host, u_short port, const char *domain, struct IN_ADDR *client_address);
+ int pop(const char *host, u_short port, const char *domain, struct IN_ADDR *client_address, bool retriable);
void count(int uses);
void dumpHist(StoreEntry *e);
void unlinkList(IdleConnList *list) const;
private:
- static const char *key(const char *host, u_short port, const char *domain, IPAddress &client_address);
+ static const char *key(const char *host, u_short port, const char *domain, struct IN_ADDR *client_address);
int hist[PCONN_HIST_SZ];
hash_table *table;
Index: squid3/src/peer_digest.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/peer_digest.cc,v
retrieving revision 1.35.6.1
retrieving revision 1.35.6.2
diff -u -r1.35.6.1 -r1.35.6.2
--- squid3/src/peer_digest.cc 25 Jan 2008 02:33:47 -0000 1.35.6.1
+++ squid3/src/peer_digest.cc 27 Jan 2008 18:08:55 -0000 1.35.6.2
@@ -1,6 +1,6 @@
/*
- * $Id: peer_digest.cc,v 1.35.6.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: peer_digest.cc,v 1.35.6.2 2008/01/27 18:08:55 rousskov Exp $
*
* DEBUG: section 72 Peer Digest Routines
* AUTHOR: Alex Rousskov
@@ -267,7 +267,7 @@
return;
}
- debugs(72, 3, "peerDigestCheck: peer " << pd->peer->host << ":" << pd->peer->http_port);
+ debugs(72, 3, "peerDigestCheck: peer " << pd->peer->host << ":" << pd->peer->http_port);
debugs(72, 3, "peerDigestCheck: time: " << squid_curtime <<
", last received: " << (long int) pd->times.received << " (" <<
std::showpos << (int) (squid_curtime - pd->times.received) << ")");
@@ -724,10 +724,10 @@
fetch->mask_offset += size;
- if (fetch->mask_offset >= pd->cd->mask_size) {
+ if (fetch->mask_offset >= (off_t)pd->cd->mask_size) {
debugs(72, 2, "peerDigestSwapInMask: Done! Got " <<
fetch->mask_offset << ", expected " << pd->cd->mask_size);
- assert(fetch->mask_offset == pd->cd->mask_size);
+ assert(fetch->mask_offset == (off_t)pd->cd->mask_size);
assert(peerDigestFetchedEnough(fetch, NULL, 0, "peerDigestSwapInMask"));
return -1; /* XXX! */
} else {
Index: squid3/src/peer_select.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/peer_select.cc,v
retrieving revision 1.20.22.1
retrieving revision 1.20.22.2
diff -u -r1.20.22.1 -r1.20.22.2
--- squid3/src/peer_select.cc 25 Jan 2008 02:33:47 -0000 1.20.22.1
+++ squid3/src/peer_select.cc 27 Jan 2008 18:08:55 -0000 1.20.22.2
@@ -1,5 +1,6 @@
+
/*
- * $Id: peer_select.cc,v 1.20.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: peer_select.cc,v 1.20.22.2 2008/01/27 18:08:55 rousskov Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
@@ -41,7 +42,6 @@
#include "ACLChecklist.h"
#include "htcp.h"
#include "forward.h"
-#include "SquidTime.h"
const char *hier_strings[] =
{
@@ -159,7 +159,7 @@
if (entry)
debugs(44, 3, "peerSelect: " << entry->url() );
else
- debugs(44, 3, "peerSelect: " << RequestMethodStr(request->method));
+ debugs(44, 3, "peerSelect: " << RequestMethodStr[request->method]);
psstate = new ps_state;
@@ -180,7 +180,9 @@
#endif
if (psstate->entry)
- psstate->entry->lock();
+ psstate->entry->lock()
+
+ ;
peerSelectFoo(psstate);
}
@@ -252,7 +254,7 @@
if (psstate->direct == DIRECT_NO)
return 0;
- myrtt = netdbHostRtt(psstate->request->GetHost());
+ myrtt = netdbHostRtt(psstate->request->host);
debugs(44, 3, "peerCheckNetdbDirect: MY RTT = " << myrtt << " msec");
debugs(44, 3, "peerCheckNetdbDirect: minimum_direct_rtt = " << Config.minDirectRtt << " msec");
@@ -261,7 +263,7 @@
if (myrtt && myrtt <= Config.minDirectRtt)
return 1;
- myhops = netdbHostHops(psstate->request->GetHost());
+ myhops = netdbHostHops(psstate->request->host);
debugs(44, 3, "peerCheckNetdbDirect: MY hops = " << myhops);
debugs(44, 3, "peerCheckNetdbDirect: minimum_direct_hops = " << Config.minDirectHops);
@@ -270,7 +272,7 @@
if (myhops && myhops <= Config.minDirectHops)
return 1;
- p = whichPeer(psstate->closest_parent_miss);
+ p = whichPeer(&psstate->closest_parent_miss);
if (p == NULL)
return 0;
@@ -288,7 +290,7 @@
{
StoreEntry *entry = ps->entry;
HttpRequest *request = ps->request;
- debugs(44, 3, "peerSelectFoo: '" << RequestMethodStr(request->method) << " " << request->GetHost() << "'");
+ debugs(44, 3, "peerSelectFoo: '" << RequestMethodStr[request->method] << " " << request->host << "'");
if (ps->direct == DIRECT_UNKNOWN) {
if (ps->always_direct == 0 && Config.accessList.AlwaysDirect) {
@@ -451,7 +453,7 @@
if (peerCheckNetdbDirect(ps)) {
code = CLOSEST_DIRECT;
- debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << request->GetHost());
+ debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << request->host);
peerAddFwdServer(&ps->servers, NULL, code);
return;
}
@@ -459,15 +461,19 @@
if ((p = ps->hit)) {
code = ps->hit_type == PEER_PARENT ? PARENT_HIT : SIBLING_HIT;
} else
- {
- if (!ps->closest_parent_miss.IsAnyAddr()) {
- p = whichPeer(ps->closest_parent_miss);
- code = CLOSEST_PARENT_MISS;
- } else if (!ps->first_parent_miss.IsAnyAddr()) {
- p = whichPeer(ps->first_parent_miss);
- code = FIRST_PARENT_MISS;
- }
- }
+#if ALLOW_SOURCE_PING
+ if ((p = ps->secho)) {
+ code = SOURCE_FASTEST;
+ } else
+#endif
+ if (ps->closest_parent_miss.sin_addr.s_addr != any_addr.s_addr) {
+ p = whichPeer(&ps->closest_parent_miss);
+ code = CLOSEST_PARENT_MISS;
+ } else if (ps->first_parent_miss.sin_addr.s_addr != any_addr.s_addr) {
+ p = whichPeer(&ps->first_parent_miss);
+ code = FIRST_PARENT_MISS;
+ }
+
if (p && code != HIER_NONE) {
debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host);
peerAddFwdServer(&ps->servers, p, code);
@@ -500,7 +506,7 @@
peer *p;
HttpRequest *request = ps->request;
hier_code code = HIER_NONE;
- debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr(request->method) << " " << request->GetHost());
+ debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr[request->method] << " " << request->host);
if (ps->direct == DIRECT_YES)
return;
@@ -619,7 +625,7 @@
return;
/* set FIRST_MISS if there is no CLOSEST parent */
- if (!ps->closest_parent_miss.IsAnyAddr())
+ if (ps->closest_parent_miss.sin_addr.s_addr != any_addr.s_addr)
return;
rtt = (tvSubMsec(ps->ping.start, current_time) - p->basetime) / p->weight;
@@ -627,7 +633,8 @@
if (rtt < 1)
rtt = 1;
- if (ps->first_parent_miss.IsAnyAddr() || rtt < ps->ping.w_rtt) {
+ if (ps->first_parent_miss.sin_addr.s_addr == any_addr.s_addr ||
+ rtt < ps->ping.w_rtt) {
ps->first_parent_miss = p->in_addr;
ps->ping.w_rtt = rtt;
}
@@ -660,6 +667,14 @@
return;
}
+#if ALLOW_SOURCE_PING
+ else if (op == ICP_SECHO) {
+ psstate->secho = p;
+ peerSelectFoo(psstate);
+ return;
+ }
+
+#endif
if (psstate->ping.n_recv < psstate->ping.n_replies_expected)
return;
@@ -716,7 +731,7 @@
return;
/* set FIRST_MISS if there is no CLOSEST parent */
- if (!ps->closest_parent_miss.IsAnyAddr())
+ if (ps->closest_parent_miss.sin_addr.s_addr != any_addr.s_addr)
return;
rtt = (tvSubMsec(ps->ping.start, current_time) - p->basetime) / p->weight;
@@ -724,7 +739,8 @@
if (rtt < 1)
rtt = 1;
- if (ps->first_parent_miss.IsAnyAddr() || rtt < ps->ping.w_rtt) {
+ if (ps->first_parent_miss.sin_addr.s_addr == any_addr.s_addr ||
+ rtt < ps->ping.w_rtt) {
ps->first_parent_miss = p->in_addr;
ps->ping.w_rtt = rtt;
}
@@ -780,13 +796,16 @@
callback (NULL),
callback_data (NULL),
servers (NULL),
- first_parent_miss(),
- closest_parent_miss(),
hit(NULL),
hit_type(PEER_NONE),
+#if ALLOW_SOURCE_PING
+
+ secho( NULL),
+#endif
acl_checklist (NULL)
{
- ; // no local defaults.
+ memset(&first_parent_miss, '\0', sizeof(first_parent_miss));
+ memset(&closest_parent_miss, '\0', sizeof(closest_parent_miss));
}
ping_data::ping_data() :
Index: squid3/src/pinger.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/pinger.cc,v
retrieving revision 1.15.22.1
retrieving revision 1.15.22.2
diff -u -r1.15.22.1 -r1.15.22.2
--- squid3/src/pinger.cc 25 Jan 2008 02:33:47 -0000 1.15.22.1
+++ squid3/src/pinger.cc 27 Jan 2008 18:08:55 -0000 1.15.22.2
@@ -1,5 +1,6 @@
+
/*
- * $Id: pinger.cc,v 1.15.22.1 2008/01/25 02:33:47 valexey_eykon Exp $
+ * $Id: pinger.cc,v 1.15.22.2 2008/01/27 18:08:55 rousskov Exp $
*
* DEBUG: section 42 ICMP Pinger program
* AUTHOR: Duane Wessels
@@ -39,162 +40,618 @@
#if USE_ICMP
-#include "ICMPv4.h"
-#include "ICMPv6.h"
-#include "ICMPPinger.h"
+/* Native Windows port doesn't have netinet support, so we emulate it.
+ At this time, Cygwin lacks icmp support in its include files, so we need
+ to use the native Windows port definitions.
+ */
+
+#ifndef _SQUID_WIN32_
+
+#include
+#include
+#include
+#include
+
+#define PINGER_TIMEOUT 10
+
+static int socket_from_squid = 0;
+static int socket_to_squid = 1;
+
+#else /* _SQUID_WIN32_ */
+
+#include "fde.h"
#ifdef _SQUID_MSWIN_
#include
#include
-#include "fde.h"
#define PINGER_TIMEOUT 5
-/* windows uses the control socket for feedback to squid */
-#define LINK_TO_SQUID squid_link
+static int socket_to_squid = -1;
+#define socket_from_squid socket_to_squid
-// windows still requires WSAFD but there are too many dependancy problems
-// to just link to win32.cc where it is normally defined.
+#else /* _SQUID_CYGWIN_ */
+#include
+#include
+#include