├── .gitignore ├── README.md ├── attribution.md ├── dhcp-server ├── dhserver.c └── dhserver.h ├── dns-server ├── dnserver.c └── dnserver.h ├── ecmhelper.h ├── fsdata.c ├── lwip-1.4.1 ├── CHANGELOG ├── COPYING ├── FILES ├── README ├── UPGRADING ├── apps │ ├── chargen │ │ ├── README │ │ ├── chargen.c │ │ └── chargen.h │ ├── httpserver │ │ ├── README │ │ ├── httpserver-netconn.c │ │ └── httpserver-netconn.h │ ├── httpserver_raw │ │ ├── fs.c │ │ ├── fs.h │ │ ├── fs │ │ │ ├── 404.html │ │ │ ├── img │ │ │ │ └── sics.gif │ │ │ └── index.html │ │ ├── fsdata.h │ │ ├── httpd.c │ │ ├── httpd.h │ │ ├── httpd_structs.h │ │ └── makefsdata │ │ │ ├── makefsdata │ │ │ ├── makefsdata.c │ │ │ └── readme.txt │ ├── netbios │ │ ├── netbios.c │ │ └── netbios.h │ ├── netio │ │ ├── netio.c │ │ └── netio.h │ ├── ping │ │ ├── ping.c │ │ └── ping.h │ ├── rtp │ │ ├── rtp.c │ │ ├── rtp.h │ │ └── rtpdata.h │ ├── shell │ │ ├── shell.c │ │ └── shell.h │ ├── smtp │ │ ├── smtp.c │ │ └── smtp.h │ ├── snmp_private_mib │ │ ├── lwip_prvmib.c │ │ └── private_mib.h │ ├── sntp │ │ ├── sntp.c │ │ └── sntp.h │ ├── socket_examples │ │ ├── socket_examples.c │ │ └── socket_examples.h │ ├── tcpecho │ │ ├── tcpecho.c │ │ └── tcpecho.h │ ├── tcpecho_raw │ │ ├── echo.c │ │ └── echo.h │ └── udpecho │ │ ├── udpecho.c │ │ └── udpecho.h ├── doc │ ├── FILES │ ├── contrib.txt │ ├── rawapi.txt │ ├── savannah.txt │ ├── snmp_agent.txt │ └── sys_arch.txt ├── src │ ├── FILES │ ├── api │ │ ├── api_lib.c │ │ ├── api_msg.c │ │ ├── err.c │ │ ├── netbuf.c │ │ ├── netdb.c │ │ ├── netifapi.c │ │ ├── sockets.c │ │ └── tcpip.c │ ├── core │ │ ├── def.c │ │ ├── dhcp.c │ │ ├── dns.c │ │ ├── init.c │ │ ├── ipv4 │ │ │ ├── autoip.c │ │ │ ├── icmp.c │ │ │ ├── igmp.c │ │ │ ├── inet.c │ │ │ ├── inet_chksum.c │ │ │ ├── ip.c │ │ │ ├── ip_addr.c │ │ │ └── ip_frag.c │ │ ├── ipv6 │ │ │ ├── README │ │ │ ├── icmp6.c │ │ │ ├── inet6.c │ │ │ ├── ip6.c │ │ │ └── ip6_addr.c │ │ ├── mem.c │ │ ├── memp.c │ │ ├── netif.c │ │ ├── pbuf.c │ │ ├── raw.c │ │ ├── snmp │ │ │ ├── asn1_dec.c │ │ │ ├── asn1_enc.c │ │ │ ├── mib2.c │ │ │ ├── mib_structs.c │ │ │ ├── msg_in.c │ │ │ └── msg_out.c │ │ ├── stats.c │ │ ├── sys.c │ │ ├── tcp.c │ │ ├── tcp_in.c │ │ ├── tcp_out.c │ │ ├── timers.c │ │ └── udp.c │ ├── include │ │ ├── arch │ │ │ ├── cc.h │ │ │ ├── cpu.h │ │ │ └── perf.h │ │ ├── ipv4 │ │ │ └── lwip │ │ │ │ ├── autoip.h │ │ │ │ ├── icmp.h │ │ │ │ ├── igmp.h │ │ │ │ ├── inet.h │ │ │ │ ├── inet_chksum.h │ │ │ │ ├── ip.h │ │ │ │ ├── ip_addr.h │ │ │ │ └── ip_frag.h │ │ ├── ipv6 │ │ │ └── lwip │ │ │ │ ├── icmp.h │ │ │ │ ├── inet.h │ │ │ │ ├── ip.h │ │ │ │ └── ip_addr.h │ │ ├── lwip │ │ │ ├── api.h │ │ │ ├── api_msg.h │ │ │ ├── arch.h │ │ │ ├── debug.h │ │ │ ├── def.h │ │ │ ├── dhcp.h │ │ │ ├── dns.h │ │ │ ├── err.h │ │ │ ├── init.h │ │ │ ├── mem.h │ │ │ ├── memp.h │ │ │ ├── memp_std.h │ │ │ ├── netbuf.h │ │ │ ├── netdb.h │ │ │ ├── netif.h │ │ │ ├── netifapi.h │ │ │ ├── opt.h │ │ │ ├── pbuf.h │ │ │ ├── raw.h │ │ │ ├── sio.h │ │ │ ├── snmp.h │ │ │ ├── snmp_asn1.h │ │ │ ├── snmp_msg.h │ │ │ ├── snmp_structs.h │ │ │ ├── sockets.h │ │ │ ├── stats.h │ │ │ ├── sys.h │ │ │ ├── tcp.h │ │ │ ├── tcp_impl.h │ │ │ ├── tcpip.h │ │ │ ├── timers.h │ │ │ └── udp.h │ │ ├── lwipopts.h │ │ ├── lwippools.h │ │ ├── netif │ │ │ ├── etharp.h │ │ │ ├── ppp_oe.h │ │ │ └── slipif.h │ │ └── posix │ │ │ ├── netdb.h │ │ │ └── sys │ │ │ └── socket.h │ └── netif │ │ ├── FILES │ │ ├── etharp.c │ │ ├── ethernetif.c │ │ ├── ppp │ │ ├── auth.c │ │ ├── auth.h │ │ ├── chap.c │ │ ├── chap.h │ │ ├── chpms.c │ │ ├── chpms.h │ │ ├── fsm.c │ │ ├── fsm.h │ │ ├── ipcp.c │ │ ├── ipcp.h │ │ ├── lcp.c │ │ ├── lcp.h │ │ ├── magic.c │ │ ├── magic.h │ │ ├── md5.c │ │ ├── md5.h │ │ ├── pap.c │ │ ├── pap.h │ │ ├── ppp.c │ │ ├── ppp.h │ │ ├── ppp_impl.h │ │ ├── ppp_oe.c │ │ ├── pppdebug.h │ │ ├── randm.c │ │ ├── randm.h │ │ ├── vj.c │ │ └── vj.h │ │ └── slipif.c └── test │ └── unit │ ├── core │ ├── test_mem.c │ └── test_mem.h │ ├── etharp │ ├── test_etharp.c │ └── test_etharp.h │ ├── lwip_check.h │ ├── lwip_unittests.c │ ├── lwipopts.h │ ├── tcp │ ├── tcp_helper.c │ ├── tcp_helper.h │ ├── test_tcp.c │ ├── test_tcp.h │ ├── test_tcp_oos.c │ └── test_tcp_oos.h │ └── udp │ ├── test_udp.c │ └── test_udp.h ├── main.c ├── stm32ecm2.hzp ├── stm32f0xx_hal.c ├── stm32f0xx_hal.h ├── stm32f0xx_hal_conf.h ├── stm32f0xx_hal_cortex.c ├── stm32f0xx_hal_cortex.h ├── stm32f0xx_hal_def.h ├── stm32f0xx_hal_flash.h ├── stm32f0xx_hal_flash_ex.h ├── stm32f0xx_hal_gpio.c ├── stm32f0xx_hal_gpio.h ├── stm32f0xx_hal_gpio_ex.h ├── stm32f0xx_hal_helper.c ├── stm32f0xx_hal_pcd.c ├── stm32f0xx_hal_pcd.h ├── stm32f0xx_hal_pcd_ex.c ├── stm32f0xx_hal_pcd_ex.h ├── stm32f0xx_hal_pwr.h ├── stm32f0xx_hal_pwr_ex.h ├── stm32f0xx_hal_rcc.c ├── stm32f0xx_hal_rcc.h ├── stm32f0xx_hal_rcc_ex.c ├── stm32f0xx_hal_rcc_ex.h ├── stm32f0xx_it.c ├── stm32f0xx_it.h ├── system_stm32f0xx.c ├── time.c ├── time.h ├── usbd_conf.c ├── usbd_conf.h ├── usbd_core.c ├── usbd_core.h ├── usbd_ctlreq.c ├── usbd_ctlreq.h ├── usbd_def.h ├── usbd_desc.c ├── usbd_desc.h ├── usbd_ecm.c ├── usbd_ecm.h ├── usbd_ioreq.c ├── usbd_ioreq.h └── usbhelper.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | stm32ecm2 THUMB Debug/* 3 | stm32ecm2 THUMB Release/* 4 | *.hzs 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | USB CDC-ECM example for STM32F072 microcontroller 2 | ================================================= 3 | 4 | This is a second generation (and hopefully more useful) version of this project. The first was originally written due to the apparent dearth of open-source implementations of this class of device. 5 | 6 | However, unlike the previous, this new version has embedded virtual DHCP, DNS, and web servers. 7 | 8 | Utilizing a copy of [lwIP 1.4.1](https://savannah.nongnu.org/projects/lwip/) from the [lrndis](https://github.com/fetisov/lrndis) project, this is a CDC-ECM implementation for the STM32F072. 9 | 10 | This is related to [D21ecm](https://github.com/majbthrd/D21ecm/), another CDC-ECM implementation (but for the Atmel SAMD21). 11 | 12 | Note that this project functions with both Linux and Mac OS X Lion 10.7.5 hosts, but not with Mac OS X El Capitan 10.11.6 nor macOS High Sierra 10.13.16. 13 | 14 | ## Alternatives 15 | 16 | Note that my priority going forward is to add the same and additional capabilities to [TinyUSB](https://github.com/hathach/tinyusb); TinyUSB has the added benefit of supporting many different processors. 17 | 18 | ## Usage 19 | 20 | TCP/IP is inherently a high memory user (at least in traditional embedded terms). However, by tweaking the options of [lwIP](https://savannah.nongnu.org/projects/lwip/), I have the implementation fitting within the 16kBytes of RAM and 128kBytes of FLASH available to the STM32F072. 21 | 22 | ## Specifics 23 | 24 | Look at main.c to get an idea of how the code could be modified. As written, one quantity (systick) is shown in real-time as "Device Time" on the embedded web server (192.168.7.1) and another three quantities (alpha, bravo, and charlie) are "User Controls" on the web page that cause app.c code to be executed. 25 | 26 | ## Requirements for compiling 27 | 28 | [Rowley Crossworks for ARM](http://www.rowley.co.uk/arm/) is presently needed to compile this code. 29 | 30 | All the code is gcc/clang compatible, and as time permits, other options may be added. 31 | -------------------------------------------------------------------------------- /attribution.md: -------------------------------------------------------------------------------- 1 | This project is derived from [lrndis](https://github.com/fetisov/lrndis), which also utilizes code from [usbstick](https://colinoflynn.com/tag/usb/). 2 | 3 | The USB stack is from the HAL driver provided by [ST](https://www.st.com/). 4 | 5 | The network stack is powered by [lwIP](https://savannah.nongnu.org/projects/lwip/). 6 | 7 | The toaster.svg image used in the web interface was obtained from [isometric-toaster](https://openclipart.org/detail/20971/isometric-toaster-by-rg1024). The file was put on a diet by removing the metadata, reducing the file size from 17374 to 12174 bytes (very important when flash size is limited). 8 | 9 | -------------------------------------------------------------------------------- /dhcp-server/dhserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 by Sergey Fetisov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | /* 26 | * version: 1.0 demo (7.02.2015) 27 | * brief: tiny dhcp ipv4 server using lwip (pcb) 28 | * ref: https://lists.gnu.org/archive/html/lwip-users/2012-12/msg00016.html 29 | */ 30 | 31 | #ifndef DHSERVER_H 32 | #define DHSERVER_H 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include "lwip/err.h" 39 | #include "lwip/udp.h" 40 | #include "netif/etharp.h" 41 | 42 | typedef struct dhcp_entry 43 | { 44 | uint8_t mac[6]; 45 | uint8_t addr[4]; 46 | uint8_t subnet[4]; 47 | uint32_t lease; 48 | } dhcp_entry_t; 49 | 50 | typedef struct dhcp_config 51 | { 52 | uint8_t addr[4]; 53 | uint16_t port; 54 | uint8_t dns[4]; 55 | const char *domain; 56 | int num_entry; 57 | dhcp_entry_t *entries; 58 | } dhcp_config_t; 59 | 60 | err_t dhserv_init(dhcp_config_t *config); 61 | void dhserv_free(void); 62 | 63 | #endif /* DHSERVER_H */ 64 | -------------------------------------------------------------------------------- /dns-server/dnserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 by Sergey Fetisov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | /* 26 | * version: 1.0 demo (7.02.2015) 27 | * brief: tiny dns ipv4 server using lwip (pcb) 28 | */ 29 | 30 | #ifndef DNSERVER 31 | #define DNSERVER 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "lwip/def.h" 38 | #include "lwip/err.h" 39 | #include "lwip/udp.h" 40 | #include "netif/etharp.h" 41 | 42 | typedef bool (*dns_query_proc_t)(const char *name, ip_addr_t *addr); 43 | 44 | err_t dnserv_init(ip_addr_t *bind, uint16_t port, dns_query_proc_t query_proc); 45 | void dnserv_free(void); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lwip-1.4.1/CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/majbthrd/stm32ecm/8c6565a83d6637dbc9f4da1cb72549ee7d5788b5/lwip-1.4.1/CHANGELOG -------------------------------------------------------------------------------- /lwip-1.4.1/COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | 34 | -------------------------------------------------------------------------------- /lwip-1.4.1/FILES: -------------------------------------------------------------------------------- 1 | src/ - The source code for the lwIP TCP/IP stack. 2 | doc/ - The documentation for lwIP. 3 | 4 | See also the FILES file in each subdirectory. 5 | -------------------------------------------------------------------------------- /lwip-1.4.1/README: -------------------------------------------------------------------------------- 1 | INTRODUCTION 2 | 3 | lwIP is a small independent implementation of the TCP/IP protocol 4 | suite that has been developed by Adam Dunkels at the Computer and 5 | Networks Architectures (CNA) lab at the Swedish Institute of Computer 6 | Science (SICS). 7 | 8 | The focus of the lwIP TCP/IP implementation is to reduce the RAM usage 9 | while still having a full scale TCP. This making lwIP suitable for use 10 | in embedded systems with tens of kilobytes of free RAM and room for 11 | around 40 kilobytes of code ROM. 12 | 13 | FEATURES 14 | 15 | * IP (Internet Protocol) including packet forwarding over multiple network 16 | interfaces 17 | * ICMP (Internet Control Message Protocol) for network maintenance and debugging 18 | * IGMP (Internet Group Management Protocol) for multicast traffic management 19 | * UDP (User Datagram Protocol) including experimental UDP-lite extensions 20 | * TCP (Transmission Control Protocol) with congestion control, RTT estimation 21 | and fast recovery/fast retransmit 22 | * Specialized raw/native API for enhanced performance 23 | * Optional Berkeley-like socket API 24 | * DNS (Domain names resolver) 25 | * SNMP (Simple Network Management Protocol) 26 | * DHCP (Dynamic Host Configuration Protocol) 27 | * AUTOIP (for IPv4, conform with RFC 3927) 28 | * PPP (Point-to-Point Protocol) 29 | * ARP (Address Resolution Protocol) for Ethernet 30 | 31 | LICENSE 32 | 33 | lwIP is freely available under a BSD license. 34 | 35 | DEVELOPMENT 36 | 37 | lwIP has grown into an excellent TCP/IP stack for embedded devices, 38 | and developers using the stack often submit bug fixes, improvements, 39 | and additions to the stack to further increase its usefulness. 40 | 41 | Development of lwIP is hosted on Savannah, a central point for 42 | software development, maintenance and distribution. Everyone can 43 | help improve lwIP by use of Savannah's interface, CVS and the 44 | mailing list. A core team of developers will commit changes to the 45 | CVS source tree. 46 | 47 | The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and 48 | contributions (such as platform ports) are in the 'contrib' module. 49 | 50 | See doc/savannah.txt for details on CVS server access for users and 51 | developers. 52 | 53 | Last night's CVS tar ball can be downloaded from: 54 | http://savannah.gnu.org/cvs.backups/lwip.tar.gz [CHANGED - NEEDS FIXING] 55 | 56 | The current CVS trees are web-browsable: 57 | http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/lwip/ 58 | http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/ 59 | 60 | Submit patches and bugs via the lwIP project page: 61 | http://savannah.nongnu.org/projects/lwip/ 62 | 63 | 64 | DOCUMENTATION 65 | 66 | The original out-dated homepage of lwIP and Adam Dunkels' papers on 67 | lwIP are at the official lwIP home page: 68 | http://www.sics.se/~adam/lwip/ 69 | 70 | Self documentation of the source code is regularly extracted from the 71 | current CVS sources and is available from this web page: 72 | http://www.nongnu.org/lwip/ 73 | 74 | There is now a constantly growin wiki about lwIP at 75 | http://lwip.wikia.com/wiki/LwIP_Wiki 76 | 77 | Also, there are mailing lists you can subscribe at 78 | http://savannah.nongnu.org/mail/?group=lwip 79 | plus searchable archives: 80 | http://lists.nongnu.org/archive/html/lwip-users/ 81 | http://lists.nongnu.org/archive/html/lwip-devel/ 82 | 83 | Reading Adam's papers, the files in docs/, browsing the source code 84 | documentation and browsing the mailing list archives is a good way to 85 | become familiar with the design of lwIP. 86 | 87 | Adam Dunkels 88 | Leon Woestenberg 89 | 90 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/chargen/README: -------------------------------------------------------------------------------- 1 | 2 | CHARGEN 3 | 4 | This file implements a nice example of handling multiple tcp sockets in a 5 | server environment. Just call chargen_init() from your application after 6 | you have initialized lwip and added your network interfaces. Change the 7 | MAX_SERV option to increase or decrease the number of sessions supported. 8 | 9 | chargen will jam as much data as possible into the output socket, so it 10 | will take up a lot of CPU time. Therefore it will be a good idea to run it 11 | as the lowest possible priority (just ahead of any idle task). 12 | 13 | This is also a good example of how to support multiple sessions in an 14 | embedded system where you might not have fork(). The multiple sessions are 15 | all handled by the same thread and select() is used for demultiplexing. 16 | 17 | No makefile is provided, just add chargen to the makefile for your 18 | application. It is OS and HW independent. 19 | 20 | Once the chargen server is running in your application, go to another system 21 | and open a telnet session to your lwip platform at port 19. You should see an 22 | ASCII pattern start to stream on you screen. 23 | 24 | As an example, lets say that your system running lwip is at IP address 25 | 192.168.10.244 and you have a linux system connected to it at IP address 26 | 192.168.10.59. Issue the following command at a terminal prompt on the linux system: 27 | 28 | telnet 192.168.10.244 19 29 | 30 | You will see a pattern similar to the following on streaming by on your 31 | screen: 32 | 33 | ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{ 34 | BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{| 35 | CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} 36 | DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 37 | EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~! 38 | FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!" 39 | GHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"# 40 | HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$ 41 | IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$% 42 | JKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%& 43 | KLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&' 44 | LMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'( 45 | 46 | It even works from windows: At a dos prompt you can also issue the same 47 | telnet command and you will get a similar (but much slower, at least on W98) 48 | data stream. 49 | 50 | David Haas 51 | 52 | 53 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/chargen/chargen.h: -------------------------------------------------------------------------------- 1 | #ifndef __CHARGEN_H__ 2 | #define __CHARGEN_H__ 3 | 4 | #include "lwip/opt.h" 5 | 6 | #if LWIP_SOCKET 7 | 8 | void chargen_init(void); 9 | 10 | #endif /* LWIP_SOCKET */ 11 | 12 | 13 | #endif /* __CHARGEN_H__ */ 14 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver/README: -------------------------------------------------------------------------------- 1 | HTTPSERVER 2 | 3 | This is a demonstration of how to make the most basic kind 4 | of server using lWIP. 5 | 6 | * httpserver-raw.c - uses raw TCP calls (coming soon!) 7 | 8 | * httpserver-netconn.c - uses netconn and netbuf API 9 | 10 | This code updates the examples in Adam Dunkel's original 11 | lwIP documentation to match changes in the code since that 12 | PDF release. 13 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver/httpserver-netconn.c: -------------------------------------------------------------------------------- 1 | 2 | #include "lwip/opt.h" 3 | #include "lwip/arch.h" 4 | #include "lwip/api.h" 5 | 6 | #include "httpserver-netconn.h" 7 | 8 | #if LWIP_NETCONN 9 | 10 | #ifndef HTTPD_DEBUG 11 | #define HTTPD_DEBUG LWIP_DBG_OFF 12 | #endif 13 | 14 | const static char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; 15 | const static char http_index_html[] = "Congrats!

Welcome to our lwIP HTTP server!

This is a small test page, served by httpserver-netconn."; 16 | 17 | /** Serve one HTTP connection accepted in the http thread */ 18 | static void 19 | http_server_netconn_serve(struct netconn *conn) 20 | { 21 | struct netbuf *inbuf; 22 | char *buf; 23 | u16_t buflen; 24 | err_t err; 25 | 26 | /* Read the data from the port, blocking if nothing yet there. 27 | We assume the request (the part we care about) is in one netbuf */ 28 | err = netconn_recv(conn, &inbuf); 29 | 30 | if (err == ERR_OK) { 31 | netbuf_data(inbuf, (void**)&buf, &buflen); 32 | 33 | /* Is this an HTTP GET command? (only check the first 5 chars, since 34 | there are other formats for GET, and we're keeping it very simple )*/ 35 | if (buflen>=5 && 36 | buf[0]=='G' && 37 | buf[1]=='E' && 38 | buf[2]=='T' && 39 | buf[3]==' ' && 40 | buf[4]=='/' ) { 41 | 42 | /* Send the HTML header 43 | * subtract 1 from the size, since we dont send the \0 in the string 44 | * NETCONN_NOCOPY: our data is const static, so no need to copy it 45 | */ 46 | netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY); 47 | 48 | /* Send our HTML page */ 49 | netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY); 50 | } 51 | } 52 | /* Close the connection (server closes in HTTP) */ 53 | netconn_close(conn); 54 | 55 | /* Delete the buffer (netconn_recv gives us ownership, 56 | so we have to make sure to deallocate the buffer) */ 57 | netbuf_delete(inbuf); 58 | } 59 | 60 | /** The main function, never returns! */ 61 | static void 62 | http_server_netconn_thread(void *arg) 63 | { 64 | struct netconn *conn, *newconn; 65 | err_t err; 66 | LWIP_UNUSED_ARG(arg); 67 | 68 | /* Create a new TCP connection handle */ 69 | conn = netconn_new(NETCONN_TCP); 70 | LWIP_ERROR("http_server: invalid conn", (conn != NULL), return;); 71 | 72 | /* Bind to port 80 (HTTP) with default IP address */ 73 | netconn_bind(conn, NULL, 80); 74 | 75 | /* Put the connection into LISTEN state */ 76 | netconn_listen(conn); 77 | 78 | do { 79 | err = netconn_accept(conn, &newconn); 80 | if (err == ERR_OK) { 81 | http_server_netconn_serve(newconn); 82 | netconn_delete(newconn); 83 | } 84 | } while(err == ERR_OK); 85 | LWIP_DEBUGF(HTTPD_DEBUG, 86 | ("http_server_netconn_thread: netconn_accept received error %d, shutting down", 87 | err)); 88 | netconn_close(conn); 89 | netconn_delete(conn); 90 | } 91 | 92 | /** Initialize the HTTP server (start its thread) */ 93 | void 94 | http_server_netconn_init() 95 | { 96 | sys_thread_new("http_server_netconn", http_server_netconn_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); 97 | } 98 | 99 | #endif /* LWIP_NETCONN*/ 100 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver/httpserver-netconn.h: -------------------------------------------------------------------------------- 1 | #ifndef __HTTPSERVER_NETCONN_H__ 2 | #define __HTTPSERVER_NETCONN_H__ 3 | 4 | void http_server_netconn_init(); 5 | 6 | #endif /* __HTTPSERVER_NETCONN_H__ */ 7 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver_raw/fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 19 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

404 - Page not found

12 |

13 | Sorry, the page you are requesting was not found on this 14 | server. 15 |

16 |
17 |   18 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver_raw/fs/img/sics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/majbthrd/stm32ecm/8c6565a83d6637dbc9f4da1cb72549ee7d5788b5/lwip-1.4.1/apps/httpserver_raw/fs/img/sics.gif -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver_raw/fs/index.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 44 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

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

16 |

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

27 |

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

34 |

35 | More information about lwIP can be found at the lwIP 36 | homepage at http://savannah.nongnu.org/projects/lwip/ 38 | or at the lwIP wiki at http://lwip.wikia.com/. 40 |

41 |
42 |   43 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver_raw/fsdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __FSDATA_H__ 33 | #define __FSDATA_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "fs.h" 37 | 38 | struct fsdata_file { 39 | const struct fsdata_file *next; 40 | const unsigned char *name; 41 | const unsigned char *data; 42 | int len; 43 | u8_t http_header_included; 44 | #if HTTPD_PRECALCULATED_CHECKSUM 45 | u16_t chksum_count; 46 | const struct fsdata_chksum *chksum; 47 | #endif /* HTTPD_PRECALCULATED_CHECKSUM */ 48 | }; 49 | 50 | #endif /* __FSDATA_H__ */ 51 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver_raw/makefsdata/makefsdata: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | open(OUTPUT, "> fsdata.c"); 4 | 5 | chdir("fs"); 6 | open(FILES, "find . -type f |"); 7 | 8 | while($file = ) { 9 | 10 | # Do not include files in CVS directories nor backup files. 11 | if($file =~ /(CVS|~)/) { 12 | next; 13 | } 14 | 15 | chop($file); 16 | 17 | open(HEADER, "> /tmp/header") || die $!; 18 | if($file =~ /404/) { 19 | print(HEADER "HTTP/1.0 404 File not found\r\n"); 20 | } else { 21 | print(HEADER "HTTP/1.0 200 OK\r\n"); 22 | } 23 | print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n"); 24 | if($file =~ /\.html$/) { 25 | print(HEADER "Content-type: text/html\r\n"); 26 | } elsif($file =~ /\.gif$/) { 27 | print(HEADER "Content-type: image/gif\r\n"); 28 | } elsif($file =~ /\.png$/) { 29 | print(HEADER "Content-type: image/png\r\n"); 30 | } elsif($file =~ /\.jpg$/) { 31 | print(HEADER "Content-type: image/jpeg\r\n"); 32 | } elsif($file =~ /\.class$/) { 33 | print(HEADER "Content-type: application/octet-stream\r\n"); 34 | } elsif($file =~ /\.ram$/) { 35 | print(HEADER "Content-type: audio/x-pn-realaudio\r\n"); 36 | } else { 37 | print(HEADER "Content-type: text/plain\r\n"); 38 | } 39 | print(HEADER "\r\n"); 40 | close(HEADER); 41 | 42 | unless($file =~ /\.plain$/ || $file =~ /cgi/) { 43 | system("cat /tmp/header $file > /tmp/file"); 44 | } else { 45 | system("cp $file /tmp/file"); 46 | } 47 | 48 | open(FILE, "/tmp/file"); 49 | unlink("/tmp/file"); 50 | unlink("/tmp/header"); 51 | 52 | $file =~ s/\.//; 53 | $fvar = $file; 54 | $fvar =~ s-/-_-g; 55 | $fvar =~ s-\.-_-g; 56 | print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); 57 | print(OUTPUT "\t/* $file */\n\t"); 58 | for($j = 0; $j < length($file); $j++) { 59 | printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); 60 | } 61 | printf(OUTPUT "0,\n"); 62 | 63 | 64 | $i = 0; 65 | while(read(FILE, $data, 1)) { 66 | if($i == 0) { 67 | print(OUTPUT "\t"); 68 | } 69 | printf(OUTPUT "%#02x, ", unpack("C", $data)); 70 | $i++; 71 | if($i == 10) { 72 | print(OUTPUT "\n"); 73 | $i = 0; 74 | } 75 | } 76 | print(OUTPUT "};\n\n"); 77 | close(FILE); 78 | push(@fvars, $fvar); 79 | push(@files, $file); 80 | } 81 | 82 | for($i = 0; $i < @fvars; $i++) { 83 | $file = $files[$i]; 84 | $fvar = $fvars[$i]; 85 | 86 | if($i == 0) { 87 | $prevfile = "NULL"; 88 | } else { 89 | $prevfile = "file" . $fvars[$i - 1]; 90 | } 91 | print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, "); 92 | print(OUTPUT "data$fvar + ". (length($file) + 1) .", "); 93 | print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); 94 | } 95 | 96 | print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n"); 97 | print(OUTPUT "#define FS_NUMFILES $i\n"); 98 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/httpserver_raw/makefsdata/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains a script ('makefsdata') to create C code suitable for 2 | httpd for given html pages (or other files) in a directory. 3 | 4 | There is also a plain C console application doing the same and extended a bit. 5 | 6 | Usage: htmlgen [targetdir] [-s] [-i]s 7 | targetdir: relative or absolute path to files to convert 8 | switch -s: toggle processing of subdirectories (default is on) 9 | switch -e: exclude HTTP header from file (header is created at runtime, default is on) 10 | switch -11: include HTTP 1.1 header (1.0 is default) 11 | 12 | if targetdir not specified, makefsdata will attempt to 13 | process files in subdirectory 'fs'. 14 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/netbios/netbios.h: -------------------------------------------------------------------------------- 1 | #ifndef __NETBIOS_H__ 2 | #define __NETBIOS_H__ 3 | 4 | void netbios_init(void); 5 | 6 | #endif /* __NETBIOS_H__ */ 7 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/netio/netio.c: -------------------------------------------------------------------------------- 1 | #include "netio.h" 2 | 3 | #include "lwip/opt.h" 4 | #include "lwip/tcp.h" 5 | 6 | /* See http://www.nwlab.net/art/netio/netio.html to get the netio tool */ 7 | 8 | #if LWIP_TCP 9 | static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) 10 | { 11 | 12 | LWIP_UNUSED_ARG(arg); 13 | 14 | if (err == ERR_OK && p != NULL) { 15 | tcp_recved(pcb, p->tot_len); 16 | pbuf_free(p); 17 | } else { 18 | pbuf_free(p); 19 | } 20 | 21 | if (err == ERR_OK && p == NULL) { 22 | tcp_arg(pcb, NULL); 23 | tcp_sent(pcb, NULL); 24 | tcp_recv(pcb, NULL); 25 | tcp_close(pcb); 26 | } 27 | 28 | return ERR_OK; 29 | } 30 | 31 | static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err) 32 | { 33 | LWIP_UNUSED_ARG(arg); 34 | LWIP_UNUSED_ARG(err); 35 | 36 | tcp_arg(pcb, NULL); 37 | tcp_sent(pcb, NULL); 38 | tcp_recv(pcb, netio_recv); 39 | return ERR_OK; 40 | } 41 | 42 | void netio_init(void) 43 | { 44 | struct tcp_pcb *pcb; 45 | 46 | pcb = tcp_new(); 47 | tcp_bind(pcb, IP_ADDR_ANY, 18767); 48 | pcb = tcp_listen(pcb); 49 | tcp_accept(pcb, netio_accept); 50 | } 51 | #endif /* LWIP_TCP */ 52 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/netio/netio.h: -------------------------------------------------------------------------------- 1 | #ifndef __NETIO_H__ 2 | #define __NETIO_H__ 3 | 4 | void netio_init(void); 5 | 6 | #endif /* __NETIO_H__ */ 7 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/ping/ping.h: -------------------------------------------------------------------------------- 1 | #ifndef __PING_H__ 2 | #define __PING_H__ 3 | 4 | /** 5 | * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used 6 | */ 7 | #ifndef PING_USE_SOCKETS 8 | #define PING_USE_SOCKETS LWIP_SOCKET 9 | #endif 10 | 11 | 12 | void ping_init(void); 13 | 14 | #if !PING_USE_SOCKETS 15 | void ping_send_now(void); 16 | #endif /* !PING_USE_SOCKETS */ 17 | 18 | #endif /* __PING_H__ */ 19 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/rtp/rtp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RTP_H__ 2 | #define __RTP_H__ 3 | 4 | #if LWIP_SOCKET && LWIP_IGMP 5 | void rtp_init(void); 6 | #endif /* LWIP_SOCKET && LWIP_IGMP */ 7 | 8 | #endif /* __RTP_H__ */ 9 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/shell/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __SHELL_H__ 33 | #define __SHELL_H__ 34 | 35 | void shell_init(void); 36 | 37 | #endif /* __SHELL_H__ */ 38 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/smtp/smtp.h: -------------------------------------------------------------------------------- 1 | #ifndef __SMTP_H__ 2 | #define __SMTP_H__ 3 | 4 | #include "lwip/err.h" 5 | 6 | /** The default TCP port used for SMTP */ 7 | #define SMTP_DEFAULT_PORT 25 8 | 9 | /** Email successfully sent */ 10 | #define SMTP_RESULT_OK 0 11 | /** Unknown error */ 12 | #define SMTP_RESULT_ERR_UNKNOWN 1 13 | /** Connection to server failed */ 14 | #define SMTP_RESULT_ERR_CONNECT 2 15 | /** Failed to resolve server hostname */ 16 | #define SMTP_RESULT_ERR_HOSTNAME 3 17 | /** Connection unexpectedly closed by remote server */ 18 | #define SMTP_RESULT_ERR_CLOSED 4 19 | /** Connection timed out (server didn't respond in time) */ 20 | #define SMTP_RESULT_ERR_TIMEOUT 5 21 | /** Server responded with an unknown response code */ 22 | #define SMTP_RESULT_ERR_SVR_RESP 6 23 | 24 | /** Prototype of an smtp callback function 25 | * 26 | * @param arg argument specified when initiating the email 27 | * @param smtp_result result of the mail transfer (see defines SMTP_RESULT_*) 28 | * @param srv_err if aborted by the server, this contains the error code received 29 | * @param err an error returned by internal lwip functions, can help to specify 30 | * the source of the error but must not necessarily be != ERR_OK 31 | */ 32 | typedef void (*smtp_result_fn)(void *arg, u8_t smtp_result, u16_t srv_err, err_t err); 33 | 34 | /** This structure is used as argument for smtp_send_mail_int(), 35 | * which in turn can be used with tcpip_callback() to send mail 36 | * from interrupt context. 37 | * For member description, see parameter description of smtp_send_mail(). 38 | * When using with tcpip_callback, this structure has to stay allocated 39 | * (e.g. using mem_malloc/mem_free) until its 'callback_fn' is called. 40 | */ 41 | struct smtp_send_request { 42 | const char *from; 43 | const char* to; 44 | const char* subject; 45 | const char* body; 46 | smtp_result_fn callback_fn; 47 | void* callback_arg; 48 | /** If this is != 0, data is *not* copied into an extra buffer 49 | * but used from the pointers supplied in this struct. 50 | * This means less memory usage, but data must stay untouched until 51 | * the callback function is called. */ 52 | u8_t static_data; 53 | }; 54 | 55 | void smtp_set_server_addr(const char* server); 56 | void smtp_set_server_port(u16_t port); 57 | err_t smtp_set_auth(const char* username, const char* pass); 58 | err_t smtp_send_mail(const char *from, const char* to, const char* subject, const char* body, 59 | smtp_result_fn callback_fn, void* callback_arg); 60 | err_t smtp_send_mail_static(const char *from, const char* to, const char* subject, const char* body, 61 | smtp_result_fn callback_fn, void* callback_arg); 62 | void smtp_send_mail_int(void *arg); 63 | #if LWIP_DEBUG 64 | const char* smtp_result_str(u8_t smtp_result); 65 | #endif 66 | 67 | #endif /* __SMTP_H__ */ 68 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/snmp_private_mib/private_mib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Exports Private lwIP MIB 4 | */ 5 | 6 | #ifndef __LWIP_PRIVATE_MIB_H__ 7 | #define __LWIP_PRIVATE_MIB_H__ 8 | 9 | #include "arch/cc.h" 10 | #include "lwip/opt.h" 11 | 12 | #if LWIP_SNMP 13 | #include "lwip/snmp_structs.h" 14 | extern const struct mib_array_node mib_private; 15 | 16 | /** @todo remove this?? */ 17 | struct private_msg 18 | { 19 | u8_t dummy; 20 | }; 21 | 22 | void lwip_privmib_init(void); 23 | 24 | #define SNMP_PRIVATE_MIB_INIT() lwip_privmib_init() 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/sntp/sntp.h: -------------------------------------------------------------------------------- 1 | #ifndef __SNTP_H__ 2 | #define __SNTP_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void sntp_init(void); 9 | void sntp_stop(void); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif /* __SNTP_H__ */ 16 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/socket_examples/socket_examples.h: -------------------------------------------------------------------------------- 1 | #ifndef __SOCKET_EXAMPLES_H__ 2 | #define __SOCKET_EXAMPLES_H__ 3 | 4 | void socket_examples_init(void); 5 | 6 | #endif /* __SOCKET_EXAMPLES_H__ */ 7 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/tcpecho/tcpecho.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #include "tcpecho.h" 33 | 34 | #include "lwip/opt.h" 35 | 36 | #if LWIP_NETCONN 37 | 38 | #include "lwip/sys.h" 39 | #include "lwip/api.h" 40 | /*-----------------------------------------------------------------------------------*/ 41 | static void 42 | tcpecho_thread(void *arg) 43 | { 44 | struct netconn *conn, *newconn; 45 | err_t err; 46 | LWIP_UNUSED_ARG(arg); 47 | 48 | /* Create a new connection identifier. */ 49 | conn = netconn_new(NETCONN_TCP); 50 | 51 | /* Bind connection to well known port number 7. */ 52 | netconn_bind(conn, NULL, 7); 53 | 54 | /* Tell connection to go into listening mode. */ 55 | netconn_listen(conn); 56 | 57 | while (1) { 58 | 59 | /* Grab new connection. */ 60 | err = netconn_accept(conn, &newconn); 61 | /*printf("accepted new connection %p\n", newconn);*/ 62 | /* Process the new connection. */ 63 | if (err == ERR_OK) { 64 | struct netbuf *buf; 65 | void *data; 66 | u16_t len; 67 | 68 | while ((err = netconn_recv(newconn, &buf)) == ERR_OK) { 69 | /*printf("Recved\n");*/ 70 | do { 71 | netbuf_data(buf, &data, &len); 72 | err = netconn_write(newconn, data, len, NETCONN_COPY); 73 | #if 0 74 | if (err != ERR_OK) { 75 | printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err)); 76 | } 77 | #endif 78 | } while (netbuf_next(buf) >= 0); 79 | netbuf_delete(buf); 80 | } 81 | /*printf("Got EOF, looping\n");*/ 82 | /* Close connection and discard connection identifier. */ 83 | netconn_close(newconn); 84 | netconn_delete(newconn); 85 | } 86 | } 87 | } 88 | /*-----------------------------------------------------------------------------------*/ 89 | void 90 | tcpecho_init(void) 91 | { 92 | sys_thread_new("tcpecho_thread", tcpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); 93 | } 94 | /*-----------------------------------------------------------------------------------*/ 95 | 96 | #endif /* LWIP_NETCONN */ 97 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/tcpecho/tcpecho.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #ifndef __TCPECHO_H__ 34 | #define __TCPECHO_H__ 35 | 36 | void tcpecho_init(void); 37 | 38 | #endif /* __TCPECHO_H__ */ 39 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/tcpecho_raw/echo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | */ 30 | #ifndef __ECHO_H__ 31 | #define __ECHO_H__ 32 | 33 | void echo_init(void); 34 | 35 | #endif /* __MINIMAL_ECHO_H */ 36 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/udpecho/udpecho.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #include "udpecho.h" 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_NETCONN 38 | 39 | #include "lwip/api.h" 40 | #include "lwip/sys.h" 41 | 42 | /*-----------------------------------------------------------------------------------*/ 43 | static void 44 | udpecho_thread(void *arg) 45 | { 46 | static struct netconn *conn; 47 | static struct netbuf *buf; 48 | static ip_addr_t *addr; 49 | static unsigned short port; 50 | char buffer[4096]; 51 | err_t err; 52 | LWIP_UNUSED_ARG(arg); 53 | 54 | conn = netconn_new(NETCONN_UDP); 55 | LWIP_ASSERT("con != NULL", conn != NULL); 56 | netconn_bind(conn, NULL, 7); 57 | 58 | while (1) { 59 | err = netconn_recv(conn, &buf); 60 | if (err == ERR_OK) { 61 | addr = netbuf_fromaddr(buf); 62 | port = netbuf_fromport(buf); 63 | /* no need netconn_connect here, since the netbuf contains the address */ 64 | if(netbuf_copy(buf, buffer, buf->p->tot_len) != buf->p->tot_len) { 65 | LWIP_DEBUGF(LWIP_DBG_ON, ("netbuf_copy failed\n")); 66 | } else { 67 | buffer[buf->p->tot_len] = '\0'; 68 | err = netconn_send(conn, buf); 69 | if(err != ERR_OK) { 70 | LWIP_DEBUGF(LWIP_DBG_ON, ("netconn_send failed: %d\n", (int)err)); 71 | } else { 72 | LWIP_DEBUGF(LWIP_DBG_ON, ("got %s\n", buffer)); 73 | } 74 | } 75 | netbuf_delete(buf); 76 | } 77 | } 78 | } 79 | /*-----------------------------------------------------------------------------------*/ 80 | void 81 | udpecho_init(void) 82 | { 83 | sys_thread_new("udpecho_thread", udpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); 84 | } 85 | 86 | #endif /* LWIP_NETCONN */ 87 | -------------------------------------------------------------------------------- /lwip-1.4.1/apps/udpecho/udpecho.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __UDPECHO_H__ 33 | #define __UDPECHO_H__ 34 | 35 | void udpecho_init(void); 36 | 37 | #endif /* __UDPECHO_H__ */ 38 | -------------------------------------------------------------------------------- /lwip-1.4.1/doc/FILES: -------------------------------------------------------------------------------- 1 | savannah.txt - How to obtain the current development source code. 2 | contrib.txt - How to contribute to lwIP as a developer. 3 | rawapi.txt - The documentation for the core API of lwIP. 4 | Also provides an overview about the other APIs and multithreading. 5 | snmp_agent.txt - The documentation for the lwIP SNMP agent. 6 | sys_arch.txt - The documentation for a system abstraction layer of lwIP. 7 | -------------------------------------------------------------------------------- /lwip-1.4.1/doc/contrib.txt: -------------------------------------------------------------------------------- 1 | 1 Introduction 2 | 3 | This document describes some guidelines for people participating 4 | in lwIP development. 5 | 6 | 2 How to contribute to lwIP 7 | 8 | Here is a short list of suggestions to anybody working with lwIP and 9 | trying to contribute bug reports, fixes, enhancements, platform ports etc. 10 | First of all as you may already know lwIP is a volunteer project so feedback 11 | to fixes or questions might often come late. Hopefully the bug and patch tracking 12 | features of Savannah help us not lose users' input. 13 | 14 | 2.1 Source code style: 15 | 16 | 1. do not use tabs. 17 | 2. indentation is two spaces per level (i.e. per tab). 18 | 3. end debug messages with a trailing newline (\n). 19 | 4. one space between keyword and opening bracket. 20 | 5. no space between function and opening bracket. 21 | 6. one space and no newline before opening curly braces of a block. 22 | 7. closing curly brace on a single line. 23 | 8. spaces surrounding assignment and comparisons. 24 | 9. don't initialize static and/or global variables to zero, the compiler takes care of that. 25 | 10. use current source code style as further reference. 26 | 27 | 2.2 Source code documentation style: 28 | 29 | 1. JavaDoc compliant and Doxygen compatible. 30 | 2. Function documentation above functions in .c files, not .h files. 31 | (This forces you to synchronize documentation and implementation.) 32 | 3. Use current documentation style as further reference. 33 | 34 | 2.3 Bug reports and patches: 35 | 36 | 1. Make sure you are reporting bugs or send patches against the latest 37 | sources. (From the latest release and/or the current CVS sources.) 38 | 2. If you think you found a bug make sure it's not already filed in the 39 | bugtracker at Savannah. 40 | 3. If you have a fix put the patch on Savannah. If it is a patch that affects 41 | both core and arch specific stuff please separate them so that the core can 42 | be applied separately while leaving the other patch 'open'. The prefered way 43 | is to NOT touch archs you can't test and let maintainers take care of them. 44 | This is a good way to see if they are used at all - the same goes for unix 45 | netifs except tapif. 46 | 4. Do not file a bug and post a fix to it to the patch area. Either a bug report 47 | or a patch will be enough. 48 | If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area. 49 | 5. Trivial patches (compiler warning, indentation and spelling fixes or anything obvious which takes a line or two) 50 | can go to the lwip-users list. This is still the fastest way of interaction and the list is not so crowded 51 | as to allow for loss of fixes. Putting bugs on Savannah and subsequently closing them is too much an overhead 52 | for reporting a compiler warning fix. 53 | 6. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other 54 | trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you 55 | change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than 56 | if it's not to the point and long :) so the chances for it to be applied are greater. 57 | 58 | 2.4 Platform porters: 59 | 60 | 1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and 61 | you think it could benefit others[1] you might want discuss this on the mailing list. You 62 | can also ask for CVS access to submit and maintain your port in the contrib CVS module. 63 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/FILES: -------------------------------------------------------------------------------- 1 | api/ - The code for the high-level wrapper API. Not needed if 2 | you use the lowel-level call-back/raw API. 3 | 4 | core/ - The core of the TPC/IP stack; protocol implementations, 5 | memory and buffer management, and the low-level raw API. 6 | 7 | include/ - lwIP include files. 8 | 9 | netif/ - Generic network interface device drivers are kept here, 10 | as well as the ARP module. 11 | 12 | For more information on the various subdirectories, check the FILES 13 | file in each directory. 14 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/api/err.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Error Management module 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/err.h" 40 | 41 | #ifdef LWIP_DEBUG 42 | 43 | static const char *err_strerr[] = { 44 | "Ok.", /* ERR_OK 0 */ 45 | "Out of memory error.", /* ERR_MEM -1 */ 46 | "Buffer error.", /* ERR_BUF -2 */ 47 | "Timeout.", /* ERR_TIMEOUT -3 */ 48 | "Routing problem.", /* ERR_RTE -4 */ 49 | "Operation in progress.", /* ERR_INPROGRESS -5 */ 50 | "Illegal value.", /* ERR_VAL -6 */ 51 | "Operation would block.", /* ERR_WOULDBLOCK -7 */ 52 | "Address in use.", /* ERR_USE -8 */ 53 | "Already connected.", /* ERR_ISCONN -9 */ 54 | "Connection aborted.", /* ERR_ABRT -10 */ 55 | "Connection reset.", /* ERR_RST -11 */ 56 | "Connection closed.", /* ERR_CLSD -12 */ 57 | "Not connected.", /* ERR_CONN -13 */ 58 | "Illegal argument.", /* ERR_ARG -14 */ 59 | "Low-level netif error.", /* ERR_IF -15 */ 60 | }; 61 | 62 | /** 63 | * Convert an lwip internal error to a string representation. 64 | * 65 | * @param err an lwip internal err_t 66 | * @return a string representation for err 67 | */ 68 | const char * 69 | lwip_strerr(err_t err) 70 | { 71 | return err_strerr[-err]; 72 | 73 | } 74 | 75 | #endif /* LWIP_DEBUG */ 76 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/core/def.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Common functions used throughout the stack. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Simon Goldschmidt 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | #include "lwip/def.h" 41 | 42 | /** 43 | * These are reference implementations of the byte swapping functions. 44 | * Again with the aim of being simple, correct and fully portable. 45 | * Byte swapping is the second thing you would want to optimize. You will 46 | * need to port it to your architecture and in your cc.h: 47 | * 48 | * #define LWIP_PLATFORM_BYTESWAP 1 49 | * #define LWIP_PLATFORM_HTONS(x) 50 | * #define LWIP_PLATFORM_HTONL(x) 51 | * 52 | * Note ntohs() and ntohl() are merely references to the htonx counterparts. 53 | */ 54 | 55 | #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) 56 | 57 | /** 58 | * Convert an u16_t from host- to network byte order. 59 | * 60 | * @param n u16_t in host byte order 61 | * @return n in network byte order 62 | */ 63 | u16_t 64 | lwip_htons(u16_t n) 65 | { 66 | return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); 67 | } 68 | 69 | /** 70 | * Convert an u16_t from network- to host byte order. 71 | * 72 | * @param n u16_t in network byte order 73 | * @return n in host byte order 74 | */ 75 | u16_t 76 | lwip_ntohs(u16_t n) 77 | { 78 | return lwip_htons(n); 79 | } 80 | 81 | /** 82 | * Convert an u32_t from host- to network byte order. 83 | * 84 | * @param n u32_t in host byte order 85 | * @return n in network byte order 86 | */ 87 | u32_t 88 | lwip_htonl(u32_t n) 89 | { 90 | return ((n & 0xff) << 24) | 91 | ((n & 0xff00) << 8) | 92 | ((n & 0xff0000UL) >> 8) | 93 | ((n & 0xff000000UL) >> 24); 94 | } 95 | 96 | /** 97 | * Convert an u32_t from network- to host byte order. 98 | * 99 | * @param n u32_t in network byte order 100 | * @return n in host byte order 101 | */ 102 | u32_t 103 | lwip_ntohl(u32_t n) 104 | { 105 | return lwip_htonl(n); 106 | } 107 | 108 | #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ 109 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/core/ipv4/inet.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Functions common to all TCP/IPv4 modules, such as the byte order functions. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/inet.h" 42 | 43 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/core/ipv6/README: -------------------------------------------------------------------------------- 1 | IPv6 support in lwIP is very experimental. 2 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/core/ipv6/ip6_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #include "lwip/opt.h" 34 | #include "lwip/ip_addr.h" 35 | #include "lwip/inet.h" 36 | 37 | u8_t 38 | ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, 39 | struct ip_addr *mask) 40 | { 41 | return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) && 42 | (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) && 43 | (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) && 44 | (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3])); 45 | 46 | } 47 | 48 | u8_t 49 | ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2) 50 | { 51 | return(addr1->addr[0] == addr2->addr[0] && 52 | addr1->addr[1] == addr2->addr[1] && 53 | addr1->addr[2] == addr2->addr[2] && 54 | addr1->addr[3] == addr2->addr[3]); 55 | } 56 | 57 | void 58 | ip_addr_set(struct ip_addr *dest, struct ip_addr *src) 59 | { 60 | SMEMCPY(dest, src, sizeof(struct ip_addr)); 61 | /* dest->addr[0] = src->addr[0]; 62 | dest->addr[1] = src->addr[1]; 63 | dest->addr[2] = src->addr[2]; 64 | dest->addr[3] = src->addr[3];*/ 65 | } 66 | 67 | u8_t 68 | ip_addr_isany(struct ip_addr *addr) 69 | { 70 | if (addr == NULL) return 1; 71 | return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0); 72 | } 73 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/core/sys.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Operating System abstraction 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/sys.h" 42 | 43 | /* Most of the functions defined in sys.h must be implemented in the 44 | * architecture-dependent file sys_arch.c */ 45 | 46 | #if !NO_SYS 47 | 48 | #ifndef sys_msleep 49 | /** 50 | * Sleep for some ms. Timeouts are NOT processed while sleeping. 51 | * 52 | * @param ms number of milliseconds to sleep 53 | */ 54 | void 55 | sys_msleep(u32_t ms) 56 | { 57 | if (ms > 0) { 58 | sys_sem_t delaysem; 59 | err_t err = sys_sem_new(&delaysem, 0); 60 | if (err == ERR_OK) { 61 | sys_arch_sem_wait(&delaysem, ms); 62 | sys_sem_free(&delaysem); 63 | } 64 | } 65 | } 66 | #endif /* sys_msleep */ 67 | 68 | #endif /* !NO_SYS */ 69 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __CC_H__ 33 | #define __CC_H__ 34 | 35 | #include "cpu.h" 36 | 37 | typedef unsigned char u8_t; 38 | typedef signed char s8_t; 39 | typedef unsigned short u16_t; 40 | typedef signed short s16_t; 41 | typedef unsigned long u32_t; 42 | typedef signed long s32_t; 43 | typedef u32_t mem_ptr_t; 44 | /* typedef int sys_prot_t; */ 45 | 46 | 47 | 48 | /* define compiler specific symbols */ 49 | #if defined (__ICCARM__) 50 | 51 | #define PACK_STRUCT_BEGIN 52 | #define PACK_STRUCT_STRUCT 53 | #define PACK_STRUCT_END 54 | #define PACK_STRUCT_FIELD(x) x 55 | #define PACK_STRUCT_USE_INCLUDES 56 | 57 | #elif defined (__CC_ARM) 58 | 59 | #define PACK_STRUCT_BEGIN __packed 60 | #define PACK_STRUCT_STRUCT 61 | #define PACK_STRUCT_END 62 | #define PACK_STRUCT_FIELD(x) x 63 | 64 | #elif defined (__GNUC__) 65 | 66 | #define PACK_STRUCT_BEGIN 67 | #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) 68 | #define PACK_STRUCT_END 69 | #define PACK_STRUCT_FIELD(x) x 70 | 71 | #elif defined (__TASKING__) 72 | 73 | #define PACK_STRUCT_BEGIN 74 | #define PACK_STRUCT_STRUCT 75 | #define PACK_STRUCT_END 76 | #define PACK_STRUCT_FIELD(x) x 77 | 78 | #endif 79 | 80 | #define LWIP_PLATFORM_ASSERT(x) do { if(!(x)) while(1); } while(0) 81 | 82 | #endif /* __CC_H__ */ 83 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/arch/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __CPU_H__ 33 | #define __CPU_H__ 34 | 35 | #define BYTE_ORDER LITTLE_ENDIAN 36 | 37 | #endif /* __CPU_H__ */ 38 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __PERF_H__ 33 | #define __PERF_H__ 34 | 35 | #define PERF_START /* null definition */ 36 | #define PERF_STOP(x) /* null definition */ 37 | 38 | #endif /* __PERF_H__ */ 39 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv4/lwip/icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ICMP_H__ 33 | #define __LWIP_ICMP_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | #include "lwip/netif.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #define ICMP_ER 0 /* echo reply */ 45 | #define ICMP_DUR 3 /* destination unreachable */ 46 | #define ICMP_SQ 4 /* source quench */ 47 | #define ICMP_RD 5 /* redirect */ 48 | #define ICMP_ECHO 8 /* echo */ 49 | #define ICMP_TE 11 /* time exceeded */ 50 | #define ICMP_PP 12 /* parameter problem */ 51 | #define ICMP_TS 13 /* timestamp */ 52 | #define ICMP_TSR 14 /* timestamp reply */ 53 | #define ICMP_IRQ 15 /* information request */ 54 | #define ICMP_IR 16 /* information reply */ 55 | 56 | enum icmp_dur_type { 57 | ICMP_DUR_NET = 0, /* net unreachable */ 58 | ICMP_DUR_HOST = 1, /* host unreachable */ 59 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ 60 | ICMP_DUR_PORT = 3, /* port unreachable */ 61 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 62 | ICMP_DUR_SR = 5 /* source route failed */ 63 | }; 64 | 65 | enum icmp_te_type { 66 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ 67 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ 68 | }; 69 | 70 | #ifdef PACK_STRUCT_USE_INCLUDES 71 | # include "arch/bpstruct.h" 72 | #endif 73 | /** This is the standard ICMP header only that the u32_t data 74 | * is splitted to two u16_t like ICMP echo needs it. 75 | * This header is also used for other ICMP types that do not 76 | * use the data part. 77 | */ 78 | PACK_STRUCT_BEGIN 79 | struct icmp_echo_hdr { 80 | PACK_STRUCT_FIELD(u8_t type); 81 | PACK_STRUCT_FIELD(u8_t code); 82 | PACK_STRUCT_FIELD(u16_t chksum); 83 | PACK_STRUCT_FIELD(u16_t id); 84 | PACK_STRUCT_FIELD(u16_t seqno); 85 | } PACK_STRUCT_STRUCT; 86 | PACK_STRUCT_END 87 | #ifdef PACK_STRUCT_USE_INCLUDES 88 | # include "arch/epstruct.h" 89 | #endif 90 | 91 | #define ICMPH_TYPE(hdr) ((hdr)->type) 92 | #define ICMPH_CODE(hdr) ((hdr)->code) 93 | 94 | /** Combines type and code to an u16_t */ 95 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) 96 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) 97 | 98 | 99 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ 100 | 101 | void icmp_input(struct pbuf *p, struct netif *inp); 102 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); 103 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); 104 | 105 | #endif /* LWIP_ICMP */ 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | #endif /* __LWIP_ICMP_H__ */ 112 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv4/lwip/igmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 CITEL Technologies Ltd. 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 CITEL Technologies Ltd 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 CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' 18 | * AND 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 CITEL TECHNOLOGIES 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 a contribution to the lwIP TCP/IP stack. 30 | * The Swedish Institute of Computer Science and Adam Dunkels 31 | * are specifically granted permission to redistribute this 32 | * source code. 33 | */ 34 | 35 | #ifndef __LWIP_IGMP_H__ 36 | #define __LWIP_IGMP_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/ip_addr.h" 40 | #include "lwip/netif.h" 41 | #include "lwip/pbuf.h" 42 | 43 | #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | 50 | /* IGMP timer */ 51 | #define IGMP_TMR_INTERVAL 100 /* Milliseconds */ 52 | #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) 53 | #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) 54 | 55 | /* MAC Filter Actions, these are passed to a netif's 56 | * igmp_mac_filter callback function. */ 57 | #define IGMP_DEL_MAC_FILTER 0 58 | #define IGMP_ADD_MAC_FILTER 1 59 | 60 | 61 | /** 62 | * igmp group structure - there is 63 | * a list of groups for each interface 64 | * these should really be linked from the interface, but 65 | * if we keep them separate we will not affect the lwip original code 66 | * too much 67 | * 68 | * There will be a group for the all systems group address but this 69 | * will not run the state machine as it is used to kick off reports 70 | * from all the other groups 71 | */ 72 | struct igmp_group { 73 | /** next link */ 74 | struct igmp_group *next; 75 | /** interface on which the group is active */ 76 | struct netif *netif; 77 | /** multicast address */ 78 | ip_addr_t group_address; 79 | /** signifies we were the last person to report */ 80 | u8_t last_reporter_flag; 81 | /** current state of the group */ 82 | u8_t group_state; 83 | /** timer for reporting, negative is OFF */ 84 | u16_t timer; 85 | /** counter of simultaneous uses */ 86 | u8_t use; 87 | }; 88 | 89 | /* Prototypes */ 90 | void igmp_init(void); 91 | err_t igmp_start(struct netif *netif); 92 | err_t igmp_stop(struct netif *netif); 93 | void igmp_report_groups(struct netif *netif); 94 | struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); 95 | void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); 96 | err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); 97 | err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); 98 | void igmp_tmr(void); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* LWIP_IGMP */ 105 | 106 | #endif /* __LWIP_IGMP_H__ */ 107 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv4/lwip/inet_chksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INET_CHKSUM_H__ 33 | #define __LWIP_INET_CHKSUM_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #include "lwip/pbuf.h" 38 | #include "lwip/ip_addr.h" 39 | 40 | /** Swap the bytes in an u16_t: much like htons() for little-endian */ 41 | #ifndef SWAP_BYTES_IN_WORD 42 | #if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) 43 | /* little endian and PLATFORM_BYTESWAP defined */ 44 | #define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) 45 | #else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ 46 | /* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ 47 | #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) 48 | #endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ 49 | #endif /* SWAP_BYTES_IN_WORD */ 50 | 51 | /** Split an u32_t in two u16_ts and add them up */ 52 | #ifndef FOLD_U32T 53 | #define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) 54 | #endif 55 | 56 | #if LWIP_CHECKSUM_ON_COPY 57 | /** Function-like macro: same as MEMCPY but returns the checksum of copied data 58 | as u16_t */ 59 | #ifndef LWIP_CHKSUM_COPY 60 | #define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) 61 | #ifndef LWIP_CHKSUM_COPY_ALGORITHM 62 | #define LWIP_CHKSUM_COPY_ALGORITHM 1 63 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 64 | #endif /* LWIP_CHKSUM_COPY */ 65 | #else /* LWIP_CHECKSUM_ON_COPY */ 66 | #define LWIP_CHKSUM_COPY_ALGORITHM 0 67 | #endif /* LWIP_CHECKSUM_ON_COPY */ 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | u16_t inet_chksum(void *dataptr, u16_t len); 74 | u16_t inet_chksum_pbuf(struct pbuf *p); 75 | u16_t inet_chksum_pseudo(struct pbuf *p, 76 | ip_addr_t *src, ip_addr_t *dest, 77 | u8_t proto, u16_t proto_len); 78 | u16_t inet_chksum_pseudo_partial(struct pbuf *p, 79 | ip_addr_t *src, ip_addr_t *dest, 80 | u8_t proto, u16_t proto_len, u16_t chksum_len); 81 | #if LWIP_CHKSUM_COPY_ALGORITHM 82 | u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); 83 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* __LWIP_INET_H__ */ 90 | 91 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv4/lwip/ip_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Jani Monoses 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_IP_FRAG_H__ 34 | #define __LWIP_IP_FRAG_H__ 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/netif.h" 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/ip.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if IP_REASSEMBLY 48 | /* The IP reassembly timer interval in milliseconds. */ 49 | #define IP_TMR_INTERVAL 1000 50 | 51 | /* IP reassembly helper struct. 52 | * This is exported because memp needs to know the size. 53 | */ 54 | struct ip_reassdata { 55 | struct ip_reassdata *next; 56 | struct pbuf *p; 57 | struct ip_hdr iphdr; 58 | u16_t datagram_len; 59 | u8_t flags; 60 | u8_t timer; 61 | }; 62 | 63 | void ip_reass_init(void); 64 | void ip_reass_tmr(void); 65 | struct pbuf * ip_reass(struct pbuf *p); 66 | #endif /* IP_REASSEMBLY */ 67 | 68 | #if IP_FRAG 69 | #if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 70 | /** A custom pbuf that holds a reference to another pbuf, which is freed 71 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 72 | * that points into the original pbuf. */ 73 | struct pbuf_custom_ref { 74 | /** 'base class' */ 75 | struct pbuf_custom pc; 76 | /** pointer to the original pbuf that is referenced */ 77 | struct pbuf *original; 78 | }; 79 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 80 | 81 | err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest); 82 | #endif /* IP_FRAG */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __LWIP_IP_FRAG_H__ */ 89 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv6/lwip/icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ICMP_H__ 33 | #define __LWIP_ICMP_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/pbuf.h" 40 | #include "lwip/netif.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define ICMP6_DUR 1 47 | #define ICMP6_TE 3 48 | #define ICMP6_ECHO 128 /* echo */ 49 | #define ICMP6_ER 129 /* echo reply */ 50 | 51 | 52 | enum icmp_dur_type { 53 | ICMP_DUR_NET = 0, /* net unreachable */ 54 | ICMP_DUR_HOST = 1, /* host unreachable */ 55 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ 56 | ICMP_DUR_PORT = 3, /* port unreachable */ 57 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 58 | ICMP_DUR_SR = 5 /* source route failed */ 59 | }; 60 | 61 | enum icmp_te_type { 62 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ 63 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ 64 | }; 65 | 66 | void icmp_input(struct pbuf *p, struct netif *inp); 67 | 68 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); 69 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); 70 | 71 | struct icmp_echo_hdr { 72 | u8_t type; 73 | u8_t icode; 74 | u16_t chksum; 75 | u16_t id; 76 | u16_t seqno; 77 | }; 78 | 79 | struct icmp_dur_hdr { 80 | u8_t type; 81 | u8_t icode; 82 | u16_t chksum; 83 | u32_t unused; 84 | }; 85 | 86 | struct icmp_te_hdr { 87 | u8_t type; 88 | u8_t icode; 89 | u16_t chksum; 90 | u32_t unused; 91 | }; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_ICMP */ 98 | 99 | #endif /* __LWIP_ICMP_H__ */ 100 | 101 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv6/lwip/inet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INET_H__ 33 | #define __LWIP_INET_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | u16_t inet_chksum(void *data, u16_t len); 44 | u16_t inet_chksum_pbuf(struct pbuf *p); 45 | u16_t inet_chksum_pseudo(struct pbuf *p, 46 | struct ip_addr *src, struct ip_addr *dest, 47 | u8_t proto, u32_t proto_len); 48 | 49 | u32_t inet_addr(const char *cp); 50 | s8_t inet_aton(const char *cp, struct in_addr *addr); 51 | 52 | #ifndef _MACHINE_ENDIAN_H_ 53 | #ifndef _NETINET_IN_H 54 | #ifndef _LINUX_BYTEORDER_GENERIC_H 55 | u16_t htons(u16_t n); 56 | u16_t ntohs(u16_t n); 57 | u32_t htonl(u32_t n); 58 | u32_t ntohl(u32_t n); 59 | #endif /* _LINUX_BYTEORDER_GENERIC_H */ 60 | #endif /* _NETINET_IN_H */ 61 | #endif /* _MACHINE_ENDIAN_H_ */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __LWIP_INET_H__ */ 68 | 69 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/ipv6/lwip/ip_addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_IP_ADDR_H__ 33 | #define __LWIP_IP_ADDR_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #define IP_ADDR_ANY 0 42 | 43 | #ifdef PACK_STRUCT_USE_INCLUDES 44 | # include "arch/bpstruct.h" 45 | #endif 46 | PACK_STRUCT_BEGIN 47 | struct ip_addr { 48 | PACK_STRUCT_FIELD(u32_t addr[4]); 49 | } PACK_STRUCT_STRUCT; 50 | PACK_STRUCT_END 51 | #ifdef PACK_STRUCT_USE_INCLUDES 52 | # include "arch/epstruct.h" 53 | #endif 54 | 55 | /* 56 | * struct ipaddr2 is used in the definition of the ARP packet format in 57 | * order to support compilers that don't have structure packing. 58 | */ 59 | #ifdef PACK_STRUCT_USE_INCLUDES 60 | # include "arch/bpstruct.h" 61 | #endif 62 | PACK_STRUCT_BEGIN 63 | struct ip_addr2 { 64 | PACK_STRUCT_FIELD(u16_t addrw[2]); 65 | } PACK_STRUCT_STRUCT; 66 | PACK_STRUCT_END 67 | #ifdef PACK_STRUCT_USE_INCLUDES 68 | # include "arch/epstruct.h" 69 | #endif 70 | 71 | #define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)((a & 0xffff) << 16) | (b & 0xffff)); \ 72 | (ipaddr)->addr[1] = htonl(((c & 0xffff) << 16) | (d & 0xffff)); \ 73 | (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \ 74 | (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0) 75 | 76 | u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, 77 | struct ip_addr *mask); 78 | u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); 79 | void ip_addr_set(struct ip_addr *dest, struct ip_addr *src); 80 | u8_t ip_addr_isany(struct ip_addr *addr); 81 | 82 | #define ip_addr_debug_print(debug, ipaddr) \ 83 | LWIP_DEBUGF(debug, ("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F"\n", \ 84 | (ntohl(ipaddr->addr[0]) >> 16) & 0xffff, \ 85 | ntohl(ipaddr->addr[0]) & 0xffff, \ 86 | (ntohl(ipaddr->addr[1]) >> 16) & 0xffff, \ 87 | ntohl(ipaddr->addr[1]) & 0xffff, \ 88 | (ntohl(ipaddr->addr[2]) >> 16) & 0xffff, \ 89 | ntohl(ipaddr->addr[2]) & 0xffff, \ 90 | (ntohl(ipaddr->addr[3]) >> 16) & 0xffff, \ 91 | ntohl(ipaddr->addr[3]) & 0xffff)); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* __LWIP_IP_ADDR_H__ */ 98 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "lwip/arch.h" 36 | #include "lwip/opt.h" 37 | 38 | /** lower two bits indicate debug level 39 | * - 0 all 40 | * - 1 warning 41 | * - 2 serious 42 | * - 3 severe 43 | */ 44 | #define LWIP_DBG_LEVEL_ALL 0x00 45 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 46 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 47 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 48 | #define LWIP_DBG_LEVEL_SEVERE 0x03 49 | #define LWIP_DBG_MASK_LEVEL 0x03 50 | 51 | /** flag for LWIP_DEBUGF to enable that debug message */ 52 | #define LWIP_DBG_ON 0x80U 53 | /** flag for LWIP_DEBUGF to disable that debug message */ 54 | #define LWIP_DBG_OFF 0x00U 55 | 56 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 57 | #define LWIP_DBG_TRACE 0x40U 58 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 59 | #define LWIP_DBG_STATE 0x20U 60 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 61 | #define LWIP_DBG_FRESH 0x10U 62 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 63 | #define LWIP_DBG_HALT 0x08U 64 | 65 | #ifndef LWIP_NOASSERT 66 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 67 | LWIP_PLATFORM_ASSERT(message); } while(0) 68 | #else /* LWIP_NOASSERT */ 69 | #define LWIP_ASSERT(message, assertion) 70 | #endif /* LWIP_NOASSERT */ 71 | 72 | /** if "expression" isn't true, then print "message" and execute "handler" expression */ 73 | #ifndef LWIP_ERROR 74 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 75 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 76 | #endif /* LWIP_ERROR */ 77 | 78 | #ifdef LWIP_DEBUG 79 | /** print debug message only if debug message type is enabled... 80 | * AND is of correct type AND is at least LWIP_DBG_LEVEL 81 | */ 82 | #define LWIP_DEBUGF(debug, message) do { \ 83 | if ( \ 84 | ((debug) & LWIP_DBG_ON) && \ 85 | ((debug) & LWIP_DBG_TYPES_ON) && \ 86 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 87 | LWIP_PLATFORM_DIAG(message); \ 88 | if ((debug) & LWIP_DBG_HALT) { \ 89 | while(1); \ 90 | } \ 91 | } \ 92 | } while(0) 93 | 94 | #else /* LWIP_DEBUG */ 95 | #define LWIP_DEBUGF(debug, message) 96 | #endif /* LWIP_DEBUG */ 97 | 98 | #endif /* __LWIP_DEBUG_H__ */ 99 | 100 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEF_H__ 33 | #define __LWIP_DEF_H__ 34 | 35 | /* arch.h might define NULL already */ 36 | #include "lwip/arch.h" 37 | #include "lwip/opt.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) 44 | #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) 45 | 46 | #ifndef NULL 47 | #define NULL ((void *)0) 48 | #endif 49 | 50 | /* Endianess-optimized shifting of two u8_t to create one u16_t */ 51 | #if BYTE_ORDER == LITTLE_ENDIAN 52 | #define LWIP_MAKE_U16(a, b) ((a << 8) | b) 53 | #else 54 | #define LWIP_MAKE_U16(a, b) ((b << 8) | a) 55 | #endif 56 | 57 | #ifndef LWIP_PLATFORM_BYTESWAP 58 | #define LWIP_PLATFORM_BYTESWAP 0 59 | #endif 60 | 61 | #ifndef LWIP_PREFIX_BYTEORDER_FUNCS 62 | /* workaround for naming collisions on some platforms */ 63 | 64 | #ifdef htons 65 | #undef htons 66 | #endif /* htons */ 67 | #ifdef htonl 68 | #undef htonl 69 | #endif /* htonl */ 70 | #ifdef ntohs 71 | #undef ntohs 72 | #endif /* ntohs */ 73 | #ifdef ntohl 74 | #undef ntohl 75 | #endif /* ntohl */ 76 | 77 | #define htons(x) lwip_htons(x) 78 | #define ntohs(x) lwip_ntohs(x) 79 | #define htonl(x) lwip_htonl(x) 80 | #define ntohl(x) lwip_ntohl(x) 81 | #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ 82 | 83 | #if BYTE_ORDER == BIG_ENDIAN 84 | #define lwip_htons(x) (x) 85 | #define lwip_ntohs(x) (x) 86 | #define lwip_htonl(x) (x) 87 | #define lwip_ntohl(x) (x) 88 | #define PP_HTONS(x) (x) 89 | #define PP_NTOHS(x) (x) 90 | #define PP_HTONL(x) (x) 91 | #define PP_NTOHL(x) (x) 92 | #else /* BYTE_ORDER != BIG_ENDIAN */ 93 | #if LWIP_PLATFORM_BYTESWAP 94 | #define lwip_htons(x) LWIP_PLATFORM_HTONS(x) 95 | #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) 96 | #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) 97 | #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) 98 | #else /* LWIP_PLATFORM_BYTESWAP */ 99 | u16_t lwip_htons(u16_t x); 100 | u16_t lwip_ntohs(u16_t x); 101 | u32_t lwip_htonl(u32_t x); 102 | u32_t lwip_ntohl(u32_t x); 103 | #endif /* LWIP_PLATFORM_BYTESWAP */ 104 | 105 | /* These macros should be calculated by the preprocessor and are used 106 | with compile-time constants only (so that there is no little-endian 107 | overhead at runtime). */ 108 | #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) 109 | #define PP_NTOHS(x) PP_HTONS(x) 110 | #define PP_HTONL(x) ((((x) & 0xff) << 24) | \ 111 | (((x) & 0xff00) << 8) | \ 112 | (((x) & 0xff0000UL) >> 8) | \ 113 | (((x) & 0xff000000UL) >> 24)) 114 | #define PP_NTOHL(x) PP_HTONL(x) 115 | 116 | #endif /* BYTE_ORDER == BIG_ENDIAN */ 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __LWIP_DEF_H__ */ 123 | 124 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ERR_H__ 33 | #define __LWIP_ERR_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** Define LWIP_ERR_T in cc.h if you want to use 43 | * a different type for your platform (must be signed). */ 44 | #ifdef LWIP_ERR_T 45 | typedef LWIP_ERR_T err_t; 46 | #else /* LWIP_ERR_T */ 47 | typedef s8_t err_t; 48 | #endif /* LWIP_ERR_T*/ 49 | 50 | /* Definitions for error constants. */ 51 | 52 | #define ERR_OK 0 /* No error, everything OK. */ 53 | #define ERR_MEM -1 /* Out of memory error. */ 54 | #define ERR_BUF -2 /* Buffer error. */ 55 | #define ERR_TIMEOUT -3 /* Timeout. */ 56 | #define ERR_RTE -4 /* Routing problem. */ 57 | #define ERR_INPROGRESS -5 /* Operation in progress */ 58 | #define ERR_VAL -6 /* Illegal value. */ 59 | #define ERR_WOULDBLOCK -7 /* Operation would block. */ 60 | #define ERR_USE -8 /* Address in use. */ 61 | #define ERR_ISCONN -9 /* Already connected. */ 62 | 63 | #define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) 64 | 65 | #define ERR_ABRT -10 /* Connection aborted. */ 66 | #define ERR_RST -11 /* Connection reset. */ 67 | #define ERR_CLSD -12 /* Connection closed. */ 68 | #define ERR_CONN -13 /* Not connected. */ 69 | 70 | #define ERR_ARG -14 /* Illegal argument. */ 71 | 72 | #define ERR_IF -15 /* Low-level netif error */ 73 | 74 | 75 | #ifdef LWIP_DEBUG 76 | extern const char *lwip_strerr(err_t err); 77 | #else 78 | #define lwip_strerr(x) "" 79 | #endif /* LWIP_DEBUG */ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* __LWIP_ERR_H__ */ 86 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INIT_H__ 33 | #define __LWIP_INIT_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** X.x.x: Major version of the stack */ 42 | #define LWIP_VERSION_MAJOR 1U 43 | /** x.X.x: Minor version of the stack */ 44 | #define LWIP_VERSION_MINOR 4U 45 | /** x.x.X: Revision of the stack */ 46 | #define LWIP_VERSION_REVISION 1U 47 | /** For release candidates, this is set to 1..254 48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 49 | * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 50 | #define LWIP_VERSION_RC 255U 51 | 52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 53 | #define LWIP_RC_RELEASE 255U 54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ 55 | #define LWIP_RC_DEVELOPMENT 0U 56 | 57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 60 | 61 | /** Provides the version of the stack */ 62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ 63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) 64 | 65 | /* Modules initialization */ 66 | void lwip_init(void); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __LWIP_INIT_H__ */ 73 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/memp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_MEMP_H__ 34 | #define __LWIP_MEMP_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ 43 | typedef enum { 44 | #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, 45 | #include "lwip/memp_std.h" 46 | MEMP_MAX 47 | } memp_t; 48 | 49 | #if MEM_USE_POOLS 50 | /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ 51 | typedef enum { 52 | /* Get the first (via: 53 | MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ 54 | MEMP_POOL_HELPER_FIRST = ((u8_t) 55 | #define LWIP_MEMPOOL(name,num,size,desc) 56 | #define LWIP_MALLOC_MEMPOOL_START 1 57 | #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 58 | #define LWIP_MALLOC_MEMPOOL_END 59 | #include "lwip/memp_std.h" 60 | ) , 61 | /* Get the last (via: 62 | MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ 63 | MEMP_POOL_HELPER_LAST = ((u8_t) 64 | #define LWIP_MEMPOOL(name,num,size,desc) 65 | #define LWIP_MALLOC_MEMPOOL_START 66 | #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * 67 | #define LWIP_MALLOC_MEMPOOL_END 1 68 | #include "lwip/memp_std.h" 69 | ) 70 | } memp_pool_helper_t; 71 | 72 | /* The actual start and stop values are here (cast them over) 73 | We use this helper type and these defines so we can avoid using const memp_t values */ 74 | #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) 75 | #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) 76 | #endif /* MEM_USE_POOLS */ 77 | 78 | #if MEMP_MEM_MALLOC || MEM_USE_POOLS 79 | extern const u16_t memp_sizes[MEMP_MAX]; 80 | #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ 81 | 82 | #if MEMP_MEM_MALLOC 83 | 84 | #include "mem.h" 85 | 86 | #define memp_init() 87 | #define memp_malloc(type) mem_malloc(memp_sizes[type]) 88 | #define memp_free(type, mem) mem_free(mem) 89 | 90 | #else /* MEMP_MEM_MALLOC */ 91 | 92 | #if MEM_USE_POOLS 93 | /** This structure is used to save the pool one element came from. */ 94 | struct memp_malloc_helper 95 | { 96 | memp_t poolnr; 97 | }; 98 | #endif /* MEM_USE_POOLS */ 99 | 100 | void memp_init(void); 101 | 102 | #if MEMP_OVERFLOW_CHECK 103 | void *memp_malloc_fn(memp_t type, const char* file, const int line); 104 | #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) 105 | #else 106 | void *memp_malloc(memp_t type); 107 | #endif 108 | void memp_free(memp_t type, void *mem); 109 | 110 | #endif /* MEMP_MEM_MALLOC */ 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* __LWIP_MEMP_H__ */ 117 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/netbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_NETBUF_H__ 33 | #define __LWIP_NETBUF_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** This netbuf has dest-addr/port set */ 44 | #define NETBUF_FLAG_DESTADDR 0x01 45 | /** This netbuf includes a checksum */ 46 | #define NETBUF_FLAG_CHKSUM 0x02 47 | 48 | struct netbuf { 49 | struct pbuf *p, *ptr; 50 | ip_addr_t addr; 51 | u16_t port; 52 | #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY 53 | #if LWIP_CHECKSUM_ON_COPY 54 | u8_t flags; 55 | #endif /* LWIP_CHECKSUM_ON_COPY */ 56 | u16_t toport_chksum; 57 | #if LWIP_NETBUF_RECVINFO 58 | ip_addr_t toaddr; 59 | #endif /* LWIP_NETBUF_RECVINFO */ 60 | #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ 61 | }; 62 | 63 | /* Network buffer functions: */ 64 | struct netbuf * netbuf_new (void); 65 | void netbuf_delete (struct netbuf *buf); 66 | void * netbuf_alloc (struct netbuf *buf, u16_t size); 67 | void netbuf_free (struct netbuf *buf); 68 | err_t netbuf_ref (struct netbuf *buf, 69 | const void *dataptr, u16_t size); 70 | void netbuf_chain (struct netbuf *head, 71 | struct netbuf *tail); 72 | 73 | err_t netbuf_data (struct netbuf *buf, 74 | void **dataptr, u16_t *len); 75 | s8_t netbuf_next (struct netbuf *buf); 76 | void netbuf_first (struct netbuf *buf); 77 | 78 | 79 | #define netbuf_copy_partial(buf, dataptr, len, offset) \ 80 | pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) 81 | #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) 82 | #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) 83 | #define netbuf_len(buf) ((buf)->p->tot_len) 84 | #define netbuf_fromaddr(buf) (&((buf)->addr)) 85 | #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr) 86 | #define netbuf_fromport(buf) ((buf)->port) 87 | #if LWIP_NETBUF_RECVINFO 88 | #define netbuf_destaddr(buf) (&((buf)->toaddr)) 89 | #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr) 90 | #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) 91 | #endif /* LWIP_NETBUF_RECVINFO */ 92 | #if LWIP_CHECKSUM_ON_COPY 93 | #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ 94 | (buf)->toport_chksum = chksum; } while(0) 95 | #endif /* LWIP_CHECKSUM_ON_COPY */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __LWIP_NETBUF_H__ */ 102 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/netifapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Redistribution and use in source and binary forms, with or without modification, 3 | * are permitted provided that the following conditions are met: 4 | * 5 | * 1. Redistributions of source code must retain the above copyright notice, 6 | * this list of conditions and the following disclaimer. 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, 8 | * this list of conditions and the following disclaimer in the documentation 9 | * and/or other materials provided with the distribution. 10 | * 3. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | * OF SUCH DAMAGE. 23 | * 24 | * This file is part of the lwIP TCP/IP stack. 25 | * 26 | */ 27 | 28 | #ifndef __LWIP_NETIFAPI_H__ 29 | #define __LWIP_NETIFAPI_H__ 30 | 31 | #include "lwip/opt.h" 32 | 33 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ 34 | 35 | #include "lwip/sys.h" 36 | #include "lwip/netif.h" 37 | #include "lwip/dhcp.h" 38 | #include "lwip/autoip.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef void (*netifapi_void_fn)(struct netif *netif); 45 | typedef err_t (*netifapi_errt_fn)(struct netif *netif); 46 | 47 | struct netifapi_msg_msg { 48 | #if !LWIP_TCPIP_CORE_LOCKING 49 | sys_sem_t sem; 50 | #endif /* !LWIP_TCPIP_CORE_LOCKING */ 51 | err_t err; 52 | struct netif *netif; 53 | union { 54 | struct { 55 | ip_addr_t *ipaddr; 56 | ip_addr_t *netmask; 57 | ip_addr_t *gw; 58 | void *state; 59 | netif_init_fn init; 60 | netif_input_fn input; 61 | } add; 62 | struct { 63 | netifapi_void_fn voidfunc; 64 | netifapi_errt_fn errtfunc; 65 | } common; 66 | } msg; 67 | }; 68 | 69 | struct netifapi_msg { 70 | void (* function)(struct netifapi_msg_msg *msg); 71 | struct netifapi_msg_msg msg; 72 | }; 73 | 74 | 75 | /* API for application */ 76 | err_t netifapi_netif_add ( struct netif *netif, 77 | ip_addr_t *ipaddr, 78 | ip_addr_t *netmask, 79 | ip_addr_t *gw, 80 | void *state, 81 | netif_init_fn init, 82 | netif_input_fn input); 83 | 84 | err_t netifapi_netif_set_addr ( struct netif *netif, 85 | ip_addr_t *ipaddr, 86 | ip_addr_t *netmask, 87 | ip_addr_t *gw ); 88 | 89 | err_t netifapi_netif_common ( struct netif *netif, 90 | netifapi_void_fn voidfunc, 91 | netifapi_errt_fn errtfunc); 92 | 93 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) 94 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) 95 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) 96 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) 97 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) 98 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) 99 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) 100 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* LWIP_NETIF_API */ 107 | 108 | #endif /* __LWIP_NETIFAPI_H__ */ 109 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_RAW_H__ 33 | #define __LWIP_RAW_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/pbuf.h" 40 | #include "lwip/def.h" 41 | #include "lwip/ip.h" 42 | #include "lwip/ip_addr.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | struct raw_pcb; 49 | 50 | /** Function prototype for raw pcb receive callback functions. 51 | * @param arg user supplied argument (raw_pcb.recv_arg) 52 | * @param pcb the raw_pcb which received data 53 | * @param p the packet buffer that was received 54 | * @param addr the remote IP address from which the packet was received 55 | * @return 1 if the packet was 'eaten' (aka. deleted), 56 | * 0 if the packet lives on 57 | * If returning 1, the callback is responsible for freeing the pbuf 58 | * if it's not used any more. 59 | */ 60 | typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, 61 | ip_addr_t *addr); 62 | 63 | struct raw_pcb { 64 | /* Common members of all PCB types */ 65 | IP_PCB; 66 | 67 | struct raw_pcb *next; 68 | 69 | u8_t protocol; 70 | 71 | /** receive callback function */ 72 | raw_recv_fn recv; 73 | /* user-supplied argument for the recv callback */ 74 | void *recv_arg; 75 | }; 76 | 77 | /* The following functions is the application layer interface to the 78 | RAW code. */ 79 | struct raw_pcb * raw_new (u8_t proto); 80 | void raw_remove (struct raw_pcb *pcb); 81 | err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr); 82 | err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr); 83 | 84 | void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); 85 | err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr); 86 | err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); 87 | 88 | /* The following functions are the lower layer interface to RAW. */ 89 | u8_t raw_input (struct pbuf *p, struct netif *inp); 90 | #define raw_init() /* Compatibility define, not init needed. */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* LWIP_RAW */ 97 | 98 | #endif /* __LWIP_RAW_H__ */ 99 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/snmp_asn1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Abstract Syntax Notation One (ISO 8824, 8825) codec. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * Author: Christiaan Simons 33 | */ 34 | 35 | #ifndef __LWIP_SNMP_ASN1_H__ 36 | #define __LWIP_SNMP_ASN1_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/err.h" 40 | #include "lwip/pbuf.h" 41 | #include "lwip/snmp.h" 42 | 43 | #if LWIP_SNMP 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ 50 | #define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ 51 | #define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ 52 | 53 | #define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ 54 | #define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ 55 | 56 | /* universal tags */ 57 | #define SNMP_ASN1_INTEG 2 58 | #define SNMP_ASN1_OC_STR 4 59 | #define SNMP_ASN1_NUL 5 60 | #define SNMP_ASN1_OBJ_ID 6 61 | #define SNMP_ASN1_SEQ 16 62 | 63 | /* application specific (SNMP) tags */ 64 | #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ 65 | #define SNMP_ASN1_COUNTER 1 /* u32_t */ 66 | #define SNMP_ASN1_GAUGE 2 /* u32_t */ 67 | #define SNMP_ASN1_TIMETICKS 3 /* u32_t */ 68 | #define SNMP_ASN1_OPAQUE 4 /* octet string */ 69 | 70 | /* context specific (SNMP) tags */ 71 | #define SNMP_ASN1_PDU_GET_REQ 0 72 | #define SNMP_ASN1_PDU_GET_NEXT_REQ 1 73 | #define SNMP_ASN1_PDU_GET_RESP 2 74 | #define SNMP_ASN1_PDU_SET_REQ 3 75 | #define SNMP_ASN1_PDU_TRAP 4 76 | 77 | err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); 78 | err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); 79 | err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); 80 | err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); 81 | err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); 82 | err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); 83 | 84 | void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); 85 | void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); 86 | void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); 87 | void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); 88 | err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); 89 | err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); 90 | err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); 91 | err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); 92 | err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); 93 | err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* LWIP_SNMP */ 100 | 101 | #endif /* __LWIP_SNMP_ASN1_H__ */ 102 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwip/timers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * Simon Goldschmidt 31 | * 32 | */ 33 | #ifndef __LWIP_TIMERS_H__ 34 | #define __LWIP_TIMERS_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | /* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ 39 | #define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) 40 | 41 | #if LWIP_TIMERS 42 | 43 | #include "lwip/err.h" 44 | #if !NO_SYS 45 | #include "lwip/sys.h" 46 | #endif 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #ifndef LWIP_DEBUG_TIMERNAMES 53 | #ifdef LWIP_DEBUG 54 | #define LWIP_DEBUG_TIMERNAMES SYS_DEBUG 55 | #else /* LWIP_DEBUG */ 56 | #define LWIP_DEBUG_TIMERNAMES 0 57 | #endif /* LWIP_DEBUG*/ 58 | #endif 59 | 60 | /** Function prototype for a timeout callback function. Register such a function 61 | * using sys_timeout(). 62 | * 63 | * @param arg Additional argument to pass to the function - set up by sys_timeout() 64 | */ 65 | typedef void (* sys_timeout_handler)(void *arg); 66 | 67 | struct sys_timeo { 68 | struct sys_timeo *next; 69 | u32_t time; 70 | sys_timeout_handler h; 71 | void *arg; 72 | #if LWIP_DEBUG_TIMERNAMES 73 | const char* handler_name; 74 | #endif /* LWIP_DEBUG_TIMERNAMES */ 75 | }; 76 | 77 | void sys_timeouts_init(void); 78 | 79 | #if LWIP_DEBUG_TIMERNAMES 80 | void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); 81 | #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) 82 | #else /* LWIP_DEBUG_TIMERNAMES */ 83 | void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); 84 | #endif /* LWIP_DEBUG_TIMERNAMES */ 85 | 86 | void sys_untimeout(sys_timeout_handler handler, void *arg); 87 | #if NO_SYS 88 | void sys_check_timeouts(void); 89 | void sys_restart_timeouts(void); 90 | #else /* NO_SYS */ 91 | void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); 92 | #endif /* NO_SYS */ 93 | 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* LWIP_TIMERS */ 100 | #endif /* __LWIP_TIMERS_H__ */ 101 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwipopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Simon Goldschmidt 30 | * 31 | */ 32 | #ifndef __LWIPOPTS_H__ 33 | #define __LWIPOPTS_H__ 34 | 35 | /* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */ 36 | #define NO_SYS 1 37 | #define MEM_ALIGNMENT 4 38 | #define LWIP_RAW 1 39 | #define LWIP_NETCONN 0 40 | #define LWIP_SOCKET 0 41 | #define LWIP_DHCP 0 42 | #define LWIP_ICMP 1 43 | #define LWIP_UDP 1 44 | #define LWIP_TCP 1 45 | #define ETH_PAD_SIZE 0 46 | #define LWIP_IP_ACCEPT_UDP_PORT(p) ((p) == PP_NTOHS(67)) 47 | 48 | #define TCP_MSS (1500 /*mtu*/ - 20 /*iphdr*/ - 20 /*tcphhr*/) 49 | #define TCP_SND_BUF (2 * TCP_MSS) 50 | 51 | #define ETHARP_SUPPORT_STATIC_ENTRIES 1 52 | 53 | #define LWIP_HTTPD_CGI 1 54 | #define LWIP_HTTPD_SSI 1 55 | #define LWIP_HTTPD_SSI_INCLUDE_TAG 0 56 | 57 | #endif /* __LWIPOPTS_H__ */ 58 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/lwippools.h: -------------------------------------------------------------------------------- 1 | //#ifndef LWIPPOOLS_H 2 | //#define LWIPPOOLS_H 3 | 4 | LWIP_MALLOC_MEMPOOL_START 5 | LWIP_MALLOC_MEMPOOL(4, 256) 6 | LWIP_MALLOC_MEMPOOL(2, 512) 7 | LWIP_MALLOC_MEMPOOL(1, 1024) 8 | LWIP_MALLOC_MEMPOOL_END 9 | 10 | //#endif 11 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/netif/slipif.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 | */ 34 | #ifndef __NETIF_SLIPIF_H__ 35 | #define __NETIF_SLIPIF_H__ 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/netif.h" 39 | 40 | /** Set this to 1 to start a thread that blocks reading on the serial line 41 | * (using sio_read()). 42 | */ 43 | #ifndef SLIP_USE_RX_THREAD 44 | #define SLIP_USE_RX_THREAD !NO_SYS 45 | #endif 46 | 47 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 48 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 49 | * packets on a queue, which is fed into lwIP from slipif_poll(). 50 | * If disabled, slipif_poll() polls the serila line (using sio_tryread()). 51 | */ 52 | #ifndef SLIP_RX_FROM_ISR 53 | #define SLIP_RX_FROM_ISR 0 54 | #endif 55 | 56 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 57 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 58 | * If disabled, packets will be dropped if more than one packet is received. 59 | */ 60 | #ifndef SLIP_RX_QUEUE 61 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | err_t slipif_init(struct netif * netif); 69 | void slipif_poll(struct netif *netif); 70 | #if SLIP_RX_FROM_ISR 71 | void slipif_process_rxqueue(struct netif *netif); 72 | void slipif_received_byte(struct netif *netif, u8_t data); 73 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 74 | #endif /* SLIP_RX_FROM_ISR */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/posix/netdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/netdb.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/netdb.h" 34 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/include/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/FILES: -------------------------------------------------------------------------------- 1 | This directory contains generic network interface device drivers that 2 | do not contain any hardware or architecture specific code. The files 3 | are: 4 | 5 | etharp.c 6 | Implements the ARP (Address Resolution Protocol) over 7 | Ethernet. The code in this file should be used together with 8 | Ethernet device drivers. Note that this module has been 9 | largely made Ethernet independent so you should be able to 10 | adapt this for other link layers (such as Firewire). 11 | 12 | ethernetif.c 13 | An example of how an Ethernet device driver could look. This 14 | file can be used as a "skeleton" for developing new Ethernet 15 | network device drivers. It uses the etharp.c ARP code. 16 | 17 | loopif.c 18 | A "loopback" network interface driver. It requires configuration 19 | through the define LWIP_LOOPIF_MULTITHREADING (see opt.h). 20 | 21 | slipif.c 22 | A generic implementation of the SLIP (Serial Line IP) 23 | protocol. It requires a sio (serial I/O) module to work. 24 | 25 | ppp/ Point-to-Point Protocol stack 26 | The PPP stack has been ported from ucip (http://ucip.sourceforge.net). 27 | It matches quite well to pppd 2.3.1 (http://ppp.samba.org), although 28 | compared to that, it has some modifications for embedded systems and 29 | the source code has been reordered a bit. -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/auth.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * auth.h - PPP Authentication and phase control header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original derived from BSD pppd.h. 32 | *****************************************************************************/ 33 | /* 34 | * pppd.h - PPP daemon global declarations. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | * 51 | */ 52 | 53 | #ifndef AUTH_H 54 | #define AUTH_H 55 | 56 | /*********************** 57 | *** PUBLIC FUNCTIONS *** 58 | ***********************/ 59 | 60 | /* we are starting to use the link */ 61 | void link_required (int); 62 | 63 | /* we are finished with the link */ 64 | void link_terminated (int); 65 | 66 | /* the LCP layer has left the Opened state */ 67 | void link_down (int); 68 | 69 | /* the link is up; authenticate now */ 70 | void link_established (int); 71 | 72 | /* a network protocol has come up */ 73 | void np_up (int, u16_t); 74 | 75 | /* a network protocol has gone down */ 76 | void np_down (int, u16_t); 77 | 78 | /* a network protocol no longer needs link */ 79 | void np_finished (int, u16_t); 80 | 81 | /* peer failed to authenticate itself */ 82 | void auth_peer_fail (int, u16_t); 83 | 84 | /* peer successfully authenticated itself */ 85 | void auth_peer_success (int, u16_t, char *, int); 86 | 87 | /* we failed to authenticate ourselves */ 88 | void auth_withpeer_fail (int, u16_t); 89 | 90 | /* we successfully authenticated ourselves */ 91 | void auth_withpeer_success (int, u16_t); 92 | 93 | /* check authentication options supplied */ 94 | void auth_check_options (void); 95 | 96 | /* check what secrets we have */ 97 | void auth_reset (int); 98 | 99 | /* Check peer-supplied username/password */ 100 | u_char check_passwd (int, char *, int, char *, int, char **, int *); 101 | 102 | /* get "secret" for chap */ 103 | int get_secret (int, char *, char *, char *, int *, int); 104 | 105 | /* check if IP address is authorized */ 106 | int auth_ip_addr (int, u32_t); 107 | 108 | /* check if IP address is unreasonable */ 109 | int bad_ip_adrs (u32_t); 110 | 111 | #endif /* AUTH_H */ 112 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/chpms.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * chpms.h - Network Microsoft Challenge Handshake Protocol header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 98-01-30 Guy Lancaster , Global Election Systems Inc. 31 | * Original built from BSD network code. 32 | ******************************************************************************/ 33 | /* 34 | * chap.h - Challenge Handshake Authentication Protocol definitions. 35 | * 36 | * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. 37 | * http://www.strataware.com/ 38 | * 39 | * All rights reserved. 40 | * 41 | * Redistribution and use in source and binary forms are permitted 42 | * provided that the above copyright notice and this paragraph are 43 | * duplicated in all such forms and that any documentation, 44 | * advertising materials, and other materials related to such 45 | * distribution and use acknowledge that the software was developed 46 | * by Eric Rosenquist. The name of the author may not be used to 47 | * endorse or promote products derived from this software without 48 | * specific prior written permission. 49 | * 50 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 51 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 52 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 53 | * 54 | * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $ 55 | */ 56 | 57 | #ifndef CHPMS_H 58 | #define CHPMS_H 59 | 60 | #define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ 61 | 62 | void ChapMS (chap_state *, char *, int, char *, int); 63 | 64 | #endif /* CHPMS_H */ 65 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/magic.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * magic.c - Network Random Number Generator program file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1997 by Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original based on BSD magic.c. 32 | *****************************************************************************/ 33 | /* 34 | * magic.c - PPP Magic Number routines. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | */ 51 | 52 | #include "lwip/opt.h" 53 | 54 | #if PPP_SUPPORT 55 | 56 | #include "ppp_impl.h" 57 | #include "randm.h" 58 | #include "magic.h" 59 | 60 | 61 | /* 62 | * magicInit - Initialize the magic number generator. 63 | * 64 | * Since we use another random number generator that has its own 65 | * initialization, we do nothing here. 66 | */ 67 | void magicInit() 68 | { 69 | return; 70 | } 71 | 72 | /* 73 | * magic - Returns the next magic number. 74 | */ 75 | u32_t magic() 76 | { 77 | return avRandom(); 78 | } 79 | 80 | #endif /* PPP_SUPPORT */ 81 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/magic.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * magic.h - Network Random Number Generator header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1997 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc. 31 | * Original derived from BSD codes. 32 | *****************************************************************************/ 33 | /* 34 | * magic.h - PPP Magic Number definitions. 35 | * 36 | * Copyright (c) 1989 Carnegie Mellon University. 37 | * All rights reserved. 38 | * 39 | * Redistribution and use in source and binary forms are permitted 40 | * provided that the above copyright notice and this paragraph are 41 | * duplicated in all such forms and that any documentation, 42 | * advertising materials, and other materials related to such 43 | * distribution and use acknowledge that the software was developed 44 | * by Carnegie Mellon University. The name of the 45 | * University may not be used to endorse or promote products derived 46 | * from this software without specific prior written permission. 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 50 | * 51 | * $Id: magic.h,v 1.3 2010/01/18 20:49:43 goldsimon Exp $ 52 | */ 53 | 54 | #ifndef MAGIC_H 55 | #define MAGIC_H 56 | 57 | /* Initialize the magic number generator */ 58 | void magicInit(void); 59 | 60 | /* Returns the next magic number */ 61 | u32_t magic(void); 62 | 63 | #endif /* MAGIC_H */ 64 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | *********************************************************************** 3 | ** md5.h -- header file for implementation of MD5 ** 4 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** 5 | ** Created: 2/17/90 RLR ** 6 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** 7 | ** Revised (for MD5): RLR 4/27/91 ** 8 | ** -- G modified to have y&~z instead of y&z ** 9 | ** -- FF, GG, HH modified to add in last register done ** 10 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** 11 | ** -- distinct additive constant for each step ** 12 | ** -- round 4 added, working mod 7 ** 13 | *********************************************************************** 14 | */ 15 | 16 | /* 17 | *********************************************************************** 18 | ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** 19 | ** ** 20 | ** License to copy and use this software is granted provided that ** 21 | ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** 22 | ** Digest Algorithm" in all material mentioning or referencing this ** 23 | ** software or this function. ** 24 | ** ** 25 | ** License is also granted to make and use derivative works ** 26 | ** provided that such works are identified as "derived from the RSA ** 27 | ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** 28 | ** material mentioning or referencing the derived work. ** 29 | ** ** 30 | ** RSA Data Security, Inc. makes no representations concerning ** 31 | ** either the merchantability of this software or the suitability ** 32 | ** of this software for any particular purpose. It is provided "as ** 33 | ** is" without express or implied warranty of any kind. ** 34 | ** ** 35 | ** These notices must be retained in any copies of any part of this ** 36 | ** documentation and/or software. ** 37 | *********************************************************************** 38 | */ 39 | 40 | #ifndef MD5_H 41 | #define MD5_H 42 | 43 | /* Data structure for MD5 (Message-Digest) computation */ 44 | typedef struct { 45 | u32_t i[2]; /* number of _bits_ handled mod 2^64 */ 46 | u32_t buf[4]; /* scratch buffer */ 47 | unsigned char in[64]; /* input buffer */ 48 | unsigned char digest[16]; /* actual digest after MD5Final call */ 49 | } MD5_CTX; 50 | 51 | void MD5Init ( MD5_CTX *mdContext); 52 | void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); 53 | void MD5Final ( unsigned char hash[], MD5_CTX *mdContext); 54 | 55 | #endif /* MD5_H */ 56 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/pppdebug.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pppdebug.h - System debugging utilities. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * portions Copyright (c) 1998 Global Election Systems Inc. 6 | * portions Copyright (c) 2001 by Cognizant Pty Ltd. 7 | * 8 | * The authors hereby grant permission to use, copy, modify, distribute, 9 | * and license this software and its documentation for any purpose, provided 10 | * that existing copyright notices are retained in all copies and that this 11 | * notice and the following disclaimer are included verbatim in any 12 | * distributions. No written agreement, license, or royalty fee is required 13 | * for any of the authorized uses. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | ****************************************************************************** 27 | * REVISION HISTORY (please don't use tabs!) 28 | * 29 | * 03-01-01 Marc Boucher 30 | * Ported to lwIP. 31 | * 98-07-29 Guy Lancaster , Global Election Systems Inc. 32 | * Original. 33 | * 34 | ***************************************************************************** 35 | */ 36 | #ifndef PPPDEBUG_H 37 | #define PPPDEBUG_H 38 | 39 | /* Trace levels. */ 40 | #define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 41 | #define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 42 | #define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 43 | #define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 44 | #define LOG_INFO (PPP_DEBUG) 45 | #define LOG_DETAIL (PPP_DEBUG) 46 | #define LOG_DEBUG (PPP_DEBUG) 47 | 48 | 49 | #define TRACELCP PPP_DEBUG 50 | 51 | #if PPP_DEBUG 52 | 53 | #define AUTHDEBUG(a, b) LWIP_DEBUGF(a, b) 54 | #define IPCPDEBUG(a, b) LWIP_DEBUGF(a, b) 55 | #define UPAPDEBUG(a, b) LWIP_DEBUGF(a, b) 56 | #define LCPDEBUG(a, b) LWIP_DEBUGF(a, b) 57 | #define FSMDEBUG(a, b) LWIP_DEBUGF(a, b) 58 | #define CHAPDEBUG(a, b) LWIP_DEBUGF(a, b) 59 | #define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) 60 | 61 | #else /* PPP_DEBUG */ 62 | 63 | #define AUTHDEBUG(a, b) 64 | #define IPCPDEBUG(a, b) 65 | #define UPAPDEBUG(a, b) 66 | #define LCPDEBUG(a, b) 67 | #define FSMDEBUG(a, b) 68 | #define CHAPDEBUG(a, b) 69 | #define PPPDEBUG(a, b) 70 | 71 | #endif /* PPP_DEBUG */ 72 | 73 | #endif /* PPPDEBUG_H */ 74 | -------------------------------------------------------------------------------- /lwip-1.4.1/src/netif/ppp/randm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * randm.h - Random number generator header file. 3 | * 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 5 | * Copyright (c) 1998 Global Election Systems Inc. 6 | * 7 | * The authors hereby grant permission to use, copy, modify, distribute, 8 | * and license this software and its documentation for any purpose, provided 9 | * that existing copyright notices are retained in all copies and that this 10 | * notice and the following disclaimer are included verbatim in any 11 | * distributions. No written agreement, license, or royalty fee is required 12 | * for any of the authorized uses. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | ****************************************************************************** 26 | * REVISION HISTORY 27 | * 28 | * 03-01-01 Marc Boucher 29 | * Ported to lwIP. 30 | * 98-05-29 Guy Lancaster , Global Election Systems Inc. 31 | * Extracted from avos. 32 | *****************************************************************************/ 33 | 34 | #ifndef RANDM_H 35 | #define RANDM_H 36 | 37 | /*********************** 38 | *** PUBLIC FUNCTIONS *** 39 | ***********************/ 40 | /* 41 | * Initialize the random number generator. 42 | */ 43 | void avRandomInit(void); 44 | 45 | /* 46 | * Churn the randomness pool on a random event. Call this early and often 47 | * on random and semi-random system events to build randomness in time for 48 | * usage. For randomly timed events, pass a null pointer and a zero length 49 | * and this will use the system timer and other sources to add randomness. 50 | * If new random data is available, pass a pointer to that and it will be 51 | * included. 52 | */ 53 | void avChurnRand(char *randData, u32_t randLen); 54 | 55 | /* 56 | * Randomize our random seed value. To be called for truely random events 57 | * such as user operations and network traffic. 58 | */ 59 | #if MD5_SUPPORT 60 | #define avRandomize() avChurnRand(NULL, 0) 61 | #else /* MD5_SUPPORT */ 62 | void avRandomize(void); 63 | #endif /* MD5_SUPPORT */ 64 | 65 | /* 66 | * Use the random pool to generate random data. This degrades to pseudo 67 | * random when used faster than randomness is supplied using churnRand(). 68 | * Thus it's important to make sure that the results of this are not 69 | * published directly because one could predict the next result to at 70 | * least some degree. Also, it's important to get a good seed before 71 | * the first use. 72 | */ 73 | void avGenRand(char *buf, u32_t bufLen); 74 | 75 | /* 76 | * Return a new random number. 77 | */ 78 | u32_t avRandom(void); 79 | 80 | 81 | #endif /* RANDM_H */ 82 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/core/test_mem.c: -------------------------------------------------------------------------------- 1 | #include "test_mem.h" 2 | 3 | #include "lwip/mem.h" 4 | #include "lwip/stats.h" 5 | 6 | #if !LWIP_STATS || !MEM_STATS 7 | #error "This tests needs MEM-statistics enabled" 8 | #endif 9 | #if LWIP_DNS 10 | #error "This test needs DNS turned off (as it mallocs on init)" 11 | #endif 12 | 13 | /* Setups/teardown functions */ 14 | 15 | static void 16 | mem_setup(void) 17 | { 18 | } 19 | 20 | static void 21 | mem_teardown(void) 22 | { 23 | } 24 | 25 | 26 | /* Test functions */ 27 | 28 | /** Call mem_malloc, mem_free and mem_trim and check stats */ 29 | START_TEST(test_mem_one) 30 | { 31 | #define SIZE1 16 32 | #define SIZE1_2 12 33 | #define SIZE2 16 34 | void *p1, *p2; 35 | mem_size_t s1, s2; 36 | LWIP_UNUSED_ARG(_i); 37 | 38 | #if LWIP_DNS 39 | fail("This test needs DNS turned off (as it mallocs on init)"); 40 | #endif 41 | 42 | fail_unless(lwip_stats.mem.used == 0); 43 | 44 | p1 = mem_malloc(SIZE1); 45 | fail_unless(p1 != NULL); 46 | fail_unless(lwip_stats.mem.used >= SIZE1); 47 | s1 = lwip_stats.mem.used; 48 | 49 | p2 = mem_malloc(SIZE2); 50 | fail_unless(p2 != NULL); 51 | fail_unless(lwip_stats.mem.used >= SIZE2 + s1); 52 | s2 = lwip_stats.mem.used; 53 | 54 | mem_trim(p1, SIZE1_2); 55 | 56 | mem_free(p2); 57 | fail_unless(lwip_stats.mem.used <= s2 - SIZE2); 58 | 59 | mem_free(p1); 60 | fail_unless(lwip_stats.mem.used == 0); 61 | } 62 | END_TEST 63 | 64 | 65 | /** Create the suite including all tests for this module */ 66 | Suite * 67 | mem_suite(void) 68 | { 69 | TFun tests[] = { 70 | test_mem_one 71 | }; 72 | return create_suite("MEM", tests, sizeof(tests)/sizeof(TFun), mem_setup, mem_teardown); 73 | } 74 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/core/test_mem.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_MEM_H__ 2 | #define __TEST_MEM_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *mem_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/etharp/test_etharp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_ETHARP_H__ 2 | #define __TEST_ETHARP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* etharp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/lwip_check.h: -------------------------------------------------------------------------------- 1 | #ifndef __LWIP_CHECK_H__ 2 | #define __LWIP_CHECK_H__ 3 | 4 | /* Common header file for lwIP unit tests using the check framework */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define FAIL_RET() do { fail(); return; } while(0) 11 | #define EXPECT(x) fail_unless(x) 12 | #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0) 13 | #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) 14 | #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) 15 | 16 | /** typedef for a function returning a test suite */ 17 | typedef Suite* (suite_getter_fn)(void); 18 | 19 | /** Create a test suite */ 20 | static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown) 21 | { 22 | size_t i; 23 | Suite *s = suite_create(name); 24 | 25 | for(i = 0; i < num_tests; i++) { 26 | /* Core test case */ 27 | TCase *tc_core = tcase_create("Core"); 28 | if ((setup != NULL) || (teardown != NULL)) { 29 | tcase_add_checked_fixture(tc_core, setup, teardown); 30 | } 31 | tcase_add_test(tc_core, tests[i]); 32 | suite_add_tcase(s, tc_core); 33 | } 34 | return s; 35 | } 36 | 37 | #endif /* __LWIP_CHECK_H__ */ 38 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/lwip_unittests.c: -------------------------------------------------------------------------------- 1 | #include "lwip_check.h" 2 | 3 | #include "udp/test_udp.h" 4 | #include "tcp/test_tcp.h" 5 | #include "tcp/test_tcp_oos.h" 6 | #include "core/test_mem.h" 7 | #include "etharp/test_etharp.h" 8 | 9 | #include "lwip/init.h" 10 | 11 | 12 | int main() 13 | { 14 | int number_failed; 15 | SRunner *sr; 16 | size_t i; 17 | suite_getter_fn* suites[] = { 18 | udp_suite, 19 | tcp_suite, 20 | tcp_oos_suite, 21 | mem_suite, 22 | etharp_suite 23 | }; 24 | size_t num = sizeof(suites)/sizeof(void*); 25 | LWIP_ASSERT("No suites defined", num > 0); 26 | 27 | lwip_init(); 28 | 29 | sr = srunner_create((suites[0])()); 30 | for(i = 1; i < num; i++) { 31 | srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); 32 | } 33 | 34 | #ifdef LWIP_UNITTESTS_NOFORK 35 | srunner_set_fork_status(sr, CK_NOFORK); 36 | #endif 37 | #ifdef LWIP_UNITTESTS_FORK 38 | srunner_set_fork_status(sr, CK_FORK); 39 | #endif 40 | 41 | srunner_run_all(sr, CK_NORMAL); 42 | number_failed = srunner_ntests_failed(sr); 43 | srunner_free(sr); 44 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 45 | } 46 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/lwipopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Simon Goldschmidt 30 | * 31 | */ 32 | #ifndef __LWIPOPTS_H__ 33 | #define __LWIPOPTS_H__ 34 | 35 | /* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */ 36 | #define NO_SYS 1 37 | #define LWIP_NETCONN 0 38 | #define LWIP_SOCKET 0 39 | 40 | /* Minimal changes to opt.h required for tcp unit tests: */ 41 | #define MEM_SIZE 16000 42 | #define TCP_SND_QUEUELEN 40 43 | #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN 44 | #define TCP_SND_BUF (12 * TCP_MSS) 45 | #define TCP_WND (10 * TCP_MSS) 46 | 47 | /* Minimal changes to opt.h required for etharp unit tests: */ 48 | #define ETHARP_SUPPORT_STATIC_ENTRIES 1 49 | 50 | #endif /* __LWIPOPTS_H__ */ 51 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/tcp/tcp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCP_HELPER_H__ 2 | #define __TCP_HELPER_H__ 3 | 4 | #include "../lwip_check.h" 5 | #include "lwip/arch.h" 6 | #include "lwip/tcp.h" 7 | #include "lwip/netif.h" 8 | 9 | /* counters used for test_tcp_counters_* callback functions */ 10 | struct test_tcp_counters { 11 | u32_t recv_calls; 12 | u32_t recved_bytes; 13 | u32_t recv_calls_after_close; 14 | u32_t recved_bytes_after_close; 15 | u32_t close_calls; 16 | u32_t err_calls; 17 | err_t last_err; 18 | char* expected_data; 19 | u32_t expected_data_len; 20 | }; 21 | 22 | struct test_tcp_txcounters { 23 | u32_t num_tx_calls; 24 | u32_t num_tx_bytes; 25 | u8_t copy_tx_packets; 26 | struct pbuf *tx_packets; 27 | }; 28 | 29 | /* Helper functions */ 30 | void tcp_remove_all(void); 31 | 32 | struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, 33 | u16_t src_port, u16_t dst_port, void* data, size_t data_len, 34 | u32_t seqno, u32_t ackno, u8_t headerflags); 35 | struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, 36 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags); 37 | struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, 38 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd); 39 | void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, 40 | ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port); 41 | void test_tcp_counters_err(void* arg, err_t err); 42 | err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); 43 | 44 | struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters); 45 | 46 | void test_tcp_input(struct pbuf *p, struct netif *inp); 47 | 48 | void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, 49 | ip_addr_t *ip_addr, ip_addr_t *netmask); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/tcp/test_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_TCP_H__ 2 | #define __TEST_TCP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/tcp/test_tcp_oos.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_TCP_OOS_H__ 2 | #define __TEST_TCP_OOS_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_oos_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/udp/test_udp.c: -------------------------------------------------------------------------------- 1 | #include "test_udp.h" 2 | 3 | #include "lwip/udp.h" 4 | #include "lwip/stats.h" 5 | 6 | #if !LWIP_STATS || !UDP_STATS || !MEMP_STATS 7 | #error "This tests needs UDP- and MEMP-statistics enabled" 8 | #endif 9 | 10 | /* Helper functions */ 11 | static void 12 | udp_remove_all(void) 13 | { 14 | struct udp_pcb *pcb = udp_pcbs; 15 | struct udp_pcb *pcb2; 16 | 17 | while(pcb != NULL) { 18 | pcb2 = pcb; 19 | pcb = pcb->next; 20 | udp_remove(pcb2); 21 | } 22 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); 23 | } 24 | 25 | /* Setups/teardown functions */ 26 | 27 | static void 28 | udp_setup(void) 29 | { 30 | udp_remove_all(); 31 | } 32 | 33 | static void 34 | udp_teardown(void) 35 | { 36 | udp_remove_all(); 37 | } 38 | 39 | 40 | /* Test functions */ 41 | 42 | START_TEST(test_udp_new_remove) 43 | { 44 | struct udp_pcb* pcb; 45 | LWIP_UNUSED_ARG(_i); 46 | 47 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); 48 | 49 | pcb = udp_new(); 50 | fail_unless(pcb != NULL); 51 | if (pcb != NULL) { 52 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 1); 53 | udp_remove(pcb); 54 | fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0); 55 | } 56 | } 57 | END_TEST 58 | 59 | 60 | /** Create the suite including all tests for this module */ 61 | Suite * 62 | udp_suite(void) 63 | { 64 | TFun tests[] = { 65 | test_udp_new_remove, 66 | }; 67 | return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown); 68 | } 69 | -------------------------------------------------------------------------------- /lwip-1.4.1/test/unit/udp/test_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_UDP_H__ 2 | #define __TEST_UDP_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* udp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /stm32f0xx_hal_helper.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file 4 | * @author MCD Application Team 5 | * @version 6 | * @date 7 | * @brief 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | #include "stm32f0xx.h" 29 | #include "stm32f0xx_hal.h" 30 | 31 | void SystemClock_Config(void) 32 | { 33 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 34 | RCC_OscInitTypeDef RCC_OscInitStruct; 35 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; 36 | static RCC_CRSInitTypeDef RCC_CRSInitStruct; 37 | 38 | /* Enable HSI48 Oscillator to be used as system clock source */ 39 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48; 40 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 41 | 42 | /* Select HSI48 as USB clock source */ 43 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; 44 | PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; 45 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); 46 | 47 | /* Select HSI48 as system clock source and configure the HCLK and PCLK1 clock dividers */ 48 | RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1); 49 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48; 50 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 51 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 52 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); 53 | 54 | /*Configure the clock recovery system (CRS)**********************************/ 55 | 56 | /*Enable CRS Clock*/ 57 | __CRS_CLK_ENABLE(); 58 | 59 | /* Default Synchro Signal division factor (not divided) */ 60 | RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1; 61 | 62 | /* Set the SYNCSRC[1:0] bits according to CRS_Source value */ 63 | RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB; 64 | 65 | /* HSI48 is synchronized with USB SOF at 1KHz rate */ 66 | RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_CALCULATE_RELOADVALUE(48000000, 1000); 67 | RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT; 68 | 69 | /* Set the TRIM[5:0] to the default value*/ 70 | RCC_CRSInitStruct.HSI48CalibrationValue = 0x20; 71 | 72 | /* Start automatic synchronization */ 73 | HAL_RCCEx_CRSConfig (&RCC_CRSInitStruct); 74 | } 75 | 76 | #ifdef USE_FULL_ASSERT 77 | /** 78 | * @brief Reports the name of the source file and the source line number 79 | * where the assert_param error has occurred. 80 | * @param file: pointer to the source file name 81 | * @param line: assert_param error line source number 82 | * @retval None 83 | */ 84 | void assert_failed(uint8_t* file, uint32_t line) 85 | { 86 | __BKPT(); 87 | /* User can add his own implementation to report the file name and line number, 88 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 89 | 90 | /* Infinite loop */ 91 | while (1) 92 | { 93 | } 94 | } 95 | #endif 96 | -------------------------------------------------------------------------------- /stm32f0xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @version V1.2.1 6 | * @date 09-January-2015 7 | * @brief Header file of PCD HAL Extension module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2015 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32L0xx_HAL_PCD_EX_H 40 | #define __STM32L0xx_HAL_PCD_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx)|| defined(STM32F070xB)|| defined(STM32F070x6) 47 | 48 | /* Includes ------------------------------------------------------------------*/ 49 | #include "stm32f0xx_hal_def.h" 50 | 51 | /** @addtogroup STM32F0xx_HAL_Driver 52 | * @{ 53 | */ 54 | 55 | /** @addtogroup PCDEx 56 | * @{ 57 | */ 58 | 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* Exported constants --------------------------------------------------------*/ 61 | /* Exported macros -----------------------------------------------------------*/ 62 | /* Internal macros -----------------------------------------------------------*/ 63 | /* Exported functions --------------------------------------------------------*/ 64 | 65 | /** @addtogroup PCDEx_Exported_Functions 66 | * @{ 67 | */ 68 | 69 | /** @addtogroup PCDEx_Exported_Functions_Group2 70 | * @{ 71 | */ 72 | 73 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 74 | uint16_t ep_addr, 75 | uint16_t ep_kind, 76 | uint32_t pmaadress); 77 | /** 78 | * @} 79 | */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6*/ 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | 100 | #endif /* __STM32F0xx_HAL_PCD_EX_H */ 101 | 102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 103 | 104 | -------------------------------------------------------------------------------- /stm32f0xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USB_Device/HID_Standalone/Src/stm32f0xx_it.c 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-June-2014 7 | * @brief Main Interrupt Service Routines. 8 | * This file provides template for all exceptions handler and 9 | * peripherals interrupt service routine. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© COPYRIGHT(c) 2014 STMicroelectronics

14 | * 15 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 16 | * You may not use this file except in compliance with the License. 17 | * You may obtain a copy of the License at: 18 | * 19 | * http://www.st.com/software_license_agreement_liberty_v2 20 | * 21 | * Unless required by applicable law or agreed to in writing, software 22 | * distributed under the License is distributed on an "AS IS" BASIS, 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | * See the License for the specific language governing permissions and 25 | * limitations under the License. 26 | * 27 | ****************************************************************************** 28 | */ 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "usbd_core.h" 32 | #include "stm32f0xx_it.h" 33 | 34 | /* Private typedef -----------------------------------------------------------*/ 35 | /* Private define ------------------------------------------------------------*/ 36 | /* Private macro -------------------------------------------------------------*/ 37 | /* Private variables ---------------------------------------------------------*/ 38 | extern PCD_HandleTypeDef hpcd; 39 | extern USBD_HandleTypeDef USBD_Device; 40 | 41 | /* Private function prototypes -----------------------------------------------*/ 42 | /* Private functions ---------------------------------------------------------*/ 43 | 44 | /******************************************************************************/ 45 | /* Cortex-M0 Processor Exceptions Handlers */ 46 | /******************************************************************************/ 47 | 48 | /** 49 | * @brief This function handles NMI exception. 50 | * @param None 51 | * @retval None 52 | */ 53 | void NMI_Handler(void) 54 | { 55 | } 56 | 57 | /** 58 | * @brief This function handles Hard Fault exception. 59 | * @param None 60 | * @retval None 61 | */ 62 | void HardFault_Handler(void) 63 | { 64 | /* Go to infinite loop when Hard Fault exception occurs */ 65 | while (1) 66 | { 67 | } 68 | } 69 | 70 | 71 | /** 72 | * @brief This function handles SVCall exception. 73 | * @param None 74 | * @retval None 75 | */ 76 | void SVC_Handler(void) 77 | { 78 | } 79 | 80 | 81 | /** 82 | * @brief This function handles PendSVC exception. 83 | * @param None 84 | * @retval None 85 | */ 86 | void PendSV_Handler(void) 87 | { 88 | } 89 | 90 | #if 0 // provided by time.c 91 | /** 92 | * @brief This function handles SysTick Handler. 93 | * @param None 94 | * @retval None 95 | */ 96 | void SysTick_Handler(void) 97 | { 98 | HAL_IncTick(); 99 | } 100 | #endif 101 | 102 | /******************************************************************************/ 103 | /* STM32F0xx Peripherals Interrupt Handlers */ 104 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 105 | /* available peripheral interrupt handler's name please refer to the startup */ 106 | /* file (startup_stm32f0xx.s). */ 107 | /******************************************************************************/ 108 | 109 | /** 110 | * @brief This function handles USB Handler. 111 | * @param None 112 | * @retval None 113 | */ 114 | void USB_IRQHandler(void) 115 | { 116 | HAL_PCD_IRQHandler(&hpcd); 117 | } 118 | 119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /stm32f0xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USB_Device/HID_Standalone/Inc/stm32f0xx_it.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-June-2014 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F0xx_IT_H 30 | #define __STM32F0xx_IT_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* Exported macro ------------------------------------------------------------*/ 40 | /* Exported functions ------------------------------------------------------- */ 41 | 42 | void NMI_Handler(void); 43 | void HardFault_Handler(void); 44 | void SVC_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | void USB_IRQHandler(void); 48 | void EXTI4_15_IRQHandler(void); 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* __STM32F0xx_IT_H */ 54 | 55 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 56 | -------------------------------------------------------------------------------- /time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 by Sergey Fetisov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | /* 26 | * version: 1.0 demo (7.02.2015) 27 | */ 28 | 29 | #include "time.h" 30 | 31 | volatile uint32_t sysTimeTicks; 32 | volatile uint32_t sysTimeDelayCounter; 33 | 34 | void time_init(void) 35 | { 36 | if (SysTick_Config(SystemCoreClock / 1000)) 37 | while (1) {} /* Capture error */ 38 | } 39 | 40 | volatile uint32_t msAddition = 0; 41 | 42 | void SysTick_Handler(void) 43 | { 44 | msAddition++; /* +1 ms */ 45 | } 46 | 47 | uint32_t mtime(void) 48 | { 49 | uint32_t ctrl; 50 | static int32_t res; 51 | uint32_t ticks; 52 | 53 | ctrl = SysTick->CTRL; 54 | 55 | read: 56 | ticks = SysTick->VAL; 57 | res = msAddition; 58 | ctrl = SysTick->CTRL; 59 | if (ctrl & SysTick_CTRL_COUNTFLAG_Msk) 60 | goto read; 61 | 62 | return res; 63 | } 64 | 65 | void msleep(int ms) 66 | { 67 | uint32_t t = mtime(); 68 | while (true) 69 | { 70 | uint32_t t1 = mtime(); 71 | if (t1 - t >= ms) break; 72 | if (t1 < t) break; /* overflow */ 73 | } 74 | } 75 | 76 | static stmr_t *stmrs = NULL; 77 | 78 | void stmr(void) 79 | { 80 | stmr_t *tmr; 81 | uint32_t time; 82 | time = mtime(); 83 | tmr = stmrs; 84 | while (tmr != NULL) 85 | { 86 | stmr_t *t; 87 | uint32_t elapsed; 88 | t = tmr; 89 | tmr = tmr->next; 90 | if ((t->flags & STMR_ACTIVE) == 0) 91 | continue; 92 | elapsed = time; 93 | elapsed -= t->event; 94 | if (elapsed < t->period) 95 | continue; 96 | t->proc(t); 97 | t->event = mtime(); 98 | } 99 | } 100 | 101 | void stmr_init(stmr_t *tmr) 102 | { 103 | tmr->period = 0; 104 | tmr->event = 0; 105 | tmr->flags = 0; 106 | tmr->data = NULL; 107 | tmr->proc = NULL; 108 | tmr->next = stmrs; 109 | stmrs = tmr; 110 | } 111 | 112 | void stmr_add(stmr_t *tmr) 113 | { 114 | tmr->next = stmrs; 115 | stmrs = tmr; 116 | } 117 | 118 | void stmr_free(stmr_t *tmr) 119 | { 120 | stmr_t *t; 121 | 122 | if (stmrs == NULL) 123 | return; 124 | 125 | if (tmr == stmrs) 126 | { 127 | stmrs = tmr->next; 128 | tmr->next = NULL; 129 | return; 130 | } 131 | 132 | t = stmrs; 133 | while (t->next != NULL) 134 | { 135 | if (t->next == tmr) 136 | { 137 | t->next = tmr->next; 138 | tmr->next = NULL; 139 | return; 140 | } 141 | t = t->next; 142 | } 143 | } 144 | 145 | void stmr_stop(stmr_t *tmr) 146 | { 147 | tmr->flags &= ~(uint32_t)STMR_ACTIVE; 148 | } 149 | 150 | void stmr_run(stmr_t *tmr) 151 | { 152 | tmr->flags |= STMR_ACTIVE; 153 | tmr->event = mtime(); 154 | } 155 | -------------------------------------------------------------------------------- /time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 by Sergey Fetisov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | /* 26 | * version: 1.0 demo (7.02.2015) 27 | */ 28 | 29 | #ifndef SYSTEMTIME 30 | #define SYSTEMTIME 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* general functions */ 42 | 43 | void time_init(void); /* time module initialization */ 44 | uint32_t mtime(void); /* monotonic time with 1 ms precision */ 45 | void msleep(int ms); /* sleep to n ms */ 46 | 47 | /* softeare timer types */ 48 | 49 | typedef struct stmr stmr_t; 50 | 51 | typedef void (*stmr_cb_t)(stmr_t *tmr); 52 | 53 | #define STMR_ACTIVE 1 54 | 55 | struct stmr 56 | { 57 | uint32_t period; /* timer period, ms. */ 58 | uint32_t event; /* the last event, ms */ 59 | uint32_t flags; /* STMR_XXX */ 60 | void *data; /* user data */ 61 | stmr_cb_t proc; /* timer proc */ 62 | stmr_t *next; /* don't touch it */ 63 | }; 64 | 65 | /* softeare timer functions */ 66 | 67 | void stmr(void); /* call it periodically */ 68 | void stmr_init(stmr_t *tmr); /* init timer and adds to list */ 69 | void stmr_add(stmr_t *tmr); /* adds timer to a timers list */ 70 | void stmr_free(stmr_t *tmr); /* remove timer from the list */ 71 | void stmr_stop(stmr_t *tmr); /* deactivate timer */ 72 | void stmr_run(stmr_t *tmr); /* activate timer */ 73 | 74 | #define TIMER_PROC(name, period, active, data) \ 75 | void name##_proc(stmr_t *tmr); \ 76 | static stmr_t name = \ 77 | { \ 78 | period, 0, active, data, \ 79 | name##_proc, NULL \ 80 | }; \ 81 | void name##_proc(stmr_t *tmr) 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USB_Device/CDC_Standalone/Inc/usbd_conf.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-June-2014 7 | * @brief General low level driver configuration 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_CONF_H 30 | #define __USBD_CONF_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm32f0xx_hal.h" 34 | #include 35 | #include 36 | #include 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Common Config */ 41 | #define ECM_NOTIFICATION_IN_EP 0x81 42 | #define ECM_DATA_IN_EP 0x82 43 | #define ECM_DATA_OUT_EP 0x03 44 | 45 | #define ECM_NOTIFICATION_IN_SZ 64 46 | #define ECM_DATA_IN_SZ USB_FS_MAX_PACKET_SIZE 47 | #define ECM_DATA_OUT_SZ USB_FS_MAX_PACKET_SIZE 48 | 49 | #define USBD_MAX_NUM_INTERFACES 2 /* FIXME: must manually ensure this is 2x NUM_OF_ECM plus any other usage */ 50 | #define USBD_MAX_NUM_CONFIGURATION 1 51 | #define USBD_MAX_STR_DESC_SIZ 0x100 52 | #define USBD_SUPPORT_USER_STRING 0 53 | #define USBD_SELF_POWERED 0 54 | #define USBD_DEBUG_LEVEL 0 55 | 56 | /* Exported macro ------------------------------------------------------------*/ 57 | /* Memory management macros */ 58 | 59 | /* DEBUG macros */ 60 | #if (USBD_DEBUG_LEVEL > 0) 61 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 62 | printf("\n"); 63 | #else 64 | #define USBD_UsrLog(...) 65 | #endif 66 | 67 | #if (USBD_DEBUG_LEVEL > 1) 68 | 69 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 70 | printf(__VA_ARGS__);\ 71 | printf("\n"); 72 | #else 73 | #define USBD_ErrLog(...) 74 | #endif 75 | 76 | #if (USBD_DEBUG_LEVEL > 2) 77 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 78 | printf(__VA_ARGS__);\ 79 | printf("\n"); 80 | #else 81 | #define USBD_DbgLog(...) 82 | #endif 83 | 84 | /* Exported functions ------------------------------------------------------- */ 85 | 86 | #endif /* __USBD_CONF_H */ 87 | 88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 89 | -------------------------------------------------------------------------------- /usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.3.0 6 | * @date 04-November-2014 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /usbd_desc.h: -------------------------------------------------------------------------------- 1 | #ifndef __USBD_DESC_H 2 | #define __USBD_DESC_H 3 | 4 | /* Includes ------------------------------------------------------------------*/ 5 | #include "usbd_def.h" 6 | 7 | /* Exported types ------------------------------------------------------------*/ 8 | /* Exported constants --------------------------------------------------------*/ 9 | /* Exported macro ------------------------------------------------------------*/ 10 | /* Exported functions ------------------------------------------------------- */ 11 | extern const USBD_DescriptorsTypeDef VCP_Desc; 12 | extern const uint8_t *const USBD_CfgFSDesc_pnt; 13 | extern const uint16_t USBD_CfgFSDesc_len; 14 | 15 | #endif /* __USBD_DESC_H */ 16 | -------------------------------------------------------------------------------- /usbd_ecm.h: -------------------------------------------------------------------------------- 1 | /* 2 | USB CDC-ECM for STM32F072 microcontroller 3 | 4 | Copyright (C) 2015,2016,2018 Peter Lawrence 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef __USB_ECM_H_ 26 | #define __USB_ECM_H_ 27 | 28 | #include 29 | #include 30 | #include "usbd_def.h" 31 | #include "usbd_ioreq.h" 32 | #include "netif/etharp.h" 33 | #include "ecmhelper.h" 34 | 35 | #define ETH_HEADER_SIZE 14 36 | #define ECM_MTU (ECM_MAX_SEGMENT_SIZE - ETH_HEADER_SIZE) 37 | 38 | /* array of callback functions invoked by USBD_RegisterClass() in main.c */ 39 | extern const USBD_ClassTypeDef USBD_ECM; 40 | 41 | uint8_t USBD_ECM_RegisterInterface(USBD_HandleTypeDef *pdev); 42 | void USBD_ECM_PMAConfig(PCD_HandleTypeDef *hpcd, uint32_t *pma_address); 43 | 44 | void usb_ecm_recv_callback(const uint8_t *data, int size); 45 | void usb_ecm_recv_renew(void); 46 | 47 | bool usb_ecm_can_xmit(void); 48 | void usb_ecm_xmit_packet(struct pbuf *p); 49 | 50 | #endif // __USB_ECM_H_ 51 | -------------------------------------------------------------------------------- /usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.3.0 6 | * @date 04-November-2014 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2014 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | --------------------------------------------------------------------------------