54#if HAVE_SYS_CAPABILITY_H
55#include <sys/capability.h>
70#define LINK_TO_SQUID squid_link
76Win32__WSAFDIsSet(
int fd, fd_set FAR * set)
79 SOCKET s =
F->win32.handle;
81 return __WSAFDIsSet(s, set);
87#define LINK_TO_SQUID 1
91using namespace std::literals::chrono_literals;
116 int icmp4_worker = -1;
117 int icmp6_worker = -1;
130 if (icmp4_worker < 0) {
133 max_fd =
max(max_fd, icmp4_worker);
137 if (icmp6_worker <0 ) {
140 max_fd =
max(max_fd, icmp6_worker);
144 if (icmp4_worker < 0 && icmp6_worker < 0) {
155 max_fd =
max(max_fd, squid_link);
157 if (setgid(getgid()) < 0) {
164 if (setuid(getuid()) < 0) {
185 if (cap_set_proc(caps) != 0) {
203 if (icmp4_worker >= 0) {
204 FD_SET(icmp4_worker, &R);
206 if (icmp6_worker >= 0) {
207 FD_SET(icmp6_worker, &R);
210 FD_SET(squid_link, &R);
213 x = select(max_fd+1, &R,
nullptr,
nullptr, &tv);
223 if (FD_ISSET(squid_link, &R)) {
227 if (icmp6_worker >= 0 && FD_ISSET(icmp6_worker, &R)) {
230 if (icmp4_worker >= 0 && FD_ISSET(icmp4_worker, &R)) {
234 const auto delay = std::chrono::duration_cast<std::chrono::seconds>(timer.
total());
237 debugs(42,
DBG_CRITICAL,
"Closing. No requests in last " << delay.count() <<
" seconds.");
252main(
int argc,
char *argv[])
254 std::cerr << argv[0] <<
": ICMP support not compiled in." << std::endl;
static void NameThisHelper(const char *name)
void Recv(void) override
Handle ICMP responses.
int Open() override
Start pinger helper and initiate control channel.
int Open() override
Start pinger helper and initiate control channel.
void Recv(void) override
Handle ICMP requests from squid, passing to helpers.
void Close() override
Shutdown pinger helper and control channel.
int Open() override
Start and initiate control channel to squid.
virtual void Close()
Shutdown pinger helper and control channel.
Clock::duration total() const
A const & max(A const &lhs, A const &rhs)
#define debugs(SECTION, LEVEL, CONTENT)
static uint32 F(uint32 X, uint32 Y, uint32 Z)
void ProbeTransport(void)
Probe to discover IPv6 capabilities.
IcmpPinger control
pinger helper contains one of these as a global object.
static const auto PingerTimeout
Icmp6 icmp6
pinger helper contains one of these as a global object.
Icmp4 icmp4
pinger helper contains one of these as a global object.
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
const char * xstrerr(int error)