Skip to content

Commit 99a18b1

Browse files
committed
fix no-std
1 parent f304cc3 commit 99a18b1

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

quic/s2n-quic-core/src/packet/handshake.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use crate::{
2222
transport,
2323
varint::VarInt,
2424
};
25+
#[cfg(feature = "alloc")]
26+
use alloc::vec::Vec;
2527
use s2n_codec::{CheckedRange, DecoderBufferMut, DecoderBufferMutResult, Encoder, EncoderValue};
2628

2729
//= https://www.rfc-editor.org/rfc/rfc9000#section-17.2.4
@@ -65,6 +67,7 @@ pub type EncryptedHandshake<'a> =
6567
pub type CleartextHandshake<'a> = Handshake<&'a [u8], &'a [u8], PacketNumber, DecoderBufferMut<'a>>;
6668

6769
impl<'a> ProtectedHandshake<'a> {
70+
#[cfg(feature = "alloc")]
6871
pub fn get_wire_bytes(&self) -> Vec<u8> {
6972
self.payload.buffer.encode_to_vec()
7073
}

quic/s2n-quic-core/src/packet/short.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use crate::{
1616
},
1717
transport,
1818
};
19+
#[cfg(feature = "alloc")]
20+
use alloc::vec::Vec;
1921
use s2n_codec::{CheckedRange, DecoderBufferMut, DecoderBufferMutResult, Encoder, EncoderValue};
2022

2123
//= https://www.rfc-editor.org/rfc/rfc9000#section-17.3.1
@@ -194,7 +196,7 @@ impl<'a> ProtectedShort<'a> {
194196
.get_checked_range(&self.destination_connection_id)
195197
.into_less_safe_slice()
196198
}
197-
199+
#[cfg(feature = "alloc")]
198200
pub fn get_wire_bytes(&self) -> Vec<u8> {
199201
self.payload.buffer.encode_to_vec()
200202
}

quic/s2n-quic-transport/src/connection/connection_impl.rs

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ impl<Config: endpoint::Config> ConnectionImpl<Config> {
379379
connection_id_validator,
380380
)?;
381381
}
382-
()
383382
}
384383
}
385384

@@ -1599,42 +1598,39 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
15991598

16001599
// notify the connection a packet was processed
16011600
self.on_processed_packet(&processed_packet, subscriber)?;
1602-
} else {
1603-
if (self.stored_packet_type.is_none()
1604-
|| self.stored_packet_type == Some(PacketNumberSpace::Handshake))
1605-
&& !self.space_manager.is_handshake_confirmed()
1606-
{
1607-
//= https://www.rfc-editor.org/rfc/rfc9001#section-4.1.4
1608-
//# However, a TLS implementation could perform some of its processing
1609-
//# asynchronously. In particular, the process of validating a
1610-
//# certificate can take some time. While waiting for TLS processing to
1611-
//# complete, an endpoint SHOULD buffer received packets if they might be
1612-
//# processed using keys that are not yet available. These packets can
1613-
//# be processed once keys are provided by TLS. An endpoint SHOULD
1614-
//# continue to respond to packets that can be processed during this
1615-
//# time.
1616-
1617-
// https://www.rfc-editor.org/rfc/rfc9000#section-5.2.1
1618-
//# Due to packet reordering or loss, a client might receive packets
1619-
//# for a connection that are encrypted with a key it has not yet computed.
1620-
//# The client MAY drop these packets, or it MAY buffer them in anticipation
1621-
//# of later packets that allow it to compute the key.
1622-
1623-
let packet_bytes = packet.get_wire_bytes();
1624-
if packet_bytes.len() + self.packet_storage.len() < self.limits.stored_packet_size()
1625-
{
1626-
self.packet_storage.extend(packet_bytes);
1627-
self.stored_packet_type = Some(PacketNumberSpace::Handshake)
1628-
}
1629-
} else {
1630-
let path = &self.path_manager[path_id];
1631-
publisher.on_packet_dropped(event::builder::PacketDropped {
1632-
reason: event::builder::PacketDropReason::PacketSpaceDoesNotExist {
1633-
path: path_event!(path, path_id),
1634-
packet_type: event::builder::PacketType::Handshake,
1635-
},
1636-
});
1601+
} else if (self.stored_packet_type.is_none()
1602+
|| self.stored_packet_type == Some(PacketNumberSpace::Handshake))
1603+
&& !self.space_manager.is_handshake_confirmed()
1604+
{
1605+
//= https://www.rfc-editor.org/rfc/rfc9001#section-4.1.4
1606+
//# However, a TLS implementation could perform some of its processing
1607+
//# asynchronously. In particular, the process of validating a
1608+
//# certificate can take some time. While waiting for TLS processing to
1609+
//# complete, an endpoint SHOULD buffer received packets if they might be
1610+
//# processed using keys that are not yet available. These packets can
1611+
//# be processed once keys are provided by TLS. An endpoint SHOULD
1612+
//# continue to respond to packets that can be processed during this
1613+
//# time.
1614+
1615+
// https://www.rfc-editor.org/rfc/rfc9000#section-5.2.1
1616+
//# Due to packet reordering or loss, a client might receive packets
1617+
//# for a connection that are encrypted with a key it has not yet computed.
1618+
//# The client MAY drop these packets, or it MAY buffer them in anticipation
1619+
//# of later packets that allow it to compute the key.
1620+
1621+
let packet_bytes = packet.get_wire_bytes();
1622+
if packet_bytes.len() + self.packet_storage.len() < self.limits.stored_packet_size() {
1623+
self.packet_storage.extend(packet_bytes);
1624+
self.stored_packet_type = Some(PacketNumberSpace::Handshake)
16371625
}
1626+
} else {
1627+
let path = &self.path_manager[path_id];
1628+
publisher.on_packet_dropped(event::builder::PacketDropped {
1629+
reason: event::builder::PacketDropReason::PacketSpaceDoesNotExist {
1630+
path: path_event!(path, path_id),
1631+
packet_type: event::builder::PacketType::Handshake,
1632+
},
1633+
});
16381634
}
16391635

16401636
Ok(())

0 commit comments

Comments
 (0)