Commit Graph
149 Commits
Author SHA1 Message Date
Jeff Hill a456c2011f Add configurable recv limits to protect against malicious peer
RecvBufferSize
RecvBufferMessages
RecvMaxMessageSize

P4:7421829,7421830
2022-08-06 14:25:21 -07:00
Fletcher Dunn b8acef56c9 Don't #define VALVE_POSIX
I changed the Steam headers that were checking this (they are not used
in the opensource code) and it is no longer needed.

P4:7380958,7380960
2022-07-15 18:51:55 -07:00
Fletcher Dunn 7012a24e0d A few more platform fixes
- minbase_identify will now check for _GAMING_XBOX_XBOXONE and
  _GAMING_XBOX_SCARLETT.  (And also _GAMING_XBOX)
- Added IsXboxScarlett() and IsXbox()
- A few places in the low level code need to be tweaked based on IsXbox()
  instead of _XBOX_ONE
- Added IsIOS() and IsTVOS()

Deleted some code that was disabling warnings, I don't think it's needed
anymore.

Tweak defines in CSteamNetworkingUtils::GetPlatformString

PS4/PS5 need Microsoft-style __declspec(dllexport)

P4:7324318
2022-06-15 13:09:27 -07:00
Fletcher Dunn 09871d2dc4 Improve platform compatibility
Replace a bunch of non-standard defines with standard ones

Don't #define POSIX in public header or test for it.  Fixes #228.
(We shoulkd probably also make this change to Steamworks headers.)

Use IsLinux(), IsPosix(), etc instead of #ifdef LINUX or #ifdef POSIX

Moved some platform socket stuff out of steamnetworkingsockets_platform.h
and into platform_sockets.h.  (none of this is actually particular to
steamnetworkingsockets.)

Some platforms don't have IPv6 support.
2022-06-14 12:04:10 -07:00
Fletcher Dunn b221ac1a1c Fix incorrect comment describing lan priority
Fixes issue #224
2022-06-08 11:11:36 -07:00
Fletcher Dunn 4b9e27841c Sync up steam headers
P4:7194210
2022-04-08 08:06:41 -07:00
Jeff Hill 23dfdbf5d4 First draft at built-in ICE client.
This means WebRTC won't be necessary to use P2P and NAT punch functionality.

P4:7193749
2022-04-07 18:21:57 -07:00
Fletcher Dunn b794235422 STEAMNETWORKINGSOCKETS_NOSTEAM is now a thing.
(Not really relevant to the opensource code.)

P4:7193707,7193716,7193719,7193724
2022-04-07 17:58:23 -07:00
Fletcher Dunn 8fe64b410d Bring Steam headers in sync with Steam main branch
Also delete some old steam2 stuff we don't need.

P4:7056269
2022-02-04 13:15:46 -08:00
Fletcher Dunn fea0e836d9 Clarify some comments about FakeIP stuff
P4:6986485
2022-01-05 10:55:41 -08:00
Fletcher Dunn 9b794e3077 Fix for flat API generation from Steam.
The render classes should not have a flat interface.  That's not useful.

P4:6894623
2021-11-12 18:36:14 -08:00
Fletcher Dunn 1b0e5ab908 Tweak comment
Mention another reason why we might sometimes deliver messages
out of priority order.

P4:6865690
2021-10-29 17:41:28 -07:00
Fletcher Dunn 9efdab59ce Multiple lane support working!
Visible changes:
- Uncomment ConfigureConnectionLanes
- Rename GetQuickConnectionStatus to GetConnectionRealTimeStatus, and change
  the prototype to return information about multiple lanes.
- Adding a test case to send data on more than one lane and make sure we get
  the priorities we expect.
- Also refactored the test-connection so that you specify what test(s) to
  run on the command line, instead of using the LIGHT_TESTS compile-time
  option.
- Bump interface version numbers.

Internal changes/bugfixes:
- Fix bug with my implementation of fair queuing.  I was always calculating
  the finish time for a lane based on the current virtual time.  But really
  it must be calculated from the time when the previous message in the same
  lane finishes.  Otherwise you don't share the bandwidth properly when it
  alternates lanes.  To keep the implementation simple, I just tag each
  message with the virual finish time.  I believe that this can actually
  cause the virtual time to go in reverse if you queue a message on an idle
  lane and we swap the active lane while sending is in progress.  But I
  think it's OK right now, and we will actually do the right thing and get
  back on track after a message or two.  To make room for this variable,
  I shuffled around how we had shoved in reliable bookkeeping in
  CSteamNetworkingMessage.
- Fix bug selecting the next message to send.  We were ignoring the priority
  classes and just using virtual time!
- Fix some bad hex math encoding and decoding the lane select frame.
- Fix some bugs that were confused about which set of links were used to
  track the list of messages in a particular lane
- Fix bug when serializing segments from multiple lanes, only one of the
  lanes will get to take advantage of the special segment encoding where
  the segment length is implied by the packet size.
- Reorder the fields in SSNPSenderState::Lane to pack them a bit better

Fixes issue #95.

P4:6865294
2021-10-29 16:46:11 -07:00
Fletcher Dunn 5a8ba93040 Improve debug names of stuff
- Added VirtualPortRender, which can be used to show symbolic names to the
  "messages" vport and the fake UDP port vports.
- Replace "vport %d" with VirtualPortRender calls in several debug output
  call sites.
- Improve and refactor CSteamNetworkConnectionP2P::GetConnectionTypeDescription
  to handle fake IP and vports smarter.

p4:6865178
2021-10-29 15:21:54 -07:00
Fletcher Dunn d34d8a25cb Fix for game coordinator lib handling STEAMNETWORKINGSOCKETS_FOREXPORT
P4:6865142
2021-10-29 15:13:54 -07:00
Fletcher Dunn 67782b3a6e First pass at multiple lane support finished
Implement packet decode for the lane select frame.  I have not executed all
this one single time!  (But I have been making sure I haven't broken the
single-lane case.)  If I have not written any bugs, the the feature almost
done!

Remaining work:
- Write test harness, make sure it does actually work...
- Bump versions, deal with old peers who don't understand lanes, etc.

Also, add STEAMNETWORKINGSOCKETS_MAX_LANES.
- Add some optimizations if STEAMNETWORKINGSOCKETS_MAX_LANES is small.
  In particular, STEAMNETWORKINGSOCKETS_MAX_LANES=1 disables support,
  and all the code is compiled out.
- Also this can be used to limit the amount of work a malicious sender
  can make a receiver do.

P4:6819330,6819343
2021-10-08 17:28:37 -07:00
Fletcher Dunn 2b2b5caace More progress on multiple lanes
- Updated wire protocol document
- Implement encoding for multiple lanes.
- Added function declaration to ISteamNetworkingSockets with rather copious
  documentation.  (But left it commented out for now, until it all works).

Remaining work:
- Implement decoding
- Bump versions, deal with old peers who don't understand lanes.
- Add tests

P4:6819091,6819098
2021-10-08 16:10:18 -07:00
Fletcher Dunn 4765afce5d Two changes to the design of lanes
- Added a system for strict priority classes, in addition to the "weight"
  system.  The combination of these two makes for a very flexible system,
  while also hopefully being easy to understand.

- Each lane has its own message number sequence.  This has several
  advantages:
  - It makes it clear that the order of messages between lanes is
    not guaranteed
  - It greatly simplifies packet encoding/decoding.  (Going to make some
    more progress on that next.)

(Based on discussions with jeffreyh@valvesoftware.com.  Thanks!)

P4:6818689,6818692
2021-10-08 14:46:33 -07:00
Fletcher Dunn 744535b052 Groundwork for "lanes".
Lanes are different messages queues with different priority levels.

Work in progress.  This change just adds some data structures, but
the actual wire encoding/decoding not yet implemented.

See also:
- Issue #95
- https://twitter.com/Mokosha/status/1444009029987041281

P4:6806862
2021-10-04 12:19:36 -07:00
Levent 30ec24294f TURN server configuration implemented. 2021-10-04 11:56:22 -07:00
Fletcher Dunn 1965539d70 Fake UDP port stuff from Steam branch
FakeIP is only available on Steam, since it requires somebody to manage the
global namespace.

P4:6761707
2021-09-10 19:30:14 -07:00
Fletcher Dunn 3ebfc3483f Added a configval to control diagnostics reporting.
(Not applicable here since there is nobody to consume the diagnostics.)

P4:6761700
2021-09-10 19:20:23 -07:00
Fletcher Dunn 746696b68a Sync up header with the one in main Steam branch.
P4:6753549
2021-09-04 13:24:07 -07:00
Fletcher Dunn 2aed27b01b Clarify comment based on discussion with a dev
P4:6722463
2021-08-12 13:58:47 -07:00
osen ae3782dcb2 Use VALVE_CALLBACK_PACK_SMALL for FreeBSD
Fixes issue #176

Signed-off-by: Fletcher Dunn <fletcherd@valvesoftware.com>
2021-06-17 16:46:29 -07:00
Fletcher Dunn 7af0943ddc Sync up with Steamworks SDK
With the exception of steam_api_common.h, which is mostly a stub,
these files are now identical with the Steamworks SDK.

Note that this also removes a check for STEAMNETWORKINGSOCKETS_OPENSOURCE
to try to set the structure packing consistently.  However, due to an
order-of-include bug (see issue #176), this wasn't actually working anyway,
and probably isn't the best approach.

P4:6610285
2021-06-17 16:21:24 -07:00
Fletcher Dunn aaadcc0661 [Steam only] Add SetGlobalCallback_FakeIPResult
And tweak an old comment referring to "ticket generator" library.

P4:6610057
2021-06-17 15:56:15 -07:00
pkubaj e75633daa9 Fix build on not specified 64-bit architectures
Only x86_64, aarch64 and s390x are specified as 64-bit, but there are more 64-bit architectures, e.g.:
- mips64,
- powerpc64,
- powerpc64le,
- riscv64.

Those are not on the list. Of those, I checked that GameNetworkingSockets builds fine on powerpc64le with this change.

Signed-off-by: Fletcher Dunn <fletcherd@valvesoftware.com>
2021-06-16 10:07:13 -07:00
Fletcher Dunn b43d37da43 [SteaM only] Added "FakeIP" system.
This won't work without Steam (STEAMNETWORKINGSOCKETS_ENABLE_FAKEIP
won't ever be defined here).  But to make sure we can always share
the headers between this code and Steamworks SDK, the interface functions
will still exist.

P4:6571466,6571469
2021-05-28 18:21:17 -07:00
Fletcher Dunn e7bf4f15bb Improve introspection/enumeration of config values
Separate "get info" and "iterate" tasks into two different functions.

Have the "get info" function just return the name, since that the most basic piece of info.

Delete the EnumerateDevVars config value.  That's too subtle and a bad design
Just always pass that option into the enumeration function.

P4:6571450
2021-05-28 18:08:21 -07:00
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