Skip to content

Commit

Permalink
Merge #1344
Browse files Browse the repository at this point in the history
1344: Add support for `SockAddr::Link` when receiving packets r=asomers a=internetionals

fixes #1343

Co-authored-by: Justin Ossevoort <github@internetionals.nl>
  • Loading branch information
bors[bot] and internetionals committed Jan 31, 2021
2 parents c0c5570 + 867cb7d commit a279f78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- i686-apple-darwin has been demoted to Tier 2 support, because it's deprecated
by Xcode.
(#[1350](https://github.com/nix-rust/nix/pull/1350))
- Fixed calling `recvfrom` on an `AddrFamily::Packet` socket
(#[1344](https://github.com/nix-rust/nix/pull/1344))

### Removed

Expand Down
9 changes: 9 additions & 0 deletions src/sys/socket/mod.rs
Expand Up @@ -1702,6 +1702,15 @@ pub fn sockaddr_storage_to_addr(
Ok(SockAddr::Unix(UnixAddr(sun, pathlen)))
}
#[cfg(any(target_os = "android", target_os = "linux"))]
libc::AF_PACKET => {
use libc::sockaddr_ll;
assert_eq!(len as usize, mem::size_of::<sockaddr_ll>());
let sll = unsafe {
*(addr as *const _ as *const sockaddr_ll)
};
Ok(SockAddr::Link(LinkAddr(sll)))
}
#[cfg(any(target_os = "android", target_os = "linux"))]
libc::AF_NETLINK => {
use libc::sockaddr_nl;
let snl = unsafe {
Expand Down

0 comments on commit a279f78

Please sign in to comment.