#include <Icmp4.h>

Inheritance diagram for Icmp4:
Collaboration diagram for Icmp4:

Public Member Functions

 Icmp4 ()
 
virtual ~Icmp4 ()
 
virtual int Open ()
 Start pinger helper and initiate control channel. More...
 
virtual void SendEcho (Ip::Address &, int, const char *, int)
 
virtual void Recv (void)
 Handle ICMP responses. More...
 
virtual void Close ()
 Shutdown pinger helper and control channel. 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

Class partially implementing RFC 792 - ICMP for IP version 4. Provides ECHO-REQUEST, ECHO-REPLY (secion 4.1)

Definition at line 133 of file Icmp4.h.

Constructor & Destructor Documentation

Icmp4::Icmp4 ( )

Definition at line 56 of file Icmp4.cc.

Icmp4::~Icmp4 ( )
virtual

Definition at line 61 of file Icmp4.cc.

References Icmp::Close().

Member Function Documentation

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

Definition at line 38 of file Icmp.cc.

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

void Icmp::Close ( void  )
virtualinherited

Reimplemented in IcmpSquid, IcmpPinger, and stubIcmp.

Definition at line 25 of file Icmp.cc.

References Icmp::icmp_ident, and Icmp::icmp_sock.

Referenced by IcmpPinger::Close(), main(), ~Icmp4(), and Icmp6::~Icmp6().

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
Bug:

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

Definition at line 88 of file Icmp.cc.

References current_time, and debugs.

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

int Icmp4::Open ( )
virtual

Implements Icmp.

Definition at line 67 of file Icmp4.cc.

References DBG_CRITICAL, DBG_IMPORTANT, debugs, Icmp::icmp_ident, Icmp::icmp_sock, IPPROTO_ICMP, MYNAME, and xstrerr().

Referenced by main().

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

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 84 of file Icmp4.cc.

References addrinfo::ai_addr, addrinfo::ai_addrlen, assert, Icmp::CheckSum(), current_time, DBG_IMPORTANT, debugs, Ip::Address::FreeAddr(), Ip::Address::getAddrInfo(), HERE(), ICMP_ECHO, Icmp::icmp_ident, icmp_pkts_sent, Icmp::icmp_sock, icmphdr, len, LOCAL_ARRAY, Icmp::Log(), MAX_PAYLOAD, MAX_PKT4_SZ, MYNAME, NULL, icmpEchoData::opcode, icmpEchoData::payload, icmpEchoData::tv, and xstrerr().

Referenced by IcmpPinger::Recv().

Member Data Documentation

int Icmp::icmp_ident
protectedinherited

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors