Skip to content

No IN6ADDR_ANY_INIT or in6_addr_any IPV6 initializers #1950

Closed
@simias

Description

@simias

The libc crate currently exports the INADDR_ANY const to initialize a wildcard IPV4 in_addr but it doesn't provide the IPV6 counterparts as far as I can tell.

In C since in6_addr is an array instead of a single variable there are two ways to initialize a wildcard IPV6 address, the in6_addr_any global variable and the IN6ADDR_ANY_INIT macro, usually expanding to { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }.

I suspect that the lack of these two symbols in the libc crate is intentional since neither of them makes a lot of sense in Rust. As far as I can tell the most reasonable way to expose this feature in Rust would be:

const IN6ADDR_ANY: in6_addr = in6_addr { s6_addr: [0; 16] };

But then it doesn't actually match any of the C symbols exactly.

On one hand not having this feature in the crate is not the end of the world, initializing an in6_addr with full zeroes is not hard. On the hand people coming from C/C++ will probably be surprised not to find this symbol in the crate, especially since the IPV4 counterpart does exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions