On Wed, Jul 24, 2024 at 09:21:13AM -0700, Stephen Hemminger wrote: > The function inet_ntop is useful to make printable addresses for debugging. > It is available on Linux and FreeBSD but not on Windows.
i know my reply is late. but the following wasn't usable? https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop it isn't wide (PSTR). i know trying to use winsock headers is a mess though so if it is hard duplicating seems fine. i would not be unhappy for more generalized apis to be built up within dpdk to avoid the platform coupling. ty > > There are some alternatives: > - add yet another OS shim in lib/eal/windows/include. > Win32 has similar InetNtoP but it uses wide characters. > > - copy/paste code from FreeBSD into some new functions. > > Hate duplicating code, but portability is a problem here. > > diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h > index 0d103d4127..a9404b4b41 100644 > --- a/lib/net/rte_ip.h > +++ b/lib/net/rte_ip.h > @@ -839,6 +839,27 @@ rte_ipv6_get_next_ext(const uint8_t *p, int proto, > size_t *ext_len) > return next_proto; > } > > + > +#define RTE_IPV4_ADDR_FMT_SIZE 16 > +#define RTE_IPV6_ADDR_FMT_SIZE 46 > + > +__rte_experimental > +int > +rte_ipv4_format_addr(char *buf, uint16_t size, const void *addr); > + > +__rte_experimental > +void > +rte_ipv4_unformat_addr(const char *str, void *addr); > + > +__rte_experimental > +void > +rte_ipv6_format_addr(char *buf, uint16_t size, const void *addr); > + > +__rte_experimental > +void > +rte_ipv4_unformat_addr(const char *str, void *addr);