Fixed stupid bug. I have no idea how I didn't run into this one for months ! The development platforms have 400-600 bytes buffer size. So every incoming 1500 packet overwrote ~ 1000 bytes of uIP variables. And this happens very easily as every packet coming in for the Windows IP stack is seen by uIP as well (and discarded because of the wrong IP address).

This commit is contained in:
oliverschmidt 2007-04-08 20:06:56 +00:00
parent 2d277b846c
commit 9cc1871810
2 changed files with 11 additions and 7 deletions

View file

@ -30,7 +30,7 @@
* *
* Author: Oliver Schmidt <ol.sc@web.de> * Author: Oliver Schmidt <ol.sc@web.de>
* *
* $Id: wpcap.c,v 1.4 2007/04/07 00:27:22 oliverschmidt Exp $ * $Id: wpcap.c,v 1.5 2007/04/08 20:06:56 oliverschmidt Exp $
*/ */
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -224,6 +224,10 @@ wpcap_poll(void)
return 0; return 0;
} }
if(packet_header->caplen > UIP_BUFSIZE) {
return 0;
}
CopyMemory(uip_buf, packet, packet_header->caplen); CopyMemory(uip_buf, packet, packet_header->caplen);
return (u16_t)packet_header->caplen; return (u16_t)packet_header->caplen;
} }

View file

@ -30,7 +30,7 @@
* *
* Author: Oliver Schmidt <ol.sc@web.de> * Author: Oliver Schmidt <ol.sc@web.de>
* *
* $Id: wpcap-service.c,v 1.7 2007/04/06 22:36:31 oliverschmidt Exp $ * $Id: wpcap-service.c,v 1.8 2007/04/08 20:09:11 oliverschmidt Exp $
*/ */
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -103,19 +103,19 @@ pollhandler(void)
return; return;
} }
if(packet_header->caplen > UIP_BUFSIZE) {
return;
}
uip_len = packet_header->caplen; uip_len = packet_header->caplen;
CopyMemory(uip_buf, packet, uip_len); CopyMemory(uip_buf, packet, uip_len);
if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
debug_printf("I");
uip_len -= sizeof(struct uip_eth_hdr);
tcpip_input(); tcpip_input();
} else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
debug_printf("A");
uip_arp_arpin(); uip_arp_arpin();
if(uip_len > 0) { if(uip_len > 0) {
if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) { if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) {
error_exit("Error on ARP response\n"); error_exit("Error on ARP response\n");