9
0
Fork 0

replace ET_DEBUG with pr_debug

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2010-01-04 15:58:55 +01:00
parent b407cda60b
commit 8f0d0f25ed
3 changed files with 25 additions and 50 deletions

View File

@ -153,9 +153,8 @@ void ArpRequest (void)
uchar *pkt; uchar *pkt;
ARP_t *arp; ARP_t *arp;
#ifdef ET_DEBUG pr_debug("ARP broadcast\n");
printf ("ARP broadcast\n");
#endif
pkt = NetTxPacket; pkt = NetTxPacket;
pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP); pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
@ -379,10 +378,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
/* if MAC address was not discovered yet, save the packet and do an ARP request */ /* if MAC address was not discovered yet, save the packet and do an ARP request */
if (memcmp(ether, NetEtherNullAddr, 6) == 0) { if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
pr_debug("sending ARP for %08lx\n", dest);
#ifdef ET_DEBUG
printf("sending ARP for %08lx\n", dest);
#endif
NetArpWaitPacketIP = dest; NetArpWaitPacketIP = dest;
NetArpWaitPacketMAC = ether; NetArpWaitPacketMAC = ether;
@ -401,10 +398,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
return 1; /* waiting */ return 1; /* waiting */
} }
#ifdef ET_DEBUG pr_debug("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]); dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]);
#endif
pkt = (uchar *)NetTxPacket; pkt = (uchar *)NetTxPacket;
pkt += NetSetEther (pkt, ether, PROT_IP); pkt += NetSetEther (pkt, ether, PROT_IP);
@ -425,9 +420,7 @@ NetReceive(uchar * inpkt, int len)
uchar *pkt; uchar *pkt;
ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid; ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid;
#ifdef ET_DEBUG pr_debug("packet received\n");
printf("packet received\n");
#endif
NetRxPkt = inpkt; NetRxPkt = inpkt;
NetRxPktLen = len; NetRxPktLen = len;
@ -446,9 +439,7 @@ NetReceive(uchar * inpkt, int len)
x = ntohs(et->et_protlen); x = ntohs(et->et_protlen);
#ifdef ET_DEBUG pr_debug("packet received\n");
printf("packet received\n");
#endif
if (x < 1514) { if (x < 1514) {
/* /*
@ -466,9 +457,8 @@ NetReceive(uchar * inpkt, int len)
} else { /* VLAN packet */ } else { /* VLAN packet */
VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)et; VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)et;
#ifdef ET_DEBUG pr_debug("VLAN packet received\n");
printf("VLAN packet received\n");
#endif
/* too small packet? */ /* too small packet? */
if (len < VLAN_ETHER_HDR_SIZE) if (len < VLAN_ETHER_HDR_SIZE)
return; return;
@ -486,9 +476,7 @@ NetReceive(uchar * inpkt, int len)
len -= VLAN_ETHER_HDR_SIZE; len -= VLAN_ETHER_HDR_SIZE;
} }
#ifdef ET_DEBUG pr_debug("Receive from protocol 0x%x\n", x);
printf("Receive from protocol 0x%x\n", x);
#endif
if ((myvlanid & VLAN_IDMASK) != VLAN_NONE) { if ((myvlanid & VLAN_IDMASK) != VLAN_NONE) {
if (vlanid == VLAN_NONE) if (vlanid == VLAN_NONE)
@ -510,9 +498,8 @@ NetReceive(uchar * inpkt, int len)
* address; so if we receive such a packet, we set * address; so if we receive such a packet, we set
* the server ethernet address * the server ethernet address
*/ */
#ifdef ET_DEBUG pr_debug("Got ARP\n");
puts ("Got ARP\n");
#endif
arp = (ARP_t *)ip; arp = (ARP_t *)ip;
if (len < ARP_HDR_SIZE) { if (len < ARP_HDR_SIZE) {
printf("bad length %d < %d\n", len, ARP_HDR_SIZE); printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
@ -541,9 +528,8 @@ NetReceive(uchar * inpkt, int len)
switch (ntohs(arp->ar_op)) { switch (ntohs(arp->ar_op)) {
case ARPOP_REQUEST: /* reply with our IP address */ case ARPOP_REQUEST: /* reply with our IP address */
#ifdef ET_DEBUG pr_debug("Got ARP REQUEST, return our IP\n");
puts ("Got ARP REQUEST, return our IP\n");
#endif
pkt = (uchar *)et; pkt = (uchar *)et;
pkt += NetSetEther(pkt, et->et_src, PROT_ARP); pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
arp->ar_op = htons(ARPOP_REPLY); arp->ar_op = htons(ARPOP_REPLY);
@ -559,20 +545,17 @@ NetReceive(uchar * inpkt, int len)
/* are we waiting for a reply */ /* are we waiting for a reply */
if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC) if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC)
break; break;
#ifdef ET_DEBUG pr_debug("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n",
printf("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n",
arp->ar_data[0], arp->ar_data[1], arp->ar_data[0], arp->ar_data[1],
arp->ar_data[2], arp->ar_data[3], arp->ar_data[2], arp->ar_data[3],
arp->ar_data[4], arp->ar_data[5]); arp->ar_data[4], arp->ar_data[5]);
#endif
tmp = NetReadIP(&arp->ar_data[6]); tmp = NetReadIP(&arp->ar_data[6]);
/* matched waiting packet's address */ /* matched waiting packet's address */
if (tmp == NetArpWaitReplyIP) { if (tmp == NetArpWaitReplyIP) {
#ifdef ET_DEBUG pr_debug("Got it\n");
puts ("Got it\n");
#endif
/* save address for later use */ /* save address for later use */
memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6); memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
@ -588,17 +571,14 @@ NetReceive(uchar * inpkt, int len)
} }
return; return;
default: default:
#ifdef ET_DEBUG pr_debug("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
printf("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
#endif
return; return;
} }
break; break;
case PROT_RARP: case PROT_RARP:
#ifdef ET_DEBUG pr_debug("Got RARP\n");
puts ("Got RARP\n");
#endif
arp = (ARP_t *)ip; arp = (ARP_t *)ip;
if (len < ARP_HDR_SIZE) { if (len < ARP_HDR_SIZE) {
printf("bad length %d < %d\n", len, ARP_HDR_SIZE); printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
@ -622,9 +602,8 @@ NetReceive(uchar * inpkt, int len)
break; break;
case PROT_IP: case PROT_IP:
#ifdef ET_DEBUG pr_debug("Got IP\n");
puts ("Got IP\n");
#endif
if (len < IP_HDR_SIZE) { if (len < IP_HDR_SIZE) {
debug ("len bad %d < %d\n", len, IP_HDR_SIZE); debug ("len bad %d < %d\n", len, IP_HDR_SIZE);
return; return;
@ -634,9 +613,9 @@ NetReceive(uchar * inpkt, int len)
return; return;
} }
len = ntohs(ip->ip_len); len = ntohs(ip->ip_len);
#ifdef ET_DEBUG
printf("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff); pr_debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
#endif
if ((ip->ip_hl_v & 0xf0) != 0x40) { if ((ip->ip_hl_v & 0xf0) != 0x40) {
return; return;
} }

View File

@ -18,9 +18,7 @@ static int PingSend(void)
memcpy(mac, NetEtherNullAddr, 6); memcpy(mac, NetEtherNullAddr, 6);
#ifdef ET_DEBUG pr_debug("sending ARP for %08lx\n", NetPingIP);
printf("sending ARP for %08lx\n", NetPingIP);
#endif
NetArpWaitPacketIP = NetPingIP; NetArpWaitPacketIP = NetPingIP;
NetArpWaitPacketMAC = mac; NetArpWaitPacketMAC = mac;

View File

@ -15,8 +15,6 @@
#include <fcntl.h> #include <fcntl.h>
#include "tftp.h" #include "tftp.h"
#undef ET_DEBUG
#define WELL_KNOWN_PORT 69 /* Well known TFTP port # */ #define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
#define TIMEOUT 5 /* Seconds to timeout for a lost pkt */ #define TIMEOUT 5 /* Seconds to timeout for a lost pkt */
# define TIMEOUT_COUNT 10 /* # of timeouts before giving up */ # define TIMEOUT_COUNT 10 /* # of timeouts before giving up */