#include <IcmpPinger.h>

Inheritance diagram for IcmpPinger:
Collaboration diagram for IcmpPinger:

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

IcmpPinger::~IcmpPinger ( )
override

Definition at line 31 of file IcmpPinger.cc.

References Close().

Member Function Documentation

◆ CheckSum()

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

Definition at line 38 of file Icmp.cc.

References size.

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

◆ Close()

void IcmpPinger::Close ( void  )
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()

int Icmp::ipHops ( int  ttl)
protectedinherited

Translate TTL to a hop distance

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

int IcmpPinger::Open ( void  )
overridevirtual

◆ Recv()

◆ SendEcho()

void IcmpPinger::SendEcho ( Ip::Address to,
int  opcode,
const char *  payload,
int  len 
)
inlineoverrideprivatevirtual

Construct and Send an ECHO request

Parameters
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.

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

int Icmp::icmp_ident
protectedinherited

◆ icmp_sock

◆ socket_from_squid

int IcmpPinger::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

int IcmpPinger::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:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors