mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Cleaning up printouts for debugging of uIP
This commit is contained in:
+1
-1
@@ -94,7 +94,6 @@ uip_neighbor_add(uip_ipaddr_t ipaddr, __xdata struct uip_neighbor_addr *addr)
|
||||
printf("Adding neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
addr->addr.addr[0], addr->addr.addr[1], addr->addr.addr[2], addr->addr.addr[3],
|
||||
addr->addr.addr[4], addr->addr.addr[5]);
|
||||
*/
|
||||
print_string("Adding neighbor with link address ");
|
||||
print_byte(addr->addr.addr[0]); write_char(':');
|
||||
print_byte(addr->addr.addr[1]); write_char(':');
|
||||
@@ -103,6 +102,7 @@ uip_neighbor_add(uip_ipaddr_t ipaddr, __xdata struct uip_neighbor_addr *addr)
|
||||
print_byte(addr->addr.addr[4]); write_char(':');
|
||||
print_byte(addr->addr.addr[5]); write_char(':');
|
||||
write_char('\n');
|
||||
*/
|
||||
|
||||
/* Find the first unused entry or the oldest used entry. */
|
||||
oldest_time = 0;
|
||||
|
||||
@@ -368,8 +368,9 @@ uip_udpchksum(void)
|
||||
#endif /* UIP_ARCH_CHKSUM */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_init(void)
|
||||
uip_init(void) __banked
|
||||
{
|
||||
uint8_t c;
|
||||
for(c = 0; c < UIP_LISTENPORTS; ++c) {
|
||||
uip_listenports[c] = 0;
|
||||
}
|
||||
@@ -801,6 +802,7 @@ uip_process(u8_t flag) __banked
|
||||
}
|
||||
goto drop;
|
||||
}
|
||||
|
||||
#if UIP_UDP
|
||||
if(flag == UIP_UDP_TIMER) {
|
||||
if(uip_udp_conn->lport != 0) {
|
||||
@@ -816,7 +818,6 @@ uip_process(u8_t flag) __banked
|
||||
}
|
||||
#endif
|
||||
|
||||
print_string("R1\n");
|
||||
/* This is where the input processing starts. */
|
||||
UIP_STAT(++uip_stat.ip.recv);
|
||||
|
||||
@@ -832,7 +833,6 @@ uip_process(u8_t flag) __banked
|
||||
}
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
/* Check validity of the IP header. */
|
||||
print_string("R2: "); print_byte(BUF->vhl); write_char('\n');
|
||||
if(BUF->vhl != 0x45) { /* IP version and header length. */
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
UIP_STAT(++uip_stat.ip.vhlerr);
|
||||
@@ -840,7 +840,6 @@ uip_process(u8_t flag) __banked
|
||||
goto drop;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
print_string("R2a\n");
|
||||
/* Check the size of the packet. If the size reported to us in
|
||||
uip_len is smaller the size reported in the IP header, we assume
|
||||
that the packet has been corrupted in transit. If the size of
|
||||
@@ -849,7 +848,6 @@ uip_process(u8_t flag) __banked
|
||||
value.. */
|
||||
|
||||
if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
|
||||
print_string("R2b\n");
|
||||
uip_len = (BUF->len[0] << 8) + BUF->len[1];
|
||||
#if UIP_CONF_IPV6
|
||||
uip_len += 40; /* The length reported in the IPv6 header is the
|
||||
@@ -885,7 +883,6 @@ uip_process(u8_t flag) __banked
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
print_string("R2b\n");
|
||||
if(uip_ipaddr_cmpc(uip_hostaddr, all_zeroes_addr)) {
|
||||
/* If we are configured to use ping IP address configuration and
|
||||
hasn't been assigned an IP address yet, we accept all ICMP
|
||||
@@ -980,7 +977,6 @@ uip_process(u8_t flag) __banked
|
||||
goto drop;
|
||||
}
|
||||
|
||||
print_string("IS ICMP\n");
|
||||
/* If we are configured to use ping IP address assignment, we use
|
||||
the destination IP address of this ping packet and assign it to
|
||||
ourself. */
|
||||
@@ -1867,7 +1863,6 @@ uip_process(u8_t flag) __banked
|
||||
/* Return and let the caller do the actual transmission. */
|
||||
uip_flags = 0;
|
||||
|
||||
print_string("uip_process done");
|
||||
return;
|
||||
drop:
|
||||
uip_len = 0;
|
||||
|
||||
@@ -185,7 +185,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
||||
* This function should be called at boot up to initilize the uIP
|
||||
* TCP/IP stack.
|
||||
*/
|
||||
void uip_init(void);
|
||||
void uip_init(void) __banked;
|
||||
|
||||
/**
|
||||
* uIP initialization function.
|
||||
|
||||
+1
-26
@@ -185,7 +185,6 @@ uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr)
|
||||
/* Check if the source IP address of the incoming packet matches
|
||||
the IP address in this ARP table entry. */
|
||||
if(ipaddr[0] == arp_table[i].ipaddr[0] && ipaddr[1] == arp_table[i].ipaddr[1]) {
|
||||
print_string("Updating: "); print_short(ipaddr[0]); print_short(ipaddr[1]); write_char('\n');
|
||||
/* An old entry found, update this and return. */
|
||||
memcpy(arp_table[i].ethaddr.addr, ethaddr->addr, 6);
|
||||
arp_table[i].time = arptime;
|
||||
@@ -198,7 +197,6 @@ uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr)
|
||||
/* If we get here, no existing ARP table entry was found, so we
|
||||
create one. */
|
||||
|
||||
print_string("No entry yet for: "); print_short(ipaddr[1]); write_char('\n');
|
||||
/* First, we try to find an unused entry in the ARP table. */
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
if(arp_table[i].ipaddr[0] == 0 && arp_table[i].ipaddr[1] == 0)
|
||||
@@ -219,8 +217,6 @@ uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr)
|
||||
i = c;
|
||||
}
|
||||
|
||||
print_string("Setting entry "); print_short(ipaddr[0]); print_short(ipaddr[1]); write_char('>');
|
||||
print_byte(arp_table[i].ethaddr.addr[0]); write_char(':'); print_byte(arp_table[i].ethaddr.addr[1]);
|
||||
/* Now, i is the ARP table entry which we will fill with the new
|
||||
information. */
|
||||
memcpy(arp_table[i].ipaddr, ipaddr, 4);
|
||||
@@ -289,25 +285,14 @@ void
|
||||
uip_arp_arpin(void) __banked
|
||||
{
|
||||
|
||||
print_string("uip_arp_arpin called");
|
||||
if(uip_len < sizeof(struct arp_hdr_i)) {
|
||||
uip_len = 0;
|
||||
return;
|
||||
}
|
||||
uip_len = 0;
|
||||
|
||||
print_string("ARP opcode: ");
|
||||
print_short((uint16_t)(&BUF->opcode)); write_char(' '); print_short((uint16_t)(&BUF->protolen)); write_char(' '); print_short((uint16_t)(&uip_buf[0]));write_char(' ');
|
||||
print_short((uint16_t)(&(BUF->shwaddr.addr[0]))); write_char(' ');
|
||||
print_short(BUF->hwtype); write_char(' ');
|
||||
print_short(BUF->protocol); write_char(' ');
|
||||
print_byte(BUF->hwlen); write_char(' ');
|
||||
print_byte(BUF->protolen); write_char(' ');
|
||||
print_short(BUF->opcode); write_char(' ');
|
||||
print_byte(BUF->shwaddr.addr[0]); write_char('\n');
|
||||
switch(BUF->opcode) {
|
||||
case HTONS(ARP_REQUEST):
|
||||
print_string("Is ARP_REQUEST\n");
|
||||
/* ARP request. If it asked for our address, we send out a
|
||||
reply. */
|
||||
if(uip_ipaddr_cmpx(BUF->dipaddr, uip_hostaddr)) {
|
||||
@@ -334,7 +319,6 @@ uip_arp_arpin(void) __banked
|
||||
}
|
||||
break;
|
||||
case HTONS(ARP_REPLY):
|
||||
print_string("Is ARP_REPLY\n");
|
||||
/* ARP reply. We insert or update the ARP table if it was meant
|
||||
for us. */
|
||||
if(uip_ipaddr_cmpx(BUF->dipaddr, uip_hostaddr)) {
|
||||
@@ -379,7 +363,6 @@ uip_arp_out(void) __banked
|
||||
__xdata struct arp_entry *tabptr;
|
||||
uint8_t i;
|
||||
|
||||
print_string("uip_arp_arout called, dest "); print_short(IPBUF->destipaddr[0]); print_short(IPBUF->destipaddr[1]); write_char('\n');
|
||||
/* Find the destination IP address in the ARP table and construct
|
||||
the Ethernet header. If the destination IP addres isn't on the
|
||||
local network, we use the default router's IP address instead.
|
||||
@@ -389,24 +372,19 @@ uip_arp_out(void) __banked
|
||||
|
||||
/* First check if destination is a local broadcast. */
|
||||
if(uip_ipaddr_cmpc(IPBUF->destipaddr, broadcast_ipaddr)) {
|
||||
print_string("local broadcast\n");
|
||||
memcpyc(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
||||
} else {
|
||||
write_char('S');
|
||||
/* Check if the destination address is on the local network. */
|
||||
if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
|
||||
write_char('T');
|
||||
/* Destination address was not on the local network, so we need to
|
||||
use the default router's IP address instead of the destination
|
||||
address when determining the MAC address. */
|
||||
uip_ipaddr_copy(ipaddr, uip_draddr);
|
||||
} else {
|
||||
write_char('U');
|
||||
/* Else, we use the destination IP address. */
|
||||
uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
|
||||
}
|
||||
|
||||
write_char('V');
|
||||
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(uip_ipaddr_cmpx(ipaddr, tabptr->ipaddr)) {
|
||||
@@ -415,7 +393,6 @@ uip_arp_out(void) __banked
|
||||
}
|
||||
|
||||
if(i == UIP_ARPTAB_SIZE) {
|
||||
write_char('W');
|
||||
/* The destination address was not in our ARP table, so we
|
||||
overwrite the IP packet with an ARP request. */
|
||||
|
||||
@@ -441,13 +418,11 @@ uip_arp_out(void) __banked
|
||||
|
||||
/* Build an ethernet header. */
|
||||
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
||||
write_char('X');
|
||||
}
|
||||
memcpyc(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
||||
|
||||
write_char('Y');
|
||||
uip_len += sizeof(struct uip_eth_hdr);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user