]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/icmp/Icmp.h
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 37 ICMP Routines */
11 #ifndef _INCLUDE_ICMP_H
12 #define _INCLUDE_ICMP_H
14 #include "ip/Address.h"
16 #define PINGER_PAYLOAD_SZ 8192
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)
24 /* This is a line-data format struct. DO NOT alter. */
25 struct pingerEchoData
{
29 char payload
[PINGER_PAYLOAD_SZ
];
32 /* This is a line-data format struct. DO NOT alter. */
33 struct pingerReplyData
{
39 char payload
[PINGER_PAYLOAD_SZ
];
45 char payload
[MAX_PAYLOAD
];
48 extern int icmp_pkts_sent
;
53 * Implements the squid interface to access ICMP operations
56 * Child implementations define specific parts of these operations
57 * using these methods as a naming and parameter template.
59 * IcmpSquid - implements the squid side of squid-pinger interface
60 * IcmpPinger - implements the pinger side of the squid-pinger interface
61 * Icmpv4 - implements pinger helper for Icmpv4
62 * Icmpv6 - implements pinger helper for Icmpv6
70 /// Start pinger helper and initiate control channel
71 virtual int Open() =0;
73 /// Shutdown pinger helper and control channel
79 * Construct and Send an ECHO request
81 \param to Destination address being 'pinged'
82 \param opcode Specific code for ECHO request, see RFC ????.
83 \param payload A payload MAY be sent in the ICMP message.
84 * Content longer than MAX_PAYLOAD will be truncated.
85 \param len Length of the payload in bytes if any is to be sent or 0.
87 virtual void SendEcho(Ip::Address
&to
, int opcode
, const char *payload
=NULL
, int len
=0) =0;
89 /// Handle ICMP responses.
90 virtual void Recv(void) =0;
93 /* shared internal methods */
95 /// Calculate a packet checksum
96 int CheckSum(unsigned short *ptr
, int size
);
99 * Translate TTL to a hop distance
101 \param ttl negative : n > 33
102 \param ttl n(0...32) : 32 >= n >= 1
103 \param ttl n(33...62) : 32 >= n >= 1
104 \param ttl n(63...64) : 2 >= n >= 1
105 \param ttl n(65...128) : 64 >= n >= 1
106 \param ttl n(129...192) : 64 >= n >= 1
107 \param ttl n(193...) : n < 255
109 \bug BUG? ttl<0 can produce high hop values
110 \bug BUG? ttl>255 can produce zero or negative hop values
115 void Log(const Ip::Address
&addr
, const uint8_t type
, const char* pkt_str
, const int rtt
, const int hops
);
117 /* no use wasting memory */
120 #endif /* USE_ICMP */