-
Notifications
You must be signed in to change notification settings - Fork 172
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
Standardize socket addresses to network format #1808
Conversation
@victorstewart this PR changes the way the Picoquic stack interprets the port numbers in addresses passed through the "incoming packet" and "prepare packet" API. I asked you to review, because I am concerned it might affect your implementation. |
i'm not sure why it makes sense to standardize around host byte order instead of network byte order, but whatever you want to do i've identified the places in my code that would need conversions. |
@victorstewart the problem are the user level API that let users set or get the IP addresses. I suppose we could set all of them in network order, but I have observed that this creates confusion with some users. Let's wait for other reviews before merging this. |
i would see the argument for host byte order if the interfaces were like |
@victorstewart I asked for a review because I wanted feedback, so thank you for providing it. Yes, standardizing on network order would also be consistent. It will make the socket code a bit simpler -- no need to "reorder" the addresses exchanged with the stack through the API The caveat is for the application interfaces -- the server address parameter in I am also waiting a review from @suhasHere. If he agrees with your feedback, I will update the PR to standardize on network order. |
I did a "PR on the PR" to standardize on network order. Interestingly, I did not need to change the code in the |
The previous socket code in
sockloop.c
and the various address setting/getting APIs used a mix of "host" and "network" format depending on the calls. This was somewhat confusing. This PR standardize the use of network or host order for the "port" values with two guidelines:picoquic.h
, always pass the addresses inhost
format. For example, is the port number is 443, the value ofsin_port
will be 443, regardless of whether the local host is using big endian or little endian format.sockloop.c
.The PR also clarifies the rules for selecting the outgoing socket. For outgoing packets, the outgoing socket will be chosen based on the Address Family of the destination address (
addr_to
) and the port number of the source address (addr_from
), with the following rules:sockloop.c
will always pick a socket bound to the same address family as the destination address.prefer_extra_socket
is set in the call tosockloop
, in which case the last socket will be selected.