From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org
Subject: Re: Portable alternative to inet_ntop?
Date: Mon, 5 Aug 2024 22:35:27 -0700 [thread overview]
Message-ID: <20240806053527.GA19300@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <20240724092113.4977b047@hermes.local>
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);
next prev parent reply other threads:[~2024-08-06 5:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 16:21 Stephen Hemminger
2024-07-26 12:36 ` Morten Brørup
2024-08-06 5:35 ` Tyler Retzlaff [this message]
2024-08-07 22:23 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240806053527.GA19300@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
--to=roretzla@linux.microsoft.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).