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

Definition at line 39 of file IcmpSquid.cc.

IcmpSquid::~IcmpSquid ( )

Definition at line 44 of file IcmpSquid.cc.

References Close().

Member Function Documentation

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

Definition at line 38 of file Icmp.cc.

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

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

Definition at line 181 of file IcmpSquid.cc.

References debugs, HERE(), S_ICMP_DOM, and SendEcho().

Referenced by netdbSendPing().

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

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 Icmp6::Recv(), Icmp4::Recv(), Icmp6::SendEcho(), and Icmp4::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.
  • Bug:
    If length specified or auto-detected is greater than the possible payload squid will die with an assert.
    This should perhapse be reduced to a truncated payload? or no payload. A WARNING is due anyway.
  • If the send results in ECONNREFUSED or EPIPE errors from helper, will cleanly shutdown the module.
This should try restarting the helper a few times?? before giving up?

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, len, MYNAME, pingerEchoData::opcode, pingerEchoData::payload, PINGER_PAYLOAD_SZ, pingerEchoData::psize, pingerEchoData::to, and xstrerr().

Referenced by DomainPing(), and Open().

Member Data Documentation

int Icmp::icmp_ident

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






Web Site Translations