119 Commits
Author SHA1 Message Date
Fletcher Dunn c048e5fabf Reorder functions so vtable matches Steamworks SDK
In general we try to make sure a given header can be shared with the
Steamworks SDK.  I've move this into a better place when we bump the
version number and release a matching SDK.
2021-05-28 17:18:47 -07:00
Fletcher Dunn c85282618b Added helpers to get/set SteamNetworkingIdentity as IPv4 address
P4:6571055
2021-05-28 16:41:00 -07:00
Fletcher Dunn 4bada2d73f Replace ESteamNetTransportKind with flags
(At least in the public interface.)

P4:6571004,6571013
2021-05-28 16:30:37 -07:00
Fletcher Dunn f062b529ac Deprecate some connection failure reasons.
P4: 6553464
2021-05-20 08:28:07 -07:00
Fletcher Dunn 681ce02895 Add helpers for custom signaling using plain C ABI.
For issue #169.
2021-04-12 09:42:11 -07:00
Fletcher Dunn a1f9413784 Adding config vars to simulate bandwidth limit
P4:6407988
2021-03-09 17:00:44 -08:00
Fletcher Dunn f025dae56a Cosmetic reordering of the config vals
P4:6407976
2021-03-09 16:59:16 -08:00
Fletcher Dunn 6c24fcaa78 Add ISteamnetworkingSockets::ResetIdentity
P4:6407930
2021-03-09 16:47:25 -08:00
Fletcher Dunn 2103db35ad Add k_ESteamNetworkingConfig_PacketTraceMaxBytes
P4:6378208
2021-02-19 13:43:48 -08:00
Fletcher Dunn ab5ef56aa2 Add k_ESteamNetworkingConfig_ConnectionUserData
Now we store the userdata in a config value, so that it can be set
atomically when a connection is created, and also so that the default
value of -1 can be customized.

Also added some warnings about the dangers of using the userData
field in callback structs.  I worry I've created a footgun here, and
would be tempted to remove the field entirely from
SteamNetConnectionStatusChangedCallback_t, but it is coming in
through a member struct SteamNetConnectionInfo_t, and it makes
sense there.

Addresses problems discussed in issue #162.

P4:6354936
2021-02-05 18:28:59 -08:00
Fletcher Dunn 3d4521ee83 Cosmetic reordering and grouping of config values.
P4:6354919
2021-02-05 18:16:38 -08:00
Fletcher Dunn 07aa89f788 Fix clang compiler warning.
steamnetworkingtypes.h:202:3: warning: anonymous types declared in an
anonymous union are an extension [-Wnested-anon-types]

Honestly surprised we haven't hit this before already.  A partner
found the warning in the Steamworks SDK version.
2020-12-07 13:34:39 -08:00
Fletcher Dunn 68a9c59bf9 Update comments.
To reflect the new potential use case with SDR hosted dedicated server.

P4:6176909
2020-10-30 12:58:26 -07:00
Fletcher Dunn ae52d2d0ce Refactor custom signaling
Removed the word "custom" from the namesofinterfacesthatwerealreadyverylong.

Added k_ESteamNetworkingConfig_Callback_CreateConnectionSignaling, which is
a mechanism for connections that require signaling to be iniated locally.
This is used by ISteamnetwrokingSockets::ConnectP2P and connections created
using the ISteamNetworkingMessages interface....which has been added.

These changes address issue #137 and bring the opensource code more in
line with Steamworks version.

Delete the define STEAMNETWORKINGSOCKETS_HAS_DEFAULT_P2P_SIGNALING.  "Default
signaling" is a thing that can exist on any platform, and can only be determined
at runtime.  Most places that were using this actually should have been
checking STEAMNETWORKINGSOCKETS_ENABLE_STEAMNETWORKINGMESSAGES anyway, and
those two defines were equivalent in practice.
STEAMNETWORKINGSOCKETS_ENABLE_STEAMNETWORKINGMESSAGES will be defined by default.
I could add a mechanism to disable it if anybody is relaly concerned about
code size.

(Also started some refactoring of the P2P listen sockets, to merge them
with hosted dedicated server listen sockets.  The goal is to enable a
way to connected to hosted dedicated servers without tickets.  That is a work
in progress, and also not relevant to the opensource code.)
2020-10-16 15:08:16 -07:00
Fletcher Dunn 952a7b95ce Reduce differences between opensource and Steam versions.
Thse headers are now *almost* identical to the one in the Steamworks SDK,
which makes it much easier for me (and possibly others) to switch between
a standalone lib and the Steamworks one, even at runtime.

Don't conditionally remove functions from the interface.  This makes them
have different ABIs and the same code cannot be compiled to target either
one.  Move STEAMNETWORKINGSOCKETS_ENABLE_SDR into a private header, and
provide stubs for all of the functions when it's not defined.

Global accessors that are defined to access code in the standalone lib
will have _Lib on the end, and the Steamworks ones will have SteamAPI().
And, if you are only compiling with one or the other (the common case),
then also declare the "undecorated accessor" to go to that one.

Added a steam_api_common.h stub which will define the very few things
that we need that are defined in that file in Steamworks.

There is one remaining cause of ABI differences, and that is structure
packing.  The Steamworks code does really unfortunate things with
structure packing, which cannot be fixed now because of backwards
compatibility.  That ship, unfortunately, has sailed.  I made a different
decition with the opensource code, but if we do want compatibiilty with
the steamworks version, we will need to do the bad thing steamworks does.
This only affects certain platforms.  I'll leave it alone for now,
but we might need to revisit it in the future.  I think right now
the number of people who just want the opensource version to have the
same ABI regardless of platform (e.g. for C# wrappers) is more than the
number who might wany the ABI to be the same as Steamworks.

I closed issue #93, even though it was not fully resolved.  This
change actually totally resolves it (with the exception of the
structure packing).
2020-10-16 13:47:02 -07:00
Fletcher Dunn 59a25fd825 Use versioned accessor for SteamNetworkingSockets() 2020-10-08 09:21:10 -07:00
Steven Noonan 6f3954c8d5 ensure VALVE_BIG_ENDIAN gets set for big endian platforms
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-10-07 17:21:26 -07:00
Steven Noonan 700c52b65c steamtypes.h: include __s390x__ in 64-bit platform detection
Not sure why it's called "X64BITS" though, that's a horrid name.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-10-07 13:44:08 -07:00
Fletcher Dunn 51f53027fd Don't use minbase in public API.
It's an internal thing.
2020-10-06 16:46:58 -07:00
Fletcher Dunn aca2fb76f9 Use strong versioning for SteamNetworkingUtils() export.
I really ought to do this for SteamNetworkingSockets() as well, but the
main reason I'm bringing this over is to sync up with Steam.

P4:6127557
2020-10-06 16:08:52 -07:00
Fletcher Dunn 1108fadc92 Sync with Steam version.
NOP for the opensource code, I just got tired of having differences exist
between the two versions.
2020-09-29 10:41:24 -07:00
Fletcher Dunn 89f81fa249 Added mechanism for custom memory allocator.
I let certain allocations go thorugh the CRT on purpose.  Specifically,
allocations that happen at static init time must go through.  Unfortunately,
MSVC's std::vector and std::map default constructors will allocate memory (!!!!)
with _ITERATOR_DEBUG_LEVEL > 0, so any such object at file scope will, for
now at least, not use the custom allocators.
2020-09-25 17:09:29 -07:00
Fletcher Dunn 4a2672292a Tweak comments in header.
This syncs up with the headers in the Steamworks SDK.
2020-09-03 12:01:59 -07:00
Fletcher Dunn ef23889bc5 Move custom signaling interfaces to a separate file.
These are advanced interfaces and we don't wnat them cluttering up the main
file.

Also sync up a few cosmetic differences with Steam branch.
2020-08-29 16:46:07 -07:00
Fletcher Dunn deb8b55199 Add slightly more detailed info about global lock. 2020-08-28 16:51:55 -07:00
Fletcher Dunn 7270058d4d Delete old stuff 2020-08-28 16:47:36 -07:00
Fletcher Dunn e3661aa353 Fix comment header
Why was I thinking, discouraging people from using this interface?  This
is the one that we would prefer people use.
2020-07-15 17:50:55 -07:00
Fletcher Dunn fdab250c8a Plumbing for ISteamNetworkingMessages callbacks 2020-07-15 17:49:19 -07:00
Fletcher Dunn d67826bca3 Typoooooooo 2020-07-07 18:25:38 -07:00
Fletcher Dunn fe8cbb084e Pass virtual port to ISteamNetworkingCustomSignalingRecvContext 2020-07-07 18:25:37 -07:00
Fletcher Dunn 6ba6b8821d Refactor to support ISteamNetworkingMessages.
Previously ISteamNetworkingSockets was plumbed through much more invasively.
But with the changes to callbacks, symmetric ocnnect mode, and P2P
connections automatically using internal loopback when sending to self,
now it is possible to implement ISteamNetworkingMessages much more as a
seperate layer on top.

ISteamnetworkingMessages is a P2P interface that is more like UDP.  You don't
listen or connect, and you don't deal with connection handles.  Instead, you
specify the remote address with each send call.  The purpose of the API is to
make it easier to port UDP code to P2P.  It's not currently part of the
opensource code, and has not yet been released in the Steamworks SDK.  But I
probably will soon, once we have some good P2P example code.  The previous
incarnations of the interface were kind of crap.  I finally have something
worth releasing.
2020-07-07 12:14:44 -07:00
Fletcher Dunn 4c71718263 Changed callback mechanism.
Now you can register standard function pointers, instead of deriving
from a special class.  This means that Steam and the opensource code
can now work the same, so this fixed issue #124
2020-07-03 18:02:21 -07:00
Fletcher Dunn 31d874de1d Changed k_ESteamNetworkingConfig_FunctionPtr to k_ESteamNetworkingConfig_Ptr
And don't enumerate them
2020-07-03 17:10:59 -07:00
Fletcher Dunn 6d90aa2d3f Add "symmetric connect" mode
This is a P2P feature for a common use case:

- The two peers are "equal" to each other.  (Neither is clearly the "client"
  or "server".)
- Either peer may initiate the connection, and indeed they may do this
  at the same time
- The peers only desire a single connection to each other, and if both
  peers initiate connections simultaneously, a protocol is needed for them
  to resolve the conflict, so that we end up with a single connection.

Also added remote virtual port to ConnectP2PCustomSignaling
2020-07-03 17:08:33 -07:00
Fletcher Dunn 5cd5fc19a1 Decorate virtualport vars with "local" or "remote"
Also, copy over the declarations for functions that require SDR.
They are behind STEAMNETWORKINSOCKETS_ENABLE_SDR, so there is
no real reason to remove the code.  It just creates merge conflicts.
2020-07-03 16:56:12 -07:00
Fletcher Dunn 4565489a20 Add closure code for unexpected "no connection" 2020-07-03 15:05:04 -07:00
Fletcher Dunn 15fbda1403 Add ICE failure codes
On Steam these are only used internally, since we always have SDR
fallback.  But without SDR fallback these will end up being the
mail failure code, if the connection fails.
2020-05-28 16:40:12 -07:00
Fletcher Dunn 639153e0fc P2P / ICE imprvoements
This change includes many changes to improve P2P connections.  I didn't
bother replaying them one at a time from perforce.

Changed the plumbing of how data packets are sent, using context structures
more. The main goal of these changes is to remove the assumption that data
packets are always sent/received on the currently selected transport.  Also,
I removed two specialized end-to-end messages for ICE transport and SDR P2P
transport. Now all end-to-end packets are ordinary data packets (just without
any data).  This is good because, for UDP, they are encrypted.  (For SDR
connections we don't encrytpt them, because we want the relays to be able to
observe them and perhaps mutate them.)  And is reduces the number of different
packet types and codepaths that need to be supported.  This does have one
unfortunate downside: the receiver does not know which transport is used to
send dropped packets.  So, any out-of-band checks on alternate transports,
which do not contain data, and are much more likely to drop (since the
transport is not selectged) will be observed as a gap in the end-to-end
sequence number.  Oddly, the sender actually will have the more complete
picture (albeit after some delay), since he knows the outcome of every
single packet, and he knows what transport was used to send it.

Added a flag that can be used to indicate to the peer, "I am not using this
transport as my primary transport."  My protocol does not have an explicit
nomination framework.  Instead, any data packet that doesn't have this flag
is considered a nomination.

SNP now needs to remember what transport was used for each outgoing packet.

Added some plumbing so that I can collect data about how often ICE is
successful, how the routes compare to SDR, and if it fails, what progress
it made.

The ICE session interface offers more control over what kind of candidtes to
gather, and returns more detailed info about the candidates and route.  The
goal here is to allow a semi-private mode.  If you don't want to share your
public address with random Internet peers (to avoid getting DDoSed), but you
do want to get a LAN connection to any peers in your office / dorm (where LAN
broadcasts may not discover that you are on the same LAN), you can choose to
share only local addresses.  This seems oddd to only share the "private"
address while keeping your "public" address a secret -- but in this case
the "private" address is actually more sensitive, and the public address is
the one that script kiddies would need to boot you.  We are dealing with a
differet kind of thread here.  The option to go totally private and disable
ICE completely, or only share relayed candidates, or only share public
addressses, are all still available, if the threat model is different.
2020-05-20 11:38:31 -07:00
Fletcher Dunn 08feeb1c52 Refactor how subsystem "spew groups" work.
The way that the different values interacted with the global setting was
awkward and backwards.  This is much easier to understand.
2020-05-12 14:57:54 -07:00
Fletcher Dunn 3db36c63ca Move rendering helpers.
When linking with Steam, these call ISteamNetworkingUtils functions, and
GCC complains if it hasn't seen that class.  Even if you don't ever call
any of these functions, GCC doesn't like the fact it could not generate the
code if you were to do so.  Not sure what the spec says, but it feels like
Visual Studio's approach makes more sense here.
2020-05-02 13:17:32 -07:00
Fletcher Dunn 9a219c8c29 Promote rendering helpers to pulic header.
These are really useful, and since everything inline, and calling functions
that we are already obligated to support, there is no extra maintenance
burden.
2020-04-29 14:21:09 -07:00
Fletcher Dunn 9a006f4e27 Added SteamNetConnectionInfo_t::m_eTransportKind
Derive TransportPopulateConnectionInfo on all the transports to
populate this field.

The ICE transport (the one we actually care about the most) is
unfortunately not fully plumbed up so that we know how we are relayed.
Will plumb that through soon.
2020-04-29 10:36:42 -07:00
Fletcher Dunn c81924d6a7 Rename some functions to fix naming conflicts.
The standalone library was defining some of the same symbols as the flat
interface in steam_api.dll, and this was leading to complications.  Renamed
those functions, and they are not part of the "flat interface", they are just
global internal functions functions.

Added wrappers in the flat interface with the same name to pass thorugh.  So
if the library is compiled with the flat interface (which we do in the
opensource version), no functions are removed and the flat interface stays the
same.
2020-04-25 15:19:11 -07:00
Fletcher Dunn 47c942fbd0 Use standard #define to detect GCC 2020-04-20 09:12:39 -07:00
Fletcher Dunn 03381b1a6b Alway use VALVE_CALLBACK_PACK_LARGE
Steamworks SDK has found itself in a really bad place having to support ABIs
that differ on different platforms.  That didn't matter in the days when
everybody compiled all of their binaries per platform, but it breaks the
"write once, run anywhere" ideal.  We don't have to support old ABIs so let's
just pick a packing and use it everywhere.  (But note that we do have stucts
with pointers in them, so our structs will vary between 32-bit and 64-bit.)

https://github.com/nxrighthere/ValveSockets-CSharp/issues/8
2020-04-17 14:12:01 -07:00
Fletcher Dunn 2a7798daf0 First steps for P2P via WebRTC
- Got WebRTC transport class started.
- Added steamwebrtc interface header.  This is some work that SamL did for
  Steamlink, to isolate all the webrtc build requirements from our code.  I'm
  not sure what the final version will look loike, but this is a good place to
  start, since this library already exists and I can get a proof of concept
  working.  After we're working, I'll probably peel back the layers a bit and
  refactor this, and then eventually figure out how to opensource that work.
- Added config values to set the STUN server list
2020-04-14 09:53:22 -07:00
Fletcher Dunn eafb08a66b Get P2P code compiling without SDR
- Bring in interfaces for custom signaling from Steamworks SDK.
- Promote some stuff related to ISteamNetworkingMessages to base class.
  It is hidden behind STEAMNETWORKINGSOCKETS_HAS_DEFAULT_P2P_SIGNALING.
- Add STEAMNETWORKINGSOCKETS_ENABLE_SDR in a bunch of places.
- Add CSteamNetworkConnectionBase::AsSteamNetworkConnectionP2P so we
  can compile without RTTI.
2020-04-13 09:44:58 -07:00
Fletcher Dunn 32edc0d49b A few small changes to sync with Steamworks. 2020-02-24 14:54:10 -08:00
Fletcher Dunn 9ba30bd6b0 Sync up flat interface with Steamworks SDK 1.48 2020-02-24 14:43:28 -08:00
Steven Noonan 6fefad3517 minbase_identify: check for _LP64 when determining architecture bitness
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-01-08 01:03:31 -08:00