Skip to content

Commit 4b6b14a

Browse files
bors[bot]bltavares
andauthored
Merge #1265
1265: Expose IP_PKTINFO Control Message on Android and iOS r=asomers a=bltavares The commit #1222 added the very useful Ipv4PktInfo to allow `sendmsg` to define the origin of the ip. Unfortunattely, it didn't add the struct to Android target devices as well. This commit adds the `target_os = "android"` and `target_os =" ios"` checks on the same place to allow the compilation to work for the following archs tested: - `cross build --target aarch64-linux-android` - `cross build --target x86_64-linux-android` - `cross build --target armv7-linux-androideabi` - `cross build --target aarch64-apple-ios` - `cross build --target x86_64-apple-ios` Co-authored-by: Bruno Tavares <[email protected]>
2 parents 2542f81 + 0a97376 commit 4b6b14a

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3939
(#[1244](https://github.com/nix-rust/nix/pull/1244))
4040
- Added `unistd::ttyname`
4141
(#[1259](https://github.com/nix-rust/nix/pull/1259))
42+
- Added support for `Ipv4PacketInfo` and `Ipv6PacketInfo` to `ControlMessage` for iOS and Android.
43+
(#[1265](https://github.com/nix-rust/nix/pull/1265))
4244

4345
### Changed
4446
- Changed `fallocate` return type from `c_int` to `()` (#[1201](https://github.com/nix-rust/nix/pull/1201))

src/sys/socket/mod.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,9 @@ pub enum ControlMessage<'a> {
730730
/// [`ip(7)`](http://man7.org/linux/man-pages/man7/ip.7.html) man page.
731731
#[cfg(any(target_os = "linux",
732732
target_os = "macos",
733-
target_os = "netbsd"))]
733+
target_os = "netbsd",
734+
target_os = "android",
735+
target_os = "ios",))]
734736
Ipv4PacketInfo(&'a libc::in_pktinfo),
735737

736738
/// Configure the sending addressing and interface for v6
@@ -740,7 +742,9 @@ pub enum ControlMessage<'a> {
740742
#[cfg(any(target_os = "linux",
741743
target_os = "macos",
742744
target_os = "netbsd",
743-
target_os = "freebsd"))]
745+
target_os = "freebsd",
746+
target_os = "android",
747+
target_os = "ios",))]
744748
Ipv6PacketInfo(&'a libc::in6_pktinfo),
745749
}
746750

@@ -824,10 +828,12 @@ impl<'a> ControlMessage<'a> {
824828
gso_size as *const _ as *const u8
825829
},
826830
#[cfg(any(target_os = "linux", target_os = "macos",
827-
target_os = "netbsd"))]
831+
target_os = "netbsd", target_os = "android",
832+
target_os = "ios",))]
828833
ControlMessage::Ipv4PacketInfo(info) => info as *const _ as *const u8,
829834
#[cfg(any(target_os = "linux", target_os = "macos",
830-
target_os = "netbsd", target_os = "freebsd"))]
835+
target_os = "netbsd", target_os = "freebsd",
836+
target_os = "android", target_os = "ios",))]
831837
ControlMessage::Ipv6PacketInfo(info) => info as *const _ as *const u8,
832838
};
833839
unsafe {
@@ -870,10 +876,12 @@ impl<'a> ControlMessage<'a> {
870876
mem::size_of_val(gso_size)
871877
},
872878
#[cfg(any(target_os = "linux", target_os = "macos",
873-
target_os = "netbsd"))]
879+
target_os = "netbsd", target_os = "android",
880+
target_os = "ios",))]
874881
ControlMessage::Ipv4PacketInfo(info) => mem::size_of_val(info),
875882
#[cfg(any(target_os = "linux", target_os = "macos",
876-
target_os = "netbsd", target_os = "freebsd"))]
883+
target_os = "netbsd", target_os = "freebsd",
884+
target_os = "android", target_os = "ios",))]
877885
ControlMessage::Ipv6PacketInfo(info) => mem::size_of_val(info),
878886
}
879887
}
@@ -892,10 +900,12 @@ impl<'a> ControlMessage<'a> {
892900
#[cfg(target_os = "linux")]
893901
ControlMessage::UdpGsoSegments(_) => libc::SOL_UDP,
894902
#[cfg(any(target_os = "linux", target_os = "macos",
895-
target_os = "netbsd"))]
903+
target_os = "netbsd", target_os = "android",
904+
target_os = "ios",))]
896905
ControlMessage::Ipv4PacketInfo(_) => libc::IPPROTO_IP,
897906
#[cfg(any(target_os = "linux", target_os = "macos",
898-
target_os = "netbsd", target_os = "freebsd"))]
907+
target_os = "netbsd", target_os = "freebsd",
908+
target_os = "android", target_os = "ios",))]
899909
ControlMessage::Ipv6PacketInfo(_) => libc::IPPROTO_IPV6,
900910
}
901911
}
@@ -925,10 +935,12 @@ impl<'a> ControlMessage<'a> {
925935
libc::UDP_SEGMENT
926936
},
927937
#[cfg(any(target_os = "linux", target_os = "macos",
928-
target_os = "netbsd"))]
938+
target_os = "netbsd", target_os = "android",
939+
target_os = "ios",))]
929940
ControlMessage::Ipv4PacketInfo(_) => libc::IP_PKTINFO,
930941
#[cfg(any(target_os = "linux", target_os = "macos",
931-
target_os = "netbsd", target_os = "freebsd"))]
942+
target_os = "netbsd", target_os = "freebsd",
943+
target_os = "android", target_os = "ios",))]
932944
ControlMessage::Ipv6PacketInfo(_) => libc::IPV6_PKTINFO,
933945
}
934946
}

0 commit comments

Comments
 (0)