# 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  * $Revision: 27817 $
    00030  * $Author: rjongbloed $
    00031  * $Date: 2012-06-12 21:52:14 -0500 (Tue, 12 Jun 2012) $
    00032  */
    00033
    00034 #ifndef PTLIB_ICMPSOCKET_H
    00035 #define PTLIB_ICMPSOCKET_H
    00036
    00037 #ifdef P_USE_PRAGMA
    00038 #pragma interface
    00039 #endif
    00040
    00041 #include <ptlib/pprocess.h>
    00042
    00046 class PICMPSocket : public PIPDatagramSocket
    00047 {
    00048   PCLASSINFO(PICMPSocket, PIPDatagramSocket);
    00049
    00050   public:
    00056     PICMPSocket();
    00058
    00061
    00062     enum PingStatus {
    00063       PingSuccess,         // don't use Success - X11 defines this!
    00064       NetworkUnreachable,
    00065       HostUnreachable,
    00066       PacketTooBig,
    00067       RequestTimedOut,
    00068       BadRoute,
    00069       TtlExpiredTransmit,
    00070       TtlExpiredReassembly,
    00071       SourceQuench,
    00072       MtuChange,
    00073       GeneralError,
    00074       NumStatuses
    00075     };
    00076
    00078     class PingInfo {
    00079       public:
    00081         PingInfo(WORD id = (WORD)PProcess::GetCurrentProcessID());
    00082
    00085
    00086         WORD identifier;
    00088         WORD sequenceNum;
    00090         BYTE ttl;
    00092         const BYTE * buffer;
    00094         PINDEX bufferSize;
    00096
    00099
    00100         PTimeInterval delay;
    00102         Address remoteAddr;
    00104         Address localAddr;
    00106         PingStatus status;
    00108     };
    00110
    00119     PBoolean Ping(
    00120       const PString & host
    00121     );
    00128     PBoolean Ping(
    00129       const PString & host,
    00130       PingInfo & info
    00131     );
    00133
    00134   protected:
    00135     const char * GetProtocolName() const;
    00136     virtual PBoolean OpenSocket();
    00137     virtual PBoolean OpenSocket(int ipAdressFamily);
    00138
    00139
    00140 // Include platform dependent part of class
    00141 #ifdef _WIN32
    00142 #include "msos/ptlib/icmpsock.h"
    00143 #else
    00144 #include "unix/ptlib/icmpsock.h"
    00145 #endif
    00146 };
    00147
    00148
    00149 #endif // PTLIB_ICMPSOCKET_H
    00150
    00151
    00152 // End Of File ///////////////////////////////////////////////////////////////