From 8e8362b70736b7e1fb3034a8d93f5a11a8ad85ac Mon Sep 17 00:00:00 2001 From: lucas Date: Fri, 20 Mar 2020 18:30:34 +0000 Subject: [PATCH] qlog ffi title and description params --- include/quiche.h | 3 ++- src/ffi.rs | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/quiche.h b/include/quiche.h index 08a10b5f78..65228e8671 100644 --- a/include/quiche.h +++ b/include/quiche.h @@ -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); diff --git a/src/ffi.rs b/src/ffi.rs index 7d907768b7..9cd8a3519e 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -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), ); }