60 debugs(37, 2,
" Socket Closed. Aborted send to " << pecho.
to <<
", opcode " << opcode <<
", len " << pecho.
psize);
72 else if (payload && len == 0)
73 len = strlen(payload);
82 pecho.
opcode = (
unsigned char) opcode;
87 memcpy(pecho.
payload, payload, len);
91 debugs(37, 2,
"to " << pecho.
to <<
", opcode " << opcode <<
", len " << pecho.
psize);
101 if (xerrno == ECONNREFUSED || xerrno == EPIPE) {
106 }
else if (x != slen) {
123 static int fail_count = 0;
133 if (n < 0 && EAGAIN != errno) {
137 if (xerrno == ECONNREFUSED)
140 if (xerrno == ECONNRESET)
143 if (++fail_count == 10)
156 const auto base =
static_cast<int>(
sizeof(preply) -
sizeof(preply.
payload));
158 debugs(37, 2,
"short reply header (" << n <<
" < " << base <<
"); dropping");
161 const auto avail = n - base;
162 if (avail >
static_cast<int>(
sizeof(preply.
payload))) {
163 debugs(37, 2,
"oversized reply payload (" << avail <<
"); dropping");
166 if (preply.
psize < 0) {
167 debugs(37, 2,
"negative psize (" << preply.
psize <<
"); dropping");
170 if (preply.
psize > avail) {
171 debugs(37, 2,
"truncated reply (psize=" << preply.
psize <<
", avail=" << avail <<
"); dropping");
177 if (n < (base + preply.
psize)) {
178 debugs(37, 2,
"truncated reply datagram; dropping");
189 debugs(37,4,
" ICMP_ECHO of " << preply.
from <<
" gave: hops=" << preply.
hops <<
", rtt=" << preply.
rtt);
193 debugs(37,4,
" DomainPing of " << preply.
from <<
" gave: hops=" << preply.
hops <<
", rtt=" << preply.
rtt);
209 debugs(37, 4,
"'" << domain <<
"' (" << to <<
")");
232 args[0] =
"(pinger)";
273 debugs(37, 4,
"Pinger handle: 0x" << std::hex <<
hIpc << std::dec <<
", PID: " <<
pid);
303 if (WaitForSingleObject(
hIpc, 12000) != WAIT_OBJECT_0) {
#define Assure(condition)
static void icmpSquidRecv(int, void *)
#define PINGER_PAYLOAD_SZ
void DomainPing(Ip::Address &to, const char *domain)
void Close() override
Shutdown pinger helper and control channel.
void Recv(void) override
Handle ICMP responses.
int Open() override
Start pinger helper and initiate control channel.
void SendEcho(Ip::Address &to, int opcode, const char *payload=nullptr, int len=0) override
unsigned short port() const
void commUnsetFdTimeout(int fd)
clear a timeout handler by FD number
int comm_udp_recv(int fd, void *buf, size_t len, int flags)
ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags)
#define debugs(SECTION, LEVEL, CONTENT)
void fd_note(int fd, const char *s)
pid_t ipcCreate(int type, const char *prog, const char *const args[], const char *name, Ip::Address &local_addr, int *rfd, int *wfd, void **hIpc)
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
void netdbHandlePingReply(const Ip::Address &from, int hops, int rtt)
ssize_t xsend(int socketFd, const void *buf, size_t bufLength, int flags)
POSIX send(2) equivalent.
char payload[PINGER_PAYLOAD_SZ]
char payload[PINGER_PAYLOAD_SZ]
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
const char * xstrerr(int error)