X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=net%2Fbootp.c;h=4db63cbbe64c65dd6722d94b91b5e2fb9aeb863a;hb=bdb3c20386e0c3b80c1e5d2408ce567c1df1ca18;hp=0799ae2b0fc4a4f9103d21e6bd73c9cc64df3a91;hpb=81813cb01f509adceb52fa3130dd65f30288416c;p=oweals%2Fu-boot.git diff --git a/net/bootp.c b/net/bootp.c index 0799ae2b0f..4db63cbbe6 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -20,8 +20,6 @@ #define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */ -#if defined(CONFIG_CMD_NET) - #define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */ #ifndef CONFIG_NET_RETRY_COUNT # define TIMEOUT_COUNT 5 /* # of timeouts before giving up */ @@ -46,7 +44,8 @@ ulong seed1, seed2; dhcp_state_t dhcp_state = INIT; unsigned long dhcp_leasetime = 0; IPaddr_t NetDHCPServerIP = 0; -static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len); +static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, + unsigned len); /* For Debug */ #if 0 @@ -284,7 +283,8 @@ static void BootpVendorProcess (u8 * ext, int size) * Handle a BOOTP received packet. */ static void -BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len) +BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, + unsigned len) { Bootp_t *bp; char *s; @@ -458,11 +458,15 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R *e++ = 42; *cnt += 1; #endif + /* no options, so back up to avoid sending an empty request list */ + if (*cnt == 0) + e -= 2; + *e++ = 255; /* End of the list */ /* Pad to minimal length */ #ifdef CONFIG_DHCP_MIN_EXT_LEN - while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN) + while ((e - start) < CONFIG_DHCP_MIN_EXT_LEN) *e++ = 0; #endif @@ -683,6 +687,9 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp) { uchar *end = popt + BOOTP_HDR_SIZE; int oplen, size; +#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) + int *to_ptr; +#endif while (popt < end && *popt != 0xff) { oplen = *(popt + 1); @@ -692,7 +699,8 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp) break; #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) case 2: /* Time offset */ - NetCopyLong ((ulong *)&NetTimeOffset, (ulong *) (popt + 2)); + to_ptr = &NetTimeOffset; + NetCopyLong ((ulong *)to_ptr, (ulong *)(popt + 2)); NetTimeOffset = ntohl (NetTimeOffset); break; #endif @@ -852,7 +860,8 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer) * Handle DHCP received packets. */ static void -DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len) +DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, + unsigned len) { Bootp_t *bp = (Bootp_t *)pkt; @@ -944,5 +953,3 @@ void DhcpRequest(void) BootpRequest(); } #endif /* CONFIG_CMD_DHCP */ - -#endif /* CONFIG_CMD_NET */