Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@redraincatching
Copy link
Contributor

based on the ideas originally developed in this pr by @WHYHD

@redraincatching redraincatching force-pushed the uint16-ports branch 3 times, most recently from ab7cd62 to 42bd9c7 Compare September 17, 2025 11:33
init_socket(&udp_fd, local_addr, *local_port, remote_addr);

ret = stunclient_send(&buf, udp_fd, local_addr, local_port, remote_addr, change_ip, change_port, padding, -1);
ret = stunclient_send(&buf, udp_fd, local_addr, (uint16_t *)local_port, remote_addr, change_ip, change_port, padding,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not change the argument to the function instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these all fall under the same issue - init_socket uses local_port as a pseudo-boolean, where it is treated as a port in the range [0, USHRT_MAX), but as a negation of a path when < 0.

the port has to be passed as an integer through some functions to preserve this meaning.

init_socket(&udp_fd, local_addr, *local_port, remote_addr);

ret = stunclient_send(&buf, udp_fd, local_addr, local_port, remote_addr, change_ip, change_port, padding, -1);
ret = stunclient_send(&buf, udp_fd, local_addr, (uint16_t *)local_port, remote_addr, change_ip, change_port, padding,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same... instead of casting should change the function argument

}

addr_set_port(&real_local_addr, response_port);
addr_set_port(&real_local_addr, (uint16_t)response_port);
Copy link
Collaborator

Choose a reason for hiding this comment

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

change the type of the argument of addr_set_port

Copy link
Collaborator

@eakraly eakraly left a comment

Choose a reason for hiding this comment

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

almost there - a few more places to change the type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants