├── CHANGELOG ├── CMakeLists.txt ├── CONTRIBUTING.md ├── Kconfig ├── LICENSE ├── README ├── VERSION ├── apps ├── dhcpserver │ └── dhcpserver.c ├── ping │ ├── esp_ping.c │ └── ping.c └── sntp │ └── sntp.c ├── component.mk ├── include └── apps │ ├── dhcpserver │ ├── dhcpserver.h │ └── dhcpserver_options.h │ ├── esp_ping.h │ ├── esp_sntp.h │ ├── ping │ └── ping.h │ └── sntp │ └── sntp.h ├── include_compat └── apps │ └── sntp │ └── sntp.h ├── linker.lf ├── lwip ├── .gitattributes ├── .gitignore ├── .gitlab-ci.yml ├── 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 │ │ │ ├── ip6_route_table.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 │ │ │ ├── ip6_route_table.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 │ ├── esp │ ├── arch │ │ └── cc.h │ └── lwipopts.h │ ├── etharp │ ├── test_etharp.c │ └── test_etharp.h │ ├── ip4 │ ├── test_ip4.c │ └── test_ip4.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 ├── patches ├── openweave-esp32-lwip-patch-0001-Add-custom-core-locking.patch ├── openweave-esp32-lwip-patch-0002-Enforce-wlan-buffer-copy.patch ├── openweave-esp32-lwip-patch-0003-Removed-include-in-lwipopts.h.patch ├── openweave-esp32-lwip-patch-0004-Fix-source-IPv6-address-selection-logic.patch ├── openweave-esp32-lwip-patch-0005-Fix-ip6_get_subnet_id.patch ├── openweave-esp32-lwip-patch-0007-UDP-interface-binding-support.patch ├── openweave-esp32-lwip-patch-0008-Static-route-table-management-in-LwIP.patch ├── openweave-esp32-lwip-patch-0009-Enable-custom-pbufs.patch └── openweave-esp32-lwip-patch-0010-Make-nd6_select_router-public.patch ├── port └── esp32 │ ├── debug │ └── lwip_debug.c │ ├── freertos │ └── sys_arch.c │ ├── include │ ├── arch │ │ ├── cc.h │ │ ├── perf.h │ │ ├── sys_arch.h │ │ └── vfs_lwip.h │ ├── arpa │ │ └── inet.h │ ├── debug │ │ └── lwip_debug.h │ ├── lwipopts.h │ ├── netdb.h │ ├── netif │ │ ├── dhcp_state.h │ │ ├── ethernetif.h │ │ └── wlanif.h │ ├── netinet │ │ └── in.h │ └── sys │ │ └── socket.h │ ├── netif │ ├── dhcp_state.c │ ├── ethernetif.c │ └── wlanif.c │ └── vfs_lwip.c └── test_afl_host ├── CMakeLists.txt ├── Makefile ├── dhcp_di.h ├── dhcpserver_di.h ├── dns_di.h ├── in_dhcp_client ├── data0.bin ├── data1.bin ├── data2.bin ├── data3.bin ├── data4.bin ├── data5.bin ├── data6.bin ├── data7.bin └── data8.bin ├── in_dhcp_server ├── data0.bin ├── data1.bin ├── data2.bin ├── data3.bin ├── data4.bin ├── data5.bin └── data6.bin ├── in_dns ├── out0.bin ├── out10.bin ├── out28.bin ├── out29.bin ├── out30.bin ├── out31.bin ├── out32.bin ├── out33.bin ├── out34.bin ├── out35.bin ├── out36.bin ├── out37.bin └── out38.bin ├── network_mock.c ├── no_warn_host.h ├── test_dhcp_client.c ├── test_dhcp_server.c └── test_dns.c /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | bf7fc41e -------------------------------------------------------------------------------- /component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Component Makefile 3 | # 4 | COMPONENT_SUBMODULES += lwip 5 | 6 | COMPONENT_ADD_INCLUDEDIRS := \ 7 | include/apps \ 8 | include/apps/sntp \ 9 | lwip/src/include \ 10 | port/esp32/include \ 11 | port/esp32/include/arch \ 12 | include_compat 13 | 14 | COMPONENT_SRCDIRS := \ 15 | apps/dhcpserver \ 16 | apps/ping \ 17 | apps/sntp \ 18 | lwip/src/api \ 19 | lwip/src/apps/sntp \ 20 | lwip/src/core \ 21 | lwip/src/core/ipv4 \ 22 | lwip/src/core/ipv6 \ 23 | lwip/src/netif \ 24 | port/esp32 \ 25 | port/esp32/freertos \ 26 | port/esp32/netif \ 27 | port/esp32/debug 28 | 29 | ifdef CONFIG_PPP_SUPPORT 30 | COMPONENT_SRCDIRS += lwip/src/netif/ppp lwip/src/netif/ppp/polarssl 31 | endif 32 | 33 | CFLAGS += -Wno-address # lots of LWIP source files evaluate macros that check address of stack variables 34 | 35 | ifeq ($(GCC_NOT_5_2_0), 1) 36 | lwip/src/netif/ppp/ppp.o: CFLAGS += -Wno-uninitialized 37 | lwip/src/netif/ppp/pppos.o: CFLAGS += -Wno-implicit-fallthrough 38 | endif 39 | 40 | COMPONENT_ADD_LDFRAGMENTS += linker.lf 41 | -------------------------------------------------------------------------------- /include/apps/dhcpserver/dhcpserver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef __DHCPS_H__ 15 | #define __DHCPS_H__ 16 | 17 | #include "sdkconfig.h" 18 | #include "lwip/ip_addr.h" 19 | 20 | typedef struct dhcps_state{ 21 | s16_t state; 22 | } dhcps_state; 23 | 24 | typedef struct dhcps_msg { 25 | u8_t op, htype, hlen, hops; 26 | u8_t xid[4]; 27 | u16_t secs, flags; 28 | u8_t ciaddr[4]; 29 | u8_t yiaddr[4]; 30 | u8_t siaddr[4]; 31 | u8_t giaddr[4]; 32 | u8_t chaddr[16]; 33 | u8_t sname[64]; 34 | u8_t file[128]; 35 | u8_t options[312]; 36 | }dhcps_msg; 37 | 38 | /* Defined in esp_misc.h */ 39 | typedef struct { 40 | bool enable; 41 | ip4_addr_t start_ip; 42 | ip4_addr_t end_ip; 43 | } dhcps_lease_t; 44 | 45 | enum dhcps_offer_option{ 46 | OFFER_START = 0x00, 47 | OFFER_ROUTER = 0x01, 48 | OFFER_DNS = 0x02, 49 | OFFER_END 50 | }; 51 | 52 | #define DHCPS_COARSE_TIMER_SECS 1 53 | #define DHCPS_MAX_LEASE 0x64 54 | #define DHCPS_LEASE_TIME_DEF (120) 55 | #define DHCPS_LEASE_UNIT CONFIG_LWIP_DHCPS_LEASE_UNIT 56 | 57 | struct dhcps_pool{ 58 | ip4_addr_t ip; 59 | u8_t mac[6]; 60 | u32_t lease_timer; 61 | }; 62 | 63 | typedef u32_t dhcps_time_t; 64 | typedef u8_t dhcps_offer_t; 65 | 66 | typedef struct { 67 | dhcps_offer_t dhcps_offer; 68 | dhcps_offer_t dhcps_dns; 69 | dhcps_time_t dhcps_time; 70 | dhcps_lease_t dhcps_poll; 71 | } dhcps_options_t; 72 | 73 | typedef void (*dhcps_cb_t)(u8_t client_ip[4]); 74 | 75 | static inline bool dhcps_router_enabled (dhcps_offer_t offer) 76 | { 77 | return (offer & OFFER_ROUTER) != 0; 78 | } 79 | 80 | static inline bool dhcps_dns_enabled (dhcps_offer_t offer) 81 | { 82 | return (offer & OFFER_DNS) != 0; 83 | } 84 | 85 | void dhcps_start(struct netif *netif, ip4_addr_t ip); 86 | void dhcps_stop(struct netif *netif); 87 | void *dhcps_option_info(u8_t op_id, u32_t opt_len); 88 | void dhcps_set_option_info(u8_t op_id, void *opt_info, u32_t opt_len); 89 | bool dhcp_search_ip_on_mac(u8_t *mac, ip4_addr_t *ip); 90 | void dhcps_dns_setserver(const ip_addr_t *dnsserver); 91 | ip4_addr_t dhcps_dns_getserver(); 92 | void dhcps_set_new_lease_cb(dhcps_cb_t cb); 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /include/apps/esp_sntp.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_SNTP_H__ 16 | #define __ESP_SNTP_H__ 17 | 18 | #include "lwip/err.h" 19 | #include "lwip/apps/sntp.h" 20 | #include "sntp.h" 21 | 22 | #endif // __ESP_SNTP_H__ 23 | -------------------------------------------------------------------------------- /include/apps/ping/ping.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | */ 30 | 31 | #ifndef LWIP_PING_H 32 | #define LWIP_PING_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** 39 | * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used 40 | */ 41 | #ifndef PING_USE_SOCKETS 42 | #define PING_USE_SOCKETS LWIP_SOCKET 43 | #endif 44 | 45 | 46 | int ping_init(void); 47 | 48 | #ifdef ESP_PING 49 | void ping_deinit(void); 50 | #endif 51 | 52 | #if !PING_USE_SOCKETS 53 | void ping_send_now(void); 54 | #endif /* !PING_USE_SOCKETS */ 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* LWIP_PING_H */ 61 | -------------------------------------------------------------------------------- /include_compat/apps/sntp/sntp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #warning "This header file is deprecated, please include esp_sntp.h instead." 3 | #include "esp_sntp.h" 4 | -------------------------------------------------------------------------------- /linker.lf: -------------------------------------------------------------------------------- 1 | [mapping] 2 | archive: liblwip.a 3 | entries: 4 | :LWIP_IRAM_OPTIMIZATION = y 5 | ethernetif:ethernet_low_level_output (noflash_text) 6 | ethernetif:ethernetif_input (noflash_text) 7 | wlanif:low_level_output (noflash_text) 8 | wlanif:wlanif_input (noflash_text) 9 | sys_arch:sys_mutex_lock (noflash_text) 10 | sys_arch:sys_mutex_unlock (noflash_text) 11 | sys_arch:sys_sem_signal (noflash_text) 12 | sys_arch:sys_arch_sem_wait (noflash_text) 13 | sys_arch:sys_mbox_post (noflash_text) 14 | sys_arch:sys_mbox_trypost (noflash_text) 15 | sys_arch:sys_arch_mbox_fetch (noflash_text) 16 | sockets:get_socket (noflash_text) 17 | sockets:lwip_recvfrom (noflash_text) 18 | sockets:lwip_sendto (noflash_text) 19 | sockets:event_callback (noflash_text) 20 | sockets:lwip_sendto_r (noflash_text) 21 | sockets:lwip_recvfrom_r (noflash_text) 22 | sockets:lwip_recv_r (noflash_text) 23 | api_lib:netconn_apimsg (noflash_text) 24 | api_lib:netconn_recv_data (noflash_text) 25 | api_lib:netconn_recv_tcp_pbuf (noflash_text) 26 | api_lib:netconn_recv (noflash_text) 27 | api_lib:netconn_send (noflash_text) 28 | api_lib:netconn_write_partly (noflash_text) 29 | tcpip:tcpip_thread (noflash_text) 30 | tcpip:tcpip_inpkt (noflash_text) 31 | tcpip:tcpip_input (noflash_text) 32 | tcpip:tcpip_send_msg_wait_sem (noflash_text) 33 | netbuf:netbuf_alloc (noflash_text) 34 | netbuf:netbuf_free (noflash_text) 35 | timeouts:sys_timeouts_mbox_fetch (noflash_text) 36 | inet_chksum:inet_cksum_pseudo_base (noflash_text) 37 | inet_chksum:inet_chksum_pseudo (noflash_text) 38 | inet_chksum:ip_chksum_pseudo (noflash_text) 39 | etharp:etharp_output_to_arp_index (noflash_text) 40 | etharp:etharp_output (noflash_text) 41 | ip4_addr:ip4_addr_isbroadcast_u32 (noflash_text) 42 | ip4:ip4_route_src (noflash_text) 43 | ip4:ip4_route_src_hook (noflash_text) 44 | ip4:ip4_route (noflash_text) 45 | ip4:ip4_input (noflash_text) 46 | ip4:ip4_output_if_src (noflash_text) 47 | ip4:ip4_output_if_opt_src (noflash_text) 48 | udp:udp_input_local_match (noflash_text) 49 | udp:udp_input (noflash_text) 50 | udp:udp_send (noflash_text) 51 | udp:udp_sendto (noflash_text) 52 | udp:udp_sendto_if (noflash_text) 53 | udp:udp_sendto_if_src (noflash_text) 54 | pbuf:pbuf_alloc (noflash_text) 55 | pbuf:pbuf_header_impl (noflash_text) 56 | pbuf:pbuf_header (noflash_text) 57 | ethernet:ethernet_input (noflash_text) 58 | -------------------------------------------------------------------------------- /lwip/.gitattributes: -------------------------------------------------------------------------------- 1 | # These files are text and should be normalized 2 | *.txt text 3 | *.c text 4 | *.h text 5 | -------------------------------------------------------------------------------- /lwip/.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 | -------------------------------------------------------------------------------- /lwip/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - host_test 3 | - deploy 4 | 5 | image: ${CI_DOCKER_REGISTRY}/esp32-ci-env 6 | 7 | variables: 8 | # tag in lwip-contrib repo, which supports our esp-lwip branch (and it's cherry-picked commits from release branches) 9 | LWIP_CONTRIB_TAG: STABLE-2_0_1_RELEASE 10 | # test timeout is seconds 11 | TEST_TIMEOUT: 200 12 | 13 | before_script: 14 | # Use CI Tools 15 | - curl -sSL ${CIT_LOADER_URL} | sh 16 | - source citools/import_functions 17 | 18 | run_lwip_unittests: 19 | stage: host_test 20 | tags: 21 | - host_test 22 | dependencies: [] 23 | script: 24 | # have to clone lwip-contrib repo, as it contains unit test infrastructure 25 | - cit_add_ssh_key "${GITLAB_KEY}" "$(cit_parse_url_host ${LWIP_CONTRIB_MIRROR})" "$(cit_parse_url_port ${LWIP_CONTRIB_MIRROR})" 26 | - git clone "${LWIP_CONTRIB_MIRROR}" lwip-contrib && cd lwip-contrib && git checkout tags/${LWIP_CONTRIB_TAG} 27 | - cd ports/unix/check/ 28 | # updating environment 29 | - export LWIPDIR=../../../../src && export CK_DEFAULT_TIMEOUT=${TEST_TIMEOUT} 30 | - export TESTFILES=`find $LWIPDIR/../test/unit -name '*.c' | tr '\n' ' '` 31 | - export CFLAGS=-I$LWIPDIR/../test/unit/esp 32 | # build and run tests 33 | - make "TESTFILES=$TESTFILES" check 34 | 35 | .add_gh_key_remote: &add_gh_key_remote | 36 | command -v ssh-agent >/dev/null || exit 1 37 | eval $(ssh-agent -s) 38 | printf '%s\n' "${GH_PUSH_KEY}" | tr -d '\r' | ssh-add - > /dev/null 39 | mkdir -p ~/.ssh && chmod 700 ~/.ssh 40 | [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config || ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts 41 | git remote remove github || true 42 | git remote add github ${GH_PUSH_REPO} 43 | 44 | push_master_to_github: 45 | stage: deploy 46 | only: 47 | - 2.0.3-esp 48 | when: on_success 49 | variables: 50 | GIT_STRATEGY: clone 51 | script: 52 | - *add_gh_key_remote 53 | - "[ -n \"${CI_COMMIT_TAG:-}\" ] && git push github ${CI_COMMIT_TAG}" 54 | - "[ -z \"${CI_COMMIT_TAG:-}\" ] && git push github ${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}" 55 | 56 | -------------------------------------------------------------------------------- /lwip/COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | 34 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/doc/doxygen/generate.bat: -------------------------------------------------------------------------------- 1 | doxygen lwip.Doxyfile 2 | -------------------------------------------------------------------------------- /lwip/doc/doxygen/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | doxygen lwip.Doxyfile 4 | -------------------------------------------------------------------------------- /lwip/doc/doxygen/output/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirection 5 | 6 | 7 | 8 | index.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/src/apps/httpd/fs/img/sics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/src/apps/httpd/fs/img/sics.gif -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | s8_t nd6_select_router(const ip6_addr_t * ip6addr, struct netif * netif); 69 | err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp); 70 | u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif); 71 | #if LWIP_ND6_TCP_REACHABILITY_HINTS 72 | void nd6_reachability_hint(const ip6_addr_t *ip6addr); 73 | #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ 74 | void nd6_cleanup_netif(struct netif *netif); 75 | #if LWIP_IPV6_MLD 76 | void nd6_adjust_mld_membership(struct netif *netif, s8_t addr_idx, u8_t new_state); 77 | #endif /* LWIP_IPV6_MLD */ 78 | 79 | #if ESP_LWIP 80 | /** set nd6 callback when ipv6 addr state pref*/ 81 | void nd6_set_cb(struct netif *netif, void (*cb)(struct netif *netif, u8_t ip_index)); 82 | #endif 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* LWIP_IPV6 */ 89 | 90 | #endif /* LWIP_HDR_ND6_H */ 91 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | 35 | #ifdef ESP_PLATFORM 36 | int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, 37 | char *host, socklen_t hostlen, 38 | char *serv, socklen_t servlen, int flags); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lwip/src/include/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/test/fuzz/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/config.h -------------------------------------------------------------------------------- /lwip/test/fuzz/inputs/arp/arp_req.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/inputs/arp/arp_req.bin -------------------------------------------------------------------------------- /lwip/test/fuzz/inputs/icmp/icmp_ping.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/inputs/icmp/icmp_ping.bin -------------------------------------------------------------------------------- /lwip/test/fuzz/inputs/ipv6/neighbor_solicitation.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/inputs/ipv6/neighbor_solicitation.bin -------------------------------------------------------------------------------- /lwip/test/fuzz/inputs/ipv6/router_adv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/inputs/ipv6/router_adv.bin -------------------------------------------------------------------------------- /lwip/test/fuzz/inputs/tcp/tcp_syn.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/inputs/tcp/tcp_syn.bin -------------------------------------------------------------------------------- /lwip/test/fuzz/inputs/udp/udp_port_5000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/lwip/test/fuzz/inputs/udp/udp_port_5000.bin -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/test/unit/esp/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Espressif Systems (Shanghai) PTE LTD 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _ESP_LWIP_ARCH_CC_H 18 | #define _ESP_LWIP_ARCH_CC_H 19 | 20 | typedef unsigned long mem_ptr_t; 21 | 22 | #include "ports/unix/port/include/arch/cc.h" 23 | 24 | #endif /* _ESP_LWIP_ARCH_CC_H */ -------------------------------------------------------------------------------- /lwip/test/unit/esp/lwipopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Espressif Systems (Shanghai) PTE LTD 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | #ifndef _ESP_LWIP_HDR_LWIPOPTS_H 17 | #define _ESP_LWIP_HDR_LWIPOPTS_H 18 | 19 | /* esp-lwip branch src and tests compilable */ 20 | #define SNTP_SERVER_DNS 0 21 | #define LWIP_HAVE_LOOPIF 1 22 | #define LWIP_NETIF_HOSTNAME 1 23 | 24 | /* ESP specific cofiguration */ 25 | #define ESP_LWIP 1 26 | #define ESP_DHCP 1 27 | #define ESP_DHCP_TIMER 1 28 | #define ESP_DHCPS_TIMER 0 29 | #define ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES 1 30 | #define ESP_IP4_ATON 1 31 | #define ESP_AUTO_RECV 1 32 | #define ESP_STATS_DROP 0 33 | #define ESP_STATS_TCP 0 34 | #define ESP_IRAM_ATTR 35 | #define ESP_GRATUITOUS_ARP 1 36 | 37 | #include "../lwipopts.h" 38 | 39 | #endif /* _ESP_LWIP_HDR_LWIPOPTS_H */ 40 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/test/unit/ip4/test_ip4.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_IP4_H 2 | #define LWIP_HDR_TEST_IP4_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* ip4_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/test/unit/lwip_unittests.c: -------------------------------------------------------------------------------- 1 | #include "lwip_check.h" 2 | 3 | #include "ip4/test_ip4.h" 4 | #include "udp/test_udp.h" 5 | #include "tcp/test_tcp.h" 6 | #include "tcp/test_tcp_oos.h" 7 | #include "core/test_mem.h" 8 | #include "core/test_pbuf.h" 9 | #include "etharp/test_etharp.h" 10 | #include "dhcp/test_dhcp.h" 11 | #include "mdns/test_mdns.h" 12 | 13 | #include "lwip/init.h" 14 | 15 | Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown) 16 | { 17 | size_t i; 18 | Suite *s = suite_create(name); 19 | 20 | for(i = 0; i < num_tests; i++) { 21 | TCase *tc_core = tcase_create(name); 22 | if ((setup != NULL) || (teardown != NULL)) { 23 | tcase_add_checked_fixture(tc_core, setup, teardown); 24 | } 25 | tcase_add_named_test(tc_core, tests[i]); 26 | suite_add_tcase(s, tc_core); 27 | } 28 | return s; 29 | } 30 | 31 | #ifdef LWIP_UNITTESTS_LIB 32 | int lwip_unittests_run(void) 33 | #else 34 | int main(void) 35 | #endif 36 | { 37 | int number_failed; 38 | SRunner *sr; 39 | size_t i; 40 | suite_getter_fn* suites[] = { 41 | ip4_suite, 42 | udp_suite, 43 | tcp_suite, 44 | tcp_oos_suite, 45 | mem_suite, 46 | pbuf_suite, 47 | etharp_suite, 48 | dhcp_suite, 49 | mdns_suite 50 | }; 51 | size_t num = sizeof(suites)/sizeof(void*); 52 | LWIP_ASSERT("No suites defined", num > 0); 53 | 54 | lwip_init(); 55 | 56 | sr = srunner_create((suites[0])()); 57 | for(i = 1; i < num; i++) { 58 | srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); 59 | } 60 | 61 | #ifdef LWIP_UNITTESTS_NOFORK 62 | srunner_set_fork_status(sr, CK_NOFORK); 63 | #endif 64 | #ifdef LWIP_UNITTESTS_FORK 65 | srunner_set_fork_status(sr, CK_FORK); 66 | #endif 67 | 68 | srunner_run_all(sr, CK_NORMAL); 69 | number_failed = srunner_ntests_failed(sr); 70 | srunner_free(sr); 71 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 72 | } 73 | -------------------------------------------------------------------------------- /lwip/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 | /* MIB2 stats are required to check IPv4 reassembly results */ 63 | #define MIB2_STATS 1 64 | 65 | #endif /* LWIP_HDR_LWIPOPTS_H */ 66 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /lwip/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 | -------------------------------------------------------------------------------- /patches/openweave-esp32-lwip-patch-0003-Removed-include-in-lwipopts.h.patch: -------------------------------------------------------------------------------- 1 | From 9cfe610fd25f1f7c1c10049dd286121f7019169c Mon Sep 17 00:00:00 2001 2 | From: Jay Logue 3 | Date: Thu, 29 Aug 2019 20:09:04 -0700 4 | Subject: [PATCH] openweave-esp32-lwip-patch-0003 : Removed include in 5 | lwipopts.h 6 | 7 | Removed unnecessary inclusion of sys/ioctl.h in lwipopts.h that results in 8 | compilation errors in certain contexts where LwIP headers are included. 9 | --- 10 | port/esp32/include/lwipopts.h | 1 - 11 | 1 file changed, 1 deletion(-) 12 | 13 | diff --git a/port/esp32/include/lwipopts.h b/port/esp32/include/lwipopts.h 14 | index 444272d..d10788e 100644 15 | --- a/port/esp32/include/lwipopts.h 16 | +++ b/port/esp32/include/lwipopts.h 17 | @@ -52,7 +52,6 @@ 18 | #include 19 | #include 20 | #include 21 | -#include 22 | #include 23 | #include 24 | #include "esp_task.h" 25 | -- 26 | 2.17.1 27 | 28 | -------------------------------------------------------------------------------- /patches/openweave-esp32-lwip-patch-0005-Fix-ip6_get_subnet_id.patch: -------------------------------------------------------------------------------- 1 | From 9fe5cb6e465c4462c9d4c8a9c319cbd2d9988db4 Mon Sep 17 00:00:00 2001 2 | From: Jay Logue 3 | Date: Thu, 29 Aug 2019 20:17:41 -0700 4 | Subject: [PATCH] openweave-esp32-lwip-patch-0005 : Fix ip6_get_subnet_id() 5 | 6 | This change corresponds to commit 192ac1284fa1b24d8cb9cd770eb8b4ece234fdc1 from tps/lwip:nest/stable 7 | 8 | Author: Abtin Keshavarzian 9 | Date: Fri Apr 8 09:35:44 2016 -0700 10 | 11 | ip6_addr.h: Fix the ip6_get_subnet_id() marco to return correct 12 | subnet id 13 | 14 | This commit changes the macro definition of ip6_get_subnet_id() in 15 | ip6_addr.h header file, so it returns the correct subnet id for a 16 | given ipv6 address. 17 | --- 18 | lwip/src/include/lwip/ip6_addr.h | 2 +- 19 | 1 file changed, 1 insertion(+), 1 deletion(-) 20 | 21 | diff --git a/lwip/src/include/lwip/ip6_addr.h b/lwip/src/include/lwip/ip6_addr.h 22 | index 381b237..5544469 100644 23 | --- a/lwip/src/include/lwip/ip6_addr.h 24 | +++ b/lwip/src/include/lwip/ip6_addr.h 25 | @@ -157,7 +157,7 @@ typedef struct ip6_addr ip6_addr_t; 26 | ((addr1)->addr[2] == (addr2)->addr[2]) && \ 27 | ((addr1)->addr[3] == (addr2)->addr[3])) 28 | 29 | -#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[2]) & 0x0000ffffUL) 30 | +#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[1]) & 0x0000ffffUL) 31 | 32 | #define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \ 33 | ((ip6addr).addr[1] == 0) && \ 34 | -- 35 | 2.17.1 36 | 37 | -------------------------------------------------------------------------------- /patches/openweave-esp32-lwip-patch-0009-Enable-custom-pbufs.patch: -------------------------------------------------------------------------------- 1 | From 9a5063ebdcf008bf30ae9a9e8c50b1d5029e8d82 Mon Sep 17 00:00:00 2001 2 | From: Jay Logue 3 | Date: Fri, 30 Aug 2019 07:49:14 -0700 4 | Subject: [PATCH] openweave-esp32-lwip-patch-0009 : Enable custom pbufs 5 | 6 | Enabled support for LwIP's custom pbufs, which are required for certain Weave 7 | functionality. 8 | --- 9 | port/esp32/include/lwipopts.h | 6 ++++++ 10 | 1 file changed, 6 insertions(+) 11 | 12 | diff --git a/port/esp32/include/lwipopts.h b/port/esp32/include/lwipopts.h 13 | index 8b5f2ad..0bbc4fb 100644 14 | --- a/port/esp32/include/lwipopts.h 15 | +++ b/port/esp32/include/lwipopts.h 16 | @@ -396,6 +396,12 @@ 17 | ---------------------------------- 18 | */ 19 | 20 | +/** 21 | + * Enable support for custom PBUFs. 22 | + */ 23 | +#define LWIP_SUPPORT_CUSTOM_PBUF 1 24 | + 25 | + 26 | /* 27 | ------------------------------------------------ 28 | ---------- Network Interfaces options ---------- 29 | -- 30 | 2.17.1 31 | 32 | -------------------------------------------------------------------------------- /patches/openweave-esp32-lwip-patch-0010-Make-nd6_select_router-public.patch: -------------------------------------------------------------------------------- 1 | From 2adef6e48d84bb65b2717dced64716d9566e1d68 Mon Sep 17 00:00:00 2001 2 | From: Jay Logue 3 | Date: Fri, 30 Aug 2019 09:53:22 -0700 4 | Subject: [PATCH] openweave-esp32-lwip-patch-0010 : Make nd6_select_router() 5 | public 6 | 7 | Allow nd6_select_router() function to be called by a user of LwIP. This 8 | provides a means for user code to determine if a default route exists on 9 | a particular interface. 10 | --- 11 | lwip/src/core/ipv6/nd6.c | 3 +-- 12 | lwip/src/include/lwip/nd6.h | 1 + 13 | 2 files changed, 2 insertions(+), 2 deletions(-) 14 | 15 | diff --git a/lwip/src/core/ipv6/nd6.c b/lwip/src/core/ipv6/nd6.c 16 | index 0b03ee8..91f07fe 100644 17 | --- a/lwip/src/core/ipv6/nd6.c 18 | +++ b/lwip/src/core/ipv6/nd6.c 19 | @@ -99,7 +99,6 @@ static void nd6_free_neighbor_cache_entry(s8_t i); 20 | static s8_t nd6_find_destination_cache_entry(const ip6_addr_t *ip6addr); 21 | static s8_t nd6_new_destination_cache_entry(void); 22 | static s8_t nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif); 23 | -static s8_t nd6_select_router(const ip6_addr_t *ip6addr, struct netif *netif); 24 | static s8_t nd6_get_router(const ip6_addr_t *router_addr, struct netif *netif); 25 | static s8_t nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif); 26 | static s8_t nd6_get_onlink_prefix(ip6_addr_t *prefix, struct netif *netif); 27 | @@ -1407,7 +1406,7 @@ nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif) 28 | * @return the default router entry index, or -1 if no suitable 29 | * router is found 30 | */ 31 | -static s8_t 32 | +s8_t 33 | nd6_select_router(const ip6_addr_t *ip6addr, struct netif *netif) 34 | { 35 | s8_t i; 36 | diff --git a/lwip/src/include/lwip/nd6.h b/lwip/src/include/lwip/nd6.h 37 | index d9fba97..cb023bc 100644 38 | --- a/lwip/src/include/lwip/nd6.h 39 | +++ b/lwip/src/include/lwip/nd6.h 40 | @@ -65,6 +65,7 @@ void nd6_tmr(void); 41 | void nd6_input(struct pbuf *p, struct netif *inp); 42 | void nd6_clear_destination_cache(void); 43 | struct netif *nd6_find_route(const ip6_addr_t *ip6addr); 44 | +s8_t nd6_select_router(const ip6_addr_t * ip6addr, struct netif * netif); 45 | err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp); 46 | u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif); 47 | #if LWIP_ND6_TCP_REACHABILITY_HINTS 48 | -- 49 | 2.17.1 50 | 51 | -------------------------------------------------------------------------------- /port/esp32/include/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef __PERF_H__ 35 | #define __PERF_H__ 36 | 37 | #define PERF_START /* null definition */ 38 | #define PERF_STOP(x) /* null definition */ 39 | 40 | #endif /* __PERF_H__ */ 41 | -------------------------------------------------------------------------------- /port/esp32/include/arch/vfs_lwip.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | void esp_vfs_lwip_sockets_register(); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /port/esp32/include/arpa/inet.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INET_H_ 16 | #define INET_H_ 17 | 18 | #include "../../../lwip/src/include/lwip/inet.h" 19 | 20 | #endif /* INET_H_ */ 21 | -------------------------------------------------------------------------------- /port/esp32/include/debug/lwip_debug.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _LWIP_DEBUG_H 17 | #define _LWIP_DEBUG_H 18 | 19 | void dbg_lwip_tcp_pcb_show(void); 20 | void dbg_lwip_udp_pcb_show(void); 21 | void dbg_lwip_tcp_rxtx_show(void); 22 | void dbg_lwip_udp_rxtx_show(void); 23 | void dbg_lwip_mem_cnt_show(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /port/esp32/include/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 | 35 | #ifdef ESP_PLATFORM 36 | int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, 37 | char *host, socklen_t hostlen, 38 | char *serv, socklen_t servlen, int flags); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /port/esp32/include/netif/dhcp_state.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _DHCP_STATE_H_ 17 | #define _DHCP_STATE_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | bool dhcp_ip_addr_restore(void *netif); 24 | 25 | void dhcp_ip_addr_store(void *netif); 26 | 27 | void dhcp_ip_addr_erase(void *netif); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* _DHCP_STATE_H_ */ -------------------------------------------------------------------------------- /port/esp32/include/netif/ethernetif.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _ETH_LWIP_IF_H_ 17 | #define _ETH_LWIP_IF_H_ 18 | 19 | #include "lwip/err.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | err_t ethernetif_init(struct netif *netif); 26 | 27 | void ethernetif_input(struct netif *netif, void *buffer, u16_t len); 28 | 29 | void netif_reg_addr_change_cb(void* cb); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _ETH_LWIP_IF_H_ */ 36 | -------------------------------------------------------------------------------- /port/esp32/include/netif/wlanif.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _WLAN_LWIP_IF_H_ 17 | #define _WLAN_LWIP_IF_H_ 18 | 19 | #include "esp_wifi.h" 20 | 21 | #include "esp_wifi_internal.h" 22 | 23 | #include "lwip/err.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | err_t wlanif_init_ap(struct netif *netif); 30 | err_t wlanif_init_sta(struct netif *netif); 31 | 32 | void wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb); 33 | 34 | wifi_interface_t wifi_get_interface(void *dev); 35 | 36 | void netif_reg_addr_change_cb(void* cb); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* _WLAN_LWIP_IF_H_ */ 43 | -------------------------------------------------------------------------------- /port/esp32/include/netinet/in.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IN_H_ 16 | #define IN_H_ 17 | 18 | #include "lwip/inet.h" 19 | 20 | #define IN6_IS_ADDR_MULTICAST(a) IN_MULTICAST(a) 21 | 22 | #endif /* IN_H_ */ 23 | -------------------------------------------------------------------------------- /port/esp32/include/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 | -------------------------------------------------------------------------------- /port/esp32/netif/dhcp_state.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include "nvs.h" 18 | #include "lwip/opt.h" 19 | #include "lwip/dhcp.h" 20 | #include "lwip/netif.h" 21 | #include "esp_interface.h" 22 | #include "tcpip_adapter.h" 23 | #include "netif/dhcp_state.h" 24 | 25 | #define DHCP_NAMESPACE "dhcp_state" 26 | #define VALID_NETIF_ID(id) ((id < ESP_IF_MAX) && (id != ESP_IF_WIFI_AP)) 27 | 28 | static uint32_t restored_ip_addr[TCPIP_ADAPTER_IF_MAX]; 29 | static const char *interface_key[] = {"IF_STA", "IF_AP", "IF_ETH"}; 30 | 31 | _Static_assert(sizeof(interface_key) / sizeof(char*) == TCPIP_ADAPTER_IF_MAX, 32 | "Number interface keys differs from number of interfaces"); 33 | 34 | bool dhcp_ip_addr_restore(void *netif) 35 | { 36 | nvs_handle nvs; 37 | bool err = false; 38 | struct netif *net = (struct netif *)netif; 39 | struct dhcp *dhcp = netif_dhcp_data(net); 40 | esp_interface_t netif_id = tcpip_adapter_get_esp_if(net); 41 | 42 | if(VALID_NETIF_ID(netif_id)) { 43 | uint32_t *ip_addr = &dhcp->offered_ip_addr.addr; 44 | if (nvs_open(DHCP_NAMESPACE, NVS_READONLY, &nvs) == ESP_OK) { 45 | if (nvs_get_u32(nvs, interface_key[netif_id], ip_addr) == ESP_OK) { 46 | restored_ip_addr[netif_id] = *ip_addr; 47 | err = true; 48 | } 49 | nvs_close(nvs); 50 | } 51 | } 52 | return err; 53 | } 54 | 55 | void dhcp_ip_addr_store(void *netif) 56 | { 57 | nvs_handle nvs; 58 | struct netif *net = (struct netif *)netif; 59 | struct dhcp *dhcp = netif_dhcp_data(net); 60 | uint32_t ip_addr = dhcp->offered_ip_addr.addr; 61 | esp_interface_t netif_id = tcpip_adapter_get_esp_if(net); 62 | 63 | if(VALID_NETIF_ID(netif_id)) { 64 | if (restored_ip_addr[netif_id] != ip_addr) { 65 | if (nvs_open(DHCP_NAMESPACE, NVS_READWRITE, &nvs) == ESP_OK) { 66 | nvs_set_u32(nvs, interface_key[netif_id], ip_addr); 67 | nvs_commit(nvs); 68 | nvs_close(nvs); 69 | } 70 | } 71 | } 72 | } 73 | 74 | void dhcp_ip_addr_erase(void *netif) 75 | { 76 | nvs_handle nvs; 77 | struct netif *net = (struct netif *)netif; 78 | esp_interface_t netif_id = tcpip_adapter_get_esp_if(net); 79 | 80 | if(VALID_NETIF_ID(netif_id)) { 81 | if (nvs_open(DHCP_NAMESPACE, NVS_READWRITE, &nvs) == ESP_OK) { 82 | nvs_erase_key(nvs, interface_key[netif_id]); 83 | nvs_commit(nvs); 84 | nvs_close(nvs); 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /port/esp32/vfs_lwip.c: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "esp_vfs.h" 22 | #include "esp_vfs_dev.h" 23 | #include "esp_attr.h" 24 | #include "soc/uart_struct.h" 25 | #include "lwip/sockets.h" 26 | #include "sdkconfig.h" 27 | #include "lwip/sys.h" 28 | 29 | _Static_assert(MAX_FDS >= CONFIG_LWIP_MAX_SOCKETS, "MAX_FDS < CONFIG_LWIP_MAX_SOCKETS"); 30 | 31 | static void lwip_stop_socket_select() 32 | { 33 | sys_sem_signal(sys_thread_sem_get()); //socket_select will return 34 | } 35 | 36 | static void lwip_stop_socket_select_isr(BaseType_t *woken) 37 | { 38 | if (sys_sem_signal_isr(sys_thread_sem_get()) && woken) { 39 | *woken = pdTRUE; 40 | } 41 | } 42 | 43 | static void *lwip_get_socket_select_semaphore() 44 | { 45 | /* Calling this from the same process as select() will ensure that the semaphore won't be allocated from 46 | * ISR (lwip_stop_socket_select_isr). 47 | */ 48 | return (void *) sys_thread_sem_get(); 49 | } 50 | 51 | static int lwip_fcntl_r_wrapper(int fd, int cmd, va_list args) 52 | { 53 | return lwip_fcntl_r(fd, cmd, va_arg(args, int)); 54 | } 55 | 56 | static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args) 57 | { 58 | return lwip_ioctl_r(fd, cmd, va_arg(args, void *)); 59 | } 60 | 61 | void esp_vfs_lwip_sockets_register() 62 | { 63 | esp_vfs_t vfs = { 64 | .flags = ESP_VFS_FLAG_DEFAULT, 65 | .write = &lwip_write_r, 66 | .open = NULL, 67 | .fstat = NULL, 68 | .close = &lwip_close_r, 69 | .read = &lwip_read_r, 70 | .fcntl = &lwip_fcntl_r_wrapper, 71 | .ioctl = &lwip_ioctl_r_wrapper, 72 | .get_socket_select_semaphore = &lwip_get_socket_select_semaphore, 73 | .socket_select = &lwip_select, 74 | .stop_socket_select = &lwip_stop_socket_select, 75 | .stop_socket_select_isr = &lwip_stop_socket_select_isr, 76 | }; 77 | /* Non-LWIP file descriptors are from 0 to (LWIP_SOCKET_OFFSET-1). LWIP 78 | * file descriptors are registered from LWIP_SOCKET_OFFSET to 79 | * MAX_FDS-1. 80 | */ 81 | 82 | ESP_ERROR_CHECK(esp_vfs_register_fd_range(&vfs, NULL, LWIP_SOCKET_OFFSET, MAX_FDS)); 83 | } 84 | -------------------------------------------------------------------------------- /test_afl_host/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following four lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | 7 | project(fuzz_test_lwip) -------------------------------------------------------------------------------- /test_afl_host/Makefile: -------------------------------------------------------------------------------- 1 | COMPONENTS_DIR=../.. 2 | CFLAGS=-std=gnu99 -Og -ggdb -ffunction-sections -fdata-sections -nostdlib -Wall -Werror=all -Wno-int-to-pointer-cast -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra \ 3 | -Wno-unused-parameter -Wno-sign-compare -Wno-address -Wno-unused-variable -DESP_PLATFORM -D IDF_VER=\"v3.1\" -MMD -MP -DWITH_POSIX 4 | INC_DIRS=-I . -I ./build/config -I $(COMPONENTS_DIR)/newlib/platform_include -I $(COMPONENTS_DIR)/newlib/include -I $(COMPONENTS_DIR)/driver/include -I $(COMPONENTS_DIR)/esp32/include -I $(COMPONENTS_DIR)/ethernet/include -I $(COMPONENTS_DIR)/freertos/include -I $(COMPONENTS_DIR)/heap/include -I $(COMPONENTS_DIR)/lwip/lwip/src/include -I $(COMPONENTS_DIR)/lwip/include/apps -I $(COMPONENTS_DIR)/lwip/lwip/src/include/netif -I $(COMPONENTS_DIR)/lwip/lwip/src/include/posix -I $(COMPONENTS_DIR)/lwip/port/esp32/include -I $(COMPONENTS_DIR)/lwip/lwip/src/include/posix -I $(COMPONENTS_DIR)/lwip/include/apps/ping -I $(COMPONENTS_DIR)/soc/esp32/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/tcpip_adapter/include -I $(COMPONENTS_DIR)/xtensa-debug-module/include 5 | TEST_NAME=test 6 | FUZZ=afl-fuzz 7 | GEN_CFG=generate_config 8 | LD=$(CC) 9 | ifeq ($(MODE),dhcp_client) 10 | DEPENDENCY_INJECTION=-include dhcp_di.h 11 | OBJECTS=dhcp.o def.o network_mock.o test_dhcp_client.o 12 | SAMPLE_PACKETS=in_dhcp_client 13 | else ifeq ($(MODE),dhcp_server) 14 | DEPENDENCY_INJECTION=-include dhcpserver_di.h 15 | OBJECTS=dhcpserver.o def.o test_dhcp_server.o network_mock.o 16 | SAMPLE_PACKETS=in_dhcp_server 17 | else ifeq ($(MODE),dns) 18 | CFLAGS+=-DNOT_MOCK_DNS 19 | DEPENDENCY_INJECTION=-include dns_di.h 20 | OBJECTS=dns.o def.o test_dns.o network_mock.o 21 | SAMPLE_PACKETS=in_dns 22 | else 23 | $(error Please specify MODE: dhcp_server, dhcp_client, dns) 24 | endif 25 | 26 | ifeq ($(INSTR),off) 27 | CC=gcc 28 | CFLAGS+=-DINSTR_IS_OFF 29 | TEST_NAME=test_sim 30 | else 31 | CC=afl-clang-fast 32 | endif 33 | 34 | CFLAGS+=$(INC_DIRS) 35 | 36 | all: $(TEST_NAME) 37 | 38 | def.o: ../lwip/src/core/def.c $(GEN_CFG) 39 | @echo "[CC] $<" 40 | @$(CC) $(CFLAGS) -D BUILDING_DEF $(DEPENDENCY_INJECTION) -c $< -o $@ 41 | 42 | dns.o: ../lwip/src/core/dns.c $(GEN_CFG) 43 | @echo "[CC] $<" 44 | @$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@ 45 | 46 | dhcp.o: ../lwip/src/core/ipv4/dhcp.c $(GEN_CFG) 47 | @echo "[CC] $<" 48 | @$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@ 49 | 50 | dhcpserver.o: ../apps/dhcpserver/dhcpserver.c $(GEN_CFG) 51 | @echo "[CC] $<" 52 | @$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@ 53 | 54 | %.o: %.c $(GEN_CFG) 55 | @echo "[CC] $<" 56 | @$(CC) $(CFLAGS) -c $< -o $@ 57 | 58 | .PHONY: $(GEN_CFG) 59 | $(GEN_CFG): 60 | $(IDF_PATH)/tools/idf.py reconfigure 61 | 62 | $(TEST_NAME): $(OBJECTS) 63 | @echo "[LD] $@" 64 | @$(LD) $(OBJECTS) -o $@ $(LDLIBS) 65 | 66 | fuzz: $(TEST_NAME) 67 | @$(FUZZ) -t 5000+ -i "$(SAMPLE_PACKETS)" -o "out" -- ./$(TEST_NAME) 68 | -------------------------------------------------------------------------------- /test_afl_host/dhcp_di.h: -------------------------------------------------------------------------------- 1 | #include "no_warn_host.h" 2 | #include "lwip/opt.h" 3 | #include "lwip/stats.h" 4 | #include "lwip/mem.h" 5 | #include "lwip/udp.h" 6 | #include "lwip/ip_addr.h" 7 | #include "lwip/netif.h" 8 | #include "lwip/def.h" 9 | #include "lwip/dhcp.h" 10 | #include "lwip/autoip.h" 11 | #include "lwip/dns.h" 12 | #include "netif/etharp.h" 13 | 14 | #ifndef BUILDING_DEF 15 | 16 | void __assert_func(const char *file, int line, const char *func, const char *expr) 17 | { 18 | printf("Assert failed in %s, %s:%d (%s)", func, file, line, expr); 19 | abort(); 20 | } 21 | 22 | static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); 23 | 24 | void (*dhcp_test_static_dhcp_recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) = NULL; 25 | 26 | void dhcp_test_init_di() 27 | { 28 | dhcp_test_static_dhcp_recv = dhcp_recv; 29 | } 30 | 31 | void dhcp_test_dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) 32 | { 33 | dhcp_test_static_dhcp_recv(arg, pcb, p, addr, port); 34 | } 35 | 36 | #endif /* BUILDING_DEF */ -------------------------------------------------------------------------------- /test_afl_host/dhcpserver_di.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dhcpserver dependecy injection -- preincluded to inject interface test functions into static variables 3 | * 4 | */ 5 | #include "no_warn_host.h" 6 | #include "lwip/pbuf.h" 7 | #include "lwip/udp.h" 8 | #include "tcpip_adapter.h" 9 | 10 | #ifndef BUILDING_DEF 11 | 12 | static void handle_dhcp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); 13 | 14 | void (*dhcp_test_static_handle_hdcp)(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) = NULL; 15 | 16 | void dhcp_test_init_di() 17 | { 18 | dhcp_test_static_handle_hdcp = handle_dhcp; 19 | } 20 | 21 | void dhcp_test_handle_dhcp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) 22 | { 23 | dhcp_test_static_handle_hdcp(arg, pcb, p, addr, port); 24 | } 25 | 26 | #endif -------------------------------------------------------------------------------- /test_afl_host/dns_di.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dns.c dependecy injection -- preincluded to inject interface test functions into static variables 3 | * 4 | */ 5 | #include "no_warn_host.h" 6 | 7 | #include "lwip/opt.h" 8 | #include "lwip/udp.h" 9 | #include "lwip/mem.h" 10 | #include "lwip/memp.h" 11 | #include "lwip/dns.h" 12 | #include "lwip/ip_addr.h" 13 | 14 | #define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr) 15 | 16 | extern uint32_t g_random_numbers[8]; 17 | extern uint32_t g_random_numbers_cnt; 18 | 19 | #ifndef BUILDING_DEF 20 | 21 | void __assert_func(const char *file, int line, const char *func, const char *expr) 22 | { 23 | printf("Assert failed in %s, %s:%d (%s)", func, file, line, expr); 24 | abort(); 25 | } 26 | 27 | int ip4addr_aton(const char *cp, ip4_addr_t *addr) 28 | { 29 | return 0; 30 | } 31 | 32 | static err_t dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found, void *callback_arg, u8_t dns_addrtype); 33 | static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); 34 | 35 | void (*dns_test_static_dns_recv)(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) = NULL; 36 | err_t (*dns_test_static_dns_enqueue)(const char *name, size_t hostnamelen, dns_found_callback found, void *callback_arg, u8_t dns_addrtype) = NULL; 37 | 38 | void dns_test_init_di() 39 | { 40 | dns_test_static_dns_recv = dns_recv; 41 | dns_test_static_dns_enqueue = dns_enqueue; 42 | } 43 | 44 | 45 | err_t dns_test_dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found, void *callback_arg, u8_t dns_addrtype) 46 | { 47 | return dns_test_static_dns_enqueue(name, hostnamelen, found, callback_arg, dns_addrtype); 48 | } 49 | 50 | void dns_test_dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) 51 | { 52 | dns_test_static_dns_recv(s, pcb, p, addr, port); 53 | } 54 | 55 | void dns_test_inject_port_and_txid(int port, int txid) 56 | { 57 | // inject random numbers 58 | g_random_numbers[0] = port; //for port 59 | g_random_numbers[1] = txid; //for txid 60 | g_random_numbers_cnt = 0; // let's start with the port 61 | } 62 | #endif -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data0.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data1.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data2.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data3.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data4.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data4.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data5.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data5.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data6.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data6.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data7.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data7.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_client/data8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_client/data8.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data0.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data1.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data2.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data3.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data4.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data4.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data5.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data5.bin -------------------------------------------------------------------------------- /test_afl_host/in_dhcp_server/data6.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dhcp_server/data6.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out0.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out10.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out10.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out28.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out28.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out29.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out29.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out30.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out30.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out31.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out31.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out32.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out32.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out33.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out33.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out34.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out34.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out35.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out35.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out36.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out36.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out37.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out37.bin -------------------------------------------------------------------------------- /test_afl_host/in_dns/out38.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openweave/openweave-esp32-lwip/5eb7efc149a3b341d90ad1cd84b57e65f58948cd/test_afl_host/in_dns/out38.bin -------------------------------------------------------------------------------- /test_afl_host/no_warn_host.h: -------------------------------------------------------------------------------- 1 | // Note: these undefs and defines are used to suppress warnings and errors when compiling esp32 idf on host gcc/clang 2 | #undef __nonnull 3 | #define __warning__ deprecated 4 | #define IRAM_ATTR 5 | #define __ESP_ATTR_H__ 6 | -------------------------------------------------------------------------------- /test_afl_host/test_dhcp_client.c: -------------------------------------------------------------------------------- 1 | #include "no_warn_host.h" 2 | #include "lwip/opt.h" 3 | #include "lwip/stats.h" 4 | #include "lwip/mem.h" 5 | #include "lwip/udp.h" 6 | #include "lwip/ip_addr.h" 7 | #include "lwip/netif.h" 8 | #include "lwip/def.h" 9 | #include "lwip/dhcp.h" 10 | #include "lwip/autoip.h" 11 | #include "lwip/dns.h" 12 | #include "netif/etharp.h" 13 | #include 14 | 15 | const ip_addr_t ip_addr_any; 16 | const ip_addr_t ip_addr_broadcast; 17 | struct ip_globals ip_data; 18 | struct netif *netif_list; 19 | struct netif mynetif; 20 | ip4_addr_t server_ip; 21 | 22 | // 23 | // Dependency injected test functions 24 | void dhcp_test_dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); 25 | void dhcp_test_init_di(); 26 | 27 | // 28 | // Test starts here 29 | // 30 | int main(int argc, char** argv) 31 | { 32 | uint8_t *buf; 33 | struct pbuf *p; 34 | FILE *file; 35 | size_t len = 1460; 36 | 37 | dhcp_test_init_di(); 38 | 39 | mynetif.flags = NETIF_FLAG_UP | NETIF_FLAG_ETHARP; 40 | mynetif.mtu = 576; 41 | 42 | 43 | IP4_ADDR(&server_ip, 192,168,4,1); 44 | dhcp_start(&mynetif); 45 | 46 | ip_data.current_input_netif = &mynetif; 47 | ip_data.current_netif = &mynetif; 48 | 49 | #ifdef INSTR_IS_OFF 50 | p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); 51 | buf = p->payload; 52 | memset(buf, 0, 1460); 53 | if (argc != 2) 54 | { 55 | printf("Non-instrumentation mode: please supply a file name created by AFL to reproduce crash\n"); 56 | return 1; 57 | } 58 | // 59 | // Note: parameter1 is a file (mangled packet) which caused the crash 60 | file = fopen(argv[1], "r"); 61 | if (file) { 62 | len = fread(buf, 1, 1460, file); 63 | } 64 | fclose(file); 65 | int i; 66 | for (i=0; i<1; i++) { 67 | #else 68 | while (__AFL_LOOP(1000)) { 69 | p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); 70 | buf = p->payload; 71 | memset(buf, 0, 1460); 72 | size_t len = read(0, buf, 1460); 73 | #endif 74 | p->len = len; 75 | p->tot_len = len; 76 | p->next = NULL; 77 | 78 | dhcp_test_dhcp_recv(NULL, NULL, p, &ip_addr_any, 0); 79 | } 80 | 81 | 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /test_afl_host/test_dhcp_server.c: -------------------------------------------------------------------------------- 1 | #include "no_warn_host.h" 2 | #include "lwip/pbuf.h" 3 | #include "lwip/udp.h" 4 | #include "tcpip_adapter.h" 5 | #include 6 | #include 7 | 8 | const ip_addr_t ip_addr_any; 9 | ip4_addr_t server_ip; 10 | struct netif mynetif; 11 | 12 | // dhcps callback 13 | void dhcp_test_dhcps_cb (u8_t client_ip[4]) {} 14 | 15 | // Dependency injected static function to pass the packet into parser 16 | void dhcp_test_handle_dhcp(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); 17 | void dhcp_test_init_di(); 18 | 19 | // 20 | // Test starts here 21 | // 22 | int main(int argc, char** argv) 23 | { 24 | uint8_t *buf; 25 | struct pbuf *p; 26 | FILE *file; 27 | size_t len = 1460; 28 | 29 | dhcp_test_init_di(); 30 | 31 | IP4_ADDR(&server_ip, 192,168,4,1); 32 | dhcps_set_new_lease_cb(dhcp_test_dhcps_cb); 33 | dhcps_start(&mynetif, server_ip); 34 | 35 | #ifdef INSTR_IS_OFF 36 | p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); 37 | buf = p->payload; 38 | memset(buf, 0, 1460); 39 | if (argc != 2) 40 | { 41 | printf("Non-instrumentation mode: please supply a file name created by AFL to reproduce crash\n"); 42 | return 1; 43 | } 44 | // 45 | // Note: parameter1 is a file (mangled packet) which caused the crash 46 | file = fopen(argv[1], "r"); 47 | if (file) { 48 | len = fread(buf, 1, 1460, file); 49 | } 50 | fclose(file); 51 | 52 | int i; 53 | for (i=0; i<1; i++) { 54 | #else 55 | while (__AFL_LOOP(1000)) { 56 | p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); 57 | buf = p->payload; 58 | memset(buf, 0, 1460); 59 | size_t len = read(0, buf, 1460); 60 | #endif 61 | p->len = len; 62 | p->tot_len = len; 63 | p->next = NULL; 64 | 65 | dhcp_test_handle_dhcp(NULL, NULL, p, &ip_addr_any, 0); 66 | } 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /test_afl_host/test_dns.c: -------------------------------------------------------------------------------- 1 | #include "no_warn_host.h" 2 | 3 | #include "lwip/opt.h" 4 | #include "lwip/udp.h" 5 | #include "lwip/mem.h" 6 | #include "lwip/memp.h" 7 | #include "lwip/dns.h" 8 | #include "lwip/ip_addr.h" 9 | 10 | #include 11 | 12 | const ip_addr_t ip_addr_any; 13 | const ip_addr_t ip_addr_broadcast; 14 | struct ip_globals ip_data; 15 | struct netif *netif_list; 16 | struct netif mynetif; 17 | ip4_addr_t server_ip; 18 | 19 | // 20 | // Dependency injected test functions 21 | void dns_test_dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); 22 | void dns_test_inject_port_and_txid(int port, int txid); 23 | 24 | void dns_test_init_di(); 25 | err_t dns_test_dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found, void *callback_arg, u8_t dns_addrtype); 26 | 27 | // 28 | // Test starts here 29 | // 30 | int main(int argc, char** argv) 31 | { 32 | uint8_t *buf; 33 | struct pbuf *p; 34 | FILE *file; 35 | size_t len = 1460; 36 | 37 | dns_test_init_di(); 38 | 39 | #ifdef INSTR_IS_OFF 40 | p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); 41 | buf = p->payload; 42 | memset(buf, 0, 1460); 43 | if (argc != 2) 44 | { 45 | printf("Non-instrumentation mode: please supply a file name created by AFL to reproduce crash\n"); 46 | return 1; 47 | } 48 | // 49 | // Note: parameter1 is a file (mangled packet) which caused the crash 50 | file = fopen(argv[1], "r"); 51 | if (file) { 52 | len = fread(buf, 1, 1460, file); 53 | } 54 | fclose(file); 55 | int i; 56 | for (i=0; i<1; i++) { 57 | #else 58 | while (__AFL_LOOP(1000)) { 59 | p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); 60 | buf = p->payload; 61 | memset(buf, 0, 1460); 62 | size_t len = read(0, buf, 1460); 63 | #endif 64 | p->len = len; 65 | p->tot_len = len; 66 | p->next = NULL; 67 | 68 | // Pretend that the response is from our pending querries 69 | dns_test_inject_port_and_txid(1024, (buf[0]<<8) + buf[1]); 70 | dns_test_dns_enqueue("test", 4, NULL, NULL, 0); 71 | 72 | // Process the packet 73 | dns_test_dns_recv(NULL, NULL, p, &ip_addr_any, 0); 74 | } 75 | 76 | 77 | 78 | return 0; 79 | } 80 | --------------------------------------------------------------------------------