diff --git a/FILES b/FILES index 636cdbfd..5134d2da 100644 --- a/FILES +++ b/FILES @@ -1,7 +1,4 @@ src/ - The source code for the lwIP TCP/IP stack. - -proj/ - Makefiles and code for compiling lwIP. - doc/ - Documentation on the lwIP APIs. -See also the FILES file in each subdirectory. \ No newline at end of file +See also the FILES file in each subdirectory. diff --git a/proj/minimal/Makefile b/proj/minimal/Makefile deleted file mode 100644 index 180a2de0..00000000 --- a/proj/minimal/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# Copyright (c) 2001, 2002 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. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. -# -# Author: Adam Dunkels -# - -CCDEP=gcc -CC=gcc -CFLAGS=-g -Wall -DIPv4 -Os -fpack-struct -LWIPARCH=unix -ARFLAGS=rs -LWIPDIR=../../src -CONTRIBDIR=../../../contrib - -CFLAGS:=$(CFLAGS) \ - -I$(LWIPDIR)/include -I$(CONTRIBDIR)/ports/$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \ - -Iapps -I. - -# COREFILES, CORE4FILES: The minimum set of files needed for lwIP. -COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \ - $(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \ - $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \ - $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c -CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \ - $(LWIPDIR)/core/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c - -# NETIFFILES: Files implementing various generic network interface functions.' -NETIFFILES=$(LWIPDIR)/netif/etharp.c mintapif.c - -# LWIPFILES: All the above. -LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES) -LWIPFILESW=$(wildcard $(LWIPFILES)) -LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o)) - -# APPFILES -APPFILES=echo.c - -LWIPLIB=liblwip4.a -APPLIB=liblwipapps.a -APPOBJS=$(notdir $(APPFILES:.c=.o)) - -%.o: - $(CC) $(CFLAGS) -c $(<:.o=.c) - -all ipv4 compile: minimal -.PHONY: all - -clean: - rm -f *.o $(LWIPLIB) $(APPLIB) minimal .depend* *.core core - -depend dep: .depend - -include .depend - -$(APPLIB): $(APPOBJS) - $(AR) $(ARFLAGS) $(APPLIB) $? - -$(LWIPLIB): $(LWIPOBJS) - $(AR) $(ARFLAGS) $(LWIPLIB) $? - -.depend: main.c $(LWIPFILES) $(APPFILES) - $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend - -minimal: .depend $(LWIPLIB) $(APPLIB) main.o $(APPFILES) - $(CC) $(CFLAGS) $(LDFLAGS) -o minimal main.o $(APPLIB) $(LWIPLIB) - - diff --git a/proj/minimal/README b/proj/minimal/README deleted file mode 100644 index 0edb5f78..00000000 --- a/proj/minimal/README +++ /dev/null @@ -1,3 +0,0 @@ -This is an example of a very minimal lwIP project. It runs in a single -thread and runs a single example application - an echo server. The -echo application is implemented using the raw API. \ No newline at end of file diff --git a/proj/minimal/echo.c b/proj/minimal/echo.c deleted file mode 100644 index 5324ac41..00000000 --- a/proj/minimal/echo.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/debug.h" -#include "lwip/stats.h" -#include "lwip/tcp.h" - -struct echo_state { - struct pbuf *p; - u8_t failed; -#define FAILED_MAX 8 -}; -/*-----------------------------------------------------------------------------------*/ -static void -echo_err(void *arg, err_t err) -{ - struct echo_state *es = arg; - - if(arg != NULL) { - pbuf_free(es->p); - mem_free(arg); - } -} -/*-----------------------------------------------------------------------------------*/ -static void -close_conn(struct tcp_pcb *pcb, struct echo_state *es) -{ - tcp_arg(pcb, NULL); -#if 0 - tcp_sent(pcb, NULL); - tcp_recv(pcb, NULL); -#endif /* 0 */ - if(es != NULL) { - pbuf_free(es->p); - mem_free(es); - } - tcp_close(pcb); -} -/*-----------------------------------------------------------------------------------*/ -static void -send_buf(struct tcp_pcb *pcb, struct echo_state *es) -{ - struct pbuf *q; - - do { - q = es->p; - es->p = pbuf_dechain(q); - if(tcp_write(pcb, q->payload, q->len, 1) == ERR_MEM) { - pbuf_chain(q, es->p); - es->p = q; - return; - } - tcp_recved(pcb, q->len); - pbuf_free(q); - } while(es->p != NULL); -} -/*-----------------------------------------------------------------------------------*/ -static err_t -echo_poll(void *arg, struct tcp_pcb *pcb) -{ - struct echo_state *es; - - if(arg == NULL) { - return tcp_close(pcb); - } - - es = arg; - - if(es->failed >= FAILED_MAX) { - close_conn(pcb, es); - tcp_abort(pcb); - return ERR_ABRT; - } - - if(es->p != NULL) { - ++es->failed; - send_buf(pcb, es); - } - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -static err_t -echo_sent(void *arg, struct tcp_pcb *pcb, u16_t len) -{ - struct echo_state *es; - - es = arg; - - if(es != NULL && es->p != NULL) { - send_buf(pcb, es); - } - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -static err_t -echo_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) -{ - struct echo_state *es; - - es = arg; - - if(p == NULL) { - close_conn(pcb, es); - return ERR_OK; - } - - if(es->p != NULL) { - pbuf_chain(es->p, p); - } else { - es->p = p; - } - - send_buf(pcb, es); - - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -static err_t -echo_accept(void *arg, struct tcp_pcb *pcb, err_t err) -{ - struct echo_state *es; - - tcp_setprio(pcb, TCP_PRIO_MIN); - - /* Allocate memory for the structure that holds the state of the - connection. */ - es = mem_malloc(sizeof(struct echo_state)); - - if(es == NULL) { - return ERR_MEM; - } - - /* Initialize the structure. */ - es->p = NULL; - es->failed = 0; - - /* Tell TCP that this is the structure we wish to be passed for our - callbacks. */ - tcp_arg(pcb, es); - - /* Tell TCP that we wish to be informed of incoming data by a call - to the http_recv() function. */ -#if 0 - tcp_recv(pcb, echo_recv); - - tcp_err(pcb, echo_err); -#endif /* 0 */ - - tcp_poll(pcb, echo_poll, 2); - - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -void -echo_init(void) -{ - struct tcp_pcb *pcb; - - pcb = tcp_new(); - tcp_bind(pcb, IP_ADDR_ANY, 7); - pcb = tcp_listen(pcb); -#if 0 - tcp_accept(pcb, echo_accept); -#endif /* 0 */ -} -/*-----------------------------------------------------------------------------------*/ -err_t -lwip_tcp_event(void *arg, struct tcp_pcb *pcb, - enum lwip_event ev, struct pbuf *p, - u16_t size, err_t err) -{ - switch(ev) { - case LWIP_EVENT_ACCEPT: - return echo_accept(arg, pcb, err); - case LWIP_EVENT_SENT: - return echo_sent(arg, pcb, size); - case LWIP_EVENT_RECV: - return echo_recv(arg, pcb, p, err); - case LWIP_EVENT_ERR: - echo_err(arg, err); - break; - case LWIP_EVENT_POLL: - return echo_poll(arg, pcb); - default: - break; - } - - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ - diff --git a/proj/minimal/lwipopts.h b/proj/minimal/lwipopts.h deleted file mode 100644 index d2903f01..00000000 --- a/proj/minimal/lwipopts.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIPOPTS_H__ -#define __LWIPOPTS_H__ - -#define NO_SYS 1 -#define LWIP_EVENT_API 1 - -/* ---------- Memory options ---------- */ -/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which - lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 - byte alignment -> define MEM_ALIGNMENT to 2. */ -#define MEM_ALIGNMENT 2 - -/* MEM_SIZE: the size of the heap memory. If the application will send -a lot of data that needs to be copied, this should be set high. */ -#define MEM_SIZE 1000 - -/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application - sends a lot of data out of ROM (or other static memory), this - should be set high. */ -#define MEMP_NUM_PBUF 8 -/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - per active UDP "connection". */ -#define MEMP_NUM_UDP_PCB 4 -/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP - connections. */ -#define MEMP_NUM_TCP_PCB 2 -/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP - connections. */ -#define MEMP_NUM_TCP_PCB_LISTEN 8 -/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP - segments. */ -#define MEMP_NUM_TCP_SEG 8 - -/* The following four are used only with the sequential API and can be - set to 0 if the application only will use the raw API. */ -/* MEMP_NUM_NETBUF: the number of struct netbufs. */ -#define MEMP_NUM_NETBUF 0 -/* MEMP_NUM_NETCONN: the number of struct netconns. */ -#define MEMP_NUM_NETCONN 0 -/* MEMP_NUM_APIMSG: the number of struct api_msg, used for - communication between the TCP/IP stack and the sequential - programs. */ -#define MEMP_NUM_API_MSG 0 -/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used - for sequential API communication and incoming packets. Used in - src/api/tcpip.c. */ -#define MEMP_NUM_TCPIP_MSG 0 -/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active - timeouts. */ -#define MEMP_NUM_SYS_TIMEOUT 0 - -/* ---------- Pbuf options ---------- */ -/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ -#define PBUF_POOL_SIZE 8 - -/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ -#define PBUF_POOL_BUFSIZE 128 - -/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a - link level header. */ -#define PBUF_LINK_HLEN 16 - -/* ---------- TCP options ---------- */ -#define LWIP_TCP 1 -#define TCP_TTL 255 - -/* Controls if TCP should queue segments that arrive out of - order. Define to 0 if your device is low on memory. */ -#define TCP_QUEUE_OOSEQ 0 - -/* TCP Maximum segment size. */ -#define TCP_MSS 128 - -/* TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 256 - -/* TCP sender buffer space (pbufs). This must be at least = 2 * - TCP_SND_BUF/TCP_MSS for things to work. */ -#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS - -/* TCP receive window. */ -#define TCP_WND 512 - -/* Maximum number of retransmissions of data segments. */ -#define TCP_MAXRTX 12 - -/* Maximum number of retransmissions of SYN segments. */ -#define TCP_SYNMAXRTX 4 - -/* ---------- ARP options ---------- */ -#define ARP_TABLE_SIZE 10 -#define ARP_QUEUEING 0 -/** - * - If enabled, cache entries are generated for every kind of ARP traffic or - * broadcast IP traffic. This enhances behaviour for sending to a dynamic set - * of hosts, for example if acting as a gateway. - * - If disabled, cache entries are generated only for IP destination addresses - * in use by lwIP or applications. This enhances performance if sending to a small, - * reasonably static number of hosts. Typically for embedded devices. - */ -#define ETHARP_ALWAYS_INSERT 0 - -/* ---------- IP options ---------- */ -/* Define IP_FORWARD to 1 if you wish to have the ability to forward - IP packets across network interfaces. If you are going to run lwIP - on a device with only one network interface, define this to 0. */ -#define IP_FORWARD 0 - -/* If defined to 1, IP options are allowed (but not parsed). If - defined to 0, all packets with IP options are dropped. */ -#define IP_OPTIONS 1 - -/* ---------- ICMP options ---------- */ -#define ICMP_TTL 255 - - -/* ---------- DHCP options ---------- */ -/* Define LWIP_DHCP to 1 if you want DHCP configuration of - interfaces. DHCP is not implemented in lwIP 0.5.1, however, so - turning this on does currently not work. */ -#define LWIP_DHCP 0 - -/* 1 if you want to do an ARP check on the offered address - (recommended). */ -#define DHCP_DOES_ARP_CHECK 1 - -/* ---------- UDP options ---------- */ -#define LWIP_UDP 0 -#define UDP_TTL 255 - - -/* ---------- Statistics options ---------- */ -/*#define STATS*/ - -#ifdef STATS -#define LINK_STATS -#define IP_STATS -#define ICMP_STATS -#define UDP_STATS -#define TCP_STATS -#define MEM_STATS -#define MEMP_STATS -#define PBUF_STATS -#define SYS_STATS -#endif /* STATS */ - -#endif /* __LWIPOPTS_H__ */ diff --git a/proj/minimal/main.c b/proj/minimal/main.c deleted file mode 100644 index 5cdf6531..00000000 --- a/proj/minimal/main.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/debug.h" - -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/sys.h" - -#include "lwip/stats.h" - -#include "lwip/ip.h" -#include "lwip/udp.h" -#include "lwip/tcp.h" - -#include "mintapif.h" - -/*-----------------------------------------------------------------------------------*/ -int -main(int argc, char **argv) -{ - struct ip_addr ipaddr, netmask, gw; - struct netif *netif; - -#ifdef PERF - perf_init("/tmp/minimal.perf"); -#endif /* PERF */ -#ifdef STATS - stats_init(); -#endif /* STATS */ - - mem_init(); - memp_init(); - pbuf_init(); - netif_init(); - ip_init(); - udp_init(); - tcp_init(); - printf("TCP/IP initialized.\n"); - - IP4_ADDR(&gw, 192,168,0,1); - IP4_ADDR(&ipaddr, 192,168,0,2); - IP4_ADDR(&netmask, 255,255,255,0); - - netif = netif_add(&ipaddr, &netmask, &gw, mintapif_init, ip_input); - - netif_set_default(netif); - - echo_init(); - - printf("Applications started.\n"); - - - while(1) { - - if(mintapif_wait(netif, 100) == MINTAPIF_TIMEOUT) { - tcp_tmr(); - } - - } - - return 0; -} -/*-----------------------------------------------------------------------------------*/ - - - - - - - - diff --git a/proj/minimal/mintapif.c b/proj/minimal/mintapif.c deleted file mode 100644 index 5014f300..00000000 --- a/proj/minimal/mintapif.c +++ /dev/null @@ -1,354 +0,0 @@ -/*-----------------------------------------------------------------------------------*/ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef linux -#include -#include -#include -#define DEVTAP "/dev/net/tun" -#else /* linux */ -#define DEVTAP "/dev/tap0" -#endif /* linux */ - -#include "lwip/stats.h" -#include "lwip/mem.h" -#include "netif/etharp.h" - -#include "mintapif.h" - -/* Define those to better describe your network interface. */ -#define IFNAME0 'e' -#define IFNAME1 't' - -struct mintapif { - struct eth_addr *ethaddr; - /* Add whatever per-interface state that is needed here. */ - u32_t lasttime; - int fd; -}; - -static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; - -/* Forward declarations. */ -static void mintapif_input(struct netif *netif); -static err_t mintapif_output(struct netif *netif, struct pbuf *p, - struct ip_addr *ipaddr); - -/*-----------------------------------------------------------------------------------*/ -static void -low_level_init(struct netif *netif) -{ - struct mintapif *mintapif; - char buf[1024]; - - mintapif = netif->state; - - /* Obtain MAC address from network interface. */ - mintapif->ethaddr->addr[0] = 1; - mintapif->ethaddr->addr[1] = 2; - mintapif->ethaddr->addr[2] = 3; - mintapif->ethaddr->addr[3] = 4; - mintapif->ethaddr->addr[4] = 5; - mintapif->ethaddr->addr[5] = 6; - - /* Do whatever else is needed to initialize interface. */ - - mintapif->fd = open(DEVTAP, O_RDWR); - if(mintapif->fd == -1) { - perror("tapif: tapif_init: open"); - exit(1); - } - -#ifdef linux - { - struct ifreq ifr; - memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_flags = IFF_TAP|IFF_NO_PI; - if (ioctl(mintapif->fd, TUNSETIFF, (void *) &ifr) < 0) { - perror(buf); - exit(1); - } - } -#endif /* Linux */ - - snprintf(buf, sizeof(buf), "ifconfig tap0 inet %d.%d.%d.%d", - ip4_addr1(&(netif->gw)), - ip4_addr2(&(netif->gw)), - ip4_addr3(&(netif->gw)), - ip4_addr4(&(netif->gw))); - - system(buf); - - mintapif->lasttime = 0; - -} -/*-----------------------------------------------------------------------------------*/ -/* - * low_level_output(): - * - * Should do the actual transmission of the packet. The packet is - * contained in the pbuf that is passed to the function. This pbuf - * might be chained. - * - */ -/*-----------------------------------------------------------------------------------*/ - -static err_t -low_level_output(struct netif *netif, struct pbuf *p) -{ - struct mintapif *mintapif; - struct pbuf *q; - char buf[1500]; - char *bufptr; - - mintapif = netif->state; - - /* initiate transfer(); */ - - bufptr = &buf[0]; - - for(q = p; q != NULL; q = q->next) { - /* Send the data from the pbuf to the interface, one pbuf at a - time. The size of the data in each pbuf is kept in the ->len - variable. */ - /* send data from(q->payload, q->len); */ - memcpy(bufptr, q->payload, q->len); - bufptr += q->len; - } - - /* signal that packet should be sent(); */ - if(write(mintapif->fd, buf, p->tot_len) == -1) { - perror("tapif: write"); - } - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -/* - * low_level_input(): - * - * Should allocate a pbuf and transfer the bytes of the incoming - * packet from the interface into the pbuf. - * - */ -/*-----------------------------------------------------------------------------------*/ -static struct pbuf * -low_level_input(struct mintapif *mintapif) -{ - struct pbuf *p, *q; - u16_t len; - char buf[1500]; - char *bufptr; - - /* Obtain the size of the packet and put it into the "len" - variable. */ - len = read(mintapif->fd, buf, sizeof(buf)); - - /* if(((double)rand()/(double)RAND_MAX) < 0.1) { - printf("drop\n"); - return NULL; - }*/ - - - /* We allocate a pbuf chain of pbufs from the pool. */ - p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL); - - if(p != NULL) { - /* We iterate over the pbuf chain until we have read the entire - packet into the pbuf. */ - bufptr = &buf[0]; - for(q = p; q != NULL; q = q->next) { - /* Read enough bytes to fill this pbuf in the chain. The - avaliable data in the pbuf is given by the q->len - variable. */ - /* read data into(q->payload, q->len); */ - memcpy(q->payload, bufptr, q->len); - bufptr += q->len; - } - /* acknowledge that packet has been read(); */ - } else { - /* drop packet(); */ - printf("Could not allocate pbufs\n"); - } - - return p; -} -/*-----------------------------------------------------------------------------------*/ -/* - * mintapif_output(): - * - * This function is called by the TCP/IP stack when an IP packet - * should be sent. It calls the function called low_level_output() to - * do the actuall transmission of the packet. - * - */ -/*-----------------------------------------------------------------------------------*/ -static err_t -mintapif_output(struct netif *netif, struct pbuf *p, - struct ip_addr *ipaddr) -{ - p = etharp_output(netif, ipaddr, p); - if(p != NULL) { - return low_level_output(netif, p); - } - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -/* - * mintapif_input(): - * - * This function should be called when a packet is ready to be read - * from the interface. It uses the function low_level_input() that - * should handle the actual reception of bytes from the network - * interface. - * - */ -/*-----------------------------------------------------------------------------------*/ -static void -mintapif_input(struct netif *netif) -{ - struct mintapif *mintapif; - struct eth_hdr *ethhdr; - struct pbuf *p, *q; - - - mintapif = netif->state; - - p = low_level_input(mintapif); - - if(p != NULL) { - -#ifdef LINK_STATS - lwip_stats.link.recv++; -#endif /* LINK_STATS */ - - ethhdr = p->payload; - - q = NULL; - switch(htons(ethhdr->type)) { - case ETHTYPE_IP: - q = etharp_ip_input(netif, p); - pbuf_header(p, -14); - netif->input(p, netif); - break; - case ETHTYPE_ARP: - q = etharp_arp_input(netif, mintapif->ethaddr, p); - break; - default: - pbuf_free(p); - break; - } - if(q != NULL) { - low_level_output(netif, q); - pbuf_free(q); - } - - } -} -/*-----------------------------------------------------------------------------------*/ -/* - * mintapif_init(): - * - * Should be called at the beginning of the program to set up the - * network interface. It calls the function low_level_init() to do the - * actual setup of the hardware. - * - */ -/*-----------------------------------------------------------------------------------*/ -void -mintapif_init(struct netif *netif) -{ - struct mintapif *mintapif; - - mintapif = mem_malloc(sizeof(struct mintapif)); - netif->state = mintapif; - netif->name[0] = IFNAME0; - netif->name[1] = IFNAME1; - netif->output = mintapif_output; - netif->linkoutput = low_level_output; - - mintapif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); - - low_level_init(netif); -} -/*-----------------------------------------------------------------------------------*/ -enum mintapif_signal -mintapif_wait(struct netif *netif, u16_t time) -{ - fd_set fdset; - struct timeval tv, now; - struct timezone tz; - int ret; - struct mintapif *mintapif; - - mintapif = netif->state; - - while(1) { - - if(mintapif->lasttime >= (u32_t)time * 1000) { - mintapif->lasttime = 0; - return MINTAPIF_TIMEOUT; - } - - tv.tv_sec = 0; - tv.tv_usec = (u32_t)time * 1000 - mintapif->lasttime; - - - FD_ZERO(&fdset); - FD_SET(mintapif->fd, &fdset); - - gettimeofday(&now, &tz); - ret = select(mintapif->fd + 1, &fdset, NULL, NULL, &tv); - if(ret == 0) { - mintapif->lasttime = 0; - return MINTAPIF_TIMEOUT; - } - gettimeofday(&tv, &tz); - mintapif->lasttime += (tv.tv_sec - now.tv_sec) * 1000000 + (tv.tv_usec - now.tv_usec); - - mintapif_input(netif); - } - - return MINTAPIF_PACKET; -} diff --git a/proj/minimal/mintapif.h b/proj/minimal/mintapif.h deleted file mode 100644 index b5e750a4..00000000 --- a/proj/minimal/mintapif.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __MINTAPIF_H__ -#define __MINTAPIF_H__ - -#include "lwip/netif.h" - -enum mintapif_signal { - MINTAPIF_TIMEOUT, - MINTAPIF_PACKET -}; - -void mintapif_init(struct netif *netif); -enum mintapif_signal mintapif_wait(struct netif *netif, u16_t time); - -#endif /* __MINTAPIF_H__ */ diff --git a/proj/unixlib/Makefile b/proj/unixlib/Makefile deleted file mode 100644 index ed0ecaa4..00000000 --- a/proj/unixlib/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# Copyright (c) 2001, 2002 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. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. -# -# Author: Adam Dunkels -# - -CCDEP=gcc -CC=gcc -CFLAGS=-g -Wall -fPIC -DIPv4 -DLWIP_DEBUG -LWIPARCH=unix -LWIPDIR=../../src -CONTRIBDIR=../../../contrib - -CFLAGS:=$(CFLAGS) \ - -I$(LWIPDIR)/include -I$(CONTRIBDIR)/ports/$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \ - -Iapps -I. - -# COREFILES, CORE4FILES: The minimum set of files needed for lwIP. -COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \ - $(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \ - $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \ - $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c -CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \ - $(LWIPDIR)/core/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c - - -# APIFILES: The files which implement the sequential and socket APIs. -APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \ - $(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c - -# NETIFFILES: Files implementing various generic network interface functions.' -NETIFFILES=$(LWIPDIR)/netif/loopif.c \ - $(LWIPDIR)/netif/etharp.c - -# ARCHFILES: Archiecture specific files. -ARCHFILES=$(wildcard $(LWIPDIR)/arch/$(LWIPARCH)/*.c $(LWIPDIR)/arch/$(LWIPARCH)/netif/*.c) - -# LWIPFILES: All the above. -LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES) -LWIPFILESW=$(wildcard $(LWIPFILES)) -LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o)) - -LWIPLIB=liblwip4$(LWIPARCH)lib.so - -%.o: - $(CC) $(CFLAGS) -c $(<:.o=.c) - -all: $(LWIPLIB) -.PHONY: all - -clean: - rm -f *.o $(LWIPLIB) *.s .depend* *.core core - -depend dep: .depend - -include .depend - -$(LWIPLIB): $(LWIPOBJS) unixlib.o - $(CC) -g -nostartfiles -shared -o $@ $^ - -.depend: unixlib.c $(LWIPFILES) - $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend \ No newline at end of file diff --git a/proj/unixlib/README b/proj/unixlib/README deleted file mode 100644 index cd6cc7b7..00000000 --- a/proj/unixlib/README +++ /dev/null @@ -1,31 +0,0 @@ -This directory contains an example of how to compile lwIP as a self -initialising shared library on Linux. - -Some brief instructions: - -* Compile the code: - - > make clean all - - This should produce liblwip4unixlib.so. This is the shared library. - -* Link an application against the shared library - - If you're using gcc you can do this by including -llwip4unixlib in -your link command. - -* Run your application - - Ensure that LD_LIBRARY_PATH includes the directory that contains -liblwip4unixlib.so (ie. this directory) - - - -If you are unsure about shared libraries and libraries on linux in -general, you might find this HOWTO useful: - - - - - -Kieran Mansley, October 2002. \ No newline at end of file diff --git a/proj/unixlib/lwipopts.h b/proj/unixlib/lwipopts.h deleted file mode 100644 index 32899952..00000000 --- a/proj/unixlib/lwipopts.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIPOPTS_H__ -#define __LWIPOPTS_H__ - -/* ---------- Memory options ---------- */ -/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which - lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 - byte alignment -> define MEM_ALIGNMENT to 2. */ -#define MEM_ALIGNMENT 1 - -/* MEM_SIZE: the size of the heap memory. If the application will send -a lot of data that needs to be copied, this should be set high. */ -#define MEM_SIZE 1600 - -/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application - sends a lot of data out of ROM (or other static memory), this - should be set high. */ -#define MEMP_NUM_PBUF 16 -/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - per active UDP "connection". */ -#define MEMP_NUM_UDP_PCB 4 -/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP - connections. */ -#define MEMP_NUM_TCP_PCB 5 -/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP - connections. */ -#define MEMP_NUM_TCP_PCB_LISTEN 8 -/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP - segments. */ -#define MEMP_NUM_TCP_SEG 16 -/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active - timeouts. */ -#define MEMP_NUM_SYS_TIMEOUT 3 - - -/* The following four are used only with the sequential API and can be - set to 0 if the application only will use the raw API. */ -/* MEMP_NUM_NETBUF: the number of struct netbufs. */ -#define MEMP_NUM_NETBUF 2 -/* MEMP_NUM_NETCONN: the number of struct netconns. */ -#define MEMP_NUM_NETCONN 4 -/* MEMP_NUM_APIMSG: the number of struct api_msg, used for - communication between the TCP/IP stack and the sequential - programs. */ -#define MEMP_NUM_API_MSG 8 -/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used - for sequential API communication and incoming packets. Used in - src/api/tcpip.c. */ -#define MEMP_NUM_TCPIP_MSG 8 - -/* These two control is reclaimer functions should be compiled - in. Should always be turned on (1). */ -#define MEM_RECLAIM 1 -#define MEMP_RECLAIM 1 - -/* ---------- Pbuf options ---------- */ -/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ -#define PBUF_POOL_SIZE 6 - -/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ -#define PBUF_POOL_BUFSIZE 128 - -/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a - link level header. */ -#define PBUF_LINK_HLEN 16 - -/* ---------- TCP options ---------- */ -#define LWIP_TCP 1 -#define TCP_TTL 255 - -/* Controls if TCP should queue segments that arrive out of - order. Define to 0 if your device is low on memory. */ -#define TCP_QUEUE_OOSEQ 1 - -/* TCP Maximum segment size. */ -#define TCP_MSS 128 - -/* TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 256 - -/* TCP sender buffer space (pbufs). This must be at least = 2 * - TCP_SND_BUF/TCP_MSS for things to work. */ -#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS - -/* TCP receive window. */ -#define TCP_WND 1024 - -/* Maximum number of retransmissions of data segments. */ -#define TCP_MAXRTX 12 - -/* Maximum number of retransmissions of SYN segments. */ -#define TCP_SYNMAXRTX 4 - -/* ---------- ARP options ---------- */ -#define ARP_TABLE_SIZE 10 -#define ARP_QUEUEING 1 -/** - * - If enabled, cache entries are generated for every kind of ARP traffic or - * broadcast IP traffic. This enhances behaviour for sending to a dynamic set - * of hosts, for example if acting as a gateway. - * - If disabled, cache entries are generated only for IP destination addresses - * in use by lwIP or applications. This enhances performance if sending to a small, - * reasonably static number of hosts. Typically for embedded devices. - */ -#define ETHARP_ALWAYS_INSERT 1 - -/* ---------- IP options ---------- */ -/* Define IP_FORWARD to 1 if you wish to have the ability to forward - IP packets across network interfaces. If you are going to run lwIP - on a device with only one network interface, define this to 0. */ -#define IP_FORWARD 1 - -/* If defined to 1, IP options are allowed (but not parsed). If - defined to 0, all packets with IP options are dropped. */ -#define IP_OPTIONS 1 - -/* ---------- ICMP options ---------- */ -#define ICMP_TTL 255 - - -/* ---------- DHCP options ---------- */ -/* Define LWIP_DHCP to 1 if you want DHCP configuration of - interfaces. DHCP is not implemented in lwIP 0.5.1, however, so - turning this on does currently not work. */ -#define LWIP_DHCP 0 - -/* 1 if you want to do an ARP check on the offered address - (recommended). */ -#define DHCP_DOES_ARP_CHECK 1 - -/* ---------- UDP options ---------- */ -#define LWIP_UDP 1 -#define UDP_TTL 255 - - -/* ---------- Statistics options ---------- */ -#define STATS - -#ifdef STATS -#define LINK_STATS -#define IP_STATS -#define ICMP_STATS -#define UDP_STATS -#define TCP_STATS -#define MEM_STATS -#define MEMP_STATS -#define PBUF_STATS -#define SYS_STATS -#endif /* STATS */ - -#endif /* __LWIPOPTS_H__ */ diff --git a/proj/unixlib/unixlib.c b/proj/unixlib/unixlib.c deleted file mode 100644 index 149caae1..00000000 --- a/proj/unixlib/unixlib.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - * - * Author: Kieran Mansley - * - * $Id: unixlib.c,v 1.2 2003/01/08 10:09:40 likewise Exp $ - */ - -/*-----------------------------------------------------------------------------------*/ -/* unixlib.c - * - * The initialisation functions for a shared library - * - * You may need to configure this file to your own needs - it is only an example - * of how lwIP can be used as a self initialising shared library. - * - * In particular, you should change the gateway, ipaddr, and netmask to be the values - * you would like the stack to use. - */ -/*-----------------------------------------------------------------------------------*/ -#include "lwip/sys.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/tcp.h" -#include "lwip/tcpip.h" -#include "lwip/netif.h" -#include "lwip/stats.h" - -#include "netif/tapif.h" - -static void -tcpip_init_done(void *arg) -{ - sys_sem_t *sem; - sem = arg; - sys_sem_signal(*sem); -} - -void _init(void){ - struct ip_addr ipaddr, netmask, gateway; - sys_sem_t sem; - - stats_init(); - sys_init(); - mem_init(); - memp_init(); - pbuf_init(); - - sem = sys_sem_new(0); - tcpip_init(tcpip_init_done, &sem); - sys_sem_wait(sem); - sys_sem_free(sem); - - netif_init(); - /* - CHANGE THESE to suit your own network configuration: - */ - IP4_ADDR(&gateway, 192,168,1,1); - IP4_ADDR(&ipaddr, 192,168,1,1); - IP4_ADDR(&netmask, 255,255,255,0); - - netif_set_default(netif_add(&ipaddr, &netmask, &gateway, tapif_init, - tcpip_input)); -} - -void _fini(void){ -} diff --git a/proj/unixsim/Makefile b/proj/unixsim/Makefile deleted file mode 100644 index 2dbe136b..00000000 --- a/proj/unixsim/Makefile +++ /dev/null @@ -1,108 +0,0 @@ -# -# Copyright (c) 2001, 2002 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. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. -# -# Author: Adam Dunkels -# - -CCDEP=gcc -CC=gcc -CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG -pedantic -LDFLAGS=-lpcap -LWIPARCH=unix -ARFLAGS=rs -LWIPDIR=../../src -CONTRIBDIR=../../../contrib - -CFLAGS:=$(CFLAGS) \ - -I$(LWIPDIR)/include -I$(CONTRIBDIR)/ports/$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \ - -Iapps -I. - -# COREFILES, CORE4FILES: The minimum set of files needed for lwIP. -COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \ - $(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \ - $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \ - $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c -CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/inet.c - - -# APIFILES: The files which implement the sequential and socket APIs. -APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \ - $(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c - -# NETIFFILES: Files implementing various generic network interface functions.' -NETIFFILES=$(LWIPDIR)/netif/loopif.c \ - $(LWIPDIR)/netif/etharp.c $(LWIPDIR)/netif/slipif.c - -# ARCHFILES: Archiecture specific files. -ARCHFILES=$(wildcard $(CONTRIBDIR)/ports/$(LWIPARCH)/*.c $(CONTRIBDIR)/ports/$(LWIPARCH)/netif/*.c) - -# APPFILES: Applications. -APPFILES=apps/fs.c apps/httpd.c \ - apps/udpecho.c apps/tcpecho.c \ - apps/shell.c - -# LWIPFILES: All the above. -LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES) -LWIPFILESW=$(wildcard $(LWIPFILES)) -LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o)) - -LWIPLIB=liblwip4.a -APPLIB=liblwipapps.a -APPOBJS=$(notdir $(APPFILES:.c=.o)) - -%.o: - $(CC) $(CFLAGS) -c $(<:.o=.c) - -all ipv4 compile: simhost -.PHONY: all - -clean: - rm -f *.o $(LWIPLIB) $(APPLIB) simhost simnode simrouter *.s .depend* *.core core - -depend dep: .depend - -include .depend - -$(APPLIB): $(APPOBJS) - $(AR) $(ARFLAGS) $(APPLIB) $? - -$(LWIPLIB): $(LWIPOBJS) - $(AR) $(ARFLAGS) $(LWIPLIB) $? - -.depend: simhost.c simnode.c simrouter.c $(LWIPFILES) $(APPFILES) - $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend - -simhost: .depend $(LWIPLIB) $(APPLIB) simhost.o $(APPFILES) - $(CC) $(CFLAGS) $(LDFLAGS) -pthread -o simhost simhost.o $(APPLIB) $(LWIPLIB) - -simrouter: .depend $(LWIPLIB) $(APPLIB) simrouter.o - $(CC) $(CFLAGS) $(LDFLAGS) -pthread -o simrouter simrouter.o $(APPLIB) $(LWIPLIB) - -simnode: .depend $(LWIPLIB) $(APPLIB) simnode.o - $(CC) $(CFLAGS) $(LDFLAGS) -pthread -o simnode simnode.o $(APPLIB) $(LWIPLIB) - diff --git a/proj/unixsim/README b/proj/unixsim/README deleted file mode 100644 index c2125783..00000000 --- a/proj/unixsim/README +++ /dev/null @@ -1,47 +0,0 @@ -This directory contains an example of how a project using lwIP might -look. It is also the development platform of lwIP, since it can be run -as a user process under FreeBSD or Linux. There are also a number of -example applications (including a simple web server) in the apps/ -directory. - -Some short instructions on how to build and run lwIP on a FreeBSD or -Linux host. For FreeBSD, the tap interface must be enabled in the -kernel configuration and the kernel must be recompiled. The tap -interface is enabled by adding the line "pseudo-device tap" in the -kernel configuration. See Chapter 9 in the FreeBSD handbook for -instructions on how to build a custom FreeBSD kernel. - -* Compile the code. This must be done by using GNU Make. Under - FreeBSD, GNU Make can be found in the ports collection under - /usr/ports/devel/gmake (type "make install distclean" to - install). Under Linux, GNU Make is the default "make". - - > gmake (FreeBSD) - - > make (Linux) - -* The compilation process produces the executable file "simhost". To - run this, you have to be root. - - > su (Type password for the root account) - # ./simhost - -* The lwIP TCP/IP stack is now running with IP address - 192.168.0.2. Some things that you can try: - - To see the packets that are going to and from the lwIP stack, run - tcpdump: - - # tcpdump -l -n -i tap0 - - You can ping lwIP: - - > ping 192.168.0.2 - - For a telnet shell, run: - - > telnet 192.168.0.2 - - Finally, "simhost" also includes a simple web server; the URL is - of course http://192.168.0.2/. - diff --git a/proj/unixsim/apps/fs.c b/proj/unixsim/apps/fs.c deleted file mode 100644 index d30049bc..00000000 --- a/proj/unixsim/apps/fs.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#include "lwip/def.h" -#include "fs.h" -#include "fsdata.h" -#include "fsdata.c" - -/*-----------------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------------------*/ -int -fs_open(char *name, struct fs_file *file) -{ - struct fsdata_file_noconst *f; - - for(f = (struct fsdata_file_noconst *)FS_ROOT; - f != NULL; - f = (struct fsdata_file_noconst *)f->next) { - if(!strcmp(name, (char *)f->name)) { - file->data = (char *)f->data; - file->len = f->len; - return 1; - } - } - return 0; -} -/*-----------------------------------------------------------------------------------*/ diff --git a/proj/unixsim/apps/fs.h b/proj/unixsim/apps/fs.h deleted file mode 100644 index 6c4eb10f..00000000 --- a/proj/unixsim/apps/fs.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __FS_H__ -#define __FS_H__ - -struct fs_file { - char *data; - int len; -}; - -/* file must be allocated by caller and will be filled in - by the function. */ -int fs_open(char *name, struct fs_file *file); - -#endif /* __FS_H__ */ diff --git a/proj/unixsim/apps/fs/404.html b/proj/unixsim/apps/fs/404.html deleted file mode 100644 index 6a3c6c93..00000000 --- a/proj/unixsim/apps/fs/404.html +++ /dev/null @@ -1,21 +0,0 @@ - -lwIP - A Lightweight TCP/IP Stack - - - - -
- SICS logo - -

lwIP - A Lightweight TCP/IP Stack

-

404 - Page not found

-

- Sorry, the page you are requesting was not found on this - server. -

-
-   -
- - diff --git a/proj/unixsim/apps/fs/img/sics.gif b/proj/unixsim/apps/fs/img/sics.gif deleted file mode 100644 index 0a4fc7bb..00000000 Binary files a/proj/unixsim/apps/fs/img/sics.gif and /dev/null differ diff --git a/proj/unixsim/apps/fs/index.html b/proj/unixsim/apps/fs/index.html deleted file mode 100644 index 402ae76a..00000000 --- a/proj/unixsim/apps/fs/index.html +++ /dev/null @@ -1,44 +0,0 @@ - -lwIP - A Lightweight TCP/IP Stack - - - - -
- SICS logo - -

lwIP - A Lightweight TCP/IP Stack

-

- The web page you are watching was served by a simple web - server running on top of the lightweight TCP/IP stack lwIP. -

-

- lwIP is an open source implementation of the TCP/IP - protocol suite that was originally written by Adam Dunkels - of the Swedish Institute of Computer Science but now is - being actively developed by a team of developers - distributed world-wide. Since it's release, lwIP has - spurred a lot of interest and has been ported to several - platforms and operating systems. lwIP can be used either - with or without an underlying OS. -

-

- The focus of the lwIP TCP/IP implementation is to reduce - the RAM usage while still having a full scale TCP. This - makes lwIP suitable for use in embedded systems with tens - of kilobytes of free RAM and room for around 40 kilobytes - of code ROM. -

-

- More information about lwIP can be found at the lwIP - homepage at http://www.sics.se/~adam/lwip/. -

-
-   -
- - - diff --git a/proj/unixsim/apps/fsdata.c b/proj/unixsim/apps/fsdata.c deleted file mode 100644 index e2c63a8b..00000000 --- a/proj/unixsim/apps/fsdata.c +++ /dev/null @@ -1,334 +0,0 @@ -static const unsigned char data_img_sics_gif[] = { - /* /img/sics.gif */ - 0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0, - 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, - 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x2f, - 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, 0x28, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, - 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, - 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x29, - 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, - 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, - 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0x47, - 0x49, 0x46, 0x38, 0x39, 0x61, 0x46, 00, 0x22, 00, 0xa5, - 00, 00, 0xd9, 0x2b, 0x39, 0x6a, 0x6a, 0x6a, 0xbf, 0xbf, - 0xbf, 0x93, 0x93, 0x93, 0xf, 0xf, 0xf, 0xb0, 0xb0, 0xb0, - 0xa6, 0xa6, 0xa6, 0x80, 0x80, 0x80, 0x76, 0x76, 0x76, 0x1e, - 0x1e, 0x1e, 0x9d, 0x9d, 0x9d, 0x2e, 0x2e, 0x2e, 0x49, 0x49, - 0x49, 0x54, 0x54, 0x54, 0x8a, 0x8a, 0x8a, 0x60, 0x60, 0x60, - 0xc6, 0xa6, 0x99, 0xbd, 0xb5, 0xb2, 0xc2, 0xab, 0xa1, 0xd9, - 0x41, 0x40, 0xd5, 0x67, 0x55, 0xc0, 0xb0, 0xaa, 0xd5, 0x5e, - 0x4e, 0xd6, 0x50, 0x45, 0xcc, 0x93, 0x7d, 0xc8, 0xa1, 0x90, - 0xce, 0x8b, 0x76, 0xd2, 0x7b, 0x65, 0xd1, 0x84, 0x6d, 0xc9, - 0x99, 0x86, 0x3a, 0x3a, 0x3a, 00, 00, 00, 0xb8, 0xb8, - 0xb8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x2c, 00, 00, 00, 00, 0x46, - 00, 0x22, 00, 00, 0x6, 0xfe, 0x40, 0x90, 0x70, 0x48, - 0x2c, 0x1a, 0x8f, 0xc8, 0xa4, 0x72, 0xc9, 0x6c, 0x3a, 0x9f, - 0xd0, 0xa8, 0x74, 0x4a, 0xad, 0x5a, 0xaf, 0xd8, 0xac, 0x76, - 0xa9, 0x40, 0x4, 0xbe, 0x83, 0xe2, 0x60, 0x3c, 0x50, 0x20, - 0xd, 0x8e, 0x6f, 00, 0x31, 0x28, 0x1c, 0xd, 0x7, 0xb5, - 0xc3, 0x60, 0x75, 0x24, 0x3e, 0xf8, 0xfc, 0x87, 0x11, 0x6, - 0xe9, 0x3d, 0x46, 0x7, 0xb, 0x7a, 0x7a, 0x7c, 0x43, 0x6, - 0x1e, 0x84, 0x78, 0xb, 0x7, 0x6e, 0x51, 0x1, 0x8a, 0x84, - 0x8, 0x7e, 0x79, 0x80, 0x87, 0x89, 0x91, 0x7a, 0x93, 0xa, - 0x4, 0x99, 0x78, 0x96, 0x4f, 0x3, 0x9e, 0x79, 0x1, 0x94, - 0x9f, 0x43, 0x9c, 0xa3, 0xa4, 0x5, 0x77, 0xa3, 0xa0, 0x4e, - 0x98, 0x79, 0xb, 0x1e, 0x83, 0xa4, 0xa6, 0x1f, 0x96, 0x5, - 0x9d, 0xaa, 0x78, 0x1, 0x7, 0x84, 0x4, 0x1e, 0x1e, 0xbb, - 0xb8, 0x51, 0x84, 0xe, 0x43, 0x5, 0x7, 0x77, 0xa5, 0x7f, - 0x42, 0xb1, 0xb2, 0x1, 0x63, 0x8, 0xd, 0xbb, 0x1, 0xc, - 0x7a, 0xd, 0x44, 0xe, 0xd8, 0xaf, 0x4c, 0x5, 0x7a, 0x4, - 0x47, 0x7, 0x7, 0xb7, 0x80, 0xa2, 0xe1, 0x7d, 0x44, 0x5, - 0x1, 0x4, 0x1, 0xd0, 0xea, 0x87, 0x93, 0x4f, 0xe0, 0x9a, - 0x49, 0xce, 0xd8, 0x79, 0x4, 0x66, 0x20, 0x15, 0x10, 0x10, - 0x11, 0x92, 0x29, 0x80, 0xb6, 0xc0, 0x91, 0x15, 0x45, 0x1e, - 0x90, 0x19, 0x71, 0x46, 0xa8, 0x5c, 0x4, 0xe, 00, 0x22, - 0x4e, 0xe8, 0x40, 0x24, 0x9f, 0x3e, 0x4, 0x6, 0xa7, 0x58, - 0xd4, 0x93, 0xa0, 0x1c, 0x91, 0x3f, 0xe8, 0xf0, 0x88, 0x3, - 0xb1, 0x21, 0xa2, 0x49, 00, 0x19, 0x86, 0xfc, 0x52, 0x44, - 0xe0, 0x1, 0x9d, 0x29, 0x21, 0x15, 0x25, 0x50, 0xf7, 0x67, - 0x25, 0x1e, 0x6, 0xfd, 0x4e, 0x9a, 0xb4, 0x90, 0xac, 0x15, - 0xfa, 0xcb, 0x52, 0x53, 0x1e, 0x8c, 0xf2, 0xf8, 0x7, 0x92, - 0x2d, 0x8, 0x3a, 0x4d, 0x12, 0x49, 0x95, 0x49, 0xdb, 0x14, - 0x4, 0xc4, 0x14, 0x85, 0x29, 0xaa, 0xe7, 0x1, 0x8, 0xa4, - 0x49, 0x1, 0x14, 0x51, 0xe0, 0x53, 0x91, 0xd5, 0x29, 0x6, - 0x1a, 0x64, 0x2, 0xf4, 0xc7, 0x81, 0x9e, 0x5, 0x20, 0x22, - 0x64, 0xa5, 0x30, 0xae, 0xab, 0x9e, 0x97, 0x53, 0xd8, 0xb9, - 0xfd, 0x50, 0xef, 0x93, 0x2, 0x42, 0x74, 0x34, 0xe8, 0x9c, - 0x20, 0x21, 0xc9, 0x1, 0x68, 0x78, 0xe6, 0x55, 0x29, 0x20, - 0x56, 0x4f, 0x4c, 0x40, 0x51, 0x71, 0x82, 0xc0, 0x70, 0x21, - 0x22, 0x85, 0xbe, 0x4b, 0x1c, 0x44, 0x5, 0xea, 0xa4, 0x1, - 0xbf, 0x22, 0xb5, 0xf0, 0x1c, 0x6, 0x51, 0x38, 0x8f, 0xe0, - 0x22, 0xec, 0x18, 0xac, 0x39, 0x22, 0xd4, 0xd6, 0x93, 0x44, - 0x1, 0x32, 0x82, 0xc8, 0xfc, 0x61, 0xb3, 0x1, 0x45, 0xc, - 0x2e, 0x83, 0x30, 0xd0, 0xe, 0x17, 0x24, 0xf, 0x70, 0x85, - 0x94, 0xee, 0x5, 0x5, 0x53, 0x4b, 0x32, 0x1b, 0x3f, 0x98, - 0xd3, 0x1d, 0x29, 0x81, 0xb0, 0xae, 0x1e, 0x8c, 0x7e, 0x68, - 0xe0, 0x60, 0x5a, 0x54, 0x8f, 0xb0, 0x78, 0x69, 0x73, 0x6, - 0xa2, 00, 0x6b, 0x57, 0xca, 0x3d, 0x11, 0x50, 0xbd, 0x4, - 0x30, 0x4b, 0x3a, 0xd4, 0xab, 0x5f, 0x1f, 0x9b, 0x3d, 0x13, - 0x74, 0x27, 0x88, 0x3c, 0x25, 0xe0, 0x17, 0xbe, 0x7a, 0x79, - 0x45, 0xd, 0xc, 0xb0, 0x8b, 0xda, 0x90, 0xca, 0x80, 0x6, - 0x5d, 0x17, 0x60, 0x1c, 0x22, 0x4c, 0xd8, 0x57, 0x22, 0x6, - 0x20, 00, 0x98, 0x7, 0x8, 0xe4, 0x56, 0x80, 0x80, 0x1c, - 0xc5, 0xb7, 0xc5, 0x82, 0xc, 0x36, 0xe8, 0xe0, 0x83, 0x10, - 0x46, 0x28, 0xe1, 0x84, 0x14, 0x56, 0x68, 0xa1, 0x10, 0x41, - 00, 00, 0x3b, }; - -static const unsigned char data_404_html[] = { - /* /404.html */ - 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, - 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, - 0x30, 0x34, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, - 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, - 0x50, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, - 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, - 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, - 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, - 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, - 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, - 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x68, - 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, - 0x3e, 0x6c, 0x77, 0x49, 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, - 0x4c, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, - 0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, - 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, - 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, - 0x22, 0x20, 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, - 0x61, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x20, - 0x20, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, - 0x64, 0x74, 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, - 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, - 0x72, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, - 0x74, 0x6f, 0x70, 0x22, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, - 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x38, 0x30, 0x22, 0x3e, - 0x9, 0x20, 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x61, 0x20, - 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, - 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x22, 0x3e, 0x3c, 0x69, 0x6d, - 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x69, 0x6d, 0x67, - 0x2f, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0x22, - 0xa, 0x9, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x3d, 0x22, 0x30, 0x22, 0x20, 0x61, 0x6c, 0x74, 0x3d, 0x22, - 0x53, 0x49, 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, - 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3d, 0x22, 0x53, 0x49, - 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x3e, 0x3c, - 0x2f, 0x61, 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, - 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, - 0x22, 0x35, 0x30, 0x30, 0x22, 0x3e, 0x9, 0x20, 0x20, 0xa, - 0x9, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x6c, 0x77, 0x49, - 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, 0x67, 0x68, - 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, 0x43, - 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b, - 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, - 0x68, 0x32, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x50, - 0x61, 0x67, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, - 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xa, 0x9, - 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, - 0x20, 0x53, 0x6f, 0x72, 0x72, 0x79, 0x2c, 0x20, 0x74, 0x68, - 0x65, 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x79, 0x6f, 0x75, - 0x20, 0x61, 0x72, 0x65, 0x20, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20, - 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, - 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73, 0xa, 0x9, 0x20, - 0x20, 0x20, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, - 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, - 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, - 0xa, 0x9, 0x20, 0x20, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, - 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, - 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, - 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, - 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, - 0x6d, 0x6c, 0x3e, 0xa, }; - -static const unsigned char data_index_html[] = { - /* /index.html */ - 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, - 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, - 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x2f, - 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, 0x28, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, - 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, - 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x29, - 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, - 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, - 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0x3c, - 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x68, 0x65, 0x61, - 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x6c, - 0x77, 0x49, 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, - 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, - 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, - 0x63, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, - 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x3c, 0x62, - 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, 0x20, - 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, - 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, - 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x72, 0x20, - 0x76, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x74, 0x6f, - 0x70, 0x22, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, - 0x74, 0x68, 0x3d, 0x22, 0x38, 0x30, 0x22, 0x3e, 0x9, 0x20, - 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, - 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, - 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, - 0x73, 0x65, 0x2f, 0x22, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, - 0x73, 0x72, 0x63, 0x3d, 0x22, 0x69, 0x6d, 0x67, 0x2f, 0x73, - 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0x22, 0xa, 0x9, - 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, - 0x30, 0x22, 0x20, 0x61, 0x6c, 0x74, 0x3d, 0x22, 0x53, 0x49, - 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x20, 0x74, - 0x69, 0x74, 0x6c, 0x65, 0x3d, 0x22, 0x53, 0x49, 0x43, 0x53, - 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x3e, 0x3c, 0x2f, 0x61, - 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, - 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x35, - 0x30, 0x30, 0x22, 0x3e, 0x9, 0x20, 0x20, 0xa, 0x9, 0x20, - 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x6c, 0x77, 0x49, 0x50, 0x20, - 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x77, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, 0x43, 0x50, 0x2f, - 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, - 0x68, 0x31, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, - 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x65, 0x20, - 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x79, - 0x6f, 0x75, 0x20, 0x61, 0x72, 0x65, 0x20, 0x77, 0x61, 0x74, - 0x63, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, - 0x61, 0x20, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x77, - 0x65, 0x62, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, - 0x6e, 0x67, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, - 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69, 0x67, - 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, - 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x73, 0x74, 0x61, 0x63, - 0x6b, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, - 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, - 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, - 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x6c, 0x77, - 0x49, 0x50, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20, - 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, - 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x77, - 0x49, 0x50, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x6f, - 0x70, 0x65, 0x6e, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, - 0x68, 0x65, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, - 0x9, 0x20, 0x20, 0x20, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x20, 0x73, 0x75, 0x69, 0x74, 0x65, 0x20, - 0x74, 0x68, 0x61, 0x74, 0x20, 0x77, 0x61, 0x73, 0x20, 0x6f, - 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x20, - 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, 0x62, 0x79, - 0x20, 0x41, 0x64, 0x61, 0x6d, 0x20, 0x44, 0x75, 0x6e, 0x6b, - 0x65, 0x6c, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, - 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x53, 0x77, 0x65, 0x64, - 0x69, 0x73, 0x68, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, - 0x75, 0x74, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x43, 0x6f, 0x6d, - 0x70, 0x75, 0x74, 0x65, 0x72, 0x20, 0x53, 0x63, 0x69, 0x65, - 0x6e, 0x63, 0x65, 0x20, 0x62, 0x75, 0x74, 0x20, 0x6e, 0x6f, - 0x77, 0x20, 0x69, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, - 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x76, 0x65, 0x6c, - 0x6f, 0x70, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x61, 0x20, - 0x74, 0x65, 0x61, 0x6d, 0x20, 0x6f, 0x66, 0x20, 0x64, 0x65, - 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x73, 0xa, 0x9, - 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x64, 0x20, 0x77, 0x6f, 0x72, 0x6c, - 0x64, 0x2d, 0x77, 0x69, 0x64, 0x65, 0x2e, 0x20, 0x53, 0x69, - 0x6e, 0x63, 0x65, 0x20, 0x69, 0x74, 0x27, 0x73, 0x20, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2c, 0x20, 0x6c, 0x77, - 0x49, 0x50, 0x20, 0x68, 0x61, 0x73, 0xa, 0x9, 0x20, 0x20, - 0x20, 0x20, 0x73, 0x70, 0x75, 0x72, 0x72, 0x65, 0x64, 0x20, - 0x61, 0x20, 0x6c, 0x6f, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x20, 0x61, 0x6e, - 0x64, 0x20, 0x68, 0x61, 0x73, 0x20, 0x62, 0x65, 0x65, 0x6e, - 0x20, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x74, 0x6f, - 0x20, 0x73, 0x65, 0x76, 0x65, 0x72, 0x61, 0x6c, 0xa, 0x9, - 0x20, 0x20, 0x20, 0x20, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, - 0x72, 0x6d, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6f, 0x70, - 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2e, 0x20, 0x6c, 0x77, 0x49, - 0x50, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x75, - 0x73, 0x65, 0x64, 0x20, 0x65, 0x69, 0x74, 0x68, 0x65, 0x72, - 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x74, 0x68, - 0x20, 0x6f, 0x72, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, - 0x74, 0x20, 0x61, 0x6e, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, - 0x6c, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x4f, 0x53, 0x2e, 0xa, - 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, - 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, - 0x54, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x20, - 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x77, 0x49, - 0x50, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x69, - 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x74, 0x6f, 0x20, - 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0xa, 0x9, 0x20, 0x20, - 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x52, 0x41, 0x4d, 0x20, - 0x75, 0x73, 0x61, 0x67, 0x65, 0x20, 0x77, 0x68, 0x69, 0x6c, - 0x65, 0x20, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x20, 0x68, 0x61, - 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6c, - 0x6c, 0x20, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x54, 0x43, - 0x50, 0x2e, 0x20, 0x54, 0x68, 0x69, 0x73, 0xa, 0x9, 0x20, - 0x20, 0x20, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6c, - 0x77, 0x49, 0x50, 0x20, 0x73, 0x75, 0x69, 0x74, 0x61, 0x62, - 0x6c, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x75, 0x73, 0x65, - 0x20, 0x69, 0x6e, 0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, - 0x65, 0x64, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, - 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x65, 0x6e, 0x73, - 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x20, 0x6b, - 0x69, 0x6c, 0x6f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x20, 0x6f, - 0x66, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20, 0x52, 0x41, 0x4d, - 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x6f, 0x6f, 0x6d, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x61, 0x72, 0x6f, 0x75, 0x6e, 0x64, - 0x20, 0x34, 0x30, 0x20, 0x6b, 0x69, 0x6c, 0x6f, 0x62, 0x79, - 0x74, 0x65, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, - 0x66, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x52, 0x4f, 0x4d, - 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, - 0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, - 0x20, 0x20, 0x4d, 0x6f, 0x72, 0x65, 0x20, 0x69, 0x6e, 0x66, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, - 0x62, 0x6f, 0x75, 0x74, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x20, - 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x66, 0x6f, 0x75, - 0x6e, 0x64, 0x20, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x6c, 0x77, 0x49, 0x50, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, - 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x20, 0x61, - 0x74, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, - 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, - 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, - 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x68, 0x74, - 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, - 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, - 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x3c, 0x2f, - 0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, - 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, - 0x64, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x26, 0x6e, 0x62, 0x73, - 0x70, 0x3b, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, - 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, - 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, - 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0xa, }; - -const struct fsdata_file file_img_sics_gif[] = {{NULL, data_img_sics_gif, data_img_sics_gif + 14, sizeof(data_img_sics_gif) - 14}}; - -const struct fsdata_file file_404_html[] = {{file_img_sics_gif, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}}; - -const struct fsdata_file file_index_html[] = {{file_404_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}}; - -#define FS_ROOT file_index_html - -#define FS_NUMFILES 3 diff --git a/proj/unixsim/apps/fsdata.h b/proj/unixsim/apps/fsdata.h deleted file mode 100644 index ee4947bb..00000000 --- a/proj/unixsim/apps/fsdata.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __FSDATA_H__ -#define __FSDATA_H__ - -struct fsdata_file { - const struct fsdata_file *next; - const unsigned char *name; - const unsigned char *data; - const int len; -}; - -struct fsdata_file_noconst { - struct fsdata_file *next; - unsigned char *name; - unsigned char *data; - int len; -}; - -#endif /* __FSDATA_H__ */ diff --git a/proj/unixsim/apps/httpd.c b/proj/unixsim/apps/httpd.c deleted file mode 100644 index 8174c68f..00000000 --- a/proj/unixsim/apps/httpd.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/debug.h" - -#include "lwip/stats.h" - -#include "httpd.h" - -#include "lwip/tcp.h" - -#include "fs.h" - -struct http_state { - char *file; - u32_t left; - u8_t retries; -}; - -/*-----------------------------------------------------------------------------------*/ -static void -conn_err(void *arg, err_t err) -{ - struct http_state *hs; - - hs = arg; - mem_free(hs); -} -/*-----------------------------------------------------------------------------------*/ -static void -close_conn(struct tcp_pcb *pcb, struct http_state *hs) -{ - tcp_arg(pcb, NULL); - tcp_sent(pcb, NULL); - tcp_recv(pcb, NULL); - mem_free(hs); - tcp_close(pcb); -} -/*-----------------------------------------------------------------------------------*/ -static void -send_data(struct tcp_pcb *pcb, struct http_state *hs) -{ - err_t err; - u16_t len; - - /* We cannot send more data than space avaliable in the send - buffer. */ - if(tcp_sndbuf(pcb) < hs->left) { - len = tcp_sndbuf(pcb); - } else { - len = hs->left; - } - - do { - err = tcp_write(pcb, hs->file, len, 0); - if(err == ERR_MEM) { - len /= 2; - } - } while(err == ERR_MEM && len > 1); - - if(err == ERR_OK) { - hs->file += len; - hs->left -= len; - /* } else { - printf("send_data: error %s len %d %d\n", lwip_strerr(err), len, tcp_sndbuf(pcb));*/ - } -} -/*-----------------------------------------------------------------------------------*/ -static err_t -http_poll(void *arg, struct tcp_pcb *pcb) -{ - struct http_state *hs; - - hs = arg; - - /* printf("Polll\n");*/ - if(hs == NULL) { - /* printf("Null, close\n");*/ - tcp_abort(pcb); - return ERR_ABRT; - } else { - ++hs->retries; - if(hs->retries == 4) { - tcp_abort(pcb); - return ERR_ABRT; - } - send_data(pcb, hs); - } - - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -static err_t -http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) -{ - struct http_state *hs; - - hs = arg; - - hs->retries = 0; - - if(hs->left > 0) { - send_data(pcb, hs); - } else { - close_conn(pcb, hs); - } - - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -static err_t -http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) -{ - int i; - char *data; - struct fs_file file; - struct http_state *hs; - - hs = arg; - - if(err == ERR_OK && p != NULL) { - - /* Inform TCP that we have taken the data. */ - tcp_recved(pcb, p->tot_len); - - if(hs->file == NULL) { - data = p->payload; - - if(strncmp(data, "GET ", 4) == 0) { - for(i = 0; i < 40; i++) { - if(((char *)data + 4)[i] == ' ' || - ((char *)data + 4)[i] == '\r' || - ((char *)data + 4)[i] == '\n') { - ((char *)data + 4)[i] = 0; - } - } - - if(*(char *)(data + 4) == '/' && - *(char *)(data + 5) == 0) { - fs_open("/index.html", &file); - } else if(!fs_open((char *)data + 4, &file)) { - fs_open("/404.html", &file); - } - hs->file = file.data; - hs->left = file.len; - /* printf("data %p len %ld\n", hs->file, hs->left);*/ - - pbuf_free(p); - send_data(pcb, hs); - - /* Tell TCP that we wish be to informed of data that has been - successfully sent by a call to the http_sent() function. */ - tcp_sent(pcb, http_sent); - } else { - pbuf_free(p); - close_conn(pcb, hs); - } - } else { - pbuf_free(p); - } - } - - if(err == ERR_OK && p == NULL) { - close_conn(pcb, hs); - } - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -static err_t -http_accept(void *arg, struct tcp_pcb *pcb, err_t err) -{ - struct http_state *hs; - - tcp_setprio(pcb, TCP_PRIO_MIN); - - /* Allocate memory for the structure that holds the state of the - connection. */ - hs = mem_malloc(sizeof(struct http_state)); - - if(hs == NULL) { - printf("http_accept: Out of memory\n"); - return ERR_MEM; - } - - /* Initialize the structure. */ - hs->file = NULL; - hs->left = 0; - hs->retries = 0; - - /* Tell TCP that this is the structure we wish to be passed for our - callbacks. */ - tcp_arg(pcb, hs); - - /* Tell TCP that we wish to be informed of incoming data by a call - to the http_recv() function. */ - tcp_recv(pcb, http_recv); - - tcp_err(pcb, conn_err); - - tcp_poll(pcb, http_poll, 4); - return ERR_OK; -} -/*-----------------------------------------------------------------------------------*/ -void -httpd_init(void) -{ - struct tcp_pcb *pcb; - - pcb = tcp_new(); - tcp_bind(pcb, IP_ADDR_ANY, 80); - pcb = tcp_listen(pcb); - tcp_accept(pcb, http_accept); -} -/*-----------------------------------------------------------------------------------*/ - diff --git a/proj/unixsim/apps/httpd.h b/proj/unixsim/apps/httpd.h deleted file mode 100644 index 4602fd4c..00000000 --- a/proj/unixsim/apps/httpd.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __HTTPD_H__ -#define __HTTPD_H__ - -void httpd_init(void); - -#endif /* __HTTPD_H__ */ diff --git a/proj/unixsim/apps/makefsdata b/proj/unixsim/apps/makefsdata deleted file mode 100644 index 37b4203e..00000000 --- a/proj/unixsim/apps/makefsdata +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/perl - -open(OUTPUT, "> fsdata.c"); - -chdir("fs"); -open(FILES, "find . -type f |"); - -while($file = ) { - - # Do not include files in CVS directories nor backup files. - if($file =~ /(CVS|~)/) { - next; - } - - chop($file); - - open(HEADER, "> /tmp/header") || die $!; - if($file =~ /404/) { - print(HEADER "HTTP/1.0 404 File not found\r\n"); - } else { - print(HEADER "HTTP/1.0 200 OK\r\n"); - } - print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n"); - if($file =~ /\.html$/) { - print(HEADER "Content-type: text/html\r\n"); - } elsif($file =~ /\.gif$/) { - print(HEADER "Content-type: image/gif\r\n"); - } elsif($file =~ /\.png$/) { - print(HEADER "Content-type: image/png\r\n"); - } elsif($file =~ /\.jpg$/) { - print(HEADER "Content-type: image/jpeg\r\n"); - } elsif($file =~ /\.class$/) { - print(HEADER "Content-type: application/octet-stream\r\n"); - } elsif($file =~ /\.ram$/) { - print(HEADER "Content-type: audio/x-pn-realaudio\r\n"); - } else { - print(HEADER "Content-type: text/plain\r\n"); - } - print(HEADER "\r\n"); - close(HEADER); - - unless($file =~ /\.plain$/ || $file =~ /cgi/) { - system("cat /tmp/header $file > /tmp/file"); - } else { - system("cp $file /tmp/file"); - } - - open(FILE, "/tmp/file"); - unlink("/tmp/file"); - unlink("/tmp/header"); - - $file =~ s/\.//; - $fvar = $file; - $fvar =~ s-/-_-g; - $fvar =~ s-\.-_-g; - print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); - print(OUTPUT "\t/* $file */\n\t"); - for($j = 0; $j < length($file); $j++) { - printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); - } - printf(OUTPUT "0,\n"); - - - $i = 0; - while(read(FILE, $data, 1)) { - if($i == 0) { - print(OUTPUT "\t"); - } - printf(OUTPUT "%#02x, ", unpack("C", $data)); - $i++; - if($i == 10) { - print(OUTPUT "\n"); - $i = 0; - } - } - print(OUTPUT "};\n\n"); - close(FILE); - push(@fvars, $fvar); - push(@files, $file); -} - -for($i = 0; $i < @fvars; $i++) { - $file = $files[$i]; - $fvar = $fvars[$i]; - - if($i == 0) { - $prevfile = "NULL"; - } else { - $prevfile = "file" . $fvars[$i - 1]; - } - print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); - print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); - print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); -} - -print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n"); -print(OUTPUT "#define FS_NUMFILES $i\n"); diff --git a/proj/unixsim/apps/shell.c b/proj/unixsim/apps/shell.c deleted file mode 100644 index 65788995..00000000 --- a/proj/unixsim/apps/shell.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include -#include - -#include "lwip/mem.h" -#include "lwip/debug.h" -#include "lwip/def.h" -#include "lwip/api.h" -#include "lwip/stats.h" - -static unsigned char buffer[1024]; - -struct command { - struct netconn *conn; - s8_t (* exec)(struct command *); - u8_t nargs; - char *args[10]; -}; - -/* Following #undefs are here to keep compiler from issuing warnings - about them being double defined. (They are defined in lwip/inet.h - as well as the Unix #includes below.) */ -#undef htonl -#undef ntohl -#undef htons -#undef ntohs -#undef HTONL -#undef NTOHL -#undef HTONS -#undef NTOHS -#undef IP_HDRINCL - -#include -#include -#include -#include -#include -#include -#include -#include - -#define ESUCCESS 0 -#define ESYNTAX -1 -#define ETOOFEW -2 -#define ETOOMANY -3 -#define ECLOSED -4 - -#define NCONNS 10 -static struct netconn *conns[NCONNS]; - -static char help_msg[] = "Avaliable commands:\n\ -open [IP address] [TCP port]: opens a TCP connection to the specified address.\n\ -lstn [TCP port]: sets up a server on the specified port.\n\ -acpt [connection #]: waits for an incoming connection request.\n\ -send [connection #] [message]: sends a message on a TCP connection.\n\ -udpc [local UDP port] [IP address] [remote port]: opens a UDP \"connection\".\n\ -udpl [local UDP port] [IP address] [remote port]: opens a UDP-Lite \"connection\".\n\ -udpn [local UDP port] [IP address] [remote port]: opens a UDP \"connection\" without checksums.\n\ -udpb [local port] [remote port]: opens a UDP broadcast \"connection\".\n\ -usnd [connection #] [message]: sends a message on a UDP connection.\n\ -recv [connection #]: recieves data on a TCP or UDP connection.\n\ -clos [connection #]: closes a TCP or UDP connection.\n\ -stat: prints out lwIP statistics.\n\ -quit: quits.\n"; - -static char *stat_msgs[] = { - "Link level * transmitted ", - " retransmitted ", - " * received ", - " forwarded ", - " * dropped ", - " * checksum errors ", - " * length errors ", - " * memory errors ", - " routing errors ", - " protocol errors ", - " option errors ", - " * misc errors ", - " cache hits ", - "IP * transmitted ", - " retransmitted ", - " * received ", - " * forwarded ", - " * dropped ", - " * checksum errors ", - " * length errors ", - " * memory errors ", - " * routing errors ", - " * protocol errors ", - " * option errors ", - " * misc errors ", - " cache hits ", - "ICMP * transmitted ", - " retransmitted ", - " * received ", - " forwarded ", - " * dropped ", - " * checksum errors ", - " length errors ", - " * memory errors ", - " routing errors ", - " * protocol errors ", - " option errors ", - " * misc errors ", - " cache hits ", - "UDP * transmitted ", - " retransmitted ", - " * received ", - " forwarded ", - " * dropped ", - " * checksum errors ", - " * length errors ", - " * memory errors ", - " * routing errors ", - " * protocol errors ", - " option errors ", - " * misc errors ", - " cache hits ", - "TCP * transmitted ", - " * retransmitted ", - " * received ", - " forwarded ", - " * dropped ", - " * checksum errors ", - " * length errors ", - " * memory errors ", - " * routing errors ", - " * protocol errors ", - " * option errors ", - " * misc errors ", - " * cache hits ", - "Pbufs * avaiable ", - " * used ", - " * high water mark ", - " * errors ", - " reclaimed ", - " pbuf_alloc() locked ", - " pbuf_refresh() locked ", - "Memory * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "Memp PBUF * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "UDP PCB * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "TCP PCB * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "TCP LISTEN * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "TCP SEG * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "Netbufs * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "Netconns * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "API msgs * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "TCPIP msgs * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "Timeouts * avaliable ", - " * used ", - " * high water mark ", - " * errors ", - " * reclaimed ", - "Semaphores * used ", - " * high water mark ", - " * errors ", - "Mailboxes * used ", - " * high water mark ", - " * errors " -}; -/*-----------------------------------------------------------------------------------*/ -static void -sendstr(const char *str, struct netconn *conn) -{ - netconn_write(conn, (void *)str, strlen(str), NETCONN_NOCOPY); -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_open(struct command *com) -{ - struct ip_addr ipaddr; - u16_t port; - int i; - err_t err; - - if(inet_aton(com->args[0], (struct in_addr *)&ipaddr) == -1) { - sendstr(strerror(errno), com->conn); - return ESYNTAX; - } - port = strtol(com->args[1], NULL, 10); - - /* Find the first unused connection in conns. */ - for(i = 0; i < NCONNS && conns[i] != NULL; i++); - - if(i == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - sendstr("Opening connection to ", com->conn); - netconn_write(com->conn, com->args[0], strlen(com->args[0]), NETCONN_COPY); - sendstr(":", com->conn); - netconn_write(com->conn, com->args[1], strlen(com->args[1]), NETCONN_COPY); - sendstr("\n", com->conn); - - conns[i] = netconn_new(NETCONN_TCP); - if(conns[i] == NULL) { - sendstr("Could not create connection identifier (out of memory).\n", com->conn); - return ESUCCESS; - } - err = netconn_connect(conns[i], &ipaddr, port); - if(err != ERR_OK) { - fprintf(stderr, "error %s\n", lwip_strerr(err)); - sendstr("Could not connect to remote host: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - netconn_delete(conns[i]); - conns[i] = NULL; - return ESUCCESS; - } - - sendstr("Opened connection, connection identifier is ", com->conn); - sprintf((char *)buffer, "%d\n", i); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_lstn(struct command *com) -{ - u16_t port; - int i; - err_t err; - - port = strtol(com->args[0], NULL, 10); - - /* Find the first unused connection in conns. */ - for(i = 0; i < NCONNS && conns[i] != NULL; i++); - - if(i == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - sendstr("Opening a listening connection on port ", com->conn); - netconn_write(com->conn, com->args[0], strlen(com->args[0]), NETCONN_COPY); - sendstr("\n", com->conn); - - conns[i] = netconn_new(NETCONN_TCP); - if(conns[i] == NULL) { - sendstr("Could not create connection identifier (out of memory).\n", com->conn); - return ESUCCESS; - } - - err = netconn_bind(conns[i], IP_ADDR_ANY, port); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not bind: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - err = netconn_listen(conns[i]); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not listen: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Opened connection, connection identifier is ", com->conn); - sprintf((char *)buffer, "%d\n", i); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_clos(struct command *com) -{ - int i; - err_t err; - - i = strtol(com->args[0], NULL, 10); - - if(i > NCONNS) { - sendstr("Connection identifier too high.\n", com->conn); - return ESUCCESS; - } - if(conns[i] == NULL) { - sendstr("Connection identifier not in use.\n", com->conn); - return ESUCCESS; - } - - err = netconn_close(conns[i]); - if(err != ERR_OK) { - sendstr("Could not close connection: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Connection closed.\n", com->conn); - netconn_delete(conns[i]); - conns[i] = NULL; - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_acpt(struct command *com) -{ - int i, j; - - /* Find the first unused connection in conns. */ - for(j = 0; j < NCONNS && conns[j] != NULL; j++); - - if(j == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - i = strtol(com->args[0], NULL, 10); - - if(i > NCONNS) { - sendstr("Connection identifier too high.\n", com->conn); - return ESUCCESS; - } - if(conns[i] == NULL) { - sendstr("Connection identifier not in use.\n", com->conn); - return ESUCCESS; - } - - conns[j] = netconn_accept(conns[i]); - - if(conns[j] == NULL) { - sendstr("Could not accept connection: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(netconn_err(conns[i])), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Accepted connection, connection identifier for new connection is ", com->conn); - sprintf((char *)buffer, "%d\n", j); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_stat(struct command *com) -{ - int i; - char buf[100]; - u16_t len; - - for(i = 0; i < sizeof(struct stats_) / 2; i++) { - len = sprintf(buf, "%d", ((u16_t *)&lwip_stats)[i]); - sendstr(stat_msgs[i], com->conn); - netconn_write(com->conn, buf, len, NETCONN_COPY); - sendstr("\n", com->conn); - } - - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_send(struct command *com) -{ - int i; - err_t err; - int len; - - i = strtol(com->args[0], NULL, 10); - - if(i > NCONNS) { - sendstr("Connection identifier too high.\n", com->conn); - return ESUCCESS; - } - - if(conns[i] == NULL) { - sendstr("Connection identifier not in use.\n", com->conn); - return ESUCCESS; - } - - len = strlen(com->args[1]); - com->args[1][len] = '\r'; - com->args[1][len + 1] = '\n'; - com->args[1][len + 2] = 0; - - err = netconn_write(conns[i], com->args[1], len + 3, NETCONN_COPY); - if(err != ERR_OK) { - sendstr("Could not send data: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Data enqueued for sending.\n", com->conn); - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_recv(struct command *com) -{ - int i; - err_t err; - struct netbuf *buf; - u16_t len; - - i = strtol(com->args[0], NULL, 10); - - if(i > NCONNS) { - sendstr("Connection identifier too high.\n", com->conn); - return ESUCCESS; - } - - if(conns[i] == NULL) { - sendstr("Connection identifier not in use.\n", com->conn); - return ESUCCESS; - } - - buf = netconn_recv(conns[i]); - if(buf != NULL) { - - netbuf_copy(buf, buffer, 1024); - len = netbuf_len(buf); - sendstr("Reading from connection:\n", com->conn); - netconn_write(com->conn, buffer, len, NETCONN_COPY); - netbuf_delete(buf); - } else { - sendstr("EOF.\n", com->conn); - } - err = netconn_err(conns[i]); - if(err != ERR_OK) { - sendstr("Could not receive data: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_udpc(struct command *com) -{ - struct ip_addr ipaddr; - u16_t lport, rport; - int i; - err_t err; - - lport = strtol(com->args[0], NULL, 10); - if(inet_aton(com->args[1], (struct in_addr *)&ipaddr) == -1) { - sendstr(strerror(errno), com->conn); - return ESYNTAX; - } - rport = strtol(com->args[2], NULL, 10); - - /* Find the first unused connection in conns. */ - for(i = 0; i < NCONNS && conns[i] != NULL; i++); - - if(i == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - sendstr("Setting up UDP connection from port ", com->conn); - netconn_write(com->conn, com->args[0], strlen(com->args[0]), NETCONN_COPY); - sendstr(" to ", com->conn); - netconn_write(com->conn, com->args[1], strlen(com->args[1]), NETCONN_COPY); - sendstr(":", com->conn); - netconn_write(com->conn, com->args[2], strlen(com->args[2]), NETCONN_COPY); - sendstr("\n", com->conn); - - conns[i] = netconn_new(NETCONN_UDP); - if(conns[i] == NULL) { - sendstr("Could not create connection identifier (out of memory).\n", com->conn); - return ESUCCESS; - } - - err = netconn_connect(conns[i], &ipaddr, rport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not connect to remote host: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - err = netconn_bind(conns[i], IP_ADDR_ANY, lport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not bind: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Connection set up, connection identifier is ", com->conn); - sprintf((char *)buffer, "%d\n", i); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_udpl(struct command *com) -{ - struct ip_addr ipaddr; - u16_t lport, rport; - int i; - err_t err; - - lport = strtol(com->args[0], NULL, 10); - if(inet_aton(com->args[1], (struct in_addr *)&ipaddr) == -1) { - sendstr(strerror(errno), com->conn); - return ESYNTAX; - } - rport = strtol(com->args[2], NULL, 10); - - /* Find the first unused connection in conns. */ - for(i = 0; i < NCONNS && conns[i] != NULL; i++); - - if(i == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - sendstr("Setting up UDP-Lite connection from port ", com->conn); - netconn_write(com->conn, com->args[0], strlen(com->args[0]), NETCONN_COPY); - sendstr(" to ", com->conn); - netconn_write(com->conn, com->args[1], strlen(com->args[1]), NETCONN_COPY); - sendstr(":", com->conn); - netconn_write(com->conn, com->args[2], strlen(com->args[2]), NETCONN_COPY); - sendstr("\n", com->conn); - - conns[i] = netconn_new(NETCONN_UDPLITE); - if(conns[i] == NULL) { - sendstr("Could not create connection identifier (out of memory).\n", com->conn); - return ESUCCESS; - } - - err = netconn_connect(conns[i], &ipaddr, rport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not connect to remote host: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - err = netconn_bind(conns[i], IP_ADDR_ANY, lport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not bind: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Connection set up, connection identifier is ", com->conn); - sprintf((char *)buffer, "%d\n", i); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_udpn(struct command *com) -{ - struct ip_addr ipaddr; - u16_t lport, rport; - int i; - err_t err; - - lport = strtol(com->args[0], NULL, 10); - if(inet_aton(com->args[1], (struct in_addr *)&ipaddr) == -1) { - sendstr(strerror(errno), com->conn); - return ESYNTAX; - } - rport = strtol(com->args[2], NULL, 10); - - /* Find the first unused connection in conns. */ - for(i = 0; i < NCONNS && conns[i] != NULL; i++); - - if(i == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - sendstr("Setting up UDP connection without checksums from port ", com->conn); - netconn_write(com->conn, com->args[0], strlen(com->args[0]), NETCONN_COPY); - sendstr(" to ", com->conn); - netconn_write(com->conn, com->args[1], strlen(com->args[1]), NETCONN_COPY); - sendstr(":", com->conn); - netconn_write(com->conn, com->args[2], strlen(com->args[2]), NETCONN_COPY); - sendstr("\n", com->conn); - - conns[i] = netconn_new(NETCONN_UDPNOCHKSUM); - if(conns[i] == NULL) { - sendstr("Could not create connection identifier (out of memory).\n", com->conn); - return ESUCCESS; - } - - err = netconn_connect(conns[i], &ipaddr, rport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not connect to remote host: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - err = netconn_bind(conns[i], IP_ADDR_ANY, lport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not bind: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Connection set up, connection identifier is ", com->conn); - sprintf((char *)buffer, "%d\n", i); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_udpb(struct command *com) -{ - struct ip_addr ipaddr; - u16_t lport, rport; - int i; - err_t err; - struct ip_addr bcaddr; - - lport = strtol(com->args[0], NULL, 10); - if(inet_aton(com->args[1], (struct in_addr *)&ipaddr) == -1) { - sendstr(strerror(errno), com->conn); - return ESYNTAX; - } - rport = strtol(com->args[2], NULL, 10); - - /* Find the first unused connection in conns. */ - for(i = 0; i < NCONNS && conns[i] != NULL; i++); - - if(i == NCONNS) { - sendstr("No more connections avaliable, sorry.\n", com->conn); - return ESUCCESS; - } - - sendstr("Setting up UDP broadcast connection from port ", com->conn); - netconn_write(com->conn, com->args[0], strlen(com->args[0]), NETCONN_COPY); - sendstr(" to ", com->conn); - netconn_write(com->conn, com->args[1], strlen(com->args[1]), NETCONN_COPY); - sendstr("\n", com->conn); - - conns[i] = netconn_new(NETCONN_UDP); - if(conns[i] == NULL) { - sendstr("Could not create connection identifier (out of memory).\n", com->conn); - return ESUCCESS; - } - - err = netconn_connect(conns[i], &ipaddr, rport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not connect to remote host: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - IP4_ADDR(&bcaddr, 255,255,255,255); - err = netconn_bind(conns[i], &bcaddr, lport); - if(err != ERR_OK) { - netconn_delete(conns[i]); - conns[i] = NULL; - sendstr("Could not bind: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Connection set up, connection identifier is ", com->conn); - sprintf((char *)buffer, "%d\n", i); - netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY); - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_usnd(struct command *com) -{ - int i; - err_t err; - struct netbuf *buf; - char *mem; - - i = strtol(com->args[0], NULL, 10); - - if(i > NCONNS) { - sendstr("Connection identifier too high.\n", com->conn); - return ESUCCESS; - } - - if(conns[i] == NULL) { - sendstr("Connection identifier not in use.\n", com->conn); - return ESUCCESS; - } - - buf = netbuf_new(); - mem = netbuf_alloc(buf, strlen(com->args[1]) + 1); - if(mem == NULL) { - sendstr("Could not allocate memory for sending.\n", com->conn); - return ESUCCESS; - } - strncpy(mem, com->args[1], strlen(com->args[1]) + 1); - err = netconn_send(conns[i], buf); - netbuf_delete(buf); - if(err != ERR_OK) { - sendstr("Could not send data: ", com->conn); -#ifdef LWIP_DEBUG - sendstr(lwip_strerr(err), com->conn); -#else - sendstr("(debugging must be turned on for error message to appear)", com->conn); -#endif /* LWIP_DEBUG */ - sendstr("\n", com->conn); - return ESUCCESS; - } - - sendstr("Data sent.\n", com->conn); - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -com_help(struct command *com) -{ - sendstr(help_msg, com->conn); - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static s8_t -parse_command(struct command *com, u32_t len) -{ - u16_t i; - u16_t bufp; - - if(strncmp((const char *)buffer, "open", 4) == 0) { - com->exec = com_open; - com->nargs = 2; - } else if(strncmp((const char *)buffer, "lstn", 4) == 0) { - com->exec = com_lstn; - com->nargs = 1; - } else if(strncmp((const char *)buffer, "acpt", 4) == 0) { - com->exec = com_acpt; - com->nargs = 1; - } else if(strncmp((const char *)buffer, "clos", 4) == 0) { - com->exec = com_clos; - com->nargs = 1; - } else if(strncmp((const char *)buffer, "stat", 4) == 0) { - com->exec = com_stat; - com->nargs = 0; - } else if(strncmp((const char *)buffer, "send", 4) == 0) { - com->exec = com_send; - com->nargs = 2; - } else if(strncmp((const char *)buffer, "recv", 4) == 0) { - com->exec = com_recv; - com->nargs = 1; - } else if(strncmp((const char *)buffer, "udpc", 4) == 0) { - com->exec = com_udpc; - com->nargs = 3; - } else if(strncmp((const char *)buffer, "udpb", 4) == 0) { - com->exec = com_udpb; - com->nargs = 2; - } else if(strncmp((const char *)buffer, "udpl", 4) == 0) { - com->exec = com_udpl; - com->nargs = 3; - } else if(strncmp((const char *)buffer, "udpn", 4) == 0) { - com->exec = com_udpn; - com->nargs = 3; - } else if(strncmp((const char *)buffer, "usnd", 4) == 0) { - com->exec = com_usnd; - com->nargs = 2; - } else if(strncmp((const char *)buffer, "help", 4) == 0) { - com->exec = com_help; - com->nargs = 0; - } else if(strncmp((const char *)buffer, "quit", 4) == 0) { - printf("quit\n"); - return ECLOSED; - } else { - return ESYNTAX; - } - - if(com->nargs == 0) { - return ESUCCESS; - } - bufp = 0; - for(; bufp < len && buffer[bufp] != ' '; bufp++); - for(i = 0; i < 10; i++) { - for(; bufp < len && buffer[bufp] == ' '; bufp++); - if(buffer[bufp] == '\r' || - buffer[bufp] == '\n') { - buffer[bufp] = 0; - if(i < com->nargs - 1) { - return ETOOFEW; - } - if(i > com->nargs - 1) { - return ETOOMANY; - } - break; - } - if(bufp > len) { - return ETOOFEW; - } - com->args[i] = (char *)&buffer[bufp]; - for(; bufp < len && buffer[bufp] != ' ' && buffer[bufp] != '\r' && - buffer[bufp] != '\n'; bufp++) { - if(buffer[bufp] == '\\') { - buffer[bufp] = ' '; - } - } - if(bufp > len) { - return ESYNTAX; - } - buffer[bufp] = 0; - bufp++; - if(i == com->nargs - 1) { - break; - } - - } - - return ESUCCESS; -} -/*-----------------------------------------------------------------------------------*/ -static void -error(s8_t err, struct netconn *conn) -{ - switch(err) { - case ESYNTAX: - sendstr("## Syntax error\n", conn); - break; - case ETOOFEW: - sendstr("## Too few arguments to command given\n", conn); - break; - case ETOOMANY: - sendstr("## Too many arguments to command given\n", conn); - break; - } -} -/*-----------------------------------------------------------------------------------*/ -static void -prompt(struct netconn *conn) -{ - sendstr("> ", conn); -} -/*-----------------------------------------------------------------------------------*/ -static void -shell_main(struct netconn *conn) -{ - struct netbuf *buf; - u32_t len; - struct command com; - s8_t err; - int i; - - do { - buf = netconn_recv(conn); - if(buf != NULL) { - netbuf_copy(buf, buffer, 1024); - len = netbuf_len(buf); - netbuf_delete(buf); - if(len >= 4) { - if(buffer[0] != 0xff && - buffer[1] != 0xfe) { - err = parse_command(&com, len); - if(err == ESUCCESS) { - com.conn = conn; - err = com.exec(&com); - } - if(err != ESUCCESS) { - error(err, conn); - } - if(err == ECLOSED) { - printf("Closed\n"); - error(err, conn); - goto close; - } - } else { - sendstr("\n\n" - "lwIP simple interactive shell.\n" - "(c) Copyright 2001, Swedish Institute of Computer Science.\n" - "Written by Adam Dunkels.\n" - "For help, try the \"help\" command.\n", conn); - } - } - } - if(buf != NULL) { - prompt(conn); - } - } while(buf != NULL); - printf("buf == NULL err %s\n", lwip_strerr(conn->err)); - close: - netconn_close(conn); - - for(i = 0; i < NCONNS; i++) { - if(conns[i] != NULL) { - netconn_delete(conns[i]); - } - conns[i] = NULL; - } - -} -/*-----------------------------------------------------------------------------------*/ -static void -shell_thread(void *arg) -{ - struct netconn *conn, *newconn; - - conn = netconn_new(NETCONN_TCP); - netconn_bind(conn, NULL, 23); - netconn_listen(conn); - - while(1) { - newconn = netconn_accept(conn); - shell_main(newconn); - netconn_delete(newconn); - } -} -/*-----------------------------------------------------------------------------------*/ -void -shell_init(void) -{ - sys_thread_new(shell_thread, NULL); -} - - - - diff --git a/proj/unixsim/apps/shell.h b/proj/unixsim/apps/shell.h deleted file mode 100644 index 874a7533..00000000 --- a/proj/unixsim/apps/shell.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __SHELL_H__ -#define __SHELL_H__ - -void shell_init(void); - -#endif /* __SHELL_H__ */ diff --git a/proj/unixsim/apps/tcpecho.c b/proj/unixsim/apps/tcpecho.c deleted file mode 100644 index 1a3ce68a..00000000 --- a/proj/unixsim/apps/tcpecho.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/sys.h" -#include "lwip/api.h" -/*-----------------------------------------------------------------------------------*/ -static void -tcpecho_thread(void *arg) -{ - struct netconn *conn, *newconn; - err_t err; - - /* Create a new connection identifier. */ - conn = netconn_new(NETCONN_TCP); - - /* Bind connection to well known port number 7. */ - netconn_bind(conn, NULL, 7); - - /* Tell connection to go into listening mode. */ - netconn_listen(conn); - - while(1) { - - /* Grab new connection. */ - newconn = netconn_accept(conn); - /*printf("accepted new connection %p\n", newconn);*/ - /* Process the new connection. */ - if(newconn != NULL) { - struct netbuf *buf; - void *data; - u16_t len; - - while((buf = netconn_recv(newconn)) != NULL) { - /*printf("Recved\n");*/ - do { - netbuf_data(buf, &data, &len); - err = netconn_write(newconn, data, len, NETCONN_COPY); - if(err != ERR_OK) { - /* printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));*/ - } - } while(netbuf_next(buf) >= 0); - netbuf_delete(buf); - } - /*printf("Got EOF, looping\n");*/ - /* Close connection and discard connection identifier. */ - netconn_delete(newconn); - } - } -} -/*-----------------------------------------------------------------------------------*/ -void -tcpecho_init(void) -{ - sys_thread_new(tcpecho_thread, NULL); -} -/*-----------------------------------------------------------------------------------*/ - - - diff --git a/proj/unixsim/apps/tcpecho.h b/proj/unixsim/apps/tcpecho.h deleted file mode 100644 index 8a78c679..00000000 --- a/proj/unixsim/apps/tcpecho.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __TCPECHO_H__ -#define __TCPECHO_H__ - -void tcpecho_init(void); - -#endif /* __TCPECHO_H__ */ diff --git a/proj/unixsim/apps/udpecho.c b/proj/unixsim/apps/udpecho.c deleted file mode 100644 index c87a54b8..00000000 --- a/proj/unixsim/apps/udpecho.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/api.h" -#include "lwip/sys.h" - -/*-----------------------------------------------------------------------------------*/ -void -udpecho_thread(void *arg) -{ - static struct netconn *conn; - static struct netbuf *buf; - static struct ip_addr *addr; - static unsigned short port; - char buffer[4096]; - - conn = netconn_new(NETCONN_UDP); - netconn_bind(conn, NULL, 7); - - while(1) { - buf = netconn_recv(conn); - addr = netbuf_fromaddr(buf); - port = netbuf_fromport(buf); - netconn_connect(conn, addr, port); - netbuf_copy(buf, buffer, buf->p->tot_len); - buffer[buf->p->tot_len] = '\0'; - netconn_send(conn, buf); - printf("got %s\n", buffer); - netbuf_delete(buf); - } -} -/*-----------------------------------------------------------------------------------*/ -void -udpecho_init(void) -{ - sys_thread_new(udpecho_thread, NULL); -} diff --git a/proj/unixsim/apps/udpecho.h b/proj/unixsim/apps/udpecho.h deleted file mode 100644 index 6c500582..00000000 --- a/proj/unixsim/apps/udpecho.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __UDPECHO_H__ -#define __UDPECHO_H__ - -void udpecho_init(void); - -#endif /* __UDPECHO_H__ */ diff --git a/proj/unixsim/lwipopts.h b/proj/unixsim/lwipopts.h deleted file mode 100644 index 0192d792..00000000 --- a/proj/unixsim/lwipopts.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIPOPTS_H__ -#define __LWIPOPTS_H__ -/* ---------- Memory options ---------- */ -/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which - lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 - byte alignment -> define MEM_ALIGNMENT to 2. */ -#define MEM_ALIGNMENT 1 - -/* MEM_SIZE: the size of the heap memory. If the application will send -a lot of data that needs to be copied, this should be set high. */ -#define MEM_SIZE 1600 - -/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application - sends a lot of data out of ROM (or other static memory), this - should be set high. */ -#define MEMP_NUM_PBUF 16 -/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - per active UDP "connection". */ -#define MEMP_NUM_UDP_PCB 4 -/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP - connections. */ -#define MEMP_NUM_TCP_PCB 5 -/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP - connections. */ -#define MEMP_NUM_TCP_PCB_LISTEN 8 -/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP - segments. */ -#define MEMP_NUM_TCP_SEG 16 -/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active - timeouts. */ -#define MEMP_NUM_SYS_TIMEOUT 3 - -/* The following four are used only with the sequential API and can be - set to 0 if the application only will use the raw API. */ -/* MEMP_NUM_NETBUF: the number of struct netbufs. */ -#define MEMP_NUM_NETBUF 2 -/* MEMP_NUM_NETCONN: the number of struct netconns. */ -#define MEMP_NUM_NETCONN 4 -/* MEMP_NUM_APIMSG: the number of struct api_msg, used for - communication between the TCP/IP stack and the sequential - programs. */ -#define MEMP_NUM_API_MSG 8 -/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used - for sequential API communication and incoming packets. Used in - src/api/tcpip.c. */ -#define MEMP_NUM_TCPIP_MSG 8 - -/* These two control is reclaimer functions should be compiled - in. Should always be turned on (1). */ -#define MEM_RECLAIM 1 -#define MEMP_RECLAIM 1 - -/* ---------- Pbuf options ---------- */ -/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ -#define PBUF_POOL_SIZE 100 - -/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ -#define PBUF_POOL_BUFSIZE 128 - -/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a - link level header. */ -#define PBUF_LINK_HLEN 16 - -/* ---------- TCP options ---------- */ -#define LWIP_TCP 1 -#define TCP_TTL 255 - -/* Controls if TCP should queue segments that arrive out of - order. Define to 0 if your device is low on memory. */ -#define TCP_QUEUE_OOSEQ 1 - -/* TCP Maximum segment size. */ -#define TCP_MSS 128 - -/* TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 256 - -/* TCP sender buffer space (pbufs). This must be at least = 2 * - TCP_SND_BUF/TCP_MSS for things to work. */ -#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS - -/* TCP receive window. */ -#define TCP_WND 1024 - -/* Maximum number of retransmissions of data segments. */ -#define TCP_MAXRTX 12 - -/* Maximum number of retransmissions of SYN segments. */ -#define TCP_SYNMAXRTX 4 - -/* ---------- ARP options ---------- */ -#define ARP_TABLE_SIZE 10 -#define ARP_QUEUEING 1 -/** - * - If enabled, cache entries are generated for every kind of ARP traffic or - * broadcast IP traffic. This enhances behaviour for sending to a dynamic set - * of hosts, for example if acting as a gateway. - * - If disabled, cache entries are generated only for IP destination addresses - * in use by lwIP or applications. This enhances performance if sending to a small, - * reasonably static number of hosts. Typically for embedded devices. - */ -#define ETHARP_ALWAYS_INSERT 1 - - -/* ---------- IP options ---------- */ -/* Define IP_FORWARD to 1 if you wish to have the ability to forward - IP packets across network interfaces. If you are going to run lwIP - on a device with only one network interface, define this to 0. */ -#define IP_FORWARD 1 - -/* If defined to 1, IP options are allowed (but not parsed). If - defined to 0, all packets with IP options are dropped. */ -#define IP_OPTIONS 1 - -/* IP reassembly and segmentation.These are orthogonal even - * if they both deal with IP fragments */ -#define IP_REASSEMBLY 1 -#define IP_FRAG 1 - -/* ---------- ICMP options ---------- */ -#define ICMP_TTL 255 - -/* ---------- DHCP options ---------- */ -/* Define LWIP_DHCP to 1 if you want DHCP configuration of - interfaces. DHCP is not implemented in lwIP 0.5.1, however, so - turning this on does currently not work. */ -#define LWIP_DHCP 0 - -/* 1 if you want to do an ARP check on the offered address - (recommended). */ -#define DHCP_DOES_ARP_CHECK 1 - -/* ---------- UDP options ---------- */ -#define LWIP_UDP 1 -#define UDP_TTL 255 - - -/* ---------- Statistics options ---------- */ -#define STATS - -#ifdef STATS -#define LINK_STATS -#define IP_STATS -#define ICMP_STATS -#define UDP_STATS -#define TCP_STATS -#define MEM_STATS -#define MEMP_STATS -#define PBUF_STATS -#define SYS_STATS -#endif /* STATS */ - -#endif /* __LWIPOPTS_H__ */ diff --git a/proj/unixsim/simhost.c b/proj/unixsim/simhost.c deleted file mode 100644 index 313b5ff0..00000000 --- a/proj/unixsim/simhost.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/debug.h" - -#include - -#include "lwip/opt.h" - -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/sys.h" - -#include "lwip/stats.h" - - -#include "lwip/tcpip.h" - -#include "netif/tapif.h" -#include "netif/tunif.h" - -#include "netif/unixif.h" -#include "netif/dropif.h" -#include "netif/pcapif.h" -#include "netif/loopif.h" - -#include "netif/tcpdump.h" - - - - -#include "lwip/ip_addr.h" - -#include "arch/perf.h" - -#include "httpd.h" -#include "udpecho.h" -#include "tcpecho.h" -#include "shell.h" - -/*-----------------------------------------------------------------------------------*/ -static void -tcp_timeout(void *data) -{ -#if TCP_DEBUG - tcp_debug_print_pcbs(); -#endif /* TCP_DEBUG */ - sys_timeout(5000, tcp_timeout, NULL); -} -/*-----------------------------------------------------------------------------------*/ -static void -tcpip_init_done(void *arg) -{ - sys_sem_t *sem; - sem = arg; - sys_sem_signal(*sem); -} -/*-----------------------------------------------------------------------------------*/ -static void -main_thread(void *arg) -{ - struct ip_addr ipaddr, netmask, gw; - sys_sem_t sem; - - netif_init(); - - sem = sys_sem_new(0); - tcpip_init(tcpip_init_done, &sem); - sys_sem_wait(sem); - sys_sem_free(sem); - printf("TCP/IP initialized.\n"); - -#if LWIP_DHCP - { - struct netif *netif; - IP4_ADDR(&gw, 0,0,0,0); - IP4_ADDR(&ipaddr, 0,0,0,0); - IP4_ADDR(&netmask, 0,0,0,0); - - netif = netif_add(&ipaddr, &netmask, &gw, tapif_init, - tcpip_input); - netif_set_default(netif); - dhcp_init(); - dhcp_start(netif); - } -#else - IP4_ADDR(&gw, 192,168,0,1); - IP4_ADDR(&ipaddr, 192,168,0,2); - IP4_ADDR(&netmask, 255,255,255,0); - - /* netif_set_default(netif_add(&ipaddr, &netmask, &gw, tapif_init, - tcpip_input));*/ - netif_set_default(netif_add(&ipaddr, &netmask, &gw, tapif_init, - tcpip_input)); -#endif - /* Only used for testing purposes: */ - /* IP4_ADDR(&gw, 193,10,66,1); - IP4_ADDR(&ipaddr, 193,10,66,107); - IP4_ADDR(&netmask, 255,255,252,0); - - netif_add(&ipaddr, &netmask, &gw, pcapif_init, - tcpip_input);*/ - - IP4_ADDR(&gw, 127,0,0,1); - IP4_ADDR(&ipaddr, 127,0,0,1); - IP4_ADDR(&netmask, 255,0,0,0); - - netif_add(&ipaddr, &netmask, &gw, loopif_init, - tcpip_input); - - tcpecho_init(); - shell_init(); - httpd_init(); - udpecho_init(); - - printf("Applications started.\n"); - - /* sys_timeout(5000, tcp_timeout, NULL);*/ - -#ifdef MEM_PERF - mem_perf_init("/tmp/memstats.client"); -#endif /* MEM_PERF */ - - /* Block for ever. */ - sem = sys_sem_new(0); - sys_sem_wait(sem); -} -/*-----------------------------------------------------------------------------------*/ -int -main(int argc, char **argv) -{ -#ifdef PERF - perf_init("/tmp/simhost.perf"); -#endif /* PERF */ -#ifdef STATS - stats_init(); -#endif /* STATS */ - sys_init(); - mem_init(); - memp_init(); - pbuf_init(); - - tcpdump_init(); - - - printf("System initialized.\n"); - - sys_thread_new((void *)(main_thread), NULL); - pause(); - return 0; -} -/*-----------------------------------------------------------------------------------*/ - - - - - - - - diff --git a/proj/unixsim/simnode.c b/proj/unixsim/simnode.c deleted file mode 100644 index c494e151..00000000 --- a/proj/unixsim/simnode.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/debug.h" - -#include - - -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/sys.h" - -#include "lwip/stats.h" - - -#include "lwip/tcpip.h" - - -#include "netif/unixif.h" -#include "netif/dropif.h" - -#include "netif/loopif.h" - -#include "netif/tcpdump.h" - -#include "lwip/ip_addr.h" - -#include "arch/perf.h" - -#include "httpd.h" -#include "udpecho.h" -#include "tcpecho.h" -#include "shell.h" - -/*-----------------------------------------------------------------------------------*/ -static void -tcp_timeout(void *data) -{ -#if TCP_DEBUG - tcp_debug_print_pcbs(); -#endif /* TCP_DEBUG */ - sys_timeout(5000, tcp_timeout, NULL); -} -/*-----------------------------------------------------------------------------------*/ -static void -tcpip_init_done(void *arg) -{ - sys_sem_t *sem; - sem = arg; - sys_sem_signal(*sem); -} -/*-----------------------------------------------------------------------------------*/ -static void -main_thread(void *arg) -{ - struct ip_addr ipaddr, netmask, gw; - sys_sem_t sem; - - - IP4_ADDR(&gw, 192,168,1,1); - IP4_ADDR(&ipaddr, 192,168,1,2); - IP4_ADDR(&netmask, 255,255,255,0); - - netif_set_default(netif_add(&ipaddr, &netmask, &gw, unixif_init_client, - tcpip_input)); - /* netif_set_default(netif_add(&ipaddr, &netmask, &gw, sioslipif_init1, - tcpip_input)); */ - - - sem = sys_sem_new(0); - tcpip_init(tcpip_init_done, &sem); - sys_sem_wait(sem); - sys_sem_free(sem); - printf("TCP/IP initialized.\n"); - - tcpecho_init(); - shell_init(); - httpd_init(); - udpecho_init(); - - printf("Applications started.\n"); - - sys_timeout(5000, tcp_timeout, NULL); - -#ifdef MEM_PERF - mem_perf_init("/tmp/memstats.client"); -#endif /* MEM_PERF */ - - sem = sys_sem_new(0); - sys_sem_wait(sem); - -} -/*-----------------------------------------------------------------------------------*/ -int -main(int argc, char **argv) -{ -#ifdef PERF - perf_init("/tmp/client.perf"); -#endif /* PERF */ -#ifdef STATS - stats_init(); -#endif /* STATS */ - sys_init(); - mem_init(); - memp_init(); - pbuf_init(); - - tcpdump_init(); - - - printf("System initialized.\n"); - - sys_thread_new((void *)(main_thread), NULL); - pause(); - return 0; -} -/*-----------------------------------------------------------------------------------*/ - - - - - - - - diff --git a/proj/unixsim/simrouter.c b/proj/unixsim/simrouter.c deleted file mode 100644 index 0e79074e..00000000 --- a/proj/unixsim/simrouter.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/debug.h" - -#include - - -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/sys.h" - -#include "lwip/stats.h" - - -#include "lwip/tcpip.h" - -#include "netif/tapif.h" - -#include "netif/unixif.h" -#include "netif/dropif.h" - -#include "netif/loopif.h" - -#include "netif/tcpdump.h" - - -#include "lwip/ip_addr.h" - -#include "arch/perf.h" - -#include "httpd.h" -#include "udpecho.h" -#include "tcpecho.h" -#include "shell.h" - -/*-----------------------------------------------------------------------------------*/ -static void -tcp_timeout(void *data) -{ -#if TCP_DEBUG - tcp_debug_print_pcbs(); -#endif /* TCP_DEBUG */ - sys_timeout(5000, tcp_timeout, NULL); -} -/*-----------------------------------------------------------------------------------*/ -static void -tcpip_init_done(void *arg) -{ - sys_sem_t *sem; - sem = arg; - sys_sem_signal(*sem); -} -/*-----------------------------------------------------------------------------------*/ -static void -main_thread(void *arg) -{ - struct ip_addr ipaddr, netmask, gw; - sys_sem_t sem; - - - IP4_ADDR(&gw, 192,168,0,1); - IP4_ADDR(&ipaddr, 192,168,0,2); - IP4_ADDR(&netmask, 255,255,255,0); - - netif_set_default(netif_add(&ipaddr, &netmask, &gw, tapif_init, - tcpip_input)); - - IP4_ADDR(&gw, 192,168,1,1); - IP4_ADDR(&ipaddr, 192,168,1,1); - IP4_ADDR(&netmask, 255,255,255,0); - netif_set_default(netif_add(&ipaddr, &netmask, &gw, unixif_init_server, - tcpip_input)); - - system("route add 192.168.1.1 192.168.0.2"); - system("route add 192.168.1.2 192.168.0.2"); - - - /*netif_set_default(netif_add(&ipaddr, &netmask, &gw, sioslipif_init1, - tcpip_input)); */ - - - sem = sys_sem_new(0); - tcpip_init(tcpip_init_done, &sem); - sys_sem_wait(sem); - sys_sem_free(sem); - printf("TCP/IP initialized.\n"); - - tcpecho_init(); - shell_init(); - httpd_init(); - udpecho_init(); - - printf("Applications started.\n"); - - sys_timeout(5000, tcp_timeout, NULL); - -#ifdef MEM_PERF - mem_perf_init("/tmp/memstats.client"); -#endif /* MEM_PERF */ - sem = sys_sem_new(0); - sys_sem_wait(sem); -} -/*-----------------------------------------------------------------------------------*/ -int -main(int argc, char **argv) -{ -#ifdef PERF - perf_init("/tmp/client.perf"); -#endif /* PERF */ -#ifdef STATS - stats_init(); -#endif /* STATS */ - sys_init(); - mem_init(); - memp_init(); - pbuf_init(); - - tcpdump_init(); - - - printf("System initialized.\n"); - - sys_thread_new((void *)(main_thread), NULL); - pause(); - return 0; -} -/*-----------------------------------------------------------------------------------*/ - - - - - - - -