Break out high level library init and kill to a seperate file.

This doesn't exist in the Steamworks SDK, so moving it to a seperate file means that the files that are in both branches can have fewer differences.

Deleted the "GameServer" interface.  That is a Steamworks thing.  I'll add another method to create additional interfaces later, if we need them.

CreateSocketPair now allows you to assign the identities to each end of the pipe.

Fix some really basic irritating issues trying to use ordinary UDP and loopback connections without an identity.  Make it more straightforward to just use generic identity with no authentication.
This commit is contained in:
Fletcher Dunn
2019-01-07 17:06:50 -08:00
committed by Steven Noonan
parent 8a1bbece9a
commit 5a25561336
16 changed files with 236 additions and 256 deletions
@@ -22,14 +22,6 @@
class ISteamNetworkingSocketsCallbacks;
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
enum { k_iSteamNetworkingCallbacks = 1200 };
#else
// #KLUDGE! This is so we don't have to link with steam_api.lib
#include <steam/steam_api.h>
#include <steam/steam_gameserver.h>
#endif
//-----------------------------------------------------------------------------
/// Lower level networking interface that more closely mirrors the standard
/// Berkeley sockets model. Sockets are hard! You should probably only use
@@ -278,76 +270,21 @@ public:
/// on ephemeral ports. Fake lag and loss are supported in this case, and CPU time is expended
/// to encrypt and decrypt.
///
/// The SteamID assigned to both ends of the connection will be the SteamID of this interface.
virtual bool CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback ) = 0;
/// If you wish to assign a specific identity to either connection, you may pass a particular
/// identity. Otherwise, if you pass nullptr, the respective connection will assume a generic
/// "localhost" identity. If you use real network loopback, this might be translated to the
/// actual bound loopback port. Otherwise, the port will be zero.
virtual bool CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pIdentity1, const SteamNetworkingIdentity *pIdentity2 ) = 0;
/// Get the identity assigned to this interface.
/// E.g. on Steam, this is the user's SteamID, or for the gameserver interface, the SteamID assigned
/// to the gameserver. Returns false and sets the result to an invalid identity if we don't know
/// our identity yet. (E.g. GameServer has not logged in. On Steam, the user will know their SteamID
/// even if they are not signed into Steam.)
virtual bool GetIdentity( SteamNetworkingIdentity *pIdentity ) = 0;
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
//
// Clients connecting to dedicated servers hosted in a data center,
// using central-authority-granted tickets.
//
/// Called when we receive a ticket from our central matchmaking system. Puts the
/// ticket into a persistent cache, and optionally returns the parsed ticket.
///
/// See stamdatagram_ticketgen.h for more details.
virtual bool ReceivedRelayAuthTicket( const void *pvTicket, int cbTicket, SteamDatagramRelayAuthTicket *pOutParsedTicket ) = 0;
/// Search cache for a ticket to talk to the server on the specified virtual port.
/// If found, returns the number of second until the ticket expires, and optionally
/// the complete cracked ticket. Returns 0 if we don't have a ticket.
///
/// Typically this is useful just to confirm that you have a ticket, before you
/// call ConnectToHostedDedicatedServer to connect to the server.
virtual int FindRelayAuthTicketForServer( const SteamNetworkingIdentity &identityGameServer, int nVirtualPort, SteamDatagramRelayAuthTicket *pOutParsedTicket ) = 0;
/// Client call to connect to a server hosted in a Valve data center, on the specified virtual
/// port. You should have received a ticket for this server, or else this connect call will fail!
///
/// You may wonder why tickets are stored in a cache, instead of simply being passed as an argument
/// here. The reason is to make reconnection to a gameserver robust, even if the client computer loses
/// connection to Steam or the central backend, or the app is restarted or crashes, etc.
virtual HSteamNetConnection ConnectToHostedDedicatedServer( const SteamNetworkingIdentity &identityTarget, int nVirtualPort ) = 0;
//
// Servers hosted in Valve data centers
//
/// Returns the value of the SDR_LISTEN_PORT environment variable.
virtual uint16 GetHostedDedicatedServerPort() = 0;
/// If you are running in a production data center, this will return the data
/// center code. Returns 0 otherwise.
virtual SteamNetworkingPOPID GetHostedDedicatedServerPOPID() = 0;
/// Return info about the hosted server. You will need to send this information to your
/// backend, and put it in tickets, so that the relays will know how to forward traffic from
/// clients to your server. See SteamDatagramRelayAuthTicket for more info.
///
/// NOTE ABOUT DEVELOPMENT ENVIRONMENTS:
/// In production in our data centers, these parameters are configured via environment variables.
/// In development, the only one you need to set is SDR_LISTEN_PORT, which is the local port you
/// want to listen on. Furthermore, if you are running your server behind a corporate firewall,
/// you probably will not be able to put the routing information returned by this function into
/// tickets. Instead, it should be a public internet address that the relays can use to send
/// data to your server. So you might just end up hardcoding a public address and setup port
/// forwarding on your corporate firewall. In that case, the port you put into the ticket
/// needs to be the public-facing port opened on your firewall, if it is different from the
/// actual server port.
///
/// This function will fail if SteamDatagramServer_Init has not been called.
///
/// Returns false if the SDR_LISTEN_PORT environment variable is not set.
virtual bool GetHostedDedicatedServerAddress( SteamDatagramHostedAddress *pRouting ) = 0;
/// Create a listen socket on the specified virtual port. The physical UDP port to use
/// will be determined by the SDR_LISTEN_PORT environment variable. If a UDP port is not
/// configured, this call will fail.
///
/// Note that this call MUST be made through the SteamNetworkingSocketsGameServer() interface
virtual HSteamListenSocket CreateHostedDedicatedServerListenSocket( int nVirtualPort ) = 0;
// Connecting to servers in known data centers, through Valve's relay network
#endif // #ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
//
@@ -386,65 +323,19 @@ public:
virtual bool SetConnectionConfigurationValue( HSteamNetConnection hConn, ESteamNetworkingConnectionConfigurationValue eConfigValue, int32 nValue ) = 0;
// TEMP KLUDGE Call to invoke all queued callbacks.
// Eventually this function will go away, and callwacks will be ordinary Steamworks callbacks.
// Eventually this function will go away, and callbacks will be ordinary Steamworks callbacks.
// You should call this at the same time you call SteamAPI_RunCallbacks and SteamGameServer_RunCallbacks
// to minimize potential changes in timing when that change happens.
virtual void RunCallbacks( ISteamNetworkingSocketsCallbacks *pCallbacks ) = 0;
protected:
~ISteamNetworkingSockets(); // Silence some warnings
};
//#define STEAMNETWORKINGSOCKETS_VERSION "SteamNetworkingSockets001"
#define STEAMNETWORKINGSOCKETS_VERSION "SteamNetworkingSockets001"
extern "C" {
// Global accessor. This will eventually be moved to steam_api.h.
// Global accessor.
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamNetworkingSockets();
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamNetworkingSocketsGameServer();
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
STEAMNETWORKINGSOCKETS_INTERFACE bool GameNetworkingSockets_Init( SteamDatagramErrMsg &errMsg );
STEAMNETWORKINGSOCKETS_INTERFACE void GameNetworkingSockets_Kill();
#else
/////////////////////////////////////////////////////////////////////////////
// Temp internal gross stuff you should ignore
typedef void * ( S_CALLTYPE *FSteamInternal_CreateInterface )( const char *);
typedef void ( S_CALLTYPE *FSteamAPI_RegisterCallback)( class CCallbackBase *pCallback, int iCallback );
typedef void ( S_CALLTYPE *FSteamAPI_UnregisterCallback)( class CCallbackBase *pCallback );
typedef void ( S_CALLTYPE *FSteamAPI_RegisterCallResult)( class CCallbackBase *pCallback, SteamAPICall_t hAPICall );
typedef void ( S_CALLTYPE *FSteamAPI_UnregisterCallResult)( class CCallbackBase *pCallback, SteamAPICall_t hAPICall );
STEAMNETWORKINGSOCKETS_INTERFACE void SteamDatagramClient_SetLauncher( const char *pszLauncher ); // Call this before SteamDatagramClient_Init
STEAMNETWORKINGSOCKETS_INTERFACE void SteamDatagramClient_Internal_SteamAPIKludge( FSteamAPI_RegisterCallback fnRegisterCallback, FSteamAPI_UnregisterCallback fnUnregisterCallback, FSteamAPI_RegisterCallResult fnRegisterCallResult, FSteamAPI_UnregisterCallResult fnUnregisterCallResult );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamDatagramClient_Init_InternalV6( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamDatagramServer_Init_Internal( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe );
/////////////////////////////////////////////////////////////////////////////
/// Initialize the user interface.
/// iPartnerMask - set this to 1 for now
inline bool SteamDatagramClient_Init( SteamDatagramErrMsg &errMsg )
{
SteamDatagramClient_Internal_SteamAPIKludge( &::SteamAPI_RegisterCallback, &::SteamAPI_UnregisterCallback, &::SteamAPI_RegisterCallResult, &::SteamAPI_UnregisterCallResult );
return SteamDatagramClient_Init_InternalV6( errMsg, ::SteamInternal_CreateInterface, ::SteamAPI_GetHSteamUser(), ::SteamAPI_GetHSteamPipe() );
}
/// Shutdown all clients and close all sockets
STEAMNETWORKINGSOCKETS_INTERFACE void SteamDatagramClient_Kill();
/// Initialize the game server interface
inline bool SteamDatagramServer_Init( SteamDatagramErrMsg &errMsg )
{
SteamDatagramClient_Internal_SteamAPIKludge( &::SteamAPI_RegisterCallback, &::SteamAPI_UnregisterCallback, &::SteamAPI_RegisterCallResult, &::SteamAPI_UnregisterCallResult );
return SteamDatagramServer_Init_Internal( errMsg, &SteamInternal_CreateInterface, ::SteamGameServer_GetHSteamUser(), ::SteamGameServer_GetHSteamPipe() );
}
/// Shutdown the game server interface
STEAMNETWORKINGSOCKETS_INTERFACE void SteamDatagramServer_Kill( );
#endif
/// Callback struct used to notify when a connection has changed state
#if defined( VALVE_CALLBACK_PACK_SMALL )
@@ -456,47 +347,13 @@ STEAMNETWORKINGSOCKETS_INTERFACE void SteamDatagramServer_Kill( );
#endif
struct SteamNetConnectionStatusChangedCallback_t
{
enum { k_iCallback = k_iSteamNetworkingCallbacks + 9 }; // Pretty sure this ID is available. It will probably change later
enum { k_iCallback = k_iSteamNetworkingSocketsCallbacks + 1 };
HSteamNetConnection m_hConn; //< Connection handle
SteamNetConnectionInfo_t m_info; //< Full connection info
int m_eOldState; //< ESNetSocketState. (Current stats is in m_info)
};
#pragma pack( pop )
/// TEMP callback dispatch mechanism.
/// You'll override this guy and hook any callbacks you are interested in,
/// and then use ISteamNetworkingSockets::RunCallbacks. Eventually this will go away,
/// and you will register for the callbacks you want using the normal SteamWorks callback
/// mechanisms, and they will get dispatched along with other Steamworks callbacks
/// when you call SteamAPI_RunCallbacks and SteamGameServer_RunCallbacks.
class ISteamNetworkingSocketsCallbacks
{
public:
inline ISteamNetworkingSocketsCallbacks() {}
virtual void OnSteamNetConnectionStatusChanged( SteamNetConnectionStatusChangedCallback_t * ) {}
virtual void OnP2PSessionRequest( P2PSessionRequest_t * ) {}
virtual void OnP2PSessionConnectFail( P2PSessionConnectFail_t * ) {}
protected:
inline ~ISteamNetworkingSocketsCallbacks() {}
};
enum ESteamNetworkingSocketsDebugOutputType
{
k_ESteamNetworkingSocketsDebugOutputType_None,
k_ESteamNetworkingSocketsDebugOutputType_Bug, // You used the API incorrectly, or an internal error happened
k_ESteamNetworkingSocketsDebugOutputType_Error, // Run-time error condition that isn't the result of a bug. (E.g. we are offline, cannot bind a port, etc)
k_ESteamNetworkingSocketsDebugOutputType_Important, // Nothing is wrong, but this is an important notification
k_ESteamNetworkingSocketsDebugOutputType_Warning,
k_ESteamNetworkingSocketsDebugOutputType_Msg, // Recommended amount
k_ESteamNetworkingSocketsDebugOutputType_Verbose, // Quite a bit
k_ESteamNetworkingSocketsDebugOutputType_Debug, // Practically everything
k_ESteamNetworkingSocketsDebugOutputType_Everything, // Everything
};
/// Setup callback for debug output, and the desired verbosity you want.
typedef void (*FSteamNetworkingSocketsDebugOutput)( /* ESteamNetworkingSocketsDebugOutputType */ int nType, const char *pszMsg );
STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetDebugOutputFunction( /* ESteamNetworkingSocketsDebugOutputType */ int eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc );
}
#endif // ISTEAMNETWORKINGSOCKETS
@@ -0,0 +1,48 @@
//====== Copyright Valve Corporation, All rights reserved. ====================
//
// High level control of the GameNetworkingSockets library.
//
//=============================================================================
#ifndef GAMENETWORKINGSOCKETS
#define GAMENETWORKINGSOCKETS
#ifdef _WIN32
#pragma once
#endif
#include "isteamnetworkingsockets.h"
extern "C" {
/// Initialize the library, setting the identity of the default interface. (The one
/// returned by SteamNetworkingSockets() ). If you specify null, a default identity
/// of "localhost" is used. You will be able to make loopback connections, and
/// UDP connections if authentication for UDP is disabled. (It is by default.)
STEAMNETWORKINGSOCKETS_INTERFACE bool GameNetworkingSockets_Init( const SteamNetworkingIdentity *pIdentity, SteamDatagramErrMsg &errMsg );
/// Shutdown library
STEAMNETWORKINGSOCKETS_INTERFACE void GameNetworkingSockets_Kill();
/// Set debug output hook
STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetDebugOutputFunction( /* ESteamNetworkingSocketsDebugOutputType */ int eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc );
}
/// Callback dispatch mechanism.
/// You'll override this guy and hook any callbacks you are interested in,
/// and then use ISteamNetworkingSockets::RunCallbacks. In Steam code, this is not used.
/// You register for the callbacks you want using the normal SteamWorks callback
/// mechanisms, which are dispatched along with other Steamworks callbacks when you call
/// SteamAPI_RunCallbacks and SteamGameServer_RunCallbacks.
class ISteamNetworkingSocketsCallbacks
{
public:
inline ISteamNetworkingSocketsCallbacks() {}
virtual void OnSteamNetConnectionStatusChanged( SteamNetConnectionStatusChangedCallback_t * ) {}
//virtual void OnP2PSessionRequest( P2PSessionRequest_t * ) {}
//virtual void OnP2PSessionConnectFail( P2PSessionConnectFail_t * ) {}
protected:
inline ~ISteamNetworkingSocketsCallbacks() {}
};
#endif // GAMENETWORKINGSOCKETS
@@ -5,30 +5,44 @@
#define STEAMNETWORKINGSOCKETS_OPENSOURCE
#ifndef PLAT_EXTERN_C
#ifdef __cplusplus
#define PLAT_EXTERN_C extern "C"
#else
#define PLAT_EXTERN_C extern
#endif
#endif
#if defined( STEAMDATAGRAMLIB_STATIC_LINK )
#define STEAMNETWORKINGSOCKETS_INTERFACE extern
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C
#else
#if defined _WIN32 || defined __CYGWIN__
#ifdef STEAMDATAGRAMLIB_FOREXPORT
#ifdef __GNUC__
#define STEAMNETWORKINGSOCKETS_INTERFACE __attribute__ ((dllexport))
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C __attribute__ ((dllexport))
#else
#define STEAMNETWORKINGSOCKETS_INTERFACE __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
#endif
#else
#ifdef __GNUC__
#define STEAMNETWORKINGSOCKETS_INTERFACE __attribute__ ((dllimport))
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C __attribute__ ((dllimport))
#else
#define STEAMNETWORKINGSOCKETS_INTERFACE __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
#endif
#endif
#else
#if __GNUC__ >= 4
#define STEAMNETWORKINGSOCKETS_INTERFACE __attribute__ ((visibility ("default")))
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C __attribute__ ((visibility ("default")))
#else
#define STEAMNETWORKINGSOCKETS_INTERFACE
#define STEAMNETWORKINGSOCKETS_INTERFACE PLAT_EXTERN_C
#endif
#endif
#endif
// Callback identifiers. These aren't actually relevant with the callback
// dispatch mechanism we are using, but they are in Steam, so let's define them
// here to keep the code the same.
enum { k_iSteamNetworkingSocketsCallbacks = 1220 };
enum { k_iSteamNetworkingMessagesCallbacks = 1250 };
#endif // #ifndef STEAMNETWORKINGSOCKETS_CONFIG
@@ -38,7 +38,7 @@ STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_GetQuickC
STEAMNETWORKINGSOCKETS_INTERFACE int SteamAPI_ISteamNetworkingSockets_GetDetailedConnectionStatus( intptr_t instancePtr, HSteamNetConnection hConn, char *pszBuf, int cbBuf );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_GetListenSocketAddress( intptr_t instancePtr, HSteamListenSocket hSocket, SteamNetworkingIPAddr *pAddress );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_CreateSocketPair( intptr_t instancePtr, HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_CreateSocketPair( intptr_t instancePtr, HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pIdentity1, const SteamNetworkingIdentity *pIdentity2 );
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
@@ -23,12 +23,9 @@
#error "Must define VALVE_CALLBACK_PACK_SMALL or VALVE_CALLBACK_PACK_LARGE"
#endif
struct SteamNetworkPingLocation_t;
struct SteamDatagramRelayAuthTicket;
struct SteamDatagramHostedAddress;
struct SteamNetConnectionStatusChangedCallback_t;
struct P2PSessionRequest_t;
struct P2PSessionConnectFail_t;
/// Handle used to identify a connection to a remote host.
typedef uint32 HSteamNetConnection;
@@ -360,7 +357,7 @@ enum ESteamNetworkingConnectionState
k_ESteamNetworkingConnectionState_Dead = -3,
};
/// Identifier used for a network location point of presence.
/// Identifier used for a network location point of presence. (E.g. a Valve data center.)
/// Typically you won't need to directly manipulate these.
typedef uint32 SteamNetworkingPOPID;
@@ -483,9 +480,6 @@ typedef struct _SteamNetworkingMessage_t
#endif
} SteamNetworkingMessage_t;
// For code compatibility
typedef SteamNetworkingMessage_t ISteamNetworkingMessage;
/// Object that describes a "location" on the Internet with sufficient
/// detail that we can reasonably estimate an upper bound on the ping between
/// the two hosts, even if a direct route between the hosts is not possible,
@@ -664,11 +658,11 @@ enum ESteamNetConnectionEnd
};
/// Max length of diagnostic error message
const int k_cchMaxSteamDatagramErrMsg = 1024;
const int k_cchMaxSteamNetworkingErrMsg = 1024;
/// Used to return English-language diagnostic error messages to caller.
/// (For debugging or spewing to a console, etc. Not intended for UI.)
typedef char SteamDatagramErrMsg[ k_cchMaxSteamDatagramErrMsg ];
typedef char SteamNetworkingErrMsg[ k_cchMaxSteamNetworkingErrMsg ];
/// Max length, in bytes (including null terminator) of the reason string
/// when a connection is closed.
@@ -968,16 +962,36 @@ enum ESteamNetworkingConnectionConfigurationValue
k_ESteamNetworkingConnectionConfigurationValue_Count,
};
enum ESteamNetworkingSocketsDebugOutputType
{
k_ESteamNetworkingSocketsDebugOutputType_None,
k_ESteamNetworkingSocketsDebugOutputType_Bug, // You used the API incorrectly, or an internal error happened
k_ESteamNetworkingSocketsDebugOutputType_Error, // Run-time error condition that isn't the result of a bug. (E.g. we are offline, cannot bind a port, etc)
k_ESteamNetworkingSocketsDebugOutputType_Important, // Nothing is wrong, but this is an important notification
k_ESteamNetworkingSocketsDebugOutputType_Warning,
k_ESteamNetworkingSocketsDebugOutputType_Msg, // Recommended amount
k_ESteamNetworkingSocketsDebugOutputType_Verbose, // Quite a bit
k_ESteamNetworkingSocketsDebugOutputType_Debug, // Practically everything
k_ESteamNetworkingSocketsDebugOutputType_Everything, // Everything
};
/// Setup callback for debug output, and the desired verbosity you want.
typedef void (*FSteamNetworkingSocketsDebugOutput)( /* ESteamNetworkingSocketsDebugOutputType */ int nType, const char *pszMsg );
///////////////////////////////////////////////////////////////////////////////
//
// Internal stuff
// For code compatibility
typedef SteamNetworkingMessage_t ISteamNetworkingMessage;
typedef SteamNetworkingErrMsg SteamDatagramErrMsg;
STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr &addr, char *buf, size_t cbBuf, bool bWithPort );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr );
STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf );
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, size_t sizeofIdentity, const char *pszStr );
STEAMNETWORKINGSOCKETS_INTERFACE uint32 SteamNetworking_Hash( const void *data, size_t len );
///////////////////////////////////////////////////////////////////////////////
//
// Definitions of inline functions declared above
inline void SteamNetworkingIPAddr::Clear() { memset( this, 0, sizeof(*this) ); }
inline bool SteamNetworkingIPAddr::IsIPv6AllZeros() const { const uint64 *q = (const uint64 *)m_ipv6; return q[0] == 0 && q[1] == 0; }
inline void SteamNetworkingIPAddr::SetIPv6( const uint8 *ipv6, uint16 nPort ) { memcpy( m_ipv6, ipv6, 16 ); m_port = nPort; }
+1 -1
View File
@@ -576,7 +576,7 @@ inline void NetLog( ... ) {}
#endif // #if 0 // SDR_PUBLIC
#ifdef _DEBUG
#if defined( _DEBUG ) && !defined( STEAMNETWORKINGSOCKETS_OPENSOURCE )
template<typename DEST_POINTER_TYPE, typename SOURCE_POINTER_TYPE>
inline DEST_POINTER_TYPE assert_cast(SOURCE_POINTER_TYPE* pSource)
{
@@ -1,6 +1,7 @@
//====== Copyright Valve Corporation, All rights reserved. ====================
#include "csteamnetworkingsockets.h"
#include <steamnetworkingsockets/steamnetworkingsockets.h>
#include "steamnetworkingsockets_lowlevel.h"
#include "steamnetworkingsockets_connections.h"
#include "steamnetworkingsockets_udp.h"
@@ -265,7 +266,7 @@ CSteamNetworkingSockets::CSteamNetworkingSockets( bool bGameServer )
static int s_nSteamNetworkingSocketsInitted = 0;
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
bool CSteamNetworkingSockets::BInitNonSteam( SteamDatagramErrMsg &errMsg )
bool CSteamNetworkingSockets::BInitNonSteam( const SteamNetworkingIdentity *pIdentity, SteamDatagramErrMsg &errMsg )
{
AssertMsg( !m_bInitted, "Initted interface twice?" );
@@ -273,6 +274,9 @@ bool CSteamNetworkingSockets::BInitNonSteam( SteamDatagramErrMsg &errMsg )
if ( !BSteamNetworkingSocketsInitCommon( errMsg) )
return false;
if ( pIdentity )
m_identity = *pIdentity;
m_bInitted = true;
++s_nSteamNetworkingSocketsInitted;
@@ -329,7 +333,7 @@ bool CSteamNetworkingSockets::BInit( ISteamClient *pClient, HSteamUser hSteamUse
// Cache our identity, if we're online
m_identity.Clear();
GetIdentity();
InternalGetIdentity();
m_bInitted = true;
++s_nSteamNetworkingSocketsInitted;
@@ -426,11 +430,11 @@ void CSteamNetworkingSockets::OnCallback( SteamServersConnected_t *param )
{
SteamDatagramTransportLock lock;
m_eLogonStatus = k_ELogonStatus_Connected;
GetIdentity();
InternalGetIdentity();
if ( m_bGameServer )
{
SpewMsg( "Gameserver logged on to Steam, assigned identity %s\n", SteamNetworkingIdentityRender( GetIdentity() ).c_str() );
SpewMsg( "Gameserver logged on to Steam, assigned identity %s\n", SteamNetworkingIdentityRender( InternalGetIdentity() ).c_str() );
}
// See if we should make a cert request now. We only need to do this if we have
@@ -444,6 +448,7 @@ void CSteamNetworkingSockets::OnCallback( SteamServersConnected_t *param )
void CSteamNetworkingSockets::OnCallback( SteamServerConnectFailure_t *param )
{
SteamDatagramTransportLock scopeLock;
ELogonStatus eSaveStatus = m_eLogonStatus;
m_eLogonStatus = k_ELogonStatus_Disconnected;
if ( eSaveStatus == CSteamNetworkingSockets::k_ELogonStatus_InitialConnecting )
@@ -455,6 +460,7 @@ void CSteamNetworkingSockets::OnCallback( SteamServerConnectFailure_t *param )
void CSteamNetworkingSockets::OnCallback( SteamServersDisconnected_t *param )
{
SteamDatagramTransportLock scopeLock;
ELogonStatus eSaveStatus = m_eLogonStatus;
m_eLogonStatus = k_ELogonStatus_Disconnected;
if ( eSaveStatus == CSteamNetworkingSockets::k_ELogonStatus_InitialConnecting )
@@ -465,7 +471,7 @@ void CSteamNetworkingSockets::OnCallback( SteamServersDisconnected_t *param )
}
#endif
const SteamNetworkingIdentity &CSteamNetworkingSockets::GetIdentity()
const SteamNetworkingIdentity &CSteamNetworkingSockets::InternalGetIdentity()
{
// FIXME SteamNetworkingIdentity
// Should eventually support other types
@@ -489,6 +495,15 @@ const SteamNetworkingIdentity &CSteamNetworkingSockets::GetIdentity()
return m_identity;
}
bool CSteamNetworkingSockets::GetIdentity( SteamNetworkingIdentity *pIdentity )
{
SteamDatagramTransportLock scopeLock;
InternalGetIdentity();
if ( pIdentity )
*pIdentity = m_identity;
return !m_identity.IsInvalid();
}
HSteamListenSocket CSteamNetworkingSockets::CreateListenSocketIP( const SteamNetworkingIPAddr &localAddr )
{
SteamDatagramTransportLock scopeLock;
@@ -783,20 +798,29 @@ bool CSteamNetworkingSockets::GetListenSocketAddress( HSteamListenSocket hSocket
return pSock->APIGetAddress( pAddress );
}
bool CSteamNetworkingSockets::CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback )
bool CSteamNetworkingSockets::CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pIdentity1, const SteamNetworkingIdentity *pIdentity2 )
{
SteamDatagramTransportLock scopeLock;
// Assume failure
*pOutConnection1 = k_HSteamNetConnection_Invalid;
*pOutConnection2 = k_HSteamNetConnection_Invalid;
SteamNetworkingIdentity identity[2];
if ( pIdentity1 )
identity[0] = *pIdentity1;
else
identity[0].SetLocalHost();
if ( pIdentity2 )
identity[1] = *pIdentity2;
else
identity[1].SetLocalHost();
// Create network connections?
if ( bUseNetworkLoopback )
{
// Create two connection objects
CSteamNetworkConnectionlocalhostLoopback *pConn[2];
if ( !CSteamNetworkConnectionlocalhostLoopback::APICreateSocketPair( this, pConn ) )
if ( !CSteamNetworkConnectionlocalhostLoopback::APICreateSocketPair( this, pConn, identity ) )
return false;
// Return their handles
@@ -807,7 +831,7 @@ bool CSteamNetworkingSockets::CreateSocketPair( HSteamNetConnection *pOutConnect
{
// Create two connection objects
CSteamNetworkConnectionPipe *pConn[2];
if ( !CSteamNetworkConnectionPipe::APICreateSocketPair( this, pConn ) )
if ( !CSteamNetworkConnectionPipe::APICreateSocketPair( this, pConn, identity ) )
return false;
// Return their handles
@@ -877,7 +901,7 @@ void CSteamNetworkingSockets::AsyncCertRequest()
// We must know our SteamID
// FIXME SteamNetworkingIdentity - only works for SteamIDs
CSteamID steamID = GetIdentity().GetSteamID();
CSteamID steamID = InternalGetIdentity().GetSteamID();
if ( !steamID.IsValid() )
{
CertRequestFailed( k_ESteamNetConnectionEnd_Misc_InternalError, "Cannot request a cert; we don't know our SteamID (yet?)." );
@@ -993,7 +1017,7 @@ void CSteamNetworkingSockets::OnCallback( SteamNetworkingSocketsCert_t *param, b
m_keyPrivateKey.Set( param->m_privKey, param->m_cbPrivKey );
// Notify connections, so they can advance their state machine
SpewVerbose( "Got cert for %s from Steam\n", SteamNetworkingIdentityRender( GetIdentity() ).c_str() );
SpewVerbose( "Got cert for %s from Steam\n", SteamNetworkingIdentityRender( InternalGetIdentity() ).c_str() );
AsyncCertRequestFinished();
}
@@ -1010,7 +1034,7 @@ void CSteamNetworkingSockets::AsyncCertRequestFinished()
void CSteamNetworkingSockets::CertRequestFailed( ESteamNetConnectionEnd nConnectionEndReason, const char *pszMsg )
{
SpewWarning( "Cert request for %s failed with reason code %d. %s\n", SteamNetworkingIdentityRender( GetIdentity() ).c_str(), nConnectionEndReason, pszMsg );
SpewWarning( "Cert request for %s failed with reason code %d. %s\n", SteamNetworkingIdentityRender( InternalGetIdentity() ).c_str(), nConnectionEndReason, pszMsg );
if ( m_msgSignedCert.has_cert() )
{
@@ -1389,8 +1413,17 @@ void CSteamNetworkingSockets::InternalQueueCallback( int nCallback, int cbCallba
}
CSteamNetworkingSockets SteamNetworkingSocketsLib::g_SteamNetworkingSocketsUser(false);
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
CSteamNetworkingSockets SteamNetworkingSocketsLib::g_SteamNetworkingSocketsGameServer(true);
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamNetworkingSocketsGameServer()
{
return &g_SteamNetworkingSocketsGameServer;
}
#endif
/////////////////////////////////////////////////////////////////////////////
//
// Global API interface
@@ -1402,21 +1435,14 @@ STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamNetworkingSockets
return &g_SteamNetworkingSocketsUser;
}
STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamNetworkingSocketsGameServer()
{
return &g_SteamNetworkingSocketsGameServer;
}
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
STEAMNETWORKINGSOCKETS_INTERFACE bool GameNetworkingSockets_Init( SteamDatagramErrMsg &errMsg )
STEAMNETWORKINGSOCKETS_INTERFACE bool GameNetworkingSockets_Init( const SteamNetworkingIdentity *pIdentity, SteamDatagramErrMsg &errMsg )
{
SteamDatagramTransportLock lock;
// Init basic functionality
if ( !g_SteamNetworkingSocketsUser.BInitNonSteam( errMsg ) )
return false;
if ( !g_SteamNetworkingSocketsGameServer.BInitNonSteam( errMsg ) )
if ( !g_SteamNetworkingSocketsUser.BInitNonSteam( pIdentity, errMsg ) )
return false;
return true;
@@ -1426,7 +1452,6 @@ STEAMNETWORKINGSOCKETS_INTERFACE void GameNetworkingSockets_Kill()
{
SteamDatagramTransportLock lock;
g_SteamNetworkingSocketsUser.Kill();
g_SteamNetworkingSocketsGameServer.Kill();
}
#else
@@ -1460,7 +1485,7 @@ STEAMNETWORKINGSOCKETS_INTERFACE void SteamDatagramClient_SetLauncher( const cha
Assert( !g_sLauncherPartner.empty() );
}
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamDatagramClient_Init_InternalV6( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamDatagramClient_Init_InternalV7( SteamDatagramErrMsg &errMsg, FSteamInternal_CreateInterface fnCreateInterface, HSteamUser hSteamUser, HSteamPipe hSteamPipe )
{
SteamDatagramTransportLock lock;
if ( g_pSteamUser )
@@ -6,6 +6,7 @@
#include <steamnetworkingsockets/isteamnetworkingsockets.h>
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
#include <steam/steam_api.h> // FIXME - could use a more narrow header
#include <steam/isteamnetworkingsocketsserialized.h>
#endif
#include "steamnetworkingsockets_connections.h"
@@ -118,7 +119,7 @@ public:
const bool m_bGameServer;
AppId_t m_nAppID;
const SteamNetworkingIdentity &GetIdentity();
const SteamNetworkingIdentity &InternalGetIdentity();
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
ISteamUtils *m_pSteamUtils;
@@ -146,7 +147,7 @@ public:
void Kill();
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
bool BInitNonSteam( SteamDatagramErrMsg &errMsg );
bool BInitNonSteam( const SteamNetworkingIdentity *pIdentity, SteamDatagramErrMsg &errMsg );
#else
bool BInit( ISteamClient *pClient, HSteamUser hSteamUser, HSteamPipe hSteamPipe, SteamDatagramErrMsg &errMsg );
void AsyncCertRequest();
@@ -185,7 +186,7 @@ public:
virtual bool GetQuickConnectionStatus( HSteamNetConnection hConn, SteamNetworkingQuickConnectionStatus *pStats ) OVERRIDE;
virtual int GetDetailedConnectionStatus( HSteamNetConnection hConn, char *pszBuf, int cbBuf ) OVERRIDE;
virtual bool GetListenSocketAddress( HSteamListenSocket hSocket, SteamNetworkingIPAddr *pAddress ) OVERRIDE;
virtual bool CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback ) OVERRIDE;
virtual bool CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pIdentity1, const SteamNetworkingIdentity *pIdentity2 ) OVERRIDE;
virtual bool GetConnectionDebugText( HSteamNetConnection hConn, char *pszOut, int nOutCCH ) OVERRIDE;
virtual int32 GetConfigurationValue( ESteamNetworkingConfigurationValue eConfigValue ) OVERRIDE;
virtual bool SetConfigurationValue( ESteamNetworkingConfigurationValue eConfigValue, int32 nValue ) OVERRIDE;
@@ -196,6 +197,7 @@ public:
virtual int32 GetConnectionConfigurationValue( HSteamNetConnection hConn, ESteamNetworkingConnectionConfigurationValue eConfigValue ) OVERRIDE;
virtual bool SetConnectionConfigurationValue( HSteamNetConnection hConn, ESteamNetworkingConnectionConfigurationValue eConfigValue, int32 nValue ) OVERRIDE;
virtual void RunCallbacks( ISteamNetworkingSocketsCallbacks *pCallbacks ) OVERRIDE;
virtual bool GetIdentity( SteamNetworkingIdentity *pIdentity ) OVERRIDE;
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
virtual HSteamListenSocket CreateListenSocketP2P( int nVirtualPort ) OVERRIDE;
@@ -250,7 +252,10 @@ protected:
#endif // STEAMNETWORKINGSOCKETS_OPENSOURCE
};
extern CSteamNetworkingSockets g_SteamNetworkingSocketsUser;
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
extern CSteamNetworkingSockets g_SteamNetworkingSocketsGameServer;
#endif
} // namespace SteamNetworkingSocketsLib
@@ -78,7 +78,7 @@ const TrustedKey s_arTrustedKeys[1] = {
// bufText.AppendFormat("\\x%02x", key.GetData()[i] );
// }
// SHA256Digest_t digest;
// DbgVerify( CCrypto::GenerateSHA256Digest( key.GetData(), key.GetLength(), &digest ) );
// CCrypto::GenerateSHA256Digest( key.GetData(), key.GetLength(), &digest );
// SpewWarning( "TrustedKey( %llullu, \"%s\" )\n", LittleQWord( *(uint64*)&digest ), bufText.String() );
//}
@@ -471,7 +471,16 @@ bool CSteamNetworkConnectionBase::BInitConnection( uint32 nPeerProtocolVersion,
Assert( m_hConnectionSelf == k_HSteamNetConnection_Invalid );
Assert( m_pParentListenSocket == nullptr || m_pSteamNetworkingSocketsInterface == m_pParentListenSocket->m_pSteamNetworkingSocketsInterface );
m_identityLocal = m_pSteamNetworkingSocketsInterface->GetIdentity();
// We need to know who we are
if ( m_identityLocal.IsInvalid() )
{
if ( !m_pSteamNetworkingSocketsInterface->GetIdentity( &m_identityLocal ) )
{
V_strcpy_safe( errMsg, "We don't know our local identity." );
return false;
}
}
m_eEndReason = k_ESteamNetConnectionEnd_Invalid;
m_szEndDebug[0] = '\0';
@@ -581,6 +590,15 @@ bool CSteamNetworkConnectionBase::BThinkCryptoReady( SteamNetworkingMicroseconds
if ( m_msgSignedCertLocal.has_cert() )
return true;
// If we are using an anonymous identity, then always use self-signed.
// CA's should never issue a certificate for this identity, because that
// is meaningless. No peer should ever honor such a certificate.
if ( m_identityLocal.IsLocalHost() )
{
InitLocalCryptoWithUnsignedCert();
return true;
}
// Already have a a signed cert?
if ( m_pSteamNetworkingSocketsInterface->m_msgSignedCert.has_ca_signature() )
{
@@ -1020,7 +1038,8 @@ bool CSteamNetworkConnectionBase::BRecvCryptoHandshake( const CMsgSteamDatagramC
bool CSteamNetworkConnectionBase::BAllowLocalUnsignedCert() const
{
// !KLUDGE! For now, assume this is OK. We need to make this configurable and lock it down
// Base class will assume this is OK. Derived connection
// types can override.
return true;
}
@@ -1976,13 +1995,13 @@ void CSteamNetworkConnectionBase::UpdateSpeeds( int nTXSpeed, int nRXSpeed )
//
/////////////////////////////////////////////////////////////////////////////
bool CSteamNetworkConnectionPipe::APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionPipe *pConn[2] )
bool CSteamNetworkConnectionPipe::APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionPipe *pConn[2], const SteamNetworkingIdentity pIdentity[2] )
{
SteamDatagramErrMsg errMsg;
SteamNetworkingMicroseconds usecNow = SteamNetworkingSockets_GetLocalTimestamp();
pConn[1] = new CSteamNetworkConnectionPipe( pSteamNetworkingSocketsInterface );
pConn[0] = new CSteamNetworkConnectionPipe( pSteamNetworkingSocketsInterface );
pConn[1] = new CSteamNetworkConnectionPipe( pSteamNetworkingSocketsInterface, pIdentity[0] );
pConn[0] = new CSteamNetworkConnectionPipe( pSteamNetworkingSocketsInterface, pIdentity[1] );
if ( !pConn[0] || !pConn[1] )
{
failed:
@@ -2029,10 +2048,11 @@ failed:
return true;
}
CSteamNetworkConnectionPipe::CSteamNetworkConnectionPipe( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface )
CSteamNetworkConnectionPipe::CSteamNetworkConnectionPipe( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, const SteamNetworkingIdentity &identity )
: CSteamNetworkConnectionBase( pSteamNetworkingSocketsInterface )
, m_pPartner( nullptr )
{
m_identityLocal = identity;
}
CSteamNetworkConnectionPipe::~CSteamNetworkConnectionPipe()
@@ -584,7 +584,7 @@ class CSteamNetworkConnectionPipe : public CSteamNetworkConnectionBase
{
public:
static bool APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionPipe **pOutConnections );
static bool APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionPipe **pOutConnections, const SteamNetworkingIdentity pIdentity[2] );
/// The guy who is on the other end.
CSteamNetworkConnectionPipe *m_pPartner;
@@ -606,7 +606,7 @@ public:
private:
// Use CreateSocketPair!
CSteamNetworkConnectionPipe( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface );
CSteamNetworkConnectionPipe( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, const SteamNetworkingIdentity &identity );
virtual ~CSteamNetworkConnectionPipe();
/// Act like we sent a sequenced packet
@@ -1,7 +1,7 @@
//====== Copyright Valve Corporation, All rights reserved. ====================
#include <steamnetworkingsockets/steamnetworkingsockets_flat.h>
#include <steamnetworkingsockets/isteamnetworkingsockets.h>
#include <steamnetworkingsockets/steamnetworkingsockets.h>
extern "C" {
@@ -102,9 +102,9 @@ STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_GetListen
return ((ISteamNetworkingSockets*)instancePtr)->GetListenSocketAddress( hSocket, pAddress );
}
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_CreateSocketPair( intptr_t instancePtr, HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback )
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_CreateSocketPair( intptr_t instancePtr, HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pIdentity1, const SteamNetworkingIdentity *pIdentity2 )
{
return ((ISteamNetworkingSockets*)instancePtr)->CreateSocketPair( pOutConnection1, pOutConnection2, bUseNetworkLoopback );
return ((ISteamNetworkingSockets*)instancePtr)->CreateSocketPair( pOutConnection1, pOutConnection2, bUseNetworkLoopback, pIdentity1, pIdentity2 );
}
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
@@ -4,6 +4,11 @@
#include "steamnetworkingsockets_connections.h"
#include "crypto.h"
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
// FIXME For P2P stats stuff
#include <steam/isteamnetworking.h>
#endif
#include "steamnetworkingconfig.h"
// Ug
@@ -747,6 +747,26 @@ bool CSteamNetworkConnectionUDP::BInitConnect( const SteamNetworkingIPAddr &addr
Assert( m_identityRemote.IsInvalid() );
m_identityRemote.Clear();
// We should know our own identity, unless the app has said it's OK to go without this.
if ( m_identityLocal.IsInvalid() ) // Specific identity hasn't already been set (by derived class, etc)
{
// Use identity from the interface, if we have one
m_identityLocal = m_pSteamNetworkingSocketsInterface->InternalGetIdentity();
if ( m_identityLocal.IsInvalid())
{
// We don't know who we are. Should we attempt anonymous?
if ( steamdatagram_ip_allow_connections_without_auth == 0 )
{
V_strcpy_safe( errMsg, "Unable to determine local identity, and auth required. Not logged in?" );
return false;
}
m_identityLocal.SetLocalHost();
}
}
// Let base class do some common initialization
uint32 nPeerProtocolVersion = 0; // don't know yet
SteamNetworkingMicroseconds usecNow = SteamNetworkingSockets_GetLocalTimestamp();
@@ -757,13 +777,6 @@ bool CSteamNetworkConnectionUDP::BInitConnect( const SteamNetworkingIPAddr &addr
return false;
}
// We should know our own identity, unless the app has said it's OK to go without this.
if ( m_identityLocal.IsInvalid() && steamdatagram_ip_allow_connections_without_auth == 0 )
{
V_strcpy_safe( errMsg, "Unable to determine local identity. Not logged into Steam?" );
return false;
}
// Start the connection state machine, and send the first request packet.
CheckConnectionStateAndSetNextThinkTime( usecNow );
@@ -1728,9 +1741,10 @@ CSteamNetworkConnectionBase::ERemoteUnsignedCert CSteamNetworkConnectionUDP::All
//
/////////////////////////////////////////////////////////////////////////////
CSteamNetworkConnectionlocalhostLoopback::CSteamNetworkConnectionlocalhostLoopback( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface )
CSteamNetworkConnectionlocalhostLoopback::CSteamNetworkConnectionlocalhostLoopback( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, const SteamNetworkingIdentity &identity )
: CSteamNetworkConnectionUDP( pSteamNetworkingSocketsInterface )
{
m_identityLocal = identity;
}
void CSteamNetworkConnectionlocalhostLoopback::InitConnectionCrypto( SteamNetworkingMicroseconds usecNow )
@@ -1748,14 +1762,14 @@ void CSteamNetworkConnectionlocalhostLoopback::PostConnectionStateChangedCallbac
CSteamNetworkConnectionUDP::PostConnectionStateChangedCallback( eOldAPIState, eNewAPIState );
}
bool CSteamNetworkConnectionlocalhostLoopback::APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionlocalhostLoopback *pConn[2] )
bool CSteamNetworkConnectionlocalhostLoopback::APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionlocalhostLoopback *pConn[2], const SteamNetworkingIdentity pIdentity[2] )
{
SteamDatagramTransportLock::AssertHeldByCurrentThread();
SteamDatagramErrMsg errMsg;
pConn[1] = new CSteamNetworkConnectionlocalhostLoopback( pSteamNetworkingSocketsInterface );
pConn[0] = new CSteamNetworkConnectionlocalhostLoopback( pSteamNetworkingSocketsInterface );
pConn[1] = new CSteamNetworkConnectionlocalhostLoopback( pSteamNetworkingSocketsInterface, pIdentity[0] );
pConn[0] = new CSteamNetworkConnectionlocalhostLoopback( pSteamNetworkingSocketsInterface, pIdentity[1] );
if ( !pConn[0] || !pConn[1] )
{
failed:
@@ -131,10 +131,10 @@ protected:
class CSteamNetworkConnectionlocalhostLoopback : public CSteamNetworkConnectionUDP
{
public:
CSteamNetworkConnectionlocalhostLoopback( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface );
CSteamNetworkConnectionlocalhostLoopback( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, const SteamNetworkingIdentity &identity );
/// Setup two connections to be talking to each other
static bool APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionlocalhostLoopback *pConn[2] );
static bool APICreateSocketPair( CSteamNetworkingSockets *pSteamNetworkingSocketsInterface, CSteamNetworkConnectionlocalhostLoopback *pConn[2], const SteamNetworkingIdentity pIdentity[2] );
/// Base class overrides
virtual void PostConnectionStateChangedCallback( ESteamNetworkingConnectionState eOldAPIState, ESteamNetworkingConnectionState eNewAPIState ) OVERRIDE;
@@ -8,28 +8,6 @@
namespace SteamNetworkingSocketsLib {
#ifdef SDR_SUPPORT_RSA_TICKETS
uint64 CalculatePublicKeyID( const CRSAPublicKey &pubKey )
{
if ( !pubKey.IsValid() )
return 0;
// Get the public modulus
uint8 modulus[ 2048 ];
uint32 cbModulus = pubKey.GetModulusBytes( modulus, sizeof(modulus) );
Assert( cbModulus >= 32 );
if ( cbModulus < 32 )
return 0;
// SHA
SHA256Digest_t digest;
DbgVerify( CCrypto::GenerateSHA256Digest( modulus, cbModulus, &digest ) );
// First 8 bytes
return LittleQWord( *(uint64*)&digest );
}
#endif
extern uint64 CalculatePublicKeyID( const CECSigningPublicKey &pubKey )
{
if ( !pubKey.IsValid() )
+2 -2
View File
@@ -7,7 +7,7 @@
#include <chrono>
#include <thread>
#include <steamnetworkingsockets/isteamnetworkingsockets.h>
#include <steamnetworkingsockets/steamnetworkingsockets.h>
#include <steamnetworkingsockets/isteamnetworkingutils.h>
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
#include <steam/steam_api.h>
@@ -66,7 +66,7 @@ static void InitSteamDatagramConnectionSockets()
{
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
SteamDatagramErrMsg errMsg;
if ( !GameNetworkingSockets_Init( errMsg ) )
if ( !GameNetworkingSockets_Init( nullptr, errMsg ) )
{
fprintf( stderr, "GameNetworkingSockets_Init failed. %s", errMsg );
exit(1);