├── .gitignore ├── NanodeUIP.cpp ├── NanodeUIP.h ├── README ├── README-uip ├── TODO ├── clock-arch.h ├── clock.h ├── dhcpc.cpp ├── dhcpc.h ├── enc28j60.cpp ├── enc28j60.h ├── examples ├── icy_radio │ ├── Jamfile │ ├── README.md │ ├── icy_radio.pde │ ├── printf.h │ ├── runtests.sh │ └── test.ex ├── ntp │ ├── Jamfile │ ├── _rtclib.cpp │ ├── _rtclib.h │ ├── ntp.pde │ ├── printf.h │ ├── runtests.sh │ └── test.ex ├── pachube │ ├── Jamfile │ ├── pachube.pde │ ├── printf.h │ ├── runtests.sh │ └── test.ex ├── sensor_gateway_rf24 │ ├── Jamfile │ ├── README.md │ ├── printf.h │ ├── runtests.sh │ ├── sensor_gateway_rf24.ino │ ├── test.ex │ └── uip-conf.h ├── simple_webclient │ ├── .gitignore │ ├── Jamfile │ ├── printf.h │ └── simple_webclient.pde ├── telnet_server │ ├── Jamfile │ ├── memb.c │ ├── memb.h │ ├── printf.h │ ├── shell.cpp │ ├── shell.h │ ├── telnet.cpp │ ├── telnet_server.pde │ ├── telnetd.h │ └── test.ex ├── uip_hello_world │ ├── Jamfile │ ├── printf.h │ └── uip_hello_world.pde ├── uip_mac_device_dump │ └── uip_mac_device_dump.pde ├── uiptest │ └── uiptest.pde └── webserver │ ├── Jamfile │ ├── dir.awk │ ├── dir.h │ ├── file_entry.h │ ├── files.awk │ ├── files.h │ ├── fs.cpp │ ├── fs │ ├── Makefile │ ├── buttons.shtml │ ├── buttons_list.shtml │ ├── credits.shtml │ ├── footer.html │ ├── header.html │ ├── index.js │ ├── index.shtml │ ├── lights.shtml │ ├── ok.txt │ ├── sensors.shtml │ ├── sensors_list.shtml │ └── set_pin.shtml │ ├── httpd_cgi.cpp │ ├── httpd_fs.cpp │ ├── pins_cgi.h │ ├── printf.h │ ├── runtests.sh │ ├── test.ex │ ├── webserver.ino │ └── xxd.awk ├── httpd.cpp ├── httpd.h ├── httpd_cgi.h ├── httpd_fs.h ├── lc-addrlabels.h ├── lc-switch.h ├── lc.h ├── makestrings.pl ├── ntpc.cpp ├── ntpc.h ├── platform.cpp ├── psock.cpp ├── psock.h ├── pt.h ├── resolv.cpp ├── resolv.h ├── timer.cpp ├── timer.h ├── uip-1.0-changelog.txt ├── uip-conf.h ├── uip.cpp ├── uip.h ├── uip ├── apps │ ├── README │ ├── dhcpc │ │ └── Makefile.dhcpc │ ├── hello-world │ │ └── Makefile.hello-world │ ├── resolv │ │ └── Makefile.resolv │ ├── smtp │ │ ├── Makefile.smtp │ │ ├── makestrings │ │ ├── smtp-strings │ │ ├── smtp-strings.c │ │ ├── smtp-strings.h │ │ ├── smtp.c │ │ └── smtp.h │ ├── telnetd │ │ ├── Makefile.telnetd │ │ ├── shell.c │ │ ├── shell.h │ │ ├── telnetd.c │ │ └── telnetd.h │ ├── webclient │ │ ├── Makefile.webclient │ │ ├── makestrings │ │ ├── webclient-strings │ │ ├── webclient-strings.c │ │ ├── webclient-strings.h │ │ ├── webclient.c │ │ └── webclient.h │ └── webserver │ │ ├── Makefile.webserver │ │ ├── http-strings │ │ ├── http-strings.c │ │ ├── http-strings.h │ │ ├── httpd-cgi.c │ │ ├── httpd-cgi.h │ │ ├── httpd-fs.c │ │ ├── httpd-fs.h │ │ ├── httpd-fs │ │ ├── 404.html │ │ ├── fade.png │ │ ├── files.shtml │ │ ├── footer.html │ │ ├── header.html │ │ ├── index.html │ │ ├── processes.shtml │ │ ├── stats.shtml │ │ ├── style.css │ │ └── tcp.shtml │ │ ├── httpd-fsdata.c │ │ ├── httpd-fsdata.h │ │ ├── httpd.c │ │ ├── httpd.h │ │ ├── makefsdata │ │ ├── makestrings │ │ └── webserver.h ├── doc │ ├── Doxyfile │ ├── Makefile │ ├── README │ ├── doxygen.sty │ ├── example-mainloop-with-arp.c │ ├── example-mainloop-without-arp.c │ ├── examples.txt │ ├── header.tex │ ├── html │ │ ├── a00036.html │ │ ├── a00037.html │ │ ├── a00038.html │ │ ├── a00039.html │ │ ├── a00040.html │ │ ├── a00041.html │ │ ├── a00042.html │ │ ├── a00043.html │ │ ├── a00044.html │ │ ├── a00045.html │ │ ├── a00046.html │ │ ├── a00047.html │ │ ├── a00048.html │ │ ├── a00049.html │ │ ├── a00050.html │ │ ├── a00051.html │ │ ├── a00077.html │ │ ├── a00078.html │ │ ├── a00079.html │ │ ├── a00080.html │ │ ├── a00081.html │ │ ├── a00082.html │ │ ├── a00083.html │ │ ├── a00084.html │ │ ├── a00085.html │ │ ├── a00086.html │ │ ├── a00087.html │ │ ├── a00088.html │ │ ├── a00089.html │ │ ├── a00090.html │ │ ├── a00091.html │ │ ├── a00092.html │ │ ├── a00093.html │ │ ├── a00094.html │ │ ├── a00095.html │ │ ├── a00096.html │ │ ├── a00097.html │ │ ├── a00100.html │ │ ├── a00101.html │ │ ├── a00102.html │ │ ├── a00103.html │ │ ├── a00104.html │ │ ├── a00105.html │ │ ├── a00107.html │ │ ├── a00110.html │ │ ├── a00111.html │ │ ├── a00112.html │ │ ├── a00113.html │ │ ├── a00114.html │ │ ├── a00120.html │ │ ├── a00121.html │ │ ├── a00123.html │ │ ├── a00124.html │ │ ├── a00125.html │ │ ├── a00127.html │ │ ├── a00128.html │ │ ├── a00129.html │ │ ├── a00130.html │ │ ├── a00131.html │ │ ├── a00132.html │ │ ├── a00134.html │ │ ├── a00135.html │ │ ├── a00136.html │ │ ├── a00137.html │ │ ├── a00138.html │ │ ├── a00139.html │ │ ├── a00140.html │ │ ├── a00141.html │ │ ├── a00142.html │ │ ├── a00143.html │ │ ├── a00144.html │ │ ├── a00145.html │ │ ├── a00146.html │ │ ├── a00147.html │ │ ├── a00148.html │ │ ├── a00149.html │ │ ├── a00150.html │ │ ├── a00151.html │ │ ├── a00152.html │ │ ├── a00153.html │ │ ├── a00154.html │ │ ├── a00155.html │ │ ├── a00156.html │ │ ├── a00157.html │ │ ├── a00158.html │ │ ├── a00159.html │ │ ├── a00160.html │ │ ├── a00161.html │ │ ├── a00162.html │ │ ├── a00163.html │ │ ├── a00164.html │ │ ├── a00168.html │ │ ├── a00169.html │ │ ├── a00170.html │ │ ├── a00171.html │ │ ├── a00172.html │ │ ├── a00173.html │ │ ├── a00174.html │ │ ├── a00175.html │ │ ├── a00176.html │ │ ├── a00177.html │ │ ├── a00178.html │ │ ├── a00179.html │ │ ├── a00180.html │ │ ├── a00181.html │ │ ├── a00182.html │ │ ├── a00183.html │ │ ├── a00184.html │ │ ├── a00185.html │ │ ├── a00186.html │ │ ├── a00187.html │ │ ├── a00188.html │ │ ├── a00189.html │ │ ├── a00190.html │ │ ├── a00191.html │ │ ├── a00192.html │ │ ├── a00193.html │ │ ├── a00194.html │ │ ├── a00195.html │ │ ├── a00196.html │ │ ├── a00197.html │ │ ├── a00198.html │ │ ├── a00199.html │ │ ├── a00200.html │ │ ├── a00201.html │ │ ├── a00202.html │ │ ├── a00203.html │ │ ├── a00204.html │ │ ├── a00205.html │ │ ├── a00206.html │ │ ├── a00207.html │ │ ├── annotated.html │ │ ├── classes.html │ │ ├── doxygen.css │ │ ├── doxygen.png │ │ ├── examples.html │ │ ├── files.html │ │ ├── ftv2blank.png │ │ ├── ftv2doc.png │ │ ├── ftv2folderclosed.png │ │ ├── ftv2folderopen.png │ │ ├── ftv2lastnode.png │ │ ├── ftv2link.png │ │ ├── ftv2mlastnode.png │ │ ├── ftv2mnode.png │ │ ├── ftv2node.png │ │ ├── ftv2plastnode.png │ │ ├── ftv2pnode.png │ │ ├── ftv2vertline.png │ │ ├── functions.html │ │ ├── functions_vars.html │ │ ├── globals.html │ │ ├── globals_0x61.html │ │ ├── globals_0x62.html │ │ ├── globals_0x64.html │ │ ├── globals_0x65.html │ │ ├── globals_0x66.html │ │ ├── globals_0x68.html │ │ ├── globals_0x69.html │ │ ├── globals_0x6c.html │ │ ├── globals_0x6d.html │ │ ├── globals_0x6e.html │ │ ├── globals_0x70.html │ │ ├── globals_0x72.html │ │ ├── globals_0x73.html │ │ ├── globals_0x74.html │ │ ├── globals_0x75.html │ │ ├── globals_0x77.html │ │ ├── globals_defs.html │ │ ├── globals_defs_0x61.html │ │ ├── globals_defs_0x62.html │ │ ├── globals_defs_0x64.html │ │ ├── globals_defs_0x65.html │ │ ├── globals_defs_0x66.html │ │ ├── globals_defs_0x68.html │ │ ├── globals_defs_0x69.html │ │ ├── globals_defs_0x6c.html │ │ ├── globals_defs_0x6d.html │ │ ├── globals_defs_0x6e.html │ │ ├── globals_defs_0x70.html │ │ ├── globals_defs_0x72.html │ │ ├── globals_defs_0x73.html │ │ ├── globals_defs_0x74.html │ │ ├── globals_defs_0x75.html │ │ ├── globals_defs_0x77.html │ │ ├── globals_func.html │ │ ├── globals_type.html │ │ ├── globals_vars.html │ │ ├── hierarchy.html │ │ ├── index.hhc │ │ ├── index.hhk │ │ ├── index.hhp │ │ ├── index.html │ │ ├── main.html │ │ ├── modules.html │ │ ├── tab_b.gif │ │ ├── tab_l.gif │ │ ├── tab_r.gif │ │ ├── tabs.css │ │ └── tree.html │ ├── mobisys2003.pdf │ ├── pt-doc.txt │ ├── sicslogo.pdf │ ├── uip-code-style.c │ ├── uip-code-style.txt │ ├── uip-doc.txt │ └── uip-refman.pdf ├── lib │ ├── memb.c │ └── memb.h ├── uip-fw.c ├── uip-fw.h ├── uip-neighbor.c ├── uip-neighbor.h ├── uip-split.c ├── uip-split.h ├── uiplib.c ├── uiplib.h └── unix │ ├── Makefile │ ├── clock-arch.c │ ├── clock-arch.h │ ├── main.c │ ├── tapdev.c │ ├── tapdev.h │ └── uip-conf.h ├── uip_arch.h ├── uip_arp.cpp ├── uip_arp.h ├── uiplib.c ├── uiplib.h ├── uipopt.h ├── webclient-strings ├── webclient-strings.c ├── webclient-strings.h ├── webclient.cpp └── webclient.h /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .*.swp 3 | version.h 4 | 16000000/ 5 | -------------------------------------------------------------------------------- /README-uip: -------------------------------------------------------------------------------- 1 | uIP is a very small implementation of the TCP/IP stack that is written 2 | by Adam Dunkels . More information can be obtained 3 | at the uIP homepage at http://www.sics.se/~adam/uip/. 4 | 5 | This is version $Name: uip-1-0 $. 6 | 7 | The directory structure look as follows: 8 | 9 | apps/ - Example applications 10 | doc/ - Documentation 11 | lib/ - Library code used by some applications 12 | uip/ - uIP TCP/IP stack code 13 | unix/ - uIP as a user space process under FreeBSD or Linux 14 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Here's my vague plan for further development: 2 | 3 | 1) Get rid of the "listening" arrays for TCP and UDP - they are a 4 | waste of memory for something that's likely to be constant per sketch 5 | and better expressed as code in program memory space. Replace with a 6 | function pointer. We've a reasonable amount of stack space, 7 | hopefully, and the compiler should be doing the tail-call 8 | optimisation; when you register a new "listening" function, have it be 9 | responsible for calling the previous one if the incoming connection / 10 | packet isn't for us. 11 | 12 | 2) Simplify the UDP code. The idea of a UDP "connection" may be left 13 | over from someone who was used to thinking about sockets. It's much 14 | easier to pass incoming packets along a chain if listening functions 15 | and see if anyone wants them. Let any of these send UDP to wherever 16 | they like too; no need for memory to store a "connection". 17 | 18 | 3) Separate DHCP and resolver out into separate modules - probably 19 | worth keeping them in this library, but make it so that they have to 20 | be invoked from the sketch. Don't refer to them from NanodeUIP.cpp. 21 | 22 | 4) Sort out datatypes. The Arduino Wiring environment defines some 23 | perfectly good ones - byte, word, etc. - and we should be using these 24 | instead of rolling our own. 25 | 26 | 5) Tidy up those awful comments! Sure, the code to manual system is 27 | nifty but we're not using it here! 28 | -------------------------------------------------------------------------------- /clock-arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.h,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | #ifndef __CLOCK_ARCH_H__ 35 | #define __CLOCK_ARCH_H__ 36 | 37 | typedef unsigned long clock_time_t; 38 | #define CLOCK_CONF_SECOND 1000 39 | 40 | #endif /* __CLOCK_ARCH_H__ */ 41 | -------------------------------------------------------------------------------- /clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup clock Clock interface 3 | * 4 | * The clock interface is the interface between the \ref timer "timer library" 5 | * and the platform specific clock functionality. The clock 6 | * interface must be implemented for each platform that uses the \ref 7 | * timer "timer library". 8 | * 9 | * The clock interface does only one this: it measures time. The clock 10 | * interface provides a macro, CLOCK_SECOND, which corresponds to one 11 | * second of system time. 12 | * 13 | * \sa \ref timer "Timer library" 14 | * 15 | * @{ 16 | */ 17 | 18 | /* 19 | * Copyright (c) 2004, Swedish Institute of Computer Science. 20 | * All rights reserved. 21 | * 22 | * Redistribution and use in source and binary forms, with or without 23 | * modification, are permitted provided that the following conditions 24 | * are met: 25 | * 1. Redistributions of source code must retain the above copyright 26 | * notice, this list of conditions and the following disclaimer. 27 | * 2. Redistributions in binary form must reproduce the above copyright 28 | * notice, this list of conditions and the following disclaimer in the 29 | * documentation and/or other materials provided with the distribution. 30 | * 3. Neither the name of the Institute nor the names of its contributors 31 | * may be used to endorse or promote products derived from this software 32 | * without specific prior written permission. 33 | * 34 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 35 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 37 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 38 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 41 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 42 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 43 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 44 | * SUCH DAMAGE. 45 | * 46 | * This file is part of the uIP TCP/IP stack 47 | * 48 | * Author: Adam Dunkels 49 | * 50 | * $Id: clock.h,v 1.3 2006/06/11 21:46:39 adam Exp $ 51 | */ 52 | #ifndef __CLOCK_H__ 53 | #define __CLOCK_H__ 54 | 55 | #include "clock-arch.h" 56 | 57 | /** 58 | * Initialize the clock library. 59 | * 60 | * This function initializes the clock library and should be called 61 | * from the main() function of the system. 62 | * 63 | */ 64 | void clock_init(void); 65 | 66 | /** 67 | * Get the current clock time. 68 | * 69 | * This function returns the current system clock time. 70 | * 71 | * \return The current clock time, measured in system ticks. 72 | */ 73 | clock_time_t clock_time(void); 74 | 75 | /** 76 | * A second, measured in system clock time. 77 | * 78 | * \hideinitializer 79 | */ 80 | #ifdef CLOCK_CONF_SECOND 81 | #define CLOCK_SECOND CLOCK_CONF_SECOND 82 | #else 83 | #define CLOCK_SECOND (clock_time_t)32 84 | #endif 85 | 86 | #endif /* __CLOCK_H__ */ 87 | 88 | /** @} */ 89 | -------------------------------------------------------------------------------- /dhcpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * @(#)$Id: dhcpc.h,v 1.3 2006/06/11 21:46:37 adam Exp $ 32 | */ 33 | #ifndef __DHCPC_H__ 34 | #define __DHCPC_H__ 35 | 36 | #include "timer.h" 37 | #include "pt.h" 38 | 39 | struct dhcpc_state { 40 | struct pt pt; 41 | char state; 42 | struct uip_udp_conn *conn; 43 | struct timer timer; 44 | u16_t ticks; 45 | const void *mac_addr; 46 | int mac_len; 47 | 48 | u8_t serverid[4]; 49 | 50 | u16_t lease_time[2]; 51 | u16_t ipaddr[2]; 52 | u16_t netmask[2]; 53 | u16_t dnsaddr[2]; 54 | u16_t default_router[2]; 55 | }; 56 | 57 | int dhcpc_init(const void *mac_addr, int mac_len); 58 | void dhcpc_request(void); 59 | 60 | void dhcpc_appcall(void); 61 | 62 | void dhcpc_configured(const struct dhcpc_state *s); 63 | 64 | /* This doesn't appear to be used, and we don't want a copy of the 65 | DHCP client state for every UDP connection! */ 66 | //typedef struct dhcpc_state *uip_udp_appstate_t; 67 | //#define UIP_UDP_APPCALL dhcpc_appcall 68 | 69 | 70 | #endif /* __DHCPC_H__ */ 71 | -------------------------------------------------------------------------------- /examples/icy_radio/README.md: -------------------------------------------------------------------------------- 1 | # Icy Radio: Internet streaming radio example for Nanode UIP 2 | 3 | ## Requirements 4 | 5 | In addition to the Nanode UIP library, you need the VS1053 library available 6 | at https://github.com/maniacbug/VS1053 7 | 8 | ## Hardware 9 | 10 | For an explanations of the hardware and connections required, see my blog 11 | post at http://maniacbug.wordpress.com/2011/12/30/arduino-on-ice-internet-radio-via-shoutcast/ 12 | -------------------------------------------------------------------------------- /examples/icy_radio/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/icy_radio/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jam u0 && expect test.ex 4 | -------------------------------------------------------------------------------- /examples/icy_radio/test.ex: -------------------------------------------------------------------------------- 1 | #/usr/bin/expect 2 | 3 | set timeout 100 4 | spawn picocom -b 38400 /dev/ttyUSB0 5 | expect "+OK" 6 | -------------------------------------------------------------------------------- /examples/ntp/_rtclib.h: -------------------------------------------------------------------------------- 1 | // Code by JeeLabs http://news.jeelabs.org/code/ 2 | // Released to the public domain! Enjoy! 3 | 4 | #ifndef __RTCLIB_H__ 5 | #define __RTCLIB_H__ 6 | 7 | // Simple general-purpose date/time class (no TZ / DST / leap second handling!) 8 | class DateTime 9 | { 10 | public: 11 | DateTime (uint32_t t =0); 12 | DateTime (uint16_t year, uint8_t month, uint8_t day, 13 | uint8_t hour =0, uint8_t min =0, uint8_t sec =0); 14 | DateTime (const char* date, const char* time); 15 | uint16_t year() const 16 | { 17 | return 2000 + yOff; 18 | } 19 | uint8_t month() const 20 | { 21 | return m; 22 | } 23 | uint8_t day() const 24 | { 25 | return d; 26 | } 27 | uint8_t hour() const 28 | { 29 | return hh; 30 | } 31 | uint8_t minute() const 32 | { 33 | return mm; 34 | } 35 | uint8_t second() const 36 | { 37 | return ss; 38 | } 39 | uint8_t dayOfWeek() const; 40 | 41 | // 32-bit times as seconds since 1/1/2000 42 | long secondstime() const; 43 | // 32-bit times as seconds since 1/1/1970 44 | uint32_t unixtime(void) const; 45 | // as a string 46 | char* toString(char* buf, int maxlen) const; 47 | // add additional time 48 | void operator+=(uint32_t); 49 | 50 | protected: 51 | uint8_t yOff, m, d, hh, mm, ss; 52 | }; 53 | 54 | 55 | extern uint8_t bcd2bin (uint8_t val); 56 | extern uint8_t bin2bcd (uint8_t val); 57 | 58 | // RTC using the internal millis() clock, has to be initialized before use 59 | // NOTE: this clock won't be correct once the millis() timer rolls over (>49d?) 60 | class RTC_Millis 61 | { 62 | public: 63 | void begin(const DateTime& dt) 64 | { 65 | adjust(dt); 66 | } 67 | void adjust(const DateTime& dt); 68 | DateTime now(); 69 | RTC_Millis(void) 70 | { 71 | adjust(DateTime(2000,1,1,0,0,0)); 72 | } 73 | 74 | protected: 75 | long offset; 76 | }; 77 | 78 | #endif // __RTCLIB_H__ 79 | 80 | // vim:ci:sw=4 sts=4 ft=cpp 81 | -------------------------------------------------------------------------------- /examples/ntp/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/ntp/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jam u0 && expect test.ex 4 | -------------------------------------------------------------------------------- /examples/ntp/test.ex: -------------------------------------------------------------------------------- 1 | #/usr/bin/expect 2 | 3 | set timeout 100 4 | spawn picocom -b 38400 /dev/ttyUSB0 5 | expect "+READY" 6 | expect "+OK" 7 | -------------------------------------------------------------------------------- /examples/pachube/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/pachube/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jam u1 && expect test.ex 4 | -------------------------------------------------------------------------------- /examples/pachube/test.ex: -------------------------------------------------------------------------------- 1 | #/usr/bin/expect 2 | 3 | set timeout 100 4 | spawn picocom -b 38400 /dev/ttyUSB1 5 | expect "+READY" 6 | send "1" 7 | expect "+OK" 8 | -------------------------------------------------------------------------------- /examples/sensor_gateway_rf24/README.md: -------------------------------------------------------------------------------- 1 | # Wireless Sensor Network Gateway 2 | 3 | This example sketch shows how to use a Nanode (or Arduino connect to an 4 | ENC28J60-based Ethernet Shield) as a gateway between your wireless sensor 5 | network and Pachube. 6 | 7 | ## Requirements 8 | 9 | This sketch requires a special uIP configuration. To upload this sketch 10 | using the Arduino IDE, first copy the uip-conf.h file from this directory 11 | up to the NanodeUIP directory. (It's a good idea to keep a backup of the 12 | old one!) 13 | 14 | It also requires libraries for working with an RF Wireless Sensor Network. 15 | * (RF24)[www.github.com/maniacbug/RF24] 16 | * (RF24Network)[www.github.com/maniacbug/RF24Network] 17 | 18 | To test out this example, put the 'sensornet' example from RF24Network onto 19 | at least one node, set the address to 1-5, and start it up. 20 | 21 | Then, attach an nRF24L01+ radio to your Nanode and upload this sketch. Soon, 22 | the readings from the other node(s) will be getting posted to Pachube every 23 | four seconds. 24 | -------------------------------------------------------------------------------- /examples/sensor_gateway_rf24/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/sensor_gateway_rf24/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jam u0 && expect test.ex 4 | -------------------------------------------------------------------------------- /examples/sensor_gateway_rf24/test.ex: -------------------------------------------------------------------------------- 1 | #/usr/bin/expect 2 | 3 | set timeout 100 4 | spawn picocom -b 38400 /dev/ttyUSB0 5 | expect "+OK" 6 | -------------------------------------------------------------------------------- /examples/simple_webclient/.gitignore: -------------------------------------------------------------------------------- 1 | 16000000/ 2 | .*.swp 3 | .*.swo 4 | version.h 5 | -------------------------------------------------------------------------------- /examples/simple_webclient/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/telnet_server/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/telnet_server/telnet_server.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "telnetd.h" 5 | #include "printf.h" 6 | 7 | #undef PSTR 8 | #define PSTR(s) (__extension__({static const char __c[] __attribute__ (( section (".progmem") )) = (s); &__c[0];})) 9 | 10 | void dhcp_status(int s,const uint16_t *) { 11 | char buf[20]="IP:"; 12 | if (s==DHCP_STATUS_OK) { 13 | uip.get_ip_addr_str(buf+3); 14 | Serial.println(buf); 15 | 16 | nanode_log_P(PSTR("Bringing up telnet server...")); 17 | telnetd_init(); 18 | } 19 | } 20 | 21 | void setup() { 22 | char buf[20]; 23 | byte macaddr[6]; 24 | NanodeUNIO unio(NANODE_MAC_DEVICE); 25 | 26 | Serial.begin(38400); 27 | printf_begin(); 28 | printf_P(PSTR(__FILE__"\r\n")); 29 | 30 | unio.read(macaddr,NANODE_MAC_ADDRESS,6); 31 | uip.init(macaddr); 32 | uip.get_mac_str(buf); 33 | Serial.println(buf); 34 | uip.wait_for_link(); 35 | nanode_log_P(PSTR("Link is up")); 36 | uip.start_dhcp(dhcp_status); 37 | nanode_log_P(PSTR("setup() done")); 38 | } 39 | 40 | void loop() { 41 | uip.poll(); 42 | } 43 | // vim:cin:ai:sts=2 sw=2 ft=cpp 44 | -------------------------------------------------------------------------------- /examples/telnet_server/telnetd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $ 33 | * 34 | */ 35 | #ifndef __TELNETD_H__ 36 | #define __TELNETD_H__ 37 | 38 | #include "uipopt.h" 39 | extern "C" 40 | { 41 | #include "memb.h" 42 | } 43 | 44 | void telnetd_appcall(void); 45 | void telnetd_init(void); 46 | 47 | // Be sure to adjust TCP_APP_STATE_SIZE if you change any of these! 48 | #ifndef TELNETD_CONF_LINELEN 49 | #define TELNETD_CONF_LINELEN 30 50 | #endif 51 | #ifndef TELNETD_CONF_NUMLINES 52 | // orig value #define TELNETD_CONF_NUMLINES 16 53 | #define TELNETD_CONF_NUMLINES 5 54 | #endif 55 | 56 | struct telnetd_line { 57 | char line[TELNETD_CONF_LINELEN]; 58 | }; 59 | 60 | struct telnetd_state { 61 | char *lines[TELNETD_CONF_NUMLINES]; 62 | char buf[TELNETD_CONF_LINELEN]; 63 | u8_t bufptr; 64 | u8_t numsent; 65 | u8_t state; 66 | 67 | char linemem_memb_count[TELNETD_CONF_NUMLINES]; 68 | telnetd_line linemem_memb_mem[TELNETD_CONF_NUMLINES]; 69 | memb_blocks linemem; 70 | }; 71 | 72 | #endif /* __TELNETD_H__ */ 73 | // vim:cin:ai:sts=2 sw=2 ft=cpp 74 | -------------------------------------------------------------------------------- /examples/telnet_server/test.ex: -------------------------------------------------------------------------------- 1 | #!/usr/bin/expect 2 | 3 | spawn telnet 192.168.1.118 4 | expect "NanodeUIP>" 5 | send "mem\r" 6 | expect "NanodeUIP>" 7 | send "help\r" 8 | expect "NanodeUIP>" 9 | send "garbage\r" 10 | expect "NanodeUIP>" 11 | send "exit\r" 12 | expect "NanodeUIP>" 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/uip_hello_world/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/uip_mac_device_dump/uip_mac_device_dump.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct macdump_state { 6 | struct psock p; 7 | byte inputbuffer[1]; 8 | word offset; 9 | /* lbuf does not actually need to be here, but there's plenty of 10 | space and it's better than allocating it on the stack in 11 | macdump_connection() */ 12 | char lbuf[80]; 13 | }; 14 | UIPASSERT(sizeof(struct macdump_state)<=TCP_APP_STATE_SIZE) 15 | 16 | static void dumppage(int offset,char lbuf[]) 17 | { 18 | byte buf[16]; 19 | char *x; 20 | int j; 21 | NanodeUNIO unio(NANODE_MAC_DEVICE); 22 | 23 | memset(buf,0,16); 24 | unio.read(buf,offset,16); 25 | x=lbuf; 26 | sprintf(x,"%02X: ",offset); 27 | x+=4; 28 | for (j=0; j<16; j++) { 29 | sprintf(x,"%02X",buf[j]); 30 | x+=2; 31 | } 32 | *x=32; // space 33 | x+=1; 34 | for (j=0; j<16; j++) { 35 | if (buf[j]>=32 && buf[j]<127) *x=buf[j]; 36 | else *x=46; // dot 37 | x++; 38 | } 39 | *x++=10; // linefeed 40 | *x++=0; 41 | } 42 | 43 | static int macdump_connection(struct macdump_state *s) 44 | { 45 | PSOCK_BEGIN(&s->p); 46 | 47 | PSOCK_SEND_STR(&s->p, "MAC device dump\n\n"); 48 | 49 | while (s->offset<256) { 50 | dumppage(s->offset,s->lbuf); 51 | PSOCK_SEND_STR(&s->p,s->lbuf); 52 | s->offset+=16; 53 | } 54 | 55 | PSOCK_CLOSE(&s->p); 56 | 57 | PSOCK_END(&s->p); 58 | } 59 | 60 | static void macdump_appcall(void) 61 | { 62 | struct macdump_state *s = (struct macdump_state *)&(uip_conn->appstate); 63 | 64 | if(uip_connected()) { 65 | PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer)-1); 66 | s->offset=0; 67 | } 68 | 69 | macdump_connection(s); 70 | } 71 | 72 | void dhcp_status(int s,const uint16_t *dnsaddr) { 73 | char buf[20]="IP:"; 74 | if (s==DHCP_STATUS_OK) { 75 | uip.get_ip_addr_str(buf+3); 76 | Serial.println(buf); 77 | } 78 | } 79 | 80 | void setup() { 81 | char buf[20]; 82 | byte macaddr[6]; 83 | NanodeUNIO unio(NANODE_MAC_DEVICE); 84 | 85 | Serial.begin(38400); 86 | Serial.println("UIP test"); 87 | 88 | unio.read(macaddr,NANODE_MAC_ADDRESS,6); 89 | uip.init(macaddr); 90 | uip.get_mac_str(buf); 91 | Serial.println(buf); 92 | uip.wait_for_link(); 93 | Serial.println("Link is up"); 94 | uip.start_dhcp(dhcp_status); 95 | uip_listen(UIP_HTONS(1000),macdump_appcall); 96 | Serial.println("setup() done"); 97 | } 98 | 99 | void loop() { 100 | uip.poll(); 101 | } 102 | 103 | -------------------------------------------------------------------------------- /examples/uiptest/uiptest.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void resolv_found(char *name,uint16_t *addr) { 5 | char buf[30]=": addr="; 6 | Serial.print(name); 7 | uip.format_ipaddr(buf+7,addr); 8 | Serial.println(buf); 9 | } 10 | 11 | void dhcp_status(int s,const uint16_t *dnsaddr) { 12 | char buf[20]="IP:"; 13 | if (s==DHCP_STATUS_OK) { 14 | resolv_conf(dnsaddr); 15 | uip.get_ip_addr_str(buf+3); 16 | Serial.println(buf); 17 | uip.query_name("www.greenend.org.uk"); 18 | } 19 | } 20 | 21 | void setup() { 22 | char buf[20]; 23 | byte macaddr[6]; 24 | NanodeUNIO unio(NANODE_MAC_DEVICE); 25 | 26 | Serial.begin(38400); 27 | Serial.println("UIP test"); 28 | 29 | unio.read(macaddr,NANODE_MAC_ADDRESS,6); 30 | uip.init(macaddr); 31 | uip.get_mac_str(buf); 32 | Serial.println(buf); 33 | uip.wait_for_link(); 34 | Serial.println("Link is up"); 35 | uip.init_resolv(resolv_found); 36 | uip.start_dhcp(dhcp_status); 37 | Serial.println("setup() done"); 38 | } 39 | 40 | void loop() { 41 | uip.poll(); 42 | } 43 | -------------------------------------------------------------------------------- /examples/webserver/dir.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print "const file_entry_t dir[] PROGMEM = {" 3 | } 4 | 5 | /^unsigned char/ { 6 | gsub(/\[\]/,"") 7 | print "{ name_" $3,",",$3,", &",$3"_len }," 8 | } 9 | 10 | END { 11 | print "{0,0,0}," 12 | print "};" 13 | } 14 | -------------------------------------------------------------------------------- /examples/webserver/dir.h: -------------------------------------------------------------------------------- 1 | const file_entry_t dir[] PROGMEM = { 2 | { name_footer_html , footer_html , & footer_html_len }, 3 | { name_header_html , header_html , & header_html_len }, 4 | { name_buttons_list_shtml , buttons_list_shtml , & buttons_list_shtml_len }, 5 | { name_buttons_shtml , buttons_shtml , & buttons_shtml_len }, 6 | { name_credits_shtml , credits_shtml , & credits_shtml_len }, 7 | { name_index_shtml , index_shtml , & index_shtml_len }, 8 | { name_lights_shtml , lights_shtml , & lights_shtml_len }, 9 | { name_sensors_list_shtml , sensors_list_shtml , & sensors_list_shtml_len }, 10 | { name_sensors_shtml , sensors_shtml , & sensors_shtml_len }, 11 | { name_set_pin_shtml , set_pin_shtml , & set_pin_shtml_len }, 12 | { name_ok_txt , ok_txt , & ok_txt_len }, 13 | { name_index_js , index_js , & index_js_len }, 14 | {0,0,0}, 15 | }; 16 | -------------------------------------------------------------------------------- /examples/webserver/file_entry.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file file_entry.h 11 | * 12 | * Contains the structure used to represent a single file in a 13 | * directory on a flash file system. 14 | * 15 | */ 16 | 17 | #ifndef __FILE_ENTRY_H__ 18 | #define __FILE_ENTRY_H__ 19 | 20 | struct file_entry_t 21 | { 22 | const char* filename; 23 | const char* data; 24 | const unsigned int* len; 25 | }; 26 | 27 | #endif // __FILE_ENTRY_H__ 28 | -------------------------------------------------------------------------------- /examples/webserver/files.awk: -------------------------------------------------------------------------------- 1 | /^unsigned char/ { 2 | print "extern const",$2,$3,";" 3 | print "const char name_" $3,"PROGMEM = \"/" gensub(/.*\/([^\/]*).c.?.?$/,"\\1","g",FILENAME) "\";" 4 | } 5 | /^unsigned int/ { 6 | print "extern const",$1,$2,$3,";" 7 | } 8 | -------------------------------------------------------------------------------- /examples/webserver/files.h: -------------------------------------------------------------------------------- 1 | extern const char footer_html[] ; 2 | const char name_footer_html[] PROGMEM = "/footer.html"; 3 | extern const unsigned int footer_html_len ; 4 | extern const char header_html[] ; 5 | const char name_header_html[] PROGMEM = "/header.html"; 6 | extern const unsigned int header_html_len ; 7 | extern const char buttons_list_shtml[] ; 8 | const char name_buttons_list_shtml[] PROGMEM = "/buttons_list.shtml"; 9 | extern const unsigned int buttons_list_shtml_len ; 10 | extern const char buttons_shtml[] ; 11 | const char name_buttons_shtml[] PROGMEM = "/buttons.shtml"; 12 | extern const unsigned int buttons_shtml_len ; 13 | extern const char credits_shtml[] ; 14 | const char name_credits_shtml[] PROGMEM = "/credits.shtml"; 15 | extern const unsigned int credits_shtml_len ; 16 | extern const char index_shtml[] ; 17 | const char name_index_shtml[] PROGMEM = "/index.shtml"; 18 | extern const unsigned int index_shtml_len ; 19 | extern const char lights_shtml[] ; 20 | const char name_lights_shtml[] PROGMEM = "/lights.shtml"; 21 | extern const unsigned int lights_shtml_len ; 22 | extern const char sensors_list_shtml[] ; 23 | const char name_sensors_list_shtml[] PROGMEM = "/sensors_list.shtml"; 24 | extern const unsigned int sensors_list_shtml_len ; 25 | extern const char sensors_shtml[] ; 26 | const char name_sensors_shtml[] PROGMEM = "/sensors.shtml"; 27 | extern const unsigned int sensors_shtml_len ; 28 | extern const char set_pin_shtml[] ; 29 | const char name_set_pin_shtml[] PROGMEM = "/set_pin.shtml"; 30 | extern const unsigned int set_pin_shtml_len ; 31 | extern const char ok_txt[] ; 32 | const char name_ok_txt[] PROGMEM = "/ok.txt"; 33 | extern const unsigned int ok_txt_len ; 34 | extern const char index_js[] ; 35 | const char name_index_js[] PROGMEM = "/index.js"; 36 | extern const unsigned int index_js_len ; 37 | -------------------------------------------------------------------------------- /examples/webserver/fs/Makefile: -------------------------------------------------------------------------------- 1 | OUTDIR = .. 2 | INFILES = $(wildcard *.html) $(wildcard *.shtml) $(wildcard *.txt) $(wildcard *.js) 3 | XXDDIR = xxd 4 | XXDFILES = $(addprefix $(XXDDIR)/, $(addsuffix .cpp, $(INFILES))) 5 | OUTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .cpp, $(subst .,_,$(INFILES)))) 6 | ALLFILES = $(OUTDIR)/fs.cpp $(OUTDIR)/files.h $(OUTDIR)/dir.h 7 | 8 | all: $(ALLFILES) 9 | 10 | clean: 11 | rm -f $(ALLFILES) $(XXDFILES) 12 | 13 | $(XXDDIR)/%.cpp : % 14 | xxd -i $< | gawk -f ../xxd.awk > $@ 15 | 16 | $(OUTDIR)/files.h : $(XXDFILES) 17 | gawk -f ../files.awk $^ > $@ 18 | 19 | $(OUTDIR)/dir.h : $(XXDFILES) 20 | gawk -f ../dir.awk $^ > $@ 21 | 22 | $(OUTDIR)/fs.cpp : $(XXDFILES) 23 | cat $(XXDFILES) > $@ 24 | -------------------------------------------------------------------------------- /examples/webserver/fs/buttons.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 | 3 | 4 |
5 |

Buttons

6 |
    7 | %! buttons_list 8 |
9 | 10 |
11 | 12 | Home 13 |
14 | 15 |
16 | %!: /footer.html 17 | -------------------------------------------------------------------------------- /examples/webserver/fs/buttons_list.shtml: -------------------------------------------------------------------------------- 1 | %! buttons_list 2 | -------------------------------------------------------------------------------- /examples/webserver/fs/credits.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 | 3 | 4 | 5 | 6 | 35 | %!: /footer.html 36 | -------------------------------------------------------------------------------- /examples/webserver/fs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/webserver/fs/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NanodeUIP 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/webserver/fs/index.js: -------------------------------------------------------------------------------- 1 | $( '#buttons' ).live( 'pageinit',function(event){ 2 | $( "button#refresh" ).click( function(e,ui) { 3 | $.get("/buttons_list.shtml",function(data) { 4 | $("#buttons_list").html(data).listview('refresh'); 5 | }); 6 | }); 7 | }); 8 | $( '#lights' ).live( 'pageinit',function(event){ 9 | $( "select.light" ).change( function(e, ui) { 10 | $.get("/set_pin.shtml?pin="+e.target.name+"&val="+$(e.target).val()); 11 | }); 12 | }); 13 | $( '#sensors' ).live( 'pageinit',function(event){ 14 | $( "button#refresh" ).click( function(e,ui) { 15 | $.get("/sensors_list.shtml",function(data) { 16 | $("#sensors_list").html(data).listview('refresh'); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/webserver/fs/index.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 | 3 | 4 | 5 | 6 |
7 |
8 |

NanodeUIP

9 |
10 |
11 | 16 |
17 |
18 | Credits 19 | Help 20 |
21 |
22 | %!: /footer.html 23 | -------------------------------------------------------------------------------- /examples/webserver/fs/lights.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 | 3 | 4 |
5 |
6 |

Lights

7 |
8 |
9 | %! lights_list 10 |
11 |
12 | Home 13 |
14 |
15 | %!: /footer.html 16 | -------------------------------------------------------------------------------- /examples/webserver/fs/ok.txt: -------------------------------------------------------------------------------- 1 | +OK 2 | -------------------------------------------------------------------------------- /examples/webserver/fs/sensors.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 | 3 | 4 |
5 |

Sensors

6 | 7 |
8 |
    9 | %! sensors_list 10 |
11 |
12 | 13 |
14 | 15 | Home 16 |
17 |
18 | %!: /footer.html 19 | -------------------------------------------------------------------------------- /examples/webserver/fs/sensors_list.shtml: -------------------------------------------------------------------------------- 1 | %! sensors_list 2 | -------------------------------------------------------------------------------- /examples/webserver/fs/set_pin.shtml: -------------------------------------------------------------------------------- 1 | %! set_pin 2 | -------------------------------------------------------------------------------- /examples/webserver/httpd_fs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | #include 10 | #include "uip.h" 11 | #include "file_entry.h" 12 | #include "httpd_fs.h" 13 | 14 | // These generated headers contain the references to the files in 15 | // the file system. 16 | #include "files.h" 17 | #include "dir.h" 18 | 19 | int strncmp_PP(const char *ch1, const char *ch2, size_t len) 20 | { 21 | char c1=0,c2=0; 22 | while (len--) 23 | { 24 | c1 = pgm_read_byte(ch1++); 25 | c2 = pgm_read_byte(ch2++); 26 | if ( c1 != c2 ) 27 | break; 28 | if(!c1 && !c2) 29 | return (0); 30 | if(!c1 || !c2) 31 | break; 32 | } 33 | return (c1 -c2); 34 | } 35 | 36 | struct entry 37 | { 38 | char* filename; 39 | char* data; 40 | unsigned int* len; 41 | entry(const void* data) 42 | { 43 | memcpy_P(this,data,sizeof(file_entry_t)); 44 | } 45 | bool matches(const char* name) const 46 | { 47 | return ( name && filename && !strncmp_P(name,filename,strlen_P(filename)) ); 48 | } 49 | bool matches_P(const char* name) const 50 | { 51 | return ( name && filename && !strncmp_PP(name,filename,strlen_P(filename)) ); 52 | } 53 | void result(struct httpd_fs_file *file) const 54 | { 55 | file->data = data; 56 | file->len = pgm_read_word(len); 57 | 58 | printf_P(PSTR("result %p %i\n\r"),data,*len); 59 | } 60 | bool isvalid(void) const 61 | { 62 | return filename != 0; 63 | } 64 | }; 65 | 66 | // Note that 'filename' might not be zero-terminated! 67 | int httpd_fs_open(const char *filename, struct httpd_fs_file *file) 68 | { 69 | nanode_log_P(PSTR("http: file open")); 70 | nanode_log((char*)filename); 71 | 72 | int result = 0; 73 | const file_entry_t* cur = dir; 74 | bool done = false; 75 | while (!done) 76 | { 77 | entry e(cur); 78 | if (e.matches(filename)) 79 | { 80 | e.result(file); 81 | done = 1; 82 | result = 1; 83 | } 84 | if (!e.isvalid()) 85 | done = 1; 86 | ++cur; 87 | } 88 | 89 | return result; 90 | } 91 | 92 | void log_Pcr(const char* str) 93 | { 94 | char c = pgm_read_byte(str++); 95 | while (c && c != '\r' && c != '\n') 96 | { 97 | Serial.print(c); 98 | c = pgm_read_byte(str++); 99 | } 100 | Serial.println(); 101 | } 102 | 103 | int httpd_fs_open_P(const char *filename, struct httpd_fs_file *file) 104 | { 105 | nanode_log_P(PSTR("http: file open _P")); 106 | log_Pcr(filename); 107 | 108 | int result = 0; 109 | const file_entry_t* cur = dir; 110 | bool done = false; 111 | while (!done) 112 | { 113 | entry e(cur); 114 | if (e.matches_P(filename)) 115 | { 116 | e.result(file); 117 | done = 1; 118 | result = 1; 119 | } 120 | if (!e.isvalid()) 121 | done = 1; 122 | ++cur; 123 | } 124 | 125 | return result; 126 | } 127 | // vim:cin:ai:sts=2 sw=2 ft=cpp 128 | -------------------------------------------------------------------------------- /examples/webserver/pins_cgi.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file pins_cgi.h 11 | * 12 | * Helpers to register pins with the CGI 13 | */ 14 | 15 | #ifndef __PINS_CGI_H__ 16 | #define __PINS_CGI_H__ 17 | 18 | /** 19 | * Definition for a single pin, as reported in an HTML list 20 | */ 21 | struct pin_def_t 22 | { 23 | const char* name; /**< Easy-to-remember name of the pin, in progmem */ 24 | uint8_t number; 25 | 26 | // Progmem accessors 27 | bool is_valid_P(void) const; 28 | const char* get_name_P(void) const; 29 | uint8_t get_number_P(void) const; 30 | }; 31 | 32 | extern void cgi_register(const pin_def_t*,const pin_def_t*,const pin_def_t*); 33 | 34 | #endif // __PINS_CGI_H__ 35 | -------------------------------------------------------------------------------- /examples/webserver/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 J. Coliz 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | */ 8 | 9 | /** 10 | * @file printf.h 11 | * 12 | * Setup necessary to direct stdout to the Arduino Serial library, which 13 | * enables 'printf' 14 | */ 15 | 16 | #ifndef __PRINTF_H__ 17 | #define __PRINTF_H__ 18 | 19 | #ifdef ARDUINO 20 | 21 | int serial_putc( char c, FILE * ) 22 | { 23 | Serial.write( c ); 24 | 25 | return c; 26 | } 27 | 28 | void printf_begin(void) 29 | { 30 | fdevopen( &serial_putc, 0 ); 31 | } 32 | 33 | #else 34 | #error This example is only for use on Arduino. 35 | #endif // ARDUINO 36 | 37 | #endif // __PRINTF_H__ 38 | -------------------------------------------------------------------------------- /examples/webserver/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jam u0 && expect test.ex 4 | -------------------------------------------------------------------------------- /examples/webserver/test.ex: -------------------------------------------------------------------------------- 1 | #/usr/bin/expect 2 | 3 | set timeout 100 4 | spawn picocom -b 38400 /dev/ttyUSB0 5 | expect -re IP:(.*)\r 6 | set ip $expect_out(1,string) 7 | expect "+READY" 8 | spawn curl -v http://$ip/index.shtml 9 | expect "" 10 | spawn curl -v http://$ip/buttons.shtml 11 | expect "" 12 | spawn curl -v http://$ip/ok.txt 13 | expect "+OK" 14 | -------------------------------------------------------------------------------- /examples/webserver/xxd.awk: -------------------------------------------------------------------------------- 1 | /unsigned/ { print $1,$2,$3,"__attribute__((__section__(\".progmem.data\")))",$4,$5; next } 2 | { print } 3 | -------------------------------------------------------------------------------- /httpd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2005, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote 14 | * products derived from this software without specific prior 15 | * written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack. 30 | * 31 | * $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 32 | * 33 | */ 34 | 35 | #ifndef __HTTPD_H__ 36 | #define __HTTPD_H__ 37 | 38 | #include "psock.h" 39 | #include "httpd_fs.h" 40 | 41 | struct httpd_state { 42 | unsigned char timer; 43 | struct psock sin, sout; 44 | struct pt outputpt, scriptpt; 45 | char inputbuf[50]; 46 | char filename[30]; 47 | char state; 48 | struct httpd_fs_file file; 49 | int len; 50 | char *scriptptr; 51 | int scriptlen; 52 | 53 | unsigned short count; 54 | }; 55 | 56 | void httpd_init(void); 57 | void httpd_appcall(void); 58 | 59 | void httpd_log(char *msg); 60 | void httpd_log_file(u16_t *requester, char *file); 61 | 62 | #endif /* __HTTPD_H__ */ 63 | -------------------------------------------------------------------------------- /httpd_cgi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup httpd 3 | * @{ 4 | */ 5 | 6 | /** 7 | * \file 8 | * Web server script interface header file 9 | * \author 10 | * Adam Dunkels 11 | * 12 | */ 13 | 14 | 15 | 16 | /* 17 | * Copyright (c) 2001, Adam Dunkels. 18 | * All rights reserved. 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 1. Redistributions of source code must retain the above copyright 24 | * notice, this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright 26 | * notice, this list of conditions and the following disclaimer in the 27 | * documentation and/or other materials provided with the distribution. 28 | * 3. The name of the author may not be used to endorse or promote 29 | * products derived from this software without specific prior 30 | * written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | * 44 | * This file is part of the uIP TCP/IP stack. 45 | * 46 | * $Id: httpd_cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 47 | * 48 | */ 49 | 50 | #ifndef __HTTPD_CGI_H__ 51 | #define __HTTPD_CGI_H__ 52 | 53 | #include "psock.h" 54 | #include "httpd.h" 55 | 56 | typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *)); 57 | 58 | httpd_cgifunction httpd_cgi(char *name); 59 | 60 | struct httpd_cgi_call { 61 | const char *name; 62 | const httpd_cgifunction function; 63 | }; 64 | 65 | /** 66 | * \brief HTTPD CGI function declaration 67 | * \param name The C variable name of the function 68 | * \param str The string name of the function, used in the script file 69 | * \param function A pointer to the function that implements it 70 | * 71 | * This macro is used for declaring a HTTPD CGI 72 | * function. This function is then added to the list of 73 | * HTTPD CGI functions with the httpd_cgi_add() function. 74 | * 75 | * \hideinitializer 76 | */ 77 | #define HTTPD_CGI_CALL(name, str, function) \ 78 | static PT_THREAD(function(struct httpd_state *, char *)); \ 79 | static const struct httpd_cgi_call name = {str, function} 80 | 81 | void httpd_cgi_init(void); 82 | #endif /* __HTTPD_CGI_H__ */ 83 | 84 | /** @} */ 85 | -------------------------------------------------------------------------------- /httpd_fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: httpd_fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $ 34 | */ 35 | #ifndef __HTTPD_FS_H__ 36 | #define __HTTPD_FS_H__ 37 | 38 | #define HTTPD_FS_STATISTICS 1 39 | 40 | struct httpd_fs_file { 41 | char *data; 42 | int len; 43 | }; 44 | 45 | /* file must be allocated by caller and will be filled in 46 | by the function. */ 47 | int httpd_fs_open(const char *name, struct httpd_fs_file *file); 48 | int httpd_fs_open_P(const char *name, struct httpd_fs_file *file); 49 | 50 | #ifdef HTTPD_FS_STATISTICS 51 | #if HTTPD_FS_STATISTICS == 1 52 | u16_t httpd_fs_count(char *name); 53 | #endif /* HTTPD_FS_STATISTICS */ 54 | #endif /* HTTPD_FS_STATISTICS */ 55 | 56 | void httpd_fs_init(void); 57 | 58 | #endif /* __HTTPD_FS_H__ */ 59 | -------------------------------------------------------------------------------- /lc-addrlabels.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: lc-addrlabels.h,v 1.3 2006/06/12 08:00:30 adam Exp $ 34 | */ 35 | 36 | /** 37 | * \addtogroup lc 38 | * @{ 39 | */ 40 | 41 | /** 42 | * \file 43 | * Implementation of local continuations based on the "Labels as 44 | * values" feature of gcc 45 | * \author 46 | * Adam Dunkels 47 | * 48 | * This implementation of local continuations is based on a special 49 | * feature of the GCC C compiler called "labels as values". This 50 | * feature allows assigning pointers with the address of the code 51 | * corresponding to a particular C label. 52 | * 53 | * For more information, see the GCC documentation: 54 | * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html 55 | * 56 | * Thanks to dividuum for finding the nice local scope label 57 | * implementation. 58 | */ 59 | 60 | #ifndef __LC_ADDRLABELS_H__ 61 | #define __LC_ADDRLABELS_H__ 62 | 63 | /** \hideinitializer */ 64 | typedef void * lc_t; 65 | 66 | #define LC_INIT(s) s = NULL 67 | 68 | 69 | #define LC_RESUME(s) \ 70 | do { \ 71 | if(s != NULL) { \ 72 | goto *s; \ 73 | } \ 74 | } while(0) 75 | 76 | #define LC_SET(s) \ 77 | do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0) 78 | 79 | #define LC_END(s) 80 | 81 | #endif /* __LC_ADDRLABELS_H__ */ 82 | 83 | /** @} */ 84 | -------------------------------------------------------------------------------- /lc-switch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: lc-switch.h,v 1.2 2006/06/12 08:00:30 adam Exp $ 34 | */ 35 | 36 | /** 37 | * \addtogroup lc 38 | * @{ 39 | */ 40 | 41 | /** 42 | * \file 43 | * Implementation of local continuations based on switch() statment 44 | * \author Adam Dunkels 45 | * 46 | * This implementation of local continuations uses the C switch() 47 | * statement to resume execution of a function somewhere inside the 48 | * function's body. The implementation is based on the fact that 49 | * switch() statements are able to jump directly into the bodies of 50 | * control structures such as if() or while() statmenets. 51 | * 52 | * This implementation borrows heavily from Simon Tatham's coroutines 53 | * implementation in C: 54 | * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html 55 | */ 56 | 57 | #ifndef __LC_SWITCH_H__ 58 | #define __LC_SWTICH_H__ 59 | 60 | /* WARNING! lc implementation using switch() does not work if an 61 | LC_SET() is done within another switch() statement! */ 62 | 63 | /** \hideinitializer */ 64 | typedef unsigned short lc_t; 65 | 66 | #define LC_INIT(s) s = 0; 67 | 68 | #define LC_RESUME(s) switch(s) { case 0: 69 | 70 | #define LC_SET(s) s = __LINE__; case __LINE__: 71 | 72 | #define LC_END(s) } 73 | 74 | #endif /* __LC_SWITCH_H__ */ 75 | 76 | /** @} */ 77 | -------------------------------------------------------------------------------- /makestrings.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | sub stringify { 4 | my $name = shift(@_); 5 | open(OUTPUTC, "> $name.c"); 6 | open(OUTPUTH, "> $name.h"); 7 | 8 | printf(OUTPUTC "#include \n"); 9 | printf(OUTPUTH "#include \n"); 10 | 11 | open(FILE, "$name"); 12 | 13 | while() { 14 | if(/(.+) "(.+)"/) { 15 | $var = $1; 16 | $data = $2; 17 | 18 | $datan = $data; 19 | $datan =~ s/\\r/\r/g; 20 | $datan =~ s/\\n/\n/g; 21 | $datan =~ s/\\01/\01/g; 22 | $datan =~ s/\\0/\0/g; 23 | 24 | printf(OUTPUTC "const char $var\[%d] PROGMEM = \n", length($datan) + 1); 25 | printf(OUTPUTC "/* \"$data\" */\n"); 26 | printf(OUTPUTC "{"); 27 | for($j = 0; $j < length($datan); $j++) { 28 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 29 | } 30 | printf(OUTPUTC "0 };\n"); 31 | 32 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 33 | 34 | } 35 | } 36 | close(OUTPUTC); 37 | close(OUTPUTH); 38 | } 39 | stringify("webclient-strings"); 40 | 41 | exit 0; 42 | -------------------------------------------------------------------------------- /ntpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * @(#)$Id: ntpc.h,v 1.3 2006/06/11 21:46:37 adam Exp $ 32 | */ 33 | #ifndef __NTPC_H__ 34 | #define __NTPC_H__ 35 | 36 | #include "timer.h" 37 | #include "pt.h" 38 | 39 | struct ntp_short { 40 | u16_t seconds; 41 | u16_t fraction; 42 | }; 43 | 44 | struct ntp_timestamp { 45 | uint16_t seconds[2]; 46 | uint16_t fraction[2]; 47 | }; 48 | 49 | struct ntpc_state { 50 | struct pt pt; 51 | char state; 52 | struct uip_udp_conn *conn; 53 | struct timer timer; 54 | u16_t ticks; 55 | 56 | uint32_t unixtime; // Seconds since Jan 1, 1970 57 | }; 58 | 59 | int ntpc_init(const uip_ipaddr_t*); 60 | void ntpc_appcall(void); 61 | void ntpc_configured(const struct ntpc_state *s); 62 | 63 | #endif /* __NTPC_H__ */ 64 | -------------------------------------------------------------------------------- /platform.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "clock.h" 3 | #include 4 | 5 | #if ARDUINO >= 100 6 | #include // Arduino 1.0 7 | #else 8 | #include // Arduino 0022 9 | #endif 10 | 11 | void clock_init(void) {} 12 | 13 | clock_time_t clock_time(void) { 14 | return millis(); 15 | } 16 | 17 | void nullproc(void) {} 18 | 19 | extern void nanode_log(char *msg); 20 | extern void nanode_log_P(PGM_P msg); 21 | 22 | void uip_log(char *msg) { 23 | nanode_log(msg); 24 | } 25 | void uip_log_P(PGM_P msg) { 26 | nanode_log_P(msg); 27 | } 28 | -------------------------------------------------------------------------------- /resolv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup resolv 3 | * @{ 4 | */ 5 | /** 6 | * \file 7 | * DNS resolver code header file. 8 | * \author Adam Dunkels 9 | */ 10 | 11 | /* 12 | * Copyright (c) 2002-2003, Adam Dunkels. 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions 17 | * are met: 18 | * 1. Redistributions of source code must retain the above copyright 19 | * notice, this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 3. The name of the author may not be used to endorse or promote 24 | * products derived from this software without specific prior 25 | * written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 29 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 31 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | * This file is part of the uIP TCP/IP stack. 40 | * 41 | * $Id: resolv.h,v 1.4 2006/06/11 21:46:37 adam Exp $ 42 | * 43 | */ 44 | #ifndef __RESOLV_H__ 45 | #define __RESOLV_H__ 46 | 47 | void resolv_appcall(void); 48 | 49 | #include "uipopt.h" 50 | 51 | /** 52 | * Callback function which is called when a hostname is found. 53 | * 54 | * This function must be implemented by the module that uses the DNS 55 | * resolver. It is called when a hostname is found, or when a hostname 56 | * was not found. 57 | * 58 | * \param name A pointer to the name that was looked up. \param 59 | * ipaddr A pointer to a 4-byte array containing the IP address of the 60 | * hostname, or NULL if the hostname could not be found. 61 | */ 62 | void resolv_found(char *name, u16_t *ipaddr); 63 | 64 | /* Functions. */ 65 | void resolv_conf(const u16_t *dnsserver); 66 | u16_t *resolv_getserver(void); 67 | void resolv_init(void); 68 | u16_t *resolv_lookup(const char *name); 69 | void resolv_query(const char *name); 70 | 71 | #endif /* __RESOLV_H__ */ 72 | 73 | /** @} */ 74 | -------------------------------------------------------------------------------- /timer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup timer Timer library 3 | * 4 | * The timer library provides functions for setting, resetting and 5 | * restarting timers, and for checking if a timer has expired. An 6 | * application must "manually" check if its timers have expired; this 7 | * is not done automatically. 8 | * 9 | * A timer is declared as a \c struct \c timer and all access to the 10 | * timer is made by a pointer to the declared timer. 11 | * 12 | * \note The timer library uses the \ref clock "Clock library" to 13 | * measure time. Intervals should be specified in the format used by 14 | * the clock library. 15 | * 16 | * @{ 17 | */ 18 | 19 | 20 | /** 21 | * \file 22 | * Timer library header file. 23 | * \author 24 | * Adam Dunkels 25 | */ 26 | 27 | /* 28 | * Copyright (c) 2004, Swedish Institute of Computer Science. 29 | * All rights reserved. 30 | * 31 | * Redistribution and use in source and binary forms, with or without 32 | * modification, are permitted provided that the following conditions 33 | * are met: 34 | * 1. Redistributions of source code must retain the above copyright 35 | * notice, this list of conditions and the following disclaimer. 36 | * 2. Redistributions in binary form must reproduce the above copyright 37 | * notice, this list of conditions and the following disclaimer in the 38 | * documentation and/or other materials provided with the distribution. 39 | * 3. Neither the name of the Institute nor the names of its contributors 40 | * may be used to endorse or promote products derived from this software 41 | * without specific prior written permission. 42 | * 43 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 44 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 | * SUCH DAMAGE. 54 | * 55 | * This file is part of the uIP TCP/IP stack 56 | * 57 | * Author: Adam Dunkels 58 | * 59 | * $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $ 60 | */ 61 | #ifndef __TIMER_H__ 62 | #define __TIMER_H__ 63 | 64 | #include "clock.h" 65 | 66 | /** 67 | * A timer. 68 | * 69 | * This structure is used for declaring a timer. The timer must be set 70 | * with timer_set() before it can be used. 71 | * 72 | * \hideinitializer 73 | */ 74 | struct timer { 75 | clock_time_t start; 76 | clock_time_t interval; 77 | }; 78 | 79 | void timer_set(struct timer *t, clock_time_t interval); 80 | void timer_reset(struct timer *t); 81 | void timer_restart(struct timer *t); 82 | int timer_expired(struct timer *t); 83 | clock_time_t timer_remaining(struct timer *t); 84 | 85 | 86 | #endif /* __TIMER_H__ */ 87 | 88 | /** @} */ 89 | /** @} */ 90 | -------------------------------------------------------------------------------- /uip/apps/README: -------------------------------------------------------------------------------- 1 | This directory contains a few example applications. They are not all 2 | heavily tested, however. 3 | -------------------------------------------------------------------------------- /uip/apps/dhcpc/Makefile.dhcpc: -------------------------------------------------------------------------------- 1 | APP_SOURCES += dhcpc.c timer.c 2 | -------------------------------------------------------------------------------- /uip/apps/hello-world/Makefile.hello-world: -------------------------------------------------------------------------------- 1 | APP_SOURCES += hello-world.c 2 | -------------------------------------------------------------------------------- /uip/apps/resolv/Makefile.resolv: -------------------------------------------------------------------------------- 1 | APP_SOURCES += resolv.c 2 | -------------------------------------------------------------------------------- /uip/apps/smtp/Makefile.smtp: -------------------------------------------------------------------------------- 1 | APP_SOURCES += smtp.c smtp-strings.c memb.c 2 | -------------------------------------------------------------------------------- /uip/apps/smtp/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "};\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("smtp-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /uip/apps/smtp/smtp-strings: -------------------------------------------------------------------------------- 1 | smtp_220 "220" 2 | smtp_helo "HELO " 3 | smtp_mail_from "MAIL FROM: " 4 | smtp_rcpt_to "RCPT TO: " 5 | smtp_data "DATA\r\n" 6 | smtp_to "To: " 7 | smtp_from "From: " 8 | smtp_subject "Subject: " 9 | smtp_quit "QUIT\r\n" 10 | smtp_crnl "\r\n" 11 | smtp_crnlperiodcrnl "\r\n.\r\n" -------------------------------------------------------------------------------- /uip/apps/smtp/smtp-strings.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: smtp-strings.c,v 1.3 2006/06/11 21:46:37 adam Exp $ 34 | */ 35 | const char smtp_220[4] = 36 | /* "220" */ 37 | {0x32, 0x32, 0x30, }; 38 | const char smtp_helo[6] = 39 | /* "HELO " */ 40 | {0x48, 0x45, 0x4c, 0x4f, 0x20, }; 41 | const char smtp_mail_from[12] = 42 | /* "MAIL FROM: " */ 43 | {0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, }; 44 | const char smtp_rcpt_to[10] = 45 | /* "RCPT TO: " */ 46 | {0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, }; 47 | const char smtp_data[7] = 48 | /* "DATA\r\n" */ 49 | {0x44, 0x41, 0x54, 0x41, 0xd, 0xa, }; 50 | const char smtp_to[5] = 51 | /* "To: " */ 52 | {0x54, 0x6f, 0x3a, 0x20, }; 53 | const char smtp_cc[5] = 54 | /* "Cc: " */ 55 | {0x43, 0x63, 0x3a, 0x20, }; 56 | const char smtp_from[7] = 57 | /* "From: " */ 58 | {0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, }; 59 | const char smtp_subject[10] = 60 | /* "Subject: " */ 61 | {0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, }; 62 | const char smtp_quit[7] = 63 | /* "QUIT\r\n" */ 64 | {0x51, 0x55, 0x49, 0x54, 0xd, 0xa, }; 65 | const char smtp_crnl[3] = 66 | /* "\r\n" */ 67 | {0xd, 0xa, }; 68 | const char smtp_crnlperiodcrnl[6] = 69 | /* "\r\n.\r\n" */ 70 | {0xd, 0xa, 0x2e, 0xd, 0xa, }; 71 | -------------------------------------------------------------------------------- /uip/apps/smtp/smtp-strings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: smtp-strings.h,v 1.3 2006/06/11 21:46:37 adam Exp $ 34 | */ 35 | extern const char smtp_220[4]; 36 | extern const char smtp_helo[6]; 37 | extern const char smtp_mail_from[12]; 38 | extern const char smtp_rcpt_to[10]; 39 | extern const char smtp_data[7]; 40 | extern const char smtp_to[5]; 41 | extern const char smtp_cc[5]; 42 | extern const char smtp_from[7]; 43 | extern const char smtp_subject[10]; 44 | extern const char smtp_quit[7]; 45 | extern const char smtp_crnl[3]; 46 | extern const char smtp_crnlperiodcrnl[6]; 47 | -------------------------------------------------------------------------------- /uip/apps/smtp/smtp.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * \addtogroup smtp 4 | * @{ 5 | */ 6 | 7 | 8 | /** 9 | * \file 10 | * SMTP header file 11 | * \author Adam Dunkels 12 | */ 13 | 14 | /* 15 | * Copyright (c) 2002, Adam Dunkels. 16 | * All rights reserved. 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted provided that the following conditions 20 | * are met: 21 | * 1. Redistributions of source code must retain the above copyright 22 | * notice, this list of conditions and the following disclaimer. 23 | * 2. Redistributions in binary form must reproduce the above copyright 24 | * notice, this list of conditions and the following disclaimer in the 25 | * documentation and/or other materials provided with the distribution. 26 | * 3. The name of the author may not be used to endorse or promote 27 | * products derived from this software without specific prior 28 | * written permission. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 31 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 34 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 36 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 37 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 38 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 39 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | * 42 | * This file is part of the uIP TCP/IP stack. 43 | * 44 | * $Id: smtp.h,v 1.4 2006/06/11 21:46:37 adam Exp $ 45 | * 46 | */ 47 | #ifndef __SMTP_H__ 48 | #define __SMTP_H__ 49 | 50 | #include "uipopt.h" 51 | 52 | /** 53 | * Error number that signifies a non-error condition. 54 | */ 55 | #define SMTP_ERR_OK 0 56 | 57 | /** 58 | * Callback function that is called when an e-mail transmission is 59 | * done. 60 | * 61 | * This function must be implemented by the module that uses the SMTP 62 | * module. 63 | * 64 | * \param error The number of the error if an error occured, or 65 | * SMTP_ERR_OK. 66 | */ 67 | void smtp_done(unsigned char error); 68 | 69 | void smtp_init(void); 70 | 71 | /* Functions. */ 72 | void smtp_configure(char *localhostname, u16_t *smtpserver); 73 | unsigned char smtp_send(char *to, char *from, 74 | char *subject, char *msg, 75 | u16_t msglen); 76 | #define SMTP_SEND(to, cc, from, subject, msg) \ 77 | smtp_send(to, cc, from, subject, msg, strlen(msg)) 78 | 79 | void smtp_appcall(void); 80 | 81 | struct smtp_state { 82 | u8_t state; 83 | char *to; 84 | char *from; 85 | char *subject; 86 | char *msg; 87 | u16_t msglen; 88 | 89 | u16_t sentlen, textlen; 90 | u16_t sendptr; 91 | 92 | }; 93 | 94 | 95 | #ifndef UIP_APPCALL 96 | #define UIP_APPCALL smtp_appcall 97 | #endif 98 | typedef struct smtp_state uip_tcp_appstate_t; 99 | 100 | 101 | #endif /* __SMTP_H__ */ 102 | 103 | /** @} */ 104 | -------------------------------------------------------------------------------- /uip/apps/telnetd/Makefile.telnetd: -------------------------------------------------------------------------------- 1 | APP_SOURCES += telnetd.c shell.c memb.c 2 | -------------------------------------------------------------------------------- /uip/apps/telnetd/telnetd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $ 33 | * 34 | */ 35 | #ifndef __TELNETD_H__ 36 | #define __TELNETD_H__ 37 | 38 | #include "uipopt.h" 39 | 40 | void telnetd_appcall(void); 41 | 42 | #ifndef TELNETD_CONF_LINELEN 43 | #define TELNETD_CONF_LINELEN 40 44 | #endif 45 | #ifndef TELNETD_CONF_NUMLINES 46 | #define TELNETD_CONF_NUMLINES 16 47 | #endif 48 | 49 | struct telnetd_state { 50 | char *lines[TELNETD_CONF_NUMLINES]; 51 | char buf[TELNETD_CONF_LINELEN]; 52 | char bufptr; 53 | u8_t numsent; 54 | u8_t state; 55 | }; 56 | 57 | typedef struct telnetd_state uip_tcp_appstate_t; 58 | 59 | #ifndef UIP_APPCALL 60 | #define UIP_APPCALL telnetd_appcall 61 | #endif 62 | 63 | #endif /* __TELNETD_H__ */ 64 | -------------------------------------------------------------------------------- /uip/apps/webclient/Makefile.webclient: -------------------------------------------------------------------------------- 1 | APP_SOURCES += webclient-strings.c webclient.c 2 | -------------------------------------------------------------------------------- /uip/apps/webclient/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "0 };\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("webclient-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /uip/apps/webclient/webclient-strings: -------------------------------------------------------------------------------- 1 | http_http "http://" 2 | http_200 "200 " 3 | http_301 "301 " 4 | http_302 "302 " 5 | http_get "GET " 6 | http_10 "HTTP/1.0" 7 | http_11 "HTTP/1.1" 8 | http_content_type "content-type: " 9 | http_texthtml "text/html" 10 | http_location "location: " 11 | http_host "host: " 12 | http_crnl "\r\n" 13 | http_index_html "/index.html" 14 | http_404_html "/404.html" 15 | http_content_type_html "Content-type: text/html\r\n\r\n" 16 | http_content_type_css "Content-type: text/css\r\n\r\n" 17 | http_content_type_text "Content-type: text/text\r\n\r\n" 18 | http_content_type_png "Content-type: image/png\r\n\r\n" 19 | http_content_type_gif "Content-type: image/gif\r\n\r\n" 20 | http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" 21 | http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" 22 | http_html ".html" 23 | http_shtml ".shtml" 24 | http_htm ".htm" 25 | http_css ".css" 26 | http_png ".png" 27 | http_gif ".gif" 28 | http_jpg ".jpg" 29 | http_text ".text" 30 | http_txt ".txt" 31 | http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" 32 | -------------------------------------------------------------------------------- /uip/apps/webclient/webclient-strings.h: -------------------------------------------------------------------------------- 1 | extern const char http_http[8]; 2 | extern const char http_200[5]; 3 | extern const char http_301[5]; 4 | extern const char http_302[5]; 5 | extern const char http_get[5]; 6 | extern const char http_10[9]; 7 | extern const char http_11[9]; 8 | extern const char http_content_type[15]; 9 | extern const char http_texthtml[10]; 10 | extern const char http_location[11]; 11 | extern const char http_host[7]; 12 | extern const char http_crnl[3]; 13 | extern const char http_index_html[12]; 14 | extern const char http_404_html[10]; 15 | extern const char http_content_type_html[28]; 16 | extern const char http_content_type_css [27]; 17 | extern const char http_content_type_text[28]; 18 | extern const char http_content_type_png [28]; 19 | extern const char http_content_type_gif [28]; 20 | extern const char http_content_type_jpg [29]; 21 | extern const char http_content_type_binary[43]; 22 | extern const char http_html[6]; 23 | extern const char http_shtml[7]; 24 | extern const char http_htm[5]; 25 | extern const char http_css[5]; 26 | extern const char http_png[5]; 27 | extern const char http_gif[5]; 28 | extern const char http_jpg[5]; 29 | extern const char http_text[6]; 30 | extern const char http_txt[5]; 31 | extern const char http_user_agent_fields[77]; 32 | -------------------------------------------------------------------------------- /uip/apps/webserver/Makefile.webserver: -------------------------------------------------------------------------------- 1 | APP_SOURCES += httpd.c http-strings.c httpd-fs.c httpd-cgi.c 2 | -------------------------------------------------------------------------------- /uip/apps/webserver/http-strings: -------------------------------------------------------------------------------- 1 | http_http "http://" 2 | http_200 "200 " 3 | http_301 "301 " 4 | http_302 "302 " 5 | http_get "GET " 6 | http_10 "HTTP/1.0" 7 | http_11 "HTTP/1.1" 8 | http_content_type "content-type: " 9 | http_texthtml "text/html" 10 | http_location "location: " 11 | http_host "host: " 12 | http_crnl "\r\n" 13 | http_index_html "/index.html" 14 | http_404_html "/404.html" 15 | http_referer "Referer:" 16 | http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" 17 | http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" 18 | http_content_type_plain "Content-type: text/plain\r\n\r\n" 19 | http_content_type_html "Content-type: text/html\r\n\r\n" 20 | http_content_type_css "Content-type: text/css\r\n\r\n" 21 | http_content_type_text "Content-type: text/text\r\n\r\n" 22 | http_content_type_png "Content-type: image/png\r\n\r\n" 23 | http_content_type_gif "Content-type: image/gif\r\n\r\n" 24 | http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" 25 | http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" 26 | http_html ".html" 27 | http_shtml ".shtml" 28 | http_htm ".htm" 29 | http_css ".css" 30 | http_png ".png" 31 | http_gif ".gif" 32 | http_jpg ".jpg" 33 | http_text ".txt" 34 | http_txt ".txt" 35 | 36 | -------------------------------------------------------------------------------- /uip/apps/webserver/http-strings.h: -------------------------------------------------------------------------------- 1 | extern const char http_http[8]; 2 | extern const char http_200[5]; 3 | extern const char http_301[5]; 4 | extern const char http_302[5]; 5 | extern const char http_get[5]; 6 | extern const char http_10[9]; 7 | extern const char http_11[9]; 8 | extern const char http_content_type[15]; 9 | extern const char http_texthtml[10]; 10 | extern const char http_location[11]; 11 | extern const char http_host[7]; 12 | extern const char http_crnl[3]; 13 | extern const char http_index_html[12]; 14 | extern const char http_404_html[10]; 15 | extern const char http_referer[9]; 16 | extern const char http_header_200[84]; 17 | extern const char http_header_404[91]; 18 | extern const char http_content_type_plain[29]; 19 | extern const char http_content_type_html[28]; 20 | extern const char http_content_type_css [27]; 21 | extern const char http_content_type_text[28]; 22 | extern const char http_content_type_png [28]; 23 | extern const char http_content_type_gif [28]; 24 | extern const char http_content_type_jpg [29]; 25 | extern const char http_content_type_binary[43]; 26 | extern const char http_html[6]; 27 | extern const char http_shtml[7]; 28 | extern const char http_htm[5]; 29 | extern const char http_css[5]; 30 | extern const char http_png[5]; 31 | extern const char http_gif[5]; 32 | extern const char http_jpg[5]; 33 | extern const char http_text[5]; 34 | extern const char http_txt[5]; 35 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-cgi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \addtogroup httpd 3 | * @{ 4 | */ 5 | 6 | /** 7 | * \file 8 | * Web server script interface header file 9 | * \author 10 | * Adam Dunkels 11 | * 12 | */ 13 | 14 | 15 | 16 | /* 17 | * Copyright (c) 2001, Adam Dunkels. 18 | * All rights reserved. 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 1. Redistributions of source code must retain the above copyright 24 | * notice, this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright 26 | * notice, this list of conditions and the following disclaimer in the 27 | * documentation and/or other materials provided with the distribution. 28 | * 3. The name of the author may not be used to endorse or promote 29 | * products derived from this software without specific prior 30 | * written permission. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | * 44 | * This file is part of the uIP TCP/IP stack. 45 | * 46 | * $Id: httpd-cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 47 | * 48 | */ 49 | 50 | #ifndef __HTTPD_CGI_H__ 51 | #define __HTTPD_CGI_H__ 52 | 53 | #include "psock.h" 54 | #include "httpd.h" 55 | 56 | typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *)); 57 | 58 | httpd_cgifunction httpd_cgi(char *name); 59 | 60 | struct httpd_cgi_call { 61 | const char *name; 62 | const httpd_cgifunction function; 63 | }; 64 | 65 | /** 66 | * \brief HTTPD CGI function declaration 67 | * \param name The C variable name of the function 68 | * \param str The string name of the function, used in the script file 69 | * \param function A pointer to the function that implements it 70 | * 71 | * This macro is used for declaring a HTTPD CGI 72 | * function. This function is then added to the list of 73 | * HTTPD CGI functions with the httpd_cgi_add() function. 74 | * 75 | * \hideinitializer 76 | */ 77 | #define HTTPD_CGI_CALL(name, str, function) \ 78 | static PT_THREAD(function(struct httpd_state *, char *)); \ 79 | static const struct httpd_cgi_call name = {str, function} 80 | 81 | void httpd_cgi_init(void); 82 | #endif /* __HTTPD_CGI_H__ */ 83 | 84 | /** @} */ 85 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $ 34 | */ 35 | #ifndef __HTTPD_FS_H__ 36 | #define __HTTPD_FS_H__ 37 | 38 | #define HTTPD_FS_STATISTICS 1 39 | 40 | struct httpd_fs_file { 41 | char *data; 42 | int len; 43 | }; 44 | 45 | /* file must be allocated by caller and will be filled in 46 | by the function. */ 47 | int httpd_fs_open(const char *name, struct httpd_fs_file *file); 48 | 49 | #ifdef HTTPD_FS_STATISTICS 50 | #if HTTPD_FS_STATISTICS == 1 51 | u16_t httpd_fs_count(char *name); 52 | #endif /* HTTPD_FS_STATISTICS */ 53 | #endif /* HTTPD_FS_STATISTICS */ 54 | 55 | void httpd_fs_init(void); 56 | 57 | #endif /* __HTTPD_FS_H__ */ 58 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

404 - file not found

5 |

Go here instead.

6 |
7 | 8 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/fade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/apps/webserver/httpd-fs/fade.png -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/files.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

File statistics

3 |
4 | 5 | 6 | 9 | 10 | 13 | 14 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 | 33 |
/index.html%! file-stats /index.html 7 |
/files.shtml%! file-stats /files.shtml 11 |
/tcp.shtml%! file-stats /tcp.shtml 15 |
/stats.shtml%! file-stats /stats.shtml 19 |
/style.css%! file-stats /style.css 23 |
/404.html%! file-stats /404.html 27 |
/fade.png%! file-stats /fade.png 31 |
34 |
35 | %!: /footer.html 36 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to the uIP web server! 5 | 6 | 7 | 8 | 9 | 17 | 18 |
19 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to the uIP web server! 5 | 6 | 7 | 8 | 9 | 17 | 18 |
19 |

20 | These web pages are served by a small web server running on top of 21 | the uIP embedded TCP/IP 22 | stack. 23 |

24 |

25 | Click on the links above for web server statistics. 26 |

27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/processes.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

System processes


3 | 4 | %! processes 5 | %!: /footer.html -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/stats.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

Network statistics

3 |
4 |
IDNamePriorityPoll handlerEvent handlerProcstate
5 |
 6 | IP           Packets received
 7 |              Packets sent
 8 | 	     Packets dropped
 9 | IP errors    IP version/header length
10 |              IP length, high byte
11 |              IP length, low byte
12 |              IP fragments
13 |              Header checksum
14 |              Wrong protocol
15 | ICMP	     Packets received
16 |              Packets sent
17 |              Packets dropped
18 |              Type errors
19 | TCP          Packets received
20 |              Packets sent
21 |              Packets dropped
22 |              Checksum errors
23 |              Data packets without ACKs
24 |              Resets
25 |              Retransmissions
26 | 	     No connection avaliable
27 | 	     Connection attempts to closed ports
28 | 
%! net-stats
29 | 
30 | 31 | %!: /footer.html 32 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/style.css: -------------------------------------------------------------------------------- 1 | h1 2 | { 3 | text-align: center; 4 | font-size:14pt; 5 | font-family:arial,helvetica; 6 | font-weight:bold; 7 | padding:10px; 8 | } 9 | 10 | body 11 | { 12 | 13 | background-color: #fffeec; 14 | color:black; 15 | 16 | font-size:8pt; 17 | font-family:arial,helvetica; 18 | } 19 | 20 | .menu 21 | { 22 | margin: 4px; 23 | width:60%; 24 | 25 | padding:2px; 26 | 27 | border: solid 1px; 28 | background-color: #fffcd2; 29 | text-align:left; 30 | 31 | font-size:9pt; 32 | font-family:arial,helvetica; 33 | } 34 | 35 | div.menubox 36 | { 37 | width: 25%; 38 | border: 0; 39 | float: left; 40 | text-align: center; 41 | } 42 | 43 | .contentblock 44 | { 45 | margin: 4px; 46 | width:60%; 47 | 48 | padding:2px; 49 | 50 | border: 1px dotted; 51 | background-color: white; 52 | 53 | font-size:8pt; 54 | font-family:arial,helvetica; 55 | 56 | } 57 | 58 | p.intro 59 | { 60 | margin-left:20px; 61 | margin-right:20px; 62 | 63 | font-size:10pt; 64 | /* font-weight:bold; */ 65 | font-family:arial,helvetica; 66 | } 67 | 68 | p.clink 69 | { 70 | font-size:12pt; 71 | font-family:courier,monospace; 72 | text-align:center; 73 | } 74 | 75 | p.clink9 76 | { 77 | font-size:9pt; 78 | font-family:courier,monospace; 79 | text-align:center; 80 | } 81 | 82 | 83 | p 84 | { 85 | padding-left:10px; 86 | } 87 | 88 | p.right 89 | { 90 | text-align:right; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fs/tcp.shtml: -------------------------------------------------------------------------------- 1 | %!: /header.html 2 |

Current connections


3 | 4 | %! tcp-connections 5 | %!: /footer.html -------------------------------------------------------------------------------- /uip/apps/webserver/httpd-fsdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | * $Id: httpd-fsdata.h,v 1.1 2006/06/07 09:13:08 adam Exp $ 34 | */ 35 | #ifndef __HTTPD_FSDATA_H__ 36 | #define __HTTPD_FSDATA_H__ 37 | 38 | #include "uip.h" 39 | 40 | struct httpd_fsdata_file { 41 | const struct httpd_fsdata_file *next; 42 | const char *name; 43 | const char *data; 44 | const int len; 45 | #ifdef HTTPD_FS_STATISTICS 46 | #if HTTPD_FS_STATISTICS == 1 47 | u16_t count; 48 | #endif /* HTTPD_FS_STATISTICS */ 49 | #endif /* HTTPD_FS_STATISTICS */ 50 | }; 51 | 52 | struct httpd_fsdata_file_noconst { 53 | struct httpd_fsdata_file *next; 54 | char *name; 55 | char *data; 56 | int len; 57 | #ifdef HTTPD_FS_STATISTICS 58 | #if HTTPD_FS_STATISTICS == 1 59 | u16_t count; 60 | #endif /* HTTPD_FS_STATISTICS */ 61 | #endif /* HTTPD_FS_STATISTICS */ 62 | }; 63 | 64 | #endif /* __HTTPD_FSDATA_H__ */ 65 | -------------------------------------------------------------------------------- /uip/apps/webserver/httpd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2005, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote 14 | * products derived from this software without specific prior 15 | * written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack. 30 | * 31 | * $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 32 | * 33 | */ 34 | 35 | #ifndef __HTTPD_H__ 36 | #define __HTTPD_H__ 37 | 38 | #include "psock.h" 39 | #include "httpd-fs.h" 40 | 41 | struct httpd_state { 42 | unsigned char timer; 43 | struct psock sin, sout; 44 | struct pt outputpt, scriptpt; 45 | char inputbuf[50]; 46 | char filename[20]; 47 | char state; 48 | struct httpd_fs_file file; 49 | int len; 50 | char *scriptptr; 51 | int scriptlen; 52 | 53 | unsigned short count; 54 | }; 55 | 56 | void httpd_init(void); 57 | void httpd_appcall(void); 58 | 59 | void httpd_log(char *msg); 60 | void httpd_log_file(u16_t *requester, char *file); 61 | 62 | #endif /* __HTTPD_H__ */ 63 | -------------------------------------------------------------------------------- /uip/apps/webserver/makefsdata: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | open(OUTPUT, "> httpd-fsdata.c"); 4 | 5 | chdir("httpd-fs"); 6 | 7 | opendir(DIR, "."); 8 | @files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); 9 | closedir(DIR); 10 | 11 | foreach $file (@files) { 12 | 13 | if(-d $file && $file !~ /^\./) { 14 | print "Processing directory $file\n"; 15 | opendir(DIR, $file); 16 | @newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR); 17 | closedir(DIR); 18 | printf "Adding files @newfiles\n"; 19 | @files = (@files, map { $_ = "$file/$_" } @newfiles); 20 | next; 21 | } 22 | } 23 | 24 | foreach $file (@files) { 25 | if(-f $file) { 26 | 27 | print "Adding file $file\n"; 28 | 29 | open(FILE, $file) || die "Could not open file $file\n"; 30 | 31 | $file =~ s-^-/-; 32 | $fvar = $file; 33 | $fvar =~ s-/-_-g; 34 | $fvar =~ s-\.-_-g; 35 | # for AVR, add PROGMEM here 36 | print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); 37 | print(OUTPUT "\t/* $file */\n\t"); 38 | for($j = 0; $j < length($file); $j++) { 39 | printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); 40 | } 41 | printf(OUTPUT "0,\n"); 42 | 43 | 44 | $i = 0; 45 | while(read(FILE, $data, 1)) { 46 | if($i == 0) { 47 | print(OUTPUT "\t"); 48 | } 49 | printf(OUTPUT "%#02x, ", unpack("C", $data)); 50 | $i++; 51 | if($i == 10) { 52 | print(OUTPUT "\n"); 53 | $i = 0; 54 | } 55 | } 56 | print(OUTPUT "0};\n\n"); 57 | close(FILE); 58 | push(@fvars, $fvar); 59 | push(@pfiles, $file); 60 | } 61 | } 62 | 63 | for($i = 0; $i < @fvars; $i++) { 64 | $file = $pfiles[$i]; 65 | $fvar = $fvars[$i]; 66 | 67 | if($i == 0) { 68 | $prevfile = "NULL"; 69 | } else { 70 | $prevfile = "file" . $fvars[$i - 1]; 71 | } 72 | print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); 73 | print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); 74 | print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); 75 | } 76 | 77 | print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n"); 78 | print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n"); 79 | -------------------------------------------------------------------------------- /uip/apps/webserver/makestrings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | sub stringify { 5 | my $name = shift(@_); 6 | open(OUTPUTC, "> $name.c"); 7 | open(OUTPUTH, "> $name.h"); 8 | 9 | open(FILE, "$name"); 10 | 11 | while() { 12 | if(/(.+) "(.+)"/) { 13 | $var = $1; 14 | $data = $2; 15 | 16 | $datan = $data; 17 | $datan =~ s/\\r/\r/g; 18 | $datan =~ s/\\n/\n/g; 19 | $datan =~ s/\\01/\01/g; 20 | $datan =~ s/\\0/\0/g; 21 | 22 | printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1); 23 | printf(OUTPUTC "/* \"$data\" */\n"); 24 | printf(OUTPUTC "{"); 25 | for($j = 0; $j < length($datan); $j++) { 26 | printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1))); 27 | } 28 | printf(OUTPUTC "};\n"); 29 | 30 | printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1); 31 | 32 | } 33 | } 34 | close(OUTPUTC); 35 | close(OUTPUTH); 36 | } 37 | stringify("http-strings"); 38 | 39 | exit 0; 40 | 41 | -------------------------------------------------------------------------------- /uip/apps/webserver/webserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $ 33 | * 34 | */ 35 | #ifndef __WEBSERVER_H__ 36 | #define __WEBSERVER_H__ 37 | 38 | #include "httpd.h" 39 | 40 | typedef struct httpd_state uip_tcp_appstate_t; 41 | /* UIP_APPCALL: the name of the application function. This function 42 | must return void and take no arguments (i.e., C type "void 43 | appfunc(void)"). */ 44 | #ifndef UIP_APPCALL 45 | #define UIP_APPCALL httpd_appcall 46 | #endif 47 | 48 | 49 | #endif /* __WEBSERVER_H__ */ 50 | -------------------------------------------------------------------------------- /uip/doc/Makefile: -------------------------------------------------------------------------------- 1 | all: htmldoc pdfdoc 2 | 3 | htmldoc: 4 | doxygen Doxyfile 5 | 6 | pdfdoc: htmldoc 7 | cd latex; make refman.pdf && mv refman.pdf ../uip-refman.pdf 8 | -------------------------------------------------------------------------------- /uip/doc/README: -------------------------------------------------------------------------------- 1 | The files in this directory comprise the uIP documentation. The files 2 | are: 3 | 4 | html/ The uIP reference manual in HTML format. 5 | 6 | uip-refman.pdf The uIP reference manual in a printable PDF version. 7 | 8 | mobisys2003.pdf Conference paper about uIP from the First 9 | International Conference on Mobile Systems, 10 | Applications and Services (MobiSys), San 11 | Francisco, May 2003. 12 | 13 | -------------------------------------------------------------------------------- /uip/doc/doxygen.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{doxygen} 3 | \RequirePackage{calc} 4 | \RequirePackage{array} 5 | \pagestyle{fancyplain} 6 | \newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}} 7 | \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} 8 | \lhead[\fancyplain{}{\bfseries\thepage}] 9 | {\fancyplain{}{\bfseries\rightmark}} 10 | \rhead[\fancyplain{}{\bfseries\leftmark}] 11 | {\fancyplain{}{\bfseries\thepage}} 12 | \rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen\lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen}} 13 | \cfoot{} 14 | \newenvironment{CompactList} 15 | {\begin{list}{}{ 16 | \setlength{\leftmargin}{0.5cm} 17 | \setlength{\itemsep}{0pt} 18 | \setlength{\parsep}{0pt} 19 | \setlength{\topsep}{0pt} 20 | \renewcommand{\makelabel}{}}} 21 | {\end{list}} 22 | \newenvironment{CompactItemize} 23 | { 24 | \begin{itemize} 25 | \setlength{\itemsep}{-3pt} 26 | \setlength{\parsep}{0pt} 27 | \setlength{\topsep}{0pt} 28 | \setlength{\partopsep}{0pt} 29 | } 30 | {\end{itemize}} 31 | \newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp} 32 | \newlength{\tmplength} 33 | \newenvironment{TabularC}[1] 34 | { 35 | \setlength{\tmplength} 36 | {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)} 37 | \par\begin{tabular*}{\linewidth} 38 | {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|} 39 | } 40 | {\end{tabular*}\par} 41 | \newcommand{\entrylabel}[1]{ 42 | {\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\\}}} 43 | \newenvironment{Desc} 44 | {\begin{list}{} 45 | { 46 | \settowidth{\labelwidth}{40pt} 47 | \setlength{\leftmargin}{\labelwidth} 48 | \setlength{\parsep}{0pt} 49 | \setlength{\itemsep}{-4pt} 50 | \renewcommand{\makelabel}{\entrylabel} 51 | } 52 | } 53 | {\end{list}} 54 | \newenvironment{Indent} 55 | {\begin{list}{}{\setlength{\leftmargin}{0.5cm}} 56 | \item[]\ignorespaces} 57 | {\unskip\end{list}} 58 | \setlength{\parindent}{0cm} 59 | \setlength{\parskip}{0.2cm} 60 | \addtocounter{secnumdepth}{1} 61 | \sloppy 62 | \usepackage[T1]{fontenc} 63 | -------------------------------------------------------------------------------- /uip/doc/example-mainloop-with-arp.c: -------------------------------------------------------------------------------- 1 | #include "uip.h" 2 | #include "uip_arp.h" 3 | #include "network-device.h" 4 | #include "httpd.h" 5 | #include "timer.h" 6 | 7 | #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) 8 | 9 | /*---------------------------------------------------------------------------*/ 10 | int 11 | main(void) 12 | { 13 | int i; 14 | uip_ipaddr_t ipaddr; 15 | struct timer periodic_timer, arp_timer; 16 | 17 | timer_set(&periodic_timer, CLOCK_SECOND / 2); 18 | timer_set(&arp_timer, CLOCK_SECOND * 10); 19 | 20 | network_device_init(); 21 | uip_init(); 22 | 23 | uip_ipaddr(ipaddr, 192,168,0,2); 24 | uip_sethostaddr(ipaddr); 25 | 26 | httpd_init(); 27 | 28 | while(1) { 29 | uip_len = network_device_read(); 30 | if(uip_len > 0) { 31 | if(BUF->type == htons(UIP_ETHTYPE_IP)) { 32 | uip_arp_ipin(); 33 | uip_input(); 34 | /* If the above function invocation resulted in data that 35 | should be sent out on the network, the global variable 36 | uip_len is set to a value > 0. */ 37 | if(uip_len > 0) { 38 | uip_arp_out(); 39 | network_device_send(); 40 | } 41 | } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { 42 | uip_arp_arpin(); 43 | /* If the above function invocation resulted in data that 44 | should be sent out on the network, the global variable 45 | uip_len is set to a value > 0. */ 46 | if(uip_len > 0) { 47 | network_device_send(); 48 | } 49 | } 50 | 51 | } else if(timer_expired(&periodic_timer)) { 52 | timer_reset(&periodic_timer); 53 | for(i = 0; i < UIP_CONNS; i++) { 54 | uip_periodic(i); 55 | /* If the above function invocation resulted in data that 56 | should be sent out on the network, the global variable 57 | uip_len is set to a value > 0. */ 58 | if(uip_len > 0) { 59 | uip_arp_out(); 60 | network_device_send(); 61 | } 62 | } 63 | 64 | #if UIP_UDP 65 | for(i = 0; i < UIP_UDP_CONNS; i++) { 66 | uip_udp_periodic(i); 67 | /* If the above function invocation resulted in data that 68 | should be sent out on the network, the global variable 69 | uip_len is set to a value > 0. */ 70 | if(uip_len > 0) { 71 | uip_arp_out(); 72 | network_device_send(); 73 | } 74 | } 75 | #endif /* UIP_UDP */ 76 | 77 | /* Call the ARP timer function every 10 seconds. */ 78 | if(timer_expired(&arp_timer)) { 79 | timer_reset(&arp_timer); 80 | uip_arp_timer(); 81 | } 82 | } 83 | } 84 | return 0; 85 | } 86 | /*---------------------------------------------------------------------------*/ 87 | -------------------------------------------------------------------------------- /uip/doc/example-mainloop-without-arp.c: -------------------------------------------------------------------------------- 1 | #include "uip.h" 2 | #include "uip_arp.h" 3 | #include "network-device.h" 4 | #include "httpd.h" 5 | #include "timer.h" 6 | 7 | /*---------------------------------------------------------------------------*/ 8 | int 9 | main(void) 10 | { 11 | int i; 12 | uip_ipaddr_t ipaddr; 13 | struct timer periodic_timer; 14 | 15 | timer_set(&periodic_timer, CLOCK_SECOND / 2); 16 | 17 | network_device_init(); 18 | uip_init(); 19 | 20 | uip_ipaddr(ipaddr, 192,168,0,2); 21 | uip_sethostaddr(ipaddr); 22 | 23 | httpd_init(); 24 | 25 | while(1) { 26 | uip_len = network_device_read(); 27 | if(uip_len > 0) { 28 | uip_input(); 29 | /* If the above function invocation resulted in data that 30 | should be sent out on the network, the global variable 31 | uip_len is set to a value > 0. */ 32 | if(uip_len > 0) { 33 | network_device_send(); 34 | } 35 | } else if(timer_expired(&periodic_timer)) { 36 | timer_reset(&periodic_timer); 37 | for(i = 0; i < UIP_CONNS; i++) { 38 | uip_periodic(i); 39 | /* If the above function invocation resulted in data that 40 | should be sent out on the network, the global variable 41 | uip_len is set to a value > 0. */ 42 | if(uip_len > 0) { 43 | network_device_send(); 44 | } 45 | } 46 | 47 | #if UIP_UDP 48 | for(i = 0; i < UIP_UDP_CONNS; i++) { 49 | uip_udp_periodic(i); 50 | /* If the above function invocation resulted in data that 51 | should be sent out on the network, the global variable 52 | uip_len is set to a value > 0. */ 53 | if(uip_len > 0) { 54 | network_device_send(); 55 | } 56 | } 57 | #endif /* UIP_UDP */ 58 | } 59 | } 60 | return 0; 61 | } 62 | /*---------------------------------------------------------------------------*/ 63 | -------------------------------------------------------------------------------- /uip/doc/examples.txt: -------------------------------------------------------------------------------- 1 | /** 2 | \defgroup apps Applications 3 | @{ 4 | 5 | The uIP distribution contains a number of example applications that 6 | can be either used directory or studied when learning to develop 7 | applications for uIP. 8 | 9 | */ 10 | 11 | /** \example hello-world.c */ 12 | /** \example hello-world.h */ 13 | 14 | /** \example smtp.c */ 15 | /** \example smtp.h */ 16 | 17 | /** \example webclient.c */ 18 | /** \example webclient.h */ 19 | 20 | /** \example example-mainloop-with-arp.c */ 21 | /** \example example-mainloop-without-arp.c */ 22 | 23 | /** \example telnetd.c */ 24 | /** \example telnetd.h */ 25 | 26 | /** \example resolv.c */ 27 | /** \example resolv.h */ 28 | 29 | /** \example dhcpc.c */ 30 | /** \example dhcpc.h */ 31 | 32 | /** \example uip-conf.h */ 33 | 34 | /** @} */ 35 | -------------------------------------------------------------------------------- /uip/doc/header.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{book} 2 | \usepackage{a4wide} 3 | \usepackage{makeidx} 4 | \usepackage{fancyhdr} 5 | \usepackage{graphicx} 6 | \usepackage{multicol} 7 | \usepackage{float} 8 | \usepackage{textcomp} 9 | \usepackage{alltt} 10 | \usepackage{times} 11 | \ifx\pdfoutput\undefined 12 | \usepackage[ps2pdf, 13 | pagebackref=true, 14 | colorlinks=true, 15 | linkcolor=blue 16 | ]{hyperref} 17 | \usepackage{pspicture} 18 | \else 19 | \usepackage[pdftex, 20 | pagebackref=true, 21 | colorlinks=true, 22 | linkcolor=blue 23 | ]{hyperref} 24 | \fi 25 | \usepackage{doxygen} 26 | \makeindex 27 | \setcounter{tocdepth}{1} 28 | \renewcommand{\footrulewidth}{0.4pt} 29 | \begin{document} 30 | \begin{titlepage} 31 | \vspace*{5cm} 32 | \begin{center} 33 | {\Huge The uIP Embedded TCP/IP Stack}\\ 34 | \vspace*{1cm} 35 | {\LARGE The uIP 1.0 Reference Manual}\\ 36 | \vspace*{3cm} 37 | {\Large June 2006}\\ 38 | \vspace*{2cm} 39 | \includegraphics[width=6cm]{../sicslogo.pdf}\\ 40 | \vspace*{1cm} 41 | {\Large Adam Dunkels}\\ 42 | {\Large \texttt{adam@sics.se}}\\ 43 | \vspace*{1cm} 44 | {\LARGE Swedish Institute of Computer Science}\\ 45 | \vspace*{0.5cm} 46 | 47 | \end{center} 48 | \end{titlepage} 49 | \clearemptydoublepage 50 | \pagenumbering{roman} 51 | \tableofcontents 52 | \clearemptydoublepage 53 | \pagenumbering{arabic} 54 | -------------------------------------------------------------------------------- /uip/doc/html/a00079.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: httpd_cgi_call Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

httpd_cgi_call Struct Reference
24 | 25 | [Web server] 26 |


Detailed Description

27 | 28 |

29 | 30 |

31 | Definition at line 60 of file httpd-cgi.h.

LocalRemoteStateRetransmissionsTimerFlags
32 | 33 | 34 | 36 | 37 | 39 | 40 |

Data Fields

35 | const char * name
38 | const httpd_cgifunction function
41 |
Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /uip/doc/html/a00083.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: psock_buf Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

psock_buf Struct Reference
24 | 25 | [Protosockets library] 26 |


Detailed Description

27 | 28 |

29 | 30 |

31 | Definition at line 95 of file psock.h. 32 | 33 | 34 | 36 | 37 | 39 | 40 |

Data Fields

35 | u8_tptr
38 | unsigned short left
41 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /uip/doc/html/a00084.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: pt Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

pt Struct Reference
24 | 25 | [Protothreads] 26 |


Detailed Description

27 |
Examples:
28 | 29 |

30 | dhcpc.h.

31 |

32 | 33 |

34 | Definition at line 54 of file pt.h. 35 | 36 | 37 | 39 | 40 |

Data Fields

38 | lc_t lc
41 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  42 | 43 | doxygen 1.4.6
44 | 45 | 46 | -------------------------------------------------------------------------------- /uip/doc/html/a00087.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: timer Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

timer Struct Reference
24 | 25 | [Timer library] 26 |

#include <timer.h> 27 |

28 |


Detailed Description

29 | A timer. 30 |

31 | This structure is used for declaring a timer. The timer must be set with timer_set() before it can be used.

Examples:
32 | 33 |

34 | dhcpc.h, example-mainloop-with-arp.c, example-mainloop-without-arp.c, and webclient.h.

35 |

36 | 37 |

38 | Definition at line 74 of file timer.h. 39 | 40 | 41 | 43 | 44 | 46 | 47 |

Data Fields

42 | clock_time_t start
45 | clock_time_t interval
48 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  49 | 50 | doxygen 1.4.6
51 | 52 | 53 | -------------------------------------------------------------------------------- /uip/doc/html/a00089.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip_eth_addr Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uip_eth_addr Struct Reference
24 | 25 | [The uIP TCP/IP stack] 26 |

#include <uip.h> 27 |

28 |


Detailed Description

29 | Representation of a 48-bit Ethernet address. 30 |

31 | 32 |

33 | Definition at line 1542 of file uip.h. 34 | 35 | 36 | 38 | 39 |

Data Fields

37 | u8_t addr [6]
40 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  41 | 42 | doxygen 1.4.6
43 | 44 | 45 | -------------------------------------------------------------------------------- /uip/doc/html/a00092.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip_neighbor_addr Struct Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uip_neighbor_addr Struct Reference


Detailed Description

24 | 25 |

26 | 27 |

28 | Definition at line 47 of file uip-neighbor.h. 29 | 30 | 31 | 33 | 34 |

Data Fields

32 | uip_eth_addr addr
35 |


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  36 | 37 | doxygen 1.4.6
38 | 39 | 40 | -------------------------------------------------------------------------------- /uip/doc/html/a00100.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/hello-world/hello-world.c File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/hello-world/hello-world.c File Reference


Detailed Description

22 | An example of how to write uIP applications with protosockets. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file hello-world.c. 28 |

29 | #include "hello-world.h"
30 | #include "uip.h"
31 | #include <string.h>
32 | 33 |

34 | Go to the source code of this file. 35 | 36 | 37 | 39 | 40 | 42 | 43 |

Functions

38 | void hello_world_init (void)
41 | void hello_world_appcall (void)
44 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  45 | 46 | doxygen 1.4.6
47 | 48 | 49 | -------------------------------------------------------------------------------- /uip/doc/html/a00112.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/webserver/httpd-cgi.c File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/webserver/httpd-cgi.c File Reference


Detailed Description

22 | Web server script interface. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file httpd-cgi.c. 28 |

29 | #include "uip.h"
30 | #include "psock.h"
31 | #include "httpd.h"
32 | #include "httpd-cgi.h"
33 | #include "httpd-fs.h"
34 | #include <stdio.h>
35 | #include <string.h>
36 | 37 |

38 | Go to the source code of this file. 39 | 40 | 41 | 43 | 44 |

Functions

42 | httpd_cgifunction httpd_cgi (char *name)
45 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  46 | 47 | doxygen 1.4.6
48 | 49 | 50 | -------------------------------------------------------------------------------- /uip/doc/html/a00113.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: apps/webserver/httpd-cgi.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

apps/webserver/httpd-cgi.h File Reference


Detailed Description

22 | Web server script interface header file. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file httpd-cgi.h. 28 |

29 | #include "psock.h"
30 | #include "httpd.h"
31 | 32 |

33 | Go to the source code of this file. 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 46 |

Data Structures

struct  httpd_cgi_call

Defines

#define HTTPD_CGI_CALL(name, str, function)
 HTTPD CGI function declaration.

Functions

44 | httpd_cgifunction httpd_cgi (char *name)
47 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  48 | 49 | doxygen 1.4.6
50 | 51 | 52 | -------------------------------------------------------------------------------- /uip/doc/html/a00125.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip/lc.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

uip/lc.h File Reference


Detailed Description

22 | Local continuations. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file lc.h. 28 |

29 | #include "lc-switch.h"
30 | 31 |

32 | Go to the source code of this file. 33 | 34 |
35 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  36 | 37 | doxygen 1.4.6
38 | 39 | 40 | -------------------------------------------------------------------------------- /uip/doc/html/a00134.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: uip/uip-split.h File Reference 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |

uip/uip-split.h File Reference


Detailed Description

22 | Module for splitting outbound TCP segments in two to avoid the delayed ACK throughput degradation. 23 |

24 |

Author:
Adam Dunkels <adam@sics.se>
25 | 26 |

27 | Definition in file uip-split.h. 28 |

29 | 30 |

31 | Go to the source code of this file. 32 | 33 | 34 | 35 | 36 | 37 |

Functions

void uip_split_output (void)
 Handle outgoing packets.
38 |


Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  39 | 40 | doxygen 1.4.6
41 | 42 | 43 | -------------------------------------------------------------------------------- /uip/doc/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/doxygen.png -------------------------------------------------------------------------------- /uip/doc/html/examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Examples 4 | 5 | 6 | 7 | 8 |
9 |
16 |

uIP 1.0 Examples

Here is a list of all examples: 34 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  35 | 36 | doxygen 1.4.6
37 | 38 | 39 | -------------------------------------------------------------------------------- /uip/doc/html/ftv2blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2blank.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2doc.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2folderclosed.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2folderopen.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2lastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2lastnode.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2link.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2mlastnode.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2mnode.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2node.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2plastnode.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2pnode.png -------------------------------------------------------------------------------- /uip/doc/html/ftv2vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/ftv2vertline.png -------------------------------------------------------------------------------- /uip/doc/html/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- _ -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_0x65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- e -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 | Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation: 54 |

55 |

- f -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_defs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- _ -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_defs_0x65.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- e -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_defs_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- f -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_defs_0x72.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |
31 |
    32 |
  • _
  • 33 |
  • a
  • 34 |
  • b
  • 35 |
  • d
  • 36 |
  • e
  • 37 |
  • f
  • 38 |
  • h
  • 39 |
  • i
  • 40 |
  • l
  • 41 |
  • m
  • 42 |
  • n
  • 43 |
  • p
  • 44 |
  • r
  • 45 |
  • s
  • 46 |
  • t
  • 47 |
  • u
  • 48 |
  • w
  • 49 |
50 |
51 | 52 |

53 |   54 |

55 |

- r -

58 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  59 | 60 | doxygen 1.4.6
61 | 62 | 63 | -------------------------------------------------------------------------------- /uip/doc/html/globals_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Data Fields 4 | 5 | 6 | 7 | 8 |
9 |
16 |
17 |
21 |
22 | 29 |
30 |   31 |

32 |

43 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  44 | 45 | doxygen 1.4.6
46 | 47 | 48 | -------------------------------------------------------------------------------- /uip/doc/html/hierarchy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Hierarchical Index 4 | 5 | 6 | 7 | 8 |
9 |
16 | 23 |

uIP 1.0 Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically: 46 |
Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by  47 | 48 | doxygen 1.4.6
49 | 50 | 51 | -------------------------------------------------------------------------------- /uip/doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /uip/doc/html/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | uIP 1.0: Module Index 4 | 5 | 6 | 7 | 8 |
9 |
16 |

uIP 1.0 Modules

Here is a list of all modules: 47 |
Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  48 | 49 | doxygen 1.4.6
50 | 51 | 52 | -------------------------------------------------------------------------------- /uip/doc/html/tab_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/tab_b.gif -------------------------------------------------------------------------------- /uip/doc/html/tab_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/tab_l.gif -------------------------------------------------------------------------------- /uip/doc/html/tab_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/html/tab_r.gif -------------------------------------------------------------------------------- /uip/doc/html/tabs.css: -------------------------------------------------------------------------------- 1 | /* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ 2 | 3 | DIV.tabs 4 | { 5 | float : left; 6 | width : 100%; 7 | background : url("tab_b.gif") repeat-x bottom; 8 | margin-bottom : 4px; 9 | } 10 | 11 | DIV.tabs UL 12 | { 13 | margin : 0px; 14 | padding-left : 10px; 15 | list-style : none; 16 | } 17 | 18 | DIV.tabs LI, DIV.tabs FORM 19 | { 20 | display : inline; 21 | margin : 0px; 22 | padding : 0px; 23 | } 24 | 25 | DIV.tabs FORM 26 | { 27 | float : right; 28 | } 29 | 30 | DIV.tabs A 31 | { 32 | float : left; 33 | background : url("tab_r.gif") no-repeat right top; 34 | border-bottom : 1px solid #84B0C7; 35 | font-size : x-small; 36 | font-weight : bold; 37 | text-decoration : none; 38 | } 39 | 40 | DIV.tabs A:hover 41 | { 42 | background-position: 100% -150px; 43 | } 44 | 45 | DIV.tabs A:link, DIV.tabs A:visited, 46 | DIV.tabs A:active, DIV.tabs A:hover 47 | { 48 | color: #1A419D; 49 | } 50 | 51 | DIV.tabs SPAN 52 | { 53 | float : left; 54 | display : block; 55 | background : url("tab_l.gif") no-repeat left top; 56 | padding : 5px 9px; 57 | white-space : nowrap; 58 | } 59 | 60 | DIV.tabs INPUT 61 | { 62 | float : right; 63 | display : inline; 64 | font-size : 1em; 65 | } 66 | 67 | DIV.tabs TD 68 | { 69 | font-size : x-small; 70 | font-weight : bold; 71 | text-decoration : none; 72 | } 73 | 74 | 75 | 76 | /* Commented Backslash Hack hides rule from IE5-Mac \*/ 77 | DIV.tabs SPAN {float : none;} 78 | /* End IE5-Mac hack */ 79 | 80 | DIV.tabs A:hover SPAN 81 | { 82 | background-position: 0% -150px; 83 | } 84 | 85 | DIV.tabs LI#current A 86 | { 87 | background-position: 100% -150px; 88 | border-width : 0px; 89 | } 90 | 91 | DIV.tabs LI#current SPAN 92 | { 93 | background-position: 0% -150px; 94 | padding-bottom : 6px; 95 | } 96 | 97 | DIV.nav 98 | { 99 | background : none; 100 | border : none; 101 | border-bottom : 1px solid #84B0C7; 102 | } 103 | -------------------------------------------------------------------------------- /uip/doc/mobisys2003.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/mobisys2003.pdf -------------------------------------------------------------------------------- /uip/doc/sicslogo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/sicslogo.pdf -------------------------------------------------------------------------------- /uip/doc/uip-code-style.txt: -------------------------------------------------------------------------------- 1 | /** 2 | \example uip-code-style.c 3 | */ 4 | -------------------------------------------------------------------------------- /uip/doc/uip-refman.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/NanodeUIP/a53770f89695dadc556c8289953a6f31f94dcd5e/uip/doc/uip-refman.pdf -------------------------------------------------------------------------------- /uip/uip-neighbor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: uip-neighbor.h,v 1.2 2006/06/12 08:00:30 adam Exp $ 32 | */ 33 | 34 | /** 35 | * \file 36 | * Header file for database of link-local neighbors, used by 37 | * IPv6 code and to be used by future ARP code. 38 | * \author 39 | * Adam Dunkels 40 | */ 41 | 42 | #ifndef __UIP_NEIGHBOR_H__ 43 | #define __UIP_NEIGHBOR_H__ 44 | 45 | #include "uip.h" 46 | 47 | struct uip_neighbor_addr { 48 | #if UIP_NEIGHBOR_CONF_ADDRTYPE 49 | UIP_NEIGHBOR_CONF_ADDRTYPE addr; 50 | #else 51 | struct uip_eth_addr addr; 52 | #endif 53 | }; 54 | 55 | void uip_neighbor_init(void); 56 | void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr); 57 | void uip_neighbor_update(uip_ipaddr_t ipaddr); 58 | struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr); 59 | void uip_neighbor_periodic(void); 60 | 61 | #endif /* __UIP-NEIGHBOR_H__ */ 62 | -------------------------------------------------------------------------------- /uip/uiplib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of 3 | * Computer Science. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: uiplib.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 33 | * 34 | */ 35 | 36 | 37 | #include "uip.h" 38 | #include "uiplib.h" 39 | 40 | 41 | /*-----------------------------------------------------------------------------------*/ 42 | unsigned char 43 | uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr) 44 | { 45 | unsigned char tmp; 46 | char c; 47 | unsigned char i, j; 48 | 49 | tmp = 0; 50 | 51 | for(i = 0; i < 4; ++i) { 52 | j = 0; 53 | do { 54 | c = *addrstr; 55 | ++j; 56 | if(j > 4) { 57 | return 0; 58 | } 59 | if(c == '.' || c == 0) { 60 | *ipaddr = tmp; 61 | ++ipaddr; 62 | tmp = 0; 63 | } else if(c >= '0' && c <= '9') { 64 | tmp = (tmp * 10) + (c - '0'); 65 | } else { 66 | return 0; 67 | } 68 | ++addrstr; 69 | } while(c != '.' && c != 0); 70 | } 71 | return 1; 72 | } 73 | 74 | /*-----------------------------------------------------------------------------------*/ 75 | -------------------------------------------------------------------------------- /uip/uiplib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * Various uIP library functions. 4 | * \author 5 | * Adam Dunkels 6 | * 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2002, Adam Dunkels. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above 19 | * copyright notice, this list of conditions and the following 20 | * disclaimer in the documentation and/or other materials provided 21 | * with the distribution. 22 | * 3. The name of the author may not be used to endorse or promote 23 | * products derived from this software without specific prior 24 | * written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 27 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 30 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * This file is part of the uIP TCP/IP stack 39 | * 40 | * $Id: uiplib.h,v 1.1 2006/06/07 09:15:19 adam Exp $ 41 | * 42 | */ 43 | #ifndef __UIPLIB_H__ 44 | #define __UIPLIB_H__ 45 | 46 | /** 47 | * \addtogroup uipconvfunc 48 | * @{ 49 | */ 50 | 51 | /** 52 | * Convert a textual representation of an IP address to a numerical representation. 53 | * 54 | * This function takes a textual representation of an IP address in 55 | * the form a.b.c.d and converts it into a 4-byte array that can be 56 | * used by other uIP functions. 57 | * 58 | * \param addrstr A pointer to a string containing the IP address in 59 | * textual form. 60 | * 61 | * \param addr A pointer to a 4-byte array that will be filled in with 62 | * the numerical representation of the address. 63 | * 64 | * \retval 0 If the IP address could not be parsed. 65 | * \retval Non-zero If the IP address was parsed. 66 | */ 67 | unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr); 68 | 69 | /** @} */ 70 | 71 | #endif /* __UIPLIB_H__ */ 72 | -------------------------------------------------------------------------------- /uip/unix/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2001, Adam Dunkels. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # 1. Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # 2. Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # 3. The name of the author may not be used to endorse or promote 13 | # products derived from this software without specific prior 14 | # written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 17 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 20 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 | # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # This file is part of the uIP TCP/IP stack. 29 | # 30 | # $Id: Makefile,v 1.13 2006/06/11 21:55:03 adam Exp $ 31 | # 32 | 33 | all: uip 34 | 35 | CC = gcc 36 | AR = ar 37 | APPS = webserver 38 | CFLAGS = -Wall -g -I../uip -I. -fpack-struct -Os 39 | -include ../uip/Makefile.include 40 | 41 | uip: $(addprefix $(OBJECTDIR)/, main.o tapdev.o clock-arch.o) apps.a uip.a 42 | 43 | clean: 44 | rm -fr *.o *~ *core uip $(OBJECTDIR) *.a 45 | -------------------------------------------------------------------------------- /uip/unix/clock-arch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | /** 35 | * \file 36 | * Implementation of architecture-specific clock functionality 37 | * \author 38 | * Adam Dunkels 39 | */ 40 | 41 | #include "clock-arch.h" 42 | #include 43 | 44 | /*---------------------------------------------------------------------------*/ 45 | clock_time_t 46 | clock_time(void) 47 | { 48 | struct timeval tv; 49 | struct timezone tz; 50 | 51 | gettimeofday(&tv, &tz); 52 | 53 | return tv.tv_sec * 1000 + tv.tv_usec / 1000; 54 | } 55 | /*---------------------------------------------------------------------------*/ 56 | -------------------------------------------------------------------------------- /uip/unix/clock-arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the uIP TCP/IP stack 30 | * 31 | * $Id: clock-arch.h,v 1.2 2006/06/12 08:00:31 adam Exp $ 32 | */ 33 | 34 | #ifndef __CLOCK_ARCH_H__ 35 | #define __CLOCK_ARCH_H__ 36 | 37 | typedef int clock_time_t; 38 | #define CLOCK_CONF_SECOND 1000 39 | 40 | #endif /* __CLOCK_ARCH_H__ */ 41 | -------------------------------------------------------------------------------- /uip/unix/tapdev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Adam Dunkels. 16 | * 4. The name of the author may not be used to endorse or promote 17 | * products derived from this software without specific prior 18 | * written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 21 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * This file is part of the uIP TCP/IP stack. 33 | * 34 | * $Id: tapdev.h,v 1.1 2002/01/10 06:22:56 adam Exp $ 35 | * 36 | */ 37 | 38 | #ifndef __TAPDEV_H__ 39 | #define __TAPDEV_H__ 40 | 41 | void tapdev_init(void); 42 | unsigned int tapdev_read(void); 43 | void tapdev_send(void); 44 | 45 | #endif /* __TAPDEV_H__ */ 46 | -------------------------------------------------------------------------------- /uiplib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of 3 | * Computer Science. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the uIP TCP/IP stack 31 | * 32 | * $Id: uiplib.c,v 1.2 2006/06/12 08:00:31 adam Exp $ 33 | * 34 | */ 35 | 36 | 37 | #include "uip.h" 38 | #include "uiplib.h" 39 | 40 | 41 | /*-----------------------------------------------------------------------------------*/ 42 | unsigned char 43 | uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr) 44 | { 45 | unsigned char tmp; 46 | char c; 47 | unsigned char i, j; 48 | 49 | tmp = 0; 50 | 51 | for(i = 0; i < 4; ++i) { 52 | j = 0; 53 | do { 54 | c = *addrstr; 55 | ++j; 56 | if(j > 4) { 57 | return 0; 58 | } 59 | if(c == '.' || c == 0) { 60 | *ipaddr = tmp; 61 | ++ipaddr; 62 | tmp = 0; 63 | } else if(c >= '0' && c <= '9') { 64 | tmp = (tmp * 10) + (c - '0'); 65 | } else { 66 | return 0; 67 | } 68 | ++addrstr; 69 | } while(c != '.' && c != 0); 70 | } 71 | return 1; 72 | } 73 | 74 | /*-----------------------------------------------------------------------------------*/ 75 | -------------------------------------------------------------------------------- /uiplib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * Various uIP library functions. 4 | * \author 5 | * Adam Dunkels 6 | * 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2002, Adam Dunkels. 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above 19 | * copyright notice, this list of conditions and the following 20 | * disclaimer in the documentation and/or other materials provided 21 | * with the distribution. 22 | * 3. The name of the author may not be used to endorse or promote 23 | * products derived from this software without specific prior 24 | * written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 27 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 30 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * This file is part of the uIP TCP/IP stack 39 | * 40 | * $Id: uiplib.h,v 1.1 2006/06/07 09:15:19 adam Exp $ 41 | * 42 | */ 43 | #ifndef __UIPLIB_H__ 44 | #define __UIPLIB_H__ 45 | 46 | /** 47 | * \addtogroup uipconvfunc 48 | * @{ 49 | */ 50 | 51 | /** 52 | * Convert a textual representation of an IP address to a numerical representation. 53 | * 54 | * This function takes a textual representation of an IP address in 55 | * the form a.b.c.d and converts it into a 4-byte array that can be 56 | * used by other uIP functions. 57 | * 58 | * \param addrstr A pointer to a string containing the IP address in 59 | * textual form. 60 | * 61 | * \param addr A pointer to a 4-byte array that will be filled in with 62 | * the numerical representation of the address. 63 | * 64 | * \retval 0 If the IP address could not be parsed. 65 | * \retval Non-zero If the IP address was parsed. 66 | */ 67 | unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr); 68 | 69 | /** @} */ 70 | 71 | #endif /* __UIPLIB_H__ */ 72 | -------------------------------------------------------------------------------- /webclient-strings: -------------------------------------------------------------------------------- 1 | 2 | http_10 "HTTP/1.0" 3 | http_11 "HTTP/1.1" 4 | http_200 "200 " 5 | http_301 "301 " 6 | http_302 "302 " 7 | http_404_html "/404.html" 8 | http_content_length "Content-Length: " 9 | http_content_type_binary "Content-type: application/octet-stream\r\n\r\n" 10 | http_content_type "content-type: " 11 | http_content_type_css "Content-type: text/css\r\n\r\n" 12 | http_content_type_gif "Content-type: image/gif\r\n\r\n" 13 | http_content_type_html "Content-type: text/html\r\n\r\n" 14 | http_content_type_jpg "Content-type: image/jpeg\r\n\r\n" 15 | http_content_type_plain "Content-type: text/plain\r\n\r\n" 16 | http_content_type_png "Content-type: image/png\r\n\r\n" 17 | http_content_type_text "Content-type: text/text\r\n\r\n" 18 | http_crnl "\r\n" 19 | http_css ".css" 20 | http_get "GET " 21 | http_gif ".gif" 22 | http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0\r\nConnection: close\r\n" 23 | http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0\r\nConnection: close\r\n" 24 | http_host "host: " 25 | http_htm ".htm" 26 | http_html ".html" 27 | http_http "http://" 28 | http_icy "ICY" 29 | http_index_html "/index.html" 30 | http_index_shtml "/index.shtml" 31 | http_jpg ".jpg" 32 | http_location "location: " 33 | http_png ".png" 34 | http_post "POST " 35 | http_put "PUT " 36 | http_referer "Referer:" 37 | http_shtml ".shtml" 38 | http_texthtml "text/html" 39 | http_text ".text" 40 | http_txt ".txt" 41 | http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0\r\n\r\n" 42 | -------------------------------------------------------------------------------- /webclient-strings.h: -------------------------------------------------------------------------------- 1 | #include 2 | extern const char http_10[9]; 3 | extern const char http_11[9]; 4 | extern const char http_200[5]; 5 | extern const char http_301[5]; 6 | extern const char http_302[5]; 7 | extern const char http_404_html[10]; 8 | extern const char http_content_length [17]; 9 | extern const char http_content_type_binary[43]; 10 | extern const char http_content_type[15]; 11 | extern const char http_content_type_css [27]; 12 | extern const char http_content_type_gif [28]; 13 | extern const char http_content_type_html[28]; 14 | extern const char http_content_type_jpg [29]; 15 | extern const char http_content_type_plain[29]; 16 | extern const char http_content_type_png [28]; 17 | extern const char http_content_type_text[28]; 18 | extern const char http_crnl[3]; 19 | extern const char http_css[5]; 20 | extern const char http_get[5]; 21 | extern const char http_gif[5]; 22 | extern const char http_header_200[54]; 23 | extern const char http_header_404[61]; 24 | extern const char http_host[7]; 25 | extern const char http_htm[5]; 26 | extern const char http_html[6]; 27 | extern const char http_http[8]; 28 | extern const char http_icy[4]; 29 | extern const char http_index_html[12]; 30 | extern const char http_index_shtml[13]; 31 | extern const char http_jpg[5]; 32 | extern const char http_location[11]; 33 | extern const char http_png[5]; 34 | extern const char http_post[6]; 35 | extern const char http_put[5]; 36 | extern const char http_referer[9]; 37 | extern const char http_shtml[7]; 38 | extern const char http_texthtml[10]; 39 | extern const char http_text[6]; 40 | extern const char http_txt[5]; 41 | extern const char http_user_agent_fields[43]; 42 | --------------------------------------------------------------------------------