33 changed files with 4510 additions and 0 deletions
@ -0,0 +1,92 @@
|
||||
#
|
||||
# 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 <adam@sics.se>
|
||||
#
|
||||
|
||||
CONTRIBDIR=../../../..
|
||||
LWIPARCH=$(CONTRIBDIR)/ports/unix
|
||||
|
||||
#Set this to where you have the lwip core module checked out from CVS
|
||||
#default assumes it's a dir named lwip at the same level as the contrib module
|
||||
LWIPDIR=$(CONTRIBDIR)/../lwip/src
|
||||
|
||||
|
||||
CCDEP=gcc
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -fPIC -DIPv4 -DLWIP_DEBUG
|
||||
|
||||
CFLAGS:=$(CFLAGS) \
|
||||
-I$(LWIPDIR)/include -I$(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=liblwip.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
|
||||
@ -0,0 +1,31 @@
|
||||
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: |
||||
|
||||
<http://www.tldp.org/HOWTO/Program-Library-HOWTO/> |
||||
|
||||
|
||||
|
||||
Kieran Mansley, October 2002. |
||||
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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__ */ |
||||
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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 <kjm25@cam.ac.uk> |
||||
* |
||||
* $Id: unixlib.c,v 1.1 2003/01/31 13:35:43 jani 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){ |
||||
} |
||||
@ -0,0 +1,96 @@
|
||||
#
|
||||
# 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 <adam@sics.se>
|
||||
#
|
||||
|
||||
CCDEP=gcc
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -DIPv4 -Os -fpack-struct
|
||||
ARFLAGS=rs
|
||||
|
||||
CONTRIBDIR=../../../..
|
||||
LWIPARCH=$(CONTRIBDIR)/ports/unix
|
||||
|
||||
#Set this to where you have the lwip core module checked out from CVS
|
||||
#default assumes it's a dir named lwip at the same level as the contrib module
|
||||
LWIPDIR=$(CONTRIBDIR)/../lwip/src
|
||||
|
||||
CFLAGS:=$(CFLAGS) \
|
||||
-I$(LWIPDIR)/include -I$(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)
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
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. |
||||
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#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; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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__ */ |
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#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; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,354 @@
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include <fcntl.h> |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <unistd.h> |
||||
#include <string.h> |
||||
#include <sys/ioctl.h> |
||||
#include <sys/socket.h> |
||||
#include <sys/types.h> |
||||
#include <sys/time.h> |
||||
#include <sys/uio.h> |
||||
#include <sys/socket.h> |
||||
|
||||
#ifdef linux |
||||
#include <sys/ioctl.h> |
||||
#include <linux/if.h> |
||||
#include <linux/if_tun.h> |
||||
#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; |
||||
} |
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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__ */ |
||||
@ -0,0 +1,111 @@
|
||||
#
|
||||
# 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 <adam@sics.se>
|
||||
#
|
||||
|
||||
CCDEP=gcc
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG -pedantic
|
||||
LDFLAGS=-lpcap
|
||||
CONTRIBDIR=../../../..
|
||||
LWIPARCH=$(CONTRIBDIR)/ports/unix
|
||||
ARFLAGS=rs
|
||||
|
||||
#Set this to where you have the lwip core module checked out from CVS
|
||||
#default assumes it's a dir named lwip at the same level as the contrib module
|
||||
LWIPDIR=$(CONTRIBDIR)/../lwip/src
|
||||
|
||||
CFLAGS:=$(CFLAGS) \
|
||||
-I$(LWIPDIR)/include -I$(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 $(LWIPARCH)/*.c $(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)
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
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/. |
||||
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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__ */ |
||||
@ -0,0 +1,21 @@
|
||||
<html> |
||||
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head> |
||||
<body bgcolor="white" text="black"> |
||||
|
||||
<table width="100%"> |
||||
<tr valign="top"><td width="80"> |
||||
<a href="http://www.sics.se/"><img src="img/sics.gif" |
||||
border="0" alt="SICS logo" title="SICS logo"></a> |
||||
</td><td width="500"> |
||||
<h1>lwIP - A Lightweight TCP/IP Stack</h1> |
||||
<h2>404 - Page not found</h2> |
||||
<p> |
||||
Sorry, the page you are requesting was not found on this |
||||
server. |
||||
</p> |
||||
</td><td> |
||||
|
||||
</td></tr> |
||||
</table> |
||||
</body> |
||||
</html> |
||||
|
After Width: | Height: | Size: 724 B |
@ -0,0 +1,44 @@
|
||||
<html> |
||||
<head><title>lwIP - A Lightweight TCP/IP Stack</title></head> |
||||
<body bgcolor="white" text="black"> |
||||
|
||||
<table width="100%"> |
||||
<tr valign="top"><td width="80"> |
||||
<a href="http://www.sics.se/"><img src="img/sics.gif" |
||||
border="0" alt="SICS logo" title="SICS logo"></a> |
||||
</td><td width="500"> |
||||
<h1>lwIP - A Lightweight TCP/IP Stack</h1> |
||||
<p> |
||||
The web page you are watching was served by a simple web |
||||
server running on top of the lightweight TCP/IP stack <a |
||||
href="http://www.sics.se/~adam/lwip/">lwIP</a>. |
||||
</p> |
||||
<p> |
||||
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. |
||||
</p> |
||||
<p> |
||||
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. |
||||
</p> |
||||
<p> |
||||
More information about lwIP can be found at the lwIP |
||||
homepage at <a |
||||
href="http://www.sics.se/~adam/lwip/">http://www.sics.se/~adam/lwip/</a>. |
||||
</p> |
||||
</td><td> |
||||
|
||||
</td></tr> |
||||
</table> |
||||
</body> |
||||
</html> |
||||
|
||||
@ -0,0 +1,334 @@
|
||||
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 |
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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__ */ |
||||
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#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); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __HTTPD_H__ |
||||
#define __HTTPD_H__ |
||||
|
||||
void httpd_init(void); |
||||
|
||||
#endif /* __HTTPD_H__ */ |
||||
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/perl |
||||
|
||||
open(OUTPUT, "> fsdata.c"); |
||||
|
||||
chdir("fs"); |
||||
open(FILES, "find . -type f |"); |
||||
|
||||
while($file = <FILES>) { |
||||
|
||||
# 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"); |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __SHELL_H__ |
||||
#define __SHELL_H__ |
||||
|
||||
void shell_init(void); |
||||
|
||||
#endif /* __SHELL_H__ */ |
||||
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#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);
|
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __TCPECHO_H__ |
||||
#define __TCPECHO_H__ |
||||
|
||||
void tcpecho_init(void); |
||||
|
||||
#endif /* __TCPECHO_H__ */ |
||||
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#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); |
||||
} |
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __UDPECHO_H__ |
||||
#define __UDPECHO_H__ |
||||
|
||||
void udpecho_init(void); |
||||
|
||||
#endif /* __UDPECHO_H__ */ |
||||
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
#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__ */ |
||||
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include <unistd.h> |
||||
|
||||
#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; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include <unistd.h> |
||||
|
||||
|
||||
#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; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* 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 <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include <unistd.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/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; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in new issue