uip-stack-commits Mailing List for The uIP Embedded TCP/IP Stack
Brought to you by:
adamdunkels,
harbaum
You can subscribe to this list here.
| 2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
|---|
|
From: Oliver S. <oli...@us...> - 2007-09-04 22:19:38
|
Update of /cvsroot/uip-stack/uip In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31816 Modified Files: README Log Message: Added support for Cygwin as development/test platform. Index: README =================================================================== RCS file: /cvsroot/uip-stack/uip/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 4 Jan 2007 11:06:34 -0000 1.1 --- README 4 Sep 2007 22:19:32 -0000 1.2 *************** *** 11,13 **** lib/ - Library code used by some applications uip/ - uIP TCP/IP stack code ! unix/ - uIP as a user space process under FreeBSD or Linux --- 11,13 ---- lib/ - Library code used by some applications uip/ - uIP TCP/IP stack code ! unix/ - uIP as a user space process under FreeBSD, Linux or Cygwin |
|
From: Oliver S. <oli...@us...> - 2007-09-04 22:19:37
|
Update of /cvsroot/uip-stack/uip/unix In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31816/unix Modified Files: Makefile main.c Added Files: wpcap.c wpcap.h Log Message: Added support for Cygwin as development/test platform. Index: Makefile =================================================================== RCS file: /cvsroot/uip-stack/uip/unix/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 4 Jan 2007 11:06:41 -0000 1.1 --- Makefile 4 Sep 2007 22:19:33 -0000 1.2 *************** *** 39,43 **** -include ../uip/Makefile.include ! uip: $(addprefix $(OBJECTDIR)/, main.o tapdev.o clock-arch.o) apps.a uip.a clean: --- 39,51 ---- -include ../uip/Makefile.include ! ifeq ($(OS),Windows_NT) ! DRVOBJ = wpcap.o ! DRVLIB = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a ! else ! DRVOBJ = tapdev.o ! DRVLIB = ! endif ! ! uip: $(addprefix $(OBJECTDIR)/, main.o clock-arch.o $(DRVOBJ)) apps.a uip.a $(DRVLIB) clean: Index: main.c =================================================================== RCS file: /cvsroot/uip-stack/uip/unix/main.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.c 4 Jan 2007 11:06:41 -0000 1.1 --- main.c 4 Sep 2007 22:19:33 -0000 1.2 *************** *** 39,43 **** --- 39,47 ---- #include "uip.h" #include "uip_arp.h" + #ifdef __CYGWIN__ + #include "wpcap.h" + #else #include "tapdev.h" + #endif #include "timer.h" *************** *** 60,64 **** --- 64,72 ---- timer_set(&arp_timer, CLOCK_SECOND * 10); + #ifdef __CYGWIN__ + wpcap_init(); + #else tapdev_init(); + #endif uip_init(); *************** *** 97,101 **** --- 105,113 ---- while(1) { + #ifdef __CYGWIN__ + uip_len = wpcap_read(); + #else uip_len = tapdev_read(); + #endif if(uip_len > 0) { if(BUF->type == htons(UIP_ETHTYPE_IP)) { *************** *** 107,111 **** --- 119,127 ---- if(uip_len > 0) { uip_arp_out(); + #ifdef __CYGWIN__ + wpcap_send(); + #else tapdev_send(); + #endif } } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { *************** *** 115,119 **** --- 131,139 ---- uip_len is set to a value > 0. */ if(uip_len > 0) { + #ifdef __CYGWIN__ + wpcap_send(); + #else tapdev_send(); + #endif } } *************** *** 128,132 **** --- 148,156 ---- if(uip_len > 0) { uip_arp_out(); + #ifdef __CYGWIN__ + wpcap_send(); + #else tapdev_send(); + #endif } } *************** *** 140,144 **** --- 164,172 ---- if(uip_len > 0) { uip_arp_out(); + #ifdef __CYGWIN__ + wpcap_send(); + #else tapdev_send(); + #endif } } --- NEW FILE: wpcap.c --- /* * Copyright (c) 2007, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This file is part of the uIP TCP/IP stack. * * Author: Oliver Schmidt <ol...@we...> * * $Id: wpcap.c,v 1.1 2007/09/04 22:19:33 oliverschmidt Exp $ */ #define WIN32_LEAN_AND_MEAN #define _WIN32_WINNT 0x0501 #include <windows.h> #include <winsock2.h> #include <iphlpapi.h> #include <stdio.h> #include <stdlib.h> #include <malloc.h> /* Avoid 'conflicting types' errors. */ #define htonl #define htons #include "uip.h" #include "uip_arp.h" #include "wpcap.h" __attribute__((dllimport)) extern char **__argv[]; struct pcap; struct pcap_if { struct pcap_if *next; char *name; char *description; struct pcap_addr { struct pcap_addr *next; struct sockaddr *addr; struct sockaddr *netmask; struct sockaddr *broadaddr; struct sockaddr *dstaddr; } *addresses; DWORD flags; }; struct pcap_pkthdr { struct timeval ts; DWORD caplen; DWORD len; }; HMODULE wpcap; static struct pcap *pcap; static int (* pcap_findalldevs)(struct pcap_if **, char *); static struct pcap *(* pcap_open_live)(char *, int, int, int, char *); static int (* pcap_next_ex)(struct pcap *, struct pcap_pkthdr **, unsigned char **); static int (* pcap_sendpacket)(struct pcap *, unsigned char *, int); #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) /*---------------------------------------------------------------------------*/ static void error_exit(char *message) { printf("error_exit: %s", message); exit(EXIT_FAILURE); } /*---------------------------------------------------------------------------*/ static void init_pcap(struct in_addr addr) { struct pcap_if *interfaces; char error[256]; if(pcap_findalldevs(&interfaces, error) == -1) { error_exit(error); } while(interfaces != NULL) { printf("init_pcap: found interface: %s\n", interfaces->description); if(interfaces->addresses != NULL && interfaces->addresses->addr != NULL && interfaces->addresses->addr->sa_family == AF_INET) { struct in_addr interface_addr; interface_addr = ((struct sockaddr_in *)interfaces->addresses->addr)->sin_addr; printf("init_pcap: with address: %s\n", inet_ntoa(interface_addr)); if(interface_addr.s_addr == addr.s_addr) { break; } } interfaces = interfaces->next; } if(interfaces == NULL) { error_exit("no interface found with ip addr specified on cmdline\n"); } pcap = pcap_open_live(interfaces->name, UIP_BUFSIZE, 0, -1, error); if(pcap == NULL) { error_exit(error); } } /*---------------------------------------------------------------------------*/ static void set_ethaddr(struct in_addr addr) { PIP_ADAPTER_ADDRESSES adapters; ULONG size = 0; if(GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, NULL, NULL, &size) != ERROR_BUFFER_OVERFLOW) { error_exit("error on access to adapter list size\n"); } adapters = alloca(size); if(GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, NULL, adapters, &size) != ERROR_SUCCESS) { error_exit("error on access to adapter list\n"); } while(adapters != NULL) { char buffer[256]; WideCharToMultiByte(CP_ACP, 0, adapters->Description, -1, buffer, sizeof(buffer), NULL, NULL); printf("set_ethaddr: found adapter: %s\n", buffer); if(adapters->FirstUnicastAddress != NULL && adapters->FirstUnicastAddress->Address.lpSockaddr != NULL && adapters->FirstUnicastAddress->Address.lpSockaddr->sa_family == AF_INET) { struct in_addr adapter_addr; adapter_addr = ((struct sockaddr_in *)adapters->FirstUnicastAddress->Address.lpSockaddr)->sin_addr; printf("set_ethaddr: with address: %s\n", inet_ntoa(adapter_addr)); if(adapter_addr.s_addr == addr.s_addr) { if(adapters->PhysicalAddressLength != 6) { error_exit("ip addr specified on cmdline does not belong to an ethernet card\n"); } printf("set_ethaddr: ethernetaddr: %02X-%02X-%02X-%02X-%02X-%02X\n", adapters->PhysicalAddress[0], adapters->PhysicalAddress[1], adapters->PhysicalAddress[2], adapters->PhysicalAddress[3], adapters->PhysicalAddress[4], adapters->PhysicalAddress[5]); uip_setethaddr((*(struct uip_eth_addr *)adapters->PhysicalAddress)); break; } } adapters = adapters->Next; } if(adapters == NULL) { error_exit("no adapter found with ip addr specified on cmdline\n"); } } /*---------------------------------------------------------------------------*/ void wpcap_init(void) { struct in_addr addr; addr.s_addr = inet_addr((*__argv)[1]); if(addr.s_addr == INADDR_NONE) { error_exit("usage: <program> <ip addr of ethernet card to share>\n"); } printf("wpcap_init: cmdline address: %s\n", inet_ntoa(addr)); wpcap = LoadLibrary("wpcap.dll"); (FARPROC)pcap_findalldevs = GetProcAddress(wpcap, "pcap_findalldevs"); (FARPROC)pcap_open_live = GetProcAddress(wpcap, "pcap_open_live"); (FARPROC)pcap_next_ex = GetProcAddress(wpcap, "pcap_next_ex"); (FARPROC)pcap_sendpacket = GetProcAddress(wpcap, "pcap_sendpacket"); if(pcap_findalldevs == NULL || pcap_open_live == NULL || pcap_next_ex == NULL || pcap_sendpacket == NULL) { error_exit("error on access to winpcap library\n"); } init_pcap(addr); set_ethaddr(addr); } /*---------------------------------------------------------------------------*/ unsigned int wpcap_read(void) { struct pcap_pkthdr *packet_header; unsigned char *packet; switch(pcap_next_ex(pcap, &packet_header, &packet)) { case -1: error_exit("error on read\n"); case 0: return 0; } if(packet_header->caplen > UIP_BUFSIZE) { return 0; } CopyMemory(uip_buf, packet, packet_header->caplen); return packet_header->caplen; } /*---------------------------------------------------------------------------*/ void wpcap_send(void) { if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) { error_exit("error on send\n"); } } /*---------------------------------------------------------------------------*/ --- NEW FILE: wpcap.h --- /* * Copyright (c) 2007, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This file is part of the uIP TCP/IP stack. * * Author: Oliver Schmidt <ol...@we...> * * $Id: wpcap.h,v 1.1 2007/09/04 22:19:33 oliverschmidt Exp $ */ #ifndef __WPCAP_H__ #define __WPCAP_H__ void wpcap_init(void); unsigned int wpcap_read(void); void wpcap_send(void); #endif /* __WPCAP_H__ */ |
|
From: Adam D. <ada...@us...> - 2007-01-04 12:43:41
|
Update of /cvsroot/uip-stack/uip In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv15742 Added Files: uip-1.0-changelog.txt Log Message: uIP 1.0 changelog from 1.0 source distribution --- NEW FILE: uip-1.0-changelog.txt --- * A new API: protosockets that are similar to BSD sockets but does not require any underlying multithreading system. * Very rudimentary IPv6 support * New application: DHCP client. Web server rewritten with protosockets. * Removed uIP zero-copy functionality in order to simplify uIP device driver coding: outbound packets are now *always* stored in full in the uip_buf buffer. * Checksum computation is now part of uip.c, but it still is possible to implement them in assembly code by specifying a configuration option. Checksum code now runs on architectures with 2-byte alignment. * Added TCP persistent timer. * Made all IP address representations use the new uip_ipaddr_ip datatype for clarity. * Updated window behavior so that sending to a host with a small open window works better now. * UDP API change: uip_udp_new() now takes port numbers in network byte order like TCP functions. * Allow reception of packets when no IP address is configured to make DHCP work. * Moved Ethernet address into main uIP module from ARP module. * Made constants explicit #defines and moved them out of the code (header sizes, TCP options, TCP header length field). * If uip_len is less than that reported by the IP header, the packet is discarded. If uip_len is greater than the length reported by the IP header, uip_len is adjusted. * Moved header size definitions into header file. * Added uIP call for polling an application without triggering any timer events. Removed redundant assignments of uip_len and uip_slen. * Removed compiler warning about icmp_input label being defined when UIP_PINGADDRCONF was not used. * Added UIP_APPDATA_SIZE macro that holds the available buffer size for user data. * Added uip_udp_bind() call. * Moved checksum code into main uIP module. * Switched the TCP, UDP and IP header structures to be structs rather than typedefs. * Prefixed TCP state names with UIP_ to avoid name space contamination. * Changed declarations of uip_appdatap and friends to void * to avoid explicit typecasts. * Bugfixes o TCP: Fixed bug with high byte of peer window size. o TCP: Fixed bug that in some cases prevented concurrent reception and transmission of TCP data. o TCP: uip_connect() didn't correctly calculate age of TIME_WAIT connections. o TCP: Array index for uip_conns[] array was out of bounds in comparison. Comparison changed to make index within bounds. o TCP: if the remote host crashes and tries to reestablish an old connection, uIP should respond with an ACK with the correct sequence and acknowledgment numbers, to which the remote host should respond with an ACK. uIP did not respond with the correct ACK. o TCP: Fixed check for SYNACK segment: now checks only relevant TCP control flags and discards flags reserved for future expansion. o TCP: Fixed bug where uIP did not inform application that a connection had been aborted during an active open. o TCP: FIN segment was accepted even though application had stopped incoming data with uip_stop(). o TCP: A FINACK segment would not always correctly acknowledge data. o UDP: checksums are now calculated after all fields have been filled in. o UDP: network byte order on lastport in uip_udp_new(). o IP: memset() bugs in IP fragment reassembly code fixed. |