]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/icmp/Icmp.h
2 * $Id: ICMP.h,v 1.1 2007/12/14 23:11:45 amosjeffries Exp $
4 * DEBUG: section 37 ICMP Routines
5 * AUTHOR: Duane Wessels, Amos Jeffries
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 #ifndef _INCLUDE_ICMP_H
35 #define _INCLUDE_ICMP_H
38 #include "IPAddress.h"
40 #define PINGER_PAYLOAD_SZ 8192
42 #define MAX_PAYLOAD 256 // WAS: SQUIDHOSTNAMELEN
43 #define MAX_PKT4_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmphdr) + 1)
45 #define MAX_PKT6_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmp6_hdr) + 1)
50 /* This is a line-data format struct. DO NOT alter. */
51 struct pingerEchoData
{
55 char payload
[PINGER_PAYLOAD_SZ
];
58 /* This is a line-data format struct. DO NOT alter. */
59 struct pingerReplyData
{
65 char payload
[PINGER_PAYLOAD_SZ
];
71 char payload
[MAX_PAYLOAD
];
74 SQUIDCEXTERN
int icmp_pkts_sent
;
80 * Implements the squid interface to access ICMP operations
83 * Child implementations define specific parts of these operations
84 * using these methods as a naming and parameter template.
86 * IcmpSquid - implements the squid side of squid-pinger interface
87 * IcmpPinger - implements the pinger side of the squid-pinger interface
88 * Icmpv4 - implements pinger helper for Icmpv4
89 * Icmpv6 - implements pinger helper for Icmpv6
97 /// Start pinger helper and initiate control channel
98 virtual int Open() =0;
100 /// Shutdown pinger helper and control channel
101 virtual void Close();
106 * Construct and Send an ECHO request
108 \param to Destination address being 'pinged'
109 \param opcode Specific code for ECHO request, see RFC ????.
110 \param payload A payload MAY be sent in the ICMP message.
111 * Content longer than MAX_PAYLOAD will be truncated.
112 \param len Length of the payload in bytes if any is to be sent or 0.
114 virtual void SendEcho(IPAddress
&to
, int opcode
, const char *payload
=NULL
, int len
=0) =0;
116 /// Handle ICMP responses.
117 virtual void Recv(void) =0;
120 /* shared internal methods */
122 /// Calculate a packet checksum
123 int CheckSum(unsigned short *ptr
, int size
);
126 * Translate TTL to a hop distance
128 \param ttl negative : n > 33
129 \param ttl n(0...32) : 32 >= n >= 1
130 \param ttl n(33...62) : 32 >= n >= 1
131 \param ttl n(63...64) : 2 >= n >= 1
132 \param ttl n(65...128) : 64 >= n >= 1
133 \param ttl n(129...192) : 64 >= n >= 1
134 \param ttl n(193...) : n < 255
136 \bug BUG? ttl<0 can produce high hop values
137 \bug BUG? ttl>255 can produce zero or negative hop values
142 void Log(const IPAddress
&addr
, const u_int8_t type
, const char* pkt_str
, const int rtt
, const int hops
);
144 /* no use wasting memory */
147 #endif /* USE_ICMP */