icmpsock.h

Go to the documentation of this file.
00001 /*
00002  * icmpsock.h
00003  *
00004  * Internet Control Message Protocol socket I/O channel class.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: icmpsock.h,v $
00030  * Revision 1.17  2006/06/21 03:28:41  csoutheren
00031  * Various cleanups thanks for Frederic Heem
00032  *
00033  * Revision 1.16  2005/11/25 03:43:47  csoutheren
00034  * Fixed function argument comments to be compatible with Doxygen
00035  *
00036  * Revision 1.15  2003/09/17 05:41:58  csoutheren
00037  * Removed recursive includes
00038  *
00039  * Revision 1.14  2003/09/17 01:18:02  csoutheren
00040  * Removed recursive include file system and removed all references
00041  * to deprecated coooperative threading support
00042  *
00043  * Revision 1.13  2003/02/11 06:47:19  craigs
00044  * Added missing OpenSocket function
00045  *
00046  * Revision 1.12  2002/09/16 01:08:59  robertj
00047  * Added #define so can select if #pragma interface/implementation is used on
00048  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00049  *
00050  * Revision 1.11  2001/05/22 12:49:32  robertj
00051  * Did some seriously wierd rewrite of platform headers to eliminate the
00052  *   stupid GNU compiler warning about braces not matching.
00053  *
00054  * Revision 1.10  1999/08/07 15:22:20  craigs
00055  * Changed Success to PingSuccess to avoid namespace collision with X define of the same name
00056  *
00057  * Revision 1.9  1999/03/09 02:59:49  robertj
00058  * Changed comments to doc++ compatible documentation.
00059  *
00060  * Revision 1.8  1999/02/16 08:20:48  robertj
00061  * MSVC 6.0 compatibility changes.
00062  *
00063  * Revision 1.7  1998/09/23 06:20:39  robertj
00064  * Added open source copyright license.
00065  *
00066  * Revision 1.6  1998/01/26 00:30:41  robertj
00067  * Added error codes, TTL and data buffer to Ping.
00068  *
00069  * Revision 1.5  1997/02/05 11:52:07  robertj
00070  * Changed current process function to return reference and validate objects descendancy.
00071  *
00072  * Revision 1.4  1996/11/04 03:57:16  robertj
00073  * Rewrite of ping for Win32 support.
00074  *
00075  * Revision 1.3  1996/09/14 13:09:19  robertj
00076  * Major upgrade:
00077  *   rearranged sockets to help support IPX.
00078  *   added indirect channel class and moved all protocols to descend from it,
00079  *   separating the protocol from the low level byte transport.
00080  *
00081  * Revision 1.2  1996/06/03 10:03:22  robertj
00082  * Changed ping to return more parameters.
00083  *
00084  * Revision 1.1  1996/05/15 21:11:16  robertj
00085  * Initial revision
00086  *
00087  */
00088 
00089 #ifndef _PICMPSOCKET
00090 #define _PICMPSOCKET
00091 
00092 #ifdef P_USE_PRAGMA
00093 #pragma interface
00094 #endif
00095 
00096 #include <ptlib/pprocess.h>
00097 
00101 class PICMPSocket : public PIPDatagramSocket
00102 {
00103   PCLASSINFO(PICMPSocket, PIPDatagramSocket);
00104 
00105   public:
00111     PICMPSocket();
00113 
00116 
00117     enum PingStatus {
00118       PingSuccess,         // don't use Success - X11 defines this!
00119       NetworkUnreachable,
00120       HostUnreachable,
00121       PacketTooBig,
00122       RequestTimedOut,
00123       BadRoute,
00124       TtlExpiredTransmit,
00125       TtlExpiredReassembly,
00126       SourceQuench,
00127       MtuChange,
00128       GeneralError,
00129       NumStatuses
00130     };
00131 
00133     class PingInfo {
00134       public:
00136         PingInfo(WORD id = (WORD)PProcess::Current().GetProcessID());
00137 
00140 
00141         WORD identifier;         
00143         WORD sequenceNum;        
00145         BYTE ttl;                
00147         const BYTE * buffer;     
00149         PINDEX bufferSize;       
00151 
00154 
00155         PTimeInterval delay;     
00157         Address remoteAddr;      
00159         Address localAddr;       
00161         PingStatus status;       
00163     };
00165 
00174     BOOL Ping(
00175       const PString & host   
00176     );
00183     BOOL Ping(
00184       const PString & host,   
00185       PingInfo & info         
00186     );
00188 
00189   protected:
00190     const char * GetProtocolName() const;
00191     virtual BOOL OpenSocket();
00192     virtual BOOL OpenSocket(int ipAdressFamily);
00193 
00194 
00195 // Include platform dependent part of class
00196 #ifdef _WIN32
00197 #include "msos/ptlib/icmpsock.h"
00198 #else
00199 #include "unix/ptlib/icmpsock.h"
00200 #endif
00201 };
00202 
00203 #endif
00204 
00205 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:25:02 2008 for PTLib by  doxygen 1.5.1