|
Squid Web Cache master
|
#include <IcmpPinger.h>
Public Member Functions | |
| IcmpPinger () | |
| ~IcmpPinger () override | |
| int | Open () override |
| Start and initiate control channel to squid. | |
| void | Close () override |
| Shutdown pinger helper and control channel. | |
| void | SendResult (pingerReplyData &preply, int len) |
| Send ICMP results back to squid. | |
| void | Recv (void) override |
| Handle ICMP requests from squid, passing to helpers. | |
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 |
Private Member Functions | |
| void | SendEcho (Ip::Address &, int, const char *, int) override |
Private Attributes | |
| int | socket_from_squid |
| int | socket_to_squid |
Implements the interface to squid for ICMP operations
Definition at line 18 of file IcmpPinger.h.
| IcmpPinger::IcmpPinger | ( | ) |
Definition at line 26 of file IcmpPinger.cc.
References socket_from_squid, and socket_to_squid.
|
override |
Definition at line 33 of file IcmpPinger.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 154 of file IcmpPinger.cc.
References Icmp::Close(), icmp4, icmp6, Icmp::icmp_sock, and xclose().
Referenced by ~IcmpPinger(), main(), OnTerminate(), Recv(), and SendResult().
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 48 of file IcmpPinger.cc.
References Debug::BanCacheLogUse(), DBG_CRITICAL, DBG_IMPORTANT, Debug::debugOptions, debugs, getCurrentTime(), Icmp::icmp_sock, MYNAME, O_BINARY, socket_from_squid, socket_to_squid, Win32SockCleanup(), xconnect(), xread(), xrecv(), xsend(), xstrdup, xstrerr(), and xwrite().
Referenced by main().
|
overridevirtual |
Implements Icmp.
Definition at line 170 of file IcmpPinger.cc.
References Close(), DBG_CRITICAL, DBG_IMPORTANT, debugs, icmp4, icmp6, Ip::Address::isIPv4(), Ip::Address::isIPv6(), pingerEchoData::opcode, pingerEchoData::payload, PINGER_PAYLOAD_SZ, pingerEchoData::psize, Icmp4::SendEcho(), Icmp6::SendEcho(), socket_from_squid, pingerEchoData::to, and xrecv().
Referenced by main().
|
inlineoverrideprivatevirtual |
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. |
Implements Icmp.
Definition at line 40 of file IcmpPinger.h.
| void IcmpPinger::SendResult | ( | pingerReplyData & | preply, |
| int | len | ||
| ) |
Definition at line 223 of file IcmpPinger.cc.
References Close(), DBG_CRITICAL, debugs, socket_to_squid, xsend(), and xstrerr().
Referenced by Icmp4::Recv(), and Icmp6::Recv().
|
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(), Close(), IcmpSquid::Close(), Icmp4::Open(), Icmp6::Open(), Open(), IcmpSquid::Open(), Icmp4::Recv(), Icmp6::Recv(), IcmpSquid::Recv(), Icmp4::SendEcho(), Icmp6::SendEcho(), and IcmpSquid::SendEcho().
|
private |
Control channel(s) to squid. May be STDIN/STDOUT pipes or an IP socket depending on the OS
Definition at line 46 of file IcmpPinger.h.
Referenced by IcmpPinger(), Open(), and Recv().
|
private |
Definition at line 47 of file IcmpPinger.h.
Referenced by IcmpPinger(), Open(), and SendResult().