include $(TOPDIR)/config.mk
-# CFLAGS += -DET_DEBUG -DDEBUG
+# CFLAGS += -DDEBUG
LIB = $(obj)libnet.a
* 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 <command.h>
#include <net.h>
retval = -6;
}
- debug ("Filtering pkt = %d\n", retval);
+ debug("Filtering pkt = %d\n", retval);
return retval;
}
if (strlen(bp->bp_file) > 0)
copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
- debug ("Bootfile: %s\n", BootFile);
+ debug("Bootfile: %s\n", BootFile);
/* Propagate to environment:
* don't delete exising entry when BOOTP / DHCP reply does
{
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));
NetBootFileSize = 0;
{
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)) {
if (*ext == 0) {
}
}
-#ifdef DEBUG_BOOTP_EXT
- puts ("[BOOTP] Received fields: \n");
+ debug("[BOOTP] Received fields: \n");
if (NetOurSubnetMask)
- printf ("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
+ debug("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
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.
Bootp_t *bp;
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));
bp = (Bootp_t *)pkt;
NetSetTimeout(0, (thand_f *)0);
- debug ("Got good BOOTP\n");
+ debug("Got good BOOTP\n");
if ((s = getenv("autoload")) != NULL) {
if (*s == 'n') {
/* get our mac */
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 */
tst1=0;
int pktlen, iplen, extlen;
IPaddr_t OfferedIP;
- debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
+ debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
pkt = NetTxPacket;
memset ((void*)pkt, 0, PKTSIZE);
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);
+ debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
{
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);
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
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);
switch (dhcp_state) {
* If filename is in format we recognize, assume it is a valid
* 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
if (strncmp(bp->bp_file,
CONFIG_SYS_BOOTFILE_PREFIX,
strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) {
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
- debug ("TRANSITIONING TO REQUESTING STATE\n");
+ debug("TRANSITIONING TO REQUESTING STATE\n");
dhcp_state = REQUESTING;
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
return;
break;
case REQUESTING:
- debug ("DHCP State: REQUESTING\n");
+ debug("DHCP State: REQUESTING\n");
if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
char *s;
struct eth_device *dev;
unsigned char enetaddr[6];
- debug ("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr);
+ debug("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr);
if (!eth_devices)
return;
return;
}
- debug ( "Setting new HW address on %s\n"
+ debug("Setting new HW address on %s\n"
"New Address is %pM\n",
dev->name, enetaddr);
old_current = eth_current;
do {
- debug ("Trying %s\n", eth_current->name);
+ debug("Trying %s\n", eth_current->name);
if (eth_current->init(eth_current,bis) >= 0) {
eth_current->state = ETH_STATE_ACTIVE;
return 0;
}
- debug ("FAIL\n");
+ debug("FAIL\n");
eth_try_another(0);
} while (old_current != eth_current);
# define ARP_TIMEOUT_COUNT CONFIG_NET_RETRY_COUNT
#endif
-#if 0
-#define ET_DEBUG
-#endif
-
/** BOOTP EXTENTIONS **/
IPaddr_t NetOurSubnetMask=0; /* Our subnet mask (0=unknown) */
volatile uchar *pkt;
ARP_t *arp;
-#ifdef ET_DEBUG
- printf ("ARP broadcast %d\n", NetArpWaitTry);
-#endif
+ debug("ARP broadcast %d\n", NetArpWaitTry);
+
pkt = NetTxPacket;
pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
/* if MAC address was not discovered yet, save the packet and do an ARP request */
if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
-#ifdef ET_DEBUG
- printf("sending ARP for %08lx\n", dest);
-#endif
+ debug("sending ARP for %08lx\n", dest);
+
NetArpWaitPacketIP = dest;
NetArpWaitPacketMAC = ether;
return 1; /* waiting */
}
-#ifdef ET_DEBUG
- printf("sending UDP to %08lx/%pM\n", dest, ether);
-#endif
+ debug("sending UDP to %08lx/%pM\n", dest, ether);
pkt = (uchar *)NetTxPacket;
pkt += NetSetEther (pkt, ether, PROT_IP);
memcpy(mac, NetEtherNullAddr, 6);
-#ifdef ET_DEBUG
- printf("sending ARP for %08lx\n", NetPingIP);
-#endif
+ debug("sending ARP for %08lx\n", NetPingIP);
NetArpWaitPacketIP = NetPingIP;
NetArpWaitPacketMAC = mac;
#endif
ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid;
-#ifdef ET_DEBUG
- printf("packet received\n");
-#endif
+ debug("packet received\n");
NetRxPacket = inpkt;
NetRxPacketLen = len;
x = ntohs(et->et_protlen);
-#ifdef ET_DEBUG
- printf("packet received\n");
-#endif
+ debug("packet received\n");
if (x < 1514) {
/*
} else { /* VLAN packet */
VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)et;
-#ifdef ET_DEBUG
- printf("VLAN packet received\n");
-#endif
+ debug("VLAN packet received\n");
+
/* too small packet? */
if (len < VLAN_ETHER_HDR_SIZE)
return;
len -= VLAN_ETHER_HDR_SIZE;
}
-#ifdef ET_DEBUG
- printf("Receive from protocol 0x%x\n", x);
-#endif
+ debug("Receive from protocol 0x%x\n", x);
#if defined(CONFIG_CMD_CDP)
if (iscdp) {
* address; so if we receive such a packet, we set
* the server ethernet address
*/
-#ifdef ET_DEBUG
- puts ("Got ARP\n");
-#endif
+ debug("Got ARP\n");
+
arp = (ARP_t *)ip;
if (len < ARP_HDR_SIZE) {
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
switch (ntohs(arp->ar_op)) {
case ARPOP_REQUEST: /* reply with our IP address */
-#ifdef ET_DEBUG
- puts ("Got ARP REQUEST, return our IP\n");
-#endif
+ debug("Got ARP REQUEST, return our IP\n");
pkt = (uchar *)et;
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
arp->ar_op = htons(ARPOP_REPLY);
}
#endif
-#ifdef ET_DEBUG
- printf("Got ARP REPLY, set server/gtwy eth addr (%pM)\n",
+ debug("Got ARP REPLY, set server/gtwy eth addr (%pM)\n",
arp->ar_data);
-#endif
tmp = NetReadIP(&arp->ar_data[6]);
/* matched waiting packet's address */
if (tmp == NetArpWaitReplyIP) {
-#ifdef ET_DEBUG
- puts ("Got it\n");
-#endif
+ debug("Got it\n");
/* save address for later use */
memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
}
return;
default:
-#ifdef ET_DEBUG
- printf("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
-#endif
+ debug("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
return;
}
break;
case PROT_RARP:
-#ifdef ET_DEBUG
- puts ("Got RARP\n");
-#endif
+ debug("Got RARP\n");
arp = (ARP_t *)ip;
if (len < ARP_HDR_SIZE) {
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
break;
case PROT_IP:
-#ifdef ET_DEBUG
- puts ("Got IP\n");
-#endif
+ debug("Got IP\n");
if (len < IP_HDR_SIZE) {
- debug ("len bad %d < %lu\n", len, (ulong)IP_HDR_SIZE);
+ debug("len bad %d < %lu\n", len, (ulong)IP_HDR_SIZE);
return;
}
if (len < ntohs(ip->ip_len)) {
return;
}
len = ntohs(ip->ip_len);
-#ifdef ET_DEBUG
- printf("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
-#endif
+ debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
+
if ((ip->ip_hl_v & 0xf0) != 0x40) {
return;
}
(*packetHandler)((uchar *)ip, 0, 0, 0);
return;
case ICMP_ECHO_REQUEST:
-#ifdef ET_DEBUG
- printf ("Got ICMP ECHO REQUEST, return %d bytes \n",
+ debug("Got ICMP ECHO REQUEST, return %d bytes \n",
ETHER_HDR_SIZE + len);
-#endif
+
memcpy (&et->et_dest[0], &et->et_src[0], 6);
memcpy (&et->et_src[ 0], NetOurEther, 6);
#include "nfs.h"
#include "bootp.h"
-/*#define NFS_DEBUG*/
-
#if defined(CONFIG_CMD_NET) && defined(CONFIG_CMD_NFS)
#define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */
static void
NfsSend (void)
{
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
switch (NfsState) {
case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
memcpy ((unsigned char *)&rpc_pkt, pkt, len);
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
return -1;
{
struct rpc_t rpc_pkt;
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
memcpy ((unsigned char *)&rpc_pkt, pkt, len);
{
struct rpc_t rpc_pkt;
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
memcpy ((unsigned char *)&rpc_pkt, pkt, len);
{
struct rpc_t rpc_pkt;
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
memcpy ((unsigned char *)&rpc_pkt, pkt, len);
struct rpc_t rpc_pkt;
int rlen;
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
memcpy ((unsigned char *)&rpc_pkt, pkt, len);
struct rpc_t rpc_pkt;
int rlen;
-#ifdef NFS_DEBUG_nop
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
memcpy ((uchar *)&rpc_pkt, pkt, sizeof(rpc_pkt.u.reply));
{
int rlen;
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
if (dest != NfsOurPort) return;
NfsState = STATE_UMOUNT_REQ;
NfsSend ();
} else {
-#ifdef NFS_DEBUG
- printf ("Symlink --> %s\n", nfs_path);
-#endif
+ debug("Symlink --> %s\n", nfs_path);
nfs_filename = basename (nfs_path);
nfs_path = dirname (nfs_path);
void
NfsStart (void)
{
-#ifdef NFS_DEBUG
- printf ("%s\n", __FUNCTION__);
-#endif
+ debug("%s\n", __func__);
NfsDownloadState = NETLOOP_FAIL;
NfsServerIP = NetServerIP;
RarpHandler(uchar * dummi0, unsigned dummi1, unsigned dummi2, unsigned dummi3)
{
char *s;
-#ifdef DEBUG
- puts ("Got good RARP\n");
-#endif
+ debug("Got good RARP\n");
if ((s = getenv("autoload")) != NULL) {
if (*s == 'n') {
/*
int pktlen = SNTP_PACKET_LEN;
int sport;
- debug ("%s\n", __FUNCTION__);
+ debug("%s\n", __func__);
memset (&pkt, 0, sizeof(pkt));
struct rtc_time tm;
ulong seconds;
- debug ("%s\n", __FUNCTION__);
+ debug("%s\n", __func__);
if (dest != SntpOurPort) return;
void
SntpStart (void)
{
- debug ("%s\n", __FUNCTION__);
+ debug("%s\n", __func__);
NetSetTimeout (SNTP_TIMEOUT, SntpTimeout);
NetSetHandler(SntpHandler);
#include "tftp.h"
#include "bootp.h"
-#undef ET_DEBUG
-
#if defined(CONFIG_CMD_NET)
#define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
strcpy ((char *)pkt, "timeout");
pkt += 7 /*strlen("timeout")*/ + 1;
sprintf((char *)pkt, "%lu", TIMEOUT / 1000);
-#ifdef ET_DEBUG
- printf("send option \"timeout %s\"\n", (char *)pkt);
-#endif
+ debug("send option \"timeout %s\"\n", (char *)pkt);
pkt += strlen((char *)pkt) + 1;
/* try for more effic. blk size */
pkt += sprintf((char *)pkt,"blksize%c%d%c",
break;
case TFTP_OACK:
-#ifdef ET_DEBUG
- printf("Got OACK: %s %s\n", pkt, pkt+strlen(pkt)+1);
-#endif
+ debug("Got OACK: %s %s\n", pkt, pkt+strlen(pkt)+1);
TftpState = STATE_OACK;
TftpServerPort = src;
/*
if (strcmp ((char*)pkt+i,"blksize") == 0) {
TftpBlkSize = (unsigned short)
simple_strtoul((char*)pkt+i+8,NULL,10);
-#ifdef ET_DEBUG
- printf ("Blocksize ack: %s, %d\n",
+ debug("Blocksize ack: %s, %d\n",
(char*)pkt+i+8,TftpBlkSize);
-#endif
break;
}
}
}
}
-#ifdef ET_DEBUG
- if (TftpState == STATE_RRQ) {
- puts ("Server did not acknowledge timeout option!\n");
- }
-#endif
+ if (TftpState == STATE_RRQ)
+ debug("Server did not acknowledge timeout option!\n");
if (TftpState == STATE_RRQ || TftpState == STATE_OACK) {
/* first block received */