--------------------- PatchSet 5918 Date: 2007/10/06 12:50:49 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Add ICMP abstract class for base of ICMP engines to come. Members: src/ICMP.h:1.1->1.1.2.1 src/icmp.cc:1.8.8.13->1.8.8.14 --- /dev/null Fri Oct 12 00:20:27 2007 +++ squid3/src/ICMP.h Fri Oct 12 00:20:27 2007 @@ -0,0 +1,84 @@ +/* + * $Id: ICMP.h,v 1.1.2.1 2007/10/06 12:50:49 amosjeffries Exp $ + * + * DEBUG: section 37 ICMP Routines + * AUTHOR: Duane Wessels, Amos Jeffries + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#ifndef _INCLUDE_ICMP_H +#define _INCLUDE_ICMP_H + +#include "config.h" +#include "IPAddress.h" + +/** + * Implements the squid interface to access ICMP operations + * + * Child implementations define specific parts of these operations + * using these methods as a naming and parameter template. + * + * icmp - implements the squid-side of pinger communications + * icmp4 - implements pinger helper for ICMPv4 + * icmp6 - implements pinger helper for ICMPv6 + */ +class ICMP +{ +public: + ICMP(); + virtual ~ICMP(); + + // Start pinger helper and initiate control channel + virtual void Open() =0; + + /// Shutdown pinger helper and control channel + virtual void Close(); + +#if USE_ICMP + + /// Construct ECHO request + virtual void SendEcho(IPAddress &to, int opcode, const char *payload, int len) =0; + + /// Handle ICMP responses. + virtual void Recv(int unused1, void *unused2) =0; + +private: + /// Send ICMP + virtual void Send(pingerEchoData * pkt, int len) =0; + + int CheckSum(unsigned short *ptr, int size); + int ipHops(int ttl); + + /* no use wasting memory */ + int icmp_sock; + int icmp_ident; +#endif /* USE_ICMP */ +}; + +#endif Index: squid3/src/icmp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/icmp.cc,v retrieving revision 1.8.8.13 retrieving revision 1.8.8.14 diff -u -r1.8.8.13 -r1.8.8.14 --- squid3/src/icmp.cc 23 Aug 2007 04:27:07 -0000 1.8.8.13 +++ squid3/src/icmp.cc 6 Oct 2007 12:50:49 -0000 1.8.8.14 @@ -1,9 +1,9 @@ /* - * $Id: icmp.cc,v 1.8.8.13 2007/08/23 04:27:07 amosjeffries Exp $ + * $Id: icmp.cc,v 1.8.8.14 2007/10/06 12:50:49 amosjeffries Exp $ * * DEBUG: section 37 ICMP Routines - * AUTHOR: Duane Wessels + * AUTHOR: Duane Wessels, Amos Jeffries * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -33,8 +33,8 @@ * */ - #include "squid.h" +#include "ICMP.h" #include "comm.h" #include "SquidTime.h" #include "IPAddress.h"