-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socket: Respect IPv6 flowinfo and scope_id in InetAddr::from_std #335
Conversation
sin6_port: addr.port().to_be(), // network byte order | ||
sin6_addr: Ipv6Addr::from_std(addr.ip()).0, | ||
sin6_flowinfo: addr.flowinfo().to_be(), // network byte order | ||
sin6_scope_id: addr.scope_id().to_be(), // network byte order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sin6_flowinfo and sin6_scope_id must be in host byte order.
Related: rust-lang/rust#32424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the port should be in network byte order, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From rust-lang/rust#32429 looks like only the port. Should be fixed now!
015040f
to
8422bfa
Compare
Looks great! Can't really test it as build is failing on nightly (nightly is required because of rust-lang/rust#32424). |
Actually, if you have a test case we can add, that would be even better! |
@kamalmarhubi std::net:SocketAddrV6 is broken on stable so test also will be broken. That stuff fixed in nightly 2016-03-25+
|
I was wrong, this fix doesn't need rust-lang/rust#32424 #[test]
pub fn test_inetv6_addr_to_sock_addr() {
let port: u16 = 3000;
let flowinfo: u32 = 1;
let scope_id: u32 = 2;
let actual = net::SocketAddr::V6(net::SocketAddrV6::new("fe80::1".parse().unwrap(), port, flowinfo, scope_id));
let addr = InetAddr::from_std(&actual);
match addr {
InetAddr::V6(addr) => {
assert_eq!(addr.sin6_port, port.to_be());
assert_eq!(addr.sin6_flowinfo, flowinfo);
assert_eq!(addr.sin6_scope_id, scope_id);
}
_ => panic!("nope"),
}
assert_eq!(actual, addr.to_std());
} |
8422bfa
to
6d01a26
Compare
Added the test, thanks! |
r? @fiveop |
@homu r+ |
📌 Commit 6d01a26 has been approved by |
⚡ Test exempted - status |
socket: Respect IPv6 flowinfo and scope_id in InetAddr::from_std Fixes #329
Fixes #329