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:52:18 +0100 [thread overview]
Message-ID: <Z0ghMlm823LThfJF@pengutronix.de> (raw)
In-Reply-To: <f7b07b73-65cc-4e8a-ac78-acff92aa2387@pengutronix.de>
On Thu, Nov 28, 2024 at 08:43:12AM +0100, Ahmad Fatoum wrote:
> On 28.11.24 08:36, Sascha Hauer wrote:
> > 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".
>
> I wanted to avoid the CONFIG_PRINTF_HEXSTR dependency.
CONFIG_PRINTF_HEXSTR is for printing hexdumps using printf.
MAC address printing is compiled in unconditionally (and must be,
because the ethernet code is using it).
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:52 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
2024-11-28 7:43 ` Ahmad Fatoum
2024-11-28 7:52 ` Sascha Hauer [this message]
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=Z0ghMlm823LThfJF@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