|
Squid Web Cache v8/master
|
#include <IcmpSquid.h>
Public Member Functions | |
| IcmpSquid () | |
| ~IcmpSquid () override | |
| int | Open () override |
| Start pinger helper and initiate control channel. | |
| void | Close () override |
| Shutdown pinger helper and control channel. | |
| 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. | |
Protected Member Functions | |
| int | CheckSum (unsigned short *ptr, int size) |
| Calculate a packet checksum. | |
| 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. | |
Protected Attributes | |
| int | icmp_sock |
| int | icmp_ident |
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.
| IcmpSquid::IcmpSquid | ( | ) |
Definition at line 40 of file IcmpSquid.cc.
|
override |
Definition at line 45 of file IcmpSquid.cc.
References Close().
Definition at line 39 of file Icmp.cc.
References size.
Referenced by Icmp4::SendEcho(), Icmp6::SendEcho(), and IcmpStub::testChecksum().
|
overridevirtual |
Reimplemented from Icmp.
Definition at line 283 of file IcmpSquid.cc.
References comm_close, DBG_CRITICAL, DBG_IMPORTANT, debugs, getCurrentTime(), hIpc, Icmp::icmp_sock, pid, and xsend().
Referenced by ~IcmpSquid(), mainRotate(), Open(), Recv(), SendEcho(), and serverConnectionsClose().
| void IcmpSquid::DomainPing | ( | Ip::Address & | to, |
| const char * | domain | ||
| ) |
Definition at line 206 of file IcmpSquid.cc.
References debugs, S_ICMP_DOM, and SendEcho().
Referenced by netdbSendPing().
Translate TTL to a hop distance
| 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 68 of file Icmp.cc.
Referenced by Icmp4::Recv(), and IcmpStub::testHops().
|
protectedinherited |
Definition at line 89 of file Icmp.cc.
References current_time, and debugs.
|
overridevirtual |
Implements Icmp.
Definition at line 218 of file IcmpSquid.cc.
References assert, SBuf::c_str(), Close(), COMM_SELECT_READ, commUnsetFdTimeout(), DBG_IMPORTANT, debugs, IcmpConfig::enable, 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().
|
overridevirtual |
If its a test probe from the pinger. Do nothing.
Implements Icmp.
Definition at line 120 of file IcmpSquid.cc.
References Close(), COMM_SELECT_READ, comm_udp_recv(), DBG_IMPORTANT, debugs, pingerReplyData::from, pingerReplyData::hops, Icmp::icmp_sock, icmpSquidRecv(), MYNAME, netdbHandlePingReply(), pingerReplyData::opcode, pingerReplyData::payload, Ip::Address::port(), pingerReplyData::psize, pingerReplyData::rtt, S_ICMP_DOM, S_ICMP_ECHO, Comm::SetSelect(), and xstrerr().
Referenced by icmpSquidRecv().
|
overridevirtual |
Construct and Send an ECHO request
| 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. |
All other send errors are ignored.
Implements Icmp.
Definition at line 53 of file IcmpSquid.cc.
References Assure, 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().
|
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().
|
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().