Lines Matching +full:packet +full:- +full:verification
4 * Use of this source code is governed by a BSD-style license
26 #include "net/dcsctp/packet/chunk/abort_chunk.h"
27 #include "net/dcsctp/packet/chunk/chunk.h"
28 #include "net/dcsctp/packet/chunk/cookie_ack_chunk.h"
29 #include "net/dcsctp/packet/chunk/cookie_echo_chunk.h"
30 #include "net/dcsctp/packet/chunk/data_chunk.h"
31 #include "net/dcsctp/packet/chunk/data_common.h"
32 #include "net/dcsctp/packet/chunk/error_chunk.h"
33 #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h"
34 #include "net/dcsctp/packet/chunk/forward_tsn_common.h"
35 #include "net/dcsctp/packet/chunk/heartbeat_ack_chunk.h"
36 #include "net/dcsctp/packet/chunk/heartbeat_request_chunk.h"
37 #include "net/dcsctp/packet/chunk/idata_chunk.h"
38 #include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h"
39 #include "net/dcsctp/packet/chunk/init_ack_chunk.h"
40 #include "net/dcsctp/packet/chunk/init_chunk.h"
41 #include "net/dcsctp/packet/chunk/reconfig_chunk.h"
42 #include "net/dcsctp/packet/chunk/sack_chunk.h"
43 #include "net/dcsctp/packet/chunk/shutdown_ack_chunk.h"
44 #include "net/dcsctp/packet/chunk/shutdown_chunk.h"
45 #include "net/dcsctp/packet/chunk/shutdown_complete_chunk.h"
46 #include "net/dcsctp/packet/chunk_validators.h"
47 #include "net/dcsctp/packet/data.h"
48 #include "net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h"
49 #include "net/dcsctp/packet/error_cause/error_cause.h"
50 #include "net/dcsctp/packet/error_cause/no_user_data_cause.h"
51 #include "net/dcsctp/packet/error_cause/out_of_resource_error_cause.h"
52 #include "net/dcsctp/packet/error_cause/protocol_violation_cause.h"
53 #include "net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h"
54 #include "net/dcsctp/packet/error_cause/user_initiated_abort_cause.h"
55 #include "net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h"
56 #include "net/dcsctp/packet/parameter/parameter.h"
57 #include "net/dcsctp/packet/parameter/state_cookie_parameter.h"
58 #include "net/dcsctp/packet/parameter/supported_extensions_parameter.h"
59 #include "net/dcsctp/packet/sctp_packet.h"
60 #include "net/dcsctp/packet/tlv_trait.h"
85 // https://tools.ietf.org/html/rfc4960#section-5.1
89 // https://tools.ietf.org/html/rfc4960#section-3.3.2
106 supported_extensions->supports(ForwardTsnChunk::kType); in ComputeCapabilities()
112 supported_extensions->supports(IDataChunk::kType) && in ComputeCapabilities()
113 supported_extensions->supports(IForwardTsnChunk::kType); in ComputeCapabilities()
116 supported_extensions->supports(ReConfigChunk::kType)) { in ComputeCapabilities()
159 if (magic == "KAME-BSD") { in DeterminePeerImplementation()
179 "t1-init",
185 "t1-cookie",
191 "t2-shutdown",
210 if (tcb_ != nullptr && tcb_->reassembly_queue().HasMessages()) { in IsConsistent()
215 return (tcb_ == nullptr && !t1_init_->is_running() && in IsConsistent()
216 !t1_cookie_->is_running() && !t2_shutdown_->is_running()); in IsConsistent()
218 return (tcb_ == nullptr && t1_init_->is_running() && in IsConsistent()
219 !t1_cookie_->is_running() && !t2_shutdown_->is_running()); in IsConsistent()
221 return (tcb_ != nullptr && !t1_init_->is_running() && in IsConsistent()
222 t1_cookie_->is_running() && !t2_shutdown_->is_running() && in IsConsistent()
223 tcb_->has_cookie_echo_chunk()); in IsConsistent()
225 return (tcb_ != nullptr && !t1_init_->is_running() && in IsConsistent()
226 !t1_cookie_->is_running() && !t2_shutdown_->is_running()); in IsConsistent()
228 return (tcb_ != nullptr && !t1_init_->is_running() && in IsConsistent()
229 !t1_cookie_->is_running() && !t2_shutdown_->is_running()); in IsConsistent()
231 return (tcb_ != nullptr && !t1_init_->is_running() && in IsConsistent()
232 !t1_cookie_->is_running() && t2_shutdown_->is_running()); in IsConsistent()
234 return (tcb_ != nullptr && !t1_init_->is_running() && in IsConsistent()
235 !t1_cookie_->is_running() && !t2_shutdown_->is_running()); in IsConsistent()
237 return (tcb_ != nullptr && !t1_init_->is_running() && in IsConsistent()
238 !t1_cookie_->is_running() && t2_shutdown_->is_running()); in IsConsistent()
305 t1_init_->Start(); in Connect()
332 RTC_DLOG(LS_VERBOSE) << log_prefix() << "Created TCB: " << tcb_->ToString(); in CreateTransmissionControlBlock()
367 tcb_->RestoreFromState(state); in RestoreFromState()
382 // https://tools.ietf.org/html/rfc4960#section-9.2 in Shutdown()
384 // endpoint enters the SHUTDOWN-PENDING state and remains there until all in Shutdown()
392 t1_init_->Stop(); in Shutdown()
393 t1_cookie_->Stop(); in Shutdown()
412 SctpPacket::Builder b = tcb_->PacketBuilder(); in Close()
427 packet_sender_.Send(tcb_->PacketBuilder().Add(AbortChunk( in CloseConnectionBecauseOfTooManyTransmissionErrors()
436 t1_init_->Stop(); in InternalClose()
437 t1_cookie_->Stop(); in InternalClose()
438 t2_shutdown_->Stop(); in InternalClose()
487 // https://tools.ietf.org/html/rfc4960#section-9.2 in Send()
489 // if it is in the SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED, or in Send()
490 // SHUTDOWN-ACK-SENT state." in Send()
511 tcb_->SendBufferedPackets(now); in Send()
528 if (!tcb_->capabilities().reconfig) { in ResetStreams()
534 tcb_->stream_reset_handler().ResetStreams(outgoing_streams); in ResetStreams()
588 metrics.cwnd_bytes = tcb_->cwnd(); in GetMetrics()
589 metrics.srtt_ms = tcb_->current_srtt().value(); in GetMetrics()
591 options_.mtu - SctpPacket::kHeaderSize - DataChunk::kHeaderSize; in GetMetrics()
593 tcb_->retransmission_queue().outstanding_items() + in GetMetrics()
594 (send_queue_.total_buffered_amount() + packet_payload_size - 1) / in GetMetrics()
596 metrics.peer_rwnd_bytes = tcb_->retransmission_queue().rwnd(); in GetMetrics()
598 tcb_->capabilities().negotiated_maximum_incoming_streams; in GetMetrics()
600 tcb_->capabilities().negotiated_maximum_incoming_streams; in GetMetrics()
605 void DcSctpSocket::MaybeSendShutdownOnPacketReceived(const SctpPacket& packet) { in MaybeSendShutdownOnPacketReceived() argument
608 std::find_if(packet.descriptors().begin(), packet.descriptors().end(), in MaybeSendShutdownOnPacketReceived()
611 }) != packet.descriptors().end(); in MaybeSendShutdownOnPacketReceived()
613 // https://tools.ietf.org/html/rfc4960#section-9.2 in MaybeSendShutdownOnPacketReceived()
614 // "While in the SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in MaybeSendShutdownOnPacketReceived()
615 // respond to each received packet containing one or more DATA chunks with in MaybeSendShutdownOnPacketReceived()
616 // a SHUTDOWN chunk and restart the T2-shutdown timer."" in MaybeSendShutdownOnPacketReceived()
618 t2_shutdown_->set_duration(tcb_->current_rto()); in MaybeSendShutdownOnPacketReceived()
619 t2_shutdown_->Start(); in MaybeSendShutdownOnPacketReceived()
626 tcb_->stream_reset_handler().MakeStreamResetRequest(); in MaybeSendResetStreamsRequest()
628 SctpPacket::Builder builder = tcb_->PacketBuilder(); in MaybeSendResetStreamsRequest()
634 bool DcSctpSocket::ValidatePacket(const SctpPacket& packet) { in ValidatePacket() argument
635 const CommonHeader& header = packet.common_header(); in ValidatePacket()
637 tcb_ != nullptr ? tcb_->my_verification_tag() : VerificationTag(0); in ValidatePacket()
640 if (packet.descriptors().size() == 1 && in ValidatePacket()
641 packet.descriptors()[0].type == InitChunk::kType) { in ValidatePacket()
642 // https://tools.ietf.org/html/rfc4960#section-8.5.1 in ValidatePacket()
643 // "When an endpoint receives an SCTP packet with the Verification Tag in ValidatePacket()
644 // set to 0, it should verify that the packet contains only an INIT chunk. in ValidatePacket()
645 // Otherwise, the receiver MUST silently discard the packet."" in ValidatePacket()
655 if (packet.descriptors().size() == 1 && in ValidatePacket()
656 packet.descriptors()[0].type == AbortChunk::kType) { in ValidatePacket()
657 // https://tools.ietf.org/html/rfc4960#section-8.5.1 in ValidatePacket()
658 // "The receiver of an ABORT MUST accept the packet if the Verification in ValidatePacket()
659 // Tag field of the packet matches its own tag and the T bit is not set OR in ValidatePacket()
661 // Otherwise, the receiver MUST silently discard the packet and take no in ValidatePacket()
663 bool t_bit = (packet.descriptors()[0].flags & 0x01) != 0; in ValidatePacket()
665 // Can't verify the tag - assume it's okey. in ValidatePacket()
669 (t_bit && header.verification_tag == tcb_->peer_verification_tag())) { in ValidatePacket()
673 "ABORT chunk verification tag was wrong"); in ValidatePacket()
677 if (packet.descriptors()[0].type == InitAckChunk::kType) { in ValidatePacket()
684 "Packet has invalid verification tag: %08x, expected %08x", in ValidatePacket()
689 if (packet.descriptors()[0].type == CookieEchoChunk::kType) { in ValidatePacket()
694 if (packet.descriptors().size() == 1 && in ValidatePacket()
695 packet.descriptors()[0].type == ShutdownCompleteChunk::kType) { in ValidatePacket()
696 // https://tools.ietf.org/html/rfc4960#section-8.5.1 in ValidatePacket()
697 // "The receiver of a SHUTDOWN COMPLETE shall accept the packet if the in ValidatePacket()
698 // Verification Tag field of the packet matches its own tag and the T bit is in ValidatePacket()
700 // Chunk Flags. Otherwise, the receiver MUST silently discard the packet in ValidatePacket()
702 bool t_bit = (packet.descriptors()[0].flags & 0x01) != 0; in ValidatePacket()
704 // Can't verify the tag - assume it's okey. in ValidatePacket()
708 (t_bit && header.verification_tag == tcb_->peer_verification_tag())) { in ValidatePacket()
712 "SHUTDOWN_COMPLETE chunk verification tag was wrong"); in ValidatePacket()
716 // https://tools.ietf.org/html/rfc4960#section-8.5 in ValidatePacket()
717 // "When receiving an SCTP packet, the endpoint MUST ensure that the value in ValidatePacket()
718 // in the Verification Tag field of the received SCTP packet matches its own in ValidatePacket()
719 // tag. If the received Verification Tag value does not match the receiver's in ValidatePacket()
720 // own tag value, the receiver shall silently discard the packet and shall not in ValidatePacket()
729 "Packet has invalid verification tag: %08x, expected %08x", in ValidatePacket()
740 if (tcb_ != nullptr && tcb_->HasTooManyTxErrors()) { in HandleTimeout()
755 packet_observer_->OnReceivedPacket(callbacks_.TimeMillis(), data); in ReceivePacket()
758 absl::optional<SctpPacket> packet = in ReceivePacket() local
760 if (!packet.has_value()) { in ReceivePacket()
761 // https://tools.ietf.org/html/rfc4960#section-6.8 in ReceivePacket()
765 "Failed to parse received SCTP packet"); in ReceivePacket()
771 for (const auto& descriptor : packet->descriptors()) { in ReceivePacket()
777 if (!ValidatePacket(*packet)) { in ReceivePacket()
779 << "Packet failed verification tag check - dropping"; in ReceivePacket()
784 MaybeSendShutdownOnPacketReceived(*packet); in ReceivePacket()
786 for (const auto& descriptor : packet->descriptors()) { in ReceivePacket()
787 if (!Dispatch(packet->common_header(), descriptor)) { in ReceivePacket()
793 tcb_->data_tracker().ObservePacketEnd(); in ReceivePacket()
794 tcb_->MaybeSendSack(); in ReceivePacket()
801 auto packet = SctpPacket::Parse(payload); in DebugPrintOutgoing() local
802 RTC_DCHECK(packet.has_value()); in DebugPrintOutgoing()
804 for (const auto& desc : packet->descriptors()) { in DebugPrintOutgoing()
879 << static_cast<int>(descriptor.type) << " with report-error bit set"; in HandleUnrecognizedChunk()
885 // https://tools.ietf.org/html/rfc4960#section-3.2 in HandleUnrecognizedChunk()
889 // Need TCB - this chunk must be sent with a correct verification tag. in HandleUnrecognizedChunk()
890 packet_sender_.Send(tcb_->PacketBuilder().Add( in HandleUnrecognizedChunk()
898 // https://tools.ietf.org/html/rfc4960#section-3.2 in HandleUnrecognizedChunk()
899 // "Stop processing this SCTP packet and discard it, do not process any in HandleUnrecognizedChunk()
910 RTC_DLOG(LS_VERBOSE) << log_prefix() << "Timer " << t1_init_->name() in OnInitTimerExpiry()
911 << " has expired: " << t1_init_->expiration_count() in OnInitTimerExpiry()
912 << "/" << t1_init_->options().max_restarts.value_or(-1); in OnInitTimerExpiry()
915 if (t1_init_->is_running()) { in OnInitTimerExpiry()
925 // https://tools.ietf.org/html/rfc4960#section-4 in OnCookieTimerExpiry()
926 // "If the T1-cookie timer expires, the endpoint MUST retransmit COOKIE in OnCookieTimerExpiry()
927 // ECHO and restart the T1-cookie timer without changing state. This MUST in OnCookieTimerExpiry()
931 RTC_DLOG(LS_VERBOSE) << log_prefix() << "Timer " << t1_cookie_->name() in OnCookieTimerExpiry()
932 << " has expired: " << t1_cookie_->expiration_count() in OnCookieTimerExpiry()
934 << t1_cookie_->options().max_restarts.value_or(-1); in OnCookieTimerExpiry()
938 if (t1_cookie_->is_running()) { in OnCookieTimerExpiry()
939 tcb_->SendBufferedPackets(callbacks_.TimeMillis()); in OnCookieTimerExpiry()
949 RTC_DLOG(LS_VERBOSE) << log_prefix() << "Timer " << t2_shutdown_->name() in OnShutdownTimerExpiry()
950 << " has expired: " << t2_shutdown_->expiration_count() in OnShutdownTimerExpiry()
952 << t2_shutdown_->options().max_restarts.value_or(-1); in OnShutdownTimerExpiry()
954 if (!t2_shutdown_->is_running()) { in OnShutdownTimerExpiry()
955 // https://tools.ietf.org/html/rfc4960#section-9.2 in OnShutdownTimerExpiry()
960 packet_sender_.Send(tcb_->PacketBuilder().Add( in OnShutdownTimerExpiry()
971 // https://tools.ietf.org/html/rfc4960#section-9.2 in OnShutdownTimerExpiry()
976 return tcb_->current_rto(); in OnShutdownTimerExpiry()
979 void DcSctpSocket::OnSentPacket(rtc::ArrayView<const uint8_t> packet, in OnSentPacket() argument
981 // The packet observer is invoked even if the packet was failed to be sent, to in OnSentPacket()
984 packet_observer_->OnSentPacket(callbacks_.TimeMillis(), packet); in OnSentPacket()
989 DebugPrintOutgoing(packet); in OnSentPacket()
992 // The heartbeat interval timer is restarted for every sent packet, to in OnSentPacket()
995 tcb_->heartbeat_handler().RestartTimer(); in OnSentPacket()
1042 packet_sender_.Send(tcb_->PacketBuilder().Add( in HandleDataCommon()
1050 << tcb_->reassembly_queue().queued_bytes() in HandleDataCommon()
1052 << tcb_->reassembly_queue().watermark_bytes() in HandleDataCommon()
1053 << ", full=" << tcb_->reassembly_queue().is_full() in HandleDataCommon()
1055 << tcb_->reassembly_queue().is_above_watermark(); in HandleDataCommon()
1057 if (tcb_->reassembly_queue().is_full()) { in HandleDataCommon()
1059 // specification only allows dropping gap-ack-blocks, and that's not in HandleDataCommon()
1062 packet_sender_.Send(tcb_->PacketBuilder().Add(AbortChunk( in HandleDataCommon()
1069 if (tcb_->reassembly_queue().is_above_watermark()) { in HandleDataCommon()
1074 if (!tcb_->data_tracker().will_increase_cum_ack_tsn(tsn)) { in HandleDataCommon()
1077 tcb_->data_tracker().ForceImmediateSack(); in HandleDataCommon()
1082 if (!tcb_->data_tracker().IsTSNValid(tsn)) { in HandleDataCommon()
1088 if (tcb_->data_tracker().Observe(tsn, immediate_ack)) { in HandleDataCommon()
1089 tcb_->reassembly_queue().Add(tsn, std::move(data)); in HandleDataCommon()
1090 tcb_->reassembly_queue().MaybeResetStreamsDeferred( in HandleDataCommon()
1091 tcb_->data_tracker().last_cumulative_acked_tsn()); in HandleDataCommon()
1103 if (chunk->initiate_tag() == VerificationTag(0) || in HandleInit()
1104 chunk->nbr_outbound_streams() == 0 || chunk->nbr_inbound_streams() == 0) { in HandleInit()
1105 // https://tools.ietf.org/html/rfc4960#section-3.3.2 in HandleInit()
1128 // https://tools.ietf.org/html/rfc4960#section-9.2 in HandleInit()
1129 // "If an endpoint is in the SHUTDOWN-ACK-SENT state and receives an in HandleInit()
1147 // https://tools.ietf.org/html/rfc4960#section-5.2.1 in HandleInit()
1151 // COOKIE-WAIT state, an endpoint MUST respond with an INIT ACK using the in HandleInit()
1160 // https://tools.ietf.org/html/rfc4960#section-5.2.2 in HandleInit()
1161 // "The outbound SCTP packet containing this INIT ACK MUST carry a in HandleInit()
1162 // Verification Tag value equal to the Initiate Tag found in the in HandleInit()
1170 // Create a new verification tag - different from the previous one. in HandleInit()
1174 if (connect_params_.verification_tag != tcb_->my_verification_tag()) { in HandleInit()
1182 TSN(*tcb_->retransmission_queue().next_tsn() + 1000000); in HandleInit()
1183 tie_tag = tcb_->tie_tag(); in HandleInit()
1193 *chunk->initiate_tag(), *chunk->initial_tsn()); in HandleInit()
1196 ComputeCapabilities(options_, chunk->nbr_outbound_streams(), in HandleInit()
1197 chunk->nbr_inbound_streams(), chunk->parameters()); in HandleInit()
1199 SctpPacket::Builder b(chunk->initiate_tag(), options_); in HandleInit()
1202 StateCookie(chunk->initiate_tag(), chunk->initial_tsn(), in HandleInit()
1203 chunk->a_rwnd(), tie_tag, capabilities) in HandleInit()
1225 // https://tools.ietf.org/html/rfc4960#section-5.2.3 in HandleInitAck()
1227 // the COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk." in HandleInitAck()
1233 auto cookie = chunk->parameters().get<StateCookieParameter>(); in HandleInitAck()
1240 .Add(ProtocolViolationCause("INIT-ACK malformed")) in HandleInitAck()
1247 ComputeCapabilities(options_, chunk->nbr_outbound_streams(), in HandleInitAck()
1248 chunk->nbr_inbound_streams(), chunk->parameters()); in HandleInitAck()
1249 t1_init_->Stop(); in HandleInitAck()
1251 metrics_.peer_implementation = DeterminePeerImplementation(cookie->data()); in HandleInitAck()
1253 // If the connection is re-established (peer restarted, but re-used old in HandleInitAck()
1255 // partly sent message is re-sent in full. The same is true when the socket in HandleInitAck()
1256 // is closed and later re-opened, which never happens in WebRTC, but is a in HandleInitAck()
1258 // send queue is already re-configured, and shouldn't be reset. in HandleInitAck()
1263 chunk->initiate_tag(), chunk->initial_tsn(), in HandleInitAck()
1264 chunk->a_rwnd(), MakeTieTag(callbacks_)); in HandleInitAck()
1269 tcb_->SetCookieEchoChunk(CookieEchoChunk(cookie->data())); in HandleInitAck()
1270 tcb_->SendBufferedPackets(callbacks_.TimeMillis()); in HandleInitAck()
1271 t1_cookie_->Start(); in HandleInitAck()
1284 StateCookie::Deserialize(chunk->cookie()); in HandleCookieEcho()
1299 "Received CookieEcho with invalid verification tag: %08x, " in HandleCookieEcho()
1307 t1_init_->Stop(); in HandleCookieEcho()
1308 t1_cookie_->Stop(); in HandleCookieEcho()
1311 tcb_->ClearCookieEchoChunk(); in HandleCookieEcho()
1318 // If the connection is re-established (peer restarted, but re-used old in HandleCookieEcho()
1320 // partly sent message is re-sent in full. The same is true when the socket in HandleCookieEcho()
1321 // is closed and later re-opened, which never happens in WebRTC, but is a in HandleCookieEcho()
1323 // send queue is already re-configured, and shouldn't be reset. in HandleCookieEcho()
1327 cookie->capabilities(), connect_params_.verification_tag, in HandleCookieEcho()
1328 connect_params_.initial_tsn, cookie->initiate_tag(), in HandleCookieEcho()
1329 cookie->initial_tsn(), cookie->a_rwnd(), MakeTieTag(callbacks_)); in HandleCookieEcho()
1332 SctpPacket::Builder b = tcb_->PacketBuilder(); in HandleCookieEcho()
1335 // https://tools.ietf.org/html/rfc4960#section-5.1 in HandleCookieEcho()
1338 // packet." in HandleCookieEcho()
1339 tcb_->SendBufferedPackets(b, callbacks_.TimeMillis()); in HandleCookieEcho()
1346 << *tcb_->my_verification_tag() in HandleCookieEchoWithTCB()
1348 << ", tcb_tag=" << *tcb_->peer_verification_tag() in HandleCookieEchoWithTCB()
1350 << ", local_tie_tag=" << *tcb_->tie_tag() in HandleCookieEchoWithTCB()
1352 // https://tools.ietf.org/html/rfc4960#section-5.2.4 in HandleCookieEchoWithTCB()
1354 if (header.verification_tag != tcb_->my_verification_tag() && in HandleCookieEchoWithTCB()
1355 tcb_->peer_verification_tag() != cookie.initiate_tag() && in HandleCookieEchoWithTCB()
1356 cookie.tie_tag() == tcb_->tie_tag()) { in HandleCookieEchoWithTCB()
1359 // "If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in HandleCookieEchoWithTCB()
1370 "Received COOKIE-ECHO while shutting down"); in HandleCookieEchoWithTCB()
1375 << "Received COOKIE-ECHO indicating a restarted peer"; in HandleCookieEchoWithTCB()
1379 } else if (header.verification_tag == tcb_->my_verification_tag() && in HandleCookieEchoWithTCB()
1380 tcb_->peer_verification_tag() != cookie.initiate_tag()) { in HandleCookieEchoWithTCB()
1387 << "Received COOKIE-ECHO indicating simultaneous connections"; in HandleCookieEchoWithTCB()
1389 } else if (header.verification_tag != tcb_->my_verification_tag() && in HandleCookieEchoWithTCB()
1390 tcb_->peer_verification_tag() == cookie.initiate_tag() && in HandleCookieEchoWithTCB()
1400 << "Received COOKIE-ECHO indicating a late COOKIE-ECHO. Discarding"; in HandleCookieEchoWithTCB()
1402 } else if (header.verification_tag == tcb_->my_verification_tag() && in HandleCookieEchoWithTCB()
1403 tcb_->peer_verification_tag() == cookie.initiate_tag()) { in HandleCookieEchoWithTCB()
1405 // the ESTABLISHED state, if it is in the COOKIE-ECHOED state. It in HandleCookieEchoWithTCB()
1410 << "Received duplicate COOKIE-ECHO, probably because of peer not " in HandleCookieEchoWithTCB()
1411 "receiving COOKIE-ACK and retransmitting COOKIE-ECHO. Continuing."; in HandleCookieEchoWithTCB()
1425 // https://tools.ietf.org/html/rfc4960#section-5.2.5 in HandleCookieAck()
1426 // "At any state other than COOKIE-ECHOED, an endpoint should silently in HandleCookieAck()
1434 t1_cookie_->Stop(); in HandleCookieAck()
1435 tcb_->ClearCookieEchoChunk(); in HandleCookieAck()
1437 tcb_->SendBufferedPackets(callbacks_.TimeMillis()); in HandleCookieAck()
1442 if (tcb_->reassembly_queue().HasMessages()) { in DeliverReassembledMessages()
1443 for (auto& message : tcb_->reassembly_queue().FlushMessages()) { in DeliverReassembledMessages()
1458 if (tcb_->retransmission_queue().HandleSack(now, sack)) { in HandleSack()
1461 // https://datatracker.ietf.org/doc/html/rfc4960#section-7.2.4 in HandleSack()
1463 // marked for retransmission will fit into a single packet, subject to in HandleSack()
1465 // which the packet is being sent. Call this value K. Retransmit those K in HandleSack()
1466 // DATA chunks in a single packet. When a Fast Retransmit is being in HandleSack()
1468 // delay retransmission for this single packet." in HandleSack()
1469 tcb_->MaybeSendFastRetransmit(); in HandleSack()
1472 // cwnd?) or indicate packet loss that may result in sending FORWARD-TSN. in HandleSack()
1473 tcb_->SendBufferedPackets(now); in HandleSack()
1476 << "Dropping out-of-order SACK with TSN " in HandleSack()
1489 tcb_->heartbeat_handler().HandleHeartbeatRequest(*std::move(chunk)); in HandleHeartbeatRequest()
1500 tcb_->heartbeat_handler().HandleHeartbeatAck(*std::move(chunk)); in HandleHeartbeatAck()
1508 std::string error_string = ErrorCausesToString(chunk->error_causes()); in HandleAbort()
1510 // https://tools.ietf.org/html/rfc4960#section-3.3.7 in HandleAbort()
1519 << ") - closing connection."; in HandleAbort()
1528 std::string error_string = ErrorCausesToString(chunk->error_causes()); in HandleError()
1547 tcb_->stream_reset_handler().HandleReConfig(*std::move(chunk)); in HandleReconfig()
1553 // If a response was processed, pending to-be-reset streams may now have in HandleReconfig()
1555 tcb_->SendBufferedPackets(now); in HandleReconfig()
1569 // https://tools.ietf.org/html/rfc4960#section-9.2 in HandleShutdown()
1570 // "If a SHUTDOWN is received in the COOKIE-WAIT or COOKIE ECHOED state, in HandleShutdown()
1573 // https://tools.ietf.org/html/rfc4960#section-9.2 in HandleShutdown()
1574 // "If an endpoint is in the SHUTDOWN-SENT state and receives a in HandleShutdown()
1576 // with a SHUTDOWN ACK to its peer, and move into the SHUTDOWN-ACK-SENT in HandleShutdown()
1577 // state restarting its T2-shutdown timer." in HandleShutdown()
1586 << "Received SHUTDOWN - shutting down the socket"; in HandleShutdown()
1587 // https://tools.ietf.org/html/rfc4960#section-9.2 in HandleShutdown()
1589 // SHUTDOWN-RECEIVED state, stop accepting new data from its SCTP user, in HandleShutdown()
1606 // https://tools.ietf.org/html/rfc4960#section-9.2 in HandleShutdownAck()
1608 // the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its peer, and in HandleShutdownAck()
1611 // "If an endpoint is in the SHUTDOWN-ACK-SENT state and receives a in HandleShutdownAck()
1612 // SHUTDOWN ACK, it shall stop the T2-shutdown timer, send a SHUTDOWN in HandleShutdownAck()
1615 SctpPacket::Builder b = tcb_->PacketBuilder(); in HandleShutdownAck()
1620 // https://tools.ietf.org/html/rfc4960#section-8.5.1 in HandleShutdownAck()
1621 // "If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state in HandleShutdownAck()
1623 // should be treated as an Out Of The Blue packet." in HandleShutdownAck()
1625 // https://tools.ietf.org/html/rfc4960#section-8.4 in HandleShutdownAck()
1626 // "If the packet contains a SHUTDOWN ACK chunk, the receiver in HandleShutdownAck()
1627 // should respond to the sender of the OOTB packet with a SHUTDOWN in HandleShutdownAck()
1629 // packet must fill in the Verification Tag field of the outbound packet in HandleShutdownAck()
1630 // with the Verification Tag received in the SHUTDOWN ACK and set the T in HandleShutdownAck()
1631 // bit in the Chunk Flags to indicate that the Verification Tag is in HandleShutdownAck()
1648 // https://tools.ietf.org/html/rfc4960#section-9.2 in HandleShutdownComplete()
1650 // verify that it is in the SHUTDOWN-ACK-SENT state; if it is not, the in HandleShutdownComplete()
1651 // chunk should be discarded. If the endpoint is in the SHUTDOWN-ACK-SENT in HandleShutdownComplete()
1652 // state, the endpoint should stop the T2-shutdown timer and remove all in HandleShutdownComplete()
1680 if (!tcb_->capabilities().partial_reliability) { in HandleForwardTsnCommon()
1681 SctpPacket::Builder b = tcb_->PacketBuilder(); in HandleForwardTsnCommon()
1685 "I-FORWARD-TSN received, but not indicated " in HandleForwardTsnCommon()
1694 tcb_->data_tracker().HandleForwardTsn(chunk.new_cumulative_tsn()); in HandleForwardTsnCommon()
1695 tcb_->reassembly_queue().Handle(chunk); in HandleForwardTsnCommon()
1696 // A forward TSN - for ordered streams - may allow messages to be in HandleForwardTsnCommon()
1701 tcb_->MaybeSendSack(); in HandleForwardTsnCommon()
1705 if (tcb_->retransmission_queue().outstanding_bytes() != 0) { in MaybeSendShutdownOrAck()
1710 // https://tools.ietf.org/html/rfc4960#section-9.2 in MaybeSendShutdownOrAck()
1714 // shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT in MaybeSendShutdownOrAck()
1718 t2_shutdown_->set_duration(tcb_->current_rto()); in MaybeSendShutdownOrAck()
1719 t2_shutdown_->Start(); in MaybeSendShutdownOrAck()
1722 // https://tools.ietf.org/html/rfc4960#section-9.2 in MaybeSendShutdownOrAck()
1725 // T2-shutdown timer of its own, entering the SHUTDOWN-ACK-SENT state. If in MaybeSendShutdownOrAck()
1734 SctpPacket::Builder b = tcb_->PacketBuilder(); in SendShutdown()
1735 b.Add(ShutdownChunk(tcb_->data_tracker().last_cumulative_acked_tsn())); in SendShutdown()
1740 packet_sender_.Send(tcb_->PacketBuilder().Add(ShutdownAckChunk())); in SendShutdownAck()
1741 t2_shutdown_->set_duration(tcb_->current_rto()); in SendShutdownAck()
1742 t2_shutdown_->Start(); in SendShutdownAck()
1753 status.Add(tcb_->GetHandoverReadiness()); in GetHandoverReadiness()
1773 tcb_->AddHandoverState(state); in GetHandoverStateAndClose()