1 /// Transcription of isteamnetworkingutils.h to D.
2 ///
3 /// Copyright: Valve Corporation, all rights reserved
4 module steam_gns.utils;
5 
6 import steam_gns.misc;
7 import steam_gns.types;
8 import steam_gns.client_public;
9 
10 @nogc nothrow extern (C++) align(4):
11 
12 version = STEAMNETWORKINGSOCKETS_STANDALONELIB;
13 
14 private alias intptr_t = size_t;
15 
16 //-----------------------------------------------------------------------------
17 /// Misc networking utilities for checking the local networking environment
18 /// and estimating pings.
19 abstract class ISteamNetworkingUtils {
20 public:
21     //
22     // Efficient message sending
23     //
24 
25     /// Allocate and initialize a message object.  Usually the reason
26     /// you call this is to pass it to ISteamNetworkingSockets::SendMessages.
27     /// The returned object will have all of the relevant fields cleared to zero.
28     ///
29     /// Optionally you can also request that this system allocate space to
30     /// hold the payload itself.  If cbAllocateBuffer is nonzero, the system
31     /// will allocate memory to hold a payload of at least cbAllocateBuffer bytes.
32     /// m_pData will point to the allocated buffer, m_cbSize will be set to the
33     /// size, and m_pfnFreeData will be set to the proper function to free up
34     /// the buffer.
35     ///
36     /// If cbAllocateBuffer=0, then no buffer is allocated.  m_pData will be NULL,
37     /// m_cbSize will be zero, and m_pfnFreeData will be NULL.  You will need to
38     /// set each of these.
39     SteamNetworkingMessage_t* AllocateMessage(int cbAllocateBuffer);
40 
41     //
42     // Access to Steam Datagram Relay (SDR) network
43     //
44 
45     //
46     // Initialization and status check
47     //
48 
49     /// If you know that you are going to be using the relay network (for example,
50     /// because you anticipate making P2P connections), call this to initialize the
51     /// relay network.  If you do not call this, the initialization will
52     /// be delayed until the first time you use a feature that requires access
53     /// to the relay network, which will delay that first access.
54     ///
55     /// You can also call this to force a retry if the previous attempt has failed.
56     /// Performing any action that requires access to the relay network will also
57     /// trigger a retry, and so calling this function is never strictly necessary,
58     /// but it can be useful to call it a program launch time, if access to the
59     /// relay network is anticipated.
60     ///
61     /// Use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t
62     /// callbacks to know when initialization has completed.
63     /// Typically initialization completes in a few seconds.
64     ///
65     /// Note: dedicated servers hosted in known data centers do *not* need
66     /// to call this, since they do not make routing decisions.  However, if
67     /// the dedicated server will be using P2P functionality, it will act as
68     /// a "client" and this should be called.
69     void InitRelayNetworkAccess();
70 
71     /// Fetch current status of the relay network.
72     ///
73     /// SteamRelayNetworkStatus_t is also a callback.  It will be triggered on
74     /// both the user and gameserver interfaces any time the status changes, or
75     /// ping measurement starts or stops.
76     ///
77     /// SteamRelayNetworkStatus_t::m_eAvail is returned.  If you want
78     /// more details, you can pass a non-NULL value.
79     ESteamNetworkingAvailability GetRelayNetworkStatus(SteamRelayNetworkStatus_t* pDetails);
80 
81     //
82     // "Ping location" functions
83     //
84     // We use the ping times to the valve relays deployed worldwide to
85     // generate a "marker" that describes the location of an Internet host.
86     // Given two such markers, we can estimate the network latency between
87     // two hosts, without sending any packets.  The estimate is based on the
88     // optimal route that is found through the Valve network.  If you are
89     // using the Valve network to carry the traffic, then this is precisely
90     // the ping you want.  If you are not, then the ping time will probably
91     // still be a reasonable estimate.
92     //
93     // This is extremely useful to select peers for matchmaking!
94     //
95     // The markers can also be converted to a string, so they can be transmitted.
96     // We have a separate library you can use on your app's matchmaking/coordinating
97     // server to manipulate these objects.  (See steamdatagram_gamecoordinator.h)
98 
99     /// Return location info for the current host.  Returns the approximate
100     /// age of the data, in seconds, or -1 if no data is available.
101     ///
102     /// It takes a few seconds to initialize access to the relay network.  If
103     /// you call this very soon after calling InitRelayNetworkAccess,
104     /// the data may not be available yet.
105     ///
106     /// This always return the most up-to-date information we have available
107     /// right now, even if we are in the middle of re-calculating ping times.
108     float GetLocalPingLocation(ref SteamNetworkPingLocation_t result);
109 
110     /// Estimate the round-trip latency between two arbitrary locations, in
111     /// milliseconds.  This is a conservative estimate, based on routing through
112     /// the relay network.  For most basic relayed connections, this ping time
113     /// will be pretty accurate, since it will be based on the route likely to
114     /// be actually used.
115     ///
116     /// If a direct IP route is used (perhaps via NAT traversal), then the route
117     /// will be different, and the ping time might be better.  Or it might actually
118     /// be a bit worse!  Standard IP routing is frequently suboptimal!
119     ///
120     /// But even in this case, the estimate obtained using this method is a
121     /// reasonable upper bound on the ping time.  (Also it has the advantage
122     /// of returning immediately and not sending any packets.)
123     ///
124     /// In a few cases we might not able to estimate the route.  In this case
125     /// a negative value is returned.  k_nSteamNetworkingPing_Failed means
126     /// the reason was because of some networking difficulty.  (Failure to
127     /// ping, etc)  k_nSteamNetworkingPing_Unknown is returned if we cannot
128     /// currently answer the question for some other reason.
129     ///
130     /// Do you need to be able to do this from a backend/matchmaking server?
131     /// You are looking for the "game coordinator" library.
132     int EstimatePingTimeBetweenTwoLocations(const ref SteamNetworkPingLocation_t location1,
133     const ref SteamNetworkPingLocation_t location2);
134 
135     /// Same as EstimatePingTime, but assumes that one location is the local host.
136     /// This is a bit faster, especially if you need to calculate a bunch of
137     /// these in a loop to find the fastest one.
138     ///
139     /// In rare cases this might return a slightly different estimate than combining
140     /// GetLocalPingLocation with EstimatePingTimeBetweenTwoLocations.  That's because
141     /// this function uses a slightly more complete set of information about what
142     /// route would be taken.
143     int EstimatePingTimeFromLocalHost(const ref SteamNetworkPingLocation_t remoteLocation);
144 
145     /// Convert a ping location into a text format suitable for sending over the wire.
146     /// The format is a compact and human readable.  However, it is subject to change
147     /// so please do not parse it yourself.  Your buffer must be at least
148     /// k_cchMaxSteamNetworkingPingLocationString bytes.
149     void ConvertPingLocationToString(const ref SteamNetworkPingLocation_t location, char* pszBuf, int cchBufSize);
150 
151     /// Parse back SteamNetworkPingLocation_t string.  Returns false if we couldn't understand
152     /// the string.
153     bool ParsePingLocationString(const char* pszString, ref SteamNetworkPingLocation_t result);
154 
155     /// Check if the ping data of sufficient recency is available, and if
156     /// it's too old, start refreshing it.
157     ///
158     /// Please only call this function when you *really* do need to force an
159     /// immediate refresh of the data.  (For example, in response to a specific
160     /// user input to refresh this information.)  Don't call it "just in case",
161     /// before every connection, etc.  That will cause extra traffic to be sent
162     /// for no benefit. The library will automatically refresh the information
163     /// as needed.
164     ///
165     /// Returns true if sufficiently recent data is already available.
166     ///
167     /// Returns false if sufficiently recent data is not available.  In this
168     /// case, ping measurement is initiated, if it is not already active.
169     /// (You cannot restart a measurement already in progress.)
170     ///
171     /// You can use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t
172     /// to know when ping measurement completes.
173     bool CheckPingDataUpToDate(float flMaxAgeSeconds);
174 
175     //
176     // List of Valve data centers, and ping times to them.  This might
177     // be useful to you if you are use our hosting, or just need to measure
178     // latency to a cloud data center where we are running relays.
179     //
180 
181     /// Fetch ping time of best available relayed route from this host to
182     /// the specified data center.
183     int GetPingToDataCenter(SteamNetworkingPOPID popID, SteamNetworkingPOPID* pViaRelayPoP);
184 
185     /// Get *direct* ping time to the relays at the data center.
186     int GetDirectPingToPOP(SteamNetworkingPOPID popID);
187 
188     /// Get number of network points of presence in the config
189     int GetPOPCount();
190 
191     /// Get list of all POP IDs.  Returns the number of entries that were filled into
192     /// your list.
193     int GetPOPList(SteamNetworkingPOPID* list, int nListSz);
194 
195     //
196     // Misc
197     //
198 
199     /// Fetch current timestamp.  This timer has the following properties:
200     ///
201     /// - Monotonicity is guaranteed.
202     /// - The initial value will be at least 24*3600*30*1e6, i.e. about
203     ///   30 days worth of microseconds.  In this way, the timestamp value of
204     ///   0 will always be at least "30 days ago".  Also, negative numbers
205     ///   will never be returned.
206     /// - Wraparound / overflow is not a practical concern.
207     ///
208     /// If you are running under the debugger and stop the process, the clock
209     /// might not advance the full wall clock time that has elapsed between
210     /// calls.  If the process is not blocked from normal operation, the
211     /// timestamp values will track wall clock time, even if you don't call
212     /// the function frequently.
213     ///
214     /// The value is only meaningful for this run of the process.  Don't compare
215     /// it to values obtained on another computer, or other runs of the same process.
216     SteamNetworkingMicroseconds GetLocalTimestamp();
217 
218     /// Set a function to receive network-related information that is useful for debugging.
219     /// This can be very useful during development, but it can also be useful for troubleshooting
220     /// problems with tech savvy end users.  If you have a console or other log that customers
221     /// can examine, these log messages can often be helpful to troubleshoot network issues.
222     /// (Especially any warning/error messages.)
223     ///
224     /// The detail level indicates what message to invoke your callback on.  Lower numeric
225     /// value means more important, and the value you pass is the lowest priority (highest
226     /// numeric value) you wish to receive callbacks for.
227     ///
228     /// The value here controls the detail level for most messages.  You can control the
229     /// detail level for various subsystems (perhaps only for certain connections) by
230     /// adjusting the configuration values k_ESteamNetworkingConfig_LogLevel_Xxxxx.
231     ///
232     /// Except when debugging, you should only use k_ESteamNetworkingSocketsDebugOutputType_Msg
233     /// or k_ESteamNetworkingSocketsDebugOutputType_Warning.  For best performance, do NOT
234     /// request a high detail level and then filter out messages in your callback.  This incurs
235     /// all of the expense of formatting the messages, which are then discarded.  Setting a high
236     /// priority value (low numeric value) here allows the library to avoid doing this work.
237     ///
238     /// IMPORTANT: This may be called from a service thread, while we own a mutex, etc.
239     /// Your output function must be threadsafe and fast!  Do not make any other
240     /// Steamworks calls from within the handler.
241     void SetDebugOutputFunction(ESteamNetworkingSocketsDebugOutputType eDetailLevel,
242     FSteamNetworkingSocketsDebugOutput pfnFunc);
243 
244     //
245     // Fake IP
246     //
247     // Useful for interfacing with code that assumes peers are identified using an IPv4 address
248     //
249 
250     /// Return true if an IPv4 address is one that might be used as a "fake" one.
251     /// This function is fast; it just does some logical tests on the IP and does
252     /// not need to do any lookup operations.
253     bool IsFakeIPv4(uint nIPv4 ) {
254         return GetIPv4FakeIPType( nIPv4 ) > ESteamNetworkingFakeIPType.NotFake;
255     }
256     ESteamNetworkingFakeIPType GetIPv4FakeIPType(uint nIPv4);
257 
258     /// Get the real identity associated with a given FakeIP.
259     ///
260     /// On failure, returns:
261     /// - k_EResultInvalidParam: the IP is not a FakeIP.
262     /// - k_EResultNoMatch: we don't recognize that FakeIP and don't know the corresponding identity.
263     ///
264     /// FakeIP's used by active connections, or the FakeIPs assigned to local identities,
265     /// will always work.  FakeIPs for recently destroyed connections will continue to
266     /// return results for a little while, but not forever.  At some point, we will forget
267     /// FakeIPs to save space.  It's reasonably safe to assume that you can read back the
268     /// real identity of a connection very soon after it is destroyed.  But do not wait
269     /// indefinitely.
270     EResult GetRealIdentityForFakeIP(const ref SteamNetworkingIPAddr fakeIP, SteamNetworkingIdentity* pOutRealIdentity);
271 
272     //
273     // Set and get configuration values, see ESteamNetworkingConfigValue for individual descriptions.
274     //
275 
276     // Shortcuts for common cases.  (Implemented as inline functions below)
277     bool SetGlobalConfigValueInt32(ESteamNetworkingConfigValue eValue, int val);
278     bool SetGlobalConfigValueFloat(ESteamNetworkingConfigValue eValue, float val);
279     bool SetGlobalConfigValueString(ESteamNetworkingConfigValue eValue, const char* val);
280     bool SetGlobalConfigValuePtr(ESteamNetworkingConfigValue eValue, void* val);
281     bool SetConnectionConfigValueInt32(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, int val);
282     bool SetConnectionConfigValueFloat(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val);
283     bool SetConnectionConfigValueString(HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char* val);
284 
285     //
286     // Set global callbacks.  If you do not want to use Steam's callback dispatch mechanism and you
287     // want to use the same callback on all (or most) listen sockets and connections, then
288     // simply install these callbacks first thing, and you are good to go.
289     // See ISteamNetworkingSockets::RunCallbacks
290     //
291     bool SetGlobalCallback_SteamNetConnectionStatusChanged(FnSteamNetConnectionStatusChanged fnCallback);
292     bool SetGlobalCallback_SteamNetAuthenticationStatusChanged(FnSteamNetAuthenticationStatusChanged fnCallback);
293     bool SetGlobalCallback_SteamRelayNetworkStatusChanged(FnSteamRelayNetworkStatusChanged fnCallback);
294     bool SetGlobalCallback_FakeIPResult(FnSteamNetworkingFakeIPResult fnCallback);
295     bool SetGlobalCallback_MessagesSessionRequest(FnSteamNetworkingMessagesSessionRequest fnCallback);
296     bool SetGlobalCallback_MessagesSessionFailed(FnSteamNetworkingMessagesSessionFailed fnCallback);
297 
298     /// Set a configuration value.
299     /// - eValue: which value is being set
300     /// - eScope: Onto what type of object are you applying the setting?
301     /// - scopeArg: Which object you want to change?  (Ignored for global scope).  E.g. connection handle, listen socket handle, interface pointer, etc.
302     /// - eDataType: What type of data is in the buffer at pValue?  This must match the type of the variable exactly!
303     /// - pArg: Value to set it to.  You can pass NULL to remove a non-global setting at this scope,
304     ///   causing the value for that object to use global defaults.  Or at global scope, passing NULL
305     ///   will reset any custom value and restore it to the system default.
306     ///   NOTE: When setting pointers (e.g. callback functions), do not pass the function pointer directly.
307     ///   Your argument should be a pointer to a function pointer.
308     bool SetConfigValue(ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj,
309         ESteamNetworkingConfigDataType eDataType, const void* pArg);
310 
311     /// Set a configuration value, using a struct to pass the value.
312     /// (This is just a convenience shortcut; see below for the implementation and
313     /// a little insight into how SteamNetworkingConfigValue_t is used when
314     /// setting config options during listen socket and connection creation.)
315     bool SetConfigValueStruct(const ref SteamNetworkingConfigValue_t opt, ESteamNetworkingConfigScope eScopeType,
316     intptr_t scopeObj);
317 
318     /// Get a configuration value.
319     /// - eValue: which value to fetch
320     /// - eScopeType: query setting on what type of object
321     /// - eScopeArg: the object to query the setting for
322     /// - pOutDataType: If non-NULL, the data type of the value is returned.
323     /// - pResult: Where to put the result.  Pass NULL to query the required buffer size.  (k_ESteamNetworkingGetConfigValue_BufferTooSmall will be returned.)
324     /// - cbResult: IN: the size of your buffer.  OUT: the number of bytes filled in or required.
325     ESteamNetworkingGetConfigValueResult GetConfigValue(ESteamNetworkingConfigValue eValue,
326     ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj, ESteamNetworkingConfigDataType* pOutDataType,
327     void* pResult, size_t* cbResult);
328 
329     /// Get info about a configuration value.  Returns the name of the value,
330     /// or NULL if the value doesn't exist.  Other output parameters can be NULL
331     /// if you do not need them.
332     const(char*) GetConfigValueInfo(ESteamNetworkingConfigValue eValue, ESteamNetworkingConfigDataType* pOutDataType,
333     ESteamNetworkingConfigScope* pOutScope);
334 
335     /// Iterate the list of all configuration values in the current environment that it might
336     /// be possible to display or edit using a generic UI.  To get the first iterable value,
337     /// pass k_ESteamNetworkingConfig_Invalid.  Returns k_ESteamNetworkingConfig_Invalid
338     /// to signal end of list.
339     ///
340     /// The bEnumerateDevVars argument can be used to include "dev" vars.  These are vars that
341     /// are recommended to only be editable in "debug" or "dev" mode and typically should not be
342     /// shown in a retail environment where a malicious local user might use this to cheat.
343     ESteamNetworkingConfigValue IterateGenericEditableConfigValues(ESteamNetworkingConfigValue eCurrent,
344     bool bEnumerateDevVars);
345 
346     //
347     // String conversions.  You'll usually access these using the respective
348     // inline methods.
349     //
350     void SteamNetworkingIPAddr_ToString(const ref SteamNetworkingIPAddr addr, char* buf, size_t cbBuf, bool bWithPort);
351     bool SteamNetworkingIPAddr_ParseString(SteamNetworkingIPAddr* pAddr, const char* pszStr);
352     ESteamNetworkingFakeIPType SteamNetworkingIPAddr_GetFakeIPType(const ref SteamNetworkingIPAddr addr);
353     void SteamNetworkingIdentity_ToString(const ref SteamNetworkingIdentity identity, char* buf, size_t cbBuf);
354     bool SteamNetworkingIdentity_ParseString(SteamNetworkingIdentity* pIdentity, const char* pszStr);
355 
356 }
357 
358 enum STEAMNETWORKINGUTILS_INTERFACE_VERSION = "SteamNetworkingUtils004";
359 
360 // Global accessors
361 // Using standalone lib
362 version (STEAMNETWORKINGSOCKETS_STANDALONELIB) {
363 
364     // Standalone lib
365     static assert(STEAMNETWORKINGUTILS_INTERFACE_VERSION[22] == '4', "Version mismatch");
366 
367     extern (C) ISteamNetworkingUtils SteamNetworkingUtils_LibV4();
368 
369     ISteamNetworkingUtils SteamNetworkingUtils_Lib() { return SteamNetworkingUtils_LibV4(); }
370 
371     version (STEAMNETWORKINGSOCKETS_STEAMAPI) { }
372     else {
373         ISteamNetworkingUtils SteamNetworkingUtils() { return SteamNetworkingUtils_LibV4(); }
374     }
375 
376 }
377 
378 /// A struct used to describe our readiness to use the relay network.
379 /// To do this we first need to fetch the network configuration,
380 /// which describes what POPs are available.
381 struct SteamRelayNetworkStatus_t {
382 
383     enum { k_iCallback = k_iSteamNetworkingUtilsCallbacks + 1 };
384 
385     /// Summary status.  When this is "current", initialization has
386     /// completed.  Anything else means you are not ready yet, or
387     /// there is a significant problem.
388     ESteamNetworkingAvailability m_eAvail;
389 
390     /// Nonzero if latency measurement is in progress (or pending,
391     /// awaiting a prerequisite).
392     int m_bPingMeasurementInProgress;
393 
394     /// Status obtaining the network config.  This is a prerequisite
395     /// for relay network access.
396     ///
397     /// Failure to obtain the network config almost always indicates
398     /// a problem with the local internet connection.
399     ESteamNetworkingAvailability m_eAvailNetworkConfig;
400 
401     /// Current ability to communicate with ANY relay.  Note that
402     /// the complete failure to communicate with any relays almost
403     /// always indicates a problem with the local Internet connection.
404     /// (However, just because you can reach a single relay doesn't
405     /// mean that the local connection is in perfect health.)
406     ESteamNetworkingAvailability m_eAvailAnyRelay;
407 
408     /// Non-localized English language status.  For diagnostic/debugging
409     /// purposes only.
410     char[256] m_debugMsg;
411 
412 }
413 
414 /// Utility class for printing a SteamNetworkingIdentity.
415 /// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() );
416 struct SteamNetworkingIdentityRender {
417 
418     this(const ref SteamNetworkingIdentity x) { x.ToString(buf.ptr, buf.sizeof); }
419     const(char)* c_str() const return { return buf.ptr; }
420 private:
421     char[SteamNetworkingIdentity.k_cchMaxString] buf;
422 
423 }
424 
425 /// Utility class for printing a SteamNetworkingIPAddrRender.
426 struct SteamNetworkingIPAddrRender {
427 
428     this(const ref SteamNetworkingIPAddr x, bool bWithPort = true) { x.ToString(buf.ptr, buf.sizeof, bWithPort); }
429     const(char*) c_str() const return { return buf.ptr; }
430 private:
431     char[SteamNetworkingIPAddr.k_cchMaxString] buf;
432 };
433 
434 ///////////////////////////////////////////////////////////////////////////////
435 //
436 // Internal stuff
437 
438 /+ which I hope I don't have to transcribe
439 
440 inline void ISteamNetworkingUtils::InitRelayNetworkAccess() { CheckPingDataUpToDate( 1e10f ); }
441 inline bool ISteamNetworkingUtils::SetGlobalConfigValueInt32( ESteamNetworkingConfigValue eValue, int32 val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Int32, &val ); }
442 inline bool ISteamNetworkingUtils::SetGlobalConfigValueFloat( ESteamNetworkingConfigValue eValue, float val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Float, &val ); }
443 inline bool ISteamNetworkingUtils::SetGlobalConfigValueString( ESteamNetworkingConfigValue eValue, const char *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_String, val ); }
444 inline bool ISteamNetworkingUtils::SetGlobalConfigValuePtr( ESteamNetworkingConfigValue eValue, void *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Global, 0, k_ESteamNetworkingConfig_Ptr, &val ); } // Note: passing pointer to pointer.
445 inline bool ISteamNetworkingUtils::SetConnectionConfigValueInt32( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, int32 val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Int32, &val ); }
446 inline bool ISteamNetworkingUtils::SetConnectionConfigValueFloat( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Float, &val ); }
447 inline bool ISteamNetworkingUtils::SetConnectionConfigValueString( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_String, val ); }
448 inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamNetConnectionStatusChanged( FnSteamNetConnectionStatusChanged fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_ConnectionStatusChanged, (void*)fnCallback ); }
449 inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamNetAuthenticationStatusChanged( FnSteamNetAuthenticationStatusChanged fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_AuthStatusChanged, (void*)fnCallback ); }
450 inline bool ISteamNetworkingUtils::SetGlobalCallback_SteamRelayNetworkStatusChanged( FnSteamRelayNetworkStatusChanged fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_RelayNetworkStatusChanged, (void*)fnCallback ); }
451 inline bool ISteamNetworkingUtils::SetGlobalCallback_FakeIPResult( FnSteamNetworkingFakeIPResult fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_FakeIPResult, (void*)fnCallback ); }
452 inline bool ISteamNetworkingUtils::SetGlobalCallback_MessagesSessionRequest( FnSteamNetworkingMessagesSessionRequest fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_MessagesSessionRequest, (void*)fnCallback ); }
453 inline bool ISteamNetworkingUtils::SetGlobalCallback_MessagesSessionFailed( FnSteamNetworkingMessagesSessionFailed fnCallback ) { return SetGlobalConfigValuePtr( k_ESteamNetworkingConfig_Callback_MessagesSessionFailed, (void*)fnCallback ); }
454 
455 inline bool ISteamNetworkingUtils::SetConfigValueStruct( const SteamNetworkingConfigValue_t &opt, ESteamNetworkingConfigScope eScopeType, intptr_t scopeObj )
456 {
457     // Locate the argument.  Strings are a special case, since the
458     // "value" (the whole string buffer) doesn't fit in the struct
459     // NOTE: for pointer values, we pass a pointer to the pointer,
460     // we do not pass the pointer directly.
461     const void *pVal = ( opt.m_eDataType == k_ESteamNetworkingConfig_String ) ? (const void *)opt.m_val.m_string : (const void *)&opt.m_val;
462     return SetConfigValue( opt.m_eValue, eScopeType, scopeObj, opt.m_eDataType, pVal );
463 }
464 
465 // How to get helper functions.
466 #if defined( STEAMNETWORKINGSOCKETS_STATIC_LINK ) || defined( STEAMNETWORKINGSOCKETS_STANDALONELIB )
467 
468     // Call direct to static functions
469     STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr *pAddr, char *buf, size_t cbBuf, bool bWithPort );
470     STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr );
471     STEAMNETWORKINGSOCKETS_INTERFACE ESteamNetworkingFakeIPType SteamNetworkingIPAddr_GetFakeIPType( const SteamNetworkingIPAddr *pAddr );
472     STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity *pIdentity, char *buf, size_t cbBuf );
473     STEAMNETWORKINGSOCKETS_INTERFACE bool SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, size_t sizeofIdentity, const char *pszStr );
474     inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamNetworkingIPAddr_ToString( this, buf, cbBuf, bWithPort ); }
475     inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamNetworkingIPAddr_ParseString( this, pszStr ); }
476     inline ESteamNetworkingFakeIPType SteamNetworkingIPAddr::GetFakeIPType() const { return SteamNetworkingIPAddr_GetFakeIPType( this ); }
477     inline void SteamNetworkingIdentity::ToString( char *buf, size_t cbBuf ) const { SteamNetworkingIdentity_ToString( this, buf, cbBuf ); }
478     inline bool SteamNetworkingIdentity::ParseString( const char *pszStr ) { return SteamNetworkingIdentity_ParseString( this, sizeof(*this), pszStr ); }
479 
480 #elif defined( STEAMNETWORKINGSOCKETS_STEAMAPI )
481     // Using steamworks SDK - go through SteamNetworkingUtils()
482     inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamNetworkingUtils()->SteamNetworkingIPAddr_ToString( *this, buf, cbBuf, bWithPort ); }
483     inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamNetworkingUtils()->SteamNetworkingIPAddr_ParseString( this, pszStr ); }
484     inline ESteamNetworkingFakeIPType SteamNetworkingIPAddr::GetFakeIPType() const { return SteamNetworkingUtils()->SteamNetworkingIPAddr_GetFakeIPType( *this ); }
485     inline void SteamNetworkingIdentity::ToString( char *buf, size_t cbBuf ) const { SteamNetworkingUtils()->SteamNetworkingIdentity_ToString( *this, buf, cbBuf ); }
486     inline bool SteamNetworkingIdentity::ParseString( const char *pszStr ) { return SteamNetworkingUtils()->SteamNetworkingIdentity_ParseString( this, pszStr ); }
487 #else
488     #error "Invalid config"
489 #endif
490 
491 #
492 
493 +/