Icmp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 37 ICMP Routines */
10 
11 #ifndef _INCLUDE_ICMP_H
12 #define _INCLUDE_ICMP_H
13 
14 #include "ip/Address.h"
15 
16 #define PINGER_PAYLOAD_SZ 8192
17 
18 #define MAX_PAYLOAD 256 // WAS: SQUIDHOSTNAMELEN
19 #define MAX_PKT4_SZ (sizeof(struct icmphdr) + sizeof(struct icmpEchoData) + 1)
20 #define MAX_PKT6_SZ (sizeof(struct icmp6_hdr) + sizeof(struct icmpEchoData) + 1)
21 
22 #if USE_ICMP
23 
24 /* This is a line-data format struct. DO NOT alter. */
26 {
27  pingerEchoData() { memset(&payload, 0, sizeof(payload)); }
29  unsigned char opcode = '\0';
30  int psize = 0;
32 };
33 
34 /* This is a line-data format struct. DO NOT alter. */
36  pingerReplyData() { memset(&payload, 0, sizeof(payload)); }
38  unsigned char opcode = '\0';
39  int rtt = 0;
40  int hops = 0;
41  int psize = 0;
43 };
44 
45 struct icmpEchoData {
46  struct timeval tv;
47  unsigned char opcode;
49 };
50 
51 extern int icmp_pkts_sent;
52 
53 #endif /* USE_ICMP */
54 
67 class Icmp
68 {
69 public:
70  Icmp();
71  virtual ~Icmp() {}
72 
74  virtual int Open() =0;
75 
77  virtual void Close();
78 
79 #if USE_ICMP
80 
90  virtual void SendEcho(Ip::Address &to, int opcode, const char *payload=NULL, int len=0) =0;
91 
93  virtual void Recv(void) =0;
94 
95 protected:
96  /* shared internal methods */
97 
99  int CheckSum(unsigned short *ptr, int size);
100 
115  int ipHops(int ttl);
116 
118  void Log(const Ip::Address &addr, const uint8_t type, const char* pkt_str, const int rtt, const int hops);
119 
120  /* no use wasting memory */
123 #endif /* USE_ICMP */
124 };
125 
126 #endif
127 
virtual ~Icmp()
Definition: Icmp.h:71
#define PINGER_PAYLOAD_SZ
Definition: Icmp.h:16
int type
Definition: errorpage.cc:152
int icmp_ident
Definition: Icmp.h:122
virtual void Close()
Shutdown pinger helper and control channel.
Definition: Icmp.cc:25
int icmp_sock
Definition: Icmp.h:121
char payload[PINGER_PAYLOAD_SZ]
Definition: Icmp.h:31
virtual int Open()=0
Start pinger helper and initiate control channel.
unsigned char opcode
Definition: Icmp.h:38
char payload[PINGER_PAYLOAD_SZ]
Definition: Icmp.h:42
int size
Definition: ModDevPoll.cc:75
#define NULL
Definition: types.h:166
#define MAX_PAYLOAD
Definition: Icmp.h:18
virtual void SendEcho(Ip::Address &to, int opcode, const char *payload=NULL, int len=0)=0
char payload[MAX_PAYLOAD]
Definition: Icmp.h:48
Ip::Address to
Definition: Icmp.h:28
pingerEchoData()
Definition: Icmp.h:27
unsigned char opcode
Definition: Icmp.h:47
unsigned char opcode
Definition: Icmp.h:29
Ip::Address from
Definition: Icmp.h:37
Icmp()
Definition: Icmp.cc:16
int psize
Definition: Icmp.h:41
int hops
Definition: Icmp.h:40
int psize
Definition: Icmp.h:30
struct timeval tv
Definition: Icmp.h:46
pingerReplyData()
Definition: Icmp.h:36
int CheckSum(unsigned short *ptr, int size)
Calculate a packet checksum.
Definition: Icmp.cc:38
int icmp_pkts_sent
Definition: pinger.cc:94
void Log(const Ip::Address &addr, const uint8_t type, const char *pkt_str, const int rtt, const int hops)
Log the packet.
Definition: Icmp.cc:88
virtual void Recv(void)=0
Handle ICMP responses.
Definition: Icmp.h:68
int ipHops(int ttl)
Definition: Icmp.cc:67

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors