Skip to content

Commit fcdb914

Browse files
authored
feat(s2n-quic-dc): add map events (#2362)
1 parent fad92d2 commit fcdb914

File tree

18 files changed

+3617
-612
lines changed

18 files changed

+3617
-612
lines changed

dc/s2n-quic-dc/events/common.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
struct ConnectionMeta {
5+
id: u64,
6+
}
7+
8+
struct EndpointMeta {}
9+
10+
struct ConnectionInfo {}

dc/s2n-quic-dc/events/connection.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
#[event("application:write")]
55
pub struct ApplicationWrite {
66
/// The number of bytes that the application tried to write
7-
len: usize,
7+
total_len: usize,
8+
9+
/// The amount that was written
10+
write_len: usize,
811
}
912

10-
#[event("application:write")]
13+
#[event("application:read")]
1114
pub struct ApplicationRead {
1215
/// The number of bytes that the application tried to read
13-
len: usize,
16+
capacity: usize,
17+
18+
/// The amount that was read
19+
read_len: usize,
1420
}

dc/s2n-quic-dc/events/map.rs

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#[event("path_secret_map:initialized")]
5+
#[subject(endpoint)]
6+
struct PathSecretMapInitialized {
7+
/// The capacity of the path secret map
8+
capacity: usize,
9+
}
10+
11+
#[event("path_secret_map:uninitialized")]
12+
#[subject(endpoint)]
13+
struct PathSecretMapUninitialized {
14+
/// The capacity of the path secret map
15+
capacity: usize,
16+
17+
/// The number of entries in the map
18+
entries: usize,
19+
}
20+
21+
#[event("path_secret_map:background_handshake_requested")]
22+
#[subject(endpoint)]
23+
/// Emitted when a background handshake is requested
24+
struct PathSecretMapBackgroundHandshakeRequested<'a> {
25+
peer_address: SocketAddress<'a>,
26+
}
27+
28+
#[event("path_secret_map:entry_replaced")]
29+
#[subject(endpoint)]
30+
/// Emitted when the entry is inserted into the path secret map
31+
struct PathSecretMapEntryInserted<'a> {
32+
peer_address: SocketAddress<'a>,
33+
34+
credential_id: &'a [u8],
35+
}
36+
37+
#[event("path_secret_map:entry_replaced")]
38+
#[subject(endpoint)]
39+
/// Emitted when the entry is considered ready for use
40+
struct PathSecretMapEntryReady<'a> {
41+
peer_address: SocketAddress<'a>,
42+
43+
credential_id: &'a [u8],
44+
}
45+
46+
#[event("path_secret_map:entry_replaced")]
47+
#[subject(endpoint)]
48+
/// Emitted when an entry is replaced by a new one for the same `peer_address`
49+
struct PathSecretMapEntryReplaced<'a> {
50+
peer_address: SocketAddress<'a>,
51+
52+
new_credential_id: &'a [u8],
53+
54+
previous_credential_id: &'a [u8],
55+
}
56+
57+
#[event("path_secret_map:unknown_path_secret_packet_sent")]
58+
#[subject(endpoint)]
59+
/// Emitted when an UnknownPathSecret packet was sent
60+
struct UnknownPathSecretPacketSent<'a> {
61+
peer_address: SocketAddress<'a>,
62+
credential_id: &'a [u8],
63+
}
64+
65+
#[event("path_secret_map:unknown_path_secret_packet_received")]
66+
#[subject(endpoint)]
67+
/// Emitted when an UnknownPathSecret packet was received
68+
struct UnknownPathSecretPacketReceived<'a> {
69+
peer_address: SocketAddress<'a>,
70+
credential_id: &'a [u8],
71+
}
72+
73+
#[event("path_secret_map:unknown_path_secret_packet_accepted")]
74+
#[subject(endpoint)]
75+
/// Emitted when an UnknownPathSecret packet was authentic and processed
76+
struct UnknownPathSecretPacketAccepted<'a> {
77+
peer_address: SocketAddress<'a>,
78+
credential_id: &'a [u8],
79+
}
80+
81+
#[event("path_secret_map:unknown_path_secret_packet_rejected")]
82+
#[subject(endpoint)]
83+
/// Emitted when an UnknownPathSecret packet was rejected as invalid
84+
struct UnknownPathSecretPacketRejected<'a> {
85+
peer_address: SocketAddress<'a>,
86+
credential_id: &'a [u8],
87+
}
88+
89+
#[event("path_secret_map:unknown_path_secret_packet_dropped")]
90+
#[subject(endpoint)]
91+
/// Emitted when an UnknownPathSecret packet was dropped due to a missing entry
92+
struct UnknownPathSecretPacketDropped<'a> {
93+
peer_address: SocketAddress<'a>,
94+
credential_id: &'a [u8],
95+
}
96+
97+
#[event("path_secret_map:replay_definitely_detected")]
98+
#[subject(endpoint)]
99+
/// Emitted when credential replay was definitely detected
100+
struct ReplayDefinitelyDetected<'a> {
101+
credential_id: &'a [u8],
102+
key_id: u64,
103+
}
104+
105+
#[event("path_secret_map:replay_potentially_detected")]
106+
#[subject(endpoint)]
107+
/// Emitted when credential replay was potentially detected, but could not be verified
108+
/// due to a limiting tracking window
109+
struct ReplayPotentiallyDetected<'a> {
110+
credential_id: &'a [u8],
111+
key_id: u64,
112+
gap: u64,
113+
}
114+
115+
#[event("path_secret_map:replay_detected_packet_sent")]
116+
#[subject(endpoint)]
117+
/// Emitted when an ReplayDetected packet was sent
118+
struct ReplayDetectedPacketSent<'a> {
119+
peer_address: SocketAddress<'a>,
120+
credential_id: &'a [u8],
121+
}
122+
123+
#[event("path_secret_map:replay_detected_packet_received")]
124+
#[subject(endpoint)]
125+
/// Emitted when an ReplayDetected packet was received
126+
struct ReplayDetectedPacketReceived<'a> {
127+
peer_address: SocketAddress<'a>,
128+
credential_id: &'a [u8],
129+
}
130+
131+
#[event("path_secret_map:replay_detected_packet_accepted")]
132+
#[subject(endpoint)]
133+
/// Emitted when an StaleKey packet was authentic and processed
134+
struct ReplayDetectedPacketAccepted<'a> {
135+
peer_address: SocketAddress<'a>,
136+
credential_id: &'a [u8],
137+
key_id: u64,
138+
}
139+
140+
#[event("path_secret_map:replay_detected_packet_rejected")]
141+
#[subject(endpoint)]
142+
/// Emitted when an ReplayDetected packet was rejected as invalid
143+
struct ReplayDetectedPacketRejected<'a> {
144+
peer_address: SocketAddress<'a>,
145+
credential_id: &'a [u8],
146+
}
147+
148+
#[event("path_secret_map:replay_detected_packet_dropped")]
149+
#[subject(endpoint)]
150+
/// Emitted when an ReplayDetected packet was dropped due to a missing entry
151+
struct ReplayDetectedPacketDropped<'a> {
152+
peer_address: SocketAddress<'a>,
153+
credential_id: &'a [u8],
154+
}
155+
156+
#[event("path_secret_map:stale_key_packet_sent")]
157+
#[subject(endpoint)]
158+
/// Emitted when an StaleKey packet was sent
159+
struct StaleKeyPacketSent<'a> {
160+
peer_address: SocketAddress<'a>,
161+
credential_id: &'a [u8],
162+
}
163+
164+
#[event("path_secret_map:stale_key_packet_received")]
165+
#[subject(endpoint)]
166+
/// Emitted when an StaleKey packet was received
167+
struct StaleKeyPacketReceived<'a> {
168+
peer_address: SocketAddress<'a>,
169+
credential_id: &'a [u8],
170+
}
171+
172+
#[event("path_secret_map:stale_key_packet_accepted")]
173+
#[subject(endpoint)]
174+
/// Emitted when an StaleKey packet was authentic and processed
175+
struct StaleKeyPacketAccepted<'a> {
176+
peer_address: SocketAddress<'a>,
177+
credential_id: &'a [u8],
178+
}
179+
180+
#[event("path_secret_map:stale_key_packet_rejected")]
181+
#[subject(endpoint)]
182+
/// Emitted when an StaleKey packet was rejected as invalid
183+
struct StaleKeyPacketRejected<'a> {
184+
peer_address: SocketAddress<'a>,
185+
credential_id: &'a [u8],
186+
}
187+
188+
#[event("path_secret_map:stale_key_packet_dropped")]
189+
#[subject(endpoint)]
190+
/// Emitted when an StaleKey packet was dropped due to a missing entry
191+
struct StaleKeyPacketDropped<'a> {
192+
peer_address: SocketAddress<'a>,
193+
credential_id: &'a [u8],
194+
}

dc/s2n-quic-dc/src/event.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@
44
#[cfg(any(test, feature = "testing"))]
55
use s2n_quic_core::event::snapshot;
66

7-
pub use s2n_quic_core::event::{Event, IntoEvent, Timestamp};
7+
pub use s2n_quic_core::event::{Event, IntoEvent};
8+
9+
/// Provides metadata related to an event
10+
pub trait Meta: core::fmt::Debug {
11+
/// A context from which the event is being emitted
12+
///
13+
/// An event can occur in the context of an Endpoint or Connection
14+
fn subject(&self) -> api::Subject;
15+
}
16+
17+
impl Meta for api::ConnectionMeta {
18+
fn subject(&self) -> api::Subject {
19+
builder::Subject::Connection { id: self.id }.into_event()
20+
}
21+
}
22+
23+
impl Meta for api::EndpointMeta {
24+
fn subject(&self) -> api::Subject {
25+
builder::Subject::Endpoint {}.into_event()
26+
}
27+
}
828

929
mod generated;
1030
pub use generated::*;

0 commit comments

Comments
 (0)