Icmp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmphdr) + 1)
20 #define MAX_PKT6_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmp6_hdr) + 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 
#define PINGER_PAYLOAD_SZ
Definition: Icmp.h:16
char payload[PINGER_PAYLOAD_SZ]
Definition: Icmp.h:31
Definition: Icmp.h:67
int type
Definition: errorpage.cc:78
unsigned char opcode
Definition: Icmp.h:47
hbase_f Log
Definition: StatHist.cc:21
#define MAX_PAYLOAD
Definition: Icmp.h:18
int psize
Definition: Icmp.h:30
static CLCB Close
Definition: Ident.cc:65
int icmp_sock
Definition: Icmp.h:121
void * addr
Definition: membanger.c:46
virtual ~Icmp()
Definition: Icmp.h:71
int icmp_ident
Definition: Icmp.h:122
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
Ip::Address to
Definition: Icmp.h:28
pingerReplyData()
Definition: Icmp.h:36
unsigned char opcode
Definition: Icmp.h:29
Ip::Address from
Definition: Icmp.h:37
pingerEchoData()
Definition: Icmp.h:27
#define NULL
Definition: types.h:166
int size
Definition: ModDevPoll.cc:77
int icmp_pkts_sent
Definition: pinger.cc:94

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors