* [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp
@ 2015-04-15 10:50 Michal Simek
2015-04-15 12:04 ` Thierry Reding
2015-04-15 13:45 ` Joe Hershberger
0 siblings, 2 replies; 4+ messages in thread
From: Michal Simek @ 2015-04-15 10:50 UTC (permalink / raw)
To: u-boot
From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Based on rfc951 transaction ID has 4 bytes which is not the case when
ulong type is used on ARM64.
Use u32 type which is well defined for all archs.
BOOTP_VENDOR_MAGIC is also 4 bytes.
Based on RFC1048 Time Offset (code 2) is also 4bytes long
and IP Address Lease Time also.
The patch converts NetCopyLong to netcopy32 and NetReadLong to netread32
to follow u-boot coding style.
Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
include/net.h | 14 +++++++-------
net/bootp.c | 18 +++++++++---------
net/bootp.h | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/include/net.h b/include/net.h
index 237c932be334..9b5f8249ddbb 100644
--- a/include/net.h
+++ b/include/net.h
@@ -607,12 +607,12 @@ static inline IPaddr_t NetReadIP(void *from)
return ip;
}
-/* return ulong *in network byteorder* */
-static inline ulong NetReadLong(ulong *from)
+/* return u32 *in network byteorder* */
+static inline u32 netread32(void *from)
{
- ulong l;
+ u32 l;
- memcpy((void *)&l, (void *)from, sizeof(l));
+ memcpy((void *)&l, from, sizeof(u32));
return l;
}
@@ -628,10 +628,10 @@ static inline void NetCopyIP(void *to, void *from)
memcpy((void *)to, from, sizeof(IPaddr_t));
}
-/* copy ulong */
-static inline void NetCopyLong(ulong *to, ulong *from)
+/* copy u32 */
+static inline void netcopy32(void *to, void *from)
{
- memcpy((void *)to, (void *)from, sizeof(ulong));
+ memcpy(to, from, sizeof(u32));
}
/**
diff --git a/net/bootp.c b/net/bootp.c
index 81066015f1c2..de0d587228df 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -125,7 +125,7 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
retval = -4;
else if (bp->bp_hlen != HWL_ETHER)
retval = -5;
- else if (!bootp_match_id(NetReadLong((ulong *)&bp->bp_id)))
+ else if (!bootp_match_id(netread32(&bp->bp_id)))
retval = -6;
debug("Filtering pkt = %d\n", retval);
@@ -350,7 +350,7 @@ BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
BootpCopyNetParams(bp); /* Store net parameters from reply */
/* Retrieve extended information (we must parse the vendor area) */
- if (NetReadLong((ulong *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
+ if (netread32(&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
BootpVendorProcess((uchar *)&bp->bp_vend[4], len);
NetSetTimeout(0, (thand_f *)0);
@@ -732,7 +732,7 @@ BootpRequest(void)
BootpID += get_timer(0);
BootpID = htonl(BootpID);
bootp_add_id(BootpID);
- NetCopyLong(&bp->bp_id, &BootpID);
+ netcopy32(&bp->bp_id, &BootpID);
/*
* Calculate proper packet lengths taking into account the
@@ -770,7 +770,7 @@ static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
case 2: /* Time offset */
to_ptr = &NetTimeOffset;
- NetCopyLong((ulong *)to_ptr, (ulong *)(popt + 2));
+ netcopy32(to_ptr, popt + 2);
NetTimeOffset = ntohl(NetTimeOffset);
break;
#endif
@@ -806,7 +806,7 @@ static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
break;
#endif
case 51:
- NetCopyLong(&dhcp_leasetime, (ulong *) (popt + 2));
+ netcopy32(&dhcp_leasetime, popt + 2);
break;
case 53: /* Ignore Message Type Option */
break;
@@ -860,7 +860,7 @@ static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
static int DhcpMessageType(unsigned char *popt)
{
- if (NetReadLong((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC))
+ if (netread32(popt) != htonl(BOOTP_VENDOR_MAGIC))
return -1;
popt += 4;
@@ -911,7 +911,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
* ID is the id of the OFFER packet
*/
- NetCopyLong(&bp->bp_id, &bp_offer->bp_id);
+ netcopy32(&bp->bp_id, &bp_offer->bp_id);
/*
* Copy options from OFFER packet if present
@@ -970,7 +970,7 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("TRANSITIONING TO REQUESTING STATE\n");
dhcp_state = REQUESTING;
- if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
+ if (netread32(&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
@@ -986,7 +986,7 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("DHCP State: REQUESTING\n");
if (DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK) {
- if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
+ if (netread32(&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
/* Store net params from reply */
diff --git a/net/bootp.h b/net/bootp.h
index 3b95a0a2ded8..cc71b2b56dec 100644
--- a/net/bootp.h
+++ b/net/bootp.h
@@ -38,7 +38,7 @@ struct Bootp_t {
uchar bp_hlen; /* Hardware address length */
# define HWL_ETHER 6
uchar bp_hops; /* Hop count (gateway thing) */
- ulong bp_id; /* Transaction ID */
+ u32 bp_id; /* Transaction ID */
ushort bp_secs; /* Seconds since boot */
ushort bp_spare1; /* Alignment */
IPaddr_t bp_ciaddr; /* Client IP address */
--
2.3.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp
2015-04-15 10:50 [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp Michal Simek
@ 2015-04-15 12:04 ` Thierry Reding
2015-04-15 13:45 ` Joe Hershberger
1 sibling, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2015-04-15 12:04 UTC (permalink / raw)
To: u-boot
On Wed, Apr 15, 2015 at 12:50:59PM +0200, Michal Simek wrote:
> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>
> Based on rfc951 transaction ID has 4 bytes which is not the case when
> ulong type is used on ARM64.
> Use u32 type which is well defined for all archs.
>
> BOOTP_VENDOR_MAGIC is also 4 bytes.
>
> Based on RFC1048 Time Offset (code 2) is also 4bytes long
> and IP Address Lease Time also.
>
> The patch converts NetCopyLong to netcopy32 and NetReadLong to netread32
> to follow u-boot coding style.
>
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> include/net.h | 14 +++++++-------
> net/bootp.c | 18 +++++++++---------
> net/bootp.h | 2 +-
> 3 files changed, 17 insertions(+), 17 deletions(-)
Looks reasonable to me:
Reviewed-by: Thierry Reding <treding@nvidia.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150415/415327c0/attachment.sig>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp
2015-04-15 10:50 [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp Michal Simek
2015-04-15 12:04 ` Thierry Reding
@ 2015-04-15 13:45 ` Joe Hershberger
2015-04-15 16:36 ` Michal Simek
1 sibling, 1 reply; 4+ messages in thread
From: Joe Hershberger @ 2015-04-15 13:45 UTC (permalink / raw)
To: u-boot
Hi Michal,
On Wed, Apr 15, 2015 at 5:50 AM, Michal Simek <michal.simek@xilinx.com>
wrote:
>
> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>
> Based on rfc951 transaction ID has 4 bytes which is not the case when
> ulong type is used on ARM64.
> Use u32 type which is well defined for all archs.
>
> BOOTP_VENDOR_MAGIC is also 4 bytes.
>
> Based on RFC1048 Time Offset (code 2) is also 4bytes long
> and IP Address Lease Time also.
>
> The patch converts NetCopyLong to netcopy32 and NetReadLong to netread32
> to follow u-boot coding style.
>
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This is a dup of https://patchwork.ozlabs.org/patch/459122/ which is
already included in a pull request here:
https://patchwork.ozlabs.org/patch/461424/
Thanks anyway,
-Joe
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp
2015-04-15 13:45 ` Joe Hershberger
@ 2015-04-15 16:36 ` Michal Simek
0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2015-04-15 16:36 UTC (permalink / raw)
To: u-boot
On 04/15/2015 03:45 PM, Joe Hershberger wrote:
> Hi Michal,
>
> On Wed, Apr 15, 2015 at 5:50 AM, Michal Simek <michal.simek@xilinx.com>
> wrote:
>>
>> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>>
>> Based on rfc951 transaction ID has 4 bytes which is not the case when
>> ulong type is used on ARM64.
>> Use u32 type which is well defined for all archs.
>>
>> BOOTP_VENDOR_MAGIC is also 4 bytes.
>>
>> Based on RFC1048 Time Offset (code 2) is also 4bytes long
>> and IP Address Lease Time also.
>>
>> The patch converts NetCopyLong to netcopy32 and NetReadLong to netread32
>> to follow u-boot coding style.
>>
>> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>
> This is a dup of https://patchwork.ozlabs.org/patch/459122/ which is
> already included in a pull request here:
> https://patchwork.ozlabs.org/patch/461424/
That's great.
Thanks,
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-15 16:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-15 10:50 [U-Boot] [PATCH] net: Use u32 instead of ulong for transaction ID in bootp Michal Simek
2015-04-15 12:04 ` Thierry Reding
2015-04-15 13:45 ` Joe Hershberger
2015-04-15 16:36 ` Michal Simek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.