Skip to content

Commit c852826

Browse files
committed
Added helpers to get/set SteamNetworkingIdentity as IPv4 address
P4:6571055
1 parent 935eb1c commit c852826

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/steam/steamnetworkingtypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ struct SteamNetworkingIdentity
258258

259259
void SetIPAddr( const SteamNetworkingIPAddr &addr ); // Set to specified IP:port
260260
const SteamNetworkingIPAddr *GetIPAddr() const; // returns null if we are not an IP address.
261+
void SetIPv4Addr( uint32 nIPv4, uint16 nPort ); // Set to specified IPv4:port
262+
uint32 GetIPv4() const; // returns 0 if we are not an IPv4 address.
261263

262264
// "localhost" is equivalent for many purposes to "anonymous." Our remote
263265
// will identify us by the network address we use.
@@ -1686,6 +1688,8 @@ inline void SteamNetworkingIdentity::SetSteamID64( uint64 steamID ) { m_eType =
16861688
inline uint64 SteamNetworkingIdentity::GetSteamID64() const { return m_eType == k_ESteamNetworkingIdentityType_SteamID ? m_steamID64 : 0; }
16871689
inline void SteamNetworkingIdentity::SetIPAddr( const SteamNetworkingIPAddr &addr ) { m_eType = k_ESteamNetworkingIdentityType_IPAddress; m_cbSize = (int)sizeof(m_ip); m_ip = addr; }
16881690
inline const SteamNetworkingIPAddr *SteamNetworkingIdentity::GetIPAddr() const { return m_eType == k_ESteamNetworkingIdentityType_IPAddress ? &m_ip : NULL; }
1691+
inline void SteamNetworkingIdentity::SetIPv4Addr( uint32 nIPv4, uint16 nPort ) { m_eType = k_ESteamNetworkingIdentityType_IPAddress; m_cbSize = (int)sizeof(m_ip); m_ip.SetIPv4( nIPv4, nPort ); }
1692+
inline uint32 SteamNetworkingIdentity::GetIPv4() const { return m_eType == k_ESteamNetworkingIdentityType_IPAddress ? m_ip.GetIPv4() : 0; }
16891693
inline void SteamNetworkingIdentity::SetLocalHost() { m_eType = k_ESteamNetworkingIdentityType_IPAddress; m_cbSize = (int)sizeof(m_ip); m_ip.SetIPv6LocalHost(); }
16901694
inline bool SteamNetworkingIdentity::IsLocalHost() const { return m_eType == k_ESteamNetworkingIdentityType_IPAddress && m_ip.IsLocalHost(); }
16911695
inline bool SteamNetworkingIdentity::SetGenericString( const char *pszString ) { size_t l = strlen( pszString ); if ( l >= sizeof(m_szGenericString) ) return false;

0 commit comments

Comments
 (0)