<netinet/in.h> setsourcefilter/getsourcefilter missing const qualifier?

Eric van Gyzen vangyzen at FreeBSD.org
Thu May 5 00:23:34 UTC 2016


On 05/ 3/16 03:50 PM, Victor Toni wrote:
> When trying to compile some linux-originated code on FreeBSD I get the
> following errors:
>
> /usr/include/netinet/in.h:585:5: note: candidate function not viable: 3rd
> argument ('const sockaddr *') would lose const qualifier
> int     setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
>          ^
> /usr/include/netinet/in.h:587:5: note: candidate function not viable: 3rd
> argument ('const sockaddr *') would lose const qualifier
> int     getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
>          ^
>
> the main difference is that the linux version makes guarantees about
> the parameters.
>
>
> Wouldn't it be safe for the FreeBSD version to make the same assumption?

Yes, it would be safe in practice, since the implementation does not 
modify those parameters.  However, RFC 3678 does not specify them as 
const, and neither do illumos (Solaris) and Mac OS X, so code that tries 
to pass const parameters is not portable.  I would suggest changing the 
code to pass non-const parameters.

Eric


More information about the freebsd-net mailing list