From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/4] net: implement ethaddr_string_cmp()
Date: Thu, 28 Nov 2024 08:36:55 +0100 [thread overview]
Message-ID: <Z0gdl5vSvNaLYqXP@pengutronix.de> (raw)
In-Reply-To: <20241126151744.3621717-5-a.fatoum@pengutronix.de>
On Tue, Nov 26, 2024 at 04:17:44PM +0100, Ahmad Fatoum wrote:
> We keep ethernet addresses either in binary or in text form at a couple
> of places, e.g. device tree, device parameters, struct net_device,
> ... etc. We have memcmp() and strcmp() respectively to compare each, add
> one more function to compare a text string with binary. This will be
> used in a follow up commit.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> include/net.h | 2 ++
> net/lib.c | 17 +++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/include/net.h b/include/net.h
> index d9b7953a3c33..dbc45b806a51 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -366,6 +366,8 @@ IPaddr_t getenv_ip(const char *name);
> int setenv_ip(const char *name, IPaddr_t ip);
>
> int string_to_ethaddr(const char *str, u8 enetaddr[6]);
> +void ethaddr_to_string(const u8 enetaddr[6], char *str);
> +int ethaddr_string_cmp(const u8 enetaddr_a[6], const char *str_b);
>
> #ifdef CONFIG_NET_RESOLV
> int resolv(const char *host, IPaddr_t *ip);
> diff --git a/net/lib.c b/net/lib.c
> index dc6e138f392c..59bd4c280caf 100644
> --- a/net/lib.c
> +++ b/net/lib.c
> @@ -37,6 +37,23 @@ int string_to_ethaddr(const char *str, u8 enetaddr[ETH_ALEN])
> return 0;
> }
>
> +void ethaddr_to_string(const u8 enetaddr[ETH_ALEN], char *str)
> +{
> + sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x",
> + enetaddr[0], enetaddr[1], enetaddr[2], enetaddr[3],
> + enetaddr[4], enetaddr[5]);
> +}
Do you reintroduce this function on purpose or due to rebasing
conflicts? A MAC address can now be printed with "%pM".
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2024-11-28 7:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 15:17 [PATCH 0/4] net: ethernet address helpers for board code Ahmad Fatoum
2024-11-26 15:17 ` [PATCH 1/4] net: add ethaddr sequence handling Ahmad Fatoum
2024-11-28 7:28 ` Sascha Hauer
2024-11-28 7:30 ` Ahmad Fatoum
2024-11-26 15:17 ` [PATCH 2/4] net: factor out eth_of_get_fixup_node Ahmad Fatoum
2024-11-26 15:17 ` [PATCH 3/4] net: export list of registered ethernet addresses Ahmad Fatoum
2024-11-26 15:17 ` [PATCH 4/4] net: implement ethaddr_string_cmp() Ahmad Fatoum
2024-11-28 7:36 ` Sascha Hauer [this message]
2024-11-28 7:43 ` Ahmad Fatoum
2024-11-28 7:52 ` Sascha Hauer
2024-11-28 8:00 ` Ahmad Fatoum
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=Z0gdl5vSvNaLYqXP@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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