/* * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/ #ifndef NET_DCSCTP_SOCKET_DCSCTP_SOCKET_H_ #define NET_DCSCTP_SOCKET_DCSCTP_SOCKET_H_
// DcSctpSocket represents a single SCTP socket, to be used over DTLS. // // Every dcSCTP is completely isolated from any other socket. // // This class manages all packet and chunk dispatching and mainly handles the // connection sequences (connect, close, shutdown, etc) as well as managing // the Transmission Control Block (tcb). // // This class is thread-compatible. class DcSctpSocket : public DcSctpSocketInterface { public: // Instantiates a DcSctpSocket, which interacts with the world through the // `callbacks` interface and is configured using `options`. // // For debugging, `log_prefix` will prefix all debug logs, and a // `packet_observer` can be attached to e.g. dump sent and received packets.
DcSctpSocket(absl::string_view log_prefix,
DcSctpSocketCallbacks& callbacks,
std::unique_ptr<PacketObserver> packet_observer, const DcSctpOptions& options);
// Detailed state (separate from SocketState, which is the public state). enumclass State {
kClosed,
kCookieWait, // TCB valid in these:
kCookieEchoed,
kEstablished,
kShutdownPending,
kShutdownSent,
kShutdownReceived,
kShutdownAckSent,
};
// Returns the log prefix used for debug logging.
std::string log_prefix() const;
// Changes the socket state, given a `reason` (for debugging/logging). void SetState(State state, absl::string_view reason); // Closes the association. Note that the TCB will not be valid past this call. void InternalClose(ErrorKind error, absl::string_view message); // Closes the association, because of too many retransmission errors. void CloseConnectionBecauseOfTooManyTransmissionErrors(); // Timer expiration handlers
webrtc::TimeDelta OnInitTimerExpiry();
webrtc::TimeDelta OnCookieTimerExpiry();
webrtc::TimeDelta OnShutdownTimerExpiry(); void OnSentPacket(rtc::ArrayView<const uint8_t> packet,
SendPacketStatus status); // Sends SHUTDOWN or SHUTDOWN-ACK if the socket is shutting down and if all // outstanding data has been acknowledged. void MaybeSendShutdownOrAck(); // If the socket is shutting down, responds SHUTDOWN to any incoming DATA. void MaybeSendShutdownOnPacketReceived(const SctpPacket& packet); // If there are streams pending to be reset, send a request to reset them. void MaybeSendResetStreamsRequest(); // Performs internal processing shared between Send and SendMany.
SendStatus InternalSend(const DcSctpMessage& message, const SendOptions& send_options); // Sends a INIT chunk. void SendInit(); // Sends a SHUTDOWN chunk. void SendShutdown(); // Sends a SHUTDOWN-ACK chunk. void SendShutdownAck(); // Validates the SCTP packet, as a whole - not the validity of individual // chunks within it, as that's done in the different chunk handlers. bool ValidatePacket(const SctpPacket& packet); // Parses `payload`, which is a serialized packet that is just going to be // sent and prints all chunks. void DebugPrintOutgoing(rtc::ArrayView<const uint8_t> payload); // Called whenever data has been received, or the cumulative acknowledgment // TSN has moved, that may result in delivering messages. void MaybeDeliverMessages(); // Returns true if there is a TCB, and false otherwise (and reports an error). bool ValidateHasTCB();
// Returns true if the parsing of a chunk of type `T` succeeded. If it didn't, // it reports an error and returns false. template <class T> bool ValidateParseSuccess(const std::optional<T>& c) { if (c.has_value()) { returntrue;
}
// Reports failing to have parsed a chunk with the provided `chunk_type`. void ReportFailedToParseChunk(int chunk_type); // Called when unknown chunks are received. May report an error. bool HandleUnrecognizedChunk(const SctpPacket::ChunkDescriptor& descriptor);
// Packets that failed to be sent, but should be retried.
PacketSender packet_sender_;
// The actual SendQueue implementation. As data can be sent on a socket before // the connection is established, this component is not in the TCB.
RRSendQueue send_queue_;
// Contains verification tag and initial TSN between having sent the INIT // until the connection is established (there is no TCB at this point).
ConnectParameters connect_params_; // The socket state.
State state_ = State::kClosed; // If the connection is established, contains a transmission control block.
std::unique_ptr<TransmissionControlBlock> tcb_;
};
} // namespace dcsctp
#endif// NET_DCSCTP_SOCKET_DCSCTP_SOCKET_H_
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.