#include <IcmpSquid.h>

Inheritance diagram for IcmpSquid:
Collaboration diagram for IcmpSquid:

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()

IcmpSquid::~IcmpSquid ( )

Definition at line 43 of file IcmpSquid.cc.

References Close().

Member Function Documentation

◆ CheckSum()

int Icmp::CheckSum ( unsigned short *  ptr,
int  size 

Definition at line 38 of file Icmp.cc.

References size.

Referenced by Icmp4::SendEcho(), Icmp6::SendEcho(), and IcmpStub::testChecksum().

◆ Close()

void IcmpSquid::Close ( void  )

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()

int Icmp::ipHops ( int  ttl)

Translate TTL to a hop distance

ttlnegative : n > 33
ttln(0...32) : 32 >= n >= 1
ttln(33...62) : 32 >= n >= 1
ttln(63...64) : 2 >= n >= 1
ttln(65...128) : 64 >= n >= 1
ttln(129...192) : 64 >= n >= 1
ttln(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()

void Icmp::Log ( const Ip::Address addr,
const uint8_t  type,
const char *  pkt_str,
const int  rtt,
const int  hops 

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()

◆ Recv()

void IcmpSquid::Recv ( void  )

◆ SendEcho()

void IcmpSquid::SendEcho ( Ip::Address to,
int  opcode,
const char *  payload = nullptr,
int  len = 0 

Construct and Send an ECHO request

toDestination address being 'pinged'
opcodeSpecific code for ECHO request, see RFC ????.
payloadA payload MAY be sent in the ICMP message. Content longer than MAX_PAYLOAD will be truncated.
lenLength 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

int Icmp::icmp_ident

◆ icmp_sock

The documentation for this class was generated from the following files:






Web Site Translations