OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Network2IO.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 #ifndef INC_C4Network2IO
17 #define INC_C4Network2IO
18 
20 #include "network/C4Client.h"
22 #include "network/C4NetIO.h"
23 
24 #include <atomic>
25 
27 
28 // enums & constants
30 {
32 };
33 
34 const int C4NetTimer = 500, // ms
35  C4NetPingFreq = 1000, // ms
36  C4NetStatisticsFreq = 1000, // ms
37  C4NetAcceptTimeout = 10, // s
38  C4NetPingTimeout = 30000;// ms
39 
40 // client count
41 const int C4NetMaxClients = 256;
42 
45  protected C4NetIO::CBClass,
46  protected StdSchedulerProc
47 {
48 public:
49  C4Network2IO();
50  ~C4Network2IO() override;
51 
52 protected:
53 
54  // main traffic net i/o classes
55  C4NetIO *pNetIO_TCP{nullptr}, *pNetIO_UDP{nullptr};
56 
57  // discovery net i/o
59 
60  // reference server
62 
63  // UPnP port mapping manager
64  class C4Network2UPnP *UPnPMgr{nullptr};
65 
66  // local client core
69 
70  // connection list
73 
74  // next connection ID to use
75  uint32_t iNextConnID{0};
76 
77  // allow incoming connections?
78  bool fAllowConnect{false};
79 
80  // connection acceptance
81  struct AutoAccept
82  {
85  }
86  *pAutoAcceptList{nullptr};
88 
89  // make sure only one connection is established?
90  bool fExclusiveConn{false};
91 
92  // timer & ping
95 
96  // statistics
98  int iTCPIRate{0}, iTCPORate{0}, iTCPBCRate{0},
100 
101  // punching
103  bool IsPuncherAddr(const C4NetIO::addr_t& addr) const;
104 
105 public:
106 
107  bool hasTCP() const { return !! pNetIO_TCP; }
108  bool hasUDP() const { return !! pNetIO_UDP; }
109 
110  // initialization
111  bool Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscovery = -1, int16_t iPortRefServer = -1, bool fBroadcast = false, bool enable_upnp = true); // by main thread
112  void Clear(); // by main thread
113  void SetLocalCCore(const C4ClientCore &CCore); // by main thread
114 
115  // i/o types
116  C4NetIO *MsgIO(); // by both
117  C4NetIO *DataIO(); // by both
118 
119  // connections
120  bool Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword = nullptr); // by main thread
121  void SetAcceptMode(bool fAcceptAll); // by main thread
122  void SetExclusiveConnMode(bool fExclusiveConn); // by main thread
123  int getConnectionCount(); // by main thread
124 
125  void ClearAutoAccept(); // by main thread
126  void AddAutoAccept(const C4ClientCore &CCore); // by main thread
127  void RemoveAutoAccept(const C4ClientCore &CCore); // by main thread
128 
129  C4Network2IOConnection *GetMsgConnection(int iClientID); // by both (returns referenced connection!)
130  C4Network2IOConnection *GetDataConnection(int iClientID); // by both (returns referenced connection!)
131 
132  // broadcasting
133  void BeginBroadcast(bool fSelectAll = false); // by both
134  void EndBroadcast(); // by both
135  bool Broadcast(const C4NetIOPacket &rPkt); // by both
136 
137  // sending helpers
138  bool SendMsgToClient(C4NetIOPacket &rPkt, int iClient); // by both
139  bool BroadcastMsg(const C4NetIOPacket &rPkt); // by both
140 
141  // punch
142  bool InitPuncher(C4NetIO::addr_t PuncherAddr); // by main thread
144  void Punch(const C4NetIO::addr_t&); // sends a ping packet
145 
146  // stuff
147  C4NetIO *getNetIO(C4Network2IOProtocol eProt); // by both
148  const char *getNetIOName(C4NetIO *pNetIO);
150 
151  // statistics
152  int getProtIRate(C4Network2IOProtocol eProt) const { return eProt == P_TCP ? iTCPIRate : iUDPIRate; }
153  int getProtORate(C4Network2IOProtocol eProt) const { return eProt == P_TCP ? iTCPORate : iUDPORate; }
154  int getProtBCRate(C4Network2IOProtocol eProt) const { return eProt == P_TCP ? iTCPBCRate : iUDPBCRate; }
155 
156  // reference
157  void SetReference(class C4Network2Reference *pReference);
158  bool IsReferenceNeeded();
159 
160 protected:
161  // *** callbacks
162  // C4NetIO-Callbacks
163  bool OnConn(const C4NetIO::addr_t &addr, const C4NetIO::addr_t &AddrConnect, const C4NetIO::addr_t *pOwnAddr, C4NetIO *pNetIO) override;
164  void OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const char *szReason) override;
165  void OnPacket(const C4NetIOPacket &rPacket, C4NetIO *pNetIO) override;
166  // C4NetIOMan
167  virtual void OnError(const char *strError, C4NetIO *pNetIO);
168  // StdSchedulerProc
169  bool Execute(int iTimeout, pollfd *) override;
171  // Event callback by C4InteractiveThread
172  void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) override; // by main thread
173 
174  // connections list
175  void AddConnection(C4Network2IOConnection *pConn); // by both
176  void RemoveConnection(C4Network2IOConnection *pConn); // by both
177  C4Network2IOConnection *GetConnection(const C4NetIO::addr_t &addr, C4NetIO *pNetIO); // by both
178  C4Network2IOConnection *GetConnectionByConnAddr(const C4NetIO::addr_t &addr, C4NetIO *pNetIO); // by both
179  C4Network2IOConnection *GetConnectionByID(uint32_t iConnID); // by thread
180 
181  // network events (signals to main thread)
182  struct NetEvPacketData;
183 
184  // connection acceptance
185  bool doAutoAccept(const C4ClientCore &CCore, const C4Network2IOConnection &Conn);
186 
187  // general packet handling (= forward in most cases)
188  bool HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread); // by both
189  void CallHandlers(int iHandlers, const class C4IDPacket *pPacket, C4Network2IOConnection *pConn, bool fThread); // by both
190 
191  // packet handling (some are really handled here)
192  void HandlePacket(char cStatus, const C4PacketBase *pPacket, C4Network2IOConnection *pConn);
193  void HandleFwdReq(const class C4PacketFwd &rFwd, C4Network2IOConnection *pBy);
194  void HandlePuncherPacket(const C4NetIOPacket &rPacket);
195 
196  // misc
197  bool Ping();
198  void CheckTimeout();
199  void GenerateStatistics(int iInterval);
200  void SendConnPackets();
201 };
202 
204 {
205  CS_Connect, // waiting for connection
206  CS_Connected, // waiting for Conn
207  CS_HalfAccepted, // got Conn (peer identified, client class created if neccessary)
208  CS_Accepted, // got ConnRe (peer did accept)
210  CS_ConnectFail // got closed before HalfAccepted was reached
211 };
212 
213 class C4Network2IOConnection // shared
214 {
215  friend class C4Network2IO;
216 public:
219 
220 protected:
221 
222  // connection data
223  class C4NetIO *pNetClass{nullptr};
226 
227  // status data
229  uint32_t iID, iRemoteID; // connection ID for this and the remote client
230  bool fAutoAccept{false}; // auto accepted by thread?
231  bool fBroadcastTarget{false}; // broadcast target?
232  time_t iTimestamp{0}; // timestamp of last status change
233  int iPingTime{-1}; // ping
234  C4TimeMilliseconds tLastPing; // if > iLastPong, it's the first ping that hasn't been answered yet, nullptr if no ping received yet
235  C4TimeMilliseconds tLastPong; // last pong received, nullptr if no pong received yet
236  C4ClientCore CCore; // client core (>= CS_HalfAccepted)
238  int iIRate, iORate; // input/output rates (by C4NetIO, in b/s)
239  int iPacketLoss; // lost packets (in the last seconds)
240  StdCopyStrBuf Password; // password to use for connect
241  bool fConnSent{false}; // initial connection packet send
242  bool fPostMortemSent{false}; // post mortem send
243 
244  // packet backlog
247  {
248  uint32_t Number;
251  };
254 
255  // list (C4Network2IO)
257 
258  // reference counter
259  std::atomic_long iRefCnt;
260 
261 public:
262  C4NetIO *getNetClass() const { return pNetClass; }
264  const C4NetIO::addr_t &getPeerAddr() const { return PeerAddr.GetPort() ? PeerAddr : ConnectAddr; }
265  const C4NetIO::addr_t &getConnectAddr() const { return ConnectAddr; }
266  uint32_t getID() const { return iID; }
267  uint32_t getRemoteID() const { return iRemoteID; }
268  time_t getTimestamp() const { return iTimestamp; }
269  const C4ClientCore &getCCore() const { return CCore; }
271  int getClientID() const { return CCore.getID(); }
272  bool isHost() const { return CCore.isHost(); }
273  int getPingTime() const { return iPingTime; }
274  int getLag() const;
275  int getIRate() const { return iIRate; }
276  int getORate() const { return iORate; }
277  int getPacketLoss() const { return iPacketLoss; }
278  const char *getPassword() const { return Password.getData(); }
279  bool isConnSent() const { return fConnSent; }
280 
281  uint32_t getInPacketCounter() const { return iInPacketCounter; }
282  uint32_t getOutPacketCounter() const { return iOutPacketCounter; }
283 
284  bool isConnecting() const { return Status == CS_Connect; }
285  bool isOpen() const { return Status != CS_Connect && Status != CS_Closed && Status != CS_ConnectFail; }
286  bool isHalfAccepted()const { return Status == CS_HalfAccepted || Status == CS_Accepted; }
287  bool isAccepted() const { return Status == CS_Accepted; }
288  bool isClosed() const { return Status == CS_Closed || Status == CS_ConnectFail; }
289  bool isAutoAccepted()const { return fAutoAccept; }
290  bool isBroadcastTarget() const { return fBroadcastTarget; }
291  bool isFailed() const { return Status == CS_ConnectFail; }
292 
293 protected:
294  // called by C4Network2IO only
295  void Set(C4NetIO *pnNetClass, C4Network2IOProtocol eProt, const C4NetIO::addr_t &nPeerAddr, const C4NetIO::addr_t &nConnectAddr, C4Network2IOConnStatus nStatus, const char *szPassword, uint32_t iID);
296  void SetRemoteID(uint32_t iRemoteID);
297  void SetPeerAddr(const C4NetIO::addr_t &nPeerAddr);
298  void OnPing();
299  void SetPingTime(int iPingTime);
300  void SetStatus(C4Network2IOConnStatus nStatus);
301  void SetAutoAccepted();
302  void OnPacketReceived(uint8_t iPacketType);
303  void ClearPacketLog(uint32_t iStartNumber = ~0);
304 
305 public:
306  // status changing
309  void SetCCore(const C4ClientCore &nCCore);
310  void ResetAutoAccepted() { fAutoAccept = false; }
311  void SetConnSent() { fConnSent = true; }
312 
313  // connection operations
314  bool Connect();
315  void Close();
316  bool Send(const C4NetIOPacket &rPkt);
317  void SetBroadcastTarget(bool fSet); // (only call after C4Network2IO::BeginBroadcast!)
318 
319  // statistics
320  void DoStatistics(int iInterval, int *pIRateSum, int *pORateSum);
321 
322  // reference counting
323  void AddRef(); void DelRef();
324 
325  // post mortem
326  bool CreatePostMortem(class C4PacketPostMortem *pPkt);
327 
328 };
329 
330 // * Packets *
331 
333 {
334 public:
335  C4PacketPing(uint32_t iPacketCounter = 0, uint32_t iRemotePacketCounter = 0);
336 
337 protected:
339  uint32_t iPacketCounter;
340 
341 public:
342  uint32_t getTravelTime() const;
343  uint32_t getPacketCounter() const { return iPacketCounter; }
344 
345  void CompileFunc(StdCompiler *pComp) override;
346 };
347 
349 {
350 public:
351  C4PacketConn();
352  C4PacketConn(const class C4ClientCore &nCCore, uint32_t iConnID, const char *szPassword = nullptr);
353 
354 protected:
355  int32_t iVer;
356  uint32_t iConnID;
359 
360 public:
361  int32_t getVer() const { return iVer; }
362  uint32_t getConnID() const { return iConnID; }
363  const C4ClientCore &getCCore() const { return CCore; }
364  const char *getPassword() const { return Password.getData(); }
365 
366  void CompileFunc(StdCompiler *pComp) override;
367 };
368 
370 {
371 public:
372  C4PacketConnRe();
373  C4PacketConnRe(bool fOK, bool fWrongPassword, const char *szMsg = nullptr);
374 
375 protected:
378 
379 public:
380  bool isOK() const { return fOK; }
381  bool isPasswordWrong() const { return fWrongPassword; }
382  const char *getMsg() const { return szMsg.getData(); }
383 
384  void CompileFunc(StdCompiler *pComp) override;
385 };
386 
387 class C4PacketFwd : public C4PacketBase
388 {
389 public:
390  C4PacketFwd();
391  C4PacketFwd(const StdBuf &Pkt);
392 
393 protected:
394  bool fNegativeList{false};
396  int32_t iClientCnt{0};
398 
399 public:
400  const StdCopyBuf &getData() const { return Data; }
401  bool isNegativeList() const { return fNegativeList; }
402  int32_t getClient(int32_t i) const { return iClients[i]; }
403  int32_t getClientCnt() const { return iClientCnt; }
404 
405  bool DoFwdTo(int32_t iClient) const;
406 
407  void SetData(const StdBuf &Pkt);
408  void SetListType(bool fnNegativeList);
409  void AddClient(int32_t iClient);
410 
411  void CompileFunc(StdCompiler *pComp) override;
412 };
413 
415 {
416 public:
418  ~C4PacketPostMortem() override;
419 
420 private:
421  uint32_t iConnID;
422  uint32_t iPacketCounter; // last packet counter of dead connection
423  uint32_t iPacketCount{0};
424  struct PacketLink
425  {
426  C4NetIOPacket Pkt;
427  PacketLink *Next;
428  };
429  PacketLink *pPackets{nullptr};
430 
431 public:
432  uint32_t getConnID() const { return iConnID; }
433  uint32_t getPacketCount() const { return iPacketCount; }
434  void SetConnID(uint32_t inConnID) { iConnID = inConnID; }
435 
436  const C4NetIOPacket *getPacket(uint32_t iNumber) const;
437  void SetPacketCounter(uint32_t iPacketCounter);
438  void Add(const C4NetIOPacket &rPkt);
439 
440  void CompileFunc(StdCompiler *pComp) override;
441 };
442 
443 #endif
bool fExclusiveConn
Definition: C4Network2IO.h:90
const char * getData() const
Definition: StdBuf.h:442
C4NetIO * pNetIO_UDP
Definition: C4Network2IO.h:55
int getConnectionCount()
void SetReference(class C4Network2Reference *pReference)
CStdCSec BroadcastCSec
Definition: C4Network2IO.h:72
C4Network2IOConnection * GetConnection(const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
StdStrBuf szMsg
Definition: C4Network2IO.h:377
Definition: StdBuf.h:29
void OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const char *szReason) override
void SetPacketCounter(uint32_t iPacketCounter)
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:499
bool isPasswordWrong() const
Definition: C4Network2IO.h:381
bool isFailed() const
Definition: C4Network2IO.h:291
bool HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread)
~C4Network2IO() override
void SendPuncherPacket(const C4NetpuncherPacket &, C4NetIO::HostAddress::AddressFamily family)
const int C4NetAcceptTimeout
Definition: C4Network2IO.h:37
void AddAutoAccept(const C4ClientCore &CCore)
uint32_t getTravelTime() const
Definition: C4Packet2.cpp:494
void SetCCore(const C4ClientCore &nCCore)
CStdCSec ConnListCSec
Definition: C4Network2IO.h:72
int getProtBCRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:154
uint32_t getRemoteID() const
Definition: C4Network2IO.h:267
C4Network2IOConnection * GetMsgConnection(int iClientID)
bool SendMsgToClient(C4NetIOPacket &rPkt, int iClient)
void OnPacketReceived(uint8_t iPacketType)
C4Network2IOProtocol eProt
Definition: C4Network2IO.h:224
bool Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword=nullptr)
C4Network2IOConnection * GetConnectionByConnAddr(const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
uint32_t iPacketCounter
Definition: C4Network2IO.h:339
const char * getPassword() const
Definition: C4Network2IO.h:364
bool Send(const C4NetIOPacket &rPkt)
C4Network2IOProtocol
Definition: C4Network2IO.h:29
bool isOK() const
Definition: C4Network2IO.h:380
uint32_t getInPacketCounter() const
Definition: C4Network2IO.h:281
void OnPacket(const C4NetIOPacket &rPacket, C4NetIO *pNetIO) override
void CompileFunc(StdCompiler *pComp) override
void SetExclusiveConnMode(bool fExclusiveConn)
C4Network2IOConnection * pNext
Definition: C4Network2IO.h:256
bool IsReferenceNeeded()
C4PacketPostMortem()
const C4NetIO::addr_t & getPeerAddr() const
Definition: C4Network2IO.h:264
uint32_t getConnID() const
Definition: C4Network2IO.h:362
C4NetIO * MsgIO()
bool isHalfAccepted() const
Definition: C4Network2IO.h:286
void Add(const C4NetIOPacket &rPkt)
class C4Network2RefServer * pRefServer
Definition: C4Network2IO.h:61
const int C4NetPingFreq
Definition: C4Network2IO.h:35
bool isHost() const
Definition: C4Client.h:58
CStdCSec & getCCoreCSec()
Definition: C4Network2IO.h:270
const C4NetIO::addr_t & getConnectAddr() const
Definition: C4Network2IO.h:265
C4NetIO::addr_t PeerAddr
Definition: C4Network2IO.h:225
void SetPingTime(int iPingTime)
CStdCSec LCCoreCSec
Definition: C4Network2IO.h:68
C4Network2IOProtocol getProtocol() const
Definition: C4Network2IO.h:263
void ClearAutoAccept()
void Punch(const C4NetIO::addr_t &)
C4TimeMilliseconds tLastExecute
Definition: C4Network2IO.h:93
const C4ClientCore & getCCore() const
Definition: C4Network2IO.h:269
class C4NetIO * pNetClass
Definition: C4Network2IO.h:223
C4ClientCore LCCore
Definition: C4Network2IO.h:67
void AddClient(int32_t iClient)
Definition: C4Packet2.cpp:459
const char * getMsg() const
Definition: C4Network2IO.h:382
int32_t getClient(int32_t i) const
Definition: C4Network2IO.h:402
C4Network2IOProtocol getNetIOProt(C4NetIO *pNetIO)
std::atomic_long iRefCnt
Definition: C4Network2IO.h:259
bool isAccepted() const
Definition: C4Network2IO.h:287
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:395
bool doAutoAccept(const C4ClientCore &CCore, const C4Network2IOConnection &Conn)
uint32_t iNextConnID
Definition: C4Network2IO.h:75
void AddConnection(C4Network2IOConnection *pConn)
void SetRemoteID(uint32_t iRemoteID)
int getClientID() const
Definition: C4Network2IO.h:271
bool OnConn(const C4NetIO::addr_t &addr, const C4NetIO::addr_t &AddrConnect, const C4NetIO::addr_t *pOwnAddr, C4NetIO *pNetIO) override
C4Network2IOConnection * GetConnectionByID(uint32_t iConnID)
void RemoveConnection(C4Network2IOConnection *pConn)
C4NetIO * getNetIO(C4Network2IOProtocol eProt)
C4TimeMilliseconds tLastPing
Definition: C4Network2IO.h:234
void SetBroadcastTarget(bool fSet)
void SetListType(bool fnNegativeList)
Definition: C4Packet2.cpp:454
bool Broadcast(const C4NetIOPacket &rPkt)
int getPingTime() const
Definition: C4Network2IO.h:273
void Set(C4NetIO *pnNetClass, C4Network2IOProtocol eProt, const C4NetIO::addr_t &nPeerAddr, const C4NetIO::addr_t &nConnectAddr, C4Network2IOConnStatus nStatus, const char *szPassword, uint32_t iID)
CStdCSec AutoAcceptCSec
Definition: C4Network2IO.h:87
void SetAcceptMode(bool fAcceptAll)
bool isConnecting() const
Definition: C4Network2IO.h:284
bool fAllowConnect
Definition: C4Network2IO.h:78
const int C4NetPingTimeout
Definition: C4Network2IO.h:38
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:406
C4NetIO::addr_t PuncherAddrIPv4
Definition: C4Network2IO.h:102
C4InteractiveEventType
int32_t getID() const
Definition: C4Client.h:57
void SendConnPackets()
bool BroadcastMsg(const C4NetIOPacket &rPkt)
C4PacketPing(uint32_t iPacketCounter=0, uint32_t iRemotePacketCounter=0)
Definition: C4Packet2.cpp:488
uint32_t getOutPacketCounter() const
Definition: C4Network2IO.h:282
C4Network2IOConnection * pConnList
Definition: C4Network2IO.h:71
C4NetIO * DataIO()
void SetLocalCCore(const C4ClientCore &CCore)
bool fNegativeList
Definition: C4Network2IO.h:394
void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) override
C4NetIO * pNetIO_TCP
Definition: C4Network2IO.h:55
void BeginBroadcast(bool fSelectAll=false)
int getProtORate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:153
virtual void OnError(const char *strError, C4NetIO *pNetIO)
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:466
int32_t getClientCnt() const
Definition: C4Network2IO.h:403
C4NetIO::addr_t PuncherAddrIPv6
Definition: C4Network2IO.h:102
void EndBroadcast()
int32_t iClientCnt
Definition: C4Network2IO.h:396
int getProtIRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:152
void GenerateStatistics(int iInterval)
void RemoveAutoAccept(const C4ClientCore &CCore)
int getPacketLoss() const
Definition: C4Network2IO.h:277
class C4Network2UPnP * UPnPMgr
Definition: C4Network2IO.h:64
StdCopyStrBuf Password
Definition: C4Network2IO.h:240
const C4NetIOPacket * getPacket(uint32_t iNumber) const
const int C4NetTimer
Definition: C4Network2IO.h:34
C4Network2IOConnStatus Status
Definition: C4Network2IO.h:228
PacketLogEntry * pPacketLog
Definition: C4Network2IO.h:252
C4Network2IOConnection * GetDataConnection(int iClientID)
class C4Network2IODiscover * pNetIODiscover
Definition: C4Network2IO.h:58
int32_t iVer
Definition: C4Network2IO.h:355
C4Network2IOConnStatus
Definition: C4Network2IO.h:203
void SetConnID(uint32_t inConnID)
Definition: C4Network2IO.h:434
uint32_t getID() const
Definition: C4Network2IO.h:266
C4TimeMilliseconds GetNextTick(C4TimeMilliseconds tNow) override
C4TimeMilliseconds tLastPing
Definition: C4Network2IO.h:94
uint32_t getPacketCount() const
Definition: C4Network2IO.h:433
bool DoFwdTo(int32_t iClient) const
Definition: C4Packet2.cpp:441
bool isNegativeList() const
Definition: C4Network2IO.h:401
uint32_t getPacketCounter() const
Definition: C4Network2IO.h:343
C4TimeMilliseconds tTime
Definition: C4Network2IO.h:338
Definition: C4Network2IO.h:246
void DoStatistics(int iInterval, int *pIRateSum, int *pORateSum)
bool isConnSent() const
Definition: C4Network2IO.h:279
~C4PacketPostMortem() override
C4NetIO::addr_t ConnectAddr
Definition: C4Network2IO.h:225
void SetStatus(C4Network2IOConnStatus nStatus)
C4TimeMilliseconds tLastStatistic
Definition: C4Network2IO.h:97
void CallHandlers(int iHandlers, const class C4IDPacket *pPacket, C4Network2IOConnection *pConn, bool fThread)
bool CreatePostMortem(class C4PacketPostMortem *pPkt)
const char * getPassword() const
Definition: C4Network2IO.h:278
bool hasUDP() const
Definition: C4Network2IO.h:108
bool Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscovery=-1, int16_t iPortRefServer=-1, bool fBroadcast=false, bool enable_upnp=true)
void HandleFwdReq(const class C4PacketFwd &rFwd, C4Network2IOConnection *pBy)
const StdCopyBuf & getData() const
Definition: C4Network2IO.h:400
void SetData(const StdBuf &Pkt)
Definition: C4Packet2.cpp:449
uint32_t getConnID() const
Definition: C4Network2IO.h:432
const int C4NetStatisticsFreq
Definition: C4Network2IO.h:36
bool hasTCP() const
Definition: C4Network2IO.h:107
bool Execute(int iTimeout, pollfd *) override
C4TimeMilliseconds tLastPong
Definition: C4Network2IO.h:235
void HandlePuncherPacket(const C4NetIOPacket &rPacket)
bool InitPuncher(C4NetIO::addr_t PuncherAddr)
C4ClientCore CCore
Definition: C4Network2IO.h:357
bool isAutoAccepted() const
Definition: C4Network2IO.h:289
time_t getTimestamp() const
Definition: C4Network2IO.h:268
const char * getNetIOName(C4NetIO *pNetIO)
C4NetIO * getNetClass() const
Definition: C4Network2IO.h:262
bool IsPuncherAddr(const C4NetIO::addr_t &addr) const
bool isClosed() const
Definition: C4Network2IO.h:288
uint16_t GetPort() const
Definition: C4NetIO.cpp:542
int32_t getVer() const
Definition: C4Network2IO.h:361
StdCopyBuf Data
Definition: C4Network2IO.h:397
uint32_t iConnID
Definition: C4Network2IO.h:356
Definition: C4Network2IO.h:414
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:425
void ClearPacketLog(uint32_t iStartNumber=~0)
bool isHost() const
Definition: C4Network2IO.h:272
bool isOpen() const
Definition: C4Network2IO.h:285
StdCopyStrBuf Password
Definition: C4Network2IO.h:358
const C4ClientCore & getCCore() const
Definition: C4Network2IO.h:363
bool isBroadcastTarget() const
Definition: C4Network2IO.h:290
void SetPeerAddr(const C4NetIO::addr_t &nPeerAddr)
const int C4NetMaxClients
Definition: C4Network2IO.h:41