# 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);