const MAX_READ_SIZE: usize = 2048; // Given a practical MTU of 1500 bytes, this seems reasonable.
pubtrait FrameDecoder<T> { /// Fuzzing corpus name for this frame type. If `Some`, decoded frames will be /// written to the fuzzing corpus with this name. #[cfg(feature = "build-fuzzing-corpus")] const FUZZING_CORPUS: Option<&'static str> = None;
fn is_known_type(frame_type: HFrameType) -> bool;
/// # Errors /// /// Returns `HttpFrameUnexpected` if frames is not allowed, i.e. is a `H3_RESERVED_FRAME_TYPES`. fn frame_type_allowed(_frame_type: HFrameType) -> Res<()> {
Ok(())
}
/// # Errors /// /// If a frame cannot be properly decoded. fn decode(frame_type: HFrameType, frame_len: u64, data: Option<&[u8]>) -> Res<Option<T>>;
}
#[expect(clippy::module_name_repetitions, reason = "This is OK.")] pubtrait StreamReader { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. /// Return an error if the stream was closed on the transport layer, but that information is not /// yet consumed on the http/3 layer. fn read_data(&mutself, buf: &mut [u8], now: Instant) -> Res<(usize, bool)>;
}
impl StreamReader for StreamReaderConnectionWrapper<'_> { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. fn read_data(&mutself, buf: &mut [u8], _now: Instant) -> Res<(usize, bool)> { let res = self.conn.stream_recv(self.stream_id, buf)?;
Ok(res)
}
}
impl StreamReader for StreamReaderRecvStreamWrapper<'_> { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. fn read_data(&mutself, buf: &mut [u8], now: Instant) -> Res<(usize, bool)> { self.recv_stream.read_data(self.conn, buf, now)
}
}
let res = T::decode(self.frame_type, self.frame_len, Some(data))?; self.reset();
Ok(res)
}
#[cfg(feature = "build-fuzzing-corpus")] /// Write `HFrame` data to indicated fuzzing corpus. /// /// The output consists of the varint-encoded frame type and length, followed by the optional /// payload data. fn write_item_to_fuzzing_corpus(&self, corpus: &str, data: Option<&[u8]>) { // We need to include the frame type and length varints before the data // to create a complete frame that the fuzzer can process. letmut encoder = neqo_common::Encoder::default();
encoder.encode_varint(self.frame_type.0);
encoder.encode_varint(self.frame_len); iflet Some(d) = data {
encoder.encode(d);
}
neqo_common::write_item_to_fuzzing_corpus(corpus, encoder.as_ref());
}
}
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.