#include <IcmpPinger.h>
Public Member Functions | |
IcmpPinger () | |
~IcmpPinger () override | |
int | Open () override |
Start and initiate control channel to squid. More... | |
void | Close () override |
Shutdown pinger helper and control channel. More... | |
void | SendResult (pingerReplyData &preply, int len) |
Send ICMP results back to squid. More... | |
void | Recv (void) override |
Handle ICMP requests from squid, passing to helpers. 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 |
Private Member Functions | |
void | SendEcho (Ip::Address &, int, const char *, int) override |
Private Attributes | |
int | socket_from_squid |
int | socket_to_squid |
Detailed Description
Implements the interface to squid for ICMP operations
Definition at line 18 of file IcmpPinger.h.
Constructor & Destructor Documentation
◆ IcmpPinger()
IcmpPinger::IcmpPinger | ( | ) |
Definition at line 24 of file IcmpPinger.cc.
References socket_from_squid, and socket_to_squid.
◆ ~IcmpPinger()
|
override |
Definition at line 31 of file IcmpPinger.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 150 of file IcmpPinger.cc.
References Icmp::Close(), icmp4, icmp6, and Icmp::icmp_sock.
Referenced by ~IcmpPinger(), main(), Recv(), and SendResult().
◆ 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 46 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(), xstrdup, and xstrerr().
Referenced by main().
◆ Recv()
|
overridevirtual |
Implements Icmp.
Definition at line 165 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, and pingerEchoData::to.
Referenced by main().
◆ SendEcho()
|
inlineoverrideprivatevirtual |
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.
Implements Icmp.
Definition at line 40 of file IcmpPinger.h.
◆ SendResult()
void IcmpPinger::SendResult | ( | pingerReplyData & | preply, |
int | len | ||
) |
Definition at line 218 of file IcmpPinger.cc.
References Close(), DBG_CRITICAL, debugs, socket_to_squid, and xstrerr().
Referenced by Icmp4::Recv(), and Icmp6::Recv().
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(), Close(), IcmpSquid::Close(), Icmp4::Open(), Icmp6::Open(), Open(), IcmpSquid::Open(), Icmp4::Recv(), Icmp6::Recv(), IcmpSquid::Recv(), Icmp4::SendEcho(), Icmp6::SendEcho(), and IcmpSquid::SendEcho().
◆ socket_from_squid
|
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().
◆ socket_to_squid
|
private |
Definition at line 47 of file IcmpPinger.h.
Referenced by IcmpPinger(), Open(), and SendResult().
The documentation for this class was generated from the following files:
- src/icmp/IcmpPinger.h
- src/icmp/IcmpPinger.cc