Skip to content

Commit

Permalink
Enable packet info and related flags for quinn-udp on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
conectado authored and Ralith committed Mar 10, 2024
1 parent 2e72f27 commit 2e31272
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions quinn-udp/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ impl UdpSocketState {
}

let mut may_fragment = false;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
{
// opportunistically try to enable GRO. See gro::gro_segments().
#[cfg(target_os = "linux")]
let _ = set_socket_option(&*io, libc::SOL_UDP, libc::UDP_GRO, OPTION_ON);

// Forbid IPv4 fragmentation. Set even for IPv6 to account for IPv6 mapped IPv4 addresses.
Expand Down Expand Up @@ -604,7 +605,7 @@ fn prepare_msg(
if let Some(ip) = &transmit.src_ip {
match ip {
IpAddr::V4(v4) => {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
{
let pktinfo = libc::in_pktinfo {
ipi_ifindex: 0,
Expand Down Expand Up @@ -685,7 +686,7 @@ fn decode_recv(
ecn_bits = cmsg::decode::<libc::c_int, libc::cmsghdr>(cmsg) as u8;
}
},
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
(libc::IPPROTO_IP, libc::IP_PKTINFO) => {
let pktinfo = unsafe { cmsg::decode::<libc::in_pktinfo, libc::cmsghdr>(cmsg) };
dst_ip = Some(IpAddr::V4(Ipv4Addr::from(
Expand Down

0 comments on commit 2e31272

Please sign in to comment.