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.16  2005/11/25 03:43:47  csoutheren
00031  * Fixed function argument comments to be compatible with Doxygen
00032  *
00033  * Revision 1.15  2003/09/17 05:41:58  csoutheren
00034  * Removed recursive includes
00035  *
00036  * Revision 1.14  2003/09/17 01:18:02  csoutheren
00037  * Removed recursive include file system and removed all references
00038  * to deprecated coooperative threading support
00039  *
00040  * Revision 1.13  2003/02/11 06:47:19  craigs
00041  * Added missing OpenSocket function
00042  *
00043  * Revision 1.12  2002/09/16 01:08:59  robertj
00044  * Added #define so can select if #pragma interface/implementation is used on
00045  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00046  *
00047  * Revision 1.11  2001/05/22 12:49:32  robertj
00048  * Did some seriously wierd rewrite of platform headers to eliminate the
00049  *   stupid GNU compiler warning about braces not matching.
00050  *
00051  * Revision 1.10  1999/08/07 15:22:20  craigs
00052  * Changed Success to PingSuccess to avoid namespace collision with X define of the same name
00053  *
00054  * Revision 1.9  1999/03/09 02:59:49  robertj
00055  * Changed comments to doc++ compatible documentation.
00056  *
00057  * Revision 1.8  1999/02/16 08:20:48  robertj
00058  * MSVC 6.0 compatibility changes.
00059  *
00060  * Revision 1.7  1998/09/23 06:20:39  robertj
00061  * Added open source copyright license.
00062  *
00063  * Revision 1.6  1998/01/26 00:30:41  robertj
00064  * Added error codes, TTL and data buffer to Ping.
00065  *
00066  * Revision 1.5  1997/02/05 11:52:07  robertj
00067  * Changed current process function to return reference and validate objects descendancy.
00068  *
00069  * Revision 1.4  1996/11/04 03:57:16  robertj
00070  * Rewrite of ping for Win32 support.
00071  *
00072  * Revision 1.3  1996/09/14 13:09:19  robertj
00073  * Major upgrade:
00074  *   rearranged sockets to help support IPX.
00075  *   added indirect channel class and moved all protocols to descend from it,
00076  *   separating the protocol from the low level byte transport.
00077  *
00078  * Revision 1.2  1996/06/03 10:03:22  robertj
00079  * Changed ping to return more parameters.
00080  *
00081  * Revision 1.1  1996/05/15 21:11:16  robertj
00082  * Initial revision
00083  *
00084  */
00085 
00086 #ifndef _PICMPSOCKET
00087 #define _PICMPSOCKET
00088 
00089 #ifdef P_USE_PRAGMA
00090 #pragma interface
00091 #endif
00092 
00093 
00097 class PICMPSocket : public PIPDatagramSocket
00098 {
00099   PCLASSINFO(PICMPSocket, PIPDatagramSocket);
00100 
00101   public:
00107     PICMPSocket();
00109 
00112 
00113     enum PingStatus {
00114       PingSuccess,         // don't use Success - X11 defines this!
00115       NetworkUnreachable,
00116       HostUnreachable,
00117       PacketTooBig,
00118       RequestTimedOut,
00119       BadRoute,
00120       TtlExpiredTransmit,
00121       TtlExpiredReassembly,
00122       SourceQuench,
00123       MtuChange,
00124       GeneralError,
00125       NumStatuses
00126     };
00127 
00129     class PingInfo {
00130       public:
00132         PingInfo(WORD id = (WORD)PProcess::Current().GetProcessID());
00133 
00136 
00137         WORD identifier;         
00139         WORD sequenceNum;        
00141         BYTE ttl;                
00143         const BYTE * buffer;     
00145         PINDEX bufferSize;       
00147 
00150 
00151         PTimeInterval delay;     
00153         Address remoteAddr;      
00155         Address localAddr;       
00157         PingStatus status;       
00159     };
00161 
00170     BOOL Ping(
00171       const PString & host   
00172     );
00179     BOOL Ping(
00180       const PString & host,   
00181       PingInfo & info         
00182     );
00184 
00185   protected:
00186     const char * GetProtocolName() const;
00187     virtual BOOL OpenSocket();
00188     virtual BOOL OpenSocket(int ipAdressFamily);
00189 
00190 
00191 // Include platform dependent part of class
00192 #ifdef _WIN32
00193 #include "msos/ptlib/icmpsock.h"
00194 #else
00195 #include "unix/ptlib/icmpsock.h"
00196 #endif
00197 };
00198 
00199 #endif
00200 
00201 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Sep 21 14:40:11 2007 for PWLib by  doxygen 1.5.3