|
@@ -8,17 +8,6 @@
|
|
* Copyright 2000-2004 Wolfgang Denk, wd@denx.de
|
|
* Copyright 2000-2004 Wolfgang Denk, wd@denx.de
|
|
*/
|
|
*/
|
|
|
|
|
|
-#if 0
|
|
|
|
-#define DEBUG 1 /* general debug */
|
|
|
|
-#define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-#ifdef DEBUG_BOOTP_EXT
|
|
|
|
-#define debug_ext(fmt,args...) printf (fmt ,##args)
|
|
|
|
-#else
|
|
|
|
-#define debug_ext(fmt,args...)
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
#include <common.h>
|
|
#include <common.h>
|
|
#include <command.h>
|
|
#include <command.h>
|
|
#include <net.h>
|
|
#include <net.h>
|
|
@@ -107,7 +96,7 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
|
|
retval = -6;
|
|
retval = -6;
|
|
}
|
|
}
|
|
|
|
|
|
- debug ("Filtering pkt = %d\n", retval);
|
|
|
|
|
|
+ debug("Filtering pkt = %d\n", retval);
|
|
|
|
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
@@ -129,7 +118,7 @@ static void BootpCopyNetParams(Bootp_t *bp)
|
|
if (strlen(bp->bp_file) > 0)
|
|
if (strlen(bp->bp_file) > 0)
|
|
copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
|
|
copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
|
|
|
|
|
|
- debug ("Bootfile: %s\n", BootFile);
|
|
|
|
|
|
+ debug("Bootfile: %s\n", BootFile);
|
|
|
|
|
|
/* Propagate to environment:
|
|
/* Propagate to environment:
|
|
* don't delete exising entry when BOOTP / DHCP reply does
|
|
* don't delete exising entry when BOOTP / DHCP reply does
|
|
@@ -156,7 +145,7 @@ static void BootpVendorFieldProcess (u8 * ext)
|
|
{
|
|
{
|
|
int size = *(ext + 1);
|
|
int size = *(ext + 1);
|
|
|
|
|
|
- debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
|
|
|
|
|
|
+ debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
|
|
*(ext + 1));
|
|
*(ext + 1));
|
|
|
|
|
|
NetBootFileSize = 0;
|
|
NetBootFileSize = 0;
|
|
@@ -255,7 +244,7 @@ static void BootpVendorProcess (u8 * ext, int size)
|
|
{
|
|
{
|
|
u8 *end = ext + size;
|
|
u8 *end = ext + size;
|
|
|
|
|
|
- debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
|
|
|
|
|
|
+ debug("[BOOTP] Checking extension (%d bytes)...\n", size);
|
|
|
|
|
|
while ((ext < end) && (*ext != 0xff)) {
|
|
while ((ext < end) && (*ext != 0xff)) {
|
|
if (*ext == 0) {
|
|
if (*ext == 0) {
|
|
@@ -269,34 +258,27 @@ static void BootpVendorProcess (u8 * ext, int size)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef DEBUG_BOOTP_EXT
|
|
|
|
- puts ("[BOOTP] Received fields: \n");
|
|
|
|
|
|
+ debug("[BOOTP] Received fields: \n");
|
|
if (NetOurSubnetMask)
|
|
if (NetOurSubnetMask)
|
|
- printf ("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
|
|
|
|
|
|
+ debug("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
|
|
|
|
|
|
if (NetOurGatewayIP)
|
|
if (NetOurGatewayIP)
|
|
- printf ("NetOurGatewayIP : %pI4", &NetOurGatewayIP);
|
|
|
|
|
|
+ debug("NetOurGatewayIP : %pI4", &NetOurGatewayIP);
|
|
|
|
|
|
- if (NetBootFileSize) {
|
|
|
|
- printf ("NetBootFileSize : %d\n", NetBootFileSize);
|
|
|
|
- }
|
|
|
|
|
|
+ if (NetBootFileSize)
|
|
|
|
+ debug("NetBootFileSize : %d\n", NetBootFileSize);
|
|
|
|
|
|
- if (NetOurHostName[0]) {
|
|
|
|
- printf ("NetOurHostName : %s\n", NetOurHostName);
|
|
|
|
- }
|
|
|
|
|
|
+ if (NetOurHostName[0])
|
|
|
|
+ debug("NetOurHostName : %s\n", NetOurHostName);
|
|
|
|
|
|
- if (NetOurRootPath[0]) {
|
|
|
|
- printf ("NetOurRootPath : %s\n", NetOurRootPath);
|
|
|
|
- }
|
|
|
|
|
|
+ if (NetOurRootPath[0])
|
|
|
|
+ debug("NetOurRootPath : %s\n", NetOurRootPath);
|
|
|
|
|
|
- if (NetOurNISDomain[0]) {
|
|
|
|
- printf ("NetOurNISDomain : %s\n", NetOurNISDomain);
|
|
|
|
- }
|
|
|
|
|
|
+ if (NetOurNISDomain[0])
|
|
|
|
+ debug("NetOurNISDomain : %s\n", NetOurNISDomain);
|
|
|
|
|
|
- if (NetBootFileSize) {
|
|
|
|
- printf ("NetBootFileSize: %d\n", NetBootFileSize);
|
|
|
|
- }
|
|
|
|
-#endif /* DEBUG_BOOTP_EXT */
|
|
|
|
|
|
+ if (NetBootFileSize)
|
|
|
|
+ debug("NetBootFileSize: %d\n", NetBootFileSize);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* Handle a BOOTP received packet.
|
|
* Handle a BOOTP received packet.
|
|
@@ -307,7 +289,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
|
|
Bootp_t *bp;
|
|
Bootp_t *bp;
|
|
char *s;
|
|
char *s;
|
|
|
|
|
|
- debug ("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
|
|
|
|
|
|
+ debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
|
|
src, dest, len, sizeof (Bootp_t));
|
|
src, dest, len, sizeof (Bootp_t));
|
|
|
|
|
|
bp = (Bootp_t *)pkt;
|
|
bp = (Bootp_t *)pkt;
|
|
@@ -330,7 +312,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
|
|
|
|
|
|
NetSetTimeout(0, (thand_f *)0);
|
|
NetSetTimeout(0, (thand_f *)0);
|
|
|
|
|
|
- debug ("Got good BOOTP\n");
|
|
|
|
|
|
+ debug("Got good BOOTP\n");
|
|
|
|
|
|
if ((s = getenv("autoload")) != NULL) {
|
|
if ((s = getenv("autoload")) != NULL) {
|
|
if (*s == 'n') {
|
|
if (*s == 'n') {
|
|
@@ -579,14 +561,9 @@ BootpRequest (void)
|
|
/* get our mac */
|
|
/* get our mac */
|
|
eth_getenv_enetaddr("ethaddr", bi_enetaddr);
|
|
eth_getenv_enetaddr("ethaddr", bi_enetaddr);
|
|
|
|
|
|
-#ifdef DEBUG
|
|
|
|
- puts ("BootpRequest => Our Mac: ");
|
|
|
|
- for (reg=0; reg<6; reg++) {
|
|
|
|
- printf ("%x%c",
|
|
|
|
- bi_enetaddr[reg],
|
|
|
|
- reg==5 ? '\n' : ':');
|
|
|
|
- }
|
|
|
|
-#endif /* DEBUG */
|
|
|
|
|
|
+ debug("BootpRequest => Our Mac: ");
|
|
|
|
+ for (reg=0; reg<6; reg++)
|
|
|
|
+ debug("%x%c", bi_enetaddr[reg], reg==5 ? '\n' : ':');
|
|
|
|
|
|
/* Mac-Manipulation 2 get seed1 */
|
|
/* Mac-Manipulation 2 get seed1 */
|
|
tst1=0;
|
|
tst1=0;
|
|
@@ -820,7 +797,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
|
|
int pktlen, iplen, extlen;
|
|
int pktlen, iplen, extlen;
|
|
IPaddr_t OfferedIP;
|
|
IPaddr_t OfferedIP;
|
|
|
|
|
|
- debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
|
|
|
|
|
|
+ debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
|
|
pkt = NetTxPacket;
|
|
pkt = NetTxPacket;
|
|
memset ((void*)pkt, 0, PKTSIZE);
|
|
memset ((void*)pkt, 0, PKTSIZE);
|
|
|
|
|
|
@@ -864,7 +841,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
|
|
iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
|
|
iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
|
|
NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
|
|
NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
|
|
|
|
|
|
- debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
|
|
|
|
|
|
+ debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
|
|
#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
|
|
#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
|
|
udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
|
|
udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
|
|
#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
|
|
#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
|
|
@@ -879,13 +856,13 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
|
|
{
|
|
{
|
|
Bootp_t *bp = (Bootp_t *)pkt;
|
|
Bootp_t *bp = (Bootp_t *)pkt;
|
|
|
|
|
|
- debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
|
|
|
|
|
|
+ debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
|
|
src, dest, len, dhcp_state);
|
|
src, dest, len, dhcp_state);
|
|
|
|
|
|
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
|
|
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
|
|
return;
|
|
return;
|
|
|
|
|
|
- debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
|
|
|
|
|
|
+ debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
|
|
src, dest, len, dhcp_state);
|
|
src, dest, len, dhcp_state);
|
|
|
|
|
|
switch (dhcp_state) {
|
|
switch (dhcp_state) {
|
|
@@ -896,14 +873,14 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
|
|
* If filename is in format we recognize, assume it is a valid
|
|
* If filename is in format we recognize, assume it is a valid
|
|
* OFFER from a server we want.
|
|
* OFFER from a server we want.
|
|
*/
|
|
*/
|
|
- debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
|
|
|
|
|
|
+ debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
|
|
#ifdef CONFIG_SYS_BOOTFILE_PREFIX
|
|
#ifdef CONFIG_SYS_BOOTFILE_PREFIX
|
|
if (strncmp(bp->bp_file,
|
|
if (strncmp(bp->bp_file,
|
|
CONFIG_SYS_BOOTFILE_PREFIX,
|
|
CONFIG_SYS_BOOTFILE_PREFIX,
|
|
strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) {
|
|
strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) {
|
|
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
|
|
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
|
|
|
|
|
|
- debug ("TRANSITIONING TO REQUESTING STATE\n");
|
|
|
|
|
|
+ debug("TRANSITIONING TO REQUESTING STATE\n");
|
|
dhcp_state = REQUESTING;
|
|
dhcp_state = REQUESTING;
|
|
|
|
|
|
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
|
|
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
|
|
@@ -918,7 +895,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
|
|
return;
|
|
return;
|
|
break;
|
|
break;
|
|
case REQUESTING:
|
|
case REQUESTING:
|
|
- debug ("DHCP State: REQUESTING\n");
|
|
|
|
|
|
+ debug("DHCP State: REQUESTING\n");
|
|
|
|
|
|
if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
|
|
if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
|
|
char *s;
|
|
char *s;
|