97 Commits
Author SHA1 Message Date
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
Steven Noonan 00fb9aa18d minbase_identify: utilize GCC endianness detection macros
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-01-08 01:03:31 -08:00
helloer 9a66b776dc Update flat interface
Added wrappers for new group poll interface and removed SteamAPI_SteamNetworkingIdentity_Hash which was a leftover
2019-12-19 13:46:33 +01:00
Fletcher Dunn a9e5e86b28 Added "poll group" interface.
This is used to poll many connections in a single function call.  Previously,
this was only possible if all of the connections were those accepted on the
same listen socket.  (ReceiveMessagesOnListenSocket).  But this left out at
least two important use cases with known users:

- If you create more than one listen socket (because there is more way to
  contact your service, e.g. once for P2P and another for direct IP, and
  another for relayed connections), then you could not poll all of the
  connections efficiently.
- In P2P use cases, we may initiate many connections to peers, and we want
  to poll all of them at once.

This change is relevant to: Issue #49, Issue #50, and issue #52.  (But I don't
this it really "fixes" any of them.)
2019-12-05 15:51:33 -08:00
Fletcher Dunn 8fcfe152eb Added simple tools to measure perf impact of global lock. 2019-12-05 15:33:17 -08:00
Fletcher Dunn 6ce738fcfd Added the concept of "dev" config values.
This is to try to limit what is exposed in a naive generic interface to allow
users to adjust config values, in a way that doesn't allow the user to break
the security in a trivial way.
2019-12-05 15:16:23 -08:00
Fletcher Dunn a33953c155 Add k_nSteamNetworkingSend_UseCurrentThread.
This improved latency in the remote play Streaming client, due to the way
we are polling.
2019-09-26 15:31:40 -07:00
Fletcher Dunn aa50330f1f Add method to send a messgae without copying payload.
Fixes #51
2019-09-23 14:13:08 -07:00
Fletcher Dunn e2cf314f1b Unsigned types are from the devil.
I will die on this hill.
2019-09-23 13:13:39 -07:00
Fletcher Dunn 286db713fa Refactoring SteamNetworkingMessage_t.
Working towards being able to use this object in a new API to send messages
efficiently.  (Issue #51.)

- Message objects are actually ref counted now.
- m_sender renamed to m_identityPeer
- Added a flags field.  Now you can know if the received message was sent
  reliable or not.
- Added inline protected destructor to enforce proper usage.
- Tweaked tons of comments
- When receiving a fragmented unreliable message, I found a place where we
  were doing more memory allocations and memcpying than necessary and
  optimized that.

Delete a #ifdef __cplusplus block.  This whole file is using tons of C++
features.  It was weird to have that one block have that #ifdef

Also: In ConnectionState_ProblemDetectedLocally and ConnectionState_FinWait,
don't try to take any action immediately.  Just trigger an immediate wake up
call, and we will take that action back out in the main loop, where we know
what's higher up on the call stack and what is safe to do.
2019-09-19 11:54:46 -07:00
Fletcher Dunn e9829bff16 Added cipher agility.
The only other currently supported cipher is the NULL cipher, which we want
for remote streaming because we don't want to pay cost to encrypt/decrypt
on mobile.  But eventually we might want to add other ciphers, and this is
the mechanism to do it.

This required shuffling around the crypto handshake quite a bit, because we
want the app to be able to set configuration options on incoming cnonections
before accepting them.
2019-09-18 16:35:09 -07:00
Fletcher Dunn 1f29e34e0f Refactor to split connection from transport.
The connection will be responsible for end to end stuff including encryption,
message fragmentation and reliability, etc.  Transports deliver datagrams.  A
transport is always associated with a single connection, but a connection may
have more than one transport, and may switch between transports over the course
of the connection lifetime.

The goal here is to have conenction types that can switch transport.
Specifically, we need to support a connection that can detect when peers
are on the same LAN and use ordinary UDP in that case, attempt NAT piercing
using STUN, and if that fails, then relay (either using TURN or SDR).

There is more work to be done here.  For example, each transport almost
certainly has its own ping time and quality characeristics, so we probably ought
to track some stats there.  (But our stats situation is already getting pretty
crazy, so maybe just track ping seperately).

This change also includes some changes relevant for Steam Remote Play
streaming, which is going to use this protocol for relayed connections.
(And eventualy, hopefully, for all connections.)  For example, steam remote
play needs really high bandwidth and packet rate, and the tolerance for
sending the timing data for jitter tracking was too tight.  I also need to
pass a "certificate" to a subprocess in a single blob, which actually includes
the private key.
2019-09-17 11:34:23 -07:00
Fletcher Dunn 89047bd887 Sync up with Steam.
In Steam I reorganized the header and clarified comments.
2019-09-02 14:42:31 -07:00
Fletcher Dunn 140498490e API to atomically set initial options.
Added a mechanism to set initial options when creating a listen socket or
connection.
2019-09-02 14:34:11 -07:00
Fletcher Dunn dc647b1a08 Explicitly track where connection is server or client.
I added a new P2P use case, where you cannot use the presence of a parent
listen socket to know.
2019-09-02 14:30:17 -07:00
Fletcher Dunn e9b367fbf6 Make MTU configurable per connection.
Also, added a mechanism to set limits on configuration values.
2019-09-02 13:35:52 -07:00
Fletcher Dunn 68d7de772f Always serialize identity using text.
This is a bit more wasteful, but it facilitates forward and backward
compatibility.  If one peer is using an identity type that an old
peer doesnt' parse, they can still often communicate.  The old peer
often doesn't need to really "understand" what the identity is.

Also fixed some parsing bugs in SteamAPI_SteamNetworkingIdentity_ParseString.
2019-09-02 13:14:10 -07:00
Fletcher Dunn addd70f182 More compatibility fixes for Switch. 2019-09-02 12:51:45 -07:00
Fletcher Dunn b1a9c24d69 Use NULL instead of nullptr.
At least in the public header.  This maximizes compatibility wth some old
toolchains.  We may not support those toolchains for building the code,
but it's nice for them to at least be able to link with us and use our
public header.
2019-09-02 10:51:34 -07:00
Fletcher Dunn dd323a682a _CONSOLE does not mean "game console" 2019-09-02 10:37:04 -07:00
Fletcher Dunn a083624804 Don't define POSIX on the _WIN32 versions of the switch compile 2019-09-02 10:31:25 -07:00
Fletcher Dunn 42e8c60a9e Clean out minbase.h. Improve Xbox and Switch compat. 2019-09-02 10:24:36 -07:00
Fletcher Dunn e8bba6ade1 Added interface for app to provision cert.
Also:
- STEAMNETWORKINGSOCKETS_STEAM now mens "running on steam", not "running using
  the steam client".  STEAMNETWORKINGSOCKETS_STEAMCLIENT is for that.
- Refactored stats stuff, moved it into the namespace.  At one point I thought
  I might expose some stuff in a public interface.  For now, keeping it internal.
- Removed concept of Steam "universe" from this branch of the code.
- Don't use OVERRIDE, override works.
2019-08-29 13:42:17 -07:00