#include <IcmpSquid.h>

Inheritance diagram for IcmpSquid:
Collaboration diagram for IcmpSquid:

Public Member Functions

 IcmpSquid ()
virtual ~IcmpSquid ()
virtual int Open ()
 Start pinger helper and initiate control channel. More...
virtual void Close ()
 Shutdown pinger helper and control channel. More...
void DomainPing (Ip::Address &to, const char *domain)
virtual void SendEcho (Ip::Address &to, int opcode, const char *payload=NULL, int len=0)
virtual void Recv (void)
 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 39 of file IcmpSquid.cc.

◆ ~IcmpSquid()

IcmpSquid::~IcmpSquid ( )

Definition at line 44 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 stubIcmp::testChecksum().

◆ Close()

void IcmpSquid::Close ( void  )

◆ DomainPing()

void IcmpSquid::DomainPing ( Ip::Address to,
const char *  domain 

Definition at line 178 of file IcmpSquid.cc.

References debugs, HERE(), 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
BUG? ttl<0 can produce high hop values
BUG? ttl>255 can produce zero or negative hop values

Definition at line 67 of file Icmp.cc.

Referenced by Icmp4::Recv(), and stubIcmp::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, debugs, and type.

Referenced by Icmp4::Recv(), Icmp6::Recv(), Icmp4::SendEcho(), and Icmp6::SendEcho().

◆ Open()

◆ Recv()

void IcmpSquid::Recv ( void  )

If its a test probe from the pinger. Do nothing.

Implements Icmp.

Definition at line 118 of file IcmpSquid.cc.

References Close(), COMM_SELECT_READ, comm_udp_recv(), DBG_IMPORTANT, debugs, F(), HERE(), Icmp::icmp_sock, icmpSquidRecv(), MYNAME, netdbHandlePingReply(), NULL, S_ICMP_DOM, S_ICMP_ECHO, Comm::SetSelect(), and xstrerr().

Referenced by icmpSquidRecv().

◆ SendEcho()

void IcmpSquid::SendEcho ( Ip::Address to,
int  opcode,
const char *  payload = NULL,
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.
    This will result in part of the payload being truncated if it contains a NULL character.
    Or it may result in a buffer over-run 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 52 of file IcmpSquid.cc.

References assert, Close(), comm_udp_send(), DBG_IMPORTANT, debugs, HERE(), 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