Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(s2n-quic-dc): add map events #2362

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dc/s2n-quic-dc/events/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

struct ConnectionMeta {
id: u64,
}

struct EndpointMeta {}

struct ConnectionInfo {}
12 changes: 9 additions & 3 deletions dc/s2n-quic-dc/events/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
#[event("application:write")]
pub struct ApplicationWrite {
/// The number of bytes that the application tried to write
len: usize,
total_len: usize,

/// The amount that was written
write_len: usize,
}

#[event("application:write")]
#[event("application:read")]
pub struct ApplicationRead {
/// The number of bytes that the application tried to read
len: usize,
capacity: usize,

/// The amount that was read
read_len: usize,
}
194 changes: 194 additions & 0 deletions dc/s2n-quic-dc/events/map.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#[event("path_secret_map:initialized")]
#[subject(endpoint)]
struct PathSecretMapInitialized {
/// The capacity of the path secret map
capacity: usize,
}

#[event("path_secret_map:uninitialized")]
#[subject(endpoint)]
struct PathSecretMapUninitialized {
/// The capacity of the path secret map
capacity: usize,

/// The number of entries in the map
entries: usize,
}

#[event("path_secret_map:background_handshake_requested")]
#[subject(endpoint)]
/// Emitted when a background handshake is requested
struct PathSecretMapBackgroundHandshakeRequested<'a> {
peer_address: SocketAddress<'a>,
}

#[event("path_secret_map:entry_replaced")]
#[subject(endpoint)]
/// Emitted when the entry is inserted into the path secret map
struct PathSecretMapEntryInserted<'a> {
peer_address: SocketAddress<'a>,

credential_id: &'a [u8],
}

#[event("path_secret_map:entry_replaced")]
#[subject(endpoint)]
/// Emitted when the entry is considered ready for use
struct PathSecretMapEntryReady<'a> {
peer_address: SocketAddress<'a>,

credential_id: &'a [u8],
}

#[event("path_secret_map:entry_replaced")]
#[subject(endpoint)]
/// Emitted when an entry is replaced by a new one for the same `peer_address`
struct PathSecretMapEntryReplaced<'a> {
peer_address: SocketAddress<'a>,

new_credential_id: &'a [u8],

previous_credential_id: &'a [u8],
}

#[event("path_secret_map:unknown_path_secret_packet_sent")]
#[subject(endpoint)]
/// Emitted when an UnknownPathSecret packet was sent
struct UnknownPathSecretPacketSent<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:unknown_path_secret_packet_received")]
#[subject(endpoint)]
/// Emitted when an UnknownPathSecret packet was received
struct UnknownPathSecretPacketReceived<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:unknown_path_secret_packet_accepted")]
#[subject(endpoint)]
/// Emitted when an UnknownPathSecret packet was authentic and processed
struct UnknownPathSecretPacketAccepted<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:unknown_path_secret_packet_rejected")]
#[subject(endpoint)]
/// Emitted when an UnknownPathSecret packet was rejected as invalid
struct UnknownPathSecretPacketRejected<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:unknown_path_secret_packet_dropped")]
#[subject(endpoint)]
/// Emitted when an UnknownPathSecret packet was dropped due to a missing entry
struct UnknownPathSecretPacketDropped<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:replay_definitely_detected")]
#[subject(endpoint)]
/// Emitted when credential replay was definitely detected
struct ReplayDefinitelyDetected<'a> {
credential_id: &'a [u8],
key_id: u64,
}

#[event("path_secret_map:replay_potentially_detected")]
#[subject(endpoint)]
/// Emitted when credential replay was potentially detected, but could not be verified
/// due to a limiting tracking window
struct ReplayPotentiallyDetected<'a> {
credential_id: &'a [u8],
key_id: u64,
gap: u64,
}

#[event("path_secret_map:replay_detected_packet_sent")]
#[subject(endpoint)]
/// Emitted when an ReplayDetected packet was sent
struct ReplayDetectedPacketSent<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:replay_detected_packet_received")]
#[subject(endpoint)]
/// Emitted when an ReplayDetected packet was received
struct ReplayDetectedPacketReceived<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:replay_detected_packet_accepted")]
#[subject(endpoint)]
/// Emitted when an StaleKey packet was authentic and processed
struct ReplayDetectedPacketAccepted<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
key_id: u64,
}

#[event("path_secret_map:replay_detected_packet_rejected")]
#[subject(endpoint)]
/// Emitted when an ReplayDetected packet was rejected as invalid
struct ReplayDetectedPacketRejected<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:replay_detected_packet_dropped")]
#[subject(endpoint)]
/// Emitted when an ReplayDetected packet was dropped due to a missing entry
struct ReplayDetectedPacketDropped<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:stale_key_packet_sent")]
#[subject(endpoint)]
/// Emitted when an StaleKey packet was sent
struct StaleKeyPacketSent<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:stale_key_packet_received")]
#[subject(endpoint)]
/// Emitted when an StaleKey packet was received
struct StaleKeyPacketReceived<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:stale_key_packet_accepted")]
#[subject(endpoint)]
/// Emitted when an StaleKey packet was authentic and processed
struct StaleKeyPacketAccepted<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:stale_key_packet_rejected")]
#[subject(endpoint)]
/// Emitted when an StaleKey packet was rejected as invalid
struct StaleKeyPacketRejected<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}

#[event("path_secret_map:stale_key_packet_dropped")]
#[subject(endpoint)]
/// Emitted when an StaleKey packet was dropped due to a missing entry
struct StaleKeyPacketDropped<'a> {
peer_address: SocketAddress<'a>,
credential_id: &'a [u8],
}
22 changes: 21 additions & 1 deletion dc/s2n-quic-dc/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@
#[cfg(any(test, feature = "testing"))]
use s2n_quic_core::event::snapshot;

pub use s2n_quic_core::event::{Event, IntoEvent, Timestamp};
pub use s2n_quic_core::event::{Event, IntoEvent};

/// Provides metadata related to an event
pub trait Meta: core::fmt::Debug {
/// A context from which the event is being emitted
///
/// An event can occur in the context of an Endpoint or Connection
fn subject(&self) -> api::Subject;
}

impl Meta for api::ConnectionMeta {
fn subject(&self) -> api::Subject {
builder::Subject::Connection { id: self.id }.into_event()
}
}

impl Meta for api::EndpointMeta {
fn subject(&self) -> api::Subject {
builder::Subject::Endpoint {}.into_event()
}
}

mod generated;
pub use generated::*;
Loading
Loading