Commit graph

81 commits

Author SHA1 Message Date
Florent Castelli
8037fc6ffa Migrate absl::optional to std::optional
Bug: webrtc:342905193
No-Try: True
Change-Id: Icc968be43b8830038ea9a1f5f604307220457807
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361021
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42911}
2024-09-02 12:16:47 +00:00
Philipp Hancke
4158678b46 Split "helpers" from SSL target to "crypto_random" and rename
since it contains helpers mostly related to cryptographically secure random numbers and strings.

BUG=webrtc:339300437

Change-Id: I10db939534b25dc792ac1600a4721d1b84521880
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/352620
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42441}
2024-06-07 06:41:51 +00:00
Philipp Hancke
7b087121b5 Move moving average helper out of ssl target
to the only place where it is used.

BUG=webrtc:339300437

Change-Id: I0d4124b95d19a11578efaf7e8e0a1ff1d39eb59b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/351581
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Cr-Commit-Position: refs/heads/main@{#42383}
2024-05-27 12:50:06 +00:00
Tomas Gunnarsson
0242939296 Reland "Deprecate old constructors and set_type() in Candidate and Port"
This reverts commit ed8390d21a.

Reason for revert: Fix has landed in chrome, ready to reland.

Original change's description:
> Revert "Deprecate old constructors and set_type() in Candidate and Port"
>
> This reverts commit aaa6851d53.
>
> Reason for revert: breaks chromium webrtc import
>
> Original change's description:
> > Deprecate old constructors and set_type() in Candidate and Port
> >
> > * Deprecates constructors that use string based `type`
> > * Deprecates string based type functions in favor of enum based.
> > * Restrict possible values of Candidate::type. Ensure a valid value
> >   is assigned at construction.
> > * Make Port constructors protected to limit their use to subclasses.
> >   - The reason for this is to make sure that use of SharedSocket()
> >     is controlled (it adds a bit of complexity).
> > * Simplify construction of Port (remove Construct() etc)
> >
> > Bug: webrtc:15846
> > Change-Id: If24ed674e175642efa49da37fd2bc847dd14f613
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339860
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#41865}
>
> Bug: webrtc:15846
> Change-Id: Ic8b7cba97f8fb207ef51a88900e704658ade28b7
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342140
> Auto-Submit: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Owners-Override: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#41867}

Bug: webrtc:15846
Change-Id: I3d52643bbb537d1c072643528828d26eb18fea94
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342200
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41875}
2024-03-08 20:39:59 +00:00
Ilya Nikolaevskiy
ed8390d21a Revert "Deprecate old constructors and set_type() in Candidate and Port"
This reverts commit aaa6851d53.

Reason for revert: breaks chromium webrtc import

Original change's description:
> Deprecate old constructors and set_type() in Candidate and Port
>
> * Deprecates constructors that use string based `type`
> * Deprecates string based type functions in favor of enum based.
> * Restrict possible values of Candidate::type. Ensure a valid value
>   is assigned at construction.
> * Make Port constructors protected to limit their use to subclasses.
>   - The reason for this is to make sure that use of SharedSocket()
>     is controlled (it adds a bit of complexity).
> * Simplify construction of Port (remove Construct() etc)
>
> Bug: webrtc:15846
> Change-Id: If24ed674e175642efa49da37fd2bc847dd14f613
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339860
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#41865}

Bug: webrtc:15846
Change-Id: Ic8b7cba97f8fb207ef51a88900e704658ade28b7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342140
Auto-Submit: Ilya Nikolaevskiy <ilnik@webrtc.org>
Owners-Override: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#41867}
2024-03-07 09:43:38 +00:00
Tommi
aaa6851d53 Deprecate old constructors and set_type() in Candidate and Port
* Deprecates constructors that use string based `type`
* Deprecates string based type functions in favor of enum based.
* Restrict possible values of Candidate::type. Ensure a valid value
  is assigned at construction.
* Make Port constructors protected to limit their use to subclasses.
  - The reason for this is to make sure that use of SharedSocket()
    is controlled (it adds a bit of complexity).
* Simplify construction of Port (remove Construct() etc)

Bug: webrtc:15846
Change-Id: If24ed674e175642efa49da37fd2bc847dd14f613
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339860
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41865}
2024-03-06 18:36:14 +00:00
Tommi
f2431a97d5 Move ComputeFoundation to Candidate.
Move code from P2PTransportChannel to Candidate, where we set the
foundation value for remote prflx candidates.

Bug: none
Change-Id: I7dbcb85bca35dca7297136b0706092dd8d2b153c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339902
Reviewed-by: Philipp Hancke <phancke@microsoft.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41774}
2024-02-21 09:24:32 +00:00
Tommi
bde80e3c0e Deprecate Candidate::set_id(), offer generate_id() instead
Bug: none
Change-Id: I68df28a24446667c1bcde04120795fce54252feb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339940
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41762}
2024-02-19 15:01:02 +00:00
Tommi
0ba663c245 Change a few uses of Candidate::type() to Candidate::type_name()
Switch to type_name() for things like logging since `type()` will
change to returning an enumeration value.

The functional change that this has is that log statements and
Connection::ToString() (used for logging) will contain "host"
instead of "local" and "srflx" instead of "stun".

Bug: webrtc:15846
Change-Id: I35c50d026e4578a25d51765d59c6f2e01b850c94
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339180
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41757}
2024-02-17 18:41:38 +00:00
Tommi
2c169aef97 Rename kLocal to kHost and kStun to kSrflx
Bug: none
Change-Id: I92845014024e5780365057e81b613b0882724d1d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/336740
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41652}
2024-02-01 12:31:08 +00:00
Tommi
c4dd03dfcb Remove kUnknown as a possible value for IceCandidateType.
Subsequently also tighten IceCandidateType error checking.
The Candidate type in `cricket` should be using something similar
(currently using a string for the type), so I'm making sure that
types that we have already, align with where we'd like to be overall.
Possibly we can move IceCandidateType to where Candidate is defined.

Bug: none
Change-Id: Iffeba7268f2a393e18a5f33249efae46e6e08252
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/335980
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41640}
2024-01-31 11:26:53 +00:00
Tommi
698b4e7087 Update more Candidate type checkers to use Candidate::is_*
This is a follow up to a previous CL that removed direct dependency on
the `cricket::` string globals.

Bug: none
Change-Id: I4d839a36739fc4694ce81b72ee036e83dae580df
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/335420
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41623}
2024-01-26 13:41:09 +00:00
Harald Alvestrand
9a953b28f9 Detangle p2p/connection.cc and port.cc
This CL does:
- Run IWYU on the relevant elements
- Make connection depend on port_interface, not port
- Make port_allocator depend only on port
- Move some constants from port.h into p2p_constants

This allows a dependency graph without ugly groups.

Bug: webrtc:15796
Change-Id: I0ff0e14eacdfe3b230a8d84902a78eb062d6c8af
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/336320
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41618}
2024-01-26 08:29:27 +00:00
Tommi
0a7fc84887 Use is_* getters when checking the Candidate type
This removes several references across the code base that depended on
the global string constants.

Bug: none
Change-Id: I007bd4b195c35261039f655f1a8f52e632c3691f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/335320
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41578}
2024-01-19 15:37:32 +00:00
Per K
698e0bec17 Add Connection::OnReadPacket(const rtc::PacketReceived&)
Deprecate old version but keep it for the time being.

Bug: webrtc:15368
Change-Id: Icbd2078a00d877ff948a2441c2027a12c85d4f2e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/326104
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41112}
2023-11-09 09:15:02 +00:00
Per K
03457f6891 Remove unused Connection::SignalReadPacket
Bug: webrtc:11943
Change-Id: I44bbc023a52c9a7499a4d66db14037180f075b30
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/326102
Auto-Submit: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41096}
2023-11-07 11:25:12 +00:00
Per K
25db2c65b6 Introduce Connection::RegisterReceivedPacketCallback
RegisterReceivedPacketCallback is used instead of
sigslot::SignalReadPacket. The callback use a new data class ReceivedPacket that combine meta
data and packet payload from a received packet.

This is the first step in an attempt to cleanup the data types used in
the packet receive pipeline.
Eventually, the ReceivedPacket class can contain more meta data such as
ECN information.

Bug: webrtc:11943,webrtc:15368
Change-Id: I984c561b9262fe4aa00176529bd8d901adf66640
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325060
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41021}
2023-10-27 12:39:39 +00:00
Jonas Oreland
c4f3919fdd Add RTC_DCHECK that port_ is always valid in Connection.
This patch is a follow up to https://webrtc-review.googlesource.com/c/src/+/260943
which made it possible to destroy a Port before a Connection (on that
port).

This patch "reverses" this, by adding RTC_DHECK, and fixes the Port
destructor to release the Connections before invalidating the WeakPtr<>.

Currently there are no known occurrences where a Connection is destroyed after it's Port is. But prior to the change in Port destructor, a bunch unit tests failed on the newly added DCHECKs.

In addition:
a) modify StunReqquestManager to remove entry from hash before calling callback. This makes it possible for callback to modify (clear) hash.
b) clear pending requests when disconnecting from port, "should not be needed", depends on a)
c) add a getter for pending_delete()

Bug: webrtc:13892, webrtc:13865
Change-Id: I5d18f2db8d93b7cc25d18bd620063589ee9257c9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/322861
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40907}
2023-10-11 10:16:15 +00:00
Jonas Oreland
fc92d33327 Add StunDictionary - patch 2
This patch hooks up the StunDictionary to Connection
and P2PTransportChannel.

Bug: webrtc:15392
Change-Id: Ibeea4d8706ebd42f2353d9d300631c02bf0d484d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/315100
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40519}
2023-08-07 13:10:00 +00:00
Jonas Oreland
614da1b1d8 Cleanup Connection message integrity handling
This cl/ clean up the handling of message integrity in Connection.
- Port validates message integrity of REQUESTs,
  using local candidate password.
- Connection validates message integrity of RESPONSEs,
  using remote candidate password.

Bug: webrtc:14578
Change-Id: I6fdb638b52f4fb7a997fd50393f9ed284543beac
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290700
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39028}
2023-01-09 10:18:40 +00:00
Harald Alvestrand
70d9e4e02b Don't log PW mismatch messages in production
The STUN message about mismatched passwords is not interesting.
Only emit it in VERBOSE mode when DCHECK is on.

Bug: webrtc:14578
Change-Id: Ie83080d88be6da24e7f2f79d7eb279087f84c2a0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288740
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38938}
2022-12-21 11:43:05 +00:00
Philipp Hancke
0487c5797a stats: implement candidate-pair lastPacket(Sent|Received)Timestamp
https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-lastpacketsenttimestamp
https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-lastpacketreceivedtimestamp

which are useful together with the ice-restart-necessary logic mentioned
in
  https://w3c.github.io/webrtc-pc/#dictionary-rtcofferoptions-members

BUG=webrtc:14619

Change-Id: I4a8ab00a37fbd4af8b948720c83787cbdfc6b9a3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/281281
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#38534}
2022-11-02 12:16:21 +00:00
Philipp Hancke
08b882d762 ice: include tiebreaker in computation of foundation attribute
the foundation attribute is currently calculated as
  CRC32(baseaddress, protocol, relayprotocol)
which is a way to satisfy the requirements from
  https://www.rfc-editor.org/rfc/rfc5245#section-4.1.1.3

However, this leaks the base address which defeats the
MDNS obfuscation described in
  https://datatracker.ietf.org/doc/draft-ietf-mmusic-mdns-ice-candidates/
since the CRC32 can be reversed using a table lookup as shown in
  https://github.com/niespodd/webrtc-local-ip-leak/

To defeat that lookup, "seed" the CRC32 with the ICE tie-breaker which is a randomly picked unsigned 64 bit integer described in
  https://www.rfc-editor.org/rfc/rfc5245#section-5.2

The tie-breaker is not known to Javascript and adding it scopes the foundation within the peer connection as described in section 4.1.1.3

To manually test (preferably with a DCHECK for IceTiebreaker() in ComputeFoundation)
- gather candidates twice on https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ and observe that the foundations are not the same after this change
- create two RTCPeerConnections with {iceCandidatePoolSize: 1}, create a datachannel, call setLocalDescription, inspect the candidates and observe that the foundations are not the same after this change.

Unit test changes have been split into a separate CL for easier integration.

BUG=webrtc:14605

Change-Id: I6bbad1635b48997b00ae74d251ae357bf8afd12f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280621
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38485}
2022-10-27 15:50:02 +00:00
Harald Alvestrand
666c333625 Stop revalidating STUN packets with the wrong password
Investigation showed that a function is revalidating STUN packets
against the wrong password.
This CL also allows absl/strings/escape.h as #include.

Bug: chromium:1177125
Change-Id: Ie068d4c076a5462f2922a012f5e1de23aa6c0b06
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279560
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38438}
2022-10-19 09:38:09 +00:00
Harald Alvestrand
47627626dd STUN: Avoid ICE message revalidation wherever possible.
Also call out the places where it happens explicitly - these are places
that need to be redesigned.

Bug: chromium:1177125
Change-Id: I3237d028dbb22380e8fbf7cedb03e965d1fcf2aa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279022
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38384}
2022-10-13 10:55:31 +00:00
Danil Chapovalov
6e7c2685e3 Allow recursive check for RTC_DCHECK_RUN_ON macro
instead of using Lock/Unlock attributes, use Assert attribute to annotate code is running on certain task queue or thread.

Such check better matches what is checked, in particular allows to
recheck (and thus better document) currently used task queue

Bug: None
Change-Id: I5bc1c397efbc8342cf7915093b578bb015c85651
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269381
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37619}
2022-07-26 09:27:23 +00:00
Ali Tofigh
de2ac5a6f3 Adopt absl::string_view in p2p/
Bug: webrtc:13579
Change-Id: Ia33afa2a9ad12d1a586087d49f581a93fddb565d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262766
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37381}
2022-06-30 13:19:18 +00:00
Tommi
6fd77f3d3f Reland "Make deletion of Connection objects more deterministic."
This reverts commit 869c87a2b9.

Reason for revert: Re-landing

Original change's description:
> Revert "Make deletion of Connection objects more deterministic."
>
> This reverts commit 942cac2e9e.
>
> Reason for revert: Reverting while downstream updates are made.
>
> Original change's description:
> > Make deletion of Connection objects more deterministic.
> >
> > This changes most deletion paths of Connection objects to go through
> > the owner class of the Connection instances, Port.
> >
> > In situations where Connection objects still need to be deleted
> > asynchronously, `async = true` can be passed to
> > `Port::DestroyConnection` and get the same behavior as
> > `Connection::Destroy` formerly gave.
> >
> > The `Destroy()` method still exists for downstream compatibility, but
> > instead of deleting connection objects asynchronously, the deletion
> > now happens synchronously via the Port class.
> >
> > Bug: webrtc:13892, webrtc:13865
> > Change-Id: I07edb7bb5e5d93b33542581b4b09def548de9e12
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259826
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#36676}
>
> Bug: webrtc:13892, webrtc:13865
> Change-Id: I37a15692c8201716402ba5c10f249e4d3754ce4c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260862
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36736}

Bug: webrtc:13892, webrtc:13865
Change-Id: I29da6c8899d8550c26ccecbbd0fe5f5556c80212
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260943
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37171}
2022-06-10 06:06:05 +00:00
Tommi
e83500e17b [Connection] Construct ping/connection requests in one step.
This moves the construction of StunMessage instances for
ConnectionRequest, outside of the Prepare() method.

Following this, removing Construct()+Prepare() is relatively
straight forward.

Bug: none
Change-Id: Ibcf0510cef30a6e648005b43602c7ae1fb06729e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264558
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37122}
2022-06-03 20:04:24 +00:00
Tommi
408143d5af Refactor StunMessage a bit
* Add ctors for providing the type and transaction id at construction.
* Update tests to use them instead of SetType+SetTransactionID
* Make sure stun message enum types are based on uint16_t
* Mark SetTransactionID as deprecated.
* Mark SetStunMagicCookie as deprecated (unused in webrtc).
* Add SetTransactionIdForTest for the one test that uses it (might not
  actually need it)
* Make StunRequest::Construct() protected.
  * Add a TODO to follow up on this since construction of StunRequest
    goes through an unnecessarily complex 3-step process involving
    other classes and a virtual method.

Bug: none
Change-Id: Ib013e58f28e7b2b4fcb3b3e1034da31dfc93e9d3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264546
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37079}
2022-06-01 17:43:55 +00:00
Tommi
c85e473740 [Connection] Remove friend clause for ConnectionRequest
* Switch to StunRequest where ConnectionRequest isn't needed.
* Move ConnectionRequest into Connection as a subclass
* Move declaration+implementation into the .cc file.

Bug: none
Change-Id: I1591a91d8e13a0db9f89cfbba0fbc9478a55b789
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264150
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37036}
2022-05-30 10:34:23 +00:00
Tommi
94ad387f77 [Connection] Replace local index with a copy of the candidate.
This is to avoid using an index into a vector that's owned by Port.

Bug: none
Change-Id: Ifc67fcc24bcb04e55c7b963de6d29bb9541c1495
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263643
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37015}
2022-05-27 10:45:24 +00:00
Tommi
c80a182e55 Remove 'new_connection' attribute from ConnectionInfo
Bug: none
Change-Id: Id08aa530ebf0bca50517d8e24b5cad9953a5691a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263180
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36971}
2022-05-23 12:58:21 +00:00
Tomas Gunnarsson
869c87a2b9 Revert "Make deletion of Connection objects more deterministic."
This reverts commit 942cac2e9e.

Reason for revert: Reverting while downstream updates are made.

Original change's description:
> Make deletion of Connection objects more deterministic.
>
> This changes most deletion paths of Connection objects to go through
> the owner class of the Connection instances, Port.
>
> In situations where Connection objects still need to be deleted
> asynchronously, `async = true` can be passed to
> `Port::DestroyConnection` and get the same behavior as
> `Connection::Destroy` formerly gave.
>
> The `Destroy()` method still exists for downstream compatibility, but
> instead of deleting connection objects asynchronously, the deletion
> now happens synchronously via the Port class.
>
> Bug: webrtc:13892, webrtc:13865
> Change-Id: I07edb7bb5e5d93b33542581b4b09def548de9e12
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259826
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36676}

Bug: webrtc:13892, webrtc:13865
Change-Id: I37a15692c8201716402ba5c10f249e4d3754ce4c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260862
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36736}
2022-05-02 20:41:39 +00:00
Tomas Gunnarsson
edeeef24a6 Revert "Clear port_ before firing destroyed event."
This reverts commit ca94696ae2.

Reason for revert: Downstream needs updating.

Original change's description:
> Clear port_ before firing destroyed event.
>
> This reverts a change introduced last week in [1] whereby the port_
> pointer would be valid while firing the `Destroyed` event.
>
> [1] https://webrtc-review.googlesource.com/c/src/+/259826
>
> Bug: webrtc:13892, webrtc:13865
> Change-Id: I9c7be8fa9a5603fbdbf0debd91e2d4e21b303270
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260860
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36728}

Bug: webrtc:13892, webrtc:13865
Change-Id: Ic7571fa8433897b348ca9a8f73ceae68014fe0c6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260921
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#36735}
2022-05-02 19:06:37 +00:00
Tommi
ca94696ae2 Clear port_ before firing destroyed event.
This reverts a change introduced last week in [1] whereby the port_
pointer would be valid while firing the `Destroyed` event.

[1] https://webrtc-review.googlesource.com/c/src/+/259826

Bug: webrtc:13892, webrtc:13865
Change-Id: I9c7be8fa9a5603fbdbf0debd91e2d4e21b303270
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260860
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36728}
2022-05-02 09:56:42 +00:00
Tommi
942cac2e9e Make deletion of Connection objects more deterministic.
This changes most deletion paths of Connection objects to go through
the owner class of the Connection instances, Port.

In situations where Connection objects still need to be deleted
asynchronously, `async = true` can be passed to
`Port::DestroyConnection` and get the same behavior as
`Connection::Destroy` formerly gave.

The `Destroy()` method still exists for downstream compatibility, but
instead of deleting connection objects asynchronously, the deletion
now happens synchronously via the Port class.

Bug: webrtc:13892, webrtc:13865
Change-Id: I07edb7bb5e5d93b33542581b4b09def548de9e12
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259826
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36676}
2022-04-27 21:52:31 +00:00
Tommi
6b1d626b04 Remove deprecated ProxyConnection ctor and make NewWeakPtr protected.
Bug: webrtc:13892
Change-Id: Icad20a0f6d304c23106dd880f3bfd2c7142929c9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258601
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36583}
2022-04-20 10:14:17 +00:00
Tommi
d229326578 [Connection] Replace pending_delete_ with !port_.
`pending_delete_` was being used to protect from referencing a
potentially bad `port_` pointer. We now use a WeakPtr for the port
reference, which we clear inside of the Destroy() method. This means
we don't need both flags.

Bug: webrtc:13892
Change-Id: I9427829444486e97d30752893ba2a30b153a70e5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258980
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36554}
2022-04-14 21:04:50 +00:00
Tomas Gunnarsson
f22dfdddfe Use std::function instead of sigslot for sending packets
Bug: webrtc:11943
Change-Id: I2df9908f5e2e2ded1f2c6fbf50ef415f73760b50
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258787
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36541}
2022-04-13 15:01:25 +00:00
Tommi
278b19da38 Rename variables of type StunMessage* from request to message.
This is just to reduce confusion since StunMessage and StunRequest
instances are frequently used together and message objects are often
configured from within request objects (which makes the name confusing).

Bug: none
Change-Id: I8bf5e774a5149239dd3023817614d411633bf583
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258484
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36533}
2022-04-12 12:52:08 +00:00
Tommi
86aa03e238 Refactor StunRequest and StunRequestManager classes.
* Make StunRequest::manager_ a reference, inject ref at ctor time.
* Make other member variables private.
* Mark methods that are only used for testing with "ForTest"
* Add RTC_GUARDED_BY for member variables and thread checks.
* Remove/reduce 'friend'-ness between classes.
* Use std::unique_ptr for owned and passed message pointers.
* Rename `requests_` to `request_manager_` (type: StunRequestManager)

Bug: webrtc:13892
Change-Id: I3a5d511b3c2645bb6813352d39e9fefe422dd1de
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258620
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36529}
2022-04-12 08:22:27 +00:00
Tommi
d7e5cfb3cf Use WeakPtr<Port> in Connection classes.
This is to aid with catching issues whereby a connection object might
have a bad reference back to a port object, e.g. inside of an async
callback.

Bug: webrtc:13892
Change-Id: I56503fedc2865919713b10f236ce023554c68ded
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257164
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36394}
2022-03-31 12:44:02 +00:00
Tommi
a8bc137835 Avoid touching port_ in Connection::ToString() after starting delete.
Bug: webrtc:13865
Change-Id: Ia469c46642d7e305a50e57d9ea6ad873e633db4e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256808
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36338}
2022-03-25 13:39:44 +00:00
Tommi
824d8b0263 Don't Prune a to-be-deleted connection object
Bug: webrtc:13865
Change-Id: I87c18c8a1dfc0284bef1e721a56ad61ab89dc1c3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256680
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36320}
2022-03-24 14:29:03 +00:00
Jonas Oreland
340cb5e46a WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 8/inf
Convert p2p/.
This completes work started in https://webrtc-review.googlesource.com/c/src/+/255602

Bug: webrtc:10335
Change-Id: I39f70890be0599c8ef46ff7982d2a229e10e67ff
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255827
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36231}
2022-03-17 09:08:45 +00:00
Tomas Gunnarsson
7c2e958711 Add a guard against double delete to Connection::Destroy
Bug: webrtc:13752
Change-Id: I80345fe2e560773f9f98f850def386ec53ae798f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252660
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36085}
2022-02-25 23:43:03 +00:00
Mirko Bonadei
0cb1cfa69e Reland "Removing MessageHandler dependency from Connection."
This reverts commit 05ea12e513.

Reason for revert: Speculative revert.

Original change's description:
> Revert "Removing MessageHandler dependency from Connection."
>
> This reverts commit 3202e29f72.
>
> Reason for revert: Introduced a crash in the task posted by Destroy()
>
> Original change's description:
> > Removing MessageHandler dependency from Connection.
> >
> > Bug: webrtc:11988
> > Change-Id: Ic35bb5baeafbda7210012dceb0d6d5f5b3eb95c9
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249941
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#35890}
>
> No-Try: True
> Bug: webrtc:11988
> Change-Id: Ie70ee145fde75b8cf76b02784176970e7a78e001
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252541
> Auto-Submit: Taylor Brandstetter <deadbeef@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36078}

No-Try: True
Bug: webrtc:11988
Change-Id: Idfd42d016e81d4352839c33dcb4ea3b0dafea08b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252584
Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36081}
2022-02-25 11:01:54 +00:00
Taylor Brandstetter
05ea12e513 Revert "Removing MessageHandler dependency from Connection."
This reverts commit 3202e29f72.

Reason for revert: Introduced a crash in the task posted by Destroy()

Original change's description:
> Removing MessageHandler dependency from Connection.
>
> Bug: webrtc:11988
> Change-Id: Ic35bb5baeafbda7210012dceb0d6d5f5b3eb95c9
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249941
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35890}

No-Try: True
Bug: webrtc:11988
Change-Id: Ie70ee145fde75b8cf76b02784176970e7a78e001
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252541
Auto-Submit: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36078}
2022-02-25 10:41:13 +00:00
Tommi
3202e29f72 Removing MessageHandler dependency from Connection.
Bug: webrtc:11988
Change-Id: Ic35bb5baeafbda7210012dceb0d6d5f5b3eb95c9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249941
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35890}
2022-02-02 16:32:20 +00:00