-
/*
- * $Id$
- *
- * 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
#include "comm/Connection.h"
#include "comm/Loops.h"
#include "event.h"
-#include "structs.h"
+#include "fatal.h"
+#include "SquidConfig.h"
#define WCCP_PORT 2048
#define WCCP_REVISION 0
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);
}
{
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,
// 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");
* Accept the UDP packet
*/
static void
-wccpHandleUdp(int sock, void *not_used)
+wccpHandleUdp(int sock, void *)
{
Ip::Address from;
int len;
}
static void
-wccpHereIam(void *voidnotused)
+wccpHereIam(void *)
{
debugs(80, 6, "wccpHereIam: Called");
wccp_here_i_am.id = last_id;
- comm_udp_send(theWccpConnection,
- &wccp_here_i_am,
- sizeof(wccp_here_i_am),
- 0);
+ double interval = 10.0; // TODO: make this configurable, possibly negotiate with the router.
+ 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)) {
+ int xerrno = errno;
+ debugs(80, 2, "ERROR: failed to send WCCP HERE_I_AM packet: " << xstrerr(xerrno));
+ interval = 2.0;
+ }
if (!eventFind(wccpHereIam, NULL))
- eventAdd("wccpHereIam", wccpHereIam, NULL, 10.0, 1);
+ eventAdd("wccpHereIam", wccpHereIam, NULL, interval, 1);
}
static void
}
#endif /* USE_WCCP */
+