Skip to content
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

[catnap] Set Source Address in OperationResult for pop() #149

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

ppenna
Copy link
Contributor

@ppenna ppenna commented Jul 28, 2022

Description

This PR fixes #147.

Sumary of Changes

  • Changed PopFuture::poll() to use recvfrom() and return the source address of the message
  • Changed the Operation::get_result() to set the address in OperationResult accordingly

Additional Information

@ppenna ppenna added the bug Something Isn't Working label Jul 28, 2022
@ppenna ppenna self-assigned this Jul 28, 2022
Some(sin) => {
let ip: Ipv4Addr = Ipv4Addr::from(sin.ip());
let port: u16 = sin.port();
Some(SocketAddrV4::new(ip, port))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to perform network-to-host byte-order conversion here? nix::sys::socket::recvfrom looks to just be returning the sockaddr in a byte array, which would presumably yield big-endian values. Unless something funky is happening in "as_sockaddr_in" (which I can't seem to find documentation for, where is that coming from?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrianZill, we don't need to because as_sockaddr_in().ip() and as_sockaddr_in().port() return the IP address and port number in host endianness, respectively. See: https://docs.rs/nix/latest/nix/sys/socket/struct.SockaddrIn.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks.

@ppenna ppenna requested a review from BrianZill July 28, 2022 18:45
Copy link
Contributor

@BrianZill BrianZill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ppenna ppenna merged commit 6a3e269 into dev Jul 29, 2022
@ppenna ppenna deleted the bugfix-catnap-pop branch July 29, 2022 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something Isn't Working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants