diff --git a/Resources/XPMP2.example.prf b/Resources/XPMP2.example.prf index b342328..4dfebee 100644 --- a/Resources/XPMP2.example.prf +++ b/Resources/XPMP2.example.prf @@ -89,6 +89,15 @@ remoteMCGroup 239.255.1.1 # Port used for communication between XPMP2 masters and the Remote Client. remotePort 49788 +# Interface to _send_ multicast on. +# Auto-discovery is used if option is not defined (commented out). +# Define an interface by numeric interface index or its interface name. +# If the defined interface name cannot be resolved you'll find a list +# of available interface names output to Log.txt after the respective ERROR line. +# Examples: +# remoteSendIntf Ethernet +# remoteSendIntf en0 + # TTL (Time-to-live) for multicast packets, ie. max number of hops they across routers they take remoteTTL 8 diff --git a/docs/html/Network_8cpp.html b/docs/html/Network_8cpp.html index cc5043a..ec41531 100644 --- a/docs/html/Network_8cpp.html +++ b/docs/html/Network_8cpp.html @@ -84,6 +84,12 @@ std::string XPMP2::_NetwGetIntfName (uint32_t idx, uint8_t family)  Get an interface's name. More...
  +LocalIntfAddrTy XPMP2::_NetwFindLocalIntf (const std::string &intf, uint8_t family) + Find a matching local interface based on name and family. More...
+  +std::string XPMP2::_NetwGetInterfaceNames (uint8_t family) + Return list of interface names of given family. More...
+  void XPMP2::_NetwGetLocalAddresses (bool bForceRefresh=false)  Fetch all local addresses and cache locally. More...
  diff --git a/docs/html/Network_8h_source.html b/docs/html/Network_8h_source.html index 36bd968..09f3637 100644 --- a/docs/html/Network_8h_source.html +++ b/docs/html/Network_8h_source.html @@ -81,7 +81,7 @@
58  sockaddr_in6 sa_in6; // AF_INET6 / IPv6
59  };
60 
-
62  SockAddrTy() { memset(this, 0, sizeof(SockAddrTy)); }
+
62  SockAddrTy() { memset((void*)this, 0, sizeof(SockAddrTy)); }
64  SockAddrTy (const sockaddr* pSa);
65 
67  bool operator< (const SockAddrTy& o) const
@@ -190,178 +190,180 @@
205 
206 public:
208  UDPMulticast() : SocketNetworking() {}
-
210  UDPMulticast(const std::string& _multicastAddr, int _port, int _ttl=8,
-
211  size_t _bufSize = 512, unsigned _timeOut_ms = 0);
-
213  virtual ~UDPMulticast();
-
214 
-
216  const std::string& GetMCAddr() const { return multicastAddr; }
-
217 
-
220  void Join (const std::string& _multicastAddr, int _port, int _ttl=8,
-
221  size_t _bufSize = 512, unsigned _timeOut_ms = 0);
-
222 
-
224  uint8_t GetFamily () const { return pMCAddr ? (uint8_t)pMCAddr->ai_family : AF_UNSPEC; }
-
225  bool IsIPv4 () const { return GetFamily() == AF_INET; }
-
226  bool IsIPv6 () const { return GetFamily() == AF_INET6; }
-
227 
-
229  void SendToDefault ();
-
231  void SendToAll ();
-
233  void SendToIntf (uint32_t idx);
-
234 
-
239  size_t SendMC (const void* _bufSend, size_t _bufSendSize);
-
240 
-
247  size_t RecvMC (bool bSwitchToRecvIntf,
-
248  std::string* _pFromAddr = nullptr,
-
249  SockAddrTy* _pFromSockAddr = nullptr,
-
250  bool* _pbIntfChanged = nullptr);
-
251 
-
252 protected:
-
253  void Cleanup ();
-
255  void GetAddrHints (struct addrinfo& hints) override;
-
257  void SetSendInterface (const in_addr& addr);
-
259  void SetSendInterface (uint32_t ifIdx);
-
260 };
-
261 
-
262 
-
264 class TCPConnection : public SocketNetworking
-
265 {
-
266 protected:
-
267  SOCKET f_session_socket = INVALID_SOCKET;
-
268  struct sockaddr_in f_session_addr = {};
-
269 #if APL == 1 || LIN == 1
-
271  SOCKET selfPipe[2] = { INVALID_SOCKET, INVALID_SOCKET };
-
272 #endif
-
273 
-
274 public:
-
276  TCPConnection() : SocketNetworking() {}
-
278  TCPConnection(const std::string& _addr, int _port, size_t _bufSize = 512,
-
279  unsigned _timeOut_ms = 0) :
-
280  SocketNetworking(_addr,_port,_bufSize,_timeOut_ms) {}
-
281 
-
282  virtual void Close();
-
283  void CloseListenerOnly();
-
284 
-
285  void listen (int numConnections = 1);
-
286  bool accept (bool bUnlisten = false);
-
287  bool listenAccept (int numConnections = 1);
-
288 
-
290  bool IsConnected () const { return f_session_socket != INVALID_SOCKET; };
-
291 
-
293  bool send(const char* msg);
-
294 
-
295 protected:
-
296  virtual void GetAddrHints (struct addrinfo& hints);
-
297 };
-
298 
-
299 
-
301 struct InetAddrTy {
-
302  union {
-
303  std::uint32_t addr[4] = {0,0,0,0};
-
304  struct in_addr in_addr;
-
305  struct in6_addr in6_addr;
-
306  };
-
307 
-
309  InetAddrTy () {}
-
311  InetAddrTy (const SockAddrTy& sa) { CopyFrom(sa); }
-
313  InetAddrTy (const sockaddr* pSa) { CopyFrom(SockAddrTy(pSa)); }
-
314 
-
316  void CopyFrom (const SockAddrTy& sa);
-
317 
-
319  bool operator==(const InetAddrTy& o) const
-
320  { return std::memcmp(this, &o, sizeof(*this)) == 0; }
-
321 
-
323  bool operator<(const InetAddrTy& o) const
-
324  { return std::memcmp(this, &o, sizeof(*this)) < 0; }
-
325 
-
326 };
+
210  UDPMulticast(const std::string& _multicastAddr, int _port,
+
211  const std::string& _sendIntf,
+
212  int _ttl=8, size_t _bufSize = 512, unsigned _timeOut_ms = 0);
+
214  virtual ~UDPMulticast();
+
215 
+
217  const std::string& GetMCAddr() const { return multicastAddr; }
+
218 
+
221  void Join (const std::string& _multicastAddr, int _port,
+
222  const std::string& _sendIntf,
+
223  int _ttl=8, size_t _bufSize = 512, unsigned _timeOut_ms = 0);
+
224 
+
226  uint8_t GetFamily () const { return pMCAddr ? (uint8_t)pMCAddr->ai_family : AF_UNSPEC; }
+
227  bool IsIPv4 () const { return GetFamily() == AF_INET; }
+
228  bool IsIPv6 () const { return GetFamily() == AF_INET6; }
+
229 
+
231  void SendToDefault ();
+
233  void SendToAll ();
+
235  void SendToIntf (uint32_t idx);
+
236 
+
241  size_t SendMC (const void* _bufSend, size_t _bufSendSize);
+
242 
+
249  size_t RecvMC (bool bSwitchToRecvIntf,
+
250  std::string* _pFromAddr = nullptr,
+
251  SockAddrTy* _pFromSockAddr = nullptr,
+
252  bool* _pbIntfChanged = nullptr);
+
253 
+
254 protected:
+
255  void Cleanup ();
+
257  void GetAddrHints (struct addrinfo& hints) override;
+
259  void SetSendInterface (const in_addr& addr);
+
261  void SetSendInterface (uint32_t ifIdx);
+
262 };
+
263 
+
264 
+
266 class TCPConnection : public SocketNetworking
+
267 {
+
268 protected:
+
269  SOCKET f_session_socket = INVALID_SOCKET;
+
270  struct sockaddr_in f_session_addr = {};
+
271 #if APL == 1 || LIN == 1
+
273  SOCKET selfPipe[2] = { INVALID_SOCKET, INVALID_SOCKET };
+
274 #endif
+
275 
+
276 public:
+
278  TCPConnection() : SocketNetworking() {}
+
280  TCPConnection(const std::string& _addr, int _port, size_t _bufSize = 512,
+
281  unsigned _timeOut_ms = 0) :
+
282  SocketNetworking(_addr,_port,_bufSize,_timeOut_ms) {}
+
283 
+
284  virtual void Close();
+
285  void CloseListenerOnly();
+
286 
+
287  void listen (int numConnections = 1);
+
288  bool accept (bool bUnlisten = false);
+
289  bool listenAccept (int numConnections = 1);
+
290 
+
292  bool IsConnected () const { return f_session_socket != INVALID_SOCKET; };
+
293 
+
295  bool send(const char* msg);
+
296 
+
297 protected:
+
298  virtual void GetAddrHints (struct addrinfo& hints);
+
299 };
+
300 
+
301 
+
303 struct InetAddrTy {
+
304  union {
+
305  std::uint32_t addr[4] = {0,0,0,0};
+
306  struct in_addr in_addr;
+
307  struct in6_addr in6_addr;
+
308  };
+
309 
+
311  InetAddrTy () {}
+
313  InetAddrTy (const SockAddrTy& sa) { CopyFrom(sa); }
+
315  InetAddrTy (const sockaddr* pSa) { CopyFrom(SockAddrTy(pSa)); }
+
316 
+
318  void CopyFrom (const SockAddrTy& sa);
+
319 
+
321  bool operator==(const InetAddrTy& o) const
+
322  { return std::memcmp(this, &o, sizeof(*this)) == 0; }
+
323 
+
325  bool operator<(const InetAddrTy& o) const
+
326  { return std::memcmp(this, &o, sizeof(*this)) < 0; }
327 
-
329 bool NetwIsLocalAddr (const InetAddrTy& addr);
-
331 inline bool NetwIsLocalAddr (const SockAddrTy& sa)
-
332 { return NetwIsLocalAddr(InetAddrTy(sa)); }
-
334 inline bool NetwIsLocalAddr (const sockaddr* pSa)
-
335 { return NetwIsLocalAddr(InetAddrTy(pSa)); }
-
336 
-
337 
-
338 } // namespace XPMP2
+
328 };
+
329 
+
331 bool NetwIsLocalAddr (const InetAddrTy& addr);
+
333 inline bool NetwIsLocalAddr (const SockAddrTy& sa)
+
334 { return NetwIsLocalAddr(InetAddrTy(sa)); }
+
336 inline bool NetwIsLocalAddr (const sockaddr* pSa)
+
337 { return NetwIsLocalAddr(InetAddrTy(pSa)); }
+
338 
339 
-
340 #endif /* Network_h */
+
340 } // namespace XPMP2
+
341 
+
342 #endif /* Network_h */
XPMP2::NetRuntimeError
Exception raised by XPMP2::SocketNetworking objects.
Definition: Network.h:87
XPMP2::NetRuntimeError::errTxt
std::string errTxt
OS text for what errno says, output of strerror_s()
Definition: Network.h:89
XPMP2::NetRuntimeError::fullWhat
std::string fullWhat
combines w and errTxt
Definition: Network.h:90
-
XPMP2::NetRuntimeError::NetRuntimeError
NetRuntimeError(const std::string &w)
Definition: Network.cpp:302
+
XPMP2::NetRuntimeError::NetRuntimeError
NetRuntimeError(const std::string &w)
Definition: Network.cpp:345
XPMP2::NetRuntimeError::what
const char * what() const noexcept override
Return the full message, ie. fullWhat
Definition: Network.h:93
XPMP2::SocketNetworking
Base class for any socket-based networking.
Definition: Network.h:99
-
XPMP2::SocketNetworking::~SocketNetworking
virtual ~SocketNetworking()
Destructor makes sure the socket is closed.
Definition: Network.cpp:324
+
XPMP2::SocketNetworking::~SocketNetworking
virtual ~SocketNetworking()
Destructor makes sure the socket is closed.
Definition: Network.cpp:367
XPMP2::SocketNetworking::getSocket
SOCKET getSocket() const
the socket
Definition: Network.h:138
XPMP2::SocketNetworking::isOpen
bool isOpen() const
Is a socket open?
Definition: Network.h:131
XPMP2::SocketNetworking::getBuf
const char * getBuf() const
return the buffer
Definition: Network.h:143
-
XPMP2::SocketNetworking::GetAddrString
static std::string GetAddrString(const SockAddrTy &sa, bool withPort=true)
Convert addresses to string.
Definition: Network.cpp:681
-
XPMP2::SocketNetworking::Close
virtual void Close()
Thread-safely close the connection(s) and frees the buffer.
Definition: Network.cpp:489
+
XPMP2::SocketNetworking::GetAddrString
static std::string GetAddrString(const SockAddrTy &sa, bool withPort=true)
Convert addresses to string.
Definition: Network.cpp:724
+
XPMP2::SocketNetworking::Close
virtual void Close()
Thread-safely close the connection(s) and frees the buffer.
Definition: Network.cpp:532
XPMP2::SocketNetworking::f_socket
SOCKET f_socket
Definition: Network.h:101
XPMP2::SocketNetworking::bufSize
size_t bufSize
Definition: Network.h:107
-
XPMP2::SocketNetworking::Open
virtual void Open(const std::string &_addr, int _port, size_t _bufSize=512, unsigned _timeOut_ms=0, bool _bBroadcast=false)
Creates a socket and binds it to the given local address.
Definition: Network.cpp:329
+
XPMP2::SocketNetworking::Open
virtual void Open(const std::string &_addr, int _port, size_t _bufSize=512, unsigned _timeOut_ms=0, bool _bBroadcast=false)
Creates a socket and binds it to the given local address.
Definition: Network.cpp:372
XPMP2::SocketNetworking::f_addr
std::string f_addr
Definition: Network.h:103
XPMP2::SocketNetworking::SocketNetworking
SocketNetworking()
Default constructor is not doing anything.
Definition: Network.h:115
XPMP2::SocketNetworking::f_port
int f_port
Definition: Network.h:102
-
XPMP2::SocketNetworking::Connect
virtual void Connect(const std::string &_addr, int _port, size_t _bufSize, unsigned _timeOut_ms=0)
Creates a socket and connects it to the given remote server.
Definition: Network.cpp:422
-
XPMP2::SocketNetworking::SetBufSize
void SetBufSize(size_t _bufSize)
(Re)Sets the buffer size (or clears it if _bufSize==0)
Definition: Network.cpp:503
-
XPMP2::SocketNetworking::recv
long recv()
Waits to receive a message, ensures zero-termination in the buffer.
Definition: Network.cpp:573
-
XPMP2::SocketNetworking::GetLastErr
static std::string GetLastErr()
Returns a human-readable text for the last error.
Definition: Network.cpp:521
-
XPMP2::SocketNetworking::setBlocking
void setBlocking(bool bBlock)
Set blocking mode.
Definition: Network.cpp:540
+
XPMP2::SocketNetworking::Connect
virtual void Connect(const std::string &_addr, int _port, size_t _bufSize, unsigned _timeOut_ms=0)
Creates a socket and connects it to the given remote server.
Definition: Network.cpp:465
+
XPMP2::SocketNetworking::SetBufSize
void SetBufSize(size_t _bufSize)
(Re)Sets the buffer size (or clears it if _bufSize==0)
Definition: Network.cpp:546
+
XPMP2::SocketNetworking::recv
long recv()
Waits to receive a message, ensures zero-termination in the buffer.
Definition: Network.cpp:616
+
XPMP2::SocketNetworking::GetLastErr
static std::string GetLastErr()
Returns a human-readable text for the last error.
Definition: Network.cpp:564
+
XPMP2::SocketNetworking::setBlocking
void setBlocking(bool bBlock)
Set blocking mode.
Definition: Network.cpp:583
XPMP2::SocketNetworking::GetAddrHints
virtual void GetAddrHints(struct addrinfo &hints)=0
Subclass to tell which addresses to look for.
XPMP2::SocketNetworking::buf
char * buf
Definition: Network.h:106
XPMP2::SocketNetworking::getAddr
std::string getAddr() const
the interface address
Definition: Network.h:140
-
XPMP2::SocketNetworking::broadcast
bool broadcast(const char *msg)
Sends a broadcast message.
Definition: Network.cpp:652
-
XPMP2::SocketNetworking::timedRecv
long timedRecv(int max_wait_ms)
Waits to receive a message with timeout, ensures zero-termination in the buffer.
Definition: Network.cpp:610
+
XPMP2::SocketNetworking::broadcast
bool broadcast(const char *msg)
Sends a broadcast message.
Definition: Network.cpp:695
+
XPMP2::SocketNetworking::timedRecv
long timedRecv(int max_wait_ms)
Waits to receive a message with timeout, ensures zero-termination in the buffer.
Definition: Network.cpp:653
XPMP2::SocketNetworking::getPort
int getPort() const
the port
Definition: Network.h:139
-
XPMP2::TCPConnection
Listens to TCP connections and opens a session socket upon connect.
Definition: Network.h:265
-
XPMP2::TCPConnection::IsConnected
bool IsConnected() const
Connected to a counterparty?
Definition: Network.h:290
-
XPMP2::TCPConnection::listen
void listen(int numConnections=1)
listen for incoming connections
Definition: Network.cpp:1187
-
XPMP2::TCPConnection::Close
virtual void Close()
also close session connection
Definition: Network.cpp:1157
-
XPMP2::TCPConnection::accept
bool accept(bool bUnlisten=false)
accept an incoming connections, optinally stop listening
Definition: Network.cpp:1193
-
XPMP2::TCPConnection::send
bool send(const char *msg)
send messages on session connection
Definition: Network.cpp:1265
-
XPMP2::TCPConnection::GetAddrHints
virtual void GetAddrHints(struct addrinfo &hints)
Subclass to tell which addresses to look for.
Definition: Network.cpp:1289
-
XPMP2::TCPConnection::CloseListenerOnly
void CloseListenerOnly()
only closes the listening socket, but not a connected session
Definition: Network.cpp:1170
-
XPMP2::TCPConnection::TCPConnection
TCPConnection(const std::string &_addr, int _port, size_t _bufSize=512, unsigned _timeOut_ms=0)
Constructor creates a socket and binds it to the given address.
Definition: Network.h:278
-
XPMP2::TCPConnection::f_session_socket
SOCKET f_session_socket
session socket, ie. the socket opened when a counterparty connects
Definition: Network.h:267
-
XPMP2::TCPConnection::TCPConnection
TCPConnection()
Default constructor is not doing anything.
Definition: Network.h:276
-
XPMP2::TCPConnection::f_session_addr
struct sockaddr_in f_session_addr
address of the connecting counterparty
Definition: Network.h:268
-
XPMP2::TCPConnection::listenAccept
bool listenAccept(int numConnections=1)
combines listening and accepting
Definition: Network.cpp:1212
+
XPMP2::TCPConnection
Listens to TCP connections and opens a session socket upon connect.
Definition: Network.h:267
+
XPMP2::TCPConnection::IsConnected
bool IsConnected() const
Connected to a counterparty?
Definition: Network.h:292
+
XPMP2::TCPConnection::listen
void listen(int numConnections=1)
listen for incoming connections
Definition: Network.cpp:1241
+
XPMP2::TCPConnection::Close
virtual void Close()
also close session connection
Definition: Network.cpp:1211
+
XPMP2::TCPConnection::accept
bool accept(bool bUnlisten=false)
accept an incoming connections, optinally stop listening
Definition: Network.cpp:1247
+
XPMP2::TCPConnection::send
bool send(const char *msg)
send messages on session connection
Definition: Network.cpp:1319
+
XPMP2::TCPConnection::GetAddrHints
virtual void GetAddrHints(struct addrinfo &hints)
Subclass to tell which addresses to look for.
Definition: Network.cpp:1343
+
XPMP2::TCPConnection::CloseListenerOnly
void CloseListenerOnly()
only closes the listening socket, but not a connected session
Definition: Network.cpp:1224
+
XPMP2::TCPConnection::TCPConnection
TCPConnection(const std::string &_addr, int _port, size_t _bufSize=512, unsigned _timeOut_ms=0)
Constructor creates a socket and binds it to the given address.
Definition: Network.h:280
+
XPMP2::TCPConnection::f_session_socket
SOCKET f_session_socket
session socket, ie. the socket opened when a counterparty connects
Definition: Network.h:269
+
XPMP2::TCPConnection::TCPConnection
TCPConnection()
Default constructor is not doing anything.
Definition: Network.h:278
+
XPMP2::TCPConnection::f_session_addr
struct sockaddr_in f_session_addr
address of the connecting counterparty
Definition: Network.h:270
+
XPMP2::TCPConnection::listenAccept
bool listenAccept(int numConnections=1)
combines listening and accepting
Definition: Network.cpp:1266
XPMP2::UDPMulticast
UDP Multicast, always binding to INADDR_ANY.
Definition: Network.h:195
-
XPMP2::UDPMulticast::GetMCAddr
const std::string & GetMCAddr() const
Return formatted multicast address, including port.
Definition: Network.h:216
-
XPMP2::UDPMulticast::SendToIntf
void SendToIntf(uint32_t idx)
Send future datagrams on this particular interface only.
Definition: Network.cpp:889
-
XPMP2::UDPMulticast::SendToAll
void SendToAll()
Send future datagrams on all interfaces.
Definition: Network.cpp:878
-
XPMP2::UDPMulticast::RecvMC
size_t RecvMC(bool bSwitchToRecvIntf, std::string *_pFromAddr=nullptr, SockAddrTy *_pFromSockAddr=nullptr, bool *_pbIntfChanged=nullptr)
Receive a multicast, received message is in XPMP2::SocketNetworking::GetBuf()
Definition: Network.cpp:966
-
XPMP2::UDPMulticast::SendToDefault
void SendToDefault()
Send future datagrams on default interfaces only (default)
Definition: Network.cpp:855
-
XPMP2::UDPMulticast::IsIPv6
bool IsIPv6() const
IPv6?
Definition: Network.h:226
-
XPMP2::UDPMulticast::SetSendInterface
void SetSendInterface(const in_addr &addr)
Set multicast send interface (IPv4 only)
Definition: Network.cpp:1120
+
XPMP2::UDPMulticast::GetMCAddr
const std::string & GetMCAddr() const
Return formatted multicast address, including port.
Definition: Network.h:217
+
XPMP2::UDPMulticast::Join
void Join(const std::string &_multicastAddr, int _port, const std::string &_sendIntf, int _ttl=8, size_t _bufSize=512, unsigned _timeOut_ms=0)
Connect to the multicast group.
Definition: Network.cpp:803
+
XPMP2::UDPMulticast::SendToIntf
void SendToIntf(uint32_t idx)
Send future datagrams on this particular interface only.
Definition: Network.cpp:943
+
XPMP2::UDPMulticast::SendToAll
void SendToAll()
Send future datagrams on all interfaces.
Definition: Network.cpp:932
+
XPMP2::UDPMulticast::RecvMC
size_t RecvMC(bool bSwitchToRecvIntf, std::string *_pFromAddr=nullptr, SockAddrTy *_pFromSockAddr=nullptr, bool *_pbIntfChanged=nullptr)
Receive a multicast, received message is in XPMP2::SocketNetworking::GetBuf()
Definition: Network.cpp:1020
+
XPMP2::UDPMulticast::SendToDefault
void SendToDefault()
Send future datagrams on default interfaces only (default)
Definition: Network.cpp:909
+
XPMP2::UDPMulticast::IsIPv6
bool IsIPv6() const
IPv6?
Definition: Network.h:228
+
XPMP2::UDPMulticast::SetSendInterface
void SetSendInterface(const in_addr &addr)
Set multicast send interface (IPv4 only)
Definition: Network.cpp:1174
XPMP2::UDPMulticast::oneIntfIdx
uint32_t oneIntfIdx
When sending to one interface only, which one?
Definition: Network.h:201
XPMP2::UDPMulticast::pMCAddr
struct addrinfo * pMCAddr
the multicast address
Definition: Network.h:198
-
XPMP2::UDPMulticast::SendMC
size_t SendMC(const void *_bufSend, size_t _bufSendSize)
Send a multicast.
Definition: Network.cpp:909
+
XPMP2::UDPMulticast::SendMC
size_t SendMC(const void *_bufSend, size_t _bufSendSize)
Send a multicast.
Definition: Network.cpp:963
XPMP2::UDPMulticast::mapSender
std::map< SockAddrTy, std::chrono::time_point< std::chrono::steady_clock > > mapSender
Keep a list of sources we received data from to be able to identify new sources.
Definition: Network.h:204
XPMP2::UDPMulticast::multicastAddr
std::string multicastAddr
the multicast address
Definition: Network.h:197
XPMP2::UDPMulticast::UDPMulticast
UDPMulticast()
Default constructor is not doing anything.
Definition: Network.h:208
-
XPMP2::UDPMulticast::GetFamily
uint8_t GetFamily() const
Protocol family.
Definition: Network.h:224
-
XPMP2::UDPMulticast::IsIPv4
bool IsIPv4() const
IPv4?
Definition: Network.h:225
-
XPMP2::UDPMulticast::GetAddrHints
void GetAddrHints(struct addrinfo &hints) override
returns information from *pMCAddr
Definition: Network.cpp:1109
-
XPMP2::UDPMulticast::Cleanup
void Cleanup()
Definition: Network.cpp:1098
-
XPMP2::UDPMulticast::Join
void Join(const std::string &_multicastAddr, int _port, int _ttl=8, size_t _bufSize=512, unsigned _timeOut_ms=0)
Connect to the multicast group.
Definition: Network.cpp:759
-
XPMP2::UDPMulticast::~UDPMulticast
virtual ~UDPMulticast()
makes sure pMCAddr is cleared up
Definition: Network.cpp:753
+
XPMP2::UDPMulticast::GetFamily
uint8_t GetFamily() const
Protocol family.
Definition: Network.h:226
+
XPMP2::UDPMulticast::IsIPv4
bool IsIPv4() const
IPv4?
Definition: Network.h:227
+
XPMP2::UDPMulticast::GetAddrHints
void GetAddrHints(struct addrinfo &hints) override
returns information from *pMCAddr
Definition: Network.cpp:1163
+
XPMP2::UDPMulticast::Cleanup
void Cleanup()
Definition: Network.cpp:1152
+
XPMP2::UDPMulticast::~UDPMulticast
virtual ~UDPMulticast()
makes sure pMCAddr is cleared up
Definition: Network.cpp:797
XPMP2::UDPMulticast::bSendToAll
bool bSendToAll
Send out multicast datagrams to all interfaces.
Definition: Network.h:200
XPMP2::UDPReceiver
Receives UDP messages.
Definition: Network.h:177
-
XPMP2::UDPReceiver::GetAddrHints
virtual void GetAddrHints(struct addrinfo &hints)
Sets flags to AI_PASSIVE, AF_INET, SOCK_DGRAM, IPPROTO_UDP.
Definition: Network.cpp:732
+
XPMP2::UDPReceiver::GetAddrHints
virtual void GetAddrHints(struct addrinfo &hints)
Sets flags to AI_PASSIVE, AF_INET, SOCK_DGRAM, IPPROTO_UDP.
Definition: Network.cpp:775
XPMP2::UDPReceiver::UDPReceiver
UDPReceiver(const std::string &_addr, int _port, size_t _bufSize=512, unsigned _timeOut_ms=0)
Constructor creates a socket and binds it to the given address.
Definition: Network.h:182
XPMP2::UDPReceiver::UDPReceiver
UDPReceiver()
Default constructor is not doing anything.
Definition: Network.h:180
XPMP2
Definition: XPMPAircraft.h:70
-
XPMP2::NetwIsLocalAddr
bool NetwIsLocalAddr(const InetAddrTy &addr)
Is given address a local one?
Definition: Network.cpp:1325
+
XPMP2::NetwIsLocalAddr
bool NetwIsLocalAddr(const InetAddrTy &addr)
Is given address a local one?
Definition: Network.cpp:1379
XPMP2::INVALID_SOCKET
constexpr SOCKET INVALID_SOCKET
Definition: Network.h:49
XPMP2::SOCKET
int SOCKET
Windows defines SOCKET, so we define it for non-Windows manually.
Definition: Network.h:48
-
XPMP2::InetAddrTy
Numerical IP address, used for both ipv4 and ipv6, for ease of handling.
Definition: Network.h:301
-
XPMP2::InetAddrTy::InetAddrTy
InetAddrTy(const sockaddr *pSa)
Take over from structure.
Definition: Network.h:313
-
XPMP2::InetAddrTy::CopyFrom
void CopyFrom(const SockAddrTy &sa)
Take over address from structure.
Definition: Network.cpp:1302
-
XPMP2::InetAddrTy::operator<
bool operator<(const InetAddrTy &o) const
Comparison also uses memcmp for defined order.
Definition: Network.h:323
-
XPMP2::InetAddrTy::operator==
bool operator==(const InetAddrTy &o) const
Equality means: all elements are equal.
Definition: Network.h:319
-
XPMP2::InetAddrTy::InetAddrTy
InetAddrTy()
Default does nothing.
Definition: Network.h:309
-
XPMP2::InetAddrTy::InetAddrTy
InetAddrTy(const SockAddrTy &sa)
Take over from structure.
Definition: Network.h:311
+
XPMP2::InetAddrTy
Numerical IP address, used for both ipv4 and ipv6, for ease of handling.
Definition: Network.h:303
+
XPMP2::InetAddrTy::InetAddrTy
InetAddrTy(const sockaddr *pSa)
Take over from structure.
Definition: Network.h:315
+
XPMP2::InetAddrTy::CopyFrom
void CopyFrom(const SockAddrTy &sa)
Take over address from structure.
Definition: Network.cpp:1356
+
XPMP2::InetAddrTy::operator<
bool operator<(const InetAddrTy &o) const
Comparison also uses memcmp for defined order.
Definition: Network.h:325
+
XPMP2::InetAddrTy::operator==
bool operator==(const InetAddrTy &o) const
Equality means: all elements are equal.
Definition: Network.h:321
+
XPMP2::InetAddrTy::InetAddrTy
InetAddrTy()
Default does nothing.
Definition: Network.h:311
+
XPMP2::InetAddrTy::InetAddrTy
InetAddrTy(const SockAddrTy &sa)
Take over from structure.
Definition: Network.h:313
XPMP2::SockAddrTy
Helper definition for all these IPv4/6 differences.
Definition: Network.h:54
XPMP2::SockAddrTy::operator<
bool operator<(const SockAddrTy &o) const
Comparison bases solely on memory compare, order isn't important, just that there is order.
Definition: Network.h:67
XPMP2::SockAddrTy::isIp4
bool isIp4() const
is this an IPv4 address?
Definition: Network.h:74
diff --git a/docs/html/Remote_8h_source.html b/docs/html/Remote_8h_source.html index c9c1caf..9cf20a2 100644 --- a/docs/html/Remote_8h_source.html +++ b/docs/html/Remote_8h_source.html @@ -197,24 +197,24 @@
XPMP2::UDPMulticast
UDP Multicast, always binding to INADDR_ANY.
Definition: Network.h:195
XPMP2
Definition: XPMPAircraft.h:70
XPMP2::mapRmtAcCacheTy
std::map< XPMPPlaneID, RmtAcCacheTy > mapRmtAcCacheTy
Defines a map with the plane id as key and the aboce cache structure as payload.
Definition: Remote.h:63
-
XPMP2::RemoteAcClearAll
void RemoteAcClearAll()
Informs us that there are no more aircraft, clear our caches!
Definition: Remote.cpp:1376
-
XPMP2::RemoteAcEnqueueDone
void RemoteAcEnqueueDone()
Informs us that all a/c have been processed: All pending messages to be sent now.
Definition: Remote.cpp:1315
-
XPMP2::RemoteAcRemove
void RemoteAcRemove(const Aircraft &ac)
Informs us about an aircraft deletion.
Definition: Remote.cpp:1348
-
XPMP2::RemoteAcEnqueueStarts
void RemoteAcEnqueueStarts(float now)
Definition: Remote.cpp:1190
+
XPMP2::RemoteAcClearAll
void RemoteAcClearAll()
Informs us that there are no more aircraft, clear our caches!
Definition: Remote.cpp:1378
+
XPMP2::RemoteAcEnqueueDone
void RemoteAcEnqueueDone()
Informs us that all a/c have been processed: All pending messages to be sent now.
Definition: Remote.cpp:1317
+
XPMP2::RemoteAcRemove
void RemoteAcRemove(const Aircraft &ac)
Informs us about an aircraft deletion.
Definition: Remote.cpp:1350
+
XPMP2::RemoteAcEnqueueStarts
void RemoteAcEnqueueStarts(float now)
Definition: Remote.cpp:1192
XPMP2::RemoteMsgTy
RemoteMsgTy
Message type.
Definition: XPMPRemote.h:77
XPMP2::RMT_MSG_AC_ANIM
@ RMT_MSG_AC_ANIM
aircraft animation values (dataRef values) only
Definition: XPMPRemote.h:83
-
XPMP2::RemoteSenderUpdateStatus
void RemoteSenderUpdateStatus()
Compares current vs. expected status and takes appropriate action.
Definition: Remote.cpp:1153
+
XPMP2::RemoteSenderUpdateStatus
void RemoteSenderUpdateStatus()
Compares current vs. expected status and takes appropriate action.
Definition: Remote.cpp:1155
XPMP2::RemoteCfgTy
RemoteCfgTy
Configuration for remote communications support.
Definition: Remote.h:32
XPMP2::REMOTE_CFG_ON
@ REMOTE_CFG_ON
config: force on
Definition: Remote.h:35
XPMP2::REMOTE_CFG_OFF
@ REMOTE_CFG_OFF
config: force off
Definition: Remote.h:33
XPMP2::REMOTE_CFG_AUTO
@ REMOTE_CFG_AUTO
config: on if in a netwoked/multiplayer setup
Definition: Remote.h:34
XPMP2::ptrRmtDataBaseTy
std::unique_ptr< RmtDataBaseTy > ptrRmtDataBaseTy
Smart pointer to XPMP2::RmtDataBaseTy by which we manage objects of this and derived types.
Definition: Remote.h:79
XPMP2::RmtDataAcRemoveTy
RmtDataEnqeueTy< RemoteAcRemoveTy, RMT_MSG_AC_REMOVE > RmtDataAcRemoveTy
A/C Removal queue type.
Definition: Remote.h:100
-
XPMP2::RemoteCleanup
void RemoteCleanup()
Grace cleanup, stops all threads.
Definition: Remote.cpp:1130
-
XPMP2::RemoteAcEnqueue
void RemoteAcEnqueue(const Aircraft &ac)
Regularly called from the flight loop callback to send a/c date onto the network.
Definition: Remote.cpp:1221
+
XPMP2::RemoteCleanup
void RemoteCleanup()
Grace cleanup, stops all threads.
Definition: Remote.cpp:1132
+
XPMP2::RemoteAcEnqueue
void RemoteAcEnqueue(const Aircraft &ac)
Regularly called from the flight loop callback to send a/c date onto the network.
Definition: Remote.cpp:1223
XPMP2::queueRmtDataTy
std::queue< ptrRmtDataBaseTy, std::list< ptrRmtDataBaseTy > > queueRmtDataTy
A queue managing the information objects, used to transfer data between main thread and network threa...
Definition: Remote.h:81
XPMP2::ptrRmtDataAcAnimTy
std::unique_ptr< RmtDataAcAnimTy > ptrRmtDataAcAnimTy
Smart pointer to XPMP2::RmtDataAcAnimTy.
Definition: Remote.h:122
-
XPMP2::RemoteInit
void RemoteInit()
Initialize the module.
Definition: Remote.cpp:1121
+
XPMP2::RemoteInit
void RemoteInit()
Initialize the module.
Definition: Remote.cpp:1123
XPMP2::RmtDataAcPosUpdateTy
RmtDataEnqeueTy< RemoteAcPosUpdateTy, RMT_MSG_AC_POS_UPDATE > RmtDataAcPosUpdateTy
A/C Position Update queue type.
Definition: Remote.h:99
XPMP2::DR_VALS
DR_VALS
The dataRefs provided by XPMP2 to the CSL models.
Definition: XPMPAircraft.h:87
XPMP2::V_COUNT
@ V_COUNT
always last, number of dataRefs XPMP2 pre-defines
Definition: XPMPAircraft.h:137
diff --git a/docs/html/Sound_8h_source.html b/docs/html/Sound_8h_source.html index 768cae8..459753d 100644 --- a/docs/html/Sound_8h_source.html +++ b/docs/html/Sound_8h_source.html @@ -358,7 +358,7 @@
XPMP2::logERR
@ logERR
errors mean, aircraft can potentially not be displayed
Definition: Utilities.h:253
XPMP2::leftOf
std::string leftOf(const std::string &s, const std::string &terminators)
Returns everything left of any of terminators.
Definition: Utilities.h:118
XPMP2::mapSoundPtrTy
std::map< std::string, SoundFilePtr > mapSoundPtrTy
Map of all sounds, indexed by a sound name (type)
Definition: Sound.h:146
-
XPMP2::LogMsg
void LogMsg(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...)
Log Text to log file.
Definition: Utilities.cpp:848
+
XPMP2::LogMsg
void LogMsg(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...)
Log Text to log file.
Definition: Utilities.cpp:849
XPMP2::gpSndSys
SoundSystem * gpSndSys
The sound system in use.
Definition: Sound.cpp:39
XPMP2::SoundInit
void SoundInit()
Initialize the sound module and load the sounds.
Definition: Sound.cpp:973
XPMP2::FmodHeadPitchRoll2Normal
void FmodHeadPitchRoll2Normal(const float head, const float pitch, const float roll, FMOD_VECTOR &vecDir, FMOD_VECTOR &vecNorm)
Convert heading/pitch to normal x/y/z vector.
Definition: Sound.cpp:682
diff --git a/docs/html/Utilities_8h.html b/docs/html/Utilities_8h.html index 809c271..af245ec 100644 --- a/docs/html/Utilities_8h.html +++ b/docs/html/Utilities_8h.html @@ -377,7 +377,7 @@

if (XPMP2::glob.bLogMdlMatch && lvl >= glob.logLvl) \
{LogMsg(__FILE__, __LINE__, __func__, lvl, __VA_ARGS__);} \
}
-
void LogMsg(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...)
Log Text to log file.
Definition: Utilities.cpp:848
+
void LogMsg(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...)
Log Text to log file.
Definition: Utilities.cpp:849
GlobVars glob
The one and only global variable structure.
Definition: Utilities.cpp:29
logLevelTy logLvl
Logging level.
Definition: XPMP2.h:132
diff --git a/docs/html/Utilities_8h_source.html b/docs/html/Utilities_8h_source.html index 33b0ea0..e505810 100644 --- a/docs/html/Utilities_8h_source.html +++ b/docs/html/Utilities_8h_source.html @@ -322,7 +322,7 @@
#define WHITESPACE
Definition: Utilities.h:89
#define XPMP2_FMTARGS(FMT)
To apply printf-style warnings to our functions.
Definition: Utilities.h:245
Definition: XPMPAircraft.h:70
-
std::valarray< float > HeadPitch2Vec(const float head, const float pitch)
Convert heading/pitch to normalized x/y/z vector.
Definition: Utilities.cpp:657
+
std::valarray< float > HeadPitch2Vec(const float head, const float pitch)
Convert heading/pitch to normalized x/y/z vector.
Definition: Utilities.cpp:658
T rad2deg(const T _rad)
Convert radians to degrees, normalized to [0..360)
Definition: Utilities.h:145
logLevelTy
Logging level.
Definition: Utilities.h:249
@ logFATAL
fatal is shortly before a crash
Definition: Utilities.h:254
@@ -332,47 +332,47 @@
@ logERR
errors mean, aircraft can potentially not be displayed
Definition: Utilities.h:253
@ logINFO
regular info messages
Definition: Utilities.h:251
std::string leftOf(const std::string &s, const std::string &terminators)
Returns everything left of any of terminators.
Definition: Utilities.h:118
-
const char * LogGetString(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg, va_list args)
Returns ptr to static buffer filled with formatted log string.
Definition: Utilities.cpp:808
+
const char * LogGetString(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg, va_list args)
Returns ptr to static buffer filled with formatted log string.
Definition: Utilities.cpp:809
constexpr const char * RSRC_OBJ8DATAREFS
Definition: Utilities.h:38
std::string TOPOSIX(const std::string &p)
On Lin/Win there is no need for a conversion, but we do treat p now as std::string
Definition: Utilities.h:349
constexpr double PI
Pi.
Definition: Utilities.h:133
-
void LogMsg(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...)
Log Text to log file.
Definition: Utilities.cpp:848
-
bool CheckEverySoOften(float &_lastCheck, float _interval, float _now)
Convenience function to check on something at most every x seconds.
Definition: Utilities.cpp:764
+
void LogMsg(const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...)
Log Text to log file.
Definition: Utilities.cpp:849
+
bool CheckEverySoOften(float &_lastCheck, float _interval, float _now)
Convenience function to check on something at most every x seconds.
Definition: Utilities.cpp:765
std::string & ltrim(std::string &s, const char *t=WHITESPACE)
trimming of string (from left)
Definition: Utilities.h:104
-
std::string GetMiscNetwTimeStr(float _time)
Return the network time as a string like used in the XP's Log.txt.
Definition: Utilities.cpp:720
+
std::string GetMiscNetwTimeStr(float _time)
Return the network time as a string like used in the XP's Log.txt.
Definition: Utilities.cpp:721
std::string FROMPOSIX(const std::string &p)
On Lin/Win there is no need for a conversion, but we do treat p now as std::string
Definition: Utilities.h:351
float angleLocCoord(float x1, float z1, float x2, float z2)
Angle of line from point (x1|z1) to point (x2|z2)
Definition: Utilities.h:176
-
void RemoveExtension(std::string &path)
Removes everything after the last dot, the dot including.
Definition: Utilities.cpp:472
-
std::list< std::string > GetDirContents(const std::string &path)
List of files in a directory (wrapper around XPLMGetDirectoryContents)
Definition: Utilities.cpp:403
+
void RemoveExtension(std::string &path)
Removes everything after the last dot, the dot including.
Definition: Utilities.cpp:473
+
std::list< std::string > GetDirContents(const std::string &path)
List of files in a directory (wrapper around XPLMGetDirectoryContents)
Definition: Utilities.cpp:404
constexpr const char * RSRC_RELATED
Definition: Utilities.h:34
-
std::valarray< float > HeadPitchRoll2Normal(const float head, const float pitch, const float roll)
Convert heading/pitch/roll to unit and normal vector, ie. returns 6 values, first 3 like HeadPitch2Ve...
Definition: Utilities.cpp:678
+
std::valarray< float > HeadPitchRoll2Normal(const float head, const float pitch, const float roll)
Convert heading/pitch/roll to unit and normal vector, ie. returns 6 values, first 3 like HeadPitch2Ve...
Definition: Utilities.cpp:679
T sqr(const T a)
Square.
Definition: Utilities.h:155
-
float GetMiscNetwTime()
Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log....
Definition: Utilities.cpp:711
+
float GetMiscNetwTime()
Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log....
Definition: Utilities.cpp:712
bool fequal(float a, float b)
Are these two float near-equal? (to avoid trying something like a == b)
Definition: Utilities.h:139
-
const std::string & GetXPSystemPath()
Returns XP's system directory, including a trailing slash.
Definition: Utilities.cpp:449
+
const std::string & GetXPSystemPath()
Returns XP's system directory, including a trailing slash.
Definition: Utilities.cpp:450
numT headNormalize(numT _head)
Normalize a heading value to [0..360), works for both float and double values.
Definition: Utilities.h:184
constexpr float EPSILON_F
Epsilon, a small number.
Definition: Utilities.h:136
-
const char * GetGraphicsDriverTxt()
Text string for current graphics driver in use.
Definition: Utilities.cpp:737
-
float headDiff(float head1, float head2)
(Shortest) difference between 2 angles: How much to turn to go from h1 to h2?
Definition: Utilities.cpp:637
-
bool ExistsFile(const std::string &filename)
Does a file path exist?
Definition: Utilities.cpp:319
-
bool CreateDir(const std::string &path)
Create directory if it does not exist.
Definition: Utilities.cpp:335
-
std::string & str_tolower(std::string &s)
change a std::string to uppercase
Definition: Utilities.cpp:583
-
bool CopyFileIfNewer(const std::string &source, const std::string &destDir)
Copy file if source is newer or destination missing.
Definition: Utilities.cpp:350
+
const char * GetGraphicsDriverTxt()
Text string for current graphics driver in use.
Definition: Utilities.cpp:738
+
float headDiff(float head1, float head2)
(Shortest) difference between 2 angles: How much to turn to go from h1 to h2?
Definition: Utilities.cpp:638
+
bool ExistsFile(const std::string &filename)
Does a file path exist?
Definition: Utilities.cpp:320
+
bool CreateDir(const std::string &path)
Create directory if it does not exist.
Definition: Utilities.cpp:336
+
std::string & str_tolower(std::string &s)
change a std::string to uppercase
Definition: Utilities.cpp:584
+
bool CopyFileIfNewer(const std::string &source, const std::string &destDir)
Copy file if source is newer or destination missing.
Definition: Utilities.cpp:351
constexpr const char * RSRC_MAP_ICONS
Definition: Utilities.h:37
-
bool IsPaused()
X-Plane in a Pause state?
Definition: Utilities.cpp:750
-
bool IsViewExternal()
Is current X-Plane view an external view (outside a cockpit)?
Definition: Utilities.cpp:757
+
bool IsPaused()
X-Plane in a Pause state?
Definition: Utilities.cpp:751
+
bool IsViewExternal()
Is current X-Plane view an external view (outside a cockpit)?
Definition: Utilities.cpp:758
T dist(const T x1, const T y1, const T z1, const T x2, const T y2, const T z2)
Pythagorean distance between two points in a 3-D world.
Definition: Utilities.h:159
std::string & trim(std::string &s, const char *t=WHITESPACE)
trimming of string (from both ends)
Definition: Utilities.h:112
-
std::string StripXPSysDir(const std::string &path)
If a path starts with X-Plane's system directory it is stripped.
Definition: Utilities.cpp:462
+
std::string StripXPSysDir(const std::string &path)
If a path starts with X-Plane's system directory it is stripped.
Definition: Utilities.cpp:463
T deg2rad(const T _deg)
Convert degree to radians.
Definition: Utilities.h:150
constexpr const char * RSRC_REL_OP
Definition: Utilities.h:35
std::string & rtrim(std::string &s, const char *t=WHITESPACE)
trimming of string (from right)
Definition: Utilities.h:96
-
bool IsDir(const std::string &path)
Is path a directory?
Definition: Utilities.cpp:326
+
bool IsDir(const std::string &path)
Is path a directory?
Definition: Utilities.cpp:327
float atan2deg(float x, float y)
atan2 converted to degrees: the angle between (0|0) and the given point
Definition: Utilities.h:166
-
int PrefsFuncIntDefault(const char *, const char *, int _default)
Default config function just always returns the provided default value.
Definition: Utilities.cpp:161
+
int PrefsFuncIntDefault(const char *, const char *, int _default)
Default config function just always returns the provided default value.
Definition: Utilities.cpp:162
constexpr const char * RSRC_DOC8643
Definition: Utilities.h:36
-
std::vector< std::string > str_tokenize(const std::string s, const std::string tokens, bool bSkipEmpty)
separates string into tokens
Definition: Utilities.cpp:590
-
std::istream & safeGetline(std::istream &is, std::string &t)
Read a line from a text file, no matter if ending on CRLF or LF.
Definition: Utilities.cpp:436
+
std::vector< std::string > str_tokenize(const std::string s, const std::string tokens, bool bSkipEmpty)
separates string into tokens
Definition: Utilities.cpp:591
+
std::istream & safeGetline(std::istream &is, std::string &t)
Read a line from a text file, no matter if ending on CRLF or LF.
Definition: Utilities.cpp:437