Go to the documentation of this file.
11 #define SQUID_HELPER 1
56 #if HAVE_SYS_CAPABILITY_H
57 #include <sys/capability.h>
67 #define LINK_TO_SQUID squid_link
73 Win32__WSAFDIsSet(
int fd, fd_set FAR * set)
76 SOCKET s =
F->win32.handle;
78 return __WSAFDIsSet(s, set);
84 #define LINK_TO_SQUID 1
88 using namespace std::literals::chrono_literals;
112 int icmp4_worker = -1;
113 int icmp6_worker = -1;
126 if (icmp4_worker < 0) {
129 max_fd =
max(max_fd, icmp4_worker);
133 if (icmp6_worker <0 ) {
136 max_fd =
max(max_fd, icmp6_worker);
140 if (icmp4_worker < 0 && icmp6_worker < 0) {
151 max_fd =
max(max_fd, squid_link);
153 if (setgid(getgid()) < 0) {
160 if (setuid(getuid()) < 0) {
181 if (cap_set_proc(caps) != 0) {
199 if (icmp4_worker >= 0) {
200 FD_SET(icmp4_worker, &R);
202 if (icmp6_worker >= 0) {
203 FD_SET(icmp6_worker, &R);
206 FD_SET(squid_link, &R);
209 const auto x =
xselect(max_fd+1, &R,
nullptr,
nullptr, &tv);
219 if (FD_ISSET(squid_link, &R)) {
223 if (icmp6_worker >= 0 && FD_ISSET(icmp6_worker, &R)) {
226 if (icmp4_worker >= 0 && FD_ISSET(icmp4_worker, &R)) {
230 const auto delay = std::chrono::duration_cast<std::chrono::seconds>(timer.
total());
233 debugs(42,
DBG_CRITICAL,
"Closing. No requests in last " << delay.count() <<
" seconds.");
248 main(
int,
char *argv[])
250 std::cerr << argv[0] <<
": ICMP support not compiled in." << std::endl;
const char * xstrerr(int error)
static uint32 F(uint32 X, uint32 Y, uint32 Z)
const A & max(A const &lhs, A const &rhs)
int Open() override
Start pinger helper and initiate control channel.
virtual void Close()
Shutdown pinger helper and control channel.
ssize_t xsend(int socketFd, const void *buf, size_t bufLength, int flags)
POSIX send(2) equivalent.
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
int Open() override
Start pinger helper and initiate control channel.
static void NameThisHelper(const char *name)
Icmp6 icmp6
pinger helper contains one of these as a global object.
IcmpPinger control
pinger helper contains one of these as a global object.
static const auto PingerTimeout
void Recv(void) override
Handle ICMP responses.
int xselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
POSIX select(2) equivalent.
int Open() override
Start and initiate control channel to squid.
void Close() override
Shutdown pinger helper and control channel.
Icmp4 icmp4
pinger helper contains one of these as a global object.
void Recv(void) override
Handle ICMP requests from squid, passing to helpers.
Clock::duration total() const
void ProbeTransport(void)
Probe to discover IPv6 capabilities.
#define debugs(SECTION, LEVEL, CONTENT)