Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

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

Generated on Mon Feb 21 20:43:09 2005 for PWLib by  doxygen 1.4.1