OpenClonk
C4Network2IO Class Referenceabstract

#include <C4Network2IO.h>

Inheritance diagram for C4Network2IO:
[legend]
Collaboration diagram for C4Network2IO:
[legend]

Classes

struct  AutoAccept
 
struct  NetEvPacketData
 

Public Member Functions

 C4Network2IO ()
 
 ~C4Network2IO () override
 
bool hasTCP () const
 
bool hasUDP () const
 
bool Init (int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscovery=-1, int16_t iPortRefServer=-1, bool fBroadcast=false, bool enable_upnp=true)
 
void Clear ()
 
void SetLocalCCore (const C4ClientCore &CCore)
 
C4NetIOMsgIO ()
 
C4NetIODataIO ()
 
bool Connect (const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword=nullptr)
 
bool ConnectWithSocket (const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, std::unique_ptr< C4NetIOTCP::Socket > socket, const char *szPassword=nullptr)
 
void SetAcceptMode (bool fAcceptAll)
 
void SetExclusiveConnMode (bool fExclusiveConn)
 
int getConnectionCount ()
 
void ClearAutoAccept ()
 
void AddAutoAccept (const C4ClientCore &CCore)
 
void RemoveAutoAccept (const C4ClientCore &CCore)
 
C4Network2IOConnectionGetMsgConnection (int iClientID)
 
C4Network2IOConnectionGetDataConnection (int iClientID)
 
void BeginBroadcast (bool fSelectAll=false)
 
void EndBroadcast ()
 
bool Broadcast (const C4NetIOPacket &rPkt)
 
bool SendMsgToClient (C4NetIOPacket &rPkt, int iClient)
 
bool BroadcastMsg (const C4NetIOPacket &rPkt)
 
bool InitPuncher (C4NetIO::addr_t PuncherAddr)
 
void SendPuncherPacket (const C4NetpuncherPacket &, C4NetIO::HostAddress::AddressFamily family)
 
void Punch (const C4NetIO::addr_t &)
 
C4NetIOgetNetIO (C4Network2IOProtocol eProt)
 
const char * getNetIOName (C4NetIO *pNetIO)
 
C4Network2IOProtocol getNetIOProt (C4NetIO *pNetIO)
 
int getProtIRate (C4Network2IOProtocol eProt) const
 
int getProtORate (C4Network2IOProtocol eProt) const
 
int getProtBCRate (C4Network2IOProtocol eProt) const
 
void SetReference (class C4Network2Reference *pReference)
 
bool IsReferenceNeeded ()
 

Protected Member Functions

bool IsPuncherAddr (const C4NetIO::addr_t &addr) const
 
bool OnConn (const C4NetIO::addr_t &addr, const C4NetIO::addr_t &AddrConnect, const C4NetIO::addr_t *pOwnAddr, C4NetIO *pNetIO) override
 
void OnDisconn (const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const char *szReason) override
 
void OnPacket (const C4NetIOPacket &rPacket, C4NetIO *pNetIO) override
 
virtual void OnError (const char *strError, C4NetIO *pNetIO)
 
bool Execute (int iTimeout, pollfd *) override
 
C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow) override
 
void OnThreadEvent (C4InteractiveEventType eEvent, void *pEventData) override
 
void AddConnection (C4Network2IOConnection *pConn)
 
void RemoveConnection (C4Network2IOConnection *pConn)
 
C4Network2IOConnectionGetConnection (const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
 
C4Network2IOConnectionGetConnectionByConnAddr (const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
 
C4Network2IOConnectionGetConnectionByID (uint32_t iConnID)
 
bool doAutoAccept (const C4ClientCore &CCore, const C4Network2IOConnection &Conn)
 
bool HandlePacket (const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread)
 
void CallHandlers (int iHandlers, const class C4IDPacket *pPacket, C4Network2IOConnection *pConn, bool fThread)
 
void HandlePacket (char cStatus, const C4PacketBase *pPacket, C4Network2IOConnection *pConn)
 
void HandleFwdReq (const class C4PacketFwd &rFwd, C4Network2IOConnection *pBy)
 
void HandlePuncherPacket (const C4NetIOPacket &rPacket)
 
bool Ping ()
 
void CheckTimeout ()
 
void GenerateStatistics (int iInterval)
 
void SendConnPackets ()
 
virtual void OnPacket (const class C4NetIOPacket &rPacket, C4NetIO *pNetIO)=0
 
void Changed ()
 
bool ExecuteUntil (int iTimeout=-1)
 
virtual void GetFDs (std::vector< struct pollfd > &)
 
bool IsSignaled ()
 
virtual bool IsLowPriority ()
 
virtual bool IsNotify ()
 
virtual uint32_t TimerInterval ()
 

Protected Attributes

C4NetIOpNetIO_TCP {nullptr}
 
C4NetIOpNetIO_UDP {nullptr}
 
class C4Network2IODiscoverpNetIODiscover {nullptr}
 
class C4Network2RefServerpRefServer {nullptr}
 
class C4Network2UPnPUPnPMgr {nullptr}
 
C4ClientCore LCCore
 
CStdCSec LCCoreCSec
 
C4Network2IOConnectionpConnList {nullptr}
 
CStdCSec ConnListCSec
 
CStdCSec BroadcastCSec
 
uint32_t iNextConnID {0}
 
bool fAllowConnect {false}
 
struct C4Network2IO::AutoAccept nullptr
 
CStdCSec AutoAcceptCSec
 
bool fExclusiveConn {false}
 
C4TimeMilliseconds tLastExecute
 
C4TimeMilliseconds tLastPing
 
C4TimeMilliseconds tLastStatistic
 
int iTCPIRate {0}
 
int iTCPORate {0}
 
int iTCPBCRate {0}
 
int iUDPIRate {0}
 
int iUDPORate {0}
 
int iUDPBCRate {0}
 
C4NetIO::addr_t PuncherAddrIPv4
 
C4NetIO::addr_t PuncherAddrIPv6
 

Detailed Description

Definition at line 43 of file C4Network2IO.h.


Class Documentation

◆ C4Network2IO::AutoAccept

struct C4Network2IO::AutoAccept

Definition at line 81 of file C4Network2IO.h.

Collaboration diagram for C4Network2IO::AutoAccept:
[legend]
Class Members
C4ClientCore CCore
AutoAccept * Next

◆ C4Network2IO::NetEvPacketData

struct C4Network2IO::NetEvPacketData

Definition at line 32 of file C4Network2IO.cpp.

Collaboration diagram for C4Network2IO::NetEvPacketData:
[legend]
Class Members
C4Network2IOConnection * Conn
C4NetIOPacket Packet

Constructor & Destructor Documentation

◆ C4Network2IO()

C4Network2IO::C4Network2IO ( )

Definition at line 43 of file C4Network2IO.cpp.

45 {
46 }
C4TimeMilliseconds tLastExecute
Definition: C4Network2IO.h:93
C4TimeMilliseconds tLastPing
Definition: C4Network2IO.h:94
C4TimeMilliseconds tLastStatistic
Definition: C4Network2IO.h:97

◆ ~C4Network2IO()

C4Network2IO::~C4Network2IO ( )
override

Definition at line 48 of file C4Network2IO.cpp.

49 {
50  Clear();
51 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ AddAutoAccept()

void C4Network2IO::AddAutoAccept ( const C4ClientCore CCore)

Definition at line 320 of file C4Network2IO.cpp.

321 {
322  CStdLock AALock(&AutoAcceptCSec);
323  // create
324  AutoAccept *pAcc = new AutoAccept();
325  pAcc->CCore = CCore;
326  // add
327  pAcc->Next = pAutoAcceptList;
328  pAutoAcceptList = pAcc;
329 }
CStdCSec AutoAcceptCSec
Definition: C4Network2IO.h:87

References AutoAcceptCSec, C4Network2IO::AutoAccept::CCore, and C4Network2IO::AutoAccept::Next.

Referenced by C4Network2ClientList::RegClient().

Here is the caller graph for this function:

◆ AddConnection()

void C4Network2IO::AddConnection ( C4Network2IOConnection pConn)
protected

Definition at line 738 of file C4Network2IO.cpp.

739 {
740  CStdLock ConnListLock(&ConnListCSec);
741  // add reference
742  pConn->AddRef();
743  // add to list
744  pConn->pNext = pConnList; pConnList = pConn;
745 }
C4Network2IOConnection * pNext
Definition: C4Network2IO.h:258
C4Network2IOConnection * pConnList
Definition: C4Network2IO.h:71
CStdCSec ConnListCSec
Definition: C4Network2IO.h:72

References C4Network2IOConnection::AddRef(), ConnListCSec, pConnList, and C4Network2IOConnection::pNext.

Referenced by ConnectWithSocket(), and OnConn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BeginBroadcast()

void C4Network2IO::BeginBroadcast ( bool  fSelectAll = false)

Definition at line 382 of file C4Network2IO.cpp.

383 {
384  // lock
386  // reset all broadcast flags
387  CStdLock ConnListLock(&ConnListCSec);
388  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
389  if (pConn->isOpen())
390  pConn->SetBroadcastTarget(fSelectAll);
391 }
CStdCSec BroadcastCSec
Definition: C4Network2IO.h:72
virtual void Enter()
Definition: StdSync.h:150

References BroadcastCSec, ConnListCSec, CStdCSec::Enter(), pConnList, and C4Network2IOConnection::pNext.

Referenced by BroadcastMsg(), C4Network2ClientList::BroadcastMsgToClients(), C4Network2ClientList::BroadcastMsgToConnClients(), and HandleFwdReq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Broadcast()

bool C4Network2IO::Broadcast ( const C4NetIOPacket rPkt)

Definition at line 399 of file C4Network2IO.cpp.

400 {
401  bool fSuccess = true;
402  // There is no broadcasting atm, emulate it
403  CStdLock ConnListLock(&ConnListCSec);
404  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
405  if (pConn->isOpen() && pConn->isBroadcastTarget())
406  fSuccess &= pConn->Send(rPkt);
407  if(!fSuccess)
408  Log("Network: Warning! Broadcast failed.");
409  return fSuccess;
410 }
bool Log(const char *szMessage)
Definition: C4Log.cpp:204

References ConnListCSec, Log(), pConnList, and C4Network2IOConnection::pNext.

Referenced by BroadcastMsg(), C4Network2ClientList::BroadcastMsgToClients(), C4Network2ClientList::BroadcastMsgToConnClients(), and HandleFwdReq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BroadcastMsg()

bool C4Network2IO::BroadcastMsg ( const C4NetIOPacket rPkt)

Definition at line 423 of file C4Network2IO.cpp.

424 {
425  // TODO: ugly algorithm. do better
426 
427  // begin broadcast
428  BeginBroadcast(false);
429  // select one connection per reachable client
430  CStdLock ConnListLock(&ConnListCSec);
431  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
432  if (pConn->isAccepted())
433  {
434  if (pConn->getProtocol() == P_UDP)
435  pConn->SetBroadcastTarget(true);
436  else if (pConn->getProtocol() == P_TCP)
437  {
438  C4Network2IOConnection *pConn2 = GetMsgConnection(pConn->getClientID());
439  if (pConn == pConn2)
440  pConn->SetBroadcastTarget(true);
441  pConn2->DelRef();
442  }
443  }
444  // send
445  bool fSuccess = Broadcast(rPkt);
446  // end broadcast
447  EndBroadcast();
448  // return
449  return fSuccess;
450 }
@ P_UDP
Definition: C4Network2IO.h:31
@ P_TCP
Definition: C4Network2IO.h:31
void BeginBroadcast(bool fSelectAll=false)
C4Network2IOConnection * GetMsgConnection(int iClientID)
bool Broadcast(const C4NetIOPacket &rPkt)
void EndBroadcast()

References BeginBroadcast(), Broadcast(), ConnListCSec, C4Network2IOConnection::DelRef(), EndBroadcast(), GetMsgConnection(), P_TCP, P_UDP, pConnList, and C4Network2IOConnection::pNext.

Referenced by C4Network2Res::FinishDerive(), C4Network2ResList::SendDiscover(), and C4Network2Res::SendStatus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CallHandlers()

void C4Network2IO::CallHandlers ( int  iHandlers,
const class C4IDPacket pPacket,
C4Network2IOConnection pConn,
bool  fThread 
)
protected

Definition at line 931 of file C4Network2IO.cpp.

932 {
933  // emulate old callbacks
934  char cStatus = pPkt->getPktType();
935  const C4PacketBase *pPacket = pPkt->getPkt();
936  // this class (network thread)
937  if (iHandlerID & PH_C4Network2IO)
938  {
939  assert(fThread);
940  HandlePacket(cStatus, pPacket, pConn);
941  }
942  // main network class (main thread)
943  if (iHandlerID & PH_C4Network2)
944  {
945  assert(!fThread);
946  ::Network.HandlePacket(cStatus, pPacket, pConn);
947  }
948  // fullscreen lobby
949  if (iHandlerID & PH_C4GUIMainDlg)
950  {
951  assert(!fThread);
952  ::Network.HandleLobbyPacket(cStatus, pPacket, pConn);
953  }
954  // client list class (main thread)
955  if (iHandlerID & PH_C4Network2ClientList)
956  {
957  assert(!fThread);
958  ::Network.Clients.HandlePacket(cStatus, pPacket, pConn);
959  }
960  // player list class (main thread)
961  if (iHandlerID & PH_C4Network2Players)
962  {
963  assert(!fThread);
964  ::Network.Players.HandlePacket(cStatus, pPacket, pConn);
965  }
966  // resource list class (network thread)
967  if (iHandlerID & PH_C4Network2ResList)
968  {
969  assert(fThread);
970  ::Network.ResList.HandlePacket(cStatus, pPacket, pConn);
971  }
972  // network control (mixed)
973  if (iHandlerID & PH_C4GameControlNetwork)
974  {
975  ::Control.Network.HandlePacket(cStatus, pPacket, pConn);
976  }
977 }
C4GameControl Control
C4Network2 Network
Definition: C4Globals.cpp:53
@ PH_C4Network2
Definition: C4PacketBase.h:192
@ PH_C4GUIMainDlg
Definition: C4PacketBase.h:193
@ PH_C4Network2Players
Definition: C4PacketBase.h:195
@ PH_C4Network2ResList
Definition: C4PacketBase.h:196
@ PH_C4Network2IO
Definition: C4PacketBase.h:191
@ PH_C4Network2ClientList
Definition: C4PacketBase.h:194
@ PH_C4GameControlNetwork
Definition: C4PacketBase.h:197
C4GameControlNetwork Network
Definition: C4GameControl.h:67
void HandlePacket(char cStatus, const C4PacketBase *pPacket, C4Network2IOConnection *pConn)
void HandlePacket(char cStatus, const C4PacketBase *pBasePkt, C4Network2IOConnection *pConn)
C4Network2Players Players
Definition: C4Network2.h:119
void HandleLobbyPacket(char cStatus, const C4PacketBase *pBasePkt, C4Network2IOConnection *pConn)
Definition: C4Network2.cpp:963
C4Network2ResList ResList
Definition: C4Network2.h:113
void HandlePacket(char cStatus, const C4PacketBase *pBasePkt, C4Network2IOConnection *pConn)
Definition: C4Network2.cpp:879
C4Network2ClientList Clients
Definition: C4Network2.h:116
bool HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread)
void HandlePacket(char cStatus, const C4PacketBase *pPacket, class C4Network2IOConnection *pConn)
void HandlePacket(char cStatus, const C4PacketBase *pPacket, C4Network2IOConnection *pConn)

References C4Network2::Clients, Control, C4IDPacket::getPkt(), C4IDPacket::getPktType(), C4Network2::HandleLobbyPacket(), C4Network2::HandlePacket(), C4Network2ClientList::HandlePacket(), C4GameControlNetwork::HandlePacket(), C4Network2ResList::HandlePacket(), C4Network2Players::HandlePacket(), HandlePacket(), Network, C4GameControl::Network, PH_C4GameControlNetwork, PH_C4GUIMainDlg, PH_C4Network2, PH_C4Network2ClientList, PH_C4Network2IO, PH_C4Network2Players, PH_C4Network2ResList, C4Network2::Players, and C4Network2::ResList.

Referenced by HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Changed()

void StdSchedulerProc::Changed ( )
protectedinherited

Definition at line 108 of file StdScheduler.cpp.

109 {
110  auto s = scheduler;
111  if (s)
112  s->Changed(this);
113 }
#define s

References s.

Referenced by C4NetIOTCP::Accept(), C4NetIOTCP::AddConnectWait(), C4NetIOUDP::AddPeer(), C4NetIOTCP::Listen(), and CStdTimerProc::SetDelay().

Here is the caller graph for this function:

◆ CheckTimeout()

void C4Network2IO::CheckTimeout ( )
protected

Definition at line 1186 of file C4Network2IO.cpp.

1187 {
1188  // acquire lock
1189  CStdLock ConnListLock(&ConnListCSec);
1190  // check all connections for timeout (use deletion-safe iteration method just in case)
1191  for (C4Network2IOConnection *pConn = pConnList, *pNext; pConn; pConn = pNext)
1192  {
1193  pNext = pConn->pNext;
1194  // status timeout
1195  if (!pConn->isClosed() && !pConn->isAccepted())
1196  if (difftime(time(nullptr), pConn->getTimestamp()) > C4NetAcceptTimeout)
1197  {
1198  Application.InteractiveThread.ThreadLogS("Network: connection accept timeout to %s", pConn->getPeerAddr().ToString().getData());
1199  pConn->Close();
1200  }
1201  // ping timeout
1202  if (pConn->isAccepted())
1203  if ((pConn->getLag() != -1 ? pConn->getLag() : 1000 * difftime(time(nullptr), pConn->getTimestamp()))
1204  > C4NetPingTimeout)
1205  {
1206  Application.InteractiveThread.ThreadLogS("%d %d %d", (int)pConn->getLag(), (int)time(nullptr), (int)pConn->getTimestamp());
1207  Application.InteractiveThread.ThreadLogS("Network: ping timeout to %s", pConn->getPeerAddr().ToString().getData());
1208  pConn->Close();
1209  }
1210  // delayed connection removal
1211  if (pConn->isClosed())
1212  if (difftime(time(nullptr), pConn->getTimestamp()) > C4NetAcceptTimeout)
1213  RemoveConnection(pConn);
1214  }
1215 }
C4Application Application
Definition: C4Globals.cpp:44
const int C4NetPingTimeout
Definition: C4Network2IO.h:38
const int C4NetAcceptTimeout
Definition: C4Network2IO.h:37
C4InteractiveThread InteractiveThread
Definition: C4Application.h:45
bool ThreadLogS(const char *szMessage,...) GNUC_FORMAT_ATTRIBUTE_O
void RemoveConnection(C4Network2IOConnection *pConn)

References Application, C4NetAcceptTimeout, C4NetPingTimeout, ConnListCSec, C4Application::InteractiveThread, pConnList, RemoveConnection(), and C4InteractiveThread::ThreadLogS().

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void C4Network2IO::Clear ( )

Definition at line 177 of file C4Network2IO.cpp.

178 {
179  // process remaining events
181  Thread.ProcessEvents();
182  // clear event callbacks
183  Thread.ClearCallback(Ev_Net_Conn, this);
184  Thread.ClearCallback(Ev_Net_Disconn, this);
185  Thread.ClearCallback(Ev_Net_Packet, this);
186  // close all connections
187  CStdLock ConnListLock(&ConnListCSec);
188  for (C4Network2IOConnection *pConn = pConnList, *pNext; pConn; pConn = pNext)
189  {
190  pNext = pConn->pNext;
191  // close
192  pConn->Close();
193  RemoveConnection(pConn);
194  }
195  // reset list
196  pConnList = nullptr;
197  ConnListLock.Clear();
198  // close net i/o classes
199  Thread.RemoveProc(this);
200  if (pNetIODiscover) { Thread.RemoveProc(pNetIODiscover); delete pNetIODiscover; pNetIODiscover = nullptr; }
201  if (pNetIO_TCP) { Thread.RemoveProc(pNetIO_TCP); delete pNetIO_TCP; pNetIO_TCP = nullptr; }
202  if (pNetIO_UDP) { Thread.RemoveProc(pNetIO_UDP); delete pNetIO_UDP; pNetIO_UDP = nullptr; }
203  if (pRefServer) { Thread.RemoveProc(pRefServer); delete pRefServer; pRefServer = nullptr; }
204  if (UPnPMgr) { delete UPnPMgr; UPnPMgr = nullptr; }
205  // remove auto-accepts
206  ClearAutoAccept();
207  // reset flags
208  fAllowConnect = fExclusiveConn = false;
209  // reset connection ID
210  iNextConnID = 0;
211 }
@ Ev_Net_Conn
@ Ev_Net_Disconn
@ Ev_Net_Packet
void RemoveProc(StdSchedulerProc *pProc)
void ClearCallback(C4InteractiveEventType eEvent, Callback *pnNetworkCallback)
void ClearAutoAccept()
class C4Network2RefServer * pRefServer
Definition: C4Network2IO.h:61
C4NetIO * pNetIO_TCP
Definition: C4Network2IO.h:55
bool fExclusiveConn
Definition: C4Network2IO.h:90
uint32_t iNextConnID
Definition: C4Network2IO.h:75
class C4Network2IODiscover * pNetIODiscover
Definition: C4Network2IO.h:58
class C4Network2UPnP * UPnPMgr
Definition: C4Network2IO.h:64
C4NetIO * pNetIO_UDP
Definition: C4Network2IO.h:55
bool fAllowConnect
Definition: C4Network2IO.h:78

References Application, CStdLock::Clear(), ClearAutoAccept(), C4InteractiveThread::ClearCallback(), ConnListCSec, Ev_Net_Conn, Ev_Net_Disconn, Ev_Net_Packet, fAllowConnect, fExclusiveConn, iNextConnID, C4Application::InteractiveThread, pConnList, pNetIO_TCP, pNetIO_UDP, pNetIODiscover, pRefServer, C4InteractiveThread::ProcessEvents(), RemoveConnection(), C4InteractiveThread::RemoveProc(), and UPnPMgr.

Referenced by C4Network2::Clear(), Init(), C4Network2::InitNetIO(), and ~C4Network2IO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearAutoAccept()

void C4Network2IO::ClearAutoAccept ( )

Definition at line 306 of file C4Network2IO.cpp.

307 {
308  CStdLock AALock(&AutoAcceptCSec);
309  // delete
310  while (pAutoAcceptList)
311  {
312  // remove
313  AutoAccept *pAcc = pAutoAcceptList;
314  pAutoAcceptList = pAcc->Next;
315  // delete
316  delete pAcc;
317  }
318 }

References AutoAcceptCSec, and C4Network2IO::AutoAccept::Next.

Referenced by Clear().

Here is the caller graph for this function:

◆ Connect()

bool C4Network2IO::Connect ( const C4NetIO::addr_t addr,
C4Network2IOProtocol  eProt,
const C4ClientCore nCCore,
const char *  szPassword = nullptr 
)

Definition at line 233 of file C4Network2IO.cpp.

234 {
235  return ConnectWithSocket(addr, eProt, nCCore, nullptr, szPassword);
236 }
bool ConnectWithSocket(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, std::unique_ptr< C4NetIOTCP::Socket > socket, const char *szPassword=nullptr)

References ConnectWithSocket().

Referenced by C4Network2Client::DoConnectAttempt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectWithSocket()

bool C4Network2IO::ConnectWithSocket ( const C4NetIO::addr_t addr,
C4Network2IOProtocol  eProt,
const C4ClientCore nCCore,
std::unique_ptr< C4NetIOTCP::Socket socket,
const char *  szPassword = nullptr 
)

Definition at line 239 of file C4Network2IO.cpp.

240 {
241  // get network class
242  C4NetIO *pNetIO = getNetIO(eProt);
243  if (!pNetIO) return false;
244  // already connected/connecting?
245  if (GetConnectionByConnAddr(addr, pNetIO)) return true;
246  // assign new connection ID, peer address isn't known yet
247  uint32_t iConnID = iNextConnID++;
248  C4NetIO::addr_t paddr;
249  // create connection object and add to list
251  pConn->Set(pNetIO, eProt, paddr, addr, CS_Connect, szPassword, iConnID);
252  pConn->SetCCore(nCCore);
253  if (socket)
254  pConn->SetSocket(std::move(socket));
255  AddConnection(pConn);
256  // connect
257  if (!pConn->Connect())
258  {
259  // show error
260  LogSilentF("Network: could not connect to %s using %s: %s", addr.ToString().getData(),
261  getNetIOName(pNetIO), pNetIO->GetError() ? pNetIO->GetError() : "");
262  pNetIO->ResetError();
263  // remove class
264  RemoveConnection(pConn);
265  return false;
266  }
267  // ok, wait for connection
268  return true;
269 }
bool LogSilentF(const char *strMessage,...)
Definition: C4Log.cpp:272
@ CS_Connect
Definition: C4Network2IO.h:206
virtual const char * GetError() const
Definition: C4NetIO.h:286
void ResetError()
Definition: C4NetIO.h:287
void SetCCore(const C4ClientCore &nCCore)
void Set(C4NetIO *pnNetClass, C4Network2IOProtocol eProt, const C4NetIO::addr_t &nPeerAddr, const C4NetIO::addr_t &nConnectAddr, C4Network2IOConnStatus nStatus, const char *szPassword, uint32_t iID)
void SetSocket(std::unique_ptr< C4NetIOTCP::Socket > socket)
C4Network2IOConnection * GetConnectionByConnAddr(const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
C4NetIO * getNetIO(C4Network2IOProtocol eProt)
void AddConnection(C4Network2IOConnection *pConn)
const char * getNetIOName(C4NetIO *pNetIO)
const char * getData() const
Definition: StdBuf.h:442
StdStrBuf ToString(int flags=0) const
Definition: C4NetIO.cpp:604

References AddConnection(), C4Network2IOConnection::Connect(), CS_Connect, GetConnectionByConnAddr(), StdStrBuf::getData(), C4NetIO::GetError(), getNetIO(), getNetIOName(), iNextConnID, LogSilentF(), RemoveConnection(), C4NetIO::ResetError(), C4Network2IOConnection::Set(), C4Network2IOConnection::SetCCore(), C4Network2IOConnection::SetSocket(), and C4NetIO::EndpointAddress::ToString().

Referenced by Connect(), and C4Network2Client::DoTCPSimultaneousOpen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DataIO()

C4NetIO * C4Network2IO::DataIO ( )

Definition at line 226 of file C4Network2IO.cpp.

227 {
228  if (pNetIO_TCP) return pNetIO_TCP;
229  if (pNetIO_UDP) return pNetIO_UDP;
230  return nullptr;
231 }

References pNetIO_TCP, and pNetIO_UDP.

Referenced by C4Network2::DrawStatus(), and C4Network2::HandleConnRe().

Here is the caller graph for this function:

◆ doAutoAccept()

bool C4Network2IO::doAutoAccept ( const C4ClientCore CCore,
const C4Network2IOConnection Conn 
)
protected

Definition at line 811 of file C4Network2IO.cpp.

812 {
813  CStdLock AALock(&AutoAcceptCSec);
814  // check if connection with the given client should be allowed
815  for (AutoAccept *pAcc = pAutoAcceptList; pAcc; pAcc = pAcc->Next)
816  // core match?
817  if (CCore.getDiffLevel(pAcc->CCore) <= C4ClientCoreDL_IDMatch)
818  {
819  // check: already got another connection for this client? Peer IP must match, then.
820  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
821  if (pConn->isAccepted() &&
822  pConn->getCCore().getDiffLevel(CCore) <= C4ClientCoreDL_IDMatch &&
823  pConn->getPeerAddr().GetHost() != Conn.getPeerAddr().GetHost())
824  return false;
825  // not found or IP matches? Let pass
826  return true;
827  }
828  return false;
829 }
const int32_t C4ClientCoreDL_IDMatch
Definition: C4Client.h:30
int32_t getDiffLevel(const C4ClientCore &CCore2) const
Definition: C4Client.cpp:75
const C4NetIO::addr_t & getPeerAddr() const
Definition: C4Network2IO.h:266
HostAddress GetHost() const
Definition: C4NetIO.h:156

References AutoAcceptCSec, C4ClientCoreDL_IDMatch, C4ClientCore::getDiffLevel(), C4NetIO::EndpointAddress::GetHost(), C4Network2IOConnection::getPeerAddr(), C4Network2IO::AutoAccept::Next, pConnList, and C4Network2IOConnection::pNext.

Referenced by HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EndBroadcast()

void C4Network2IO::EndBroadcast ( )

Definition at line 393 of file C4Network2IO.cpp.

394 {
395  // unlock
397 }
virtual void Leave()
Definition: StdSync.h:151

References BroadcastCSec, and CStdCSec::Leave().

Referenced by BroadcastMsg(), C4Network2ClientList::BroadcastMsgToClients(), C4Network2ClientList::BroadcastMsgToConnClients(), and HandleFwdReq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

bool C4Network2IO::Execute ( int  iTimeout,
pollfd *   
)
overrideprotectedvirtual

Implements StdSchedulerProc.

Definition at line 637 of file C4Network2IO.cpp.

638 {
640 
641  // check for timeout
642  CheckTimeout();
643 
644  // ping all open connections
646  {
647  Ping();
649  }
650 
651  // do statistics
653  {
656  }
657 
658  // resources
660 
661  // ok
662  return true;
663 }
const int C4NetStatisticsFreq
Definition: C4Network2IO.h:36
const int C4NetPingFreq
Definition: C4Network2IO.h:35
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
void GenerateStatistics(int iInterval)
static C4TimeMilliseconds Now()

References C4NetPingFreq, C4NetStatisticsFreq, CheckTimeout(), GenerateStatistics(), Inside(), Network, C4TimeMilliseconds::Now(), C4Network2ResList::OnTimer(), Ping(), C4Network2::ResList, tLastExecute, tLastPing, and tLastStatistic.

Here is the call graph for this function:

◆ ExecuteUntil()

bool StdSchedulerProc::ExecuteUntil ( int  iTimeout = -1)
inherited

Definition at line 33 of file StdScheduler.cpp.

34 {
35  // Infinite?
36  if (iTimeout < 0)
37  for (;;)
38  if (!Execute())
39  return false;
40  // Calculate endpoint
41  C4TimeMilliseconds tStopTime = C4TimeMilliseconds::Now() + iTimeout;
42  for (;;)
43  {
44  // Call execute with given timeout
45  if (!Execute(std::max(iTimeout, 0)))
46  return false;
47  // Calculate timeout
49  if (tTime >= tStopTime)
50  break;
51  iTimeout = tStopTime - tTime;
52  }
53  // All ok.
54  return true;
55 }
virtual bool Execute(int iTimeout=-1, pollfd *readyfds=nullptr)=0

References StdSchedulerProc::Execute(), and C4TimeMilliseconds::Now().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateStatistics()

void C4Network2IO::GenerateStatistics ( int  iInterval)
protected

Definition at line 1217 of file C4Network2IO.cpp.

1218 {
1219  int iTCPIRateSum = 0, iTCPORateSum = 0, iUDPIRateSum = 0, iUDPORateSum = 0;
1220 
1221  // acquire lock, get connection statistics
1222  CStdLock ConnListLock(&ConnListCSec);
1223  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
1224  if (pConn->isOpen())
1225  {
1226  bool fTCP = pConn->getNetClass() == pNetIO_TCP;
1227  pConn->DoStatistics(iInterval, fTCP ? &iTCPIRateSum : &iUDPIRateSum,
1228  fTCP ? &iTCPORateSum : &iUDPORateSum);
1229  }
1230  ConnListLock.Clear();
1231 
1232  // get broadcast statistics
1233  int inTCPBCRate = 0, inUDPBCRate = 0;
1234  if (pNetIO_TCP) pNetIO_TCP->GetStatistic(&inTCPBCRate);
1235  if (pNetIO_UDP) pNetIO_UDP->GetStatistic(&inUDPBCRate);
1236 
1237  // normalize everything
1238  iTCPIRateSum = iTCPIRateSum * 1000 / iInterval;
1239  iTCPORateSum = iTCPORateSum * 1000 / iInterval;
1240  iUDPIRateSum = iUDPIRateSum * 1000 / iInterval;
1241  iUDPORateSum = iUDPORateSum * 1000 / iInterval;
1242  inTCPBCRate = inTCPBCRate * 1000 / iInterval;
1243  inUDPBCRate = inUDPBCRate * 1000 / iInterval;
1244 
1245  // clear
1248 
1249  // save back
1250  iTCPIRate = iTCPIRateSum; iTCPORate = iTCPORateSum; iTCPBCRate = inTCPBCRate;
1251  iUDPIRate = iUDPIRateSum; iUDPORate = iUDPORateSum; iUDPBCRate = inUDPBCRate;
1252 }
virtual void ClearStatistic()=0
virtual bool GetStatistic(int *pBroadcastRate)=0

References CStdLock::Clear(), C4NetIO::ClearStatistic(), ConnListCSec, C4NetIO::GetStatistic(), iTCPBCRate, iTCPIRate, iTCPORate, iUDPBCRate, iUDPIRate, iUDPORate, pConnList, pNetIO_TCP, pNetIO_UDP, and C4Network2IOConnection::pNext.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetConnection()

C4Network2IOConnection * C4Network2IO::GetConnection ( const C4NetIO::addr_t addr,
C4NetIO pNetIO 
)
protected

Definition at line 768 of file C4Network2IO.cpp.

769 {
770  CStdLock ConnListLock(&ConnListCSec);
771  // search
772  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
773  if (pConn->getNetClass() == pNetIO && pConn->getPeerAddr() == addr)
774  return pConn;
775  return nullptr;
776 }

References ConnListCSec, pConnList, and C4Network2IOConnection::pNext.

Referenced by OnDisconn(), and OnPacket().

Here is the caller graph for this function:

◆ GetConnectionByConnAddr()

C4Network2IOConnection * C4Network2IO::GetConnectionByConnAddr ( const C4NetIO::addr_t addr,
C4NetIO pNetIO 
)
protected

Definition at line 778 of file C4Network2IO.cpp.

779 {
780  CStdLock ConnListLock(&ConnListCSec);
781  // search
782  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
783  if (pConn->getNetClass() == pNetIO && pConn->getConnectAddr() == addr)
784  return pConn;
785  return nullptr;
786 }

References ConnListCSec, pConnList, and C4Network2IOConnection::pNext.

Referenced by ConnectWithSocket(), OnConn(), and OnDisconn().

Here is the caller graph for this function:

◆ GetConnectionByID()

C4Network2IOConnection * C4Network2IO::GetConnectionByID ( uint32_t  iConnID)
protected

Definition at line 788 of file C4Network2IO.cpp.

789 {
790  CStdLock ConnListLock(&ConnListCSec);
791  // search
792  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
793  if (pConn->getID() == iConnID)
794  return pConn;
795  return nullptr;
796 }

References ConnListCSec, pConnList, and C4Network2IOConnection::pNext.

Referenced by HandlePacket().

Here is the caller graph for this function:

◆ getConnectionCount()

int C4Network2IO::getConnectionCount ( )

Definition at line 296 of file C4Network2IO.cpp.

297 {
298  int iCount = 0;
299  CStdLock ConnListLock(&ConnListCSec);
300  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
301  if (!pConn->isClosed())
302  iCount++;
303  return iCount;
304 }

References ConnListCSec, pConnList, and C4Network2IOConnection::pNext.

Referenced by C4Network2::OnDisconn().

Here is the caller graph for this function:

◆ GetDataConnection()

C4Network2IOConnection * C4Network2IO::GetDataConnection ( int  iClientID)

Definition at line 368 of file C4Network2IO.cpp.

369 {
370  CStdLock ConnListLock(&ConnListCSec);
371  C4Network2IOConnection *pRes = nullptr;
372  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
373  if (pConn->isAccepted())
374  if (pConn->getClientID() == iClientID)
375  if (pConn->getProtocol() == P_TCP || !pRes)
376  pRes = pConn;
377  // add reference
378  if (pRes) pRes->AddRef();
379  return pRes;
380 }

References C4Network2IOConnection::AddRef(), ConnListCSec, P_TCP, pConnList, and C4Network2IOConnection::pNext.

Referenced by C4Network2Res::SendChunk().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFDs()

virtual void StdSchedulerProc::GetFDs ( std::vector< struct pollfd > &  )
inlinevirtualinherited

Reimplemented in C4FileMonitor, C4NetIOSimpleUDP, C4NetIOTCP, CStdNotifyProc, C4StdInProc, and C4HTTPClient.

Definition at line 72 of file StdScheduler.h.

72 { }

◆ GetMsgConnection()

C4Network2IOConnection * C4Network2IO::GetMsgConnection ( int  iClientID)

Definition at line 354 of file C4Network2IO.cpp.

355 {
356  CStdLock ConnListLock(&ConnListCSec);
357  C4Network2IOConnection *pRes = nullptr;
358  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
359  if (pConn->isAccepted())
360  if (pConn->getClientID() == iClientID)
361  if (pConn->getProtocol() == P_UDP || !pRes)
362  pRes = pConn;
363  // add reference
364  if (pRes) pRes->AddRef();
365  return pRes;
366 }

References C4Network2IOConnection::AddRef(), ConnListCSec, P_UDP, pConnList, and C4Network2IOConnection::pNext.

Referenced by BroadcastMsg(), HandleFwdReq(), SendMsgToClient(), and C4Network2Res::StartLoad().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNetIO()

C4NetIO * C4Network2IO::getNetIO ( C4Network2IOProtocol  eProt)

Definition at line 712 of file C4Network2IO.cpp.

713 {
714  switch (eProt)
715  {
716  case P_UDP: return pNetIO_UDP;
717  case P_TCP: return pNetIO_TCP;
718  default: return nullptr;
719  }
720 }

References P_TCP, P_UDP, pNetIO_TCP, and pNetIO_UDP.

Referenced by ConnectWithSocket(), C4Network2Client::DoConnectAttempt(), and C4Network2Client::DoTCPSimultaneousOpen().

Here is the caller graph for this function:

◆ getNetIOName()

const char * C4Network2IO::getNetIOName ( C4NetIO pNetIO)

Definition at line 722 of file C4Network2IO.cpp.

723 {
724  if (!pNetIO) return "nullptr";
725  if (pNetIO == pNetIO_TCP) return "TCP";
726  if (pNetIO == pNetIO_UDP) return "UDP";
727  return "UNKNOWN";
728 }

References pNetIO_TCP, and pNetIO_UDP.

Referenced by ConnectWithSocket(), C4Network2::DrawStatus(), OnConn(), C4Network2::OnConnect(), C4Network2::OnConnectFail(), OnDisconn(), C4Network2::OnDisconnect(), OnError(), OnPacket(), and C4Network2ClientDlg::UpdateText().

Here is the caller graph for this function:

◆ getNetIOProt()

C4Network2IOProtocol C4Network2IO::getNetIOProt ( C4NetIO pNetIO)

Definition at line 730 of file C4Network2IO.cpp.

731 {
732  if (!pNetIO) return P_NONE;
733  if (pNetIO == pNetIO_TCP) return P_TCP;
734  if (pNetIO == pNetIO_UDP) return P_UDP;
735  return P_NONE;
736 }
@ P_NONE
Definition: C4Network2IO.h:31

References P_NONE, P_TCP, P_UDP, pNetIO_TCP, and pNetIO_UDP.

Referenced by C4Network2::DrawStatus(), and OnConn().

Here is the caller graph for this function:

◆ GetNextTick()

C4TimeMilliseconds C4Network2IO::GetNextTick ( C4TimeMilliseconds  tNow)
overrideprotectedvirtual

Reimplemented from StdSchedulerProc.

Definition at line 665 of file C4Network2IO.cpp.

666 {
667  return tLastExecute + C4NetTimer;
668 }
const int C4NetTimer
Definition: C4Network2IO.h:34

References C4NetTimer, and tLastExecute.

◆ getProtBCRate()

int C4Network2IO::getProtBCRate ( C4Network2IOProtocol  eProt) const
inline

Definition at line 155 of file C4Network2IO.h.

155 { return eProt == P_TCP ? iTCPBCRate : iUDPBCRate; }

References iTCPBCRate, iUDPBCRate, and P_TCP.

Referenced by C4Network2::DrawStatus().

Here is the caller graph for this function:

◆ getProtIRate()

int C4Network2IO::getProtIRate ( C4Network2IOProtocol  eProt) const
inline

Definition at line 153 of file C4Network2IO.h.

153 { return eProt == P_TCP ? iTCPIRate : iUDPIRate; }

References iTCPIRate, iUDPIRate, and P_TCP.

Referenced by C4Network2::DrawStatus(), and C4Network2Stats::ExecuteSecond().

Here is the caller graph for this function:

◆ getProtORate()

int C4Network2IO::getProtORate ( C4Network2IOProtocol  eProt) const
inline

Definition at line 154 of file C4Network2IO.h.

154 { return eProt == P_TCP ? iTCPORate : iUDPORate; }

References iTCPORate, iUDPORate, and P_TCP.

Referenced by C4Network2::DrawStatus(), and C4Network2Stats::ExecuteSecond().

Here is the caller graph for this function:

◆ HandleFwdReq()

void C4Network2IO::HandleFwdReq ( const class C4PacketFwd rFwd,
C4Network2IOConnection pBy 
)
protected

Definition at line 1105 of file C4Network2IO.cpp.

1106 {
1107  CStdLock ConnListLock(&ConnListCSec);
1108  // init packet
1109  C4PacketFwd nFwd;
1110  nFwd.SetListType(false);
1111  // find all clients the message should be forwarded to
1112  int iClientID; C4Network2IOConnection *pConn;
1113  for (pConn = pConnList; pConn; pConn = pConn->pNext)
1114  if (pConn->isAccepted())
1115  if ((iClientID = pConn->getClientID()) >= 0)
1116  if (iClientID != pBy->getClientID())
1117  if (rFwd.DoFwdTo(iClientID) && !nFwd.DoFwdTo(iClientID))
1118  nFwd.AddClient(iClientID);
1119  // check count (hardcoded: broadcast for > 2 clients)
1120  if (nFwd.getClientCnt() <= 2)
1121  {
1122  C4NetIOPacket Pkt(rFwd.getData(), C4NetIO::addr_t());
1123  for (int i = 0; i < nFwd.getClientCnt(); i++)
1124  if ((pConn = GetMsgConnection(nFwd.getClient(i))))
1125  {
1126  pConn->Send(Pkt);
1127  pConn->DelRef();
1128  }
1129  }
1130  else
1131  {
1132  // Temporarily unlock connection list for getting broadcast lock
1133  // (might lead to deathlocks otherwise, as the lock is often taken
1134  // in the opposite order)
1135  ConnListLock.Clear();
1136 
1137  BeginBroadcast();
1138  nFwd.SetData(rFwd.getData());
1139  // add all clients
1140  CStdLock ConnListLock(&ConnListCSec);
1141  for (int i = 0; i < nFwd.getClientCnt(); i++)
1142  if ((pConn = GetMsgConnection(nFwd.getClient(i))))
1143  {
1144  pConn->SetBroadcastTarget(true);
1145  pConn->DelRef();
1146  }
1147  // broadcast
1149  EndBroadcast();
1150  }
1151  // doing a callback here; don't lock!
1152  ConnListLock.Clear();
1153  // forward to self?
1154  if (rFwd.DoFwdTo(LCCore.getID()))
1155  {
1156  C4NetIOPacket Packet(rFwd.getData(), pBy->getPeerAddr());
1157  HandlePacket(Packet, pBy, true);
1158  }
1159 }
C4NetIOPacket MkC4NetIOPacket(char cStatus, const class C4PacketBase &Pkt, const C4NetIO::addr_t &addr=C4NetIO::addr_t())
Definition: C4PacketBase.h:40
@ PID_Fwd
Definition: C4PacketBase.h:93
int32_t getID() const
Definition: C4Client.h:57
bool Send(const C4NetIOPacket &rPkt)
bool isAccepted() const
Definition: C4Network2IO.h:289
void SetBroadcastTarget(bool fSet)
C4ClientCore LCCore
Definition: C4Network2IO.h:67
bool DoFwdTo(int32_t iClient) const
Definition: C4Packet2.cpp:445
int32_t getClientCnt() const
Definition: C4Network2IO.h:406
int32_t getClient(int32_t i) const
Definition: C4Network2IO.h:405
void SetData(const StdBuf &Pkt)
Definition: C4Packet2.cpp:453
void AddClient(int32_t iClient)
Definition: C4Packet2.cpp:463
void SetListType(bool fnNegativeList)
Definition: C4Packet2.cpp:458

References C4PacketFwd::AddClient(), BeginBroadcast(), Broadcast(), CStdLock::Clear(), ConnListCSec, C4Network2IOConnection::DelRef(), C4PacketFwd::DoFwdTo(), EndBroadcast(), C4PacketFwd::getClient(), C4PacketFwd::getClientCnt(), C4Network2IOConnection::getClientID(), C4PacketFwd::getData(), C4ClientCore::getID(), GetMsgConnection(), C4Network2IOConnection::getPeerAddr(), HandlePacket(), C4Network2IOConnection::isAccepted(), LCCore, MkC4NetIOPacket(), pConnList, PID_Fwd, C4Network2IOConnection::pNext, C4Network2IOConnection::Send(), C4Network2IOConnection::SetBroadcastTarget(), C4PacketFwd::SetData(), and C4PacketFwd::SetListType().

Referenced by HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandlePacket() [1/2]

void C4Network2IO::HandlePacket ( char  cStatus,
const C4PacketBase pPacket,
C4Network2IOConnection pConn 
)
protected

Definition at line 979 of file C4Network2IO.cpp.

980 {
981  // security
982  if (!pConn) return;
983 
984 #define GETPKT(type, name) \
985  assert(pPacket); const type &name = \
986  static_cast<const type &>(*pPacket);
987 
988  switch (cStatus)
989  {
990 
991  case PID_Conn: // connection request
992  {
993  if (!pConn->isOpen()) break;
994  // get packet
995  GETPKT(C4PacketConn, rPkt)
996  // set connection ID
997  pConn->SetRemoteID(rPkt.getConnID());
998  // check auto-accept
999  if (doAutoAccept(rPkt.getCCore(), *pConn))
1000  {
1001  // send answer back
1002  C4PacketConnRe pcr(true, false, "auto accept");
1003  if (!pConn->Send(MkC4NetIOPacket(PID_ConnRe, pcr)))
1004  pConn->Close();
1005  // accept
1006  pConn->SetStatus(CS_HalfAccepted);
1007  pConn->SetCCore(rPkt.getCCore());
1008  pConn->SetAutoAccepted();
1009  }
1010  // note that this packet will get processed by C4Network2, too (main thread)
1011  }
1012  break;
1013 
1014  case PID_ConnRe: // connection request reply
1015  {
1016  if (!pConn->isOpen()) break;
1017  // conn not sent? That's fishy.
1018  // FIXME: Note this happens if the peer has exclusive connection mode on.
1019  if (!pConn->isConnSent())
1020  {
1021  pConn->Close();
1022  break;
1023  }
1024  // get packet
1025  GETPKT(C4PacketConnRe, rPkt)
1026  // auto accept connection
1027  if (rPkt.isOK())
1028  {
1029  if (pConn->isHalfAccepted() && pConn->isAutoAccepted())
1030  pConn->SetAccepted();
1031  }
1032  }
1033  break;
1034 
1035  case PID_Ping:
1036  {
1037  if (!pConn->isOpen()) break;
1038  GETPKT(C4PacketPing, rPkt)
1039  // pong
1040  C4PacketPing PktPong = rPkt;
1041  pConn->Send(MkC4NetIOPacket(PID_Pong, PktPong));
1042  // remove received packets from log
1043  pConn->ClearPacketLog(rPkt.getPacketCounter());
1044  }
1045  break;
1046 
1047  case PID_Pong:
1048  {
1049  if (!pConn->isOpen()) break;
1050  GETPKT(C4PacketPing, rPkt);
1051  // save
1052  pConn->SetPingTime(rPkt.getTravelTime());
1053  }
1054  break;
1055 
1056  case PID_FwdReq:
1057  {
1058  GETPKT(C4PacketFwd, rPkt);
1059  HandleFwdReq(rPkt, pConn);
1060  }
1061  break;
1062 
1063  case PID_Fwd:
1064  {
1065  GETPKT(C4PacketFwd, rPkt);
1066  // only received accidently?
1067  if (!rPkt.DoFwdTo(LCCore.getID())) break;
1068  // handle
1069  C4NetIOPacket Packet(rPkt.getData(), pConn->getPeerAddr());
1070  HandlePacket(Packet, pConn, true);
1071  }
1072  break;
1073 
1074  case PID_PostMortem:
1075  {
1076  GETPKT(C4PacketPostMortem, rPkt);
1077  // Get connection
1078  C4Network2IOConnection *pConn = GetConnectionByID(rPkt.getConnID());
1079  if (!pConn) return;
1080  // Handle all packets
1081  uint32_t iCounter;
1082  for (iCounter = pConn->getInPacketCounter(); ; iCounter++)
1083  {
1084  // Get packet
1085  const C4NetIOPacket *pPkt = rPkt.getPacket(iCounter);
1086  if (!pPkt) break;
1087  // Handle it
1088  HandlePacket(*pPkt, pConn, true);
1089  }
1090  // Log
1091  if (iCounter > pConn->getInPacketCounter())
1092  Application.InteractiveThread.ThreadLogS("Network: Recovered %d packets", iCounter - pConn->getInPacketCounter());
1093  // Remove the connection from our list
1094  if (!pConn->isClosed())
1095  pConn->Close();
1096  RemoveConnection(pConn);
1097  }
1098  break;
1099 
1100  }
1101 
1102 #undef GETPKT
1103 }
#define GETPKT(type, name)
@ CS_HalfAccepted
Definition: C4Network2IO.h:208
@ PID_PostMortem
Definition: C4PacketBase.h:96
@ PID_Conn
Definition: C4PacketBase.h:88
@ PID_Pong
Definition: C4PacketBase.h:85
@ PID_FwdReq
Definition: C4PacketBase.h:92
@ PID_Ping
Definition: C4PacketBase.h:84
@ PID_ConnRe
Definition: C4PacketBase.h:89
bool isConnSent() const
Definition: C4Network2IO.h:281
uint32_t getInPacketCounter() const
Definition: C4Network2IO.h:283
bool isHalfAccepted() const
Definition: C4Network2IO.h:288
void SetRemoteID(uint32_t iRemoteID)
void ClearPacketLog(uint32_t iStartNumber=~0)
bool isAutoAccepted() const
Definition: C4Network2IO.h:291
void SetStatus(C4Network2IOConnStatus nStatus)
void SetPingTime(int iPingTime)
bool doAutoAccept(const C4ClientCore &CCore, const C4Network2IOConnection &Conn)
void HandleFwdReq(const class C4PacketFwd &rFwd, C4Network2IOConnection *pBy)
C4Network2IOConnection * GetConnectionByID(uint32_t iConnID)
Definition: C4Network2IO.h:418

References Application, C4Network2IOConnection::ClearPacketLog(), C4Network2IOConnection::Close(), CS_HalfAccepted, doAutoAccept(), GetConnectionByID(), C4ClientCore::getID(), C4Network2IOConnection::getInPacketCounter(), C4Network2IOConnection::getPeerAddr(), GETPKT, HandleFwdReq(), HandlePacket(), C4Application::InteractiveThread, C4Network2IOConnection::isAutoAccepted(), C4Network2IOConnection::isClosed(), C4Network2IOConnection::isConnSent(), C4Network2IOConnection::isHalfAccepted(), C4Network2IOConnection::isOpen(), LCCore, MkC4NetIOPacket(), PID_Conn, PID_ConnRe, PID_Fwd, PID_FwdReq, PID_Ping, PID_Pong, PID_PostMortem, RemoveConnection(), C4Network2IOConnection::Send(), C4Network2IOConnection::SetAccepted(), C4Network2IOConnection::SetAutoAccepted(), C4Network2IOConnection::SetCCore(), C4Network2IOConnection::SetPingTime(), C4Network2IOConnection::SetRemoteID(), C4Network2IOConnection::SetStatus(), and C4InteractiveThread::ThreadLogS().

Here is the call graph for this function:

◆ HandlePacket() [2/2]

bool C4Network2IO::HandlePacket ( const C4NetIOPacket rPacket,
C4Network2IOConnection pConn,
bool  fThread 
)
protected

Definition at line 831 of file C4Network2IO.cpp.

832 {
833  // security: add connection reference
834  if (!pConn) return false;
835  pConn->AddRef();
836 
837  // accept only PID_Conn and PID_Ping on non-accepted connections
838  if(!pConn->isHalfAccepted())
839  if(rPacket.getStatus() != PID_Conn && rPacket.getStatus() != PID_Ping && rPacket.getStatus() != PID_ConnRe)
840  return false;
841 
842  // unpack packet (yet another no-idea-why-it's-needed-cast)
843  C4IDPacket Pkt; C4PacketBase &PktB = Pkt;
844  try
845  {
846  PktB.unpack(rPacket);
847  }
848  catch (StdCompiler::Exception *pExc)
849  {
850  Application.InteractiveThread.ThreadLog("Network: error: Failed to unpack packet id %02x: %s", rPacket.getStatus(), pExc->Msg.getData());
851  delete pExc;
852 #ifndef _DEBUG
853  pConn->Close();
854 #endif
855  return false;
856  }
857 
858  // dump packet (network thread only)
859 #if(C4NET2IO_DUMP_LEVEL > 0)
860  if (Config.Network.PacketLogging && fThread && Pkt.getPktType() != PID_Ping && Pkt.getPktType() != PID_Pong && Pkt.getPktType() != PID_NetResData)
861  {
862  // StdStrBuf PacketDump = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdaptrPacket);
863  StdStrBuf PacketHeader = FormatString("HandlePacket: %s by %s (%lu bytes, counter %d)",
864  C4TimeMilliseconds::Now().AsString().getData(),
865  pConn->getPeerAddr().ToString().getData(),
866  static_cast<unsigned long>(rPacket.getSize()), pConn->getInPacketCounter());
867  StdStrBuf Dump = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(Pkt, PacketHeader.getData()));
868  // Put it directly. The standard functions behind StdBuf.Format seem to choke when you pass them too much data.
870  }
871 #endif
872 
873  // search packet handling data
874  bool fSendToMainThread = false, fHandled = false;
875  for (const C4PktHandlingData *pHData = PktHandlingData; pHData->ID != PID_None; pHData++)
876  if (pHData->ID == rPacket.getStatus())
877  {
878  // correct thread?
879  if (!pHData->ProcByThread == !fThread)
880  {
881  // connection accepted?
882  if (pHData->AcceptedOnly || pConn->isAccepted() || pConn->isClosed())
883  {
884  fHandled = true;
885 #if(C4NET2IO_DUMP_LEVEL > 2)
887 #endif
888 
889  // call handler(s)
890  CallHandlers(pHData->HandlerID, &Pkt, pConn, fThread);
891 
892 #if(C4NET2IO_DUMP_LEVEL > 2)
893  uint32_t iBlockedTime = C4TimeMilliseconds::Now() - tStart;
894  if (fThread && iBlockedTime > 100)
895  {
896  Application.InteractiveThread.ThreadLogS("HandlePacket: ... blocked for %u ms!", iBlockedTime);
897  }
898 #endif
899 
900  }
901  }
902  // transfer to main thread?
903  else if (!pHData->ProcByThread && fThread)
904  {
905  fHandled = true;
906  fSendToMainThread = true;
907  }
908  }
909 
910  // send to main thread?
911  if (fSendToMainThread)
912  {
913  // create data
914  NetEvPacketData *pEvData = new NetEvPacketData;
915  pEvData->Packet.Take(rPacket.Duplicate());
916  pEvData->Conn = pConn; pConn->AddRef();
917  // trigger event
919  Application.InteractiveThread.ThreadLogS("...push event ");
920  }
921 
922  // unhandled?
923  if (!fHandled && !pConn->isClosed())
924  Application.InteractiveThread.ThreadLog("Network: Unhandled packet (status %02x)", rPacket.getStatus());
925 
926  // remove connection reference
927  pConn->DelRef();
928  return fHandled;
929 }
C4Config Config
Definition: C4Config.cpp:930
@ Ev_LogSilent
const C4PktHandlingData PktHandlingData[]
Definition: C4Packet2.cpp:50
@ PID_None
Definition: C4PacketBase.h:78
@ PID_NetResData
Definition: C4PacketBase.h:133
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4ConfigNetwork Network
Definition: C4Config.h:259
int32_t PacketLogging
Definition: C4Config.h:171
C4PacketType getPktType() const
Definition: C4PacketBase.h:259
bool ThreadLog(const char *szMessage,...) GNUC_FORMAT_ATTRIBUTE_O
bool PushEvent(C4InteractiveEventType eEventType, void *pData=nullptr)
C4NetIOPacket Duplicate() const
Definition: C4NetIO.h:326
uint8_t getStatus() const
Definition: C4NetIO.h:319
void CallHandlers(int iHandlers, const class C4IDPacket *pPacket, C4Network2IOConnection *pConn, bool fThread)
void unpack(const C4NetIOPacket &Pkt, char *pStatus=nullptr)
Definition: C4Packet2.cpp:160
size_t getSize() const
Definition: StdBuf.h:101
char * GrabPointer()
Definition: StdBuf.h:459
C4PacketType ID
Definition: C4PacketBase.h:204

References C4Network2IOConnection::AddRef(), Application, CallHandlers(), C4Network2IOConnection::Close(), Config, C4Network2IO::NetEvPacketData::Conn, C4Network2IOConnection::DelRef(), C4NetIOPacket::Duplicate(), Ev_LogSilent, Ev_Net_Packet, FormatString(), StdStrBuf::getData(), C4Network2IOConnection::getInPacketCounter(), C4Network2IOConnection::getPeerAddr(), C4IDPacket::getPktType(), StdBuf::getSize(), C4NetIOPacket::getStatus(), StdStrBuf::GrabPointer(), C4PktHandlingData::ID, C4Application::InteractiveThread, C4Network2IOConnection::isAccepted(), C4Network2IOConnection::isClosed(), C4Network2IOConnection::isHalfAccepted(), mkNamingAdapt(), StdCompiler::Exception::Msg, C4Config::Network, C4TimeMilliseconds::Now(), C4Network2IO::NetEvPacketData::Packet, C4ConfigNetwork::PacketLogging, PID_Conn, PID_ConnRe, PID_NetResData, PID_None, PID_Ping, PID_Pong, PktHandlingData, C4InteractiveThread::PushEvent(), StdBuf::Take(), C4InteractiveThread::ThreadLog(), C4InteractiveThread::ThreadLogS(), C4NetIO::EndpointAddress::ToString(), and C4PacketBase::unpack().

Referenced by CallHandlers(), HandleFwdReq(), HandlePacket(), OnPacket(), and OnThreadEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandlePuncherPacket()

void C4Network2IO::HandlePuncherPacket ( const C4NetIOPacket rPacket)
protected

Definition at line 1161 of file C4Network2IO.cpp.

1162 {
1163  auto pkt = C4NetpuncherPacket::Construct(rPacket);
1164  if (pkt && ::Network.HandlePuncherPacket(move(pkt), rPacket.getAddr().GetFamily()));
1165  else
1166  {
1167  assert(pNetIO_UDP);
1168  pNetIO_UDP->Close(rPacket.getAddr());
1169  }
1170 }
virtual bool Close()=0
const C4NetIO::addr_t & getAddr() const
Definition: C4NetIO.h:317
static std::unique_ptr< C4NetpuncherPacket > Construct(const C4NetIOPacket &rpack)
bool HandlePuncherPacket(C4NetpuncherPacket::uptr, C4NetIO::HostAddress::AddressFamily family)
Definition: C4Network2.cpp:972
AddressFamily GetFamily() const
Definition: C4NetIO.cpp:520

References C4NetIO::Close(), C4NetpuncherPacket::Construct(), C4NetIOPacket::getAddr(), C4NetIO::HostAddress::GetFamily(), C4Network2::HandlePuncherPacket(), Network, and pNetIO_UDP.

Referenced by OnPacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasTCP()

bool C4Network2IO::hasTCP ( ) const
inline

Definition at line 107 of file C4Network2IO.h.

107 { return !! pNetIO_TCP; }

References pNetIO_TCP.

Referenced by C4Network2::InitNetIO().

Here is the caller graph for this function:

◆ hasUDP()

bool C4Network2IO::hasUDP ( ) const
inline

Definition at line 108 of file C4Network2IO.h.

108 { return !! pNetIO_UDP; }

References pNetIO_UDP.

Referenced by C4Network2::InitNetIO().

Here is the caller graph for this function:

◆ Init()

bool C4Network2IO::Init ( int16_t  iPortTCP,
int16_t  iPortUDP,
int16_t  iPortDiscovery = -1,
int16_t  iPortRefServer = -1,
bool  fBroadcast = false,
bool  enable_upnp = true 
)

Definition at line 53 of file C4Network2IO.cpp.

54 {
55  // Already initialized? Clear first
56  if (pNetIO_TCP || pNetIO_UDP) Clear();
57 
58  // init members
62 
63  // init event callback
65  Thread.SetCallback(Ev_Net_Conn, this);
66  Thread.SetCallback(Ev_Net_Disconn, this);
67  Thread.SetCallback(Ev_Net_Packet, this);
68 
69  // initialize UPnP manager
70  if (enable_upnp && (iPortTCP > 0 || iPortUDP > 0))
71  {
72  assert(!UPnPMgr);
73  UPnPMgr = new C4Network2UPnP;
74  }
75 
76  // initialize net i/o classes: TCP first
77  if (iPortTCP > 0)
78  {
79  // create
80  pNetIO_TCP = new C4NetIOTCP();
81  // init
82  if (!pNetIO_TCP->Init(iPortTCP))
83  {
84  LogF("Network: could not init TCP i/o (%s)", pNetIO_TCP->GetError() ? pNetIO_TCP->GetError() : "");
85  delete pNetIO_TCP; pNetIO_TCP = nullptr;
86  }
87  else
88  LogSilentF("Network: TCP initialized on port %d", iPortTCP);
89 
90  // add to thread, set callback
91  if (pNetIO_TCP)
92  {
93  Thread.AddProc(pNetIO_TCP);
94  pNetIO_TCP->SetCallback(this);
95  if (UPnPMgr) UPnPMgr->AddMapping(P_TCP, iPortTCP, iPortTCP);
96  }
97 
98  }
99  // then UDP
100  if (iPortUDP > 0)
101  {
102  // create
103  pNetIO_UDP = new C4NetIOUDP();
104  // init
105  if (!pNetIO_UDP->Init(iPortUDP))
106  {
107  LogF("Network: could not init UDP i/o (%s)", pNetIO_UDP->GetError() ? pNetIO_UDP->GetError() : "");
108  delete pNetIO_UDP; pNetIO_UDP = nullptr;
109  }
110  else
111  LogSilentF("Network: UDP initialized on port %d", iPortUDP);
112 
113  // add to thread, set callback
114  if (pNetIO_UDP)
115  {
116  Thread.AddProc(pNetIO_UDP);
117  pNetIO_UDP->SetCallback(this);
118  if (UPnPMgr) UPnPMgr->AddMapping(P_UDP, iPortUDP, iPortUDP);
119  }
120  }
121 
122  // no protocols?
123  if (!pNetIO_TCP && !pNetIO_UDP)
124  {
125  LogFatal("Network: fatal - no protocols available!");
126  Thread.ClearCallback(Ev_Net_Conn, this);
127  Thread.ClearCallback(Ev_Net_Disconn, this);
128  Thread.ClearCallback(Ev_Net_Packet, this);
129  return false;
130  }
131 
132  // discovery last
133  if (iPortDiscover > 0)
134  {
135  // create
136  pNetIODiscover = new C4Network2IODiscover(iPortRefServer);
138  // init
139  if (!pNetIODiscover->Init(iPortDiscover))
140  {
141  LogF("Network: could not init discovery (%s)", pNetIODiscover->GetError() ? pNetIODiscover->GetError() : "");
142  delete pNetIODiscover; pNetIODiscover = nullptr;
143  }
144  else
145  LogSilentF("Network: discovery initialized on port %d", iPortDiscover);
146  // add to thread
147  if (pNetIODiscover)
148  Thread.AddProc(pNetIODiscover);
149  }
150 
151  // plus reference server
152  if (iPortRefServer > 0)
153  {
154  // create
156  // init
157  if (!pRefServer->Init(iPortRefServer))
158  {
159  LogF("Network: could not init reference server (%s)", pNetIO_UDP->GetError() ? pNetIO_UDP->GetError() : "");
160  delete pRefServer; pRefServer = nullptr;
161  }
162  else
163  LogSilentF("Network: reference server initialized on port %d", iPortRefServer);
164  // add to thread
165  if (pRefServer)
166  Thread.AddProc(pRefServer);
167  }
168 
169  // own timer
171  Thread.AddProc(this);
172 
173  // ok
174  return true;
175 }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:239
bool AddProc(StdSchedulerProc *pProc)
void SetCallback(C4InteractiveEventType eEvent, Callback *pnNetworkCallback)
virtual void SetCallback(CBClass *pnCallback)=0
virtual bool Init(uint16_t iPort=addr_t::IPPORT_NONE)=0
bool Init(uint16_t iPort=addr_t::IPPORT_NONE) override
Definition: C4NetIO.cpp:811
void SetDiscoverable(bool fnEnabled)
bool Init(uint16_t iPort=C4NetIO::addr_t::IPPORT_NONE) override
void AddMapping(enum C4Network2IOProtocol protocol, uint16_t intport, uint16_t extport)

References C4Network2UPnP::AddMapping(), C4InteractiveThread::AddProc(), Application, Clear(), C4InteractiveThread::ClearCallback(), Ev_Net_Conn, Ev_Net_Disconn, Ev_Net_Packet, C4NetIO::GetError(), C4NetIOTCP::Init(), C4NetIO::Init(), C4Network2IODiscover::Init(), C4Application::InteractiveThread, iTCPBCRate, iTCPIRate, iTCPORate, iUDPBCRate, iUDPIRate, iUDPORate, LogF(), LogFatal(), LogSilentF(), C4TimeMilliseconds::Now(), P_TCP, P_UDP, pNetIO_TCP, pNetIO_UDP, pNetIODiscover, pRefServer, C4InteractiveThread::SetCallback(), C4NetIO::SetCallback(), C4Network2IODiscover::SetDiscoverable(), tLastExecute, tLastPing, tLastStatistic, and UPnPMgr.

Referenced by C4Network2::InitNetIO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitPuncher()

bool C4Network2IO::InitPuncher ( C4NetIO::addr_t  PuncherAddr)

Definition at line 452 of file C4Network2IO.cpp.

453 {
454  // UDP must be initialized
455  if (!pNetIO_UDP)
456  return false;
457  // save address
458  switch (nPuncherAddr.GetFamily())
459  {
461  PuncherAddrIPv4 = nPuncherAddr;
462  break;
464  PuncherAddrIPv6 = nPuncherAddr;
465  break;
467  assert(!"Unexpected address family");
468  }
469  // let's punch
470  return pNetIO_UDP->Connect(nPuncherAddr);
471 }
virtual bool Connect(const addr_t &addr)=0
C4NetIO::addr_t PuncherAddrIPv4
Definition: C4Network2IO.h:102
C4NetIO::addr_t PuncherAddrIPv6
Definition: C4Network2IO.h:102

References C4NetIO::Connect(), C4NetIO::HostAddress::GetFamily(), C4NetIO::HostAddress::IPv4, C4NetIO::HostAddress::IPv6, pNetIO_UDP, PuncherAddrIPv4, PuncherAddrIPv6, and C4NetIO::HostAddress::UnknownFamily.

Referenced by C4Network2::InitPuncher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsLowPriority()

virtual bool StdSchedulerProc::IsLowPriority ( )
inlinevirtualinherited

Definition at line 82 of file StdScheduler.h.

82 { return false; }

◆ IsNotify()

virtual bool StdSchedulerProc::IsNotify ( )
inlinevirtualinherited

Reimplemented in CStdNotifyProc, and C4NetIO.

Definition at line 83 of file StdScheduler.h.

83 { return false; }

◆ IsPuncherAddr()

bool C4Network2IO::IsPuncherAddr ( const C4NetIO::addr_t addr) const
protected

Definition at line 490 of file C4Network2IO.cpp.

491 {
492  return (!PuncherAddrIPv4.IsNull() && PuncherAddrIPv4 == addr)
493  || (!PuncherAddrIPv6.IsNull() && PuncherAddrIPv6 == addr);
494 }

References C4NetIO::EndpointAddress::IsNull(), PuncherAddrIPv4, and PuncherAddrIPv6.

Referenced by OnConn(), OnDisconn(), and OnPacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsReferenceNeeded()

bool C4Network2IO::IsReferenceNeeded ( )

Definition at line 806 of file C4Network2IO.cpp.

807 {
808  return !!pRefServer;
809 }

References pRefServer.

Referenced by C4Network2::Execute().

Here is the caller graph for this function:

◆ IsSignaled()

bool StdSchedulerProc::IsSignaled ( )
inherited

◆ MsgIO()

C4NetIO * C4Network2IO::MsgIO ( )

Definition at line 219 of file C4Network2IO.cpp.

220 {
221  if (pNetIO_UDP) return pNetIO_UDP;
222  if (pNetIO_TCP) return pNetIO_TCP;
223  return nullptr;
224 }

References pNetIO_TCP, and pNetIO_UDP.

Referenced by C4Network2::DrawStatus(), and C4Network2::HandleConnRe().

Here is the caller graph for this function:

◆ OnConn()

bool C4Network2IO::OnConn ( const C4NetIO::addr_t addr,
const C4NetIO::addr_t AddrConnect,
const C4NetIO::addr_t pOwnAddr,
C4NetIO pNetIO 
)
overrideprotectedvirtual

Reimplemented from C4NetIO::CBClass.

Definition at line 497 of file C4Network2IO.cpp.

498 {
499  // puncher answer?
500  if (pNetIO == pNetIO_UDP && IsPuncherAddr(ConnectAddr))
501  {
502  // got an address?
503  if (pOwnAddr)
504  ::Network.OnPuncherConnect(*pOwnAddr);
505  return true;
506  }
507 
508 #if(C4NET2IO_DUMP_LEVEL > 1)
509  Application.InteractiveThread.ThreadLogS("OnConn: %s %s",
510  C4TimeMilliseconds::Now().AsString().getData(),
511  getNetIOName(pNetIO));
512 #endif
513  // search connection
514  C4Network2IOConnection *pConn = nullptr;
515  if (!ConnectAddr.IsNull())
516  pConn = GetConnectionByConnAddr(ConnectAddr, pNetIO);
517  // not found?
518  if (!pConn)
519  {
520  // allow connect?
521  if (!fAllowConnect) return false;
522  // create new connection object
523  uint32_t iConnID = iNextConnID++;
524  pConn = new C4Network2IOConnection();
525  pConn->Set(pNetIO, getNetIOProt(pNetIO), PeerAddr, ConnectAddr, CS_Connected, nullptr, iConnID);
526  // add to list
527  AddConnection(pConn);
528  }
529  else
530  {
531  // already closed this connection (attempt)?
532  if (pConn->isClosed())
533  return false;
534  if (!pConn->isOpen())
535  {
536  // change status
537  pConn->SetStatus(CS_Connected);
538  pConn->SetPeerAddr(PeerAddr);
539  }
540  }
541  // send welcome packet, if appropriate
542  SendConnPackets();
543 #if(C4NET2IO_DUMP_LEVEL > 0)
544  // log
545  Application.InteractiveThread.ThreadLogS("Network: got %s connection from %s", getNetIOName(pNetIO), PeerAddr.ToString().getData());
546 #endif
547  // do event (disabled - unused)
548  // pConn->AddRef(); PushNetEv(NE_Conn, pConn);
549  // ok
550  return true;
551 }
@ CS_Connected
Definition: C4Network2IO.h:207
void OnPuncherConnect(C4NetIO::addr_t addr)
void SetPeerAddr(const C4NetIO::addr_t &nPeerAddr)
C4Network2IOProtocol getNetIOProt(C4NetIO *pNetIO)
bool IsPuncherAddr(const C4NetIO::addr_t &addr) const
void SendConnPackets()

References AddConnection(), Application, CS_Connected, fAllowConnect, GetConnectionByConnAddr(), StdStrBuf::getData(), getNetIOName(), getNetIOProt(), iNextConnID, C4Application::InteractiveThread, C4Network2IOConnection::isClosed(), C4NetIO::EndpointAddress::IsNull(), C4Network2IOConnection::isOpen(), IsPuncherAddr(), Network, C4TimeMilliseconds::Now(), C4Network2::OnPuncherConnect(), pNetIO_UDP, SendConnPackets(), C4Network2IOConnection::Set(), C4Network2IOConnection::SetPeerAddr(), C4Network2IOConnection::SetStatus(), C4InteractiveThread::ThreadLogS(), and C4NetIO::EndpointAddress::ToString().

Here is the call graph for this function:

◆ OnDisconn()

void C4Network2IO::OnDisconn ( const C4NetIO::addr_t addr,
C4NetIO pNetIO,
const char *  szReason 
)
overrideprotectedvirtual

Reimplemented from C4NetIO::CBClass.

Definition at line 553 of file C4Network2IO.cpp.

554 {
555  // punch?
556  if (pNetIO == pNetIO_UDP && IsPuncherAddr(addr))
557  {
558  if (PuncherAddrIPv4 == addr)
560  else
562  return;
563  }
564 #if(C4NET2IO_DUMP_LEVEL > 1)
565  Application.InteractiveThread.ThreadLogS("OnDisconn: %s %s",
566  C4TimeMilliseconds::Now().AsString().getData(),
567  getNetIOName(pNetIO));
568 #endif
569  // find connection
570  C4Network2IOConnection *pConn = GetConnection(addr, pNetIO);
571  if (!pConn) pConn = GetConnectionByConnAddr(addr, pNetIO);
572  if (!pConn) return;
573 #if(C4NET2IO_DUMP_LEVEL > 0)
574  // log
575  Application.InteractiveThread.ThreadLogS("Network: %s connection to %s %s (%s)",
576  getNetIOName(pNetIO), addr.ToString().getData(), pConn->isConnecting() ? "failed" : "closed" , szReason);
577 #endif
578  // already closed? ignore
579  if (!pConn->isClosed())
580  // not accepted yet? count as connection failure
581  pConn->SetStatus(pConn->isHalfAccepted() ? CS_Closed : CS_ConnectFail);
582  // keep connection for main thread message
583  pConn->AddRef();
584  // check for pending welcome packets
585  SendConnPackets();
586  // signal to main thread
588  // don't remove connection from list - wait for postmortem or timeout
589 }
@ CS_ConnectFail
Definition: C4Network2IO.h:211
@ CS_Closed
Definition: C4Network2IO.h:210
bool isConnecting() const
Definition: C4Network2IO.h:286
C4Network2IOConnection * GetConnection(const C4NetIO::addr_t &addr, C4NetIO *pNetIO)

References C4Network2IOConnection::AddRef(), Application, C4NetIO::EndpointAddress::Clear(), CS_Closed, CS_ConnectFail, Ev_Net_Disconn, GetConnection(), GetConnectionByConnAddr(), StdStrBuf::getData(), getNetIOName(), C4Application::InteractiveThread, C4Network2IOConnection::isClosed(), C4Network2IOConnection::isConnecting(), C4Network2IOConnection::isHalfAccepted(), IsPuncherAddr(), C4TimeMilliseconds::Now(), pNetIO_UDP, PuncherAddrIPv4, PuncherAddrIPv6, C4InteractiveThread::PushEvent(), SendConnPackets(), C4Network2IOConnection::SetStatus(), C4InteractiveThread::ThreadLogS(), and C4NetIO::EndpointAddress::ToString().

Here is the call graph for this function:

◆ OnError()

void C4Network2IO::OnError ( const char *  strError,
C4NetIO pNetIO 
)
protectedvirtual

Definition at line 631 of file C4Network2IO.cpp.

632 {
633  // let's log it
634  Application.InteractiveThread.ThreadLog("Network: %s error: %s", getNetIOName(pNetIO), strError);
635 }

References Application, getNetIOName(), C4Application::InteractiveThread, and C4InteractiveThread::ThreadLog().

Here is the call graph for this function:

◆ OnPacket() [1/2]

void C4Network2IO::OnPacket ( const C4NetIOPacket rPacket,
C4NetIO pNetIO 
)
overrideprotected

Definition at line 591 of file C4Network2IO.cpp.

592 {
593 #if C4NET2IO_DUMP_LEVEL > 1
594  auto tTime = C4TimeMilliseconds::Now();
595 #endif
596 #if(C4NET2IO_DUMP_LEVEL > 1)
597  Application.InteractiveThread.ThreadLogS("OnPacket: %s status %02x %s",
598  C4TimeMilliseconds::Now().AsString().getData(),
599  rPacket.getStatus(), getNetIOName(pNetIO));
600 #endif
601  if (pNetIO == pNetIO_UDP && IsPuncherAddr(rPacket.getAddr()))
602  {
603  HandlePuncherPacket(rPacket);
604  return;
605  }
606  if (!rPacket.getSize()) return;
607  // find connection
608  C4Network2IOConnection *pConn = GetConnection(rPacket.getAddr(), pNetIO);
609  if (!pConn)
610  {
611  Application.InteractiveThread.ThreadLog("Network: could not find connection for %s packet (status %02x) from %s!", getNetIOName(pNetIO), rPacket.getStatus(), rPacket.getAddr().ToString().getData());
612  return;
613  }
614 #if(C4NET2IO_DUMP_LEVEL > 2)
615  uint32_t iFindConnectionBlocked = C4TimeMilliseconds::Now() - tTime;
616  if (iFindConnectionBlocked > 100)
617  Application.InteractiveThread.ThreadLogS("OnPacket: ... blocked %d ms for finding the connection!", iFindConnectionBlocked);
618 #endif
619  // notify
620  pConn->OnPacketReceived(rPacket.getStatus());
621  // handle packet
622  HandlePacket(rPacket, pConn, true);
623  // log time
624 #if(C4NET2IO_DUMP_LEVEL > 1)
625  uint32_t iHandlingBlocked = C4TimeMilliseconds::Now() - tTime;
626  if (iHandlingBlocked > 100)
627  Application.InteractiveThread.ThreadLogS("OnPacket: ... blocked %d ms for handling!", iHandlingBlocked);
628 #endif
629 }
void OnPacketReceived(uint8_t iPacketType)
void HandlePuncherPacket(const C4NetIOPacket &rPacket)

References Application, C4NetIOPacket::getAddr(), GetConnection(), StdStrBuf::getData(), getNetIOName(), StdBuf::getSize(), C4NetIOPacket::getStatus(), HandlePacket(), HandlePuncherPacket(), C4Application::InteractiveThread, IsPuncherAddr(), C4TimeMilliseconds::Now(), C4Network2IOConnection::OnPacketReceived(), pNetIO_UDP, C4InteractiveThread::ThreadLog(), C4InteractiveThread::ThreadLogS(), and C4NetIO::EndpointAddress::ToString().

Here is the call graph for this function:

◆ OnPacket() [2/2]

virtual void C4NetIO::CBClass::OnPacket ( const class C4NetIOPacket rPacket,
C4NetIO pNetIO 
)
pure virtualinherited

Implemented in C4Network2IODiscoverClient, C4Network2IODiscover, C4NetIO::CBProxy< T >, and MyCBClass.

Referenced by C4NetIOSimpleUDP::Execute(), and C4NetIOTCP::UnpackPacket().

Here is the caller graph for this function:

◆ OnThreadEvent()

void C4Network2IO::OnThreadEvent ( C4InteractiveEventType  eEvent,
void *  pEventData 
)
overrideprotectedvirtual

Implements C4InteractiveThread::Callback.

Definition at line 670 of file C4Network2IO.cpp.

671 {
672  switch (eEvent)
673  {
674  case Ev_Net_Conn: // got a connection
675  {
676  C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData);
677  // do callback
678  ::Network.OnConn(pConn);
679  // remove reference
680  pConn->DelRef();
681  }
682  break;
683 
684  case Ev_Net_Disconn: // connection closed
685  {
686  C4Network2IOConnection *pConn = reinterpret_cast<C4Network2IOConnection *>(pEventData);
687  assert(pConn->isClosed());
688  // do callback
689  ::Network.OnDisconn(pConn);
690  // remove reference
691  pConn->DelRef();
692  }
693  break;
694 
695  case Ev_Net_Packet: // got packet
696  {
697  NetEvPacketData *pData = reinterpret_cast<NetEvPacketData *>(pEventData);
698  // handle
699  HandlePacket(pData->Packet, pData->Conn, false);
700  // clear up
701  pData->Conn->DelRef();
702  delete pData;
703  }
704  break;
705 
706  default:
707  // TODO
708  break;
709  }
710 }
void OnDisconn(C4Network2IOConnection *pConn)
Definition: C4Network2.cpp:836
void OnConn(C4Network2IOConnection *pConn)
Definition: C4Network2.cpp:828

References C4Network2IO::NetEvPacketData::Conn, C4Network2IOConnection::DelRef(), Ev_Net_Conn, Ev_Net_Disconn, Ev_Net_Packet, HandlePacket(), C4Network2IOConnection::isClosed(), Network, C4Network2::OnConn(), C4Network2::OnDisconn(), and C4Network2IO::NetEvPacketData::Packet.

Here is the call graph for this function:

◆ Ping()

bool C4Network2IO::Ping ( )
protected

Definition at line 1172 of file C4Network2IO.cpp.

1173 {
1174  bool fSuccess = true;
1175  // ping all connections
1176  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
1177  if (pConn->isOpen())
1178  {
1179  C4PacketPing Ping(pConn->getInPacketCounter(), pConn->getOutPacketCounter());
1180  fSuccess &= pConn->Send(MkC4NetIOPacket(PID_Ping, Ping));
1181  pConn->OnPing();
1182  }
1183  return fSuccess;
1184 }

References MkC4NetIOPacket(), pConnList, PID_Ping, and C4Network2IOConnection::pNext.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Punch()

void C4Network2IO::Punch ( const C4NetIO::addr_t punchee_addr)

Definition at line 473 of file C4Network2IO.cpp.

474 {
475  if (!pNetIO_UDP)
476  return;
477  C4PacketPing PktPeng;
478  dynamic_cast<C4NetIOUDP*>(pNetIO_UDP)->SendDirect(MkC4NetIOPacket(PID_Pong, PktPeng, punchee_addr));
479 }

References MkC4NetIOPacket(), PID_Pong, and pNetIO_UDP.

Referenced by C4Network2::HandlePuncherPacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveAutoAccept()

void C4Network2IO::RemoveAutoAccept ( const C4ClientCore CCore)

Definition at line 331 of file C4Network2IO.cpp.

332 {
333  CStdLock AALock(&AutoAcceptCSec);
334  // find & remove
335  AutoAccept *pAcc = pAutoAcceptList, *pLast = nullptr;
336  while (pAcc)
337  if (pAcc->CCore.getDiffLevel(CCore) <= C4ClientCoreDL_IDMatch)
338  {
339  // unlink
340  AutoAccept *pDelete = pAcc;
341  pAcc = pAcc->Next;
342  (pLast ? pLast->Next : pAutoAcceptList) = pAcc;
343  // delete
344  delete pDelete;
345  }
346  else
347  {
348  // next peer
349  pLast = pAcc;
350  pAcc = pAcc->Next;
351  }
352 }

References AutoAcceptCSec, C4ClientCoreDL_IDMatch, C4Network2IO::AutoAccept::CCore, C4ClientCore::getDiffLevel(), and C4Network2IO::AutoAccept::Next.

Referenced by C4Network2ClientList::DeleteClient().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveConnection()

void C4Network2IO::RemoveConnection ( C4Network2IOConnection pConn)
protected

Definition at line 747 of file C4Network2IO.cpp.

748 {
749  CStdLock ConnListLock(&ConnListCSec);
750  // search & remove
751  if (pConnList == pConn)
752  pConnList = pConn->pNext;
753  else
754  {
756  for (pAct = pConnList; pAct; pAct = pAct->pNext)
757  if (pAct->pNext == pConn)
758  break;
759  if (pAct)
760  pAct->pNext = pConn->pNext;
761  else
762  return;
763  }
764  // remove reference
765  pConn->pNext = nullptr; pConn->DelRef();
766 }

References ConnListCSec, C4Network2IOConnection::DelRef(), pConnList, and C4Network2IOConnection::pNext.

Referenced by CheckTimeout(), Clear(), ConnectWithSocket(), and HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendConnPackets()

void C4Network2IO::SendConnPackets ( )
protected

Definition at line 1254 of file C4Network2IO.cpp.

1255 {
1256  CStdLock ConnListLock(&ConnListCSec);
1257 
1258  // exlusive conn?
1259  if (fExclusiveConn)
1260  // find a live connection
1261  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
1262  if (pConn->isAccepted() || (!pConn->isClosed() && pConn->isConnSent()))
1263  // do not sent additional conn packets - no other connection should succeed
1264  return;
1265 
1266  // sent pending welcome packet(s)
1267  for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
1268  if (pConn->isOpen() && !pConn->isConnSent())
1269  {
1270  // make packet
1271  CStdLock LCCoreLock(&LCCoreCSec);
1272  C4NetIOPacket Pkt = MkC4NetIOPacket(PID_Conn, C4PacketConn(LCCore, pConn->getID(), pConn->getPassword()));
1273  LCCoreLock.Clear();
1274  // send
1275  if (!pConn->Send(Pkt))
1276  pConn->Close();
1277  else
1278  {
1279  // set flag
1280  pConn->SetConnSent();
1281  // only one conn packet at a time
1282  if (fExclusiveConn)
1283  return;
1284  }
1285  }
1286 
1287 }
CStdCSec LCCoreCSec
Definition: C4Network2IO.h:68

References CStdLock::Clear(), ConnListCSec, fExclusiveConn, C4ClientCore::getID(), LCCore, LCCoreCSec, MkC4NetIOPacket(), pConnList, PID_Conn, and C4Network2IOConnection::pNext.

Referenced by OnConn(), OnDisconn(), and SetExclusiveConnMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendMsgToClient()

bool C4Network2IO::SendMsgToClient ( C4NetIOPacket rPkt,
int  iClient 
)

Definition at line 412 of file C4Network2IO.cpp.

413 {
414  // find msg connection
415  C4Network2IOConnection *pConn = GetMsgConnection(iClient);
416  if (!pConn) return false;
417  // send
418  bool fSuccess = pConn->Send(rPkt);
419  pConn->DelRef();
420  return fSuccess;
421 }

References C4Network2IOConnection::DelRef(), GetMsgConnection(), and C4Network2IOConnection::Send().

Here is the call graph for this function:

◆ SendPuncherPacket()

void C4Network2IO::SendPuncherPacket ( const C4NetpuncherPacket p,
C4NetIO::HostAddress::AddressFamily  family 
)

Definition at line 481 of file C4Network2IO.cpp.

482 {
483  if (!pNetIO_UDP) return;
486  else if (family == C4NetIO::HostAddress::IPv6 && !PuncherAddrIPv6.IsNull())
488 }
virtual bool Send(const class C4NetIOPacket &rPacket)=0
C4NetIOPacket PackTo(const C4NetIO::addr_t &) const

References C4NetIO::HostAddress::IPv4, C4NetIO::HostAddress::IPv6, C4NetIO::EndpointAddress::IsNull(), C4NetpuncherPacket::PackTo(), pNetIO_UDP, PuncherAddrIPv4, PuncherAddrIPv6, and C4NetIO::Send().

Referenced by C4Network2::OnPuncherConnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAcceptMode()

void C4Network2IO::SetAcceptMode ( bool  fAcceptAll)

Definition at line 271 of file C4Network2IO.cpp.

272 {
273  fAllowConnect = fnAllowConnect;
274  // Allow connect? Allow discovery of this host
275  if (fAllowConnect)
276  {
277  if (pNetIODiscover)
278  {
281  }
282  }
283 }

References C4Network2IODiscover::Announce(), fAllowConnect, pNetIODiscover, and C4Network2IODiscover::SetDiscoverable().

Referenced by C4Network2::InitHost().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetExclusiveConnMode()

void C4Network2IO::SetExclusiveConnMode ( bool  fExclusiveConn)

Definition at line 285 of file C4Network2IO.cpp.

286 {
287  if (fExclusiveConn == fnExclusiveConn)
288  return;
289  // Set flag
290  fExclusiveConn = fnExclusiveConn;
291  // Allowed? Send all pending welcome packets
292  if (!fExclusiveConn)
293  SendConnPackets();
294 }

References fExclusiveConn, and SendConnPackets().

Here is the call graph for this function:

◆ SetLocalCCore()

void C4Network2IO::SetLocalCCore ( const C4ClientCore CCore)

Definition at line 213 of file C4Network2IO.cpp.

214 {
215  CStdLock LCCoreLock(&LCCoreCSec);
216  LCCore = nCCore;
217 }

References LCCore, and LCCoreCSec.

Referenced by C4Network2::HandleJoinData(), and C4Network2::InitNetIO().

Here is the caller graph for this function:

◆ SetReference()

void C4Network2IO::SetReference ( class C4Network2Reference pReference)

Definition at line 798 of file C4Network2IO.cpp.

799 {
800  if (pRefServer)
801  pRefServer->SetReference(pReference);
802  else
803  delete pReference;
804 }
void SetReference(C4Network2Reference *pReference)

References pRefServer, and C4Network2RefServer::SetReference().

Referenced by C4Network2::Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimerInterval()

virtual uint32_t StdSchedulerProc::TimerInterval ( )
inlinevirtualinherited

Reimplemented in CStdTimerProc.

Definition at line 84 of file StdScheduler.h.

84 { return 0; }

Member Data Documentation

◆ AutoAcceptCSec

CStdCSec C4Network2IO::AutoAcceptCSec
protected

Definition at line 87 of file C4Network2IO.h.

Referenced by AddAutoAccept(), ClearAutoAccept(), doAutoAccept(), and RemoveAutoAccept().

◆ BroadcastCSec

CStdCSec C4Network2IO::BroadcastCSec
protected

Definition at line 72 of file C4Network2IO.h.

Referenced by BeginBroadcast(), and EndBroadcast().

◆ ConnListCSec

◆ fAllowConnect

bool C4Network2IO::fAllowConnect {false}
protected

Definition at line 78 of file C4Network2IO.h.

Referenced by Clear(), OnConn(), and SetAcceptMode().

◆ fExclusiveConn

bool C4Network2IO::fExclusiveConn {false}
protected

Definition at line 90 of file C4Network2IO.h.

Referenced by Clear(), SendConnPackets(), and SetExclusiveConnMode().

◆ iNextConnID

uint32_t C4Network2IO::iNextConnID {0}
protected

Definition at line 75 of file C4Network2IO.h.

Referenced by Clear(), ConnectWithSocket(), and OnConn().

◆ iTCPBCRate

int C4Network2IO::iTCPBCRate {0}
protected

Definition at line 98 of file C4Network2IO.h.

Referenced by GenerateStatistics(), getProtBCRate(), and Init().

◆ iTCPIRate

int C4Network2IO::iTCPIRate {0}
protected

Definition at line 98 of file C4Network2IO.h.

Referenced by GenerateStatistics(), getProtIRate(), and Init().

◆ iTCPORate

int C4Network2IO::iTCPORate {0}
protected

Definition at line 98 of file C4Network2IO.h.

Referenced by GenerateStatistics(), getProtORate(), and Init().

◆ iUDPBCRate

int C4Network2IO::iUDPBCRate {0}
protected

Definition at line 99 of file C4Network2IO.h.

Referenced by GenerateStatistics(), getProtBCRate(), and Init().

◆ iUDPIRate

int C4Network2IO::iUDPIRate {0}
protected

Definition at line 99 of file C4Network2IO.h.

Referenced by GenerateStatistics(), getProtIRate(), and Init().

◆ iUDPORate

int C4Network2IO::iUDPORate {0}
protected

Definition at line 99 of file C4Network2IO.h.

Referenced by GenerateStatistics(), getProtORate(), and Init().

◆ LCCore

C4ClientCore C4Network2IO::LCCore
protected

Definition at line 67 of file C4Network2IO.h.

Referenced by HandleFwdReq(), HandlePacket(), SendConnPackets(), and SetLocalCCore().

◆ LCCoreCSec

CStdCSec C4Network2IO::LCCoreCSec
protected

Definition at line 68 of file C4Network2IO.h.

Referenced by SendConnPackets(), and SetLocalCCore().

◆ nullptr

struct C4Network2IO::AutoAccept C4Network2IO::nullptr
protected

◆ pConnList

◆ pNetIO_TCP

C4NetIO* C4Network2IO::pNetIO_TCP {nullptr}
protected

◆ pNetIO_UDP

◆ pNetIODiscover

class C4Network2IODiscover* C4Network2IO::pNetIODiscover {nullptr}
protected

Definition at line 58 of file C4Network2IO.h.

Referenced by Clear(), Init(), and SetAcceptMode().

◆ pRefServer

class C4Network2RefServer* C4Network2IO::pRefServer {nullptr}
protected

Definition at line 61 of file C4Network2IO.h.

Referenced by Clear(), Init(), IsReferenceNeeded(), and SetReference().

◆ PuncherAddrIPv4

C4NetIO::addr_t C4Network2IO::PuncherAddrIPv4
protected

Definition at line 102 of file C4Network2IO.h.

Referenced by InitPuncher(), IsPuncherAddr(), OnDisconn(), and SendPuncherPacket().

◆ PuncherAddrIPv6

C4NetIO::addr_t C4Network2IO::PuncherAddrIPv6
protected

Definition at line 102 of file C4Network2IO.h.

Referenced by InitPuncher(), IsPuncherAddr(), OnDisconn(), and SendPuncherPacket().

◆ tLastExecute

C4TimeMilliseconds C4Network2IO::tLastExecute
protected

Definition at line 93 of file C4Network2IO.h.

Referenced by Execute(), GetNextTick(), and Init().

◆ tLastPing

C4TimeMilliseconds C4Network2IO::tLastPing
protected

Definition at line 94 of file C4Network2IO.h.

Referenced by Execute(), and Init().

◆ tLastStatistic

C4TimeMilliseconds C4Network2IO::tLastStatistic
protected

Definition at line 97 of file C4Network2IO.h.

Referenced by Execute(), and Init().

◆ UPnPMgr

class C4Network2UPnP* C4Network2IO::UPnPMgr {nullptr}
protected

Definition at line 64 of file C4Network2IO.h.

Referenced by Clear(), and Init().


The documentation for this class was generated from the following files: