]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/wccp.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / wccp.cc
index f15ecce12dfe9a87c66c60eb10fa85857f9fbba3..0374b2ca0ab03e25edad971886390394bc6173dc 100644 (file)
@@ -1,35 +1,13 @@
-
 /*
- * DEBUG: section 80    WCCP Support
- * AUTHOR: Glenn Chisholm
- *
- * 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.
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
+
+/* DEBUG: section 80    WCCP Support */
+
 #include "squid.h"
 
 #if USE_WCCP
@@ -37,6 +15,7 @@
 #include "comm/Connection.h"
 #include "comm/Loops.h"
 #include "event.h"
+#include "fatal.h"
 #include "SquidConfig.h"
 
 #define WCCP_PORT 2048
@@ -120,7 +99,7 @@ wccpInit(void)
     last_assign_buckets_change = 0;
     number_caches = 0;
 
-    if (!Config.Wccp.router.IsAnyAddr())
+    if (!Config.Wccp.router.isAnyAddr())
         if (!eventFind(wccpHereIam, NULL))
             eventAdd("wccpHereIam", wccpHereIam, NULL, 5.0, 1);
 }
@@ -130,23 +109,23 @@ wccpConnectionOpen(void)
 {
     debugs(80, 5, "wccpConnectionOpen: Called");
 
-    if (Config.Wccp.router.IsAnyAddr()) {
+    if (Config.Wccp.router.isAnyAddr()) {
         debugs(80, 2, "WCCPv1 disabled.");
         return;
     }
 
-    if ( !Config.Wccp.router.SetIPv4() ) {
+    if ( !Config.Wccp.router.setIPv4() ) {
         debugs(80, DBG_CRITICAL, "WCCPv1 Disabled. Router " << Config.Wccp.router << " is not an IPv4 address.");
         return;
     }
 
-    if ( !Config.Wccp.address.SetIPv4() ) {
+    if ( !Config.Wccp.address.setIPv4() ) {
         debugs(80, DBG_CRITICAL, "WCCPv1 Disabled. Local address " << Config.Wccp.address << " is not an IPv4 address.");
         return;
     }
 
-    Config.Wccp.address.SetPort(WCCP_PORT);
-    Config.Wccp.router.SetPort(WCCP_PORT);
+    Config.Wccp.address.port(WCCP_PORT);
+    Config.Wccp.router.port(WCCP_PORT);
 
     theWccpConnection = comm_open_listener(SOCK_DGRAM,
                                            IPPROTO_UDP,
@@ -164,7 +143,7 @@ wccpConnectionOpen(void)
     // Sadly WCCP only does IPv4
 
     struct sockaddr_in router;
-    Config.Wccp.router.GetSockAddr(router);
+    Config.Wccp.router.getSockAddr(router);
     if (connect(theWccpConnection, (struct sockaddr*)&router, sizeof(router)))
         fatal("Unable to connect WCCP out socket");
 
@@ -195,7 +174,7 @@ wccpConnectionClose(void)
  * Accept the UDP packet
  */
 static void
-wccpHandleUdp(int sock, void *not_used)
+wccpHandleUdp(int sock, void *)
 {
     Ip::Address from;
     int len;
@@ -292,18 +271,18 @@ wccpLowestIP(void)
 }
 
 static void
-wccpHereIam(void *voidnotused)
+wccpHereIam(void *)
 {
     debugs(80, 6, "wccpHereIam: Called");
 
     wccp_here_i_am.id = last_id;
     double interval = 10.0; // TODO: make this configurable, possibly negotiate with the router.
-    errno = 0;
     ssize_t sent = comm_udp_send(theWccpConnection, &wccp_here_i_am, sizeof(wccp_here_i_am), 0);
 
     // if we failed to send the whole lot, try again at a shorter interval (20%)
     if (sent != sizeof(wccp_here_i_am)) {
-        debusg(80, 2, "ERROR: failed to send WCCP HERE_I_AM packet: " << xstrerror());
+        int xerrno = errno;
+        debugs(80, 2, "ERROR: failed to send WCCP HERE_I_AM packet: " << xstrerr(xerrno));
         interval = 2.0;
     }
 
@@ -382,3 +361,4 @@ wccpAssignBuckets(void)
 }
 
 #endif /* USE_WCCP */
+