Skip to content

Commit a279f78

Browse files
Merge #1344
1344: Add support for `SockAddr::Link` when receiving packets r=asomers a=internetionals fixes #1343 Co-authored-by: Justin Ossevoort <github@internetionals.nl>
2 parents c0c5570 + 867cb7d commit a279f78

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1818
- i686-apple-darwin has been demoted to Tier 2 support, because it's deprecated
1919
by Xcode.
2020
(#[1350](https://github.com/nix-rust/nix/pull/1350))
21+
- Fixed calling `recvfrom` on an `AddrFamily::Packet` socket
22+
(#[1344](https://github.com/nix-rust/nix/pull/1344))
2123

2224
### Removed
2325

src/sys/socket/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,15 @@ pub fn sockaddr_storage_to_addr(
17021702
Ok(SockAddr::Unix(UnixAddr(sun, pathlen)))
17031703
}
17041704
#[cfg(any(target_os = "android", target_os = "linux"))]
1705+
libc::AF_PACKET => {
1706+
use libc::sockaddr_ll;
1707+
assert_eq!(len as usize, mem::size_of::<sockaddr_ll>());
1708+
let sll = unsafe {
1709+
*(addr as *const _ as *const sockaddr_ll)
1710+
};
1711+
Ok(SockAddr::Link(LinkAddr(sll)))
1712+
}
1713+
#[cfg(any(target_os = "android", target_os = "linux"))]
17051714
libc::AF_NETLINK => {
17061715
use libc::sockaddr_nl;
17071716
let snl = unsafe {

0 commit comments

Comments
 (0)