|
| 1 | + |
| 2 | +/* |
| 3 | +
|
| 4 | +Redistribution and use in source and binary forms, with or without modification, |
| 5 | +are permitted provided that the following conditions are met: |
| 6 | +
|
| 7 | +1. Redistributions of source code must retain the above copyright notice, |
| 8 | +this list of conditions and the following disclaimer. |
| 9 | +2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | +this list of conditions and the following disclaimer in the documentation |
| 11 | +and/or other materials provided with the distribution. |
| 12 | +3. The name of the author may not be used to endorse or promote products |
| 13 | +derived from this software without specific prior written permission. |
| 14 | +
|
| 15 | +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED |
| 16 | +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 17 | +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
| 18 | +SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 20 | +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 21 | +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 22 | +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 23 | +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
| 24 | +OF SUCH DAMAGE. |
| 25 | +
|
| 26 | +author: d. gauchard |
| 27 | +
|
| 28 | +*/ |
| 29 | + |
| 30 | +// version for esp8266 sdk-2.0.0(656edbf) |
| 31 | + |
| 32 | +#ifndef LWIP2_ARCH_CC_H |
| 33 | +#define LWIP2_ARCH_CC_H |
| 34 | + |
| 35 | +#include "stdint.h" |
| 36 | + |
| 37 | +#include "lwip-err-t.h" |
| 38 | + |
| 39 | +#ifdef LWIP_BUILD |
| 40 | + |
| 41 | +// define LWIP_BUILD only when building LWIP |
| 42 | +// otherwise include files below would conflict |
| 43 | +// with standard headers like atoi() |
| 44 | +#ifdef __cplusplus |
| 45 | +extern "C" |
| 46 | +{ |
| 47 | +#endif |
| 48 | +#include "ets_sys.h" |
| 49 | +#include "osapi.h" |
| 50 | +#include "esp-missing.h" |
| 51 | +#ifdef __cplusplus |
| 52 | +} |
| 53 | +#endif |
| 54 | + |
| 55 | +void sntp_set_system_time (uint32_t t); |
| 56 | + |
| 57 | +#endif // defined(LWIP_BUILD) |
| 58 | + |
| 59 | +#include "mem.h" // useful for os_malloc used in esp-arduino's mDNS |
| 60 | + |
| 61 | +typedef uint32_t sys_prot_t; // not really used |
| 62 | +#define SYS_ARCH_DECL_PROTECT(lev) |
| 63 | +#define SYS_ARCH_PROTECT(lev) os_intr_lock() |
| 64 | +#define SYS_ARCH_UNPROTECT(lev) os_intr_unlock() |
| 65 | + |
| 66 | +/////////////////////////////// |
| 67 | +//// DEBUG |
| 68 | +#include "gluedebug.h" |
| 69 | + |
| 70 | +#if ULWIPDEBUG // debug 1:on or 0 |
| 71 | +#define LWIP_DEBUG 1 |
| 72 | +#define LWIP_PLATFORM_DIAG(x) do { os_printf x; } while(0) |
| 73 | +#define LWIP_PLATFORM_ASSERT(x) do { os_printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); *(int*)0=0; } while(0) |
| 74 | +//#define LWIP_PLATFORM_ASSERT(x) do { os_printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); while(1); } while(0) |
| 75 | +#endif // ULWIPDEBUG |
| 76 | + |
| 77 | +#if !ULWIPASSERT |
| 78 | +#define LWIP_NOASSERT 1 |
| 79 | +#endif |
| 80 | + |
| 81 | +/////////////////////////////// |
| 82 | +//// MISSING |
| 83 | + |
| 84 | +#define sys_now millis // arduino wire millis() definition returns 32 bits like sys_now() does |
| 85 | +#define LWIP_RAND r_rand // old lwip uses this useful undocumented function |
| 86 | +#define IPSTR "%d.%d.%d.%d" |
| 87 | +#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \ |
| 88 | + ip4_addr2_16(ipaddr), \ |
| 89 | + ip4_addr3_16(ipaddr), \ |
| 90 | + ip4_addr4_16(ipaddr) |
| 91 | + |
| 92 | +// ip_addr / ip_info: do not exist in lwip2 (only in lwip1.4) |
| 93 | +struct ip_addr { |
| 94 | + uint32_t addr; |
| 95 | +}; |
| 96 | +struct ip_info { |
| 97 | + struct ip_addr ip; |
| 98 | + struct ip_addr netmask; |
| 99 | + struct ip_addr gw; |
| 100 | +}; |
| 101 | + |
| 102 | +/////////////////////////////// |
| 103 | +//// PROVIDED TO USER |
| 104 | + |
| 105 | +typedef struct ip4_addr ip4_addr_t; |
| 106 | +extern int ntp_servers_number; |
| 107 | +extern ip4_addr_t* ntp_servers; |
| 108 | + |
| 109 | +/////////////////////////////// |
| 110 | +//// STUBS |
| 111 | + |
| 112 | +// these symbols must be renamed in the new implementation |
| 113 | +// because they are known/used in blobs |
| 114 | + |
| 115 | +#define dhcp_cleanup dhcp_cleanup_LWIP2 |
| 116 | +#define dhcp_release dhcp_release_LWIP2 |
| 117 | +#define dhcp_start dhcp_start_LWIP2 |
| 118 | +#define dhcp_stop dhcp_stop_LWIP2 |
| 119 | +#define dhcps_start dhcps_start_LWIP2 |
| 120 | +//#define dhcps_stop dhcps_stop_LWIP2 // void(void) |
| 121 | +#define espconn_init espconn_init_LWIP2 |
| 122 | +#define etharp_output etharp_output_LWIP2 |
| 123 | +#define ethbroadcast ethbroadcast_LWIP2 |
| 124 | +#define ethernet_input ethernet_input_LWIP2 |
| 125 | +#define lwip_init lwip_init_LWIP2 |
| 126 | +#define netif_add netif_add_LWIP2 |
| 127 | +#define netif_default netif_default_LWIP2 |
| 128 | +#define netif_remove netif_remove_LWIP2 |
| 129 | +#define netif_set_addr netif_set_addr_LWIP2 |
| 130 | +#define netif_set_default netif_set_default_LWIP2 |
| 131 | +#define netif_set_down netif_set_down_LWIP2 |
| 132 | +#define netif_set_up netif_set_up_LWIP2 |
| 133 | +#define pbuf_alloc pbuf_alloc_LWIP2 |
| 134 | +#define pbuf_free pbuf_free_LWIP2 |
| 135 | +#define pbuf_ref pbuf_ref_LWIP2 |
| 136 | +//#define sys_check_timeouts sys_check_timeouts_LWIP2 // void(void) |
| 137 | + |
| 138 | +#if !defined(LWIP_DEBUG) || !SYS_DEBUG |
| 139 | +#define sys_timeout sys_timeout_LWIP2 |
| 140 | +#endif |
| 141 | + |
| 142 | +#define sys_untimeout sys_untimeout_LWIP2 |
| 143 | + |
| 144 | +/////////////////////////////// |
| 145 | +#endif // LWIP2_ARCH_CC_H |
0 commit comments