DPDK patches and discussions
 help / color / mirror / Atom feed
* Portable alternative to inet_ntop?
@ 2024-07-24 16:21 Stephen Hemminger
  2024-07-26 12:36 ` Morten Brørup
  2024-08-06  5:35 ` Tyler Retzlaff
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2024-07-24 16:21 UTC (permalink / raw)
  To: dev, Tyler Retzlaff

The function inet_ntop is useful to make printable addresses for debugging.
It is available on Linux and FreeBSD but not on Windows.

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);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-07 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 16:21 Portable alternative to inet_ntop? Stephen Hemminger
2024-07-26 12:36 ` Morten Brørup
2024-08-06  5:35 ` Tyler Retzlaff
2024-08-07 22:23   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).