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