Skip to content

Commit

Permalink
Implements SCTP zero checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Oct 24, 2023
1 parent 5145ba8 commit 02739d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/rtc/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ struct RTC_CPP_EXPORT Configuration {

// Local maximum message size for Data Channels
optional<size_t> maxMessageSize;

// SCTP settings
bool sctpZeroChecksum = false;
};

} // namespace rtc
Expand Down
10 changes: 10 additions & 0 deletions src/impl/sctptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ SctpTransport::SctpTransport(shared_ptr<Transport> lower, const Configuration &c
throw std::runtime_error("Could not disable SCTP fragmented interleave, errno=" +
std::to_string(errno));

// When using SCTP over DTLS, the data integrity is ensured by DTLS, so there's no
// need to additionally compute CRC32c.
// See https://datatracker.ietf.org/doc/html/draft-ietf-tsvwg-sctp-zero-checksum
if (config.sctpZeroChecksum) {
int on = 1;
if (usrsctp_setsockopt(mSock, IPPROTO_SCTP, SCTP_ACCEPT_ZERO_CHECKSUM, &on, sizeof(on)))
throw std::runtime_error("Could set socket option SCTP_ACCEPT_ZERO_CHECKSUM, errno=" +
std::to_string(errno));
}

int rcvBuf = 0;
socklen_t rcvBufLen = sizeof(rcvBuf);
if (usrsctp_getsockopt(mSock, SOL_SOCKET, SO_RCVBUF, &rcvBuf, &rcvBufLen))
Expand Down

0 comments on commit 02739d5

Please sign in to comment.