#include <IcmpSquid.h>
Public Member Functions | |
IcmpSquid () | |
~IcmpSquid () override | |
int | Open () override |
Start pinger helper and initiate control channel. More... | |
void | Close () override |
Shutdown pinger helper and control channel. More... | |
void | DomainPing (Ip::Address &to, const char *domain) |
void | SendEcho (Ip::Address &to, int opcode, const char *payload=nullptr, int len=0) override |
void | Recv (void) override |
Handle ICMP responses. More... | |
Protected Member Functions | |
int | CheckSum (unsigned short *ptr, int size) |
Calculate a packet checksum. More... | |
int | ipHops (int ttl) |
void | Log (const Ip::Address &addr, const uint8_t type, const char *pkt_str, const int rtt, const int hops) |
Log the packet. More... | |
Protected Attributes | |
int | icmp_sock |
int | icmp_ident |
Detailed Description
Implements a non-blocking pseudo-ICMP engine for squid internally.
Rather than doing all the work itself it passes each request off to an external pinger helper and returns results form that helper to squid.
Provides ECHO-REQUEST, ECHO-REPLY in a protocol-neutral manner.
Definition at line 24 of file IcmpSquid.h.
Constructor & Destructor Documentation
◆ IcmpSquid()
IcmpSquid::IcmpSquid | ( | ) |
Definition at line 38 of file IcmpSquid.cc.
◆ ~IcmpSquid()
|
override |
Definition at line 43 of file IcmpSquid.cc.
References Close().
Member Function Documentation
◆ CheckSum()
Definition at line 38 of file Icmp.cc.
References size.
Referenced by Icmp4::SendEcho(), Icmp6::SendEcho(), and IcmpStub::testChecksum().
◆ Close()
|
overridevirtual |
Reimplemented from Icmp.
Definition at line 254 of file IcmpSquid.cc.
References comm_close, DBG_CRITICAL, DBG_IMPORTANT, debugs, getCurrentTime(), hIpc, Icmp::icmp_sock, and pid.
Referenced by ~IcmpSquid(), mainRotate(), Open(), Recv(), SendEcho(), and serverConnectionsClose().
◆ DomainPing()
void IcmpSquid::DomainPing | ( | Ip::Address & | to, |
const char * | domain | ||
) |
Definition at line 177 of file IcmpSquid.cc.
References debugs, S_ICMP_DOM, and SendEcho().
Referenced by netdbSendPing().
◆ ipHops()
Translate TTL to a hop distance
- Parameters
-
ttl negative : n > 33 ttl n(0...32) : 32 >= n >= 1 ttl n(33...62) : 32 >= n >= 1 ttl n(63...64) : 2 >= n >= 1 ttl n(65...128) : 64 >= n >= 1 ttl n(129...192) : 64 >= n >= 1 ttl n(193...) : n < 255
XXX: BUG? ttl<0 can produce high hop values XXX: BUG? ttl>255 can produce zero or negative hop values
Definition at line 67 of file Icmp.cc.
Referenced by Icmp4::Recv(), and IcmpStub::testHops().
◆ Log()
|
protectedinherited |
Definition at line 88 of file Icmp.cc.
References current_time, and debugs.
Referenced by Icmp4::Recv(), Icmp6::Recv(), Icmp4::SendEcho(), and Icmp6::SendEcho().
◆ Open()
|
overridevirtual |
Implements Icmp.
Definition at line 189 of file IcmpSquid.cc.
References assert, SBuf::c_str(), Close(), COMM_SELECT_READ, commUnsetFdTimeout(), DBG_IMPORTANT, debugs, IcmpConfig::enable, Ip::EnableIpv6, fd_note(), hIpc, Icmp::icmp_sock, IcmpCfg, icmpSquidRecv(), IPC_UDP_SOCKET, ipcCreate(), pid, IcmpConfig::program, S_ICMP_ECHO, SendEcho(), Ip::Address::setIPv4(), Ip::Address::setLocalhost(), and Comm::SetSelect().
Referenced by mainRotate(), and serverConnectionsOpen().
◆ Recv()
|
overridevirtual |
If its a test probe from the pinger. Do nothing.
Implements Icmp.
Definition at line 117 of file IcmpSquid.cc.
References Close(), COMM_SELECT_READ, comm_udp_recv(), DBG_IMPORTANT, debugs, F(), pingerReplyData::from, pingerReplyData::hops, Icmp::icmp_sock, icmpSquidRecv(), MYNAME, netdbHandlePingReply(), pingerReplyData::opcode, pingerReplyData::rtt, S_ICMP_DOM, S_ICMP_ECHO, Comm::SetSelect(), and xstrerr().
Referenced by icmpSquidRecv().
◆ SendEcho()
|
overridevirtual |
Construct and Send an ECHO request
- Parameters
-
to Destination address being 'pinged' opcode Specific code for ECHO request, see RFC ????. payload A payload MAY be sent in the ICMP message. Content longer than MAX_PAYLOAD will be truncated. len Length of the payload in bytes if any is to be sent or 0.
- Does nothing if the pinger socket is not available.
- If no payload is given or is set as NULL it will ignore payload and len
- Otherwise if len is 0, uses strlen() to detect length of payload. XXX: This will result in part of the payload being truncated if it contains a NUL character. Or it may result in a buffer over-read if the payload is not NUL-terminated properly.
- If the send results in ECONNREFUSED or EPIPE errors from helper, will cleanly shutdown the module.
All other send errors are ignored.
Implements Icmp.
Definition at line 51 of file IcmpSquid.cc.
References assert, Close(), comm_udp_send(), DBG_IMPORTANT, debugs, Icmp::icmp_sock, MYNAME, pingerEchoData::opcode, pingerEchoData::payload, PINGER_PAYLOAD_SZ, pingerEchoData::psize, pingerEchoData::to, and xstrerr().
Referenced by DomainPing(), and Open().
Member Data Documentation
◆ icmp_ident
|
protectedinherited |
Definition at line 122 of file Icmp.h.
Referenced by Icmp::Icmp(), Icmp::Close(), Icmp4::Open(), Icmp6::Open(), Icmp4::Recv(), Icmp6::Recv(), Icmp4::SendEcho(), and Icmp6::SendEcho().
◆ icmp_sock
|
protectedinherited |
Definition at line 121 of file Icmp.h.
Referenced by Icmp::Icmp(), Icmp::Close(), IcmpPinger::Close(), Close(), Icmp4::Open(), Icmp6::Open(), IcmpPinger::Open(), Open(), Icmp4::Recv(), Icmp6::Recv(), Recv(), Icmp4::SendEcho(), Icmp6::SendEcho(), and SendEcho().
The documentation for this class was generated from the following files:
- src/icmp/IcmpSquid.h
- src/icmp/IcmpSquid.cc