Added documentation about SteamNetConnectionStatusChangedCallback_t. This is an
important callback, so it's been pretty bad that it was essentially undocumented
until now.
Also use ESteamNetworkingConnectionState instead of int. (I have taken steps
to make sure that the enum is the right size.)
The notes about ISteamNetworkingUtils::InitializeRelayNetworkAccess are not
relevant in the opensource context.
In Steamworks, we want to keep the number of odinary DLL imports to an
absolute minimum, because those come from steam_api.dll, which we do
not update. (The developer needs to take a new one to update their SDK.)
The functions in the interface come from steamclient.dll, which we do
update frequently.
This resulted in the following changes:
* Printing and parsing of SteamNetworkingIPAddr and SteamNetworkingIdentity
were moved to ISteamNetworkingUtils functions. Most C++ code will still
access them through the inline class methods, so they won't really care
where they are implemented.
* Deleted some hashing functions. This is not hard to write, and the
definition of operator= gives you an example of what to do.
* SteamNetworkingMessage::Release will happen through a pointer, so that it
can be dynamiclaly linked.
Other changes:
* Renamed an old name "STEAMDATAGRAMLIB" to "STEAMNETWORKINGSOCKETS" in
a few places.
* Use STEAMNETWORKINGSOCKETS_ENABLE_SDR in a few places, to remove
SDR-specific functionality. (We might opensource the SDR support code
in the future.)
This isn't critical in an environment like this, where we don't have ABI compatibility commitments. But for the Steamworks SDK this will hopefully be useful. Once we release a version of an interface, we must support that ABI indefinitely.
Put essential stuff at the top, less commonly used fields at the bottom. Also, SteamNetworkingIdentity is a large object, so having it in the middle of the object increased the likelihood of touching multiple cache lines.
Moved them to ISteamNetworkingUtils, which is now actually shared Steam (mostly) with a real accessor and and interface, and not a dummy interface object with all static methods.
Connection settings have a system of inheritance, so they can be set globally, per SteamNetworkingSockets interface, per listen socket, or per connection.
Deleted the config variable to simulate fake *message* loss. That is not useful.
Introduced STEAMNETWORKINGSOCKETS_ENABLE_SDR define, to make it more clear why code is being #ifdef'ed out. (E.g. if we open-sourced that code, we would want that included.)
Replaced ESteamNetworkingSendType with a basic flags bitmask.
Cleaned up a bunch of comments.
Changed SteamNetworkingMessage_t release mechanism. Now the callback is only to free the buffer, and it's assumed that this API will manage the actual objects. (This is important because the actual type is a derived type and has extra stuff on the end.) Also laid some groundwork for user management of message objects. (Relevant for issue #51.)
Make it a method of ISteamnetworkingUtils method. This matches Steam.
Make sure ESteamNetworkingSocketsDebugOutputType is 32-bits, and declare the output callback to take an enum instead of int.
Switched AES-GCM IV's to be 96-bit instead of 128-bit.
- This is what TLS uses (RFC5288)
- This is what NIST recommends (https://dl.acm.org/citation.cfm?id=2206251)
- This is more optimal. (Certainly for OpenSSL's implementation; I believe it's true in general for GCM.)
- This is the only value that libsodium supports. Note that we're still using a 32-bit tag, and libsodium only supports the full 128-bit tag (to my knowledge, see #48). But we might decide to use the full 128-bit tag, and that that point libsodium could be used.
Moved the protocol number out of transport-specific handshake packets to be a "crypt parameter", where it will be signed. In the future we might need to allow some clients to connect to older clients that have a known security vulnerability (perhaps only during some temporary transition period). We don't want an attacker to be able to forge the protocol version and force the weaker protocol to be negotiated.
Bumped the protocol version because these are wire-compatibility-breaking changes.
Added a specific error code if a connection fails due to protocol incompatibilities.
* Provide plain C wrappers to the inline functions in SteamNetworkingIPAddr and SteamNetworkingIdentity
* Change names to be consistent with the rest of the Steamworks names.
Also moved a bunch of Steam-specific stuff to other files, which are not included in this repository.
Moved high level init/kill to a seperate file, so that isteamnworkigsockets.h won't be cluttered with
a bunch of #ifdefs.
Added IClient interface layer, which is useless in this context, butneeded in Steam, since we
provide backwards compatibility for all old ISteamXxx interfaces.
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.
* Interface changes:
Replaced all CSteamIDs with SteamNetworkingIdentity, which is an abstract concept.
Added IPv6 support. This has not been tested at this time, but all the basics
are there and any issues should be small bugfixes.
Improved and standardized connection debug names. You can set a debug name for a connection,
and the full debug string, which includes the Connection ID, transport-specific data, and
your name (if any) are printed consistently in logging messages and this name is also present
in SteamNetConnectionInfo_t. Connection handles are now the same as the local ConnectionID
on the wire. This makes debugging a lot easier.
GetListenSocketInfo renamed to GetListenSocketAddress and now actually does something.
Split out P2P and ordinary UDP listen sockets into two seperate objects. This simplifies
the opensource code (since P2P is not support)
* Misc internal code cleanup:
Broke up CCrypto monolith, so that we can more easily and cleanly:
- Share what we really want to share with Steam. Mainly some text parsing of keys, etc.
- Replace the actual crypto primitives with another provider (e.g. libsodium)
Delete a whole bunch of unused and messy cruft that was left when we ripped this out from Steam,
as well as code and messages specific to relayed connections (supported only on Steam)
Switch a bunch of maps to hashmaps instead of red/black tree maps. The CUtlHashMap class comes
from Steam and is designed to scale to very large size (N in the millions), and if the table
needs to be rehashed, the cost is amortized instead of triggering a large cost all at once.
This functionality is not needed. Nor do we need stable handles, so it would be better to use
a table based on open addressing. That would be a small optimization and also allow us to
get rid of bitstring.*, which unfortunately got added as a result of this change.
Added standalone IPv6 address parsing files: ipv6text.*. These are plain C and do not have
any dependencies, and could be split out, since they are independenctly useful and, unlike
all of our other utility routes (e.g. tier0, tier1, etc), actually worthy of being used
outside of Valve.
This not only removes some redundancy, but also is a step towards rejecting duplicate sequence numbers earlier. (#20)
Also rework how hosted dedicated servers are configured, but that is not relevant to the opensource version of this code.
More consistent with what the Steamworks one will look like. Crazy-long names, intptr_t for ths "this" pointer (I don't understand why, but that's what is done elsewhere), and always pass the "this" pointer, even when it's not actually needed
This doesn't put the fields in the "order of importance if youa re trying to understand it" order.
But it does make sure that no matter what the pointer size, everythig is aligned on natural boundaries, with no packing gaps.
Previously there were some cases where the connection code would need to send stats,
and it wasn't able to piggy-back them on a data packet. A seperate standalone
stats message was used for this. Changed to plumbing so that the connection code
could initiate sending of an SNP data packet, but ask SNP to not use the whole packet,
and pass through some data, back to the connection-type-specific code. This way all
stats can be sent inline in a data packet.
This is a step towards getting rid of the LinkStatsTracker's acks. Those are still
useful for stats on the relay leg of relayed connections, but for end-to-end, SNP
already does acks, and so it's silly and complicated to have two different mechanisms
for this.
Tweaked ack delay values and timeouts. If the ping was realy low, then if a receiver waited
until the timeout and was forced to flush the acks (no piggy-back opportunity
presented itself), then the sender's timeout was exactly the same, and so there
was no room for error and the ack would just barely timeout.
Also when a packet is NACKed, spew a bit more detail about what actually caused the
nack (either an actual nack from the other side, or ack timeout).
Changed some constants related to PingLocation stuff. That isn't really applicable
to this lib, but I've made some improvements to that system in the Steam code.
This features a robust ack model inspired by Google QUIC,
which allows for minimal retransmission of reliable data.
It should also allow for the rate calculations to be done
by the sender, but that has been temporarily broken.
The wire framing has also been significantly optimized.
The test is compiling, but not fully working.
NOTE: THIS IS UNIT TEST, NOT A TYPICAL SAMPLE OF HOW TO USE THE LIBRARY, PLEASE DON'T CUT AND PASTE. If we have time we'll add a better sample code with a proper server and client.
Also renamed some "SteamDatagram" things (which is the name used to refer to the relay network, not included with the opensource code) to "SteamnetworkingSockets".
Remove include of platform.h in a public header. That's not supposed to be visible or needed outside of compiling the library.
Added a stub for ISteamNetworkingUtils. The only thing that's available in the opensource library is the timestamp function. In the Steamworks version there are utilities for reasoning about the relay network and estimating ping between two locations.
These changes compile and link, but they probably crash or something
right now. We need to get a unit test or three into the repo so we can
vet changes like this.
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Move truly "public" headers to an "include" folder. The internal "public" directory contains files that are only "public" in the context of the Steam build environment.