From: Robert Schwebel Date: Thu, 6 Mar 2003 13:31:01 +0100 Subject: [U-Boot-Users] [PATCH] 2/9: bootp Message-ID: <20030306123101.GO16290@pengutronix.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de BOOTP ===== - bug: when accessing data inside a network packet you must use NetCopyIP. When accessing data directly via pointers you can be biten by the processor's 32 bit alignment. Robert -- Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Braunschweiger Str. 79, 31134 Hildesheim, Germany Handelsregister: Amtsgericht Hildesheim, HRA 2686 Phone: +49-5121-28619-0 | Fax: +49-5121-28619-4 -------------- next part -------------- diff -urN -x CVS -x ptx-patches -x logfile -x logfile1 u-boot/net/bootp.c u-boot-ptx/net/bootp.c --- u-boot/net/bootp.c 2002-09-28 01:19:37.000000000 +0200 +++ u-boot-ptx/net/bootp.c 2003-02-11 19:42:44.000000000 +0100 @@ -8,10 +8,11 @@ * Copyright 2000-2002 Wolfgang Denk, wd at denx.de */ -#if 0 -#define DEBUG 1 /* general debug */ -#define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */ -#endif +//#define DEBUG 1 /* general debug */ +//#define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */ +#undef DEBUG +#undef DEBUG_BOOTP_EXT + #ifdef DEBUG_BOOTP_EXT #define debug_ext(fmt,args...) printf (fmt ,##args) @@ -752,8 +753,10 @@ volatile uchar *pkt, *iphdr; Bootp_t *bp; int pktlen, iplen, extlen; + IPaddr_t OfferedIP; debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n"); + pkt = NetTxPacket; memset ((void*)pkt, 0, PKTSIZE); @@ -784,13 +787,16 @@ /* * Copy options from OFFER packet if present */ - extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST, NetServerIP, bp->bp_yiaddr); + + NetCopyIP(&OfferedIP, &bp->bp_yiaddr); + extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST, NetServerIP, OfferedIP); pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen; iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen; NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen); + NetSendPacket(NetTxPacket, pktlen); }