├── .gitattributes ├── .gitignore ├── CHANGELOG ├── COPYING ├── FILES ├── README ├── UPGRADING ├── doc ├── FILES ├── NO_SYS_SampleCode.c ├── contrib.txt ├── doxygen │ ├── generate.bat │ ├── generate.sh │ ├── lwip.Doxyfile │ ├── main_page.h │ └── output │ │ └── index.html ├── mdns.txt ├── mqtt_client.txt ├── ppp.txt ├── rawapi.txt ├── savannah.txt └── sys_arch.txt ├── src ├── FILES ├── Filelists.mk ├── api │ ├── api_lib.c │ ├── api_msg.c │ ├── err.c │ ├── netbuf.c │ ├── netdb.c │ ├── netifapi.c │ ├── sockets.c │ └── tcpip.c ├── apps │ ├── httpd │ │ ├── fs.c │ │ ├── fs │ │ │ ├── 404.html │ │ │ ├── img │ │ │ │ └── sics.gif │ │ │ └── index.html │ │ ├── fsdata.c │ │ ├── fsdata.h │ │ ├── httpd.c │ │ ├── httpd_structs.h │ │ └── makefsdata │ │ │ ├── makefsdata │ │ │ ├── makefsdata.c │ │ │ └── readme.txt │ ├── lwiperf │ │ └── lwiperf.c │ ├── mdns │ │ └── mdns.c │ ├── mqtt │ │ └── mqtt.c │ ├── netbiosns │ │ └── netbiosns.c │ ├── snmp │ │ ├── snmp_asn1.c │ │ ├── snmp_asn1.h │ │ ├── snmp_core.c │ │ ├── snmp_core_priv.h │ │ ├── snmp_mib2.c │ │ ├── snmp_mib2_icmp.c │ │ ├── snmp_mib2_interfaces.c │ │ ├── snmp_mib2_ip.c │ │ ├── snmp_mib2_snmp.c │ │ ├── snmp_mib2_system.c │ │ ├── snmp_mib2_tcp.c │ │ ├── snmp_mib2_udp.c │ │ ├── snmp_msg.c │ │ ├── snmp_msg.h │ │ ├── snmp_netconn.c │ │ ├── snmp_pbuf_stream.c │ │ ├── snmp_pbuf_stream.h │ │ ├── snmp_raw.c │ │ ├── snmp_scalar.c │ │ ├── snmp_table.c │ │ ├── snmp_threadsync.c │ │ ├── snmp_traps.c │ │ ├── snmpv3.c │ │ ├── snmpv3_dummy.c │ │ ├── snmpv3_mbedtls.c │ │ └── snmpv3_priv.h │ ├── sntp │ │ └── sntp.c │ └── tftp │ │ └── tftp_server.c ├── core │ ├── def.c │ ├── dns.c │ ├── inet_chksum.c │ ├── init.c │ ├── ip.c │ ├── ipv4 │ │ ├── autoip.c │ │ ├── dhcp.c │ │ ├── etharp.c │ │ ├── icmp.c │ │ ├── igmp.c │ │ ├── ip4.c │ │ ├── ip4_addr.c │ │ └── ip4_frag.c │ ├── ipv6 │ │ ├── dhcp6.c │ │ ├── ethip6.c │ │ ├── icmp6.c │ │ ├── inet6.c │ │ ├── ip6.c │ │ ├── ip6_addr.c │ │ ├── ip6_frag.c │ │ ├── mld6.c │ │ └── nd6.c │ ├── mem.c │ ├── memp.c │ ├── netif.c │ ├── pbuf.c │ ├── raw.c │ ├── stats.c │ ├── sys.c │ ├── tcp.c │ ├── tcp_in.c │ ├── tcp_out.c │ ├── timeouts.c │ └── udp.c ├── include │ ├── lwip │ │ ├── api.h │ │ ├── apps │ │ │ ├── FILES │ │ │ ├── fs.h │ │ │ ├── httpd.h │ │ │ ├── httpd_opts.h │ │ │ ├── lwiperf.h │ │ │ ├── mdns.h │ │ │ ├── mdns_opts.h │ │ │ ├── mdns_priv.h │ │ │ ├── mqtt.h │ │ │ ├── mqtt_opts.h │ │ │ ├── netbiosns.h │ │ │ ├── netbiosns_opts.h │ │ │ ├── snmp.h │ │ │ ├── snmp_core.h │ │ │ ├── snmp_mib2.h │ │ │ ├── snmp_opts.h │ │ │ ├── snmp_scalar.h │ │ │ ├── snmp_table.h │ │ │ ├── snmp_threadsync.h │ │ │ ├── snmpv3.h │ │ │ ├── sntp.h │ │ │ ├── sntp_opts.h │ │ │ ├── tftp_opts.h │ │ │ └── tftp_server.h │ │ ├── arch.h │ │ ├── autoip.h │ │ ├── debug.h │ │ ├── def.h │ │ ├── dhcp.h │ │ ├── dhcp6.h │ │ ├── dns.h │ │ ├── err.h │ │ ├── errno.h │ │ ├── etharp.h │ │ ├── ethip6.h │ │ ├── icmp.h │ │ ├── icmp6.h │ │ ├── igmp.h │ │ ├── inet.h │ │ ├── inet_chksum.h │ │ ├── init.h │ │ ├── ip.h │ │ ├── ip4.h │ │ ├── ip4_addr.h │ │ ├── ip4_frag.h │ │ ├── ip6.h │ │ ├── ip6_addr.h │ │ ├── ip6_frag.h │ │ ├── ip_addr.h │ │ ├── mem.h │ │ ├── memp.h │ │ ├── mld6.h │ │ ├── nd6.h │ │ ├── netbuf.h │ │ ├── netdb.h │ │ ├── netif.h │ │ ├── netifapi.h │ │ ├── opt.h │ │ ├── pbuf.h │ │ ├── priv │ │ │ ├── api_msg.h │ │ │ ├── memp_priv.h │ │ │ ├── memp_std.h │ │ │ ├── nd6_priv.h │ │ │ ├── tcp_priv.h │ │ │ └── tcpip_priv.h │ │ ├── prot │ │ │ ├── autoip.h │ │ │ ├── dhcp.h │ │ │ ├── dns.h │ │ │ ├── etharp.h │ │ │ ├── ethernet.h │ │ │ ├── icmp.h │ │ │ ├── icmp6.h │ │ │ ├── igmp.h │ │ │ ├── ip.h │ │ │ ├── ip4.h │ │ │ ├── ip6.h │ │ │ ├── mld6.h │ │ │ ├── nd6.h │ │ │ ├── tcp.h │ │ │ └── udp.h │ │ ├── raw.h │ │ ├── sio.h │ │ ├── snmp.h │ │ ├── sockets.h │ │ ├── stats.h │ │ ├── sys.h │ │ ├── tcp.h │ │ ├── tcpip.h │ │ ├── timeouts.h │ │ └── udp.h │ ├── netif │ │ ├── etharp.h │ │ ├── ethernet.h │ │ ├── lowpan6.h │ │ ├── lowpan6_opts.h │ │ ├── ppp │ │ │ ├── ccp.h │ │ │ ├── chap-md5.h │ │ │ ├── chap-new.h │ │ │ ├── chap_ms.h │ │ │ ├── eap.h │ │ │ ├── ecp.h │ │ │ ├── eui64.h │ │ │ ├── fsm.h │ │ │ ├── ipcp.h │ │ │ ├── ipv6cp.h │ │ │ ├── lcp.h │ │ │ ├── magic.h │ │ │ ├── mppe.h │ │ │ ├── polarssl │ │ │ │ ├── arc4.h │ │ │ │ ├── des.h │ │ │ │ ├── md4.h │ │ │ │ ├── md5.h │ │ │ │ └── sha1.h │ │ │ ├── ppp.h │ │ │ ├── ppp_impl.h │ │ │ ├── ppp_opts.h │ │ │ ├── pppapi.h │ │ │ ├── pppcrypt.h │ │ │ ├── pppdebug.h │ │ │ ├── pppoe.h │ │ │ ├── pppol2tp.h │ │ │ ├── pppos.h │ │ │ ├── upap.h │ │ │ └── vj.h │ │ └── slipif.h │ └── posix │ │ ├── errno.h │ │ ├── netdb.h │ │ └── sys │ │ └── socket.h └── netif │ ├── FILES │ ├── ethernet.c │ ├── ethernetif.c │ ├── lowpan6.c │ ├── ppp │ ├── PPPD_FOLLOWUP │ ├── auth.c │ ├── ccp.c │ ├── chap-md5.c │ ├── chap-new.c │ ├── chap_ms.c │ ├── demand.c │ ├── eap.c │ ├── ecp.c │ ├── eui64.c │ ├── fsm.c │ ├── ipcp.c │ ├── ipv6cp.c │ ├── lcp.c │ ├── magic.c │ ├── mppe.c │ ├── multilink.c │ ├── polarssl │ │ ├── README │ │ ├── arc4.c │ │ ├── des.c │ │ ├── md4.c │ │ ├── md5.c │ │ └── sha1.c │ ├── ppp.c │ ├── pppapi.c │ ├── pppcrypt.c │ ├── pppoe.c │ ├── pppol2tp.c │ ├── pppos.c │ ├── upap.c │ ├── utils.c │ └── vj.c │ └── slipif.c └── test ├── fuzz ├── Makefile ├── README ├── config.h ├── fuzz.c ├── inputs │ ├── arp │ │ └── arp_req.bin │ ├── icmp │ │ └── icmp_ping.bin │ ├── ipv6 │ │ ├── neighbor_solicitation.bin │ │ └── router_adv.bin │ ├── tcp │ │ └── tcp_syn.bin │ └── udp │ │ └── udp_port_5000.bin ├── lwipopts.h └── output_to_pcap.sh └── unit ├── core ├── test_mem.c ├── test_mem.h ├── test_pbuf.c └── test_pbuf.h ├── dhcp ├── test_dhcp.c └── test_dhcp.h ├── etharp ├── test_etharp.c └── test_etharp.h ├── lwip_check.h ├── lwip_unittests.c ├── lwipopts.h ├── mdns ├── test_mdns.c └── test_mdns.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 /.gitattributes: -------------------------------------------------------------------------------- 1 | # These files are text and should be normalized 2 | *.txt text 3 | *.c text 4 | *.h text 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | /doc/doxygen/output/html 4 | /src/apps/snmp/LwipMibCompiler/CCodeGeneration/bin/ 5 | /src/apps/snmp/LwipMibCompiler/CCodeGeneration/obj/ 6 | /src/apps/snmp/LwipMibCompiler/LwipMibCompiler/bin/ 7 | /src/apps/snmp/LwipMibCompiler/LwipMibCompiler/obj/ 8 | /src/apps/snmp/LwipMibCompiler/MibViewer/bin/ 9 | /src/apps/snmp/LwipMibCompiler/MibViewer/obj/ 10 | /src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/bin/ 11 | /src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/obj/ 12 | /src/apps/snmp/LwipMibCompiler/SharpSnmpLib/bin/ 13 | /src/apps/snmp/LwipMibCompiler/SharpSnmpLib/obj/ 14 | /src/apps/snmp/LwipMibCompiler/LwipMibCompiler.userprefs 15 | /src/apps/snmp/LwipMibCompiler/*.suo 16 | /test/fuzz/output 17 | /test/fuzz/lwip_fuzz 18 | /test/fuzz/.depend 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /FILES: -------------------------------------------------------------------------------- 1 | src/ - The source code for the lwIP TCP/IP stack. 2 | doc/ - The documentation for lwIP. 3 | test/ - Some code to test whether the sources do what they should. 4 | 5 | See also the FILES file in each subdirectory. 6 | -------------------------------------------------------------------------------- /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 | 14 | FEATURES 15 | 16 | * IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over 17 | multiple network interfaces 18 | * ICMP (Internet Control Message Protocol) for network maintenance and debugging 19 | * IGMP (Internet Group Management Protocol) for multicast traffic management 20 | * MLD (Multicast listener discovery for IPv6). Aims to be compliant with 21 | RFC 2710. No support for MLDv2 22 | * ND (Neighbor discovery and stateless address autoconfiguration for IPv6). 23 | Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 24 | (Address autoconfiguration) 25 | * UDP (User Datagram Protocol) including experimental UDP-lite extensions 26 | * TCP (Transmission Control Protocol) with congestion control, RTT estimation 27 | and fast recovery/fast retransmit 28 | * raw/native API for enhanced performance 29 | * Optional Berkeley-like socket API 30 | * DNS (Domain names resolver) 31 | 32 | 33 | APPLICATIONS 34 | 35 | * HTTP server with SSI and CGI 36 | * SNMPv2c agent with MIB compiler (Simple Network Management Protocol) 37 | * SNTP (Simple network time protocol) 38 | * NetBIOS name service responder 39 | * MDNS (Multicast DNS) responder 40 | * iPerf server implementation 41 | 42 | 43 | LICENSE 44 | 45 | lwIP is freely available under a BSD license. 46 | 47 | 48 | DEVELOPMENT 49 | 50 | lwIP has grown into an excellent TCP/IP stack for embedded devices, 51 | and developers using the stack often submit bug fixes, improvements, 52 | and additions to the stack to further increase its usefulness. 53 | 54 | Development of lwIP is hosted on Savannah, a central point for 55 | software development, maintenance and distribution. Everyone can 56 | help improve lwIP by use of Savannah's interface, Git and the 57 | mailing list. A core team of developers will commit changes to the 58 | Git source tree. 59 | 60 | The lwIP TCP/IP stack is maintained in the 'lwip' Git module and 61 | contributions (such as platform ports) are in the 'contrib' Git module. 62 | 63 | See doc/savannah.txt for details on Git server access for users and 64 | developers. 65 | 66 | The current Git trees are web-browsable: 67 | http://git.savannah.gnu.org/cgit/lwip.git 68 | http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git 69 | 70 | Submit patches and bugs via the lwIP project page: 71 | http://savannah.nongnu.org/projects/lwip/ 72 | 73 | Continuous integration builds (GCC, clang): 74 | https://travis-ci.org/yarrick/lwip-merged 75 | 76 | 77 | DOCUMENTATION 78 | 79 | Self documentation of the source code is regularly extracted from the current 80 | Git sources and is available from this web page: 81 | http://www.nongnu.org/lwip/ 82 | 83 | There is now a constantly growing wiki about lwIP at 84 | http://lwip.wikia.com/wiki/LwIP_Wiki 85 | 86 | Also, there are mailing lists you can subscribe at 87 | http://savannah.nongnu.org/mail/?group=lwip 88 | plus searchable archives: 89 | http://lists.nongnu.org/archive/html/lwip-users/ 90 | http://lists.nongnu.org/archive/html/lwip-devel/ 91 | 92 | lwIP was originally written by Adam Dunkels: 93 | http://dunkels.com/adam/ 94 | 95 | Reading Adam's papers, the files in docs/, browsing the source code 96 | documentation and browsing the mailing list archives is a good way to 97 | become familiar with the design of lwIP. 98 | 99 | Adam Dunkels 100 | Leon Woestenberg 101 | -------------------------------------------------------------------------------- /doc/FILES: -------------------------------------------------------------------------------- 1 | doxygen/ - Configuration files and scripts to create the lwIP doxygen source 2 | documentation (found at http://www.nongnu.org/lwip/) 3 | 4 | savannah.txt - How to obtain the current development source code. 5 | contrib.txt - How to contribute to lwIP as a developer. 6 | rawapi.txt - The documentation for the core API of lwIP. 7 | Also provides an overview about the other APIs and multithreading. 8 | sys_arch.txt - The documentation for a system abstraction layer of lwIP. 9 | ppp.txt - Documentation of the PPP interface for lwIP. 10 | -------------------------------------------------------------------------------- /doc/NO_SYS_SampleCode.c: -------------------------------------------------------------------------------- 1 | void eth_mac_irq() 2 | { 3 | /* Service MAC IRQ here */ 4 | 5 | /* Allocate pbuf from pool (avoid using heap in interrupts) */ 6 | struct pbuf* p = pbuf_alloc(PBUF_RAW, eth_data_count, PBUF_POOL); 7 | 8 | if(p != NULL) { 9 | /* Copy ethernet frame into pbuf */ 10 | pbuf_take(p, eth_data, eth_data_count); 11 | 12 | /* Put in a queue which is processed in main loop */ 13 | if(!queue_try_put(&queue, p)) { 14 | /* queue is full -> packet loss */ 15 | pbuf_free(p); 16 | } 17 | } 18 | } 19 | 20 | static err_t netif_output(struct netif *netif, struct pbuf *p) 21 | { 22 | LINK_STATS_INC(link.xmit); 23 | 24 | /* Update SNMP stats (only if you use SNMP) */ 25 | MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len); 26 | int unicast = ((p->payload[0] & 0x01) == 0); 27 | if (unicast) { 28 | MIB2_STATS_NETIF_INC(netif, ifoutucastpkts); 29 | } else { 30 | MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts); 31 | } 32 | 33 | lock_interrupts(); 34 | pbuf_copy_partial(p, mac_send_buffer, p->tot_len, 0); 35 | /* Start MAC transmit here */ 36 | unlock_interrupts(); 37 | 38 | return ERR_OK; 39 | } 40 | 41 | static void netif_status_callback(struct netif *netif) 42 | { 43 | printf("netif status changed %s\n", ip4addr_ntoa(netif_ip4_addr(netif))); 44 | } 45 | 46 | static err_t netif_init(struct netif *netif) 47 | { 48 | netif->linkoutput = netif_output; 49 | netif->output = etharp_output; 50 | netif->output_ip6 = ethip6_output; 51 | netif->mtu = ETHERNET_MTU; 52 | netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP | NETIF_FLAG_MLD6; 53 | MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, 100000000); 54 | 55 | SMEMCPY(netif->hwaddr, your_mac_address_goes_here, sizeof(netif->hwaddr)); 56 | netif->hwaddr_len = sizeof(netif->hwaddr); 57 | 58 | return ERR_OK; 59 | } 60 | 61 | void main(void) 62 | { 63 | struct netif netif; 64 | 65 | lwip_init(); 66 | 67 | netif_add(&netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY, NULL, netif_init, netif_input); 68 | netif.name[0] = 'e'; 69 | netif.name[1] = '0'; 70 | netif_create_ip6_linklocal_address(&netif, 1); 71 | netif.ip6_autoconfig_enabled = 1; 72 | netif_set_status_callback(&netif, netif_status_callback); 73 | netif_set_default(&netif); 74 | netif_set_up(&netif); 75 | 76 | /* Start DHCP and HTTPD */ 77 | dhcp_init(); 78 | httpd_init(); 79 | 80 | while(1) { 81 | /* Check link state, e.g. via MDIO communication with PHY */ 82 | if(link_state_changed()) { 83 | if(link_is_up()) { 84 | netif_set_link_up(&netif); 85 | } else { 86 | netif_set_link_down(&netif); 87 | } 88 | } 89 | 90 | /* Check for received frames, feed them to lwIP */ 91 | lock_interrupts(); 92 | struct pbuf* p = queue_try_get(&queue); 93 | unlock_interrupts(); 94 | 95 | if(p != NULL) { 96 | LINK_STATS_INC(link.recv); 97 | 98 | /* Update SNMP stats (only if you use SNMP) */ 99 | MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len); 100 | int unicast = ((p->payload[0] & 0x01) == 0); 101 | if (unicast) { 102 | MIB2_STATS_NETIF_INC(netif, ifinucastpkts); 103 | } else { 104 | MIB2_STATS_NETIF_INC(netif, ifinnucastpkts); 105 | } 106 | 107 | if(netif.input(p, &netif) != ERR_OK) { 108 | pbuf_free(p); 109 | } 110 | } 111 | 112 | /* Cyclic lwIP timers check */ 113 | sys_check_timeouts(); 114 | 115 | /* your application goes here */ 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /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 Git 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 preferred 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. Patches should be specific to a single change or to related changes. Do not mix bugfixes with spelling and other 50 | trivial fixes unless the bugfix is trivial too. Do not reorganize code and rename identifiers in the same patch you 51 | change behaviour if not necessary. A patch is easier to read and understand if it's to the point and short than 52 | if it's not to the point and long :) so the chances for it to be applied are greater. 53 | 54 | 2.4 Platform porters: 55 | 56 | 1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and 57 | you think it could benefit others[1] you might want discuss this on the mailing list. You 58 | can also ask for Git access to submit and maintain your port in the contrib Git module. 59 | -------------------------------------------------------------------------------- /doc/doxygen/generate.bat: -------------------------------------------------------------------------------- 1 | doxygen lwip.Doxyfile 2 | -------------------------------------------------------------------------------- /doc/doxygen/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | doxygen lwip.Doxyfile 4 | -------------------------------------------------------------------------------- /doc/doxygen/output/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirection 5 | 6 | 7 | 8 | index.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /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 | apps/ - Higher layer applications that are specifically programmed 5 | with the lwIP low-level raw API. 6 | 7 | core/ - The core of the TPC/IP stack; protocol implementations, 8 | memory and buffer management, and the low-level raw API. 9 | 10 | include/ - lwIP include files. 11 | 12 | netif/ - Generic network interface device drivers are kept here. 13 | 14 | For more information on the various subdirectories, check the FILES 15 | file in each directory. 16 | -------------------------------------------------------------------------------- /src/apps/httpd/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 | -------------------------------------------------------------------------------- /src/apps/httpd/fs/img/sics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/src/apps/httpd/fs/img/sics.gif -------------------------------------------------------------------------------- /src/apps/httpd/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 | -------------------------------------------------------------------------------- /src/apps/httpd/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 LWIP_FSDATA_H 33 | #define LWIP_FSDATA_H 34 | 35 | #include "lwip/apps/httpd_opts.h" 36 | #include "lwip/apps/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 flags; 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 /* LWIP_FSDATA_H */ 51 | -------------------------------------------------------------------------------- /src/apps/httpd/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 | -------------------------------------------------------------------------------- /src/apps/httpd/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 | -------------------------------------------------------------------------------- /src/apps/snmp/snmp_core_priv.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: Martin Hentschel 30 | * 31 | */ 32 | 33 | #ifndef LWIP_HDR_APPS_SNMP_CORE_PRIV_H 34 | #define LWIP_HDR_APPS_SNMP_CORE_PRIV_H 35 | 36 | #include "lwip/apps/snmp_opts.h" 37 | 38 | #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ 39 | 40 | #include "lwip/apps/snmp_core.h" 41 | #include "snmp_asn1.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* (outdated) SNMPv1 error codes 48 | * shall not be used by MIBS anymore, nevertheless required from core for properly answering a v1 request 49 | */ 50 | #define SNMP_ERR_NOSUCHNAME 2 51 | #define SNMP_ERR_BADVALUE 3 52 | #define SNMP_ERR_READONLY 4 53 | /* error codes which are internal and shall not be used by MIBS 54 | * shall not be used by MIBS anymore, nevertheless required from core for properly answering a v1 request 55 | */ 56 | #define SNMP_ERR_TOOBIG 1 57 | #define SNMP_ERR_AUTHORIZATIONERROR 16 58 | #define SNMP_ERR_NOSUCHOBJECT SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_OBJECT 59 | #define SNMP_ERR_ENDOFMIBVIEW SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_END_OF_MIB_VIEW 60 | 61 | 62 | const struct snmp_node* snmp_mib_tree_resolve_exact(const struct snmp_mib *mib, const u32_t *oid, u8_t oid_len, u8_t* oid_instance_len); 63 | const struct snmp_node* snmp_mib_tree_resolve_next(const struct snmp_mib *mib, const u32_t *oid, u8_t oid_len, struct snmp_obj_id* oidret); 64 | 65 | typedef u8_t (*snmp_validate_node_instance_method)(struct snmp_node_instance*, void*); 66 | 67 | u8_t snmp_get_node_instance_from_oid(const u32_t *oid, u8_t oid_len, struct snmp_node_instance* node_instance); 68 | u8_t snmp_get_next_node_instance_from_oid(const u32_t *oid, u8_t oid_len, snmp_validate_node_instance_method validate_node_instance_method, void* validate_node_instance_arg, struct snmp_obj_id* node_oid, struct snmp_node_instance* node_instance); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* LWIP_SNMP */ 75 | 76 | #endif /* LWIP_HDR_APPS_SNMP_CORE_PRIV_H */ 77 | -------------------------------------------------------------------------------- /src/apps/snmp/snmp_pbuf_stream.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNMP pbuf stream wrapper (internal API, do not use in client code). 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Martin Hentschel 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_APPS_SNMP_PBUF_STREAM_H 39 | #define LWIP_HDR_APPS_SNMP_PBUF_STREAM_H 40 | 41 | #include "lwip/apps/snmp_opts.h" 42 | 43 | #if LWIP_SNMP 44 | 45 | #include "lwip/err.h" 46 | #include "lwip/pbuf.h" 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | struct snmp_pbuf_stream 53 | { 54 | struct pbuf* pbuf; 55 | u16_t offset; 56 | u16_t length; 57 | }; 58 | 59 | err_t snmp_pbuf_stream_init(struct snmp_pbuf_stream* pbuf_stream, struct pbuf* p, u16_t offset, u16_t length); 60 | err_t snmp_pbuf_stream_read(struct snmp_pbuf_stream* pbuf_stream, u8_t* data); 61 | err_t snmp_pbuf_stream_write(struct snmp_pbuf_stream* pbuf_stream, u8_t data); 62 | err_t snmp_pbuf_stream_writebuf(struct snmp_pbuf_stream* pbuf_stream, const void* buf, u16_t buf_len); 63 | err_t snmp_pbuf_stream_writeto(struct snmp_pbuf_stream* pbuf_stream, struct snmp_pbuf_stream* target_pbuf_stream, u16_t len); 64 | err_t snmp_pbuf_stream_seek(struct snmp_pbuf_stream* pbuf_stream, s32_t offset); 65 | err_t snmp_pbuf_stream_seek_abs(struct snmp_pbuf_stream* pbuf_stream, u32_t offset); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* LWIP_SNMP */ 72 | 73 | #endif /* LWIP_HDR_APPS_SNMP_PBUF_STREAM_H */ 74 | -------------------------------------------------------------------------------- /src/apps/snmp/snmp_raw.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNMP RAW API frontend. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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: Dirk Ziegelmeier 33 | */ 34 | 35 | #include "lwip/apps/snmp_opts.h" 36 | #include "lwip/ip_addr.h" 37 | 38 | #if LWIP_SNMP && SNMP_USE_RAW 39 | 40 | #include "lwip/udp.h" 41 | #include "lwip/ip.h" 42 | #include "snmp_msg.h" 43 | 44 | /* lwIP UDP receive callback function */ 45 | static void 46 | snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) 47 | { 48 | LWIP_UNUSED_ARG(arg); 49 | 50 | snmp_receive(pcb, p, addr, port); 51 | 52 | pbuf_free(p); 53 | } 54 | 55 | err_t 56 | snmp_sendto(void *handle, struct pbuf *p, const ip_addr_t *dst, u16_t port) 57 | { 58 | return udp_sendto((struct udp_pcb*)handle, p, dst, port); 59 | } 60 | 61 | u8_t 62 | snmp_get_local_ip_for_dst(void* handle, const ip_addr_t *dst, ip_addr_t *result) 63 | { 64 | struct udp_pcb* udp_pcb = (struct udp_pcb*)handle; 65 | struct netif *dst_if; 66 | const ip_addr_t* dst_ip; 67 | 68 | LWIP_UNUSED_ARG(udp_pcb); /* unused in case of IPV4 only configuration */ 69 | 70 | ip_route_get_local_ip(&udp_pcb->local_ip, dst, dst_if, dst_ip); 71 | 72 | if ((dst_if != NULL) && (dst_ip != NULL)) { 73 | ip_addr_copy(*result, *dst_ip); 74 | return 1; 75 | } else { 76 | return 0; 77 | } 78 | } 79 | 80 | /** 81 | * @ingroup snmp_core 82 | * Starts SNMP Agent. 83 | * Allocates UDP pcb and binds it to IP_ANY_TYPE port 161. 84 | */ 85 | void 86 | snmp_init(void) 87 | { 88 | err_t err; 89 | 90 | struct udp_pcb *snmp_pcb = udp_new_ip_type(IPADDR_TYPE_ANY); 91 | LWIP_ERROR("snmp_raw: no PCB", (snmp_pcb != NULL), return;); 92 | 93 | snmp_traps_handle = snmp_pcb; 94 | 95 | udp_recv(snmp_pcb, snmp_recv, (void *)SNMP_IN_PORT); 96 | err = udp_bind(snmp_pcb, IP_ANY_TYPE, SNMP_IN_PORT); 97 | LWIP_ERROR("snmp_raw: Unable to bind PCB", (err == ERR_OK), return;); 98 | } 99 | 100 | #endif /* LWIP_SNMP && SNMP_USE_RAW */ 101 | -------------------------------------------------------------------------------- /src/apps/snmp/snmpv3_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Additional SNMPv3 functionality RFC3414 and RFC3826 (internal API, do not use in client code). 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2016 Elias Oenal. 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: Elias Oenal 33 | */ 34 | 35 | #ifndef LWIP_HDR_APPS_SNMP_V3_PRIV_H 36 | #define LWIP_HDR_APPS_SNMP_V3_PRIV_H 37 | 38 | #include "lwip/apps/snmp_opts.h" 39 | 40 | #if LWIP_SNMP && LWIP_SNMP_V3 41 | 42 | #include "snmp_pbuf_stream.h" 43 | 44 | /* According to RFC 3411 */ 45 | #define SNMP_V3_MAX_ENGINE_ID_LENGTH 32 46 | #define SNMP_V3_MAX_USER_LENGTH 32 47 | 48 | #define SNMP_V3_MAX_AUTH_PARAM_LENGTH 12 49 | #define SNMP_V3_MAX_PRIV_PARAM_LENGTH 8 50 | 51 | #define SNMP_V3_AUTH_FLAG 0x01 52 | #define SNMP_V3_PRIV_FLAG 0x02 53 | 54 | #define SNMP_V3_MD5_LEN 16 55 | #define SNMP_V3_SHA_LEN 20 56 | 57 | u32_t snmpv3_get_engine_boots_internal(void); 58 | u32_t snmpv3_get_engine_time_internal(void); 59 | err_t snmpv3_auth(struct snmp_pbuf_stream* stream, u16_t length, const u8_t* key, u8_t algo, u8_t* hmac_out); 60 | err_t snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, const u8_t* key, 61 | const u8_t* priv_param, const u32_t engine_boots, const u32_t engine_time, u8_t algo, u8_t mode); 62 | err_t snmpv3_build_priv_param(u8_t* priv_param); 63 | 64 | #endif 65 | 66 | #endif /* LWIP_HDR_APPS_SNMP_V3_PRIV_H */ 67 | -------------------------------------------------------------------------------- /src/core/ipv6/dhcp6.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * DHCPv6. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_IPV6 && LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/ip6_addr.h" 47 | #include "lwip/def.h" 48 | 49 | 50 | #endif /* LWIP_IPV6 && LWIP_IPV6_DHCP6 */ 51 | -------------------------------------------------------------------------------- /src/core/ipv6/inet6.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * INET v6 addresses. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_IPV6 && LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/def.h" 47 | #include "lwip/inet.h" 48 | 49 | /** This variable is initialized by the system to contain the wildcard IPv6 address. 50 | */ 51 | const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; 52 | 53 | #endif /* LWIP_IPV6 */ 54 | -------------------------------------------------------------------------------- /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 | /** 40 | * @defgroup sys_layer Porting (system abstraction layer) 41 | * @ingroup lwip 42 | * @verbinclude "sys_arch.txt" 43 | * 44 | * @defgroup sys_os OS abstraction layer 45 | * @ingroup sys_layer 46 | * No need to implement functions in this section in NO_SYS mode. 47 | * 48 | * @defgroup sys_sem Semaphores 49 | * @ingroup sys_os 50 | * 51 | * @defgroup sys_mutex Mutexes 52 | * @ingroup sys_os 53 | * Mutexes are recommended to correctly handle priority inversion, 54 | * especially if you use LWIP_CORE_LOCKING . 55 | * 56 | * @defgroup sys_mbox Mailboxes 57 | * @ingroup sys_os 58 | * 59 | * @defgroup sys_time Time 60 | * @ingroup sys_layer 61 | * 62 | * @defgroup sys_prot Critical sections 63 | * @ingroup sys_layer 64 | * Used to protect short regions of code against concurrent access. 65 | * - Your system is a bare-metal system (probably with an RTOS) 66 | * and interrupts are under your control: 67 | * Implement this as LockInterrupts() / UnlockInterrupts() 68 | * - Your system uses an RTOS with deferred interrupt handling from a 69 | * worker thread: Implement as a global mutex or lock/unlock scheduler 70 | * - Your system uses a high-level OS with e.g. POSIX signals: 71 | * Implement as a global mutex 72 | * 73 | * @defgroup sys_misc Misc 74 | * @ingroup sys_os 75 | */ 76 | 77 | #include "lwip/opt.h" 78 | 79 | #include "lwip/sys.h" 80 | 81 | /* Most of the functions defined in sys.h must be implemented in the 82 | * architecture-dependent file sys_arch.c */ 83 | 84 | #if !NO_SYS 85 | 86 | #ifndef sys_msleep 87 | /** 88 | * Sleep for some ms. Timeouts are NOT processed while sleeping. 89 | * 90 | * @param ms number of milliseconds to sleep 91 | */ 92 | void 93 | sys_msleep(u32_t ms) 94 | { 95 | if (ms > 0) { 96 | sys_sem_t delaysem; 97 | err_t err = sys_sem_new(&delaysem, 0); 98 | if (err == ERR_OK) { 99 | sys_arch_sem_wait(&delaysem, ms); 100 | sys_sem_free(&delaysem); 101 | } 102 | } 103 | } 104 | #endif /* sys_msleep */ 105 | 106 | #endif /* !NO_SYS */ 107 | -------------------------------------------------------------------------------- /src/include/lwip/apps/FILES: -------------------------------------------------------------------------------- 1 | This directory contains application headers. 2 | Every application shall provide one api file APP.h and optionally one options file APP_opts.h 3 | -------------------------------------------------------------------------------- /src/include/lwip/apps/lwiperf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP iPerf server implementation 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2014 Simon Goldschmidt 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Simon Goldschmidt 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_LWIPERF_H 38 | #define LWIP_HDR_APPS_LWIPERF_H 39 | 40 | #include "lwip/opt.h" 41 | #include "lwip/ip_addr.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #define LWIPERF_TCP_PORT_DEFAULT 5001 48 | 49 | /** lwIPerf test results */ 50 | enum lwiperf_report_type 51 | { 52 | /** The server side test is done */ 53 | LWIPERF_TCP_DONE_SERVER, 54 | /** The client side test is done */ 55 | LWIPERF_TCP_DONE_CLIENT, 56 | /** Local error lead to test abort */ 57 | LWIPERF_TCP_ABORTED_LOCAL, 58 | /** Data check error lead to test abort */ 59 | LWIPERF_TCP_ABORTED_LOCAL_DATAERROR, 60 | /** Transmit error lead to test abort */ 61 | LWIPERF_TCP_ABORTED_LOCAL_TXERROR, 62 | /** Remote side aborted the test */ 63 | LWIPERF_TCP_ABORTED_REMOTE 64 | }; 65 | 66 | /** Prototype of a report function that is called when a session is finished. 67 | This report function can show the test results. 68 | @param report_type contains the test result */ 69 | typedef void (*lwiperf_report_fn)(void *arg, enum lwiperf_report_type report_type, 70 | const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port, 71 | u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec); 72 | 73 | 74 | void* lwiperf_start_tcp_server(const ip_addr_t* local_addr, u16_t local_port, 75 | lwiperf_report_fn report_fn, void* report_arg); 76 | void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg); 77 | void lwiperf_abort(void* lwiperf_session); 78 | 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* LWIP_HDR_APPS_LWIPERF_H */ 85 | -------------------------------------------------------------------------------- /src/include/lwip/apps/mdns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MDNS responder 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2015 Verisure Innovation AB 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Ekman 35 | * 36 | */ 37 | #ifndef LWIP_HDR_MDNS_H 38 | #define LWIP_HDR_MDNS_H 39 | 40 | #include "lwip/apps/mdns_opts.h" 41 | #include "lwip/netif.h" 42 | 43 | #if LWIP_MDNS_RESPONDER 44 | 45 | enum mdns_sd_proto { 46 | DNSSD_PROTO_UDP = 0, 47 | DNSSD_PROTO_TCP = 1 48 | }; 49 | 50 | #define MDNS_LABEL_MAXLEN 63 51 | 52 | struct mdns_host; 53 | struct mdns_service; 54 | 55 | /** Callback function to add text to a reply, called when generating the reply */ 56 | typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata); 57 | 58 | void mdns_resp_init(void); 59 | 60 | err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl); 61 | err_t mdns_resp_remove_netif(struct netif *netif); 62 | 63 | err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata); 64 | err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len); 65 | void mdns_resp_netif_settings_changed(struct netif *netif); 66 | 67 | #endif /* LWIP_MDNS_RESPONDER */ 68 | 69 | #endif /* LWIP_HDR_MDNS_H */ 70 | -------------------------------------------------------------------------------- /src/include/lwip/apps/mdns_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MDNS responder 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2015 Verisure Innovation AB 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Ekman 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_APPS_MDNS_OPTS_H 39 | #define LWIP_HDR_APPS_MDNS_OPTS_H 40 | 41 | #include "lwip/opt.h" 42 | 43 | /** 44 | * @defgroup mdns_opts Options 45 | * @ingroup mdns 46 | * @{ 47 | */ 48 | 49 | /** 50 | * LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS 51 | * transport. IGMP is needed for IPv4 multicast. 52 | */ 53 | #ifndef LWIP_MDNS_RESPONDER 54 | #define LWIP_MDNS_RESPONDER 0 55 | #endif /* LWIP_MDNS_RESPONDER */ 56 | 57 | /** The maximum number of services per netif */ 58 | #ifndef MDNS_MAX_SERVICES 59 | #define MDNS_MAX_SERVICES 1 60 | #endif 61 | 62 | /** 63 | * MDNS_DEBUG: Enable debugging for multicast DNS. 64 | */ 65 | #ifndef MDNS_DEBUG 66 | #define MDNS_DEBUG LWIP_DBG_OFF 67 | #endif 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | #endif /* LWIP_HDR_APPS_MDNS_OPTS_H */ 74 | 75 | -------------------------------------------------------------------------------- /src/include/lwip/apps/mdns_priv.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MDNS responder private definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2015 Verisure Innovation AB 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Ekman 35 | * 36 | */ 37 | #ifndef LWIP_HDR_MDNS_PRIV_H 38 | #define LWIP_HDR_MDNS_PRIV_H 39 | 40 | #include "lwip/apps/mdns_opts.h" 41 | #include "lwip/pbuf.h" 42 | 43 | #if LWIP_MDNS_RESPONDER 44 | 45 | /* Domain struct and methods - visible for unit tests */ 46 | 47 | #define MDNS_DOMAIN_MAXLEN 256 48 | #define MDNS_READNAME_ERROR 0xFFFF 49 | 50 | struct mdns_domain { 51 | /* Encoded domain name */ 52 | u8_t name[MDNS_DOMAIN_MAXLEN]; 53 | /* Total length of domain name, including zero */ 54 | u16_t length; 55 | /* Set if compression of this domain is not allowed */ 56 | u8_t skip_compression; 57 | }; 58 | 59 | err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len); 60 | u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain); 61 | int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b); 62 | u16_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain); 63 | 64 | #endif /* LWIP_MDNS_RESPONDER */ 65 | 66 | #endif /* LWIP_HDR_MDNS_PRIV_H */ 67 | -------------------------------------------------------------------------------- /src/include/lwip/apps/mqtt_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MQTT client options 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2016 Erik Andersson 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Erik Andersson 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_MQTT_OPTS_H 38 | #define LWIP_HDR_APPS_MQTT_OPTS_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** 47 | * @defgroup mqtt_opts Options 48 | * @ingroup mqtt 49 | * @{ 50 | */ 51 | 52 | /** 53 | * Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads 54 | */ 55 | #ifndef MQTT_OUTPUT_RINGBUF_SIZE 56 | #define MQTT_OUTPUT_RINGBUF_SIZE 256 57 | #endif 58 | 59 | /** 60 | * Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8 61 | * If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8 62 | */ 63 | #ifndef MQTT_VAR_HEADER_BUFFER_LEN 64 | #define MQTT_VAR_HEADER_BUFFER_LEN 128 65 | #endif 66 | 67 | /** 68 | * Maximum number of pending subscribe, unsubscribe and publish requests to server . 69 | */ 70 | #ifndef MQTT_REQ_MAX_IN_FLIGHT 71 | #define MQTT_REQ_MAX_IN_FLIGHT 4 72 | #endif 73 | 74 | /** 75 | * Seconds between each cyclic timer call. 76 | */ 77 | #ifndef MQTT_CYCLIC_TIMER_INTERVAL 78 | #define MQTT_CYCLIC_TIMER_INTERVAL 5 79 | #endif 80 | 81 | /** 82 | * Publish, subscribe and unsubscribe request timeout in seconds. 83 | */ 84 | #ifndef MQTT_REQ_TIMEOUT 85 | #define MQTT_REQ_TIMEOUT 30 86 | #endif 87 | 88 | /** 89 | * Seconds for MQTT connect response timeout after sending connect request 90 | */ 91 | #ifndef MQTT_CONNECT_TIMOUT 92 | #define MQTT_CONNECT_TIMOUT 100 93 | #endif 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* LWIP_HDR_APPS_MQTT_OPTS_H */ 104 | -------------------------------------------------------------------------------- /src/include/lwip/apps/netbiosns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * NETBIOS name service responder 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 | #ifndef LWIP_HDR_APPS_NETBIOS_H 33 | #define LWIP_HDR_APPS_NETBIOS_H 34 | 35 | #include "lwip/apps/netbiosns_opts.h" 36 | 37 | void netbiosns_init(void); 38 | #ifndef NETBIOS_LWIP_NAME 39 | void netbiosns_set_name(const char* hostname); 40 | #endif 41 | void netbiosns_stop(void); 42 | 43 | #endif /* LWIP_HDR_APPS_NETBIOS_H */ 44 | -------------------------------------------------------------------------------- /src/include/lwip/apps/netbiosns_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * NETBIOS name service responder options 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 | #ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H 33 | #define LWIP_HDR_APPS_NETBIOS_OPTS_H 34 | 35 | #include "lwip/opt.h" 36 | 37 | /** 38 | * @defgroup netbiosns_opts Options 39 | * @ingroup netbiosns 40 | * @{ 41 | */ 42 | 43 | /** NetBIOS name of lwip device 44 | * This must be uppercase until NETBIOS_STRCMP() is defined to a string 45 | * comparision function that is case insensitive. 46 | * If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME): 47 | * (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "") 48 | * 49 | * If this is not defined, netbiosns_set_name() can be called at runtime to change the name. 50 | */ 51 | #ifdef __DOXYGEN__ 52 | #define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV" 53 | #endif 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | #endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */ 60 | -------------------------------------------------------------------------------- /src/include/lwip/apps/snmp_mib2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNMP MIB2 API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Dirk Ziegelmeier 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_SNMP_MIB2_H 38 | #define LWIP_HDR_APPS_SNMP_MIB2_H 39 | 40 | #include "lwip/apps/snmp_opts.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ 47 | #if SNMP_LWIP_MIB2 48 | 49 | #include "lwip/apps/snmp_core.h" 50 | 51 | extern const struct snmp_mib mib2; 52 | 53 | #if SNMP_USE_NETCONN 54 | #include "lwip/apps/snmp_threadsync.h" 55 | void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg); 56 | extern struct snmp_threadsync_instance snmp_mib2_lwip_locks; 57 | #endif 58 | 59 | #ifndef SNMP_SYSSERVICES 60 | #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) 61 | #endif 62 | 63 | void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */ 64 | void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); 65 | void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen); 66 | void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); 67 | void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen); 68 | void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); 69 | void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen); 70 | 71 | #endif /* SNMP_LWIP_MIB2 */ 72 | #endif /* LWIP_SNMP */ 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* LWIP_HDR_APPS_SNMP_MIB2_H */ 79 | -------------------------------------------------------------------------------- /src/include/lwip/apps/snmpv3.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Additional SNMPv3 functionality RFC3414 and RFC3826. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2016 Elias Oenal. 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: Elias Oenal 33 | */ 34 | 35 | #ifndef LWIP_HDR_APPS_SNMP_V3_H 36 | #define LWIP_HDR_APPS_SNMP_V3_H 37 | 38 | #include "lwip/apps/snmp_opts.h" 39 | #include "lwip/err.h" 40 | 41 | #if LWIP_SNMP && LWIP_SNMP_V3 42 | 43 | #define SNMP_V3_AUTH_ALGO_INVAL 0 44 | #define SNMP_V3_AUTH_ALGO_MD5 1 45 | #define SNMP_V3_AUTH_ALGO_SHA 2 46 | 47 | #define SNMP_V3_PRIV_ALGO_INVAL 0 48 | #define SNMP_V3_PRIV_ALGO_DES 1 49 | #define SNMP_V3_PRIV_ALGO_AES 2 50 | 51 | #define SNMP_V3_PRIV_MODE_DECRYPT 0 52 | #define SNMP_V3_PRIV_MODE_ENCRYPT 1 53 | 54 | /* 55 | * The following callback functions must be implemented by the application. 56 | * There is a dummy implementation in snmpv3_dummy.c. 57 | */ 58 | 59 | void snmpv3_get_engine_id(const char **id, u8_t *len); 60 | err_t snmpv3_set_engine_id(const char* id, u8_t len); 61 | 62 | u32_t snmpv3_get_engine_boots(void); 63 | void snmpv3_set_engine_boots(u32_t boots); 64 | 65 | u32_t snmpv3_get_engine_time(void); 66 | void snmpv3_reset_engine_time(void); 67 | 68 | err_t snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *priv_algo, u8_t *priv_key); 69 | 70 | /* The following functions are provided by the SNMPv3 agent */ 71 | 72 | void snmpv3_engine_id_changed(void); 73 | 74 | void snmpv3_password_to_key_md5( 75 | const u8_t *password, /* IN */ 76 | u8_t passwordlen, /* IN */ 77 | const u8_t *engineID, /* IN - pointer to snmpEngineID */ 78 | u8_t engineLength, /* IN - length of snmpEngineID */ 79 | u8_t *key); /* OUT - pointer to caller 16-octet buffer */ 80 | 81 | void snmpv3_password_to_key_sha( 82 | const u8_t *password, /* IN */ 83 | u8_t passwordlen, /* IN */ 84 | const u8_t *engineID, /* IN - pointer to snmpEngineID */ 85 | u8_t engineLength, /* IN - length of snmpEngineID */ 86 | u8_t *key); /* OUT - pointer to caller 20-octet buffer */ 87 | 88 | #endif 89 | 90 | #endif /* LWIP_HDR_APPS_SNMP_V3_H */ 91 | -------------------------------------------------------------------------------- /src/include/lwip/apps/sntp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * SNTP client API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Frédéric Bernon, Simon Goldschmidt 35 | * 36 | */ 37 | #ifndef LWIP_HDR_APPS_SNTP_H 38 | #define LWIP_HDR_APPS_SNTP_H 39 | 40 | #include "lwip/apps/sntp_opts.h" 41 | #include "lwip/ip_addr.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* SNTP operating modes: default is to poll using unicast. 48 | The mode has to be set before calling sntp_init(). */ 49 | #define SNTP_OPMODE_POLL 0 50 | #define SNTP_OPMODE_LISTENONLY 1 51 | void sntp_setoperatingmode(u8_t operating_mode); 52 | u8_t sntp_getoperatingmode(void); 53 | 54 | void sntp_init(void); 55 | void sntp_stop(void); 56 | u8_t sntp_enabled(void); 57 | 58 | void sntp_setserver(u8_t idx, const ip_addr_t *addr); 59 | const ip_addr_t* sntp_getserver(u8_t idx); 60 | 61 | #if SNTP_SERVER_DNS 62 | void sntp_setservername(u8_t idx, char *server); 63 | char *sntp_getservername(u8_t idx); 64 | #endif /* SNTP_SERVER_DNS */ 65 | 66 | #if SNTP_GET_SERVERS_FROM_DHCP 67 | void sntp_servermode_dhcp(int set_servers_from_dhcp); 68 | #else /* SNTP_GET_SERVERS_FROM_DHCP */ 69 | #define sntp_servermode_dhcp(x) 70 | #endif /* SNTP_GET_SERVERS_FROM_DHCP */ 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* LWIP_HDR_APPS_SNTP_H */ 77 | -------------------------------------------------------------------------------- /src/include/lwip/apps/tftp_opts.h: -------------------------------------------------------------------------------- 1 | /****************************************************************//** 2 | * 3 | * @file tftp_opts.h 4 | * 5 | * @author Logan Gunthorpe 6 | * 7 | * @brief Trivial File Transfer Protocol (RFC 1350) implementation options 8 | * 9 | * Copyright (c) Deltatee Enterprises Ltd. 2013 10 | * All rights reserved. 11 | * 12 | ********************************************************************/ 13 | 14 | /* 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification,are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. The name of the author may not be used to endorse or promote products 24 | * derived from this software without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 29 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 31 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * Author: Logan Gunthorpe 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_APPS_TFTP_OPTS_H 42 | #define LWIP_HDR_APPS_TFTP_OPTS_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | /** 47 | * @defgroup tftp_opts Options 48 | * @ingroup tftp 49 | * @{ 50 | */ 51 | 52 | /** 53 | * Enable TFTP debug messages 54 | */ 55 | #if !defined TFTP_DEBUG || defined __DOXYGEN__ 56 | #define TFTP_DEBUG LWIP_DBG_ON 57 | #endif 58 | 59 | /** 60 | * TFTP server port 61 | */ 62 | #if !defined TFTP_PORT || defined __DOXYGEN__ 63 | #define TFTP_PORT 69 64 | #endif 65 | 66 | /** 67 | * TFTP timeout 68 | */ 69 | #if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__ 70 | #define TFTP_TIMEOUT_MSECS 10000 71 | #endif 72 | 73 | /** 74 | * Max. number of retries when a file is read from server 75 | */ 76 | #if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__ 77 | #define TFTP_MAX_RETRIES 5 78 | #endif 79 | 80 | /** 81 | * TFTP timer cyclic interval 82 | */ 83 | #if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__ 84 | #define TFTP_TIMER_MSECS 50 85 | #endif 86 | 87 | /** 88 | * Max. length of TFTP filename 89 | */ 90 | #if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__ 91 | #define TFTP_MAX_FILENAME_LEN 20 92 | #endif 93 | 94 | /** 95 | * Max. length of TFTP mode 96 | */ 97 | #if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__ 98 | #define TFTP_MAX_MODE_LEN 7 99 | #endif 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | #endif /* LWIP_HDR_APPS_TFTP_OPTS_H */ 106 | -------------------------------------------------------------------------------- /src/include/lwip/apps/tftp_server.h: -------------------------------------------------------------------------------- 1 | /****************************************************************//** 2 | * 3 | * @file tftp_server.h 4 | * 5 | * @author Logan Gunthorpe 6 | * 7 | * @brief Trivial File Transfer Protocol (RFC 1350) 8 | * 9 | * Copyright (c) Deltatee Enterprises Ltd. 2013 10 | * All rights reserved. 11 | * 12 | ********************************************************************/ 13 | 14 | /* 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification,are permitted provided that the following conditions are met: 17 | * 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. The name of the author may not be used to endorse or promote products 24 | * derived from this software without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 27 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 29 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 31 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | * Author: Logan Gunthorpe 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_APPS_TFTP_SERVER_H 42 | #define LWIP_HDR_APPS_TFTP_SERVER_H 43 | 44 | #include "lwip/apps/tftp_opts.h" 45 | #include "lwip/err.h" 46 | #include "lwip/pbuf.h" 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /** @ingroup tftp 53 | * TFTP context containing callback functions for TFTP transfers 54 | */ 55 | struct tftp_context { 56 | /** 57 | * Open file for read/write. 58 | * @param fname Filename 59 | * @param mode Mode string from TFTP RFC 1350 (netascii, octet, mail) 60 | * @param write Flag indicating read (0) or write (!= 0) access 61 | * @returns File handle supplied to other functions 62 | */ 63 | void* (*open)(const char* fname, const char* mode, u8_t write); 64 | /** 65 | * Close file handle 66 | * @param handle File handle returned by open() 67 | */ 68 | void (*close)(void* handle); 69 | /** 70 | * Read from file 71 | * @param handle File handle returned by open() 72 | * @param buf Target buffer to copy read data to 73 | * @param bytes Number of bytes to copy to buf 74 | * @returns >= 0: Success; < 0: Error 75 | */ 76 | int (*read)(void* handle, void* buf, int bytes); 77 | /** 78 | * Write to file 79 | * @param handle File handle returned by open() 80 | * @param pbuf PBUF adjusted such that payload pointer points 81 | * to the beginning of write data. In other words, 82 | * TFTP headers are stripped off. 83 | * @returns >= 0: Success; < 0: Error 84 | */ 85 | int (*write)(void* handle, struct pbuf* p); 86 | }; 87 | 88 | err_t tftp_init(const struct tftp_context* ctx); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_HDR_APPS_TFTP_SERVER_H */ 95 | -------------------------------------------------------------------------------- /src/include/lwip/autoip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * AutoIP Automatic LinkLocal IP Configuration 5 | */ 6 | 7 | /* 8 | * 9 | * Copyright (c) 2007 Dominik Spies 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 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. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * Author: Dominik Spies 35 | * 36 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 37 | * with RFC 3927. 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_AUTOIP_H 42 | #define LWIP_HDR_AUTOIP_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/netif.h" 49 | /* #include "lwip/udp.h" */ 50 | #include "lwip/etharp.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** AutoIP Timing */ 57 | #define AUTOIP_TMR_INTERVAL 100 58 | #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) 59 | 60 | /** AutoIP state information per netif */ 61 | struct autoip 62 | { 63 | /** the currently selected, probed, announced or used LL IP-Address */ 64 | ip4_addr_t llipaddr; 65 | /** current AutoIP state machine state */ 66 | u8_t state; 67 | /** sent number of probes or announces, dependent on state */ 68 | u8_t sent_num; 69 | /** ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ 70 | u16_t ttw; 71 | /** ticks until a conflict can be solved by defending */ 72 | u8_t lastconflict; 73 | /** total number of probed/used Link Local IP-Addresses */ 74 | u8_t tried_llipaddr; 75 | }; 76 | 77 | 78 | void autoip_set_struct(struct netif *netif, struct autoip *autoip); 79 | /** Remove a struct autoip previously set to the netif using autoip_set_struct() */ 80 | #define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0) 81 | err_t autoip_start(struct netif *netif); 82 | err_t autoip_stop(struct netif *netif); 83 | void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); 84 | void autoip_tmr(void); 85 | void autoip_network_changed(struct netif *netif); 86 | u8_t autoip_supplied_address(const struct netif *netif); 87 | 88 | /* for lwIP internal use by ip4.c */ 89 | u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr); 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* LWIP_IPV4 && LWIP_AUTOIP */ 96 | 97 | #endif /* LWIP_HDR_AUTOIP_H */ 98 | -------------------------------------------------------------------------------- /src/include/lwip/dhcp6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 address autoconfiguration as per RFC 4862. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * IPv6 address autoconfiguration as per RFC 4862. 38 | * 39 | * Please coordinate changes and requests with Ivan Delamer 40 | * 41 | */ 42 | 43 | #ifndef LWIP_HDR_IP6_DHCP6_H 44 | #define LWIP_HDR_IP6_DHCP6_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */ 49 | 50 | 51 | struct dhcp6 52 | { 53 | /*@todo: implement DHCP6*/ 54 | }; 55 | 56 | #endif /* LWIP_IPV6_DHCP6 */ 57 | 58 | #endif /* LWIP_HDR_IP6_DHCP6_H */ 59 | -------------------------------------------------------------------------------- /src/include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Error codes 4 | */ 5 | /* 6 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 23 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 25 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 29 | * OF SUCH DAMAGE. 30 | * 31 | * This file is part of the lwIP TCP/IP stack. 32 | * 33 | * Author: Adam Dunkels 34 | * 35 | */ 36 | #ifndef LWIP_HDR_ERR_H 37 | #define LWIP_HDR_ERR_H 38 | 39 | #include "lwip/opt.h" 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** 47 | * @defgroup infrastructure_errors Error codes 48 | * @ingroup infrastructure 49 | * @{ 50 | */ 51 | 52 | /** Define LWIP_ERR_T in cc.h if you want to use 53 | * a different type for your platform (must be signed). */ 54 | #ifdef LWIP_ERR_T 55 | typedef LWIP_ERR_T err_t; 56 | #else /* LWIP_ERR_T */ 57 | typedef s8_t err_t; 58 | #endif /* LWIP_ERR_T*/ 59 | 60 | /** Definitions for error constants. */ 61 | typedef enum { 62 | /** No error, everything OK. */ 63 | ERR_OK = 0, 64 | /** Out of memory error. */ 65 | ERR_MEM = -1, 66 | /** Buffer error. */ 67 | ERR_BUF = -2, 68 | /** Timeout. */ 69 | ERR_TIMEOUT = -3, 70 | /** Routing problem. */ 71 | ERR_RTE = -4, 72 | /** Operation in progress */ 73 | ERR_INPROGRESS = -5, 74 | /** Illegal value. */ 75 | ERR_VAL = -6, 76 | /** Operation would block. */ 77 | ERR_WOULDBLOCK = -7, 78 | /** Address in use. */ 79 | ERR_USE = -8, 80 | /** Already connecting. */ 81 | ERR_ALREADY = -9, 82 | /** Conn already established.*/ 83 | ERR_ISCONN = -10, 84 | /** Not connected. */ 85 | ERR_CONN = -11, 86 | /** Low-level netif error */ 87 | ERR_IF = -12, 88 | 89 | /** Connection aborted. */ 90 | ERR_ABRT = -13, 91 | /** Connection reset. */ 92 | ERR_RST = -14, 93 | /** Connection closed. */ 94 | ERR_CLSD = -15, 95 | /** Illegal argument. */ 96 | ERR_ARG = -16 97 | } err_enum_t; 98 | 99 | #define ERR_IS_FATAL(e) ((e) <= ERR_ABRT) 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | #ifdef LWIP_DEBUG 106 | extern const char *lwip_strerr(err_t err); 107 | #else 108 | #define lwip_strerr(x) "" 109 | #endif /* LWIP_DEBUG */ 110 | 111 | #if !NO_SYS 112 | int err_to_errno(err_t err); 113 | #endif /* !NO_SYS */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* LWIP_HDR_ERR_H */ 120 | -------------------------------------------------------------------------------- /src/include/lwip/ethip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Ethernet output for IPv6. Uses ND tables for link-layer addressing. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_ETHIP6_H 43 | #define LWIP_HDR_ETHIP6_H 44 | 45 | #include "lwip/opt.h" 46 | 47 | #if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip6.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | 60 | err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_IPV6 && LWIP_ETHERNET */ 67 | 68 | #endif /* LWIP_HDR_ETHIP6_H */ 69 | -------------------------------------------------------------------------------- /src/include/lwip/icmp6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 version of ICMP, as per RFC 4443. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | #ifndef LWIP_HDR_ICMP6_H 42 | #define LWIP_HDR_ICMP6_H 43 | 44 | #include "lwip/opt.h" 45 | #include "lwip/pbuf.h" 46 | #include "lwip/ip6_addr.h" 47 | #include "lwip/netif.h" 48 | #include "lwip/prot/icmp6.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 55 | 56 | void icmp6_input(struct pbuf *p, struct netif *inp); 57 | void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c); 58 | void icmp6_packet_too_big(struct pbuf *p, u32_t mtu); 59 | void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c); 60 | void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, u32_t pointer); 61 | 62 | #endif /* LWIP_ICMP6 && LWIP_IPV6 */ 63 | 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | 70 | #endif /* LWIP_HDR_ICMP6_H */ 71 | -------------------------------------------------------------------------------- /src/include/lwip/ip4_frag.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IP fragmentation/reassembly 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Jani Monoses 35 | * 36 | */ 37 | 38 | #ifndef LWIP_HDR_IP4_FRAG_H 39 | #define LWIP_HDR_IP4_FRAG_H 40 | 41 | #include "lwip/opt.h" 42 | #include "lwip/err.h" 43 | #include "lwip/pbuf.h" 44 | #include "lwip/netif.h" 45 | #include "lwip/ip_addr.h" 46 | #include "lwip/ip.h" 47 | 48 | #if LWIP_IPV4 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if IP_REASSEMBLY 55 | /* The IP reassembly timer interval in milliseconds. */ 56 | #define IP_TMR_INTERVAL 1000 57 | 58 | /** IP reassembly helper struct. 59 | * This is exported because memp needs to know the size. 60 | */ 61 | struct ip_reassdata { 62 | struct ip_reassdata *next; 63 | struct pbuf *p; 64 | struct ip_hdr iphdr; 65 | u16_t datagram_len; 66 | u8_t flags; 67 | u8_t timer; 68 | }; 69 | 70 | void ip_reass_init(void); 71 | void ip_reass_tmr(void); 72 | struct pbuf * ip4_reass(struct pbuf *p); 73 | #endif /* IP_REASSEMBLY */ 74 | 75 | #if IP_FRAG 76 | #if !LWIP_NETIF_TX_SINGLE_PBUF 77 | #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED 78 | #define LWIP_PBUF_CUSTOM_REF_DEFINED 79 | /** A custom pbuf that holds a reference to another pbuf, which is freed 80 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 81 | * that points into the original pbuf. */ 82 | struct pbuf_custom_ref { 83 | /** 'base class' */ 84 | struct pbuf_custom pc; 85 | /** pointer to the original pbuf that is referenced */ 86 | struct pbuf *original; 87 | }; 88 | #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ 89 | #endif /* !LWIP_NETIF_TX_SINGLE_PBUF */ 90 | 91 | err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest); 92 | #endif /* IP_FRAG */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | 98 | #endif /* LWIP_IPV4 */ 99 | 100 | #endif /* LWIP_HDR_IP4_FRAG_H */ 101 | -------------------------------------------------------------------------------- /src/include/lwip/ip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 layer. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | #ifndef LWIP_HDR_IP6_H 42 | #define LWIP_HDR_IP6_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 47 | 48 | #include "lwip/ip6_addr.h" 49 | #include "lwip/prot/ip6.h" 50 | #include "lwip/def.h" 51 | #include "lwip/pbuf.h" 52 | #include "lwip/netif.h" 53 | 54 | #include "lwip/err.h" 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest); 61 | const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest); 62 | err_t ip6_input(struct pbuf *p, struct netif *inp); 63 | err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 64 | u8_t hl, u8_t tc, u8_t nexth); 65 | err_t ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 66 | u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); 67 | err_t ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 68 | u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); 69 | #if LWIP_NETIF_HWADDRHINT 70 | err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 71 | u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint); 72 | #endif /* LWIP_NETIF_HWADDRHINT */ 73 | #if LWIP_IPV6_MLD 74 | err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value); 75 | #endif /* LWIP_IPV6_MLD */ 76 | 77 | #define ip6_netif_get_local_ip(netif, dest) (((netif) != NULL) ? \ 78 | ip6_select_source_address(netif, dest) : NULL) 79 | 80 | #if IP6_DEBUG 81 | void ip6_debug_print(struct pbuf *p); 82 | #else 83 | #define ip6_debug_print(p) 84 | #endif /* IP6_DEBUG */ 85 | 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LWIP_IPV6 */ 92 | 93 | #endif /* LWIP_HDR_IP6_H */ 94 | -------------------------------------------------------------------------------- /src/include/lwip/mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Heap API 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_MEM_H 38 | #define LWIP_HDR_MEM_H 39 | 40 | #include "lwip/opt.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if MEM_LIBC_MALLOC 47 | 48 | #include "lwip/arch.h" 49 | 50 | typedef size_t mem_size_t; 51 | #define MEM_SIZE_F SZT_F 52 | 53 | #elif MEM_USE_POOLS 54 | 55 | typedef u16_t mem_size_t; 56 | #define MEM_SIZE_F U16_F 57 | 58 | #else 59 | 60 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of 61 | * 65535 leaves some room for alignment... 62 | */ 63 | #if MEM_SIZE > 64000L 64 | typedef u32_t mem_size_t; 65 | #define MEM_SIZE_F U32_F 66 | #else 67 | typedef u16_t mem_size_t; 68 | #define MEM_SIZE_F U16_F 69 | #endif /* MEM_SIZE > 64000 */ 70 | #endif 71 | 72 | void mem_init(void); 73 | void *mem_trim(void *mem, mem_size_t size); 74 | void *mem_malloc(mem_size_t size); 75 | void *mem_calloc(mem_size_t count, mem_size_t size); 76 | void mem_free(void *mem); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* LWIP_HDR_MEM_H */ 83 | -------------------------------------------------------------------------------- /src/include/lwip/mld6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710. 5 | * No support for MLDv2. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2010 Inico Technologies Ltd. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 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. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Ivan Delamer 37 | * 38 | * 39 | * Please coordinate changes and requests with Ivan Delamer 40 | * 41 | */ 42 | 43 | #ifndef LWIP_HDR_MLD6_H 44 | #define LWIP_HDR_MLD6_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_IPV6_MLD && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 49 | 50 | #include "lwip/pbuf.h" 51 | #include "lwip/netif.h" 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** MLD group */ 58 | struct mld_group { 59 | /** next link */ 60 | struct mld_group *next; 61 | /** multicast address */ 62 | ip6_addr_t group_address; 63 | /** signifies we were the last person to report */ 64 | u8_t last_reporter_flag; 65 | /** current state of the group */ 66 | u8_t group_state; 67 | /** timer for reporting */ 68 | u16_t timer; 69 | /** counter of simultaneous uses */ 70 | u8_t use; 71 | }; 72 | 73 | #define MLD6_TMR_INTERVAL 100 /* Milliseconds */ 74 | 75 | err_t mld6_stop(struct netif *netif); 76 | void mld6_report_groups(struct netif *netif); 77 | void mld6_tmr(void); 78 | struct mld_group *mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr); 79 | void mld6_input(struct pbuf *p, struct netif *inp); 80 | err_t mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); 81 | err_t mld6_joingroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); 82 | err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); 83 | err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); 84 | 85 | /** @ingroup mld6 86 | * Get list head of MLD6 groups for netif. 87 | * Note: The allnodes group IP is NOT in the list, since it must always 88 | * be received for correct IPv6 operation. 89 | * @see @ref netif_set_mld_mac_filter() 90 | */ 91 | #define netif_mld6_data(netif) ((struct mld_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_MLD6)) 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_IPV6_MLD && LWIP_IPV6 */ 98 | 99 | #endif /* LWIP_HDR_MLD6_H */ 100 | -------------------------------------------------------------------------------- /src/include/lwip/nd6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Neighbor discovery and stateless address autoconfiguration for IPv6. 5 | * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 6 | * (Address autoconfiguration). 7 | */ 8 | 9 | /* 10 | * Copyright (c) 2010 Inico Technologies Ltd. 11 | * All rights reserved. 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 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Ivan Delamer 38 | * 39 | * 40 | * Please coordinate changes and requests with Ivan Delamer 41 | * 42 | */ 43 | 44 | #ifndef LWIP_HDR_ND6_H 45 | #define LWIP_HDR_ND6_H 46 | 47 | #include "lwip/opt.h" 48 | 49 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 50 | 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/err.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** 1 second period */ 59 | #define ND6_TMR_INTERVAL 1000 60 | 61 | struct pbuf; 62 | struct netif; 63 | 64 | void nd6_tmr(void); 65 | void nd6_input(struct pbuf *p, struct netif *inp); 66 | void nd6_clear_destination_cache(void); 67 | struct netif *nd6_find_route(const ip6_addr_t *ip6addr); 68 | err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp); 69 | u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif); 70 | #if LWIP_ND6_TCP_REACHABILITY_HINTS 71 | void nd6_reachability_hint(const ip6_addr_t *ip6addr); 72 | #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ 73 | void nd6_cleanup_netif(struct netif *netif); 74 | #if LWIP_IPV6_MLD 75 | void nd6_adjust_mld_membership(struct netif *netif, s8_t addr_idx, u8_t new_state); 76 | #endif /* LWIP_IPV6_MLD */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* LWIP_IPV6 */ 83 | 84 | #endif /* LWIP_HDR_ND6_H */ 85 | -------------------------------------------------------------------------------- /src/include/lwip/prot/autoip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * AutoIP protocol definitions 4 | */ 5 | 6 | /* 7 | * 8 | * Copyright (c) 2007 Dominik Spies 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 | * Author: Dominik Spies 34 | * 35 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 36 | * with RFC 3927. 37 | * 38 | */ 39 | 40 | #ifndef LWIP_HDR_PROT_AUTOIP_H 41 | #define LWIP_HDR_PROT_AUTOIP_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 169.254.0.0 */ 48 | #define AUTOIP_NET 0xA9FE0000 49 | /* 169.254.1.0 */ 50 | #define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) 51 | /* 169.254.254.255 */ 52 | #define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) 53 | 54 | /* RFC 3927 Constants */ 55 | #define PROBE_WAIT 1 /* second (initial random delay) */ 56 | #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ 57 | #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ 58 | #define PROBE_NUM 3 /* (number of probe packets) */ 59 | #define ANNOUNCE_NUM 2 /* (number of announcement packets) */ 60 | #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ 61 | #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ 62 | #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ 63 | #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ 64 | #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ 65 | 66 | /* AutoIP client states */ 67 | typedef enum { 68 | AUTOIP_STATE_OFF = 0, 69 | AUTOIP_STATE_PROBING = 1, 70 | AUTOIP_STATE_ANNOUNCING = 2, 71 | AUTOIP_STATE_BOUND = 3 72 | } autoip_state_enum_t; 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* LWIP_HDR_PROT_AUTOIP_H */ 79 | -------------------------------------------------------------------------------- /src/include/lwip/prot/etharp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * ARP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_ETHARP_H 38 | #define LWIP_HDR_PROT_ETHARP_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/prot/ethernet.h" 42 | #include "lwip/ip4_addr.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #ifndef ETHARP_HWADDR_LEN 49 | #define ETHARP_HWADDR_LEN ETH_HWADDR_LEN 50 | #endif 51 | 52 | #ifdef PACK_STRUCT_USE_INCLUDES 53 | # include "arch/bpstruct.h" 54 | #endif 55 | PACK_STRUCT_BEGIN 56 | /** the ARP message, see RFC 826 ("Packet format") */ 57 | struct etharp_hdr { 58 | PACK_STRUCT_FIELD(u16_t hwtype); 59 | PACK_STRUCT_FIELD(u16_t proto); 60 | PACK_STRUCT_FLD_8(u8_t hwlen); 61 | PACK_STRUCT_FLD_8(u8_t protolen); 62 | PACK_STRUCT_FIELD(u16_t opcode); 63 | PACK_STRUCT_FLD_S(struct eth_addr shwaddr); 64 | PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr); 65 | PACK_STRUCT_FLD_S(struct eth_addr dhwaddr); 66 | PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr); 67 | } PACK_STRUCT_STRUCT; 68 | PACK_STRUCT_END 69 | #ifdef PACK_STRUCT_USE_INCLUDES 70 | # include "arch/epstruct.h" 71 | #endif 72 | 73 | #define SIZEOF_ETHARP_HDR 28 74 | 75 | /* ARP hwtype values */ 76 | enum etharp_hwtype { 77 | HWTYPE_ETHERNET = 1 78 | /* others not used */ 79 | }; 80 | 81 | /* ARP message types (opcodes) */ 82 | enum etharp_opcode { 83 | ARP_REQUEST = 1, 84 | ARP_REPLY = 2 85 | }; 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LWIP_HDR_PROT_ETHARP_H */ 92 | -------------------------------------------------------------------------------- /src/include/lwip/prot/icmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * ICMP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_ICMP_H 38 | #define LWIP_HDR_PROT_ICMP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define ICMP_ER 0 /* echo reply */ 47 | #define ICMP_DUR 3 /* destination unreachable */ 48 | #define ICMP_SQ 4 /* source quench */ 49 | #define ICMP_RD 5 /* redirect */ 50 | #define ICMP_ECHO 8 /* echo */ 51 | #define ICMP_TE 11 /* time exceeded */ 52 | #define ICMP_PP 12 /* parameter problem */ 53 | #define ICMP_TS 13 /* timestamp */ 54 | #define ICMP_TSR 14 /* timestamp reply */ 55 | #define ICMP_IRQ 15 /* information request */ 56 | #define ICMP_IR 16 /* information reply */ 57 | #define ICMP_AM 17 /* address mask request */ 58 | #define ICMP_AMR 18 /* address mask reply */ 59 | 60 | #ifdef PACK_STRUCT_USE_INCLUDES 61 | # include "arch/bpstruct.h" 62 | #endif 63 | /** This is the standard ICMP header only that the u32_t data 64 | * is split to two u16_t like ICMP echo needs it. 65 | * This header is also used for other ICMP types that do not 66 | * use the data part. 67 | */ 68 | PACK_STRUCT_BEGIN 69 | struct icmp_echo_hdr { 70 | PACK_STRUCT_FLD_8(u8_t type); 71 | PACK_STRUCT_FLD_8(u8_t code); 72 | PACK_STRUCT_FIELD(u16_t chksum); 73 | PACK_STRUCT_FIELD(u16_t id); 74 | PACK_STRUCT_FIELD(u16_t seqno); 75 | } PACK_STRUCT_STRUCT; 76 | PACK_STRUCT_END 77 | #ifdef PACK_STRUCT_USE_INCLUDES 78 | # include "arch/epstruct.h" 79 | #endif 80 | 81 | /* Compatibility defines, old versions used to combine type and code to an u16_t */ 82 | #define ICMPH_TYPE(hdr) ((hdr)->type) 83 | #define ICMPH_CODE(hdr) ((hdr)->code) 84 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) 85 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* LWIP_HDR_PROT_ICMP_H */ 92 | -------------------------------------------------------------------------------- /src/include/lwip/prot/igmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IGMP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IGMP_H 38 | #define LWIP_HDR_PROT_IGMP_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/ip4_addr.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 48 | * IGMP constants 49 | */ 50 | #define IGMP_TTL 1 51 | #define IGMP_MINLEN 8 52 | #define ROUTER_ALERT 0x9404U 53 | #define ROUTER_ALERTLEN 4 54 | 55 | /* 56 | * IGMP message types, including version number. 57 | */ 58 | #define IGMP_MEMB_QUERY 0x11 /* Membership query */ 59 | #define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */ 60 | #define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */ 61 | #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ 62 | 63 | /* Group membership states */ 64 | #define IGMP_GROUP_NON_MEMBER 0 65 | #define IGMP_GROUP_DELAYING_MEMBER 1 66 | #define IGMP_GROUP_IDLE_MEMBER 2 67 | 68 | /** 69 | * IGMP packet format. 70 | */ 71 | #ifdef PACK_STRUCT_USE_INCLUDES 72 | # include "arch/bpstruct.h" 73 | #endif 74 | PACK_STRUCT_BEGIN 75 | struct igmp_msg { 76 | PACK_STRUCT_FLD_8(u8_t igmp_msgtype); 77 | PACK_STRUCT_FLD_8(u8_t igmp_maxresp); 78 | PACK_STRUCT_FIELD(u16_t igmp_checksum); 79 | PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address); 80 | } PACK_STRUCT_STRUCT; 81 | PACK_STRUCT_END 82 | #ifdef PACK_STRUCT_USE_INCLUDES 83 | # include "arch/epstruct.h" 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* LWIP_HDR_PROT_IGMP_H */ 91 | -------------------------------------------------------------------------------- /src/include/lwip/prot/ip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IP_H 38 | #define LWIP_HDR_PROT_IP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #define IP_PROTO_ICMP 1 43 | #define IP_PROTO_IGMP 2 44 | #define IP_PROTO_UDP 17 45 | #define IP_PROTO_UDPLITE 136 46 | #define IP_PROTO_TCP 6 47 | 48 | /** This operates on a void* by loading the first byte */ 49 | #define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4) 50 | 51 | #endif /* LWIP_HDR_PROT_IP_H */ 52 | -------------------------------------------------------------------------------- /src/include/lwip/prot/mld6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * MLD6 protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_MLD6_H 38 | #define LWIP_HDR_PROT_MLD6_H 39 | 40 | #include "lwip/arch.h" 41 | #include "lwip/prot/ip6.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** Multicast listener report/query/done message header. */ 48 | #ifdef PACK_STRUCT_USE_INCLUDES 49 | # include "arch/bpstruct.h" 50 | #endif 51 | PACK_STRUCT_BEGIN 52 | struct mld_header { 53 | PACK_STRUCT_FLD_8(u8_t type); 54 | PACK_STRUCT_FLD_8(u8_t code); 55 | PACK_STRUCT_FIELD(u16_t chksum); 56 | PACK_STRUCT_FIELD(u16_t max_resp_delay); 57 | PACK_STRUCT_FIELD(u16_t reserved); 58 | PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); 59 | /* Options follow. */ 60 | } PACK_STRUCT_STRUCT; 61 | PACK_STRUCT_END 62 | #ifdef PACK_STRUCT_USE_INCLUDES 63 | # include "arch/epstruct.h" 64 | #endif 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* LWIP_HDR_PROT_MLD6_H */ 71 | -------------------------------------------------------------------------------- /src/include/lwip/prot/tcp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * TCP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_TCP_H 38 | #define LWIP_HDR_PROT_TCP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Length of the TCP header, excluding options. */ 47 | #define TCP_HLEN 20 48 | 49 | /* Fields are (of course) in network byte order. 50 | * Some fields are converted to host byte order in tcp_input(). 51 | */ 52 | #ifdef PACK_STRUCT_USE_INCLUDES 53 | # include "arch/bpstruct.h" 54 | #endif 55 | PACK_STRUCT_BEGIN 56 | struct tcp_hdr { 57 | PACK_STRUCT_FIELD(u16_t src); 58 | PACK_STRUCT_FIELD(u16_t dest); 59 | PACK_STRUCT_FIELD(u32_t seqno); 60 | PACK_STRUCT_FIELD(u32_t ackno); 61 | PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); 62 | PACK_STRUCT_FIELD(u16_t wnd); 63 | PACK_STRUCT_FIELD(u16_t chksum); 64 | PACK_STRUCT_FIELD(u16_t urgp); 65 | } PACK_STRUCT_STRUCT; 66 | PACK_STRUCT_END 67 | #ifdef PACK_STRUCT_USE_INCLUDES 68 | # include "arch/epstruct.h" 69 | #endif 70 | 71 | /* TCP header flags bits */ 72 | #define TCP_FIN 0x01U 73 | #define TCP_SYN 0x02U 74 | #define TCP_RST 0x04U 75 | #define TCP_PSH 0x08U 76 | #define TCP_ACK 0x10U 77 | #define TCP_URG 0x20U 78 | #define TCP_ECE 0x40U 79 | #define TCP_CWR 0x80U 80 | /* Valid TCP header flags */ 81 | #define TCP_FLAGS 0x3fU 82 | 83 | #define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) 84 | #define TCPH_FLAGS(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)) 85 | 86 | #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr)) 87 | #define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags)) 88 | #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = (u16_t)(lwip_htons((u16_t)((len) << 12) | (flags))) 89 | 90 | #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags)) 91 | #define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags)) 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_HDR_PROT_TCP_H */ 98 | -------------------------------------------------------------------------------- /src/include/lwip/prot/udp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * UDP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_UDP_H 38 | #define LWIP_HDR_PROT_UDP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define UDP_HLEN 8 47 | 48 | /* Fields are (of course) in network byte order. */ 49 | #ifdef PACK_STRUCT_USE_INCLUDES 50 | # include "arch/bpstruct.h" 51 | #endif 52 | PACK_STRUCT_BEGIN 53 | struct udp_hdr { 54 | PACK_STRUCT_FIELD(u16_t src); 55 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 56 | PACK_STRUCT_FIELD(u16_t len); 57 | PACK_STRUCT_FIELD(u16_t chksum); 58 | } PACK_STRUCT_STRUCT; 59 | PACK_STRUCT_END 60 | #ifdef PACK_STRUCT_USE_INCLUDES 61 | # include "arch/epstruct.h" 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* LWIP_HDR_PROT_UDP_H */ 69 | -------------------------------------------------------------------------------- /src/include/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* ARP has been moved to core/ipv4, provide this #include for compatibility only */ 2 | #include "lwip/etharp.h" 3 | #include "netif/ethernet.h" 4 | -------------------------------------------------------------------------------- /src/include/netif/ethernet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Ethernet input function - handles INCOMING ethernet level traffic 4 | * To be used in most low-level netif implementations 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 9 | * Copyright (c) 2003-2004 Leon Woestenberg 10 | * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. 11 | * All rights reserved. 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 | * 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 33 | * OF SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Adam Dunkels 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_NETIF_ETHERNET_H 42 | #define LWIP_HDR_NETIF_ETHERNET_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #include "lwip/pbuf.h" 47 | #include "lwip/netif.h" 48 | #include "lwip/prot/ethernet.h" 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #if LWIP_ARP || LWIP_ETHERNET 55 | 56 | /** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) 57 | * to a filter function that returns the correct netif when using multiple 58 | * netifs on one hardware interface where the netif's low-level receive 59 | * routine cannot decide for the correct netif (e.g. when mapping multiple 60 | * IP addresses to one hardware interface). 61 | */ 62 | #ifndef LWIP_ARP_FILTER_NETIF 63 | #define LWIP_ARP_FILTER_NETIF 0 64 | #endif 65 | 66 | err_t ethernet_input(struct pbuf *p, struct netif *netif); 67 | err_t ethernet_output(struct netif* netif, struct pbuf* p, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type); 68 | 69 | extern const struct eth_addr ethbroadcast, ethzero; 70 | 71 | #endif /* LWIP_ARP || LWIP_ETHERNET */ 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* LWIP_HDR_NETIF_ETHERNET_H */ 78 | -------------------------------------------------------------------------------- /src/include/netif/lowpan6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * 6LowPAN output for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2015 Inico Technologies Ltd. 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: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_LOWPAN6_H 43 | #define LWIP_HDR_LOWPAN6_H 44 | 45 | #include "netif/lowpan6_opts.h" 46 | 47 | #if LWIP_IPV6 && LWIP_6LOWPAN /* don't build if not configured for use in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip.h" 51 | #include "lwip/ip_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** 1 second period */ 59 | #define LOWPAN6_TMR_INTERVAL 1000 60 | 61 | void lowpan6_tmr(void); 62 | 63 | err_t lowpan6_set_context(u8_t index, const ip6_addr_t * context); 64 | err_t lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low); 65 | 66 | #if LWIP_IPV4 67 | err_t lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); 68 | #endif /* LWIP_IPV4 */ 69 | err_t lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 70 | err_t lowpan6_input(struct pbuf * p, struct netif *netif); 71 | err_t lowpan6_if_init(struct netif *netif); 72 | 73 | /* pan_id in network byte order. */ 74 | err_t lowpan6_set_pan_id(u16_t pan_id); 75 | 76 | #if !NO_SYS 77 | err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp); 78 | #endif /* !NO_SYS */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* LWIP_IPV6 && LWIP_6LOWPAN */ 85 | 86 | #endif /* LWIP_HDR_LOWPAN6_H */ 87 | -------------------------------------------------------------------------------- /src/include/netif/lowpan6_opts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 6LowPAN options list 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2015 Inico Technologies Ltd. 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 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Ivan Delamer 35 | * 36 | * 37 | * Please coordinate changes and requests with Ivan Delamer 38 | * 39 | */ 40 | 41 | #ifndef LWIP_HDR_LOWPAN6_OPTS_H 42 | #define LWIP_HDR_LOWPAN6_OPTS_H 43 | 44 | #include "lwip/opt.h" 45 | 46 | #ifndef LWIP_6LOWPAN 47 | #define LWIP_6LOWPAN 0 48 | #endif 49 | 50 | #ifndef LWIP_6LOWPAN_NUM_CONTEXTS 51 | #define LWIP_6LOWPAN_NUM_CONTEXTS 10 52 | #endif 53 | 54 | #ifndef LWIP_6LOWPAN_INFER_SHORT_ADDRESS 55 | #define LWIP_6LOWPAN_INFER_SHORT_ADDRESS 1 56 | #endif 57 | 58 | #ifndef LWIP_6LOWPAN_IPHC 59 | #define LWIP_6LOWPAN_IPHC 1 60 | #endif 61 | 62 | #ifndef LWIP_6LOWPAN_HW_CRC 63 | #define LWIP_6LOWPAN_HW_CRC 1 64 | #endif 65 | 66 | #ifndef LOWPAN6_DEBUG 67 | #define LOWPAN6_DEBUG LWIP_DBG_OFF 68 | #endif 69 | 70 | #endif /* LWIP_HDR_LOWPAN6_OPTS_H */ 71 | -------------------------------------------------------------------------------- /src/include/netif/ppp/chap-md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap-md5.h - New CHAP/MD5 implementation. 3 | * 4 | * Copyright (c) 2003 Paul Mackerras. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. The name(s) of the authors of this software must not be used to 14 | * endorse or promote products derived from this software without 15 | * prior written permission. 16 | * 17 | * 3. Redistributions of any form whatsoever must retain the following 18 | * acknowledgment: 19 | * "This product includes software developed by Paul Mackerras 20 | * ". 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | */ 30 | 31 | #include "netif/ppp/ppp_opts.h" 32 | #if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 33 | 34 | extern const struct chap_digest_type md5_digest; 35 | 36 | #endif /* PPP_SUPPORT && CHAP_SUPPORT */ 37 | -------------------------------------------------------------------------------- /src/include/netif/ppp/chap_ms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap_ms.h - Challenge Handshake Authentication Protocol definitions. 3 | * 4 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 35 | 36 | #ifndef CHAPMS_INCLUDE 37 | #define CHAPMS_INCLUDE 38 | 39 | extern const struct chap_digest_type chapms_digest; 40 | extern const struct chap_digest_type chapms2_digest; 41 | 42 | #endif /* CHAPMS_INCLUDE */ 43 | 44 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 45 | -------------------------------------------------------------------------------- /src/include/netif/ppp/ecp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ecp.h - Definitions for PPP Encryption Control Protocol. 3 | * 4 | * Copyright (c) 2002 Google, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. The name(s) of the authors of this software must not be used to 20 | * endorse or promote products derived from this software without 21 | * prior written permission. 22 | * 23 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 24 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 25 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 27 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 28 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 29 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 30 | * 31 | * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ 32 | */ 33 | 34 | #include "netif/ppp/ppp_opts.h" 35 | #if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 36 | 37 | typedef struct ecp_options { 38 | bool required; /* Is ECP required? */ 39 | unsigned enctype; /* Encryption type */ 40 | } ecp_options; 41 | 42 | extern fsm ecp_fsm[]; 43 | extern ecp_options ecp_wantoptions[]; 44 | extern ecp_options ecp_gotoptions[]; 45 | extern ecp_options ecp_allowoptions[]; 46 | extern ecp_options ecp_hisoptions[]; 47 | 48 | extern const struct protent ecp_protent; 49 | 50 | #endif /* PPP_SUPPORT && ECP_SUPPORT */ 51 | -------------------------------------------------------------------------------- /src/include/netif/ppp/eui64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.h - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #ifndef EUI64_H 42 | #define EUI64_H 43 | 44 | /* 45 | * @todo: 46 | * 47 | * Maybe this should be done by processing struct in6_addr directly... 48 | */ 49 | typedef union 50 | { 51 | u8_t e8[8]; 52 | u16_t e16[4]; 53 | u32_t e32[2]; 54 | } eui64_t; 55 | 56 | #define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) 57 | #define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ 58 | ((e).e32[1] == (o).e32[1])) 59 | #define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0; 60 | 61 | #define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t)) 62 | 63 | #define eui64_magic(e) do { \ 64 | (e).e32[0] = magic(); \ 65 | (e).e32[1] = magic(); \ 66 | (e).e8[0] &= ~2; \ 67 | } while (0) 68 | #define eui64_magic_nz(x) do { \ 69 | eui64_magic(x); \ 70 | } while (eui64_iszero(x)) 71 | #define eui64_magic_ne(x, y) do { \ 72 | eui64_magic(x); \ 73 | } while (eui64_equals(x, y)) 74 | 75 | #define eui64_get(ll, cp) do { \ 76 | eui64_copy((*cp), (ll)); \ 77 | (cp) += sizeof(eui64_t); \ 78 | } while (0) 79 | 80 | #define eui64_put(ll, cp) do { \ 81 | eui64_copy((ll), (*cp)); \ 82 | (cp) += sizeof(eui64_t); \ 83 | } while (0) 84 | 85 | #define eui64_set32(e, l) do { \ 86 | (e).e32[0] = 0; \ 87 | (e).e32[1] = lwip_htonl(l); \ 88 | } while (0) 89 | #define eui64_setlo32(e, l) eui64_set32(e, l) 90 | 91 | char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ 92 | 93 | #endif /* EUI64_H */ 94 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 95 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/arc4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file arc4.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_ARC4 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_ARC4_H 40 | #define LWIP_INCLUDED_POLARSSL_ARC4_H 41 | 42 | /** 43 | * \brief ARC4 context structure 44 | */ 45 | typedef struct 46 | { 47 | int x; /*!< permutation index */ 48 | int y; /*!< permutation index */ 49 | unsigned char m[256]; /*!< permutation table */ 50 | } 51 | arc4_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief ARC4 key schedule 59 | * 60 | * \param ctx ARC4 context to be initialized 61 | * \param key the secret key 62 | * \param keylen length of the key 63 | */ 64 | void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); 65 | 66 | /** 67 | * \brief ARC4 cipher function 68 | * 69 | * \param ctx ARC4 context 70 | * \param buf buffer to be processed 71 | * \param buflen amount of data in buf 72 | */ 73 | void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */ 80 | 81 | #endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ 82 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/des.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file des.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_DES 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_DES_H 40 | #define LWIP_INCLUDED_POLARSSL_DES_H 41 | 42 | #define DES_ENCRYPT 1 43 | #define DES_DECRYPT 0 44 | 45 | /** 46 | * \brief DES context structure 47 | */ 48 | typedef struct 49 | { 50 | int mode; /*!< encrypt/decrypt */ 51 | unsigned long sk[32]; /*!< DES subkeys */ 52 | } 53 | des_context; 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /** 60 | * \brief DES key schedule (56-bit, encryption) 61 | * 62 | * \param ctx DES context to be initialized 63 | * \param key 8-byte secret key 64 | */ 65 | void des_setkey_enc( des_context *ctx, unsigned char key[8] ); 66 | 67 | /** 68 | * \brief DES key schedule (56-bit, decryption) 69 | * 70 | * \param ctx DES context to be initialized 71 | * \param key 8-byte secret key 72 | */ 73 | void des_setkey_dec( des_context *ctx, unsigned char key[8] ); 74 | 75 | /** 76 | * \brief DES-ECB block encryption/decryption 77 | * 78 | * \param ctx DES context 79 | * \param input 64-bit input block 80 | * \param output 64-bit output block 81 | */ 82 | void des_crypt_ecb( des_context *ctx, 83 | const unsigned char input[8], 84 | unsigned char output[8] ); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* LWIP_INCLUDED_POLARSSL_DES_H */ 91 | 92 | #endif /* LWIP_INCLUDED_POLARSSL_DES */ 93 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/md4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md4.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_MD4 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_MD4_H 40 | #define LWIP_INCLUDED_POLARSSL_MD4_H 41 | 42 | /** 43 | * \brief MD4 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[4]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | md4_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief MD4 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void md4_starts( md4_context *ctx ); 63 | 64 | /** 65 | * \brief MD4 process buffer 66 | * 67 | * \param ctx MD4 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief MD4 final digest 75 | * 76 | * \param ctx MD4 context 77 | * \param output MD4 checksum result 78 | */ 79 | void md4_finish( md4_context *ctx, unsigned char output[16] ); 80 | 81 | /** 82 | * \brief Output = MD4( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output MD4 checksum result 87 | */ 88 | void md4( unsigned char *input, int ilen, unsigned char output[16] ); 89 | 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* LWIP_INCLUDED_POLARSSL_MD4_H */ 96 | 97 | #endif /* LWIP_INCLUDED_POLARSSL_MD4 */ 98 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/md5.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md5.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_MD5 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_MD5_H 40 | #define LWIP_INCLUDED_POLARSSL_MD5_H 41 | 42 | /** 43 | * \brief MD5 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[4]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | md5_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief MD5 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void md5_starts( md5_context *ctx ); 63 | 64 | /** 65 | * \brief MD5 process buffer 66 | * 67 | * \param ctx MD5 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief MD5 final digest 75 | * 76 | * \param ctx MD5 context 77 | * \param output MD5 checksum result 78 | */ 79 | void md5_finish( md5_context *ctx, unsigned char output[16] ); 80 | 81 | /** 82 | * \brief Output = MD5( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output MD5 checksum result 87 | */ 88 | void md5( unsigned char *input, int ilen, unsigned char output[16] ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ 95 | 96 | #endif /* LWIP_INCLUDED_POLARSSL_MD5 */ 97 | -------------------------------------------------------------------------------- /src/include/netif/ppp/polarssl/sha1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file sha1.h 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "netif/ppp/ppp_opts.h" 37 | #if LWIP_INCLUDED_POLARSSL_SHA1 38 | 39 | #ifndef LWIP_INCLUDED_POLARSSL_SHA1_H 40 | #define LWIP_INCLUDED_POLARSSL_SHA1_H 41 | 42 | /** 43 | * \brief SHA-1 context structure 44 | */ 45 | typedef struct 46 | { 47 | unsigned long total[2]; /*!< number of bytes processed */ 48 | unsigned long state[5]; /*!< intermediate digest state */ 49 | unsigned char buffer[64]; /*!< data block being processed */ 50 | } 51 | sha1_context; 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief SHA-1 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void sha1_starts( sha1_context *ctx ); 63 | 64 | /** 65 | * \brief SHA-1 process buffer 66 | * 67 | * \param ctx SHA-1 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); 72 | 73 | /** 74 | * \brief SHA-1 final digest 75 | * 76 | * \param ctx SHA-1 context 77 | * \param output SHA-1 checksum result 78 | */ 79 | void sha1_finish( sha1_context *ctx, unsigned char output[20] ); 80 | 81 | /** 82 | * \brief Output = SHA-1( input buffer ) 83 | * 84 | * \param input buffer holding the data 85 | * \param ilen length of the input data 86 | * \param output SHA-1 checksum result 87 | */ 88 | void sha1( unsigned char *input, int ilen, unsigned char output[20] ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ 95 | 96 | #endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ 97 | -------------------------------------------------------------------------------- /src/include/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 | 37 | #include "netif/ppp/ppp_opts.h" 38 | #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 39 | 40 | #ifndef PPPDEBUG_H 41 | #define PPPDEBUG_H 42 | 43 | /* Trace levels. */ 44 | #define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 45 | #define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) 46 | #define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 47 | #define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) 48 | #define LOG_INFO (PPP_DEBUG) 49 | #define LOG_DETAIL (PPP_DEBUG) 50 | #define LOG_DEBUG (PPP_DEBUG) 51 | 52 | #if PPP_DEBUG 53 | 54 | #define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 55 | #define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 56 | #define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 57 | #define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 58 | #define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 59 | #define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 60 | #define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 61 | #define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) 62 | #define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) 63 | 64 | #else /* PPP_DEBUG */ 65 | 66 | #define MAINDEBUG(a) 67 | #define SYSDEBUG(a) 68 | #define FSMDEBUG(a) 69 | #define LCPDEBUG(a) 70 | #define IPCPDEBUG(a) 71 | #define IPV6CPDEBUG(a) 72 | #define UPAPDEBUG(a) 73 | #define CHAPDEBUG(a) 74 | #define PPPDEBUG(a, b) 75 | 76 | #endif /* PPP_DEBUG */ 77 | 78 | #endif /* PPPDEBUG_H */ 79 | 80 | #endif /* PPP_SUPPORT */ 81 | -------------------------------------------------------------------------------- /src/include/netif/slipif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * SLIP netif API 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001, Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the Institute nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * This file is part of the lwIP TCP/IP stack. 36 | * 37 | * Author: Adam Dunkels 38 | * 39 | */ 40 | #ifndef LWIP_HDR_NETIF_SLIPIF_H 41 | #define LWIP_HDR_NETIF_SLIPIF_H 42 | 43 | #include "lwip/opt.h" 44 | #include "lwip/netif.h" 45 | 46 | /** Set this to 1 to start a thread that blocks reading on the serial line 47 | * (using sio_read()). 48 | */ 49 | #ifndef SLIP_USE_RX_THREAD 50 | #define SLIP_USE_RX_THREAD !NO_SYS 51 | #endif 52 | 53 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 54 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 55 | * packets on a queue, which is fed into lwIP from slipif_poll(). 56 | * If disabled, slipif_poll() polls the serial line (using sio_tryread()). 57 | */ 58 | #ifndef SLIP_RX_FROM_ISR 59 | #define SLIP_RX_FROM_ISR 0 60 | #endif 61 | 62 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 63 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 64 | * If disabled, packets will be dropped if more than one packet is received. 65 | */ 66 | #ifndef SLIP_RX_QUEUE 67 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 68 | #endif 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | err_t slipif_init(struct netif * netif); 75 | void slipif_poll(struct netif *netif); 76 | #if SLIP_RX_FROM_ISR 77 | void slipif_process_rxqueue(struct netif *netif); 78 | void slipif_received_byte(struct netif *netif, u8_t data); 79 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 80 | #endif /* SLIP_RX_FROM_ISR */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* LWIP_HDR_NETIF_SLIPIF_H */ 87 | 88 | -------------------------------------------------------------------------------- /src/include/posix/errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/errno.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/errno.h" 34 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | ethernet.c 6 | Shared code for Ethernet based interfaces. 7 | 8 | ethernetif.c 9 | An example of how an Ethernet device driver could look. This 10 | file can be used as a "skeleton" for developing new Ethernet 11 | network device drivers. It uses the etharp.c ARP code. 12 | 13 | lowpan6.c 14 | A 6LoWPAN implementation as a netif. 15 | 16 | slipif.c 17 | A generic implementation of the SLIP (Serial Line IP) 18 | protocol. It requires a sio (serial I/O) module to work. 19 | 20 | ppp/ Point-to-Point Protocol stack 21 | The lwIP PPP support is based from pppd (http://ppp.samba.org) with 22 | huge changes to match code size and memory requirements for embedded 23 | devices. Please read /doc/ppp.txt and ppp/PPPD_FOLLOWUP for a detailed 24 | explanation. 25 | -------------------------------------------------------------------------------- /src/netif/ppp/eui64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.c - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #include "netif/ppp/ppp_impl.h" 42 | #include "netif/ppp/eui64.h" 43 | 44 | /* 45 | * eui64_ntoa - Make an ascii representation of an interface identifier 46 | */ 47 | char *eui64_ntoa(eui64_t e) { 48 | static char buf[20]; 49 | 50 | sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x", 51 | e.e8[0], e.e8[1], e.e8[2], e.e8[3], 52 | e.e8[4], e.e8[5], e.e8[6], e.e8[7]); 53 | return buf; 54 | } 55 | 56 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 57 | -------------------------------------------------------------------------------- /src/netif/ppp/polarssl/README: -------------------------------------------------------------------------------- 1 | About PolarSSL files into lwIP PPP support 2 | ------------------------------------------ 3 | 4 | This folder contains some files fetched from the latest BSD release of 5 | the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption 6 | methods we need for lwIP PPP support. 7 | 8 | The PolarSSL files were cleaned to contain only the necessary struct 9 | fields and functions needed for lwIP. 10 | 11 | The PolarSSL API was not changed at all, so if you are already using 12 | PolarSSL you can choose to skip the compilation of the included PolarSSL 13 | library into lwIP. 14 | 15 | If you are not using the embedded copy you must include external 16 | libraries into your arch/cc.h port file. 17 | 18 | Beware of the stack requirements which can be a lot larger if you are not 19 | using our cleaned PolarSSL library. 20 | 21 | 22 | PolarSSL project website: http://polarssl.org/ 23 | -------------------------------------------------------------------------------- /src/netif/ppp/polarssl/arc4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * An implementation of the ARCFOUR algorithm 3 | * 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine 5 | * 6 | * Copyright (C) 2009 Paul Bakker 7 | * 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * * Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | /* 36 | * The ARCFOUR algorithm was publicly disclosed on 94/09. 37 | * 38 | * http://groups.google.com/group/sci.crypt/msg/10a300c9d21afca0 39 | */ 40 | 41 | #include "netif/ppp/ppp_opts.h" 42 | #if PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_ARC4 43 | 44 | #include "netif/ppp/polarssl/arc4.h" 45 | /* 46 | * ARC4 key schedule 47 | */ 48 | void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ) 49 | { 50 | int i, j, k, a; 51 | unsigned char *m; 52 | 53 | ctx->x = 0; 54 | ctx->y = 0; 55 | m = ctx->m; 56 | 57 | for( i = 0; i < 256; i++ ) 58 | m[i] = (unsigned char) i; 59 | 60 | j = k = 0; 61 | 62 | for( i = 0; i < 256; i++, k++ ) 63 | { 64 | if( k >= keylen ) k = 0; 65 | 66 | a = m[i]; 67 | j = ( j + a + key[k] ) & 0xFF; 68 | m[i] = m[j]; 69 | m[j] = (unsigned char) a; 70 | } 71 | } 72 | 73 | /* 74 | * ARC4 cipher function 75 | */ 76 | void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ) 77 | { 78 | int i, x, y, a, b; 79 | unsigned char *m; 80 | 81 | x = ctx->x; 82 | y = ctx->y; 83 | m = ctx->m; 84 | 85 | for( i = 0; i < buflen; i++ ) 86 | { 87 | x = ( x + 1 ) & 0xFF; a = m[x]; 88 | y = ( y + a ) & 0xFF; b = m[y]; 89 | 90 | m[x] = (unsigned char) b; 91 | m[y] = (unsigned char) a; 92 | 93 | buf[i] = (unsigned char) 94 | ( buf[i] ^ m[(unsigned char)( a + b )] ); 95 | } 96 | 97 | ctx->x = x; 98 | ctx->y = y; 99 | } 100 | 101 | #endif /* PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_DES */ 102 | -------------------------------------------------------------------------------- /src/netif/ppp/pppcrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1 3 | * 4 | * Extracted from chap_ms.c by James Carlson. 5 | * 6 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. The name(s) of the authors of this software must not be used to 21 | * endorse or promote products derived from this software without 22 | * prior written permission. 23 | * 24 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 25 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 26 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 27 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 28 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 29 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 30 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not necessary */ 35 | 36 | #include "netif/ppp/ppp_impl.h" 37 | 38 | #include "netif/ppp/pppcrypt.h" 39 | 40 | 41 | static u_char pppcrypt_get_7bits(u_char *input, int startBit) { 42 | unsigned int word; 43 | 44 | word = (unsigned)input[startBit / 8] << 8; 45 | word |= (unsigned)input[startBit / 8 + 1]; 46 | 47 | word >>= 15 - (startBit % 8 + 7); 48 | 49 | return word & 0xFE; 50 | } 51 | 52 | /* IN 56 bit DES key missing parity bits 53 | * OUT 64 bit DES key with parity bits added 54 | */ 55 | void pppcrypt_56_to_64_bit_key(u_char *key, u_char * des_key) { 56 | des_key[0] = pppcrypt_get_7bits(key, 0); 57 | des_key[1] = pppcrypt_get_7bits(key, 7); 58 | des_key[2] = pppcrypt_get_7bits(key, 14); 59 | des_key[3] = pppcrypt_get_7bits(key, 21); 60 | des_key[4] = pppcrypt_get_7bits(key, 28); 61 | des_key[5] = pppcrypt_get_7bits(key, 35); 62 | des_key[6] = pppcrypt_get_7bits(key, 42); 63 | des_key[7] = pppcrypt_get_7bits(key, 49); 64 | } 65 | 66 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 67 | -------------------------------------------------------------------------------- /test/fuzz/Makefile: -------------------------------------------------------------------------------- 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 | all compile: lwip_fuzz 33 | .PHONY: all clean 34 | 35 | CC=afl-gcc 36 | LDFLAGS=-lm 37 | CFLAGS=-O0 38 | 39 | CONTRIBDIR=../../../lwip-contrib 40 | include $(CONTRIBDIR)/ports/unix/Common.mk 41 | 42 | clean: 43 | rm -f *.o $(LWIPLIBCOMMON) lwip_fuzz *.s .depend* *.core core 44 | 45 | depend dep: .depend 46 | 47 | include .depend 48 | 49 | .depend: fuzz.c $(LWIPFILES) $(APPFILES) 50 | $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend 51 | 52 | lwip_fuzz: .depend $(LWIPLIBCOMMON) fuzz.o 53 | $(CC) $(CFLAGS) -o lwip_fuzz fuzz.o $(LWIPLIBCOMMON) $(LDFLAGS) 54 | -------------------------------------------------------------------------------- /test/fuzz/README: -------------------------------------------------------------------------------- 1 | 2 | Fuzzing the lwIP stack (afl-fuzz requires linux/unix or similar) 3 | 4 | This directory contains a small app that reads Ethernet frames from stdin and 5 | processes them. It is used together with the 'american fuzzy lop' tool (found 6 | at http://lcamtuf.coredump.cx/afl/) and the sample inputs to test how 7 | unexpected inputs are handled. The afl tool will read the known inputs, and 8 | try to modify them to exercise as many code paths as possible, by instrumenting 9 | the code and keeping track of which code is executed. 10 | 11 | Just running make will produce the test program. 12 | 13 | Then run afl with: 14 | 15 | afl-fuzz -i inputs/ -o output ./lwip_fuzz 16 | 17 | and it should start working. It will probably complain about CPU scheduler, 18 | set AFL_SKIP_CPUFREQ=1 to ignore it. 19 | If it complains about invalid "/proc/sys/kernel/core_pattern" setting, try 20 | executing "sudo bash -c 'echo core > /proc/sys/kernel/core_pattern'". 21 | 22 | The input is split into different subdirectories since they test different 23 | parts of the code, and since you want to run one instance of afl-fuzz on each 24 | core. 25 | 26 | When afl finds a crash or a hang, the input that caused it will be placed in 27 | the output directory. If you have hexdump and text2pcap tools installed, 28 | running output_to_pcap.sh will create pcap files for each input 29 | file to simplify viewing in wireshark. 30 | 31 | The lwipopts.h file needs to have checksum checking off, otherwise almost every 32 | packet will be discarded because of that. The other options can be tuned to 33 | expose different parts of the code. 34 | 35 | -------------------------------------------------------------------------------- /test/fuzz/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/config.h -------------------------------------------------------------------------------- /test/fuzz/inputs/arp/arp_req.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/inputs/arp/arp_req.bin -------------------------------------------------------------------------------- /test/fuzz/inputs/icmp/icmp_ping.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/inputs/icmp/icmp_ping.bin -------------------------------------------------------------------------------- /test/fuzz/inputs/ipv6/neighbor_solicitation.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/inputs/ipv6/neighbor_solicitation.bin -------------------------------------------------------------------------------- /test/fuzz/inputs/ipv6/router_adv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/inputs/ipv6/router_adv.bin -------------------------------------------------------------------------------- /test/fuzz/inputs/tcp/tcp_syn.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/inputs/tcp/tcp_syn.bin -------------------------------------------------------------------------------- /test/fuzz/inputs/udp/udp_port_5000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARMmbed/lwip/4059748b4789fbda5970261bb075657565a1f381/test/fuzz/inputs/udp/udp_port_5000.bin -------------------------------------------------------------------------------- /test/fuzz/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 LWIP_HDR_LWIPOPTS_H__ 33 | #define LWIP_HDR_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 | #define SYS_LIGHTWEIGHT_PROT 0 40 | 41 | #define LWIP_IPV6 1 42 | #define IPV6_FRAG_COPYHEADER 1 43 | #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 44 | 45 | /* Enable DHCP to test it */ 46 | #define LWIP_DHCP 1 47 | 48 | /* Turn off checksum verification of fuzzed data */ 49 | #define CHECKSUM_CHECK_IP 0 50 | #define CHECKSUM_CHECK_UDP 0 51 | #define CHECKSUM_CHECK_TCP 0 52 | #define CHECKSUM_CHECK_ICMP 0 53 | #define CHECKSUM_CHECK_ICMP6 0 54 | 55 | /* Minimal changes to opt.h required for tcp unit tests: */ 56 | #define MEM_SIZE 16000 57 | #define TCP_SND_QUEUELEN 40 58 | #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN 59 | #define TCP_SND_BUF (12 * TCP_MSS) 60 | #define TCP_WND (10 * TCP_MSS) 61 | #define LWIP_WND_SCALE 1 62 | #define TCP_RCV_SCALE 0 63 | #define PBUF_POOL_SIZE 400 /* pbuf tests need ~200KByte */ 64 | 65 | /* Minimal changes to opt.h required for etharp unit tests: */ 66 | #define ETHARP_SUPPORT_STATIC_ENTRIES 1 67 | 68 | #endif /* LWIP_HDR_LWIPOPTS_H__ */ 69 | -------------------------------------------------------------------------------- /test/fuzz/output_to_pcap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ] 4 | then 5 | echo "This script will make pcap files from the afl-fuzz crash/hang files" 6 | echo "It needs hexdump and text2pcap" 7 | echo "Please give output directory as argument" 8 | exit 2 9 | fi 10 | 11 | for i in `ls $1/crashes/id*` 12 | do 13 | PCAPNAME=`echo $i | grep pcap` 14 | if [ -z "$PCAPNAME" ]; then 15 | hexdump -C $i > $1/$$.tmp 16 | text2pcap $1/$$.tmp ${i}.pcap 17 | fi 18 | done 19 | for i in `ls $1/hangs/id*` 20 | do 21 | PCAPNAME=`echo $i | grep pcap` 22 | if [ -z "$PCAPNAME" ]; then 23 | hexdump -C $i > $1/$$.tmp 24 | text2pcap $1/$$.tmp ${i}.pcap 25 | fi 26 | done 27 | rm -f $1/$$.tmp 28 | 29 | echo 30 | echo "Created pcap files:" 31 | ls $1/*/*.pcap 32 | -------------------------------------------------------------------------------- /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 | fail_unless(lwip_stats.mem.used == 0); 39 | 40 | p1 = mem_malloc(SIZE1); 41 | fail_unless(p1 != NULL); 42 | fail_unless(lwip_stats.mem.used >= SIZE1); 43 | s1 = lwip_stats.mem.used; 44 | 45 | p2 = mem_malloc(SIZE2); 46 | fail_unless(p2 != NULL); 47 | fail_unless(lwip_stats.mem.used >= SIZE2 + s1); 48 | s2 = lwip_stats.mem.used; 49 | 50 | mem_trim(p1, SIZE1_2); 51 | 52 | mem_free(p2); 53 | fail_unless(lwip_stats.mem.used <= s2 - SIZE2); 54 | 55 | mem_free(p1); 56 | fail_unless(lwip_stats.mem.used == 0); 57 | } 58 | END_TEST 59 | 60 | static void malloc_keep_x(int x, int num, int size, int freestep) 61 | { 62 | int i; 63 | void* p[16]; 64 | LWIP_ASSERT("invalid size", size >= 0 && size < (mem_size_t)-1); 65 | memset(p, 0, sizeof(p)); 66 | for(i = 0; i < num && i < 16; i++) { 67 | p[i] = mem_malloc((mem_size_t)size); 68 | fail_unless(p[i] != NULL); 69 | } 70 | for(i = 0; i < num && i < 16; i += freestep) { 71 | if (i == x) { 72 | continue; 73 | } 74 | mem_free(p[i]); 75 | p[i] = NULL; 76 | } 77 | for(i = 0; i < num && i < 16; i++) { 78 | if (i == x) { 79 | continue; 80 | } 81 | if (p[i] != NULL) { 82 | mem_free(p[i]); 83 | p[i] = NULL; 84 | } 85 | } 86 | fail_unless(p[x] != NULL); 87 | mem_free(p[x]); 88 | } 89 | 90 | START_TEST(test_mem_random) 91 | { 92 | const int num = 16; 93 | int x; 94 | int size; 95 | int freestep; 96 | LWIP_UNUSED_ARG(_i); 97 | 98 | fail_unless(lwip_stats.mem.used == 0); 99 | 100 | for (x = 0; x < num; x++) { 101 | for (size = 1; size < 32; size++) { 102 | for (freestep = 1; freestep <= 3; freestep++) { 103 | fail_unless(lwip_stats.mem.used == 0); 104 | malloc_keep_x(x, num, size, freestep); 105 | fail_unless(lwip_stats.mem.used == 0); 106 | } 107 | } 108 | } 109 | } 110 | END_TEST 111 | 112 | /** Create the suite including all tests for this module */ 113 | Suite * 114 | mem_suite(void) 115 | { 116 | testfunc tests[] = { 117 | TESTFUNC(test_mem_one), 118 | TESTFUNC(test_mem_random) 119 | }; 120 | return create_suite("MEM", tests, sizeof(tests)/sizeof(testfunc), mem_setup, mem_teardown); 121 | } 122 | -------------------------------------------------------------------------------- /test/unit/core/test_mem.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MEM_H 2 | #define LWIP_HDR_TEST_MEM_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *mem_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/core/test_pbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_PBUF_H 2 | #define LWIP_HDR_TEST_PBUF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *pbuf_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/dhcp/test_dhcp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_DHCP_H 2 | #define LWIP_HDR_TEST_DHCP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* dhcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/etharp/test_etharp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_ETHARP_H 2 | #define LWIP_HDR_TEST_ETHARP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* etharp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/lwip_check.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_LWIP_CHECK_H 2 | #define LWIP_HDR_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 struct { 17 | TFun func; 18 | const char *name; 19 | } testfunc; 20 | 21 | #define TESTFUNC(x) {(x), "" # x "" } 22 | 23 | /* Modified function from check.h, supplying function name */ 24 | #define tcase_add_named_test(tc,tf) \ 25 | _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1) 26 | 27 | /** typedef for a function returning a test suite */ 28 | typedef Suite* (suite_getter_fn)(void); 29 | 30 | /** Create a test suite */ 31 | Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown); 32 | 33 | #ifdef LWIP_UNITTESTS_LIB 34 | int lwip_unittests_run(void) 35 | #endif 36 | 37 | #endif /* LWIP_HDR_LWIP_CHECK_H */ 38 | -------------------------------------------------------------------------------- /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 "core/test_pbuf.h" 8 | #include "etharp/test_etharp.h" 9 | #include "dhcp/test_dhcp.h" 10 | #include "mdns/test_mdns.h" 11 | 12 | #include "lwip/init.h" 13 | 14 | Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown) 15 | { 16 | size_t i; 17 | Suite *s = suite_create(name); 18 | 19 | for(i = 0; i < num_tests; i++) { 20 | TCase *tc_core = tcase_create(name); 21 | if ((setup != NULL) || (teardown != NULL)) { 22 | tcase_add_checked_fixture(tc_core, setup, teardown); 23 | } 24 | tcase_add_named_test(tc_core, tests[i]); 25 | suite_add_tcase(s, tc_core); 26 | } 27 | return s; 28 | } 29 | 30 | #ifdef LWIP_UNITTESTS_LIB 31 | int lwip_unittests_run(void) 32 | #else 33 | int main(void) 34 | #endif 35 | { 36 | int number_failed; 37 | SRunner *sr; 38 | size_t i; 39 | suite_getter_fn* suites[] = { 40 | udp_suite, 41 | tcp_suite, 42 | tcp_oos_suite, 43 | mem_suite, 44 | pbuf_suite, 45 | etharp_suite, 46 | dhcp_suite, 47 | mdns_suite 48 | }; 49 | size_t num = sizeof(suites)/sizeof(void*); 50 | LWIP_ASSERT("No suites defined", num > 0); 51 | 52 | lwip_init(); 53 | 54 | sr = srunner_create((suites[0])()); 55 | for(i = 1; i < num; i++) { 56 | srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); 57 | } 58 | 59 | #ifdef LWIP_UNITTESTS_NOFORK 60 | srunner_set_fork_status(sr, CK_NOFORK); 61 | #endif 62 | #ifdef LWIP_UNITTESTS_FORK 63 | srunner_set_fork_status(sr, CK_FORK); 64 | #endif 65 | 66 | srunner_run_all(sr, CK_NORMAL); 67 | number_failed = srunner_ntests_failed(sr); 68 | srunner_free(sr); 69 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 70 | } 71 | -------------------------------------------------------------------------------- /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 LWIP_HDR_LWIPOPTS_H 33 | #define LWIP_HDR_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 SYS_LIGHTWEIGHT_PROT 0 38 | #define LWIP_NETCONN 0 39 | #define LWIP_SOCKET 0 40 | 41 | /* Enable DHCP to test it, disable UDP checksum to easier inject packets */ 42 | #define LWIP_DHCP 1 43 | 44 | /* Minimal changes to opt.h required for tcp unit tests: */ 45 | #define MEM_SIZE 16000 46 | #define TCP_SND_QUEUELEN 40 47 | #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN 48 | #define TCP_SND_BUF (12 * TCP_MSS) 49 | #define TCP_WND (10 * TCP_MSS) 50 | #define LWIP_WND_SCALE 1 51 | #define TCP_RCV_SCALE 0 52 | #define PBUF_POOL_SIZE 400 /* pbuf tests need ~200KByte */ 53 | 54 | /* Enable IGMP and MDNS for MDNS tests */ 55 | #define LWIP_IGMP 1 56 | #define LWIP_MDNS_RESPONDER 1 57 | #define LWIP_NUM_NETIF_CLIENT_DATA (LWIP_MDNS_RESPONDER) 58 | 59 | /* Minimal changes to opt.h required for etharp unit tests: */ 60 | #define ETHARP_SUPPORT_STATIC_ENTRIES 1 61 | 62 | #endif /* LWIP_HDR_LWIPOPTS_H */ 63 | -------------------------------------------------------------------------------- /test/unit/mdns/test_mdns.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MDNS_H__ 2 | #define LWIP_HDR_TEST_MDNS_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* mdns_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/tcp/tcp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TCP_HELPER_H 2 | #define LWIP_HDR_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 | -------------------------------------------------------------------------------- /test/unit/tcp/test_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TCP_H 2 | #define LWIP_HDR_TEST_TCP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/unit/tcp/test_tcp_oos.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TCP_OOS_H 2 | #define LWIP_HDR_TEST_TCP_OOS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_oos_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /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(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 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(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 0); 48 | 49 | pcb = udp_new(); 50 | fail_unless(pcb != NULL); 51 | if (pcb != NULL) { 52 | fail_unless(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 1); 53 | udp_remove(pcb); 54 | fail_unless(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 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 | testfunc tests[] = { 65 | TESTFUNC(test_udp_new_remove), 66 | }; 67 | return create_suite("UDP", tests, sizeof(tests)/sizeof(testfunc), udp_setup, udp_teardown); 68 | } 69 | -------------------------------------------------------------------------------- /test/unit/udp/test_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_UDP_H 2 | #define LWIP_HDR_TEST_UDP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* udp_suite(void); 7 | 8 | #endif 9 | --------------------------------------------------------------------------------