* [PATCH] ethtool: RX NFC - Convert ip address to big endian.
@ 2011-08-15 15:40 nirmu
2011-08-15 16:00 ` Ben Hutchings
0 siblings, 1 reply; 2+ messages in thread
From: nirmu @ 2011-08-15 15:40 UTC (permalink / raw)
To: bhutchings; +Cc: netdev, Nir Muchtar, Nir Muchtar
From: Nir Muchtar <nirmu@dev.mellanox.co.il>
Signed-off-by: Nir Muchtar <nirmu@mellanox.com>
---
Unless there's a reason that I'm missing to why the user
is expected to specify ip addresses in big endian format.
rxclass.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/rxclass.c b/rxclass.c
index b227901..98d035b 100644
--- a/rxclass.c
+++ b/rxclass.c
@@ -704,7 +704,7 @@ static int rxclass_get_ulong(char *str, unsigned long long *val, int size)
return 0;
}
-static int rxclass_get_ipv4(char *str, __be32 *val)
+static int rxclass_get_ipv4(char *str, u32 *val)
{
if (!inet_pton(AF_INET, str, val))
return -1;
@@ -828,11 +828,11 @@ static int rxclass_get_val(char *str, unsigned char *p, u32 *flags,
break;
}
case OPT_IP4: {
- __be32 val;
+ u32 val;
err = rxclass_get_ipv4(str, &val);
if (err)
return -1;
- *(__be32 *)&p[opt->offset] = val;
+ *(__be32 *)&p[opt->offset] = htonl((u32)val);
if (opt->moffset >= 0)
*(__be32 *)&p[opt->moffset] = (__be32)mask;
break;
@@ -929,11 +929,11 @@ static int rxclass_get_mask(char *str, unsigned char *p,
break;
}
case OPT_IP4: {
- __be32 val;
+ u32 val;
err = rxclass_get_ipv4(str, &val);
if (err)
return -1;
- *(__be32 *)&p[opt->moffset] = ~val;
+ *(__be32 *)&p[opt->moffset] = ~htonl((u32)val);
break;
}
case OPT_MAC: {
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ethtool: RX NFC - Convert ip address to big endian.
2011-08-15 15:40 [PATCH] ethtool: RX NFC - Convert ip address to big endian nirmu
@ 2011-08-15 16:00 ` Ben Hutchings
0 siblings, 0 replies; 2+ messages in thread
From: Ben Hutchings @ 2011-08-15 16:00 UTC (permalink / raw)
To: nirmu; +Cc: netdev, Nir Muchtar
On Mon, 2011-08-15 at 18:40 +0300, nirmu@dev.mellanox.co.il wrote:
> From: Nir Muchtar <nirmu@dev.mellanox.co.il>
>
> Signed-off-by: Nir Muchtar <nirmu@mellanox.com>
> ---
> Unless there's a reason that I'm missing to why the user
> is expected to specify ip addresses in big endian format.
>
> rxclass.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/rxclass.c b/rxclass.c
> index b227901..98d035b 100644
> --- a/rxclass.c
> +++ b/rxclass.c
> @@ -704,7 +704,7 @@ static int rxclass_get_ulong(char *str, unsigned long long *val, int size)
> return 0;
> }
>
> -static int rxclass_get_ipv4(char *str, __be32 *val)
> +static int rxclass_get_ipv4(char *str, u32 *val)
> {
> if (!inet_pton(AF_INET, str, val))
> return -1;
[...]
inet_pton() does the conversion to big-endian format.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-15 16:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-15 15:40 [PATCH] ethtool: RX NFC - Convert ip address to big endian nirmu
2011-08-15 16:00 ` Ben Hutchings
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).