diff options
author | Yizhou Jiang <yizhou.jiang@amlogic.com> | 2016-09-01 13:56:22 +0800 |
---|---|---|
committer | Xiaobo Gu <xiaobo.gu@amlogic.com> | 2016-09-20 02:07:45 -0700 |
commit | dd339fff99923bb33c7604c04090003dd569d35f (patch) | |
tree | 234b3cfe83ca41f168c72c46eda7f03b98db0540 /net | |
parent | 2ef42ee33a4d6fd13cd0745954e974283e788d16 (diff) | |
download | u-boot-odroid-c1-dd339fff99923bb33c7604c04090003dd569d35f.tar.gz |
PD#131379: eth: fix dhcp in uboot for 64-bit CPU
Change-Id: Id4efc5a2c819649eb5bb94bf45afcf71d3d0b96c
Diffstat (limited to 'net')
-rw-r--r-- | net/bootp.c | 21 | ||||
-rw-r--r-- | net/bootp.h | 2 |
2 files changed, 13 insertions, 10 deletions
diff --git a/net/bootp.c b/net/bootp.c index 81066015f1..2e89f7b8aa 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -59,7 +59,7 @@ ulong bootp_timeout; #if defined(CONFIG_CMD_DHCP) static dhcp_state_t dhcp_state = INIT; -static unsigned long dhcp_leasetime; +static unsigned int dhcp_leasetime; static IPaddr_t NetDHCPServerIP; static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len); @@ -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(NetReadLong((uint *)&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 (NetReadLong((uint *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) BootpVendorProcess((uchar *)&bp->bp_vend[4], len); NetSetTimeout(0, (thand_f *)0); @@ -661,7 +661,7 @@ BootpRequest(void) #ifdef CONFIG_BOOTP_RANDOM_DELAY ulong rand_ms; #endif - ulong BootpID; + uint BootpID; bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start"); #if defined(CONFIG_CMD_DHCP) @@ -730,8 +730,11 @@ BootpRequest(void) | ((ulong)NetOurEther[4] << 8) | (ulong)NetOurEther[5]; BootpID += get_timer(0); + BootpID = htonl(BootpID); + bootp_add_id(BootpID); + NetCopyLong(&bp->bp_id, &BootpID); /* @@ -770,7 +773,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)); + NetCopyLong((uint *)to_ptr, (uint *)(popt + 2)); NetTimeOffset = ntohl(NetTimeOffset); break; #endif @@ -806,7 +809,7 @@ static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp) break; #endif case 51: - NetCopyLong(&dhcp_leasetime, (ulong *) (popt + 2)); + NetCopyLong(&dhcp_leasetime, (uint *) (popt + 2)); break; case 53: /* Ignore Message Type Option */ break; @@ -860,7 +863,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 (NetReadLong((uint *)popt) != htonl(BOOTP_VENDOR_MAGIC)) return -1; popt += 4; @@ -970,7 +973,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 (NetReadLong((uint *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp); @@ -986,7 +989,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 (NetReadLong((uint *)&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 3b95a0a2de..c4b507d186 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 */ + uint bp_id; /* Transaction ID */ ushort bp_secs; /* Seconds since boot */ ushort bp_spare1; /* Alignment */ IPaddr_t bp_ciaddr; /* Client IP address */ |