Skip to content

Commit 0921341

Browse files
quic_trace: fix conn_at_idx
1 parent 566cd34 commit 0921341

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/app/shared_dev/commands/quic_trace/fd_quic_trace_main.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ dump_quic_config( fd_quic_config_t * config ) {
121121
}
122122

123123
static char const *
124-
peer_cid_str( fd_quic_conn_t * conn ) {
124+
peer_cid_str( fd_quic_conn_t const * conn ) {
125125
static char buf[FD_QUIC_MAX_CONN_ID_SZ*2];
126-
ulong sz = conn->peer_cids[0].sz;
127-
uchar * cid = conn->peer_cids[0].conn_id;
126+
ulong sz = conn->peer_cids[0].sz;
127+
uchar const * cid = conn->peer_cids[0].conn_id;
128128
sz = fd_ulong_min( sz, FD_QUIC_MAX_CONN_ID_SZ );
129129

130130
fd_hex_encode( buf, cid, sz );
@@ -133,7 +133,7 @@ peer_cid_str( fd_quic_conn_t * conn ) {
133133
}
134134

135135
static void
136-
dump_connection( fd_quic_conn_t * conn ) {
136+
dump_connection( fd_quic_conn_t const * conn ) {
137137
(void)conn;
138138

139139
#define CONN_MEMB_LIST(X,CONN,...) \
@@ -182,6 +182,14 @@ dump_connection( fd_quic_conn_t * conn ) {
182182
));
183183
}
184184

185+
static fd_quic_conn_t const *
186+
fd_quic_trace_conn_at_idx( fd_quic_t const * quic, ulong idx, ulong quic_raddr ) {
187+
fd_quic_state_t const * state = fd_quic_get_state_const( quic );
188+
ulong const conn_base_off = state->conn_base - quic_raddr;
189+
ulong const local_conn_base = (ulong)quic + conn_base_off;
190+
return (fd_quic_conn_t *)( local_conn_base + idx * state->conn_sz );
191+
}
192+
185193
void
186194
quic_trace_cmd_fn( args_t * args,
187195
config_t * config ) {
@@ -284,9 +292,8 @@ quic_trace_cmd_fn( args_t * args,
284292
ulong state_cap = sizeof( state_cnt) / sizeof( state_cnt[0] );
285293
#undef _
286294

287-
fd_quic_state_t * quic_state = fd_quic_get_state( quic );
288295
for( ulong j = 0; j < conn_cnt; ++j ) {
289-
fd_quic_conn_t * conn = fd_quic_conn_at_idx( quic_state, j );
296+
fd_quic_conn_t const * conn = fd_quic_trace_conn_at_idx( quic, j, quic_raddr );
290297
ulong state = conn->state;
291298
ulong *state_bucket = state < state_cap ? &state_cnt[state] : &state_unknown;
292299

0 commit comments

Comments
 (0)