Skip to content

Commit

Permalink
qlog ffi title and description params
Browse files Browse the repository at this point in the history
  • Loading branch information
LPardue committed Mar 20, 2020
1 parent 54cacf8 commit 8e8362b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ quiche_conn *quiche_conn_new_with_tls(const uint8_t *scid, size_t scid_len,
bool is_server);

// Enables qlog to the specified file descriptor. Unix only.
void quiche_conn_set_qlog_fd(quiche_conn *conn, int fd);
void quiche_conn_set_qlog_fd(quiche_conn *conn, int fd, const char * log_title,
const char * log_desc);

// Processes QUIC packets received from the peer.
ssize_t quiche_conn_recv(quiche_conn *conn, uint8_t *buf, size_t buf_len);
Expand Down
12 changes: 9 additions & 3 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,20 @@ pub extern fn quiche_config_set_cc_algorithm(

#[no_mangle]
#[cfg(all(unix, feature = "qlog"))]
pub extern fn quiche_conn_set_qlog_fd(conn: &mut Connection, fd: c_int) {
pub extern fn quiche_conn_set_qlog_fd(
conn: &mut Connection, fd: c_int, log_title: *const c_char,
log_desc: *const c_char,
) {
let f = unsafe { std::fs::File::from_raw_fd(fd) };
let writer = std::io::BufWriter::new(f);

let title = unsafe { ffi::CStr::from_ptr(log_title).to_str().unwrap() };
let description = unsafe { ffi::CStr::from_ptr(log_desc).to_str().unwrap() };

conn.set_qlog(
std::boxed::Box::new(writer),
"quiche-client qlog".to_string(),
format!("{} id={}", "quiche-client qlog", conn.trace_id),
title.to_string(),
format!("{} id={}", description, conn.trace_id),
);
}

Expand Down

0 comments on commit 8e8362b

Please sign in to comment.