Skip to content

Commit

Permalink
fix linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
youyuanwu committed Jan 21, 2025
1 parent e6d1963 commit 2c51a2e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ include!("linux_bindings.rs");
pub type ADDRESS_FAMILY = u16;
#[cfg(target_os = "windows")]
include!("win_bindings.rs");

/// Temp type for casting manual ffi flags. To be removed eventually.
#[cfg(not(target_os = "windows"))]
pub type QuicFlag = u32;
#[cfg(target_os = "windows")]
pub type QuicFlag = i32;
24 changes: 17 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,11 @@ impl Connection {

pub fn shutdown(&self, flags: ConnectionShutdownFlags, error_code: u62) {
unsafe {
Api::ffi_ref().ConnectionShutdown.unwrap()(self.handle, flags as i32, error_code);
Api::ffi_ref().ConnectionShutdown.unwrap()(
self.handle,
flags as crate::ffi::QuicFlag,
error_code,
);
}
}

Expand Down Expand Up @@ -1610,7 +1614,7 @@ impl Connection {
self.handle,
buffer as *const Buffer as *const QUIC_BUFFER,
buffer_count,
flags as i32,
flags as crate::ffi::QuicFlag,
client_send_context as *mut c_void,
)
};
Expand All @@ -1634,7 +1638,7 @@ impl Connection {
let status = unsafe {
Api::ffi_ref()
.ConnectionCertificateValidationComplete
.unwrap()(self.handle, result, tls_alert as i32)
.unwrap()(self.handle, result, tls_alert as crate::ffi::QuicFlag)
};
Error::ok_from_raw(status)
}
Expand Down Expand Up @@ -1771,7 +1775,7 @@ impl Stream {
let status = unsafe {
Api::ffi_ref().StreamOpen.unwrap()(
connection.handle,
flags as i32,
flags as crate::ffi::QuicFlag,
Some(std::mem::transmute(handler)),
context as *mut c_void,
std::ptr::addr_of_mut!(self.handle),
Expand All @@ -1781,13 +1785,19 @@ impl Stream {
}

pub fn start(&self, flags: StreamStartFlags) -> Result<(), Error> {
let status = unsafe { Api::ffi_ref().StreamStart.unwrap()(self.handle, flags as i32) };
let status = unsafe {
Api::ffi_ref().StreamStart.unwrap()(self.handle, flags as crate::ffi::QuicFlag)
};
Error::ok_from_raw(status)
}

pub fn shutdown(&self, flags: StreamShutdownFlags, error_code: u62) -> Result<(), Error> {
let status = unsafe {
Api::ffi_ref().StreamShutdown.unwrap()(self.handle, flags as i32, error_code)
Api::ffi_ref().StreamShutdown.unwrap()(
self.handle,
flags as crate::ffi::QuicFlag,
error_code,
)
};
Error::ok_from_raw(status)
}
Expand All @@ -1812,7 +1822,7 @@ impl Stream {
self.handle,
buffer as *const Buffer as *const QUIC_BUFFER,
buffer_count,
flags as i32,
flags as crate::ffi::QuicFlag,
client_send_context as *mut c_void, //(self as *const Stream) as *const c_void,
)
};
Expand Down

0 comments on commit 2c51a2e

Please sign in to comment.