Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cPingCommon.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cPingCommon_H
6 #define _INC_cPingCommon_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "../Net/cNetSocket.h"
13 
14 namespace GrayLib
15 {
17  {
21 
22  enum MSGTYPE_TYPE
23  {
29 
30  MSGTYPE_EMPTY = 0,
31 
32  MSGTYPE_ECHO_REQ = 1,
33  MSGTYPE_ECHO_RESP,
34  MSGTYPE_STATUS_REQ,
35  MSGTYPE_STATUS_RESP,
36  MSGTYPE_INFO_REQ,
37  MSGTYPE_INFO_RESP,
38  // ... some other (more detailed) types of requests.
39  MSGTYPE_QTY,
40  };
41 
43 
44  virtual size_t MakePingPacket(OUT BYTE* pData, MSGTYPE_TYPE eMsgType, const void* pPayload, size_t nPayloadSize) const = 0;
45  virtual HRESULT CheckPingPacket(const BYTE* pData, size_t iLen, size_t* pnPayloadOffset) const = 0;
46  };
47 
49  {
54 
55  public:
56  static const size_t k_SIZE_MAX = 76;
57 
58  virtual size_t MakePingPacket(OUT BYTE* pData, MSGTYPE_TYPE eMsgType, const void* pPayload, size_t nPayloadSize) const override;
59  virtual HRESULT CheckPingPacket(const BYTE* pData, size_t iLen, size_t* pnPayloadOffset) const override;
60  };
61 
62  // TODO: cPingICMP6 ??
63 
65  {
68 
69  public:
70  // The default max value for UDP packet size is often quoted as 1280 bytes.
71  // MTU size of most switches in the network is 1500. so 1400 should be safe.
72  // 1460 bytes is the largest TCP packet on Ethernet?
73  // Min guaranteed to be supported everywhere is 512. probably larger but MUST be smaller than 65507.
74  // http://compnetworking.about.com/od/networkprotocols/l/aa071200a.htm says 8192 bytes is OK.
75  static const size_t k_SIZE_MAX = 1400;
76 
79 
80  public:
81  cPingCommon(const IPingProtocol* pForm /* = &cPingGray::k_Def */ );
82  virtual ~cPingCommon();
83 
84  HRESULT OpenPing(const cNetAddress& AddrListen, bool bICMP = false);
85  void ClosePing();
86 
87  virtual HRESULT onTickPing(OUT BYTE* pPayload, OUT size_t& nPayloadLen, OUT cNetAddress& SockAddr);
88  };
89 };
90 #endif // _INC_cPingCommon_H
#define IGNORE_WARN_INTERFACE(c)
Definition: GrayCore.h:79
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cNetAddr.h:31
Definition: cNetSocket.h:185
Definition: cPingCommon.h:65
const IPingProtocol * m_pForm
What type of ping protocol are we ? Ping packet formatter.
Definition: cPingCommon.h:78
cNetSocket m_Socket
the UDP socket i listen and send on.
Definition: cPingCommon.h:77
Definition: cPingCommon.h:49
Definition: cPingCommon.h:16
Definition: cMesh.h:22
DECLARE_INTERFACE(IScriptableSetter)