aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorFlorent Castelli <orphis@webrtc.org>2021-05-04 20:12:52 +0200
committerWebRTC LUCI CQ <webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-05-04 21:43:24 +0000
commit0810b0510411763c21fb717654888351b173f106 (patch)
treee86da20182259e5e732a091403416314c27bd568 /net
parentda3dc149b20576a9bae09b0d7a4ecfe819829c1f (diff)
downloadwebrtc-0810b0510411763c21fb717654888351b173f106.tar.gz
dcsctp: Add SetMaxMessageSize() to socket
An SCTP transport for Data Channels allows changing the maximum message size through SDP. See https://w3c.github.io/webrtc-pc/#sctp-transport-update-mms Bug: webrtc:12614 Change-Id: I8cff33c5f9c1d60934a726c546bc9cbdcd9e22d9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217387 Reviewed-by: Victor Boivie <boivie@webrtc.org> Commit-Queue: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33920}
Diffstat (limited to 'net')
-rw-r--r--net/dcsctp/public/dcsctp_socket.h3
-rw-r--r--net/dcsctp/socket/dcsctp_socket.cc4
-rw-r--r--net/dcsctp/socket/dcsctp_socket.h3
-rw-r--r--net/dcsctp/socket/dcsctp_socket_test.cc5
4 files changed, 14 insertions, 1 deletions
diff --git a/net/dcsctp/public/dcsctp_socket.h b/net/dcsctp/public/dcsctp_socket.h
index f340cd9ca0..1c2fb97f7a 100644
--- a/net/dcsctp/public/dcsctp_socket.h
+++ b/net/dcsctp/public/dcsctp_socket.h
@@ -296,6 +296,9 @@ class DcSctpSocketInterface {
// The options it was created with.
virtual const DcSctpOptions& options() const = 0;
+ // Update the options max_message_size.
+ virtual void SetMaxMessageSize(size_t max_message_size) = 0;
+
// Sends the message `message` using the provided send options.
// Sending a message is an asynchrous operation, and the `OnError` callback
// may be invoked to indicate any errors in sending the message.
diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc
index b54ad80b9c..dd54317718 100644
--- a/net/dcsctp/socket/dcsctp_socket.cc
+++ b/net/dcsctp/socket/dcsctp_socket.cc
@@ -424,6 +424,10 @@ SocketState DcSctpSocket::state() const {
}
}
+void DcSctpSocket::SetMaxMessageSize(size_t max_message_size) {
+ options_.max_message_size = max_message_size;
+}
+
void DcSctpSocket::MaybeSendShutdownOnPacketReceived(const SctpPacket& packet) {
if (state_ == State::kShutdownSent) {
bool has_data_chunk =
diff --git a/net/dcsctp/socket/dcsctp_socket.h b/net/dcsctp/socket/dcsctp_socket.h
index 271e82e42e..24c0437b41 100644
--- a/net/dcsctp/socket/dcsctp_socket.h
+++ b/net/dcsctp/socket/dcsctp_socket.h
@@ -92,6 +92,7 @@ class DcSctpSocket : public DcSctpSocketInterface {
rtc::ArrayView<const StreamID> outgoing_streams) override;
SocketState state() const override;
const DcSctpOptions& options() const override { return options_; }
+ void SetMaxMessageSize(size_t max_message_size) override;
// Returns this socket's verification tag, or zero if not yet connected.
VerificationTag verification_tag() const {
@@ -244,7 +245,7 @@ class DcSctpSocket : public DcSctpSocketInterface {
const std::string log_prefix_;
const std::unique_ptr<PacketObserver> packet_observer_;
- const DcSctpOptions options_;
+ DcSctpOptions options_;
// Enqueues callbacks and dispatches them just before returning to the caller.
CallbackDeferrer callbacks_;
diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc
index 1848448587..c542a9cd1a 100644
--- a/net/dcsctp/socket/dcsctp_socket_test.cc
+++ b/net/dcsctp/socket/dcsctp_socket_test.cc
@@ -1085,5 +1085,10 @@ TEST_F(DcSctpSocketTest, PassingHighWatermarkWillOnlyAcceptCumAckTsn) {
.Build());
}
+TEST_F(DcSctpSocketTest, SetMaxMessageSize) {
+ sock_a_.SetMaxMessageSize(42u);
+ EXPECT_EQ(sock_a_.options().max_message_size, 42u);
+}
+
} // namespace
} // namespace dcsctp