PTLib  Version 2.10.10
icmpsock.h
Go to the documentation of this file.
1 /*
2  * icmpsock.h
3  *
4  * Internet Control Message Protocol socket I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 27817 $
30  * $Author: rjongbloed $
31  * $Date: 2012-06-12 21:52:14 -0500 (Tue, 12 Jun 2012) $
32  */
33 
34 #ifndef PTLIB_ICMPSOCKET_H
35 #define PTLIB_ICMPSOCKET_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptlib/pprocess.h>
42 
47 {
48  PCLASSINFO(PICMPSocket, PIPDatagramSocket);
49 
50  public:
56  PICMPSocket();
58 
61  enum PingStatus {
63  PingSuccess, // don't use Success - X11 defines this!
75  };
76 
78  class PingInfo {
79  public:
81  PingInfo(WORD id = (WORD)PProcess::GetCurrentProcessID());
82 
85  WORD identifier;
88  WORD sequenceNum;
90  BYTE ttl;
92  const BYTE * buffer;
94  PINDEX bufferSize;
96 
108  };
110 
119  PBoolean Ping(
120  const PString & host
121  );
128  PBoolean Ping(
129  const PString & host,
130  PingInfo & info
131  );
133 
134  protected:
135  const char * GetProtocolName() const;
136  virtual PBoolean OpenSocket();
137  virtual PBoolean OpenSocket(int ipAdressFamily);
138 
139 
140 // Include platform dependent part of class
141 #ifdef _WIN32
142 #include "msos/ptlib/icmpsock.h"
143 #else
144 #include "unix/ptlib/icmpsock.h"
145 #endif
146 };
147 
148 
149 #endif // PTLIB_ICMPSOCKET_H
150 
151 
152 // End Of File ///////////////////////////////////////////////////////////////
Definition: icmpsock.h:64
Definition: icmpsock.h:72
Create a socket channel that uses allows ICMP commands in the Internal Protocol.
Definition: icmpsock.h:46
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
const char * GetProtocolName() const
This function returns the protocol name for the socket type.
PINDEX bufferSize
Size of buffer (< 64k).
Definition: icmpsock.h:94
Definition: icmpsock.h:73
virtual PBoolean OpenSocket()
PICMPSocket()
Create a TCP/IP protocol socket channel.
Definition: icmpsock.h:69
Information used by and obtained by the ping operation.
Definition: icmpsock.h:78
Definition: icmpsock.h:66
BOOL PBoolean
Definition: object.h:102
Definition: icmpsock.h:67
Definition: icmpsock.h:74
const BYTE * buffer
Send buffer (if NULL, defaults to 32 bytes).
Definition: icmpsock.h:92
PingStatus
Results of ICMP operation.
Definition: icmpsock.h:62
PingStatus status
Status of the last ping operation.
Definition: icmpsock.h:106
The character string class.
Definition: pstring.h:108
PBoolean Ping(const PString &host)
Send an ECHO_REPLY message to the specified host and wait for a reply to be sent back.
Definition: icmpsock.h:68
Definition: icmpsock.h:71
A class describing an IP address.
Definition: ipsock.h:75
BYTE ttl
Time To Live for packet.
Definition: icmpsock.h:90
Internet Protocol Datagram Socket class.
Definition: ipdsock.h:45
static PProcessIdentifier GetCurrentProcessID()
Get the platform dependent process identifier for the currentprocess.
PTimeInterval delay
Time for packet to make trip.
Definition: icmpsock.h:100
Definition: icmpsock.h:63
PingInfo(WORD id=(WORD) PProcess::GetCurrentProcessID())
Create Ping information structure.
Definition: icmpsock.h:70
Address localAddr
Destination address of reply packet.
Definition: icmpsock.h:104
WORD sequenceNum
Sequence number for ping packet.
Definition: icmpsock.h:88
Address remoteAddr
Source address of reply packet.
Definition: icmpsock.h:102
WORD identifier
Arbitrary identifier for the ping.
Definition: icmpsock.h:86
Definition: icmpsock.h:65