<div dir="ltr">Indeed, looks wrong. It works merely by accident - both structs have port field at the same offset.</div><br><div class="gmail_quote"><div dir="ltr">czw., 30 sie 2018 o 15:03 Radostin Stoyanov <<a href="mailto:rstoyanov1@gmail.com">rstoyanov1@gmail.com</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 07/06/18 11:32, Pawel Stradomski wrote:<br>
> + if (saddr.ss_family == AF_INET6) {<br>
> + opts.port = ntohs(((struct sockaddr_in *)&saddr)->sin_port);<br>
> + } else if (saddr.ss_family == AF_INET) {<br>
> + opts.port = ntohs(((struct sockaddr_in6 *)&saddr)->sin6_port);<br>
> + }<br>
> +<br>
<br>
This patch has been merged into master but I noticed this part from<br>
setup_tcp_server() in util.c<br>
and I was wondering if the logic in this condition should be reversed?<br>
<br>
For example:<br>
<br>
if (saddr.ss_family == AF_INET6) {<br>
opts.port = ntohs(((struct sockaddr_in6 *)&saddr)->sin6_port);<br>
} else if (saddr.ss_family == AF_INET) {<br>
opts.port = ntohs(((struct sockaddr_in *)&saddr)->sin_port);<br>
}<br>
<br>
Thanks,<br>
Radostin<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Paweł Stradomski</div>