Skip to content

Conversation

@izissise
Copy link
Contributor

  • Add bswap_128()
  • Add IPv6 support to getifaddrs() on Bsd
    Tested on x86_64 MacOs OpenBsd FreeBsd and NetBsd.

There is extra ioctl calls on the ipv6 bsd path
because SIOCGIFCONF doesn't returns the addr flag
or the netmask.

Luckily all bsd systems share the same values for
SIOCGIFAFLAG_IN6 and SIOCGIFNETMASK_IN6.

@izissise izissise changed the title Getifaddrs bsd Add IPv6 support to getifaddrs() on Bsd Aug 13, 2025
Copy link
Owner

@jart jart left a comment

Choose a reason for hiding this comment

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

Wow this is great. I wish Linux had this! Thank you for doing this.

libcesque uint16_t bswap_16(uint16_t) pureconst;
libcesque uint32_t bswap_32(uint32_t) pureconst;
libcesque uint64_t bswap_64(uint64_t) pureconst;
libcesque uint128_t bswap_128(uint128_t) pureconst;
Copy link
Owner

Choose a reason for hiding this comment

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

I recommend putting this line behind an ifdef like:

#ifdef _COSMO_SOURCE
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 406 || defined(__llvm__)
// ...

Copy link
Contributor Author

@izissise izissise Jan 19, 2026

Choose a reason for hiding this comment

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

I added the guards, I wish Linux had an easy way to get ipv6 info aswell

This greatly helps for IPv6 endianess convertion
Tested on x86_64 MacOs OpenBsd FreeBsd and NetBsd.

There is extra ioctl calls on the ipv6 bsd path
because SIOCGIFCONF doesn't returns the addr flag
or the netmask.

Luckily all bsd systems share the same values for
SIOCGIFAFLAG_IN6 and SIOCGIFNETMASK_IN6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants