├── .gitignore ├── Makefile ├── Makefile.ajk ├── Makefile.open ├── README.md ├── espconn_dummy.c ├── fastmake.sh ├── gen_misc.bat ├── gen_misc.sh ├── include ├── arch │ ├── cc.h │ ├── perf.h │ └── sys_arch.h ├── lwip │ ├── api.h │ ├── api_msg.h │ ├── app │ │ ├── dhcpserver.h │ │ ├── dhcpserver_common.h │ │ ├── encdhcpserver.h │ │ ├── espconn.h │ │ ├── espconn_tcp.h │ │ ├── espconn_udp.h │ │ └── ping.h │ ├── arch.h │ ├── autoip.h │ ├── debug.h │ ├── def.h │ ├── dhcp.h │ ├── dns.h │ ├── err.h │ ├── icmp.h │ ├── igmp.h │ ├── inet.h │ ├── inet_chksum.h │ ├── init.h │ ├── ip.h │ ├── ip_addr.h │ ├── ip_frag.h │ ├── ip_route.h │ ├── lwip_napt.h │ ├── mdns.h │ ├── mem.h │ ├── memp.h │ ├── memp_std.h │ ├── netbuf.h │ ├── netdb.h │ ├── netif.h │ ├── netifapi.h │ ├── opt.h │ ├── pbuf.h │ ├── puck_def.h │ ├── raw.h │ ├── sio.h │ ├── snmp.h │ ├── snmp_asn1.h │ ├── snmp_msg.h │ ├── snmp_structs.h │ ├── sntp.h │ ├── sockets.h │ ├── stats.h │ ├── sys.h │ ├── tcp.h │ ├── tcp_impl.h │ ├── tcpip.h │ ├── timers.h │ └── udp.h ├── lwipopts.h ├── netif │ ├── driver │ │ ├── spi.h │ │ └── spi_register.h │ ├── espenc.h │ ├── etharp.h │ ├── if_llc.h │ ├── ppp_oe.h │ ├── slipif.h │ ├── tunif.h │ └── wlan_lwip_if.h └── user_config.h ├── lwip ├── Makefile ├── api │ ├── Makefile │ ├── api_lib.c │ ├── api_msg.c │ ├── err.c │ ├── netbuf.c │ ├── netdb.c │ ├── netifapi.c │ ├── sockets.c │ └── tcpip.c ├── app │ ├── Makefile │ ├── dhcpserver.c │ ├── encdhcpserver.c │ ├── espconn.c │ ├── espconn_mdns.c │ ├── espconn_tcp.c │ ├── espconn_udp.c │ ├── netio.c │ └── ping.c ├── core │ ├── Makefile │ ├── def.c │ ├── dhcp.c │ ├── dns.c │ ├── init.c │ ├── ipv4 │ │ ├── Makefile │ │ ├── autoip.c │ │ ├── icmp.c │ │ ├── igmp.c │ │ ├── inet.c │ │ ├── inet_chksum.c │ │ ├── ip.c │ │ ├── ip_addr.c │ │ ├── ip_frag.c │ │ └── ip_route.c │ ├── mdns.c │ ├── mem.c │ ├── memp.c │ ├── netif.c │ ├── pbuf.c │ ├── raw.c │ ├── sntp.c │ ├── stats.c │ ├── sys.c │ ├── sys_arch.c │ ├── tcp.c │ ├── tcp_in.c │ ├── tcp_out.c │ ├── timers.c │ └── udp.c └── netif │ ├── Makefile │ ├── espenc.c │ ├── etharp.c │ ├── slipif.c │ └── tunif.c └── user ├── Makefile └── user_main.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Required variables for each makefile 3 | # Discard this section from all parent makefiles 4 | # Expected variables (with automatic defaults): 5 | # CSRCS (all "C" files in the dir) 6 | # SUBDIRS (all subdirs with a Makefile) 7 | # GEN_LIBS - list of libs to be generated () 8 | # GEN_IMAGES - list of object file images to be generated () 9 | # GEN_BINS - list of binaries to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | TARGET = eagle 15 | #FLAVOR = release 16 | FLAVOR = debug 17 | 18 | #EXTRA_CCFLAGS += -u 19 | 20 | ifndef PDIR # { 21 | GEN_IMAGES= eagle.app.v6.out 22 | GEN_BINS= eagle.app.v6.bin 23 | SPECIAL_MKTARGETS=$(APP_MKTARGETS) 24 | SUBDIRS= \ 25 | user \ 26 | lwip 27 | 28 | endif # } PDIR 29 | 30 | APPDIR = . 31 | LDDIR = ../ld 32 | 33 | CCFLAGS += -Os 34 | 35 | TARGET_LDFLAGS = \ 36 | -nostdlib \ 37 | -Wl,-EL \ 38 | --longcalls \ 39 | --text-section-literals 40 | 41 | ifeq ($(FLAVOR),debug) 42 | TARGET_LDFLAGS += -g -O2 43 | endif 44 | 45 | ifeq ($(FLAVOR),release) 46 | TARGET_LDFLAGS += -g -O0 47 | endif 48 | 49 | COMPONENTS_eagle.app.v6 = \ 50 | user/libuser.a \ 51 | lwip/liblwip.a 52 | 53 | LINKFLAGS_eagle.app.v6 = \ 54 | -L../lib \ 55 | -nostdlib \ 56 | -T$(LD_FILE) \ 57 | -Wl,--no-check-sections \ 58 | -u call_user_start \ 59 | -Wl,-static \ 60 | -Wl,--start-group \ 61 | -lc \ 62 | -lgcc \ 63 | -lhal \ 64 | -lphy \ 65 | -lpp \ 66 | -lnet80211 \ 67 | -lwpa \ 68 | -lcrypto \ 69 | -lmain \ 70 | -ljson \ 71 | -lupgrade\ 72 | -lssl \ 73 | -lpwm \ 74 | -lsmartconfig \ 75 | $(DEP_LIBS_eagle.app.v6) \ 76 | -Wl,--end-group 77 | 78 | DEPENDS_eagle.app.v6 = \ 79 | $(LD_FILE) \ 80 | $(LDDIR)/eagle.rom.addr.v6.ld 81 | 82 | ############################################################# 83 | # Configuration i.e. compile options etc. 84 | # Target specific stuff (defines etc.) goes in here! 85 | # Generally values applying to a tree are captured in the 86 | # makefile at its root level - these are then overridden 87 | # for a subtree within the makefile rooted therein 88 | # 89 | 90 | #UNIVERSAL_TARGET_DEFINES = \ 91 | 92 | # Other potential configuration flags include: 93 | # -DTXRX_TXBUF_DEBUG 94 | # -DTXRX_RXBUF_DEBUG 95 | # -DWLAN_CONFIG_CCX 96 | CONFIGURATION_DEFINES = -DICACHE_FLASH \ 97 | -DLWIP_OPEN_SRC \ 98 | -DPBUF_RSV_FOR_WLAN \ 99 | -DEBUF_LWIP 100 | 101 | DEFINES += \ 102 | $(UNIVERSAL_TARGET_DEFINES) \ 103 | $(CONFIGURATION_DEFINES) 104 | 105 | DDEFINES += \ 106 | $(UNIVERSAL_TARGET_DEFINES) \ 107 | $(CONFIGURATION_DEFINES) 108 | 109 | 110 | ############################################################# 111 | # Recursion Magic - Don't touch this!! 112 | # 113 | # Each subtree potentially has an include directory 114 | # corresponding to the common APIs applicable to modules 115 | # rooted at that subtree. Accordingly, the INCLUDE PATH 116 | # of a module can only contain the include directories up 117 | # its parent path, and not its siblings 118 | # 119 | # Required for each makefile to inherit from the parent 120 | # 121 | 122 | INCLUDES := $(INCLUDES) -I $(PDIR)include 123 | PDIR := ../$(PDIR) 124 | sinclude $(PDIR)Makefile 125 | 126 | .PHONY: FORCE 127 | FORCE: 128 | 129 | -------------------------------------------------------------------------------- /Makefile.ajk: -------------------------------------------------------------------------------- 1 | COMPILE ?= gcc 2 | BOOT ?= none 3 | APP ?= 0 4 | SPI_SPEED ?= 40 5 | SPI_MODE ?= QIO 6 | SPI_SIZE_MAP ?= 0 7 | 8 | CC = $(CURDIR)/../esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc 9 | AR = $(CURDIR)/../esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar 10 | DEFS = -DLWIP_OPEN_SRC -DPBUF_RSV_FOR_WLAN -DEBUF_LWIP -DICACHE_FLASH -DMEMCPY=memcpy -DSMEMCPY=memcpy 11 | COPT = -Os 12 | CFLAGS = $(DEFS) $(COPT) -Iinclude -Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 $(CFLAGS_EXTRA) 13 | # Install prefix of esp-open-sdk toolchain 14 | PREFIX = $(CURDIR)/../esp-open-sdk/xtensa-lx106-elf 15 | 16 | 17 | OBJS = \ 18 | lwip/core/def.o \ 19 | lwip/core/dhcp.o \ 20 | lwip/core/dns.o \ 21 | lwip/core/init.o \ 22 | lwip/core/mem.o \ 23 | lwip/core/memp.o \ 24 | lwip/core/netif.o \ 25 | lwip/core/pbuf.o \ 26 | lwip/core/raw.o \ 27 | lwip/core/sntp.o \ 28 | lwip/core/stats.o \ 29 | lwip/core/sys_arch.o \ 30 | lwip/core/sys.o \ 31 | lwip/core/tcp.o \ 32 | lwip/core/tcp_in.o \ 33 | lwip/core/tcp_out.o \ 34 | lwip/core/timers.o \ 35 | lwip/core/udp.o \ 36 | lwip/core/ipv4/autoip.o \ 37 | lwip/core/ipv4/icmp.o \ 38 | lwip/core/ipv4/igmp.o \ 39 | lwip/core/ipv4/inet.o \ 40 | lwip/core/ipv4/inet_chksum.o \ 41 | lwip/core/ipv4/ip_addr.o \ 42 | lwip/core/ipv4/ip.o \ 43 | lwip/core/ipv4/ip_route.o \ 44 | lwip/core/ipv4/ip_frag.o \ 45 | lwip/netif/etharp.o \ 46 | lwip/netif/slipif.o \ 47 | lwip/netif/tunif.o \ 48 | lwip/netif/espenc.o \ 49 | lwip/app/espconn.o\ 50 | lwip/app/espconn_udp.o\ 51 | lwip/app/espconn_tcp.o\ 52 | lwip/app/espconn_mdns.o\ 53 | lwip/app/ping.o\ 54 | lwip/app/netio.o\ 55 | lwip/app/dhcpserver.o \ 56 | lwip/app/encdhcpserver.o \ 57 | 58 | 59 | LIB = liblwip_open.a 60 | 61 | all: $(LIB) 62 | 63 | 64 | $(LIB): $(OBJS) 65 | $(AR) rcs $@ $^ 66 | 67 | install: $(LIB) 68 | cp $(LIB) $(PREFIX)/xtensa-lx106-elf/sysroot/usr/lib/ 69 | 70 | clean: 71 | rm -f $(OBJS) $(LIB) 72 | -------------------------------------------------------------------------------- /Makefile.open: -------------------------------------------------------------------------------- 1 | COMPILE ?= gcc 2 | BOOT ?= none 3 | APP ?= 0 4 | SPI_SPEED ?= 40 5 | SPI_MODE ?= QIO 6 | SPI_SIZE_MAP ?= 0 7 | 8 | CC = $(CURDIR)/../esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc 9 | AR = $(CURDIR)/../esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar 10 | DEFS = -DLWIP_OPEN_SRC -DPBUF_RSV_FOR_WLAN -DEBUF_LWIP -DICACHE_FLASH -DMEMCPY=memcpy -DSMEMCPY=memcpy 11 | COPT = -Os 12 | CFLAGS = $(DEFS) $(COPT) -Iinclude -Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 $(CFLAGS_EXTRA) 13 | # Install prefix of esp-open-sdk toolchain 14 | PREFIX = $(CURDIR)/../esp-open-sdk/xtensa-lx106-elf 15 | 16 | 17 | OBJS = \ 18 | lwip/core/def.o \ 19 | lwip/core/dhcp.o \ 20 | lwip/core/dns.o \ 21 | lwip/core/init.o \ 22 | lwip/core/mem.o \ 23 | lwip/core/memp.o \ 24 | lwip/core/netif.o \ 25 | lwip/core/pbuf.o \ 26 | lwip/core/raw.o \ 27 | lwip/core/sntp.o \ 28 | lwip/core/stats.o \ 29 | lwip/core/sys_arch.o \ 30 | lwip/core/sys.o \ 31 | lwip/core/tcp.o \ 32 | lwip/core/tcp_in.o \ 33 | lwip/core/tcp_out.o \ 34 | lwip/core/timers.o \ 35 | lwip/core/udp.o \ 36 | lwip/core/ipv4/autoip.o \ 37 | lwip/core/ipv4/icmp.o \ 38 | lwip/core/ipv4/igmp.o \ 39 | lwip/core/ipv4/inet.o \ 40 | lwip/core/ipv4/inet_chksum.o \ 41 | lwip/core/ipv4/ip_addr.o \ 42 | lwip/core/ipv4/ip.o \ 43 | lwip/core/ipv4/ip_route.o \ 44 | lwip/core/ipv4/ip_frag.o \ 45 | lwip/netif/etharp.o \ 46 | lwip/netif/slipif.o \ 47 | lwip/netif/tunif.o \ 48 | lwip/netif/espenc.o \ 49 | lwip/app/espconn.o\ 50 | lwip/app/espconn_udp.o\ 51 | lwip/app/espconn_tcp.o\ 52 | lwip/app/espconn_mdns.o\ 53 | lwip/app/ping.o\ 54 | lwip/app/netio.o\ 55 | lwip/app/dhcpserver.o \ 56 | lwip/app/encdhcpserver.o \ 57 | 58 | 59 | LIB = liblwip_open.a 60 | 61 | all: $(LIB) 62 | 63 | 64 | $(LIB): $(OBJS) 65 | $(AR) rcs $@ $^ 66 | 67 | install: $(LIB) 68 | cp $(LIB) $(PREFIX)/xtensa-lx106-elf/sysroot/usr/lib/ 69 | 70 | clean: 71 | rm -f $(OBJS) $(LIB) 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open lwIP with NAT, SLIP, and static routing for the ESP8266 2 | 3 | ## NAT 4 | The new functions are exported in the "lwip/lwip_napt.h" header. NAPT should be enabled on the SoftAP interface of the ESP (this is typically the interface with netif.num == 1). 5 | 6 | The additional NAPT functionality is enabled by the options IP_FORWARD, IP_NAPT, and IP_NAPT_DYNAMIC in "lwipopts.h". 7 | 8 | This version of lwIP can replace the default version of lwIP in the esp-open-sdk. Just clone and replace the esp-lwip-open directory in the sdk. 9 | 10 | It is based on neocat's NAPT extensions: https://github.com/NeoCat/esp8266-Arduino/commit/4108c8dbced7769c75bcbb9ed880f1d3f178bcbe 11 | 12 | Fixes some issues I had with checksums and timers and can be used for full WiFi repeater functionality. If you want to use it as a permanent replacement for liblwib.a you might want to add the option IP_NAPT_DYNAMIC = 1. With this option the memory for the NAPT tables is allocated only, if ip_napt_init(max_nat, max_portmap) is called explicitly before enabling NAPT. 13 | 14 | ## SLIP 15 | This stack also supports SLIP (Serial Line IP) interfaces via UARTs. To get this up and running, you will need an appropriate UART-driver and some initialization in the main program. You can find a demo at: https://github.com/martin-ger/esp_slip_router 16 | 17 | ## ENC28J60 Ethernet 18 | Starting from the Ethernet ENC28J60 driver from https://github.com/Informatic/espenc . This works with an ENC28J60 connected via SPI. To get this running, you will need at least this SPI driver: https://github.com/MetalPhreak/ESP8266_SPI_Driver and the following wiring: 19 | ``` 20 | ESP8266 ENC28J60 21 | 22 | GPIO12 <---> MISO 23 | GPIO13 <---> MOSI 24 | GPIO14 <---> SCLK 25 | GPIO15 <---> CS 26 | GPIO5 <---> INT 27 | GPIO4 <---> RESET 28 | Q3/V33 <---> 3.3V 29 | GND <---> GND 30 | ``` 31 | In addition you will need a transistor for decoupling GPIO15, otherwise your ESP will not boot any more, see: https://esp8266hints.wordpress.com/category/ethernet/ 32 | 33 | Usage: 34 | Simply connect the enc28j60 as described above, include "lwip/netif" and "netif/espenc.h". 35 | A hardware reset in the ESP's init is optional, but it ensures that an ESP reset also resets the enc. It is done by toggeling GPIO4 (0 and 1), e.g. using the easygpio lib: 36 | ``` 37 | #define ENC28J60_HW_RESET 4 38 | 39 | easygpio_pinMode(ENC28J60_HW_RESET, EASYGPIO_PULLUP, EASYGPIO_OUTPUT); 40 | easygpio_outputSet(ENC28J60_HW_RESET, 0); 41 | os_delay_us(500); 42 | easygpio_outputSet(ENC28J60_HW_RESET, 1); 43 | os_delay_us(1000); 44 | ``` 45 | 46 | Initialize the Ethernet interface in your code by calling the init function: 47 | ``` 48 | struct netif* espenc_init(uint8_t *mac_addr, ip_addr_t *ip, ip_addr_t *mask, ip_addr_t *gw, bool dhcp); 49 | ``` 50 | 51 | ## Static Routing Table 52 | 53 | IPv4 now has a static routing table. In "ip_route.h" there are these new functions: 54 | ``` 55 | struct route_entry { 56 | ip_addr_t ip; 57 | ip_addr_t mask; 58 | ip_addr_t gw; 59 | }; 60 | 61 | /* Add a static route, true on success */ 62 | bool ip_add_route(ip_addr_t ip, ip_addr_t mask, ip_addr_t gw); 63 | 64 | /* Remove a static route, true on success */ 65 | bool ip_rm_route(ip_addr_t ip, ip_addr_t mask); 66 | 67 | /* Finds a route entry for an address, NULL if none */ 68 | struct route_entry *ip_find_route(ip_addr_t ip); 69 | 70 | /* Delete all static routes */ 71 | void ip_delete_routes(void); 72 | 73 | /* Returns the n_th entry of the routing table, true on success */ 74 | bool ip_get_route(uint32_t no, ip_addr_t *ip, ip_addr_t *mask, ip_addr_t *gw); 75 | ``` 76 | 77 | ## Additional Netifs 78 | 79 | ### Loopback 80 | With LWIP_HAVE_LOOPIF 1 in lwipopts.h the lwip stack provides a loopback ("lo0") interface at 127.0.0.1. To get it working call void loopback_netif_init(netif_status_callback_fn cb) from netif.h. Either the callback provided in the init function is implemented to schedule a netif_poll(netif) in the main task or (with NULL callback) netif_poll_all() has to be called peroidically in the main loop. 81 | 82 | ### Tunif 83 | A TUNIF dummy device: this skeleton driver needs at least some additional load/unload functions to be useful for anything. It is intended as starting point for a tunnel device, e.g. for some kind of VPN tunnel. 84 | -------------------------------------------------------------------------------- /espconn_dummy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ICACHE_FLASH_ATTR espconn_init(void) 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /fastmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | make -f Makefile.open clean 3 | make -f Makefile.open COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=0 4 | -------------------------------------------------------------------------------- /gen_misc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo gen_misc.bat version 20150511 4 | echo . 5 | 6 | echo Please follow below steps(1-5) to generate specific bin(s): 7 | echo STEP 1: choose boot version(0=boot_v1.1, 1=boot_v1.2+, 2=none) 8 | set input=default 9 | set /p input=enter(0/1/2, default 2): 10 | 11 | if %input% equ 0 ( 12 | set boot=old 13 | ) else ( 14 | if %input% equ 1 ( 15 | set boot=new 16 | ) else ( 17 | set boot=none 18 | ) 19 | ) 20 | 21 | echo boot mode: %boot% 22 | echo. 23 | 24 | echo STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin) 25 | set input=default 26 | set /p input=enter (0/1/2, default 0): 27 | 28 | if %input% equ 1 ( 29 | if %boot% equ none ( 30 | set app=0 31 | echo choose no boot before 32 | echo generate bin: eagle.flash.bin+eagle.irom0text.bin 33 | ) else ( 34 | set app=1 35 | echo generate bin: user1.bin 36 | ) 37 | ) else ( 38 | if %input% equ 2 ( 39 | if %boot% equ none ( 40 | set app=0 41 | echo choose no boot before 42 | echo generate bin: eagle.flash.bin+eagle.irom0text.bin 43 | ) else ( 44 | set app=2 45 | echo generate bin: user2.bin 46 | ) 47 | ) else ( 48 | if %boot% neq none ( 49 | set boot=none 50 | echo ignore boot 51 | ) 52 | set app=0 53 | echo generate bin: eagle.flash.bin+eagle.irom0text.bin 54 | )) 55 | 56 | echo. 57 | 58 | echo STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz) 59 | set input=default 60 | set /p input=enter (0/1/2/3, default 2): 61 | 62 | if %input% equ 0 ( 63 | set spi_speed=20 64 | ) else ( 65 | if %input% equ 1 ( 66 | set spi_speed=26.7 67 | ) else ( 68 | if %input% equ 3 ( 69 | set spi_speed=80 70 | ) else ( 71 | set spi_speed=40 72 | ))) 73 | 74 | echo spi speed: %spi_speed% MHz 75 | echo. 76 | 77 | echo STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT) 78 | set input=default 79 | set /p input=enter (0/1/2/3, default 0): 80 | 81 | if %input% equ 1 ( 82 | set spi_mode=QOUT 83 | ) else ( 84 | if %input% equ 2 ( 85 | set spi_mode=DIO 86 | ) else ( 87 | if %input% equ 3 ( 88 | set spi_mode=DOUT 89 | ) else ( 90 | set spi_mode=QIO 91 | ))) 92 | 93 | echo spi mode: %spi_mode% 94 | echo. 95 | 96 | echo STEP 5: choose flash size and map 97 | echo 0= 512KB( 256KB+ 256KB) 98 | echo 2=1024KB( 512KB+ 512KB) 99 | echo 3=2048KB( 512KB+ 512KB) 100 | echo 4=4096KB( 512KB+ 512KB) 101 | echo 5=2048KB(1024KB+1024KB) 102 | echo 6=4096KB(1024KB+1024KB) 103 | set input=default 104 | set /p input=enter (0/1/2/3/4/5/6, default 0): 105 | 106 | if %input% equ 2 ( 107 | set spi_size_map=2 108 | echo spi size: 1024KB 109 | echo spi ota map: 512KB + 512KB 110 | ) else ( 111 | if %input% equ 3 ( 112 | set spi_size_map=3 113 | echo spi size: 2048KB 114 | echo spi ota map: 512KB + 512KB 115 | ) else ( 116 | if %input% equ 4 ( 117 | set spi_size_map=4 118 | echo spi size: 4096KB 119 | echo spi ota map: 512KB + 512KB 120 | ) else ( 121 | if %input% equ 5 ( 122 | set spi_size_map=5 123 | echo spi size: 2048KB 124 | echo spi ota map: 1024KB + 1024KB 125 | ) else ( 126 | if %input% equ 6 ( 127 | set spi_size_map=6 128 | echo spi size: 4096KB 129 | echo spi ota map: 1024KB + 1024KB 130 | ) else ( 131 | set spi_size_map=0 132 | echo spi size: 512KB 133 | echo spi ota map: 256KB + 256KB 134 | ) 135 | ) 136 | ) 137 | ) 138 | ) 139 | 140 | touch user/user_main.c 141 | 142 | echo. 143 | echo start... 144 | echo. 145 | 146 | make BOOT=%boot% APP=%app% SPI_SPEED=%spi_speed% SPI_MODE=%spi_mode% SPI_SIZE=%spi_size_map% 147 | 148 | -------------------------------------------------------------------------------- /gen_misc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "gen_misc.sh version 20150511" 4 | echo "" 5 | 6 | echo "Please follow below steps(1-5) to generate specific bin(s):" 7 | echo "STEP 1: choose boot version(0=boot_v1.1, 1=boot_v1.2+, 2=none)" 8 | echo "enter(0/1/2, default 2):" 9 | read input 10 | 11 | if [ -z "$input" ]; then 12 | boot=none 13 | elif [ $input == 0 ]; then 14 | boot=old 15 | elif [ $input == 1 ]; then 16 | boot=new 17 | else 18 | boot=none 19 | fi 20 | 21 | echo "boot mode: $boot" 22 | echo "" 23 | 24 | echo "STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)" 25 | echo "enter (0/1/2, default 0):" 26 | read input 27 | 28 | if [ -z "$input" ]; then 29 | if [ $boot != none ]; then 30 | boot=none 31 | echo "ignore boot" 32 | fi 33 | app=0 34 | echo "generate bin: eagle.flash.bin+eagle.irom0text.bin" 35 | elif [ $input == 1 ]; then 36 | if [ $boot == none ]; then 37 | app=0 38 | echo "choose no boot before" 39 | echo "generate bin: eagle.flash.bin+eagle.irom0text.bin" 40 | else 41 | app=1 42 | echo "generate bin: user1.bin" 43 | fi 44 | elif [ $input == 2 ]; then 45 | if [ $boot == none ]; then 46 | app=0 47 | echo "choose no boot before" 48 | echo "generate bin: eagle.flash.bin+eagle.irom0text.bin" 49 | else 50 | app=2 51 | echo "generate bin: user2.bin" 52 | fi 53 | else 54 | if [ $boot != none ]; then 55 | boot=none 56 | echo "ignore boot" 57 | fi 58 | app=0 59 | echo "generate bin: eagle.flash.bin+eagle.irom0text.bin" 60 | fi 61 | 62 | echo "" 63 | 64 | echo "STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)" 65 | echo "enter (0/1/2/3, default 2):" 66 | read input 67 | 68 | if [ -z "$input" ]; then 69 | spi_speed=40 70 | elif [ $input == 0 ]; then 71 | spi_speed=20 72 | elif [ $input == 1 ]; then 73 | spi_speed=26.7 74 | elif [ $input == 3 ]; then 75 | spi_speed=80 76 | else 77 | spi_speed=40 78 | fi 79 | 80 | echo "spi speed: $spi_speed MHz" 81 | echo "" 82 | 83 | echo "STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)" 84 | echo "enter (0/1/2/3, default 0):" 85 | read input 86 | 87 | if [ -z "$input" ]; then 88 | spi_mode=QIO 89 | elif [ $input == 1 ]; then 90 | spi_mode=QOUT 91 | elif [ $input == 2 ]; then 92 | spi_mode=DIO 93 | elif [ $input == 3 ]; then 94 | spi_mode=DOUT 95 | else 96 | spi_mode=QIO 97 | fi 98 | 99 | echo "spi mode: $spi_mode" 100 | echo "" 101 | 102 | echo "STEP 5: choose spi size and map" 103 | echo " 0= 512KB( 256KB+ 256KB)" 104 | echo " 2=1024KB( 512KB+ 512KB)" 105 | echo " 3=2048KB( 512KB+ 512KB)" 106 | echo " 4=4096KB( 512KB+ 512KB)" 107 | echo " 5=2048KB(1024KB+1024KB)" 108 | echo " 6=4096KB(1024KB+1024KB)" 109 | echo "enter (0/2/3/4/5/6, default 0):" 110 | read input 111 | 112 | if [ -z "$input" ]; then 113 | spi_size_map=0 114 | echo "spi size: 512KB" 115 | echo "spi ota map: 256KB + 256KB" 116 | elif [ $input == 2 ]; then 117 | spi_size_map=2 118 | echo "spi size: 1024KB" 119 | echo "spi ota map: 512KB + 512KB" 120 | elif [ $input == 3 ]; then 121 | spi_size_map=3 122 | echo "spi size: 2048KB" 123 | echo "spi ota map: 512KB + 512KB" 124 | elif [ $input == 4 ]; then 125 | spi_size_map=4 126 | echo "spi size: 4096KB" 127 | echo "spi ota map: 512KB + 512KB" 128 | elif [ $input == 5 ]; then 129 | spi_size_map=5 130 | echo "spi size: 2048KB" 131 | echo "spi ota map: 1024KB + 1024KB" 132 | elif [ $input == 6 ]; then 133 | spi_size_map=6 134 | echo "spi size: 4096KB" 135 | echo "spi ota map: 1024KB + 1024KB" 136 | else 137 | spi_size_map=0 138 | echo "spi size: 512KB" 139 | echo "spi ota map: 256KB + 256KB" 140 | fi 141 | 142 | echo "" 143 | 144 | touch user/user_main.c 145 | 146 | echo "" 147 | echo "start..." 148 | echo "" 149 | 150 | make COMPILE=gcc BOOT=$boot APP=$app SPI_SPEED=$spi_speed SPI_MODE=$spi_mode SPI_SIZE_MAP=$spi_size_map 151 | -------------------------------------------------------------------------------- /include/arch/cc.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 __ARCH_CC_H__ 35 | #define __ARCH_CC_H__ 36 | 37 | //#include 38 | #include "c_types.h" 39 | #include "ets_sys.h" 40 | #include "osapi.h" 41 | #define EFAULT 14 42 | 43 | //#define LWIP_PROVIDE_ERRNO 44 | 45 | #if (1) 46 | #define BYTE_ORDER LITTLE_ENDIAN 47 | #else 48 | #define BYTE_ORDER BIG_ENDIAN 49 | #endif 50 | 51 | 52 | typedef unsigned char u8_t; 53 | typedef signed char s8_t; 54 | typedef unsigned short u16_t; 55 | typedef signed short s16_t; 56 | typedef unsigned long u32_t; 57 | typedef signed long s32_t; 58 | typedef unsigned long mem_ptr_t; 59 | 60 | #define S16_F "d" 61 | #define U16_F "d" 62 | #define X16_F "x" 63 | 64 | #define S32_F "d" 65 | #define U32_F "d" 66 | #define X32_F "x" 67 | 68 | 69 | 70 | //#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) 71 | #define PACK_STRUCT_FIELD(x) x 72 | #define PACK_STRUCT_STRUCT __attribute__((packed)) 73 | #define PACK_STRUCT_BEGIN 74 | #define PACK_STRUCT_END 75 | 76 | //#define LWIP_DEBUG 77 | 78 | #ifdef LWIP_DEBUG 79 | #define LWIP_PLATFORM_DIAG(x) os_printf x 80 | #define LWIP_PLATFORM_ASSERT(x) 81 | #else 82 | #define LWIP_PLATFORM_DIAG(x) 83 | #define LWIP_PLATFORM_ASSERT(x) 84 | #endif 85 | 86 | #define SYS_ARCH_DECL_PROTECT(x) 87 | #define SYS_ARCH_PROTECT(x) 88 | #define SYS_ARCH_UNPROTECT(x) 89 | 90 | #define LWIP_PLATFORM_BYTESWAP 1 91 | #define LWIP_PLATFORM_HTONS(_n) ((u16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff))) 92 | #define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) )) 93 | 94 | #if LWIP_RAW 95 | extern u8_t memp_memory_RAW_PCB_base[]; 96 | #endif /* LWIP_RAW */ 97 | 98 | #if LWIP_UDP 99 | extern u8_t memp_memory_UDP_PCB_base[]; 100 | #endif /* LWIP_UDP */ 101 | 102 | #if LWIP_TCP 103 | extern u8_t memp_memory_TCP_PCB_base[]; 104 | extern u8_t memp_memory_TCP_PCB_LISTEN_base[]; 105 | extern u8_t memp_memory_TCP_SEG_base[] SHMEM_ATTR; 106 | #endif /* LWIP_TCP */ 107 | 108 | #if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */ 109 | extern u8_t memp_memory_SYS_TIMEOUT_base[]; 110 | #endif /* LWIP_TIMERS */ 111 | 112 | extern u8_t memp_memory_PBUF_base[]; 113 | extern u8_t memp_memory_PBUF_POOL_base[]; 114 | 115 | 116 | 117 | #endif /* __ARCH_CC_H__ */ 118 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /include/arch/sys_arch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-ger/esp-open-lwip/5157a11da89c2ae8aeca0653c5a44fed7377fde8/include/arch/sys_arch.h -------------------------------------------------------------------------------- /include/lwip/api_msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_API_MSG_H__ 33 | #define __LWIP_API_MSG_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include /* for size_t */ 40 | 41 | #include "lwip/ip_addr.h" 42 | #include "lwip/err.h" 43 | #include "lwip/sys.h" 44 | #include "lwip/igmp.h" 45 | #include "lwip/api.h" 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /* For the netconn API, these values are use as a bitmask! */ 52 | #define NETCONN_SHUT_RD 1 53 | #define NETCONN_SHUT_WR 2 54 | #define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) 55 | 56 | /* IP addresses and port numbers are expected to be in 57 | * the same byte order as in the corresponding pcb. 58 | */ 59 | /** This struct includes everything that is necessary to execute a function 60 | for a netconn in another thread context (mainly used to process netconns 61 | in the tcpip_thread context to be thread safe). */ 62 | struct api_msg_msg { 63 | /** The netconn which to process - always needed: it includes the semaphore 64 | which is used to block the application thread until the function finished. */ 65 | struct netconn *conn; 66 | /** The return value of the function executed in tcpip_thread. */ 67 | err_t err; 68 | /** Depending on the executed function, one of these union members is used */ 69 | union { 70 | /** used for do_send */ 71 | struct netbuf *b; 72 | /** used for do_newconn */ 73 | struct { 74 | u8_t proto; 75 | } n; 76 | /** used for do_bind and do_connect */ 77 | struct { 78 | ip_addr_t *ipaddr; 79 | u16_t port; 80 | } bc; 81 | /** used for do_getaddr */ 82 | struct { 83 | ip_addr_t *ipaddr; 84 | u16_t *port; 85 | u8_t local; 86 | } ad; 87 | /** used for do_write */ 88 | struct { 89 | const void *dataptr; 90 | size_t len; 91 | u8_t apiflags; 92 | } w; 93 | /** used for do_recv */ 94 | struct { 95 | u32_t len; 96 | } r; 97 | /** used for do_close (/shutdown) */ 98 | struct { 99 | u8_t shut; 100 | } sd; 101 | #if LWIP_IGMP 102 | /** used for do_join_leave_group */ 103 | struct { 104 | ip_addr_t *multiaddr; 105 | ip_addr_t *netif_addr; 106 | enum netconn_igmp join_or_leave; 107 | } jl; 108 | #endif /* LWIP_IGMP */ 109 | #if TCP_LISTEN_BACKLOG 110 | struct { 111 | u8_t backlog; 112 | } lb; 113 | #endif /* TCP_LISTEN_BACKLOG */ 114 | } msg; 115 | }; 116 | 117 | /** This struct contains a function to execute in another thread context and 118 | a struct api_msg_msg that serves as an argument for this function. 119 | This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ 120 | struct api_msg { 121 | /** function to execute in tcpip_thread context */ 122 | void (* function)(struct api_msg_msg *msg); 123 | /** arguments for this function */ 124 | struct api_msg_msg msg; 125 | }; 126 | 127 | #if LWIP_DNS 128 | /** As do_gethostbyname requires more arguments but doesn't require a netconn, 129 | it has its own struct (to avoid struct api_msg getting bigger than necessary). 130 | do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg 131 | (see netconn_gethostbyname). */ 132 | struct dns_api_msg { 133 | /** Hostname to query or dotted IP address string */ 134 | const char *name; 135 | /** Rhe resolved address is stored here */ 136 | ip_addr_t *addr; 137 | /** This semaphore is posted when the name is resolved, the application thread 138 | should wait on it. */ 139 | sys_sem_t *sem; 140 | /** Errors are given back here */ 141 | err_t *err; 142 | }; 143 | #endif /* LWIP_DNS */ 144 | 145 | void do_newconn ( struct api_msg_msg *msg); 146 | void do_delconn ( struct api_msg_msg *msg); 147 | void do_bind ( struct api_msg_msg *msg); 148 | void do_connect ( struct api_msg_msg *msg); 149 | void do_disconnect ( struct api_msg_msg *msg); 150 | void do_listen ( struct api_msg_msg *msg); 151 | void do_send ( struct api_msg_msg *msg); 152 | void do_recv ( struct api_msg_msg *msg); 153 | void do_write ( struct api_msg_msg *msg); 154 | void do_getaddr ( struct api_msg_msg *msg); 155 | void do_close ( struct api_msg_msg *msg); 156 | void do_shutdown ( struct api_msg_msg *msg); 157 | #if LWIP_IGMP 158 | void do_join_leave_group( struct api_msg_msg *msg); 159 | #endif /* LWIP_IGMP */ 160 | 161 | #if LWIP_DNS 162 | void do_gethostbyname(void *arg); 163 | #endif /* LWIP_DNS */ 164 | 165 | struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); 166 | void netconn_free(struct netconn *conn); 167 | 168 | #ifdef __cplusplus 169 | } 170 | #endif 171 | 172 | #endif /* LWIP_NETCONN */ 173 | 174 | #endif /* __LWIP_API_MSG_H__ */ 175 | -------------------------------------------------------------------------------- /include/lwip/app/dhcpserver.h: -------------------------------------------------------------------------------- 1 | #ifndef __DHCPS_H__ 2 | #define __DHCPS_H__ 3 | 4 | #define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0) 5 | #include "dhcpserver_common.h" 6 | #define DHCPS_DEBUG 0 7 | 8 | extern uint32 dhcps_lease_time; 9 | #define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0 10 | 11 | void dhcps_start(struct ip_info *info); 12 | void dhcps_stop(void); 13 | 14 | void dhcps_set_DNS(struct ip_addr *dns_ip) ICACHE_FLASH_ATTR; 15 | struct dhcps_pool *dhcps_get_mapping(uint16_t no) ICACHE_FLASH_ATTR; 16 | void dhcps_set_mapping(struct ip_addr *addr, uint8 *mac, uint32 lease_time) ICACHE_FLASH_ATTR; 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /include/lwip/app/dhcpserver_common.h: -------------------------------------------------------------------------------- 1 | #ifndef __DHCPS_COMMON_H__ 2 | #define __DHCPS_COMMON_H__ 3 | 4 | #define USE_DNS 5 | 6 | typedef struct dhcps_state{ 7 | sint16_t state; 8 | } dhcps_state; 9 | 10 | // ����dhcpclient�Զ����һ��DHCP msg�ṹ�� 11 | typedef struct dhcps_msg { 12 | uint8_t op, htype, hlen, hops; 13 | uint8_t xid[4]; 14 | uint16_t secs, flags; 15 | uint8_t ciaddr[4]; 16 | uint8_t yiaddr[4]; 17 | uint8_t siaddr[4]; 18 | uint8_t giaddr[4]; 19 | uint8_t chaddr[16]; 20 | uint8_t sname[64]; 21 | uint8_t file[128]; 22 | uint8_t options[312]; 23 | }dhcps_msg; 24 | 25 | #ifndef LWIP_OPEN_SRC 26 | struct dhcps_lease { 27 | bool enable; 28 | struct ip_addr start_ip; 29 | struct ip_addr end_ip; 30 | }; 31 | 32 | enum dhcps_offer_option{ 33 | OFFER_START = 0x00, 34 | OFFER_ROUTER = 0x01, 35 | OFFER_END 36 | }; 37 | #endif 38 | 39 | struct dhcps_pool{ 40 | struct ip_addr ip; 41 | uint8 mac[6]; 42 | uint32 lease_timer; 43 | }; 44 | 45 | typedef struct _list_node{ 46 | void *pnode; 47 | struct _list_node *pnext; 48 | }list_node; 49 | 50 | #define DHCPS_MAX_LEASE 0x64 51 | #define BOOTP_BROADCAST 0x8000 52 | 53 | #define DHCP_REQUEST 1 54 | #define DHCP_REPLY 2 55 | #define DHCP_HTYPE_ETHERNET 1 56 | #define DHCP_HLEN_ETHERNET 6 57 | #define DHCP_MSG_LEN 236 58 | 59 | #define DHCPS_SERVER_PORT 67 60 | #define DHCPS_CLIENT_PORT 68 61 | 62 | #define DHCPDISCOVER 1 63 | #define DHCPOFFER 2 64 | #define DHCPREQUEST 3 65 | #define DHCPDECLINE 4 66 | #define DHCPACK 5 67 | #define DHCPNAK 6 68 | #define DHCPRELEASE 7 69 | 70 | #define DHCP_OPTION_SUBNET_MASK 1 71 | #define DHCP_OPTION_ROUTER 3 72 | #define DHCP_OPTION_DNS_SERVER 6 73 | #define DHCP_OPTION_REQ_IPADDR 50 74 | #define DHCP_OPTION_LEASE_TIME 51 75 | #define DHCP_OPTION_MSG_TYPE 53 76 | #define DHCP_OPTION_SERVER_ID 54 77 | #define DHCP_OPTION_INTERFACE_MTU 26 78 | #define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31 79 | #define DHCP_OPTION_BROADCAST_ADDRESS 28 80 | #define DHCP_OPTION_REQ_LIST 55 81 | #define DHCP_OPTION_END 255 82 | 83 | //#define USE_CLASS_B_NET 1 84 | #define MAX_STATION_NUM 8 85 | 86 | #define DHCPS_STATE_OFFER 1 87 | #define DHCPS_STATE_DECLINE 2 88 | #define DHCPS_STATE_ACK 3 89 | #define DHCPS_STATE_NAK 4 90 | #define DHCPS_STATE_IDLE 5 91 | #define DHCPS_STATE_RELEASE 6 92 | 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /include/lwip/app/encdhcpserver.h: -------------------------------------------------------------------------------- 1 | #ifndef __enc_DHCPS_H__ 2 | #define __enc_DHCPS_H__ 3 | 4 | #define enc_dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0) 5 | #include "dhcpserver_common.h" 6 | 7 | extern uint32 enc_dhcps_lease_time; 8 | #define enc_DHCPS_LEASE_TIMER enc_dhcps_lease_time //0x05A0 9 | #define ENCDHCPS_DEBUG 0 10 | 11 | 12 | void enc_dhcps_start(struct netif* enetif); 13 | void enc_dhcps_stop(void); 14 | 15 | void enc_dhcps_set_DNS(struct ip_addr *dns_ip) ICACHE_FLASH_ATTR; 16 | struct dhcps_pool *enc_dhcps_get_mapping(uint16_t no) ICACHE_FLASH_ATTR; 17 | void enc_dhcps_set_mapping(struct ip_addr *addr, uint8 *mac, uint32 lease_time) ICACHE_FLASH_ATTR; 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /include/lwip/app/espconn_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESPCONN_TCP_H__ 2 | #define __ESPCONN_TCP_H__ 3 | 4 | #ifndef ESPCONN_TCP_DEBUG 5 | #define ESPCONN_TCP_DEBUG LWIP_DBG_OFF 6 | #endif 7 | #include "lwip/app/espconn.h" 8 | 9 | #ifndef ESPCONN_TCP_TIMER 10 | #define ESPCONN_TCP_TIMER 40 11 | #endif 12 | 13 | #define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE) 14 | #define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE) 15 | 16 | /****************************************************************************** 17 | * FunctionName : espconn_kill_oldest_pcb 18 | * Description : A oldest incoming connection has been killed. 19 | * Parameters : none 20 | * Returns : none 21 | *******************************************************************************/ 22 | 23 | extern void espconn_kill_oldest_pcb(void); 24 | 25 | /****************************************************************************** 26 | * FunctionName : espconn_tcp_disconnect 27 | * Description : A new incoming connection has been disconnected. 28 | * Parameters : espconn -- the espconn used to disconnect with host 29 | * Returns : none 30 | *******************************************************************************/ 31 | 32 | extern void espconn_tcp_disconnect(espconn_msg *pdiscon,u8 type); 33 | 34 | /****************************************************************************** 35 | * FunctionName : espconn_tcp_client 36 | * Description : Initialize the client: set up a connect PCB and bind it to 37 | * the defined port 38 | * Parameters : espconn -- the espconn used to build client 39 | * Returns : none 40 | *******************************************************************************/ 41 | 42 | extern sint8 espconn_tcp_client(struct espconn* espconn); 43 | 44 | /****************************************************************************** 45 | * FunctionName : espconn_tcp_server 46 | * Description : Initialize the server: set up a listening PCB and bind it to 47 | * the defined port 48 | * Parameters : espconn -- the espconn used to build server 49 | * Returns : none 50 | *******************************************************************************/ 51 | 52 | extern sint8 espconn_tcp_server(struct espconn *espconn); 53 | 54 | #endif /* __CLIENT_TCP_H__ */ 55 | 56 | -------------------------------------------------------------------------------- /include/lwip/app/espconn_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESPCONN_UDP_H__ 2 | #define __ESPCONN_UDP_H__ 3 | 4 | #ifndef ESPCONN_UDP_DEBUG 5 | #define ESPCONN_UDP_DEBUG LWIP_DBG_OFF 6 | #endif 7 | 8 | #include "lwip/app/espconn.h" 9 | 10 | /****************************************************************************** 11 | * FunctionName : espconn_udp_client 12 | * Description : Initialize the client: set up a PCB and bind it to the port 13 | * Parameters : pespconn -- the espconn used to build client 14 | * Returns : none 15 | *******************************************************************************/ 16 | 17 | extern sint8 espconn_udp_client(struct espconn *pespconn); 18 | 19 | /****************************************************************************** 20 | * FunctionName : espconn_udp_disconnect 21 | * Description : A new incoming connection has been disconnected. 22 | * Parameters : espconn -- the espconn used to disconnect with host 23 | * Returns : none 24 | *******************************************************************************/ 25 | 26 | extern void espconn_udp_disconnect(espconn_msg *pdiscon); 27 | 28 | /****************************************************************************** 29 | * FunctionName : espconn_udp_server 30 | * Description : Initialize the server: set up a PCB and bind it to the port 31 | * Parameters : pespconn -- the espconn used to build server 32 | * Returns : none 33 | *******************************************************************************/ 34 | 35 | extern sint8 espconn_udp_server(struct espconn *espconn); 36 | 37 | /****************************************************************************** 38 | * FunctionName : espconn_udp_sent 39 | * Description : sent data for client or server 40 | * Parameters : void *arg -- client or server to send 41 | * uint8* psent -- Data to send 42 | * uint16 length -- Length of data to send 43 | * Returns : none 44 | *******************************************************************************/ 45 | 46 | extern err_t espconn_udp_sent(void *arg, uint8 *psent, uint16 length); 47 | 48 | /****************************************************************************** 49 | * FunctionName : espconn_udp_sendto 50 | * Description : sent data for UDP 51 | * Parameters : void *arg -- UDP to send 52 | * uint8* psent -- Data to send 53 | * uint16 length -- Length of data to send 54 | * Returns : return espconn error code. 55 | * - ESPCONN_OK. Successful. No error occured. 56 | * - ESPCONN_MEM. Out of memory. 57 | * - ESPCONN_RTE. Could not find route to destination address. 58 | * - More errors could be returned by lower protocol layers. 59 | *******************************************************************************/ 60 | extern err_t espconn_udp_sendto(void *arg, uint8 *psent, uint16 length); 61 | 62 | #endif /* __ESPCONN_UDP_H__ */ 63 | 64 | 65 | -------------------------------------------------------------------------------- /include/lwip/app/ping.h: -------------------------------------------------------------------------------- 1 | #ifndef __PING_H__ 2 | #define __PING_H__ 3 | #include "lwip/ip_addr.h" 4 | #include "lwip/icmp.h" 5 | /** 6 | * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used 7 | */ 8 | #ifndef PING_USE_SOCKETS 9 | #define PING_USE_SOCKETS LWIP_SOCKET 10 | #endif 11 | 12 | /** 13 | * PING_DEBUG: Enable debugging for PING. 14 | */ 15 | #ifndef PING_DEBUG 16 | #define PING_DEBUG LWIP_DBG_OFF 17 | #endif 18 | 19 | /** ping receive timeout - in milliseconds */ 20 | #ifndef PING_RCV_TIMEO 21 | #define PING_RCV_TIMEO 1000 22 | #endif 23 | 24 | /** ping delay - in milliseconds */ 25 | #ifndef PING_COARSE 26 | #define PING_COARSE 1000 27 | #endif 28 | 29 | /** ping identifier - must fit on a u16_t */ 30 | #ifndef PING_ID 31 | #define PING_ID 0xAFAF 32 | #endif 33 | 34 | /** ping additional data size to include in the packet */ 35 | #ifndef PING_DATA_SIZE 36 | #define PING_DATA_SIZE 32 37 | #endif 38 | 39 | /** ping result action - no default action */ 40 | #ifndef PING_RESULT 41 | #define PING_RESULT(ping_ok) 42 | #endif 43 | 44 | #define DEFAULT_PING_MAX_COUNT 4 45 | #define PING_TIMEOUT_MS 1000 46 | 47 | typedef void (* ping_recv_function)(void* arg, void *pdata); 48 | typedef void (* ping_sent_function)(void* arg, void *pdata); 49 | 50 | struct ping_option{ 51 | uint32 count; 52 | uint32 ip; 53 | uint32 coarse_time; 54 | ping_recv_function recv_function; 55 | ping_sent_function sent_function; 56 | void* reverse; 57 | }; 58 | 59 | struct ping_msg{ 60 | struct ping_option *ping_opt; 61 | struct raw_pcb *ping_pcb; 62 | uint32 ping_start; 63 | uint32 ping_sent; 64 | uint32 timeout_count; 65 | uint32 max_count; 66 | uint32 sent_count; 67 | uint32 coarse_time; 68 | }; 69 | 70 | struct ping_resp{ 71 | uint32 total_count; 72 | uint32 resp_time; 73 | uint32 seqno; 74 | uint32 timeout_count; 75 | uint32 bytes; 76 | uint32 total_bytes; 77 | uint32 total_time; 78 | sint8 ping_err; 79 | }; 80 | 81 | bool ping_start(struct ping_option *ping_opt); 82 | bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv); 83 | bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent); 84 | 85 | #endif /* __PING_H__ */ 86 | -------------------------------------------------------------------------------- /include/lwip/autoip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * AutoIP Automatic LinkLocal IP Configuration 5 | */ 6 | 7 | /* 8 | * 9 | * Copyright (c) 2007 Dominik Spies 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * Author: Dominik Spies 35 | * 36 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 37 | * with RFC 3927. 38 | * 39 | * 40 | * Please coordinate changes and requests with Dominik Spies 41 | * 42 | */ 43 | 44 | #ifndef __LWIP_AUTOIP_H__ 45 | #define __LWIP_AUTOIP_H__ 46 | 47 | #include "lwip/opt.h" 48 | 49 | #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ 50 | 51 | #include "lwip/netif.h" 52 | #include "lwip/udp.h" 53 | #include "netif/etharp.h" 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /* AutoIP Timing */ 60 | #define AUTOIP_TMR_INTERVAL 100 61 | #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) 62 | 63 | /* RFC 3927 Constants */ 64 | #define PROBE_WAIT 1 /* second (initial random delay) */ 65 | #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ 66 | #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ 67 | #define PROBE_NUM 3 /* (number of probe packets) */ 68 | #define ANNOUNCE_NUM 2 /* (number of announcement packets) */ 69 | #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ 70 | #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ 71 | #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ 72 | #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ 73 | #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ 74 | 75 | /* AutoIP client states */ 76 | #define AUTOIP_STATE_OFF 0 77 | #define AUTOIP_STATE_PROBING 1 78 | #define AUTOIP_STATE_ANNOUNCING 2 79 | #define AUTOIP_STATE_BOUND 3 80 | 81 | struct autoip 82 | { 83 | ip_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */ 84 | u8_t state; /* current AutoIP state machine state */ 85 | u8_t sent_num; /* sent number of probes or announces, dependent on state */ 86 | u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ 87 | u8_t lastconflict; /* ticks until a conflict can be solved by defending */ 88 | u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */ 89 | }; 90 | 91 | 92 | /** Init srand, has to be called before entering mainloop */ 93 | void autoip_init(void); 94 | 95 | /** Set a struct autoip allocated by the application to work with */ 96 | void autoip_set_struct(struct netif *netif, struct autoip *autoip); 97 | 98 | /** Start AutoIP client */ 99 | err_t autoip_start(struct netif *netif); 100 | 101 | /** Stop AutoIP client */ 102 | err_t autoip_stop(struct netif *netif); 103 | 104 | /** Handles every incoming ARP Packet, called by etharp_arp_input */ 105 | void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); 106 | 107 | /** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */ 108 | void autoip_tmr(void); 109 | 110 | /** Handle a possible change in the network configuration */ 111 | void autoip_network_changed(struct netif *netif); 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif /* LWIP_AUTOIP */ 118 | 119 | #endif /* __LWIP_AUTOIP_H__ */ 120 | -------------------------------------------------------------------------------- /include/lwip/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "lwipopts.h" 36 | #include "lwip/arch.h" 37 | 38 | /** lower two bits indicate debug level 39 | * - 0 all 40 | * - 1 warning 41 | * - 2 serious 42 | * - 3 severe 43 | */ 44 | #define LWIP_DBG_LEVEL_ALL 0x00 45 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 46 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 47 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 48 | #define LWIP_DBG_LEVEL_SEVERE 0x03 49 | #define LWIP_DBG_MASK_LEVEL 0x03 50 | 51 | /** flag for LWIP_DEBUGF to enable that debug message */ 52 | #define LWIP_DBG_ON 0x80U 53 | /** flag for LWIP_DEBUGF to disable that debug message */ 54 | #define LWIP_DBG_OFF 0x00U 55 | 56 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 57 | #define LWIP_DBG_TRACE 0x40U 58 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 59 | #define LWIP_DBG_STATE 0x20U 60 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 61 | #define LWIP_DBG_FRESH 0x10U 62 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 63 | #define LWIP_DBG_HALT 0x08U 64 | 65 | #ifndef LWIP_NOASSERT 66 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 67 | LWIP_PLATFORM_ASSERT(message); } while(0) 68 | #else /* LWIP_NOASSERT */ 69 | #define LWIP_ASSERT(message, assertion) 70 | #endif /* LWIP_NOASSERT */ 71 | 72 | /** if "expression" isn't true, then print "message" and execute "handler" expression */ 73 | #ifndef LWIP_ERROR 74 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 75 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 76 | #endif /* LWIP_ERROR */ 77 | 78 | #ifdef LWIP_DEBUG 79 | /** print debug message only if debug message type is enabled... 80 | * AND is of correct type AND is at least LWIP_DBG_LEVEL 81 | */ 82 | #define LWIP_DEBUGF(debug, message) do { \ 83 | if ( \ 84 | ((debug) & LWIP_DBG_ON) && \ 85 | ((debug) & LWIP_DBG_TYPES_ON) && \ 86 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 87 | LWIP_PLATFORM_DIAG(message); \ 88 | if ((debug) & LWIP_DBG_HALT) { \ 89 | while(1); \ 90 | } \ 91 | } \ 92 | } while(0) 93 | 94 | #else /* LWIP_DEBUG */ 95 | #define LWIP_DEBUGF(debug, message) 96 | #endif /* LWIP_DEBUG */ 97 | 98 | #endif /* __LWIP_DEBUG_H__ */ 99 | 100 | -------------------------------------------------------------------------------- /include/lwip/def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEF_H__ 33 | #define __LWIP_DEF_H__ 34 | 35 | /* arch.h might define NULL already */ 36 | #include "lwip/arch.h" 37 | #include "lwip/opt.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) 44 | #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) 45 | 46 | #ifndef NULL 47 | #define NULL ((void *)0) 48 | #endif 49 | 50 | /** Get the absolute difference between 2 u32_t values (correcting overflows) 51 | * 'a' is expected to be 'higher' (without overflow) than 'b'. */ 52 | #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1))) 53 | 54 | /* Endianess-optimized shifting of two u8_t to create one u16_t */ 55 | #if BYTE_ORDER == LITTLE_ENDIAN 56 | #define LWIP_MAKE_U16(a, b) ((a << 8) | b) 57 | #else 58 | #define LWIP_MAKE_U16(a, b) ((b << 8) | a) 59 | #endif 60 | 61 | #ifndef LWIP_PLATFORM_BYTESWAP 62 | #define LWIP_PLATFORM_BYTESWAP 0 63 | #endif 64 | 65 | #ifndef LWIP_PREFIX_BYTEORDER_FUNCS 66 | /* workaround for naming collisions on some platforms */ 67 | 68 | #ifdef htons 69 | #undef htons 70 | #endif /* htons */ 71 | #ifdef htonl 72 | #undef htonl 73 | #endif /* htonl */ 74 | #ifdef ntohs 75 | #undef ntohs 76 | #endif /* ntohs */ 77 | #ifdef ntohl 78 | #undef ntohl 79 | #endif /* ntohl */ 80 | 81 | #define htons(x) lwip_htons(x) 82 | #define ntohs(x) lwip_ntohs(x) 83 | #define htonl(x) lwip_htonl(x) 84 | #define ntohl(x) lwip_ntohl(x) 85 | #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ 86 | 87 | #if BYTE_ORDER == BIG_ENDIAN 88 | #define lwip_htons(x) (x) 89 | #define lwip_ntohs(x) (x) 90 | #define lwip_htonl(x) (x) 91 | #define lwip_ntohl(x) (x) 92 | #define PP_HTONS(x) (x) 93 | #define PP_NTOHS(x) (x) 94 | #define PP_HTONL(x) (x) 95 | #define PP_NTOHL(x) (x) 96 | #else /* BYTE_ORDER != BIG_ENDIAN */ 97 | #if LWIP_PLATFORM_BYTESWAP 98 | #define lwip_htons(x) LWIP_PLATFORM_HTONS(x) 99 | #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) 100 | #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) 101 | #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) 102 | #else /* LWIP_PLATFORM_BYTESWAP */ 103 | u16_t lwip_htons(u16_t x); 104 | u16_t lwip_ntohs(u16_t x); 105 | u32_t lwip_htonl(u32_t x); 106 | u32_t lwip_ntohl(u32_t x); 107 | #endif /* LWIP_PLATFORM_BYTESWAP */ 108 | 109 | /* These macros should be calculated by the preprocessor and are used 110 | with compile-time constants only (so that there is no little-endian 111 | overhead at runtime). */ 112 | #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) 113 | #define PP_NTOHS(x) PP_HTONS(x) 114 | #define PP_HTONL(x) ((((x) & 0xff) << 24) | \ 115 | (((x) & 0xff00) << 8) | \ 116 | (((x) & 0xff0000UL) >> 8) | \ 117 | (((x) & 0xff000000UL) >> 24)) 118 | #define PP_NTOHL(x) PP_HTONL(x) 119 | 120 | #endif /* BYTE_ORDER == BIG_ENDIAN */ 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif /* __LWIP_DEF_H__ */ 127 | 128 | -------------------------------------------------------------------------------- /include/lwip/dns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * lwip DNS resolver header file. 3 | 4 | * Author: Jim Pettinato 5 | * April 2007 6 | 7 | * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. The name of the author may not be used to endorse or promote 18 | * products derived from this software without specific prior 19 | * written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef __LWIP_DNS_H__ 35 | #define __LWIP_DNS_H__ 36 | 37 | #include "lwip/opt.h" 38 | 39 | #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** DNS timer period */ 46 | #define DNS_TMR_INTERVAL 1000 47 | 48 | /** DNS field TYPE used for "Resource Records" */ 49 | #define DNS_RRTYPE_A 1 /* a host address */ 50 | #define DNS_RRTYPE_NS 2 /* an authoritative name server */ 51 | #define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ 52 | #define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ 53 | #define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ 54 | #define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ 55 | #define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ 56 | #define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ 57 | #define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ 58 | #define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ 59 | #define DNS_RRTYPE_WKS 11 /* a well known service description */ 60 | #define DNS_RRTYPE_PTR 12 /* a domain name pointer */ 61 | #define DNS_RRTYPE_HINFO 13 /* host information */ 62 | #define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ 63 | #define DNS_RRTYPE_MX 15 /* mail exchange */ 64 | #define DNS_RRTYPE_TXT 16 /* text strings */ 65 | 66 | /** DNS field CLASS used for "Resource Records" */ 67 | #define DNS_RRCLASS_IN 1 /* the Internet */ 68 | #define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ 69 | #define DNS_RRCLASS_CH 3 /* the CHAOS class */ 70 | #define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ 71 | #define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ 72 | 73 | /* The size used for the next line is rather a hack, but it prevents including socket.h in all files 74 | that include memp.h, and that would possibly break portability (since socket.h defines some types 75 | and constants possibly already define by the OS). 76 | Calculation rule: 77 | sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */ 78 | #define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1) 79 | 80 | #if DNS_LOCAL_HOSTLIST 81 | /** struct used for local host-list */ 82 | struct local_hostlist_entry { 83 | /** static hostname */ 84 | const char *name; 85 | /** static host address in network byteorder */ 86 | ip_addr_t addr; 87 | struct local_hostlist_entry *next; 88 | }; 89 | #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC 90 | #ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN 91 | #define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH 92 | #endif 93 | #define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) 94 | #endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ 95 | #endif /* DNS_LOCAL_HOSTLIST */ 96 | 97 | /** Callback which is invoked when a hostname is found. 98 | * A function of this type must be implemented by the application using the DNS resolver. 99 | * @param name pointer to the name that was looked up. 100 | * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, 101 | * or NULL if the name could not be found (or on any other error). 102 | * @param callback_arg a user-specified callback argument passed to dns_gethostbyname 103 | */ 104 | typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); 105 | 106 | void dns_init(void); 107 | void dns_tmr(void); 108 | void dns_setserver(u8_t numdns, ip_addr_t *dnsserver); 109 | ip_addr_t dns_getserver(u8_t numdns); 110 | err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, 111 | dns_found_callback found, void *callback_arg); 112 | 113 | #if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC 114 | int dns_local_removehost(const char *hostname, const ip_addr_t *addr); 115 | err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); 116 | #endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* LWIP_DNS */ 123 | 124 | #endif /* __LWIP_DNS_H__ */ 125 | -------------------------------------------------------------------------------- /include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ERR_H__ 33 | #define __LWIP_ERR_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** Define LWIP_ERR_T in cc.h if you want to use 43 | * a different type for your platform (must be signed). */ 44 | #ifdef LWIP_ERR_T 45 | typedef LWIP_ERR_T err_t; 46 | #else /* LWIP_ERR_T */ 47 | typedef s8_t err_t; 48 | #endif /* LWIP_ERR_T*/ 49 | 50 | /* Definitions for error constants. */ 51 | 52 | #define ERR_OK 0 /* No error, everything OK. */ 53 | #define ERR_MEM -1 /* Out of memory error. */ 54 | #define ERR_BUF -2 /* Buffer error. */ 55 | #define ERR_TIMEOUT -3 /* Timeout. */ 56 | #define ERR_RTE -4 /* Routing problem. */ 57 | #define ERR_INPROGRESS -5 /* Operation in progress */ 58 | #define ERR_VAL -6 /* Illegal value. */ 59 | #define ERR_WOULDBLOCK -7 /* Operation would block. */ 60 | 61 | #define ERR_IS_FATAL(e) ((e) < ERR_WOULDBLOCK) 62 | 63 | #define ERR_ABRT -8 /* Connection aborted. */ 64 | #define ERR_RST -9 /* Connection reset. */ 65 | #define ERR_CLSD -10 /* Connection closed. */ 66 | #define ERR_CONN -11 /* Not connected. */ 67 | 68 | #define ERR_ARG -12 /* Illegal argument. */ 69 | 70 | #define ERR_USE -13 /* Address in use. */ 71 | 72 | #define ERR_IF -14 /* Low-level netif error */ 73 | #define ERR_ISCONN -15 /* Already connected. */ 74 | 75 | 76 | #ifdef LWIP_DEBUG 77 | #define lwip_strerr(x) "" 78 | #else 79 | #define lwip_strerr(x) "" 80 | #endif /* LWIP_DEBUG */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* __LWIP_ERR_H__ */ 87 | -------------------------------------------------------------------------------- /include/lwip/icmp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-ger/esp-open-lwip/5157a11da89c2ae8aeca0653c5a44fed7377fde8/include/lwip/icmp.h -------------------------------------------------------------------------------- /include/lwip/igmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 CITEL Technologies Ltd. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is a contribution to the lwIP TCP/IP stack. 30 | * The Swedish Institute of Computer Science and Adam Dunkels 31 | * are specifically granted permission to redistribute this 32 | * source code. 33 | */ 34 | 35 | #ifndef __LWIP_IGMP_H__ 36 | #define __LWIP_IGMP_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/ip_addr.h" 40 | #include "lwip/netif.h" 41 | #include "lwip/pbuf.h" 42 | 43 | #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | 50 | /* IGMP timer */ 51 | #define IGMP_TMR_INTERVAL 100 /* Milliseconds */ 52 | #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) 53 | #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) 54 | 55 | /* MAC Filter Actions, these are passed to a netif's 56 | * igmp_mac_filter callback function. */ 57 | #define IGMP_DEL_MAC_FILTER 0 58 | #define IGMP_ADD_MAC_FILTER 1 59 | 60 | 61 | /** 62 | * igmp group structure - there is 63 | * a list of groups for each interface 64 | * these should really be linked from the interface, but 65 | * if we keep them separate we will not affect the lwip original code 66 | * too much 67 | * 68 | * There will be a group for the all systems group address but this 69 | * will not run the state machine as it is used to kick off reports 70 | * from all the other groups 71 | */ 72 | struct igmp_group { 73 | /** next link */ 74 | struct igmp_group *next; 75 | /** interface on which the group is active */ 76 | struct netif *netif; 77 | /** multicast address */ 78 | ip_addr_t group_address; 79 | /** signifies we were the last person to report */ 80 | u8_t last_reporter_flag; 81 | /** current state of the group */ 82 | u8_t group_state; 83 | /** timer for reporting, negative is OFF */ 84 | u16_t timer; 85 | /** counter of simultaneous uses */ 86 | u8_t use; 87 | }; 88 | 89 | /* Prototypes */ 90 | void igmp_init(void)ICACHE_FLASH_ATTR; 91 | err_t igmp_start(struct netif *netif)ICACHE_FLASH_ATTR; 92 | err_t igmp_stop(struct netif *netif)ICACHE_FLASH_ATTR; 93 | void igmp_report_groups(struct netif *netif)ICACHE_FLASH_ATTR; 94 | struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr)ICACHE_FLASH_ATTR; 95 | void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)ICACHE_FLASH_ATTR; 96 | err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR; 97 | err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR; 98 | void igmp_tmr(void)ICACHE_FLASH_ATTR; 99 | #define LWIP_RAND() r_rand() 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* LWIP_IGMP */ 105 | 106 | #endif /* __LWIP_IGMP_H__ */ 107 | -------------------------------------------------------------------------------- /include/lwip/inet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INET_H__ 33 | #define __LWIP_INET_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/def.h" 37 | #include "lwip/ip_addr.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** For compatibility with BSD code */ 44 | struct in_addr { 45 | u32_t s_addr; 46 | }; 47 | 48 | /** 255.255.255.255 */ 49 | #define INADDR_NONE IPADDR_NONE 50 | /** 127.0.0.1 */ 51 | #define INADDR_LOOPBACK IPADDR_LOOPBACK 52 | /** 0.0.0.0 */ 53 | #define INADDR_ANY IPADDR_ANY 54 | /** 255.255.255.255 */ 55 | #define INADDR_BROADCAST IPADDR_BROADCAST 56 | 57 | /* Definitions of the bits in an Internet address integer. 58 | 59 | On subnets, host and network parts are found according to 60 | the subnet mask, not these masks. */ 61 | #define IN_CLASSA(a) IP_CLASSA(a) 62 | #define IN_CLASSA_NET IP_CLASSA_NET 63 | #define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT 64 | #define IN_CLASSA_HOST IP_CLASSA_HOST 65 | #define IN_CLASSA_MAX IP_CLASSA_MAX 66 | 67 | #define IN_CLASSB(b) IP_CLASSB(b) 68 | #define IN_CLASSB_NET IP_CLASSB_NET 69 | #define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT 70 | #define IN_CLASSB_HOST IP_CLASSB_HOST 71 | #define IN_CLASSB_MAX IP_CLASSB_MAX 72 | 73 | #define IN_CLASSC(c) IP_CLASSC(c) 74 | #define IN_CLASSC_NET IP_CLASSC_NET 75 | #define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT 76 | #define IN_CLASSC_HOST IP_CLASSC_HOST 77 | #define IN_CLASSC_MAX IP_CLASSC_MAX 78 | 79 | #define IN_CLASSD(d) IP_CLASSD(d) 80 | #define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ 81 | #define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ 82 | #define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ 83 | #define IN_CLASSD_MAX IP_CLASSD_MAX 84 | 85 | #define IN_MULTICAST(a) IP_MULTICAST(a) 86 | 87 | #define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) 88 | #define IN_BADCLASS(a) IP_BADCLASS(a) 89 | 90 | #define IN_LOOPBACKNET IP_LOOPBACKNET 91 | 92 | #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) 93 | #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) 94 | /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */ 95 | #define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr)) 96 | 97 | /* directly map this to the lwip internal functions */ 98 | #define inet_addr(cp) ipaddr_addr(cp) 99 | #define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr) 100 | #define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr)) 101 | #define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen) 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | #endif /* __LWIP_INET_H__ */ 108 | -------------------------------------------------------------------------------- /include/lwip/inet_chksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INET_CHKSUM_H__ 33 | #define __LWIP_INET_CHKSUM_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #include "lwip/pbuf.h" 38 | #include "lwip/ip_addr.h" 39 | 40 | /** Swap the bytes in an u16_t: much like htons() for little-endian */ 41 | #ifndef SWAP_BYTES_IN_WORD 42 | #if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) 43 | /* little endian and PLATFORM_BYTESWAP defined */ 44 | #define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) 45 | #else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ 46 | /* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ 47 | #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) 48 | #endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ 49 | #endif /* SWAP_BYTES_IN_WORD */ 50 | 51 | /** Split an u32_t in two u16_ts and add them up */ 52 | #ifndef FOLD_U32T 53 | #define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) 54 | #endif 55 | 56 | #if LWIP_CHECKSUM_ON_COPY 57 | /** Function-like macro: same as MEMCPY but returns the checksum of copied data 58 | as u16_t */ 59 | #ifndef LWIP_CHKSUM_COPY 60 | #define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) 61 | #ifndef LWIP_CHKSUM_COPY_ALGORITHM 62 | #define LWIP_CHKSUM_COPY_ALGORITHM 1 63 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 64 | #endif /* LWIP_CHKSUM_COPY */ 65 | #else /* LWIP_CHECKSUM_ON_COPY */ 66 | #define LWIP_CHKSUM_COPY_ALGORITHM 0 67 | #endif /* LWIP_CHECKSUM_ON_COPY */ 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | u16_t inet_chksum(void *dataptr, u16_t len)ICACHE_FLASH_ATTR; 74 | u16_t inet_chksum_pbuf(struct pbuf *p)ICACHE_FLASH_ATTR; 75 | u16_t inet_chksum_pseudo(struct pbuf *p, 76 | ip_addr_t *src, ip_addr_t *dest, 77 | u8_t proto, u16_t proto_len)ICACHE_FLASH_ATTR; 78 | u16_t inet_chksum_pseudo_partial(struct pbuf *p, 79 | ip_addr_t *src, ip_addr_t *dest, 80 | u8_t proto, u16_t proto_len, u16_t chksum_len)ICACHE_FLASH_ATTR; 81 | #if LWIP_CHKSUM_COPY_ALGORITHM 82 | u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len)ICACHE_FLASH_ATTR; 83 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* __LWIP_INET_H__ */ 90 | 91 | -------------------------------------------------------------------------------- /include/lwip/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INIT_H__ 33 | #define __LWIP_INIT_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** X.x.x: Major version of the stack */ 42 | #define LWIP_VERSION_MAJOR 1U 43 | /** x.X.x: Minor version of the stack */ 44 | #define LWIP_VERSION_MINOR 4U 45 | /** x.x.X: Revision of the stack */ 46 | #define LWIP_VERSION_REVISION 0U 47 | /** For release candidates, this is set to 1..254 48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 49 | * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 50 | #define LWIP_VERSION_RC 2U 51 | 52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 53 | #define LWIP_RC_RELEASE 255U 54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ 55 | #define LWIP_RC_DEVELOPMENT 0U 56 | 57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 60 | 61 | /** Provides the version of the stack */ 62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ 63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) 64 | 65 | /* Modules initialization */ 66 | void lwip_init(void) ICACHE_FLASH_ATTR; 67 | //void lwip_init(void); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __LWIP_INIT_H__ */ 74 | -------------------------------------------------------------------------------- /include/lwip/ip_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Jani Monoses 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_IP_FRAG_H__ 34 | #define __LWIP_IP_FRAG_H__ 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/netif.h" 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/ip.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if IP_REASSEMBLY 48 | /* The IP reassembly timer interval in milliseconds. */ 49 | #define IP_TMR_INTERVAL 1000 50 | 51 | /* IP reassembly helper struct. 52 | * This is exported because memp needs to know the size. 53 | */ 54 | struct ip_reassdata { 55 | struct ip_reassdata *next; 56 | struct pbuf *p; 57 | struct ip_hdr iphdr; 58 | u16_t datagram_len; 59 | u8_t flags; 60 | u8_t timer; 61 | }; 62 | 63 | void ip_reass_init(void)ICACHE_FLASH_ATTR; 64 | void ip_reass_tmr(void)ICACHE_FLASH_ATTR; 65 | struct pbuf * ip_reass(struct pbuf *p)ICACHE_FLASH_ATTR; 66 | #endif /* IP_REASSEMBLY */ 67 | 68 | #if IP_FRAG 69 | #if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 70 | /** A custom pbuf that holds a reference to another pbuf, which is freed 71 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 72 | * that points into the original pbuf. */ 73 | struct pbuf_custom_ref { 74 | /** 'base class' */ 75 | struct pbuf_custom pc; 76 | /** pointer to the original pbuf that is referenced */ 77 | struct pbuf *original; 78 | }; 79 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 80 | 81 | err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)ICACHE_FLASH_ATTR; 82 | #endif /* IP_FRAG */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __LWIP_IP_FRAG_H__ */ 89 | -------------------------------------------------------------------------------- /include/lwip/ip_route.h: -------------------------------------------------------------------------------- 1 | #ifndef __LWIP_IP_ROUTE_H__ 2 | #define __LWIP_IP_ROUTE_H__ 3 | 4 | #include "lwip/opt.h" 5 | #include "lwip/ip_addr.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define MAX_ROUTES 10 12 | 13 | struct route_entry { 14 | ip_addr_t ip; 15 | ip_addr_t mask; 16 | ip_addr_t gw; 17 | }; 18 | 19 | extern struct route_entry ip_rt_table[MAX_ROUTES]; 20 | extern int ip_route_max; 21 | 22 | /* Add a static route, true on success */ 23 | bool ip_add_route(ip_addr_t ip, ip_addr_t mask, ip_addr_t gw); 24 | 25 | /* Remove a static route, true on success */ 26 | bool ip_rm_route(ip_addr_t ip, ip_addr_t mask); 27 | 28 | /* Finds a route entry for an address, NULL if none */ 29 | struct route_entry *ip_find_route(ip_addr_t ip); 30 | 31 | /* Delete all static routes */ 32 | void ip_delete_routes(void); 33 | 34 | /* Returns the n_th entry of the routing table, true on success */ 35 | bool ip_get_route(uint32_t no, ip_addr_t *ip, ip_addr_t *mask, ip_addr_t *gw); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __LWIP_IP_ROUTE_H__ */ 42 | -------------------------------------------------------------------------------- /include/lwip/lwip_napt.h: -------------------------------------------------------------------------------- 1 | #ifndef __LWIP_NAPT_H__ 2 | #define __LWIP_NAPT_H__ 3 | 4 | #include "lwip/opt.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #if IP_FORWARD 11 | #if IP_NAPT 12 | 13 | /* Default size of the tables used for NAPT */ 14 | #define IP_NAPT_MAX 512 15 | #define IP_PORTMAP_MAX 32 16 | 17 | /* Timeouts in sec for the various protocol types */ 18 | #define IP_NAPT_TIMEOUT_MS_TCP (30*60*1000) 19 | #define IP_NAPT_TIMEOUT_MS_TCP_DISCON (20*1000) 20 | #define IP_NAPT_TIMEOUT_MS_UDP (2*1000) 21 | #define IP_NAPT_TIMEOUT_MS_ICMP (2*1000) 22 | 23 | #define IP_NAPT_PORT_RANGE_START 49152 24 | #define IP_NAPT_PORT_RANGE_END 61439 25 | 26 | struct napt_table { 27 | u32_t last; 28 | u32_t src; 29 | u32_t dest; 30 | u16_t sport; 31 | u16_t dport; 32 | u16_t mport; 33 | u8_t proto; 34 | u8_t fin1 : 1; 35 | u8_t fin2 : 1; 36 | u8_t finack1 : 1; 37 | u8_t finack2 : 1; 38 | u8_t synack : 1; 39 | u8_t rst : 1; 40 | u16_t next, prev; 41 | }; 42 | 43 | struct portmap_table { 44 | u32_t maddr; 45 | u32_t daddr; 46 | u16_t mport; 47 | u16_t dport; 48 | u8_t proto; 49 | u8 valid; 50 | }; 51 | 52 | extern struct portmap_table *ip_portmap_table; 53 | 54 | /** 55 | * Allocates and initializes the NAPT tables. 56 | * 57 | * @param max_nat max number of enties in the NAPT table (use IP_NAPT_MAX if in doubt) 58 | * @param max_portmap max number of enties in the NAPT table (use IP_PORTMAP_MAX if in doubt) 59 | */ 60 | void 61 | ip_napt_init(uint16_t max_nat, uint8_t max_portmap); 62 | 63 | 64 | /** 65 | * Enable/Disable NAPT for a specified interface. 66 | * 67 | * @param addr ip address of the interface 68 | * @param enable non-zero to enable NAPT, or 0 to disable. 69 | */ 70 | void 71 | ip_napt_enable(u32_t addr, int enable); 72 | 73 | 74 | /** 75 | * Enable/Disable NAPT for a specified interface. 76 | * 77 | * @param netif number of the interface 78 | * @param enable non-zero to enable NAPT, or 0 to disable. 79 | */ 80 | void 81 | ip_napt_enable_no(u8_t number, int enable); 82 | 83 | 84 | /** 85 | * Register port mapping on the external interface to internal interface. 86 | * When the same port mapping is registered again, the old mapping is overwritten. 87 | * In this implementation, only 1 unique port mapping can be defined for each target address/port. 88 | * 89 | * @param proto target protocol 90 | * @param maddr ip address of the external interface 91 | * @param mport mapped port on the external interface, in host byte order. 92 | * @param daddr destination ip address 93 | * @param dport destination port, in host byte order. 94 | */ 95 | u8_t 96 | ip_portmap_add(u8_t proto, u32_t maddr, u16_t mport, u32_t daddr, u16_t dport); 97 | 98 | 99 | /** 100 | * Unregister port mapping on the external interface to internal interface. 101 | * 102 | * @param proto target protocol 103 | * @param maddr ip address of the external interface 104 | */ 105 | u8_t 106 | ip_portmap_remove(u8_t proto, u16_t mport); 107 | 108 | 109 | /** 110 | * Sets the NAPT timeout for TCP connections. 111 | * 112 | * @param secs timeout in secs 113 | */ 114 | void 115 | ip_napt_set_tcp_timeout(u32_t secs); 116 | 117 | 118 | /** 119 | * Sets the NAPT timeout for UDP 'connections'. 120 | * 121 | * @param secs timeout in secs 122 | */ 123 | void 124 | ip_napt_set_udp_timeout(u32_t secs); 125 | 126 | #endif /* IP_NAPT */ 127 | #endif /* IP_FORWARD */ 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* __LWIP_NAPT_H__ */ 134 | -------------------------------------------------------------------------------- /include/lwip/mdns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * lwip MDNS resolver header file. 3 | * 4 | * Created on: Jul 29, 2010 5 | * Author: Daniel Toma 6 | 7 | 8 | * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. 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 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote 19 | * products derived from this software without specific prior 20 | * written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 23 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 26 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 28 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __LWIP_DNS_H__ 36 | #define __LWIP_DNS_H__ 37 | 38 | #include "lwip/opt.h" 39 | 40 | #if LWIP_MDNS /* don't build if not configured for use in lwipopts.h */ 41 | 42 | /** DNS timer period */ 43 | #define DNS_TMR_INTERVAL 1000 44 | 45 | /** mDNS Address offset flag*/ 46 | #define DNS_OFFSET_FLAG 0xC0 /* the offset flag in the DNS message */ 47 | #define DNS_DEFAULT_OFFSET 0x0C /* the offset is set at the beginning of the DNS message */ 48 | 49 | #define DNS_IP_ADDR_LEN 4 50 | 51 | 52 | /** DNS field TYPE used for "Resource Records" */ 53 | #define DNS_RRTYPE_A 1 /* a host address */ 54 | #define DNS_RRTYPE_NS 2 /* an authoritative name server */ 55 | #define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ 56 | #define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ 57 | #define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ 58 | #define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ 59 | #define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ 60 | #define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ 61 | #define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ 62 | #define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ 63 | #define DNS_RRTYPE_WKS 11 /* a well known service description */ 64 | #define DNS_RRTYPE_PTR 12 /* a domain name pointer */ 65 | #define DNS_RRTYPE_HINFO 13 /* host information */ 66 | #define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ 67 | #define DNS_RRTYPE_MX 15 /* mail exchange */ 68 | #define DNS_RRTYPE_TXT 16 /* text strings */ 69 | #define DNS_RRTYPE_SRV 33 /* Service record */ 70 | #define DNS_RRTYPE_OPT 41 /* EDNS0 OPT record */ 71 | #define DNS_RRTYPE_TSIG 250 /* Transaction Signature */ 72 | #define DNS_RRTYPE_ANY 255 /*Not a DNS type, but a DNS query type, meaning "all types"*/ 73 | 74 | /* DNS field CLASS used for "Resource Records" */ 75 | #define DNS_RRCLASS_IN 1 /* the Internet */ 76 | #define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ 77 | #define DNS_RRCLASS_CH 3 /* the CHAOS class */ 78 | #define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ 79 | #define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ 80 | #define DNS_RRCLASS_FLUSH_IN 0x8001/* Flush bit and Internet*/ 81 | 82 | /** Callback which is invoked when a hostname is found. 83 | * A function of this type must be implemented by the application using the DNS resolver. 84 | * @param name pointer to the name that was looked up. 85 | * @param ipaddr pointer to a struct ip_addr containing the IP address of the hostname, 86 | * or NULL if the name could not be found (or on any other error). 87 | * @param callback_arg a user-specified callback argument passed to dns_gethostbyname 88 | */ 89 | #ifndef _MDNS_INFO 90 | #define _MDNS_INFO 91 | struct mdns_info { 92 | char *host_name; 93 | char *server_name; 94 | uint16 server_port; 95 | unsigned long ipAddr; 96 | char *txt_data[10]; 97 | }; 98 | #endif 99 | //void mdns_enable(void); 100 | //void mdns_disable(void); 101 | //void mdns_init(struct mdns_info *info); 102 | //void mdns_close(void); 103 | //char* mdns_get_hostname(void); 104 | //void mdns_set_hostname(char *name); 105 | //void mdns_set_servername(const char *name); 106 | //char* mdns_get_servername(void); 107 | //void mdns_server_unregister(void); 108 | //void mdns_server_register(void) ; 109 | //void mdns_tmr(void); 110 | //void Delay(unsigned long ulSeconds); 111 | 112 | #endif /* LWIP_DNS */ 113 | 114 | #endif /* __LWIP_DNS_H__ */ 115 | -------------------------------------------------------------------------------- /include/lwip/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_MEM_H__ 33 | #define __LWIP_MEM_H__ 34 | 35 | #include "lwip/opt.h" 36 | //#include "mem_manager.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | #if MEM_LIBC_MALLOC 43 | 44 | #include /* for size_t */ 45 | 46 | typedef size_t mem_size_t; 47 | 48 | /* aliases for C library malloc() */ 49 | #define mem_init() 50 | /* in case C library malloc() needs extra protection, 51 | * allow these defines to be overridden. 52 | */ 53 | #ifndef MEMLEAK_DEBUG 54 | #ifndef mem_free 55 | #define mem_free(s) vPortFree(s, "", __LINE__) 56 | #endif 57 | #ifndef mem_malloc 58 | #define mem_malloc(s) pvPortMalloc(s, "", __LINE__,false) 59 | #endif 60 | #ifndef mem_calloc 61 | #define mem_calloc(l, s) ({void* ptr = (void*)pvPortMalloc((l) * (s), "", __LINE__,true);if(ptr){os_memset(ptr,0x0,(l) * (s));} ptr;})// pvPortCalloc(l, s, "", __LINE__) 62 | #endif 63 | #ifndef mem_realloc 64 | #define mem_realloc(p, s) pvPortRealloc(p, s, "", __LINE__) 65 | #endif 66 | #ifndef mem_zalloc 67 | #define mem_zalloc(s) mem_calloc(1,s) // pvPortZalloc(s, "", __LINE__) 68 | #endif 69 | #else 70 | #ifndef mem_free 71 | #define mem_free(s) \ 72 | do{\ 73 | const char *file = mem_debug_file;\ 74 | vPortFree(s, file, __LINE__);\ 75 | }while(0) 76 | #endif 77 | 78 | #ifndef mem_malloc 79 | #define mem_malloc(s) (const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__,false);}) 80 | #endif 81 | #ifndef mem_calloc 82 | #define mem_calloc(l, s) ({const char *file = mem_debug_file; pvPortCalloc(l, s, file, __LINE__);}) 83 | #endif 84 | #ifndef mem_realloc 85 | #define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);}) 86 | #endif 87 | #ifndef mem_zalloc 88 | #define mem_zalloc(s) ({const char *file = mem_debug_file; pvPortZalloc(s, file, __LINE__);}) 89 | #endif 90 | 91 | #endif 92 | 93 | #ifndef os_malloc 94 | #ifndef MEMLEAK_DEBUG 95 | #define os_malloc(s) pvPortMalloc(s, "", __LINE__,true) 96 | #else 97 | #define os_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__,true);}) 98 | #endif 99 | #endif 100 | #ifndef os_realloc 101 | #define os_realloc(p, s) mem_realloc((p), (s)) 102 | #endif 103 | #ifndef os_zalloc 104 | #define os_zalloc(s) mem_zalloc((s)) 105 | #endif 106 | #ifndef os_free 107 | #define os_free(p) mem_free((p)) 108 | #endif 109 | 110 | /* Since there is no C library allocation function to shrink memory without 111 | moving it, define this to nothing. */ 112 | #ifndef mem_trim 113 | #define mem_trim(mem, size) (mem) 114 | #endif 115 | #else /* MEM_LIBC_MALLOC */ 116 | 117 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of 118 | * 65535 leaves some room for alignment... 119 | */ 120 | #if MEM_SIZE > 64000l 121 | typedef u32_t mem_size_t; 122 | #define MEM_SIZE_F U32_F 123 | #else 124 | typedef u16_t mem_size_t; 125 | #define MEM_SIZE_F U16_F 126 | #endif /* MEM_SIZE > 64000 */ 127 | 128 | #if MEM_USE_POOLS 129 | /** mem_init is not used when using pools instead of a heap */ 130 | #define mem_init() 131 | /** mem_trim is not used when using pools instead of a heap: 132 | we can't free part of a pool element and don't want to copy the rest */ 133 | #define mem_trim(mem, size) (mem) 134 | #else /* MEM_USE_POOLS */ 135 | /* lwIP alternative malloc */ 136 | void mem_init(void)ICACHE_FLASH_ATTR; 137 | void *mem_trim(void *mem, mem_size_t size)ICACHE_FLASH_ATTR; 138 | #endif /* MEM_USE_POOLS */ 139 | void *mem_malloc(mem_size_t size)ICACHE_FLASH_ATTR; 140 | void *mem_calloc(mem_size_t count, mem_size_t size)ICACHE_FLASH_ATTR; 141 | void mem_free(void *mem)ICACHE_FLASH_ATTR; 142 | #endif /* MEM_LIBC_MALLOC */ 143 | 144 | /** Calculate memory size for an aligned buffer - returns the next highest 145 | * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and 146 | * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4). 147 | */ 148 | #ifndef LWIP_MEM_ALIGN_SIZE 149 | #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) 150 | #endif 151 | 152 | /** Calculate safe memory size for an aligned buffer when using an unaligned 153 | * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the 154 | * start (e.g. if buffer is u8_t[] and actual data will be u32_t*) 155 | */ 156 | #ifndef LWIP_MEM_ALIGN_BUFFER 157 | #define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1)) 158 | #endif 159 | 160 | /** Align a memory pointer to the alignment defined by MEM_ALIGNMENT 161 | * so that ADDR % MEM_ALIGNMENT == 0 162 | */ 163 | #ifndef LWIP_MEM_ALIGN 164 | #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) 165 | #endif 166 | 167 | #ifdef __cplusplus 168 | } 169 | #endif 170 | 171 | #endif /* __LWIP_MEM_H__ */ 172 | -------------------------------------------------------------------------------- /include/lwip/memp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_MEMP_H__ 34 | #define __LWIP_MEMP_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ 43 | typedef enum { 44 | #define LWIP_MEMPOOL(name,num,size,desc, attr) MEMP_##name, 45 | #include "lwip/memp_std.h" 46 | MEMP_MAX 47 | } memp_t; 48 | 49 | #if MEM_USE_POOLS 50 | /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ 51 | typedef enum { 52 | /* Get the first (via: 53 | MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ 54 | MEMP_POOL_HELPER_FIRST = ((u8_t) 55 | #define LWIP_MEMPOOL(name,num,size,desc) 56 | #define LWIP_MALLOC_MEMPOOL_START 1 57 | #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 58 | #define LWIP_MALLOC_MEMPOOL_END 59 | #include "lwip/memp_std.h" 60 | ) , 61 | /* Get the last (via: 62 | MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ 63 | MEMP_POOL_HELPER_LAST = ((u8_t) 64 | #define LWIP_MEMPOOL(name,num,size,desc) 65 | #define LWIP_MALLOC_MEMPOOL_START 66 | #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * 67 | #define LWIP_MALLOC_MEMPOOL_END 1 68 | #include "lwip/memp_std.h" 69 | ) 70 | } memp_pool_helper_t; 71 | 72 | /* The actual start and stop values are here (cast them over) 73 | We use this helper type and these defines so we can avoid using const memp_t values */ 74 | #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) 75 | #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) 76 | #endif /* MEM_USE_POOLS */ 77 | 78 | #if MEMP_MEM_MALLOC || MEM_USE_POOLS 79 | extern const u32_t memp_sizes[MEMP_MAX]; 80 | #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ 81 | 82 | #if MEMP_MEM_MALLOC 83 | 84 | #include "mem.h" 85 | 86 | #define memp_init() 87 | #define memp_malloc(type) mem_malloc(memp_sizes[type]) 88 | #define memp_free(type, mem) mem_free(mem) 89 | 90 | #else /* MEMP_MEM_MALLOC */ 91 | 92 | #if MEM_USE_POOLS 93 | /** This structure is used to save the pool one element came from. */ 94 | struct memp_malloc_helper 95 | { 96 | memp_t poolnr; 97 | }; 98 | #endif /* MEM_USE_POOLS */ 99 | 100 | void memp_init(void)ICACHE_FLASH_ATTR; 101 | 102 | #if MEMP_OVERFLOW_CHECK 103 | void *memp_malloc_fn(memp_t type, const char* file, const int line)ICACHE_FLASH_ATTR; 104 | #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) 105 | #else 106 | void *memp_malloc(memp_t type)ICACHE_FLASH_ATTR; 107 | #endif 108 | void memp_free(memp_t type, void *mem)ICACHE_FLASH_ATTR; 109 | 110 | #endif /* MEMP_MEM_MALLOC */ 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* __LWIP_MEMP_H__ */ 117 | -------------------------------------------------------------------------------- /include/lwip/memp_std.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SETUP: Make sure we define everything we will need. 3 | * 4 | * We have create three types of pools: 5 | * 1) MEMPOOL - standard pools 6 | * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c 7 | * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct 8 | * 9 | * If the include'r doesn't require any special treatment of each of the types 10 | * above, then will declare #2 & #3 to be just standard mempools. 11 | */ 12 | #ifndef LWIP_MALLOC_MEMPOOL 13 | /* This treats "malloc pools" just like any other pool. 14 | The pools are a little bigger to provide 'size' as the amount of user data. */ 15 | #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size, attr) 16 | #define LWIP_MALLOC_MEMPOOL_START 17 | #define LWIP_MALLOC_MEMPOOL_END 18 | #endif /* LWIP_MALLOC_MEMPOOL */ 19 | 20 | #ifndef LWIP_PBUF_MEMPOOL 21 | /* This treats "pbuf pools" just like any other pool. 22 | * Allocates buffers for a pbuf struct AND a payload size */ 23 | #define LWIP_PBUF_MEMPOOL(name, num, payload, desc, attr) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc, attr) 24 | #endif /* LWIP_PBUF_MEMPOOL */ 25 | 26 | 27 | /* 28 | * A list of internal pools used by LWIP. 29 | * 30 | * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description) 31 | * creates a pool name MEMP_pool_name. description is used in stats.c 32 | */ 33 | #if LWIP_RAW 34 | LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB", DMEM_ATTR) 35 | #endif /* LWIP_RAW */ 36 | 37 | #if LWIP_UDP 38 | LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB", DMEM_ATTR) 39 | #endif /* LWIP_UDP */ 40 | 41 | #if LWIP_TCP 42 | LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB", DMEM_ATTR) 43 | LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN", DMEM_ATTR) 44 | LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG", DMEM_ATTR) 45 | #endif /* LWIP_TCP */ 46 | 47 | #if IP_REASSEMBLY 48 | LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA", DMEM_ATTR) 49 | #endif /* IP_REASSEMBLY */ 50 | #if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 51 | LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF", DMEM_ATTR) 52 | #endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 53 | 54 | #if LWIP_NETCONN 55 | LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF") 56 | LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN") 57 | #endif /* LWIP_NETCONN */ 58 | 59 | #if NO_SYS==0 60 | LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API") 61 | #if !LWIP_TCPIP_CORE_LOCKING_INPUT 62 | LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT") 63 | #endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ 64 | #endif /* NO_SYS==0 */ 65 | 66 | #if ARP_QUEUEING 67 | LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE", DMEM_ATTR) 68 | #endif /* ARP_QUEUEING */ 69 | 70 | #if LWIP_IGMP 71 | LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP", DMEM_ATTR) 72 | #endif /* LWIP_IGMP */ 73 | 74 | #if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */ 75 | LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT", DMEM_ATTR) 76 | #endif /* LWIP_TIMERS */ 77 | 78 | #if LWIP_SNMP 79 | LWIP_MEMPOOL(SNMP_ROOTNODE, MEMP_NUM_SNMP_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE") 80 | LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_node), "SNMP_NODE") 81 | LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND") 82 | LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE") 83 | #endif /* LWIP_SNMP */ 84 | #if LWIP_DNS && LWIP_SOCKET 85 | LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB") 86 | #endif /* LWIP_DNS && LWIP_SOCKET */ 87 | #if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC 88 | LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST") 89 | #endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ 90 | #if PPP_SUPPORT && PPPOE_SUPPORT 91 | LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF") 92 | #endif /* PPP_SUPPORT && PPPOE_SUPPORT */ 93 | 94 | /* 95 | * A list of pools of pbuf's used by LWIP. 96 | * 97 | * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description) 98 | * creates a pool name MEMP_pool_name. description is used in stats.c 99 | * This allocates enough space for the pbuf struct and a payload. 100 | * (Example: pbuf_payload_size=0 allocates only size for the struct) 101 | */ 102 | LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM", DMEM_ATTR) 103 | 104 | /* XXX: need to align to 4 byte as memp strcut is 4-byte long. otherwise will crash */ 105 | #define LWIP_MEM_ALIGN4_SIZE(size) (((size) + 4 - 1) & ~(4-1)) 106 | 107 | LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, LWIP_MEM_ALIGN4_SIZE(PBUF_POOL_BUFSIZE), "PBUF_POOL", DMEM_ATTR) 108 | 109 | 110 | /* 111 | * Allow for user-defined pools; this must be explicitly set in lwipopts.h 112 | * since the default is to NOT look for lwippools.h 113 | */ 114 | #if MEMP_USE_CUSTOM_POOLS 115 | #include "lwippools.h" 116 | #endif /* MEMP_USE_CUSTOM_POOLS */ 117 | 118 | /* 119 | * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later 120 | * (#undef is ignored for something that is not defined) 121 | */ 122 | #undef LWIP_MEMPOOL 123 | #undef LWIP_MALLOC_MEMPOOL 124 | #undef LWIP_MALLOC_MEMPOOL_START 125 | #undef LWIP_MALLOC_MEMPOOL_END 126 | #undef LWIP_PBUF_MEMPOOL 127 | -------------------------------------------------------------------------------- /include/lwip/netbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_NETBUF_H__ 33 | #define __LWIP_NETBUF_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/pbuf.h" 37 | #include "lwip/ip_addr.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** This netbuf has dest-addr/port set */ 44 | #define NETBUF_FLAG_DESTADDR 0x01 45 | /** This netbuf includes a checksum */ 46 | #define NETBUF_FLAG_CHKSUM 0x02 47 | 48 | struct netbuf { 49 | struct pbuf *p, *ptr; 50 | ip_addr_t addr; 51 | u16_t port; 52 | #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY 53 | #if LWIP_CHECKSUM_ON_COPY 54 | u8_t flags; 55 | #endif /* LWIP_CHECKSUM_ON_COPY */ 56 | u16_t toport_chksum; 57 | #if LWIP_NETBUF_RECVINFO 58 | ip_addr_t toaddr; 59 | #endif /* LWIP_NETBUF_RECVINFO */ 60 | #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ 61 | }; 62 | 63 | /* Network buffer functions: */ 64 | struct netbuf * netbuf_new (void)ICACHE_FLASH_ATTR; 65 | void netbuf_delete (struct netbuf *buf)ICACHE_FLASH_ATTR; 66 | void * netbuf_alloc (struct netbuf *buf, u16_t size)ICACHE_FLASH_ATTR; 67 | void netbuf_free (struct netbuf *buf)ICACHE_FLASH_ATTR; 68 | err_t netbuf_ref (struct netbuf *buf, 69 | const void *dataptr, u16_t size)ICACHE_FLASH_ATTR; 70 | void netbuf_chain (struct netbuf *head, 71 | struct netbuf *tail)ICACHE_FLASH_ATTR; 72 | 73 | err_t netbuf_data (struct netbuf *buf, 74 | void **dataptr, u16_t *len)ICACHE_FLASH_ATTR; 75 | s8_t netbuf_next (struct netbuf *buf)ICACHE_FLASH_ATTR; 76 | void netbuf_first (struct netbuf *buf)ICACHE_FLASH_ATTR; 77 | 78 | 79 | #define netbuf_copy_partial(buf, dataptr, len, offset) \ 80 | pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) 81 | #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) 82 | #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) 83 | #define netbuf_len(buf) ((buf)->p->tot_len) 84 | #define netbuf_fromaddr(buf) (&((buf)->addr)) 85 | #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr) 86 | #define netbuf_fromport(buf) ((buf)->port) 87 | #if LWIP_NETBUF_RECVINFO 88 | #define netbuf_destaddr(buf) (&((buf)->toaddr)) 89 | #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr) 90 | #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) 91 | #endif /* LWIP_NETBUF_RECVINFO */ 92 | #if LWIP_CHECKSUM_ON_COPY 93 | #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ 94 | (buf)->toport_chksum = chksum; } while(0) 95 | #endif /* LWIP_CHECKSUM_ON_COPY */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __LWIP_NETBUF_H__ */ 102 | -------------------------------------------------------------------------------- /include/lwip/netdb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Redistribution and use in source and binary forms, with or without modification, 3 | * are permitted provided that the following conditions are met: 4 | * 5 | * 1. Redistributions of source code must retain the above copyright notice, 6 | * this list of conditions and the following disclaimer. 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, 8 | * this list of conditions and the following disclaimer in the documentation 9 | * and/or other materials provided with the distribution. 10 | * 3. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | * OF SUCH DAMAGE. 23 | * 24 | * This file is part of the lwIP TCP/IP stack. 25 | * 26 | * Author: Simon Goldschmidt 27 | * 28 | */ 29 | #ifndef __LWIP_NETDB_H__ 30 | #define __LWIP_NETDB_H__ 31 | 32 | #include "lwip/opt.h" 33 | 34 | #if LWIP_DNS && LWIP_SOCKET 35 | 36 | #include /* for size_t */ 37 | 38 | #include "lwip/inet.h" 39 | #include "lwip/sockets.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* some rarely used options */ 46 | #ifndef LWIP_DNS_API_DECLARE_H_ERRNO 47 | #define LWIP_DNS_API_DECLARE_H_ERRNO 1 48 | #endif 49 | 50 | #ifndef LWIP_DNS_API_DEFINE_ERRORS 51 | #define LWIP_DNS_API_DEFINE_ERRORS 1 52 | #endif 53 | 54 | #ifndef LWIP_DNS_API_DECLARE_STRUCTS 55 | #define LWIP_DNS_API_DECLARE_STRUCTS 1 56 | #endif 57 | 58 | #if LWIP_DNS_API_DEFINE_ERRORS 59 | /** Errors used by the DNS API functions, h_errno can be one of them */ 60 | #define EAI_NONAME 200 61 | #define EAI_SERVICE 201 62 | #define EAI_FAIL 202 63 | #define EAI_MEMORY 203 64 | 65 | #define HOST_NOT_FOUND 210 66 | #define NO_DATA 211 67 | #define NO_RECOVERY 212 68 | #define TRY_AGAIN 213 69 | #endif /* LWIP_DNS_API_DEFINE_ERRORS */ 70 | 71 | #if LWIP_DNS_API_DECLARE_STRUCTS 72 | struct hostent { 73 | char *h_name; /* Official name of the host. */ 74 | char **h_aliases; /* A pointer to an array of pointers to alternative host names, 75 | terminated by a null pointer. */ 76 | int h_addrtype; /* Address type. */ 77 | int h_length; /* The length, in bytes, of the address. */ 78 | char **h_addr_list; /* A pointer to an array of pointers to network addresses (in 79 | network byte order) for the host, terminated by a null pointer. */ 80 | #define h_addr h_addr_list[0] /* for backward compatibility */ 81 | }; 82 | 83 | struct addrinfo { 84 | int ai_flags; /* Input flags. */ 85 | int ai_family; /* Address family of socket. */ 86 | int ai_socktype; /* Socket type. */ 87 | int ai_protocol; /* Protocol of socket. */ 88 | socklen_t ai_addrlen; /* Length of socket address. */ 89 | struct sockaddr *ai_addr; /* Socket address of socket. */ 90 | char *ai_canonname; /* Canonical name of service location. */ 91 | struct addrinfo *ai_next; /* Pointer to next in list. */ 92 | }; 93 | #endif /* LWIP_DNS_API_DECLARE_STRUCTS */ 94 | 95 | #if LWIP_DNS_API_DECLARE_H_ERRNO 96 | /* application accessable error code set by the DNS API functions */ 97 | extern int h_errno; 98 | #endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/ 99 | 100 | struct hostent *lwip_gethostbyname(const char *name); 101 | int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, 102 | size_t buflen, struct hostent **result, int *h_errnop); 103 | void lwip_freeaddrinfo(struct addrinfo *ai); 104 | int lwip_getaddrinfo(const char *nodename, 105 | const char *servname, 106 | const struct addrinfo *hints, 107 | struct addrinfo **res); 108 | 109 | #if LWIP_COMPAT_SOCKETS 110 | #define gethostbyname(name) lwip_gethostbyname(name) 111 | #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \ 112 | lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop) 113 | #define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo) 114 | #define getaddrinfo(nodname, servname, hints, res) \ 115 | lwip_getaddrinfo(nodname, servname, hints, res) 116 | #endif /* LWIP_COMPAT_SOCKETS */ 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* LWIP_DNS && LWIP_SOCKET */ 123 | 124 | #endif /* __LWIP_NETDB_H__ */ 125 | -------------------------------------------------------------------------------- /include/lwip/netif.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-ger/esp-open-lwip/5157a11da89c2ae8aeca0653c5a44fed7377fde8/include/lwip/netif.h -------------------------------------------------------------------------------- /include/lwip/netifapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Redistribution and use in source and binary forms, with or without modification, 3 | * are permitted provided that the following conditions are met: 4 | * 5 | * 1. Redistributions of source code must retain the above copyright notice, 6 | * this list of conditions and the following disclaimer. 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, 8 | * this list of conditions and the following disclaimer in the documentation 9 | * and/or other materials provided with the distribution. 10 | * 3. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | * OF SUCH DAMAGE. 23 | * 24 | * This file is part of the lwIP TCP/IP stack. 25 | * 26 | */ 27 | 28 | #ifndef __LWIP_NETIFAPI_H__ 29 | #define __LWIP_NETIFAPI_H__ 30 | 31 | #include "lwip/opt.h" 32 | 33 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ 34 | 35 | #include "lwip/sys.h" 36 | #include "lwip/netif.h" 37 | #include "lwip/dhcp.h" 38 | #include "lwip/autoip.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef void (*netifapi_void_fn)(struct netif *netif); 45 | typedef err_t (*netifapi_errt_fn)(struct netif *netif); 46 | 47 | struct netifapi_msg_msg { 48 | #if !LWIP_TCPIP_CORE_LOCKING 49 | sys_sem_t sem; 50 | #endif /* !LWIP_TCPIP_CORE_LOCKING */ 51 | err_t err; 52 | struct netif *netif; 53 | union { 54 | struct { 55 | ip_addr_t *ipaddr; 56 | ip_addr_t *netmask; 57 | ip_addr_t *gw; 58 | void *state; 59 | netif_init_fn init; 60 | netif_input_fn input; 61 | } add; 62 | struct { 63 | netifapi_void_fn voidfunc; 64 | netifapi_errt_fn errtfunc; 65 | } common; 66 | } msg; 67 | }; 68 | 69 | struct netifapi_msg { 70 | void (* function)(struct netifapi_msg_msg *msg); 71 | struct netifapi_msg_msg msg; 72 | }; 73 | 74 | 75 | /* API for application */ 76 | err_t netifapi_netif_add ( struct netif *netif, 77 | ip_addr_t *ipaddr, 78 | ip_addr_t *netmask, 79 | ip_addr_t *gw, 80 | void *state, 81 | netif_init_fn init, 82 | netif_input_fn input); 83 | 84 | err_t netifapi_netif_set_addr ( struct netif *netif, 85 | ip_addr_t *ipaddr, 86 | ip_addr_t *netmask, 87 | ip_addr_t *gw ); 88 | 89 | err_t netifapi_netif_common ( struct netif *netif, 90 | netifapi_void_fn voidfunc, 91 | netifapi_errt_fn errtfunc); 92 | 93 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) 94 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) 95 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) 96 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) 97 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) 98 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) 99 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) 100 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* LWIP_NETIF_API */ 107 | 108 | #endif /* __LWIP_NETIFAPI_H__ */ 109 | -------------------------------------------------------------------------------- /include/lwip/pbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_PBUF_H__ 34 | #define __LWIP_PBUF_H__ 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** Currently, the pbuf_custom code is only needed for one specific configuration 44 | * of IP_FRAG */ 45 | #define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) 46 | 47 | #define PBUF_TRANSPORT_HLEN 20 48 | #define PBUF_IP_HLEN 20 49 | 50 | typedef enum { 51 | PBUF_TRANSPORT, 52 | PBUF_IP, 53 | PBUF_LINK, 54 | PBUF_RAW 55 | } pbuf_layer; 56 | 57 | typedef enum { 58 | PBUF_RAM, /* pbuf data is stored in RAM */ 59 | PBUF_ROM, /* pbuf data is stored in ROM */ 60 | PBUF_REF, /* pbuf comes from the pbuf pool */ 61 | PBUF_POOL, /* pbuf payload refers to RAM */ 62 | #ifdef EBUF_LWIP 63 | PBUF_ESF_RX /* pbuf payload is from WLAN */ 64 | #endif /* ESF_LWIP */ 65 | } pbuf_type; 66 | 67 | 68 | /** indicates this packet's data should be immediately passed to the application */ 69 | #define PBUF_FLAG_PUSH 0x01U 70 | /** indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a 71 | a pbuf differently */ 72 | #define PBUF_FLAG_IS_CUSTOM 0x02U 73 | /** indicates this pbuf is UDP multicast to be looped back */ 74 | #define PBUF_FLAG_MCASTLOOP 0x04U 75 | 76 | struct pbuf { 77 | /** next pbuf in singly linked pbuf chain */ 78 | struct pbuf *next; 79 | 80 | /** pointer to the actual data in the buffer */ 81 | void *payload; 82 | 83 | /** 84 | * total length of this buffer and all next buffers in chain 85 | * belonging to the same packet. 86 | * 87 | * For non-queue packet chains this is the invariant: 88 | * p->tot_len == p->len + (p->next? p->next->tot_len: 0) 89 | */ 90 | u16_t tot_len; 91 | 92 | /** length of this buffer */ 93 | u16_t len; 94 | 95 | /** pbuf_type as u8_t instead of enum to save space */ 96 | u8_t /*pbuf_type*/ type; 97 | 98 | /** misc flags */ 99 | u8_t flags; 100 | 101 | /** 102 | * the reference count always equals the number of pointers 103 | * that refer to this pbuf. This can be pointers from an application, 104 | * the stack itself, or pbuf->next pointers from a chain. 105 | */ 106 | u16_t ref; 107 | 108 | /* add a pointer for esf_buf */ 109 | void * eb; 110 | }; 111 | 112 | #if LWIP_SUPPORT_CUSTOM_PBUF 113 | /** Prototype for a function to free a custom pbuf */ 114 | typedef void (*pbuf_free_custom_fn)(struct pbuf *p); 115 | 116 | /** A custom pbuf: like a pbuf, but following a function pointer to free it. */ 117 | struct pbuf_custom { 118 | /** The actual pbuf */ 119 | struct pbuf pbuf; 120 | /** This function is called when pbuf_free deallocates this pbuf(_custom) */ 121 | pbuf_free_custom_fn custom_free_function; 122 | }; 123 | #endif /* LWIP_SUPPORT_CUSTOM_PBUF */ 124 | 125 | /* Initializes the pbuf module. This call is empty for now, but may not be in future. */ 126 | #define pbuf_init() 127 | 128 | struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type)ICACHE_FLASH_ATTR; 129 | #if LWIP_SUPPORT_CUSTOM_PBUF 130 | struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, 131 | struct pbuf_custom *p, void *payload_mem, 132 | u16_t payload_mem_len)ICACHE_FLASH_ATTR; 133 | #endif /* LWIP_SUPPORT_CUSTOM_PBUF */ 134 | void pbuf_realloc(struct pbuf *p, u16_t size)ICACHE_FLASH_ATTR; 135 | u8_t pbuf_header(struct pbuf *p, s16_t header_size)ICACHE_FLASH_ATTR; 136 | void pbuf_ref(struct pbuf *p)ICACHE_FLASH_ATTR; 137 | u8_t pbuf_free(struct pbuf *p)ICACHE_FLASH_ATTR; 138 | u8_t pbuf_clen(struct pbuf *p)ICACHE_FLASH_ATTR; 139 | void pbuf_cat(struct pbuf *head, struct pbuf *tail)ICACHE_FLASH_ATTR; 140 | void pbuf_chain(struct pbuf *head, struct pbuf *tail)ICACHE_FLASH_ATTR; 141 | struct pbuf *pbuf_dechain(struct pbuf *p)ICACHE_FLASH_ATTR; 142 | err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)ICACHE_FLASH_ATTR; 143 | u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset)ICACHE_FLASH_ATTR; 144 | err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)ICACHE_FLASH_ATTR; 145 | struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer)ICACHE_FLASH_ATTR; 146 | #if LWIP_CHECKSUM_ON_COPY 147 | err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, 148 | u16_t len, u16_t *chksum)ICACHE_FLASH_ATTR; 149 | #endif /* LWIP_CHECKSUM_ON_COPY */ 150 | 151 | u8_t pbuf_get_at(struct pbuf* p, u16_t offset)ICACHE_FLASH_ATTR; 152 | u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n)ICACHE_FLASH_ATTR; 153 | u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset)ICACHE_FLASH_ATTR; 154 | u16_t pbuf_strstr(struct pbuf* p, const char* substr)ICACHE_FLASH_ATTR; 155 | 156 | #ifdef __cplusplus 157 | } 158 | #endif 159 | 160 | #endif /* __LWIP_PBUF_H__ */ 161 | -------------------------------------------------------------------------------- /include/lwip/puck_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * puck_def.h 3 | * 4 | * Created on: Jul 22, 2010 5 | * Author: dtoma 6 | */ 7 | 8 | #ifndef PUCK_DEF_H_ 9 | #define PUCK_DEF_H_ 10 | 11 | 12 | 13 | #define INSTRUMENT_PORT 8760 14 | 15 | #define INSTRUMENT_LENGTH 80 16 | 17 | #define MDNS_NAME_LENGTH 68 //68 18 | 19 | char* PUCK_SERVICE = NULL; 20 | //#define PUCK_SERVICE "_Escpressif._tcp.local" 21 | #define DNS_SD_SERVICE "_services._dns-sd._udp.local" 22 | #define SERVICE_DESCRIPTION "PUCK PROTOCOL" 23 | #define PUCK_SERVICE_LENGTH 30 24 | 25 | #define UUID_LEN 16 26 | #define DS_VERS_LEN 2 27 | #define DS_SIZE_LEN 2 28 | #define MAN_ID_LEN 4 29 | #define MAN_MODEL_LEN 2 30 | #define MAN_VERS_LEN 2 31 | #define SER_NUM_LEN 4 32 | #define NAME_LEN 64 33 | #define PUCK_DATASHEET_SIZE 96 34 | 35 | #define UUID_OFFSET 0 36 | #define DS_VERS_OFFSET UUID_LEN + UUID_OFFSET 37 | #define DS_SIZE_OFFSET DS_VERS_LEN + DS_VERS_OFFSET 38 | #define MAN_ID_OFFSET DS_SIZE_LEN + DS_SIZE_OFFSET 39 | #define MAN_MODEL_OFFSET MAN_ID_LEN + MAN_ID_OFFSET 40 | #define MAN_VERS_OFFSET MAN_MODEL_LEN + MAN_MODEL_OFFSET 41 | #define SER_NUM_OFFSET MAN_VERS_LEN + MAN_VERS_OFFSET 42 | #define NAME_OFFSET SER_NUM_LEN + SER_NUM_OFFSET 43 | 44 | #endif /* __PUCK_DEF_H__ */ 45 | -------------------------------------------------------------------------------- /include/lwip/raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_RAW_H__ 33 | #define __LWIP_RAW_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/pbuf.h" 40 | #include "lwip/def.h" 41 | #include "lwip/ip.h" 42 | #include "lwip/ip_addr.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | struct raw_pcb; 49 | 50 | /** Function prototype for raw pcb receive callback functions. 51 | * @param arg user supplied argument (raw_pcb.recv_arg) 52 | * @param pcb the raw_pcb which received data 53 | * @param p the packet buffer that was received 54 | * @param addr the remote IP address from which the packet was received 55 | * @return 1 if the packet was 'eaten' (aka. deleted), 56 | * 0 if the packet lives on 57 | * If returning 1, the callback is responsible for freeing the pbuf 58 | * if it's not used any more. 59 | */ 60 | typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, 61 | ip_addr_t *addr); 62 | 63 | struct raw_pcb { 64 | /* Common members of all PCB types */ 65 | IP_PCB; 66 | 67 | struct raw_pcb *next; 68 | 69 | u8_t protocol; 70 | 71 | /** receive callback function */ 72 | raw_recv_fn recv; 73 | /* user-supplied argument for the recv callback */ 74 | void *recv_arg; 75 | }; 76 | 77 | /* The following functions is the application layer interface to the 78 | RAW code. */ 79 | struct raw_pcb * raw_new (u8_t proto)ICACHE_FLASH_ATTR; 80 | void raw_remove (struct raw_pcb *pcb)ICACHE_FLASH_ATTR; 81 | err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; 82 | err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; 83 | 84 | void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)ICACHE_FLASH_ATTR; 85 | err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; 86 | err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); 87 | 88 | /* The following functions are the lower layer interface to RAW. */ 89 | u8_t raw_input (struct pbuf *p, struct netif *inp)ICACHE_FLASH_ATTR; 90 | #define raw_init() /* Compatibility define, not init needed. */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* LWIP_RAW */ 97 | 98 | #endif /* __LWIP_RAW_H__ */ 99 | -------------------------------------------------------------------------------- /include/lwip/sio.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 | * This is the interface to the platform specific serial IO module 32 | * It needs to be implemented by those platforms which need SLIP or PPP 33 | */ 34 | 35 | #ifndef __SIO_H__ 36 | #define __SIO_H__ 37 | 38 | #include "lwip/arch.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* If you want to define sio_fd_t elsewhere or differently, 45 | define this in your cc.h file. */ 46 | #ifndef __sio_fd_t_defined 47 | typedef void * sio_fd_t; 48 | #endif 49 | 50 | /* The following functions can be defined to something else in your cc.h file 51 | or be implemented in your custom sio.c file. */ 52 | 53 | #ifndef sio_open 54 | /** 55 | * Opens a serial device for communication. 56 | * 57 | * @param devnum device number 58 | * @return handle to serial device if successful, NULL otherwise 59 | */ 60 | sio_fd_t sio_open(u8_t devnum)ICACHE_FLASH_ATTR; 61 | #endif 62 | 63 | #ifndef sio_send 64 | /** 65 | * Sends a single character to the serial device. 66 | * 67 | * @param c character to send 68 | * @param fd serial device handle 69 | * 70 | * @note This function will block until the character can be sent. 71 | */ 72 | void sio_send(u8_t c, sio_fd_t fd)ICACHE_FLASH_ATTR; 73 | #endif 74 | 75 | #ifndef sio_recv 76 | /** 77 | * Receives a single character from the serial device. 78 | * 79 | * @param fd serial device handle 80 | * 81 | * @note This function will block until a character is received. 82 | */ 83 | u8_t sio_recv(sio_fd_t fd)ICACHE_FLASH_ATTR; 84 | #endif 85 | 86 | #ifndef sio_read 87 | /** 88 | * Reads from the serial device. 89 | * 90 | * @param fd serial device handle 91 | * @param data pointer to data buffer for receiving 92 | * @param len maximum length (in bytes) of data to receive 93 | * @return number of bytes actually received - may be 0 if aborted by sio_read_abort 94 | * 95 | * @note This function will block until data can be received. The blocking 96 | * can be cancelled by calling sio_read_abort(). 97 | */ 98 | u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len)ICACHE_FLASH_ATTR; 99 | #endif 100 | 101 | #ifndef sio_tryread 102 | /** 103 | * Tries to read from the serial device. Same as sio_read but returns 104 | * immediately if no data is available and never blocks. 105 | * 106 | * @param fd serial device handle 107 | * @param data pointer to data buffer for receiving 108 | * @param len maximum length (in bytes) of data to receive 109 | * @return number of bytes actually received 110 | */ 111 | u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len)ICACHE_FLASH_ATTR; 112 | #endif 113 | 114 | #ifndef sio_write 115 | /** 116 | * Writes to the serial device. 117 | * 118 | * @param fd serial device handle 119 | * @param data pointer to data to send 120 | * @param len length (in bytes) of data to send 121 | * @return number of bytes actually sent 122 | * 123 | * @note This function will block until all data can be sent. 124 | */ 125 | u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len)ICACHE_FLASH_ATTR; 126 | #endif 127 | 128 | #ifndef sio_read_abort 129 | /** 130 | * Aborts a blocking sio_read() call. 131 | * 132 | * @param fd serial device handle 133 | */ 134 | void sio_read_abort(sio_fd_t fd)ICACHE_FLASH_ATTR; 135 | #endif 136 | 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | 141 | #endif /* __SIO_H__ */ 142 | -------------------------------------------------------------------------------- /include/lwip/snmp_asn1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Abstract Syntax Notation One (ISO 8824, 8825) codec. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * Author: Christiaan Simons 33 | */ 34 | 35 | #ifndef __LWIP_SNMP_ASN1_H__ 36 | #define __LWIP_SNMP_ASN1_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/err.h" 40 | #include "lwip/pbuf.h" 41 | #include "lwip/snmp.h" 42 | 43 | #if LWIP_SNMP 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ 50 | #define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ 51 | #define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ 52 | 53 | #define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ 54 | #define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ 55 | 56 | /* universal tags */ 57 | #define SNMP_ASN1_INTEG 2 58 | #define SNMP_ASN1_OC_STR 4 59 | #define SNMP_ASN1_NUL 5 60 | #define SNMP_ASN1_OBJ_ID 6 61 | #define SNMP_ASN1_SEQ 16 62 | 63 | /* application specific (SNMP) tags */ 64 | #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ 65 | #define SNMP_ASN1_COUNTER 1 /* u32_t */ 66 | #define SNMP_ASN1_GAUGE 2 /* u32_t */ 67 | #define SNMP_ASN1_TIMETICKS 3 /* u32_t */ 68 | #define SNMP_ASN1_OPAQUE 4 /* octet string */ 69 | 70 | /* context specific (SNMP) tags */ 71 | #define SNMP_ASN1_PDU_GET_REQ 0 72 | #define SNMP_ASN1_PDU_GET_NEXT_REQ 1 73 | #define SNMP_ASN1_PDU_GET_RESP 2 74 | #define SNMP_ASN1_PDU_SET_REQ 3 75 | #define SNMP_ASN1_PDU_TRAP 4 76 | 77 | err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); 78 | err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); 79 | err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); 80 | err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); 81 | err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); 82 | err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); 83 | 84 | void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); 85 | void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); 86 | void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); 87 | void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); 88 | err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); 89 | err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); 90 | err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); 91 | err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); 92 | err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); 93 | err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* LWIP_SNMP */ 100 | 101 | #endif /* __LWIP_SNMP_ASN1_H__ */ 102 | -------------------------------------------------------------------------------- /include/lwip/sntp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_SNTP_H 2 | #define LWIP_SNTP_H 3 | 4 | #include "lwip/opt.h" 5 | #include "lwip/ip_addr.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | /** The maximum number of SNTP servers that can be set */ 12 | #ifndef SNTP_MAX_SERVERS 13 | #define SNTP_MAX_SERVERS 3 14 | #endif 15 | 16 | /** Set this to 1 to implement the callback function called by dhcp when 17 | * NTP servers are received. */ 18 | #ifndef SNTP_GET_SERVERS_FROM_DHCP 19 | #define SNTP_GET_SERVERS_FROM_DHCP 0//LWIP_DHCP_GET_NTP_SRV 20 | #endif 21 | 22 | /* Set this to 1 to support DNS names (or IP address strings) to set sntp servers */ 23 | #ifndef SNTP_SERVER_DNS 24 | #define SNTP_SERVER_DNS 1 25 | #endif 26 | 27 | /** One server address/name can be defined as default if SNTP_SERVER_DNS == 1: 28 | * #define SNTP_SERVER_ADDRESS "pool.ntp.org" 29 | */ 30 | uint32 sntp_get_current_timestamp(); 31 | char* sntp_get_real_time(long t); 32 | 33 | void sntp_init(void); 34 | void sntp_stop(void); 35 | 36 | sint8 sntp_get_timezone(void); 37 | bool sntp_set_timezone(sint8 timezone); 38 | void sntp_setserver(u8_t idx, ip_addr_t *addr); 39 | ip_addr_t sntp_getserver(u8_t idx); 40 | 41 | #if SNTP_SERVER_DNS 42 | void sntp_setservername(u8_t idx, char *server); 43 | char *sntp_getservername(u8_t idx); 44 | #endif /* SNTP_SERVER_DNS */ 45 | 46 | #if SNTP_GET_SERVERS_FROM_DHCP 47 | void sntp_servermode_dhcp(int set_servers_from_dhcp); 48 | #else /* SNTP_GET_SERVERS_FROM_DHCP */ 49 | #define sntp_servermode_dhcp(x) 50 | #endif /* SNTP_GET_SERVERS_FROM_DHCP */ 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* LWIP_SNTP_H */ 57 | -------------------------------------------------------------------------------- /include/lwip/tcpip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_TCPIP_H__ 33 | #define __LWIP_TCPIP_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if !NO_SYS /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/api_msg.h" 40 | #include "lwip/netifapi.h" 41 | #include "lwip/pbuf.h" 42 | #include "lwip/api.h" 43 | #include "lwip/sys.h" 44 | #include "lwip/timers.h" 45 | #include "lwip/netif.h" 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /** Define this to something that triggers a watchdog. This is called from 52 | * tcpip_thread after processing a message. */ 53 | #ifndef LWIP_TCPIP_THREAD_ALIVE 54 | #define LWIP_TCPIP_THREAD_ALIVE() 55 | #endif 56 | 57 | #if LWIP_TCPIP_CORE_LOCKING 58 | /** The global semaphore to lock the stack. */ 59 | extern sys_mutex_t lock_tcpip_core; 60 | #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core) 61 | #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core) 62 | #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m) 63 | #define TCPIP_APIMSG_ACK(m) 64 | #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m) 65 | #define TCPIP_NETIFAPI_ACK(m) 66 | #else /* LWIP_TCPIP_CORE_LOCKING */ 67 | #define LOCK_TCPIP_CORE() 68 | #define UNLOCK_TCPIP_CORE() 69 | #define TCPIP_APIMSG(m) tcpip_apimsg(m) 70 | #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed) 71 | #define TCPIP_NETIFAPI(m) tcpip_netifapi(m) 72 | #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem) 73 | #endif /* LWIP_TCPIP_CORE_LOCKING */ 74 | 75 | /** Function prototype for the init_done function passed to tcpip_init */ 76 | typedef void (*tcpip_init_done_fn)(void *arg); 77 | /** Function prototype for functions passed to tcpip_callback() */ 78 | typedef void (*tcpip_callback_fn)(void *ctx); 79 | 80 | void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); 81 | 82 | #if LWIP_NETCONN 83 | err_t tcpip_apimsg(struct api_msg *apimsg); 84 | #if LWIP_TCPIP_CORE_LOCKING 85 | err_t tcpip_apimsg_lock(struct api_msg *apimsg); 86 | #endif /* LWIP_TCPIP_CORE_LOCKING */ 87 | #endif /* LWIP_NETCONN */ 88 | 89 | err_t tcpip_input(struct pbuf *p, struct netif *inp); 90 | 91 | #if LWIP_NETIF_API 92 | err_t tcpip_netifapi(struct netifapi_msg *netifapimsg); 93 | #if LWIP_TCPIP_CORE_LOCKING 94 | err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg); 95 | #endif /* LWIP_TCPIP_CORE_LOCKING */ 96 | #endif /* LWIP_NETIF_API */ 97 | 98 | err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); 99 | #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) 100 | 101 | /* free pbufs or heap memory from another context without blocking */ 102 | err_t pbuf_free_callback(struct pbuf *p); 103 | err_t mem_free_callback(void *m); 104 | 105 | #if LWIP_TCPIP_TIMEOUT 106 | err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); 107 | err_t tcpip_untimeout(sys_timeout_handler h, void *arg); 108 | #endif /* LWIP_TCPIP_TIMEOUT */ 109 | 110 | enum tcpip_msg_type { 111 | #if LWIP_NETCONN 112 | TCPIP_MSG_API, 113 | #endif /* LWIP_NETCONN */ 114 | TCPIP_MSG_INPKT, 115 | #if LWIP_NETIF_API 116 | TCPIP_MSG_NETIFAPI, 117 | #endif /* LWIP_NETIF_API */ 118 | #if LWIP_TCPIP_TIMEOUT 119 | TCPIP_MSG_TIMEOUT, 120 | TCPIP_MSG_UNTIMEOUT, 121 | #endif /* LWIP_TCPIP_TIMEOUT */ 122 | TCPIP_MSG_CALLBACK 123 | }; 124 | 125 | struct tcpip_msg { 126 | enum tcpip_msg_type type; 127 | sys_sem_t *sem; 128 | union { 129 | #if LWIP_NETCONN 130 | struct api_msg *apimsg; 131 | #endif /* LWIP_NETCONN */ 132 | #if LWIP_NETIF_API 133 | struct netifapi_msg *netifapimsg; 134 | #endif /* LWIP_NETIF_API */ 135 | struct { 136 | struct pbuf *p; 137 | struct netif *netif; 138 | } inp; 139 | struct { 140 | tcpip_callback_fn function; 141 | void *ctx; 142 | } cb; 143 | #if LWIP_TCPIP_TIMEOUT 144 | struct { 145 | u32_t msecs; 146 | sys_timeout_handler h; 147 | void *arg; 148 | } tmo; 149 | #endif /* LWIP_TCPIP_TIMEOUT */ 150 | } msg; 151 | }; 152 | 153 | #ifdef __cplusplus 154 | } 155 | #endif 156 | 157 | #endif /* !NO_SYS */ 158 | 159 | #endif /* __LWIP_TCPIP_H__ */ 160 | -------------------------------------------------------------------------------- /include/lwip/timers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * Simon Goldschmidt 31 | * 32 | */ 33 | #ifndef __LWIP_TIMERS_H__ 34 | #define __LWIP_TIMERS_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | /* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ 39 | #define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) 40 | 41 | #if LWIP_TIMERS 42 | 43 | #include "lwip/err.h" 44 | #include "lwip/sys.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | #ifndef LWIP_DEBUG_TIMERNAMES 51 | #ifdef LWIP_DEBUG 52 | #define LWIP_DEBUG_TIMERNAMES SYS_DEBUG 53 | #else /* LWIP_DEBUG */ 54 | #define LWIP_DEBUG_TIMERNAMES 0 55 | #endif /* LWIP_DEBUG*/ 56 | #endif 57 | 58 | /** Function prototype for a timeout callback function. Register such a function 59 | * using sys_timeout(). 60 | * 61 | * @param arg Additional argument to pass to the function - set up by sys_timeout() 62 | */ 63 | typedef void (* sys_timeout_handler)(void *arg); 64 | 65 | struct sys_timeo { 66 | struct sys_timeo *next; 67 | u32_t time; 68 | sys_timeout_handler h; 69 | void *arg; 70 | #if LWIP_DEBUG_TIMERNAMES 71 | const char* handler_name; 72 | #endif /* LWIP_DEBUG_TIMERNAMES */ 73 | }; 74 | 75 | void sys_timeouts_init(void)ICACHE_FLASH_ATTR; 76 | 77 | #if LWIP_DEBUG_TIMERNAMES 78 | void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name)ICACHE_FLASH_ATTR; 79 | #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) 80 | #else /* LWIP_DEBUG_TIMERNAMES */ 81 | void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)ICACHE_FLASH_ATTR; 82 | #endif /* LWIP_DEBUG_TIMERNAMES */ 83 | 84 | void sys_untimeout(sys_timeout_handler handler, void *arg)ICACHE_FLASH_ATTR; 85 | #if NO_SYS 86 | void sys_check_timeouts(void)ICACHE_FLASH_ATTR; 87 | void sys_restart_timeouts(void)ICACHE_FLASH_ATTR; 88 | #else /* NO_SYS */ 89 | void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); 90 | #endif /* NO_SYS */ 91 | 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_TIMERS */ 98 | #endif /* __LWIP_TIMERS_H__ */ 99 | -------------------------------------------------------------------------------- /include/lwip/udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_UDP_H__ 33 | #define __LWIP_UDP_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/pbuf.h" 40 | #include "lwip/netif.h" 41 | #include "lwip/ip_addr.h" 42 | #include "lwip/ip.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #define UDP_HLEN 8 49 | 50 | /* Fields are (of course) in network byte order. */ 51 | #ifdef PACK_STRUCT_USE_INCLUDES 52 | # include "arch/bpstruct.h" 53 | #endif 54 | PACK_STRUCT_BEGIN 55 | struct udp_hdr { 56 | PACK_STRUCT_FIELD(u16_t src); 57 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 58 | PACK_STRUCT_FIELD(u16_t len); 59 | PACK_STRUCT_FIELD(u16_t chksum); 60 | } PACK_STRUCT_STRUCT; 61 | PACK_STRUCT_END 62 | #ifdef PACK_STRUCT_USE_INCLUDES 63 | # include "arch/epstruct.h" 64 | #endif 65 | 66 | #define UDP_FLAGS_NOCHKSUM 0x01U 67 | #define UDP_FLAGS_UDPLITE 0x02U 68 | #define UDP_FLAGS_CONNECTED 0x04U 69 | #define UDP_FLAGS_MULTICAST_LOOP 0x08U 70 | 71 | struct udp_pcb; 72 | 73 | /** Function prototype for udp pcb receive callback functions 74 | * addr and port are in same byte order as in the pcb 75 | * The callback is responsible for freeing the pbuf 76 | * if it's not used any more. 77 | * 78 | * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf 79 | * makes 'addr' invalid, too. 80 | * 81 | * @param arg user supplied argument (udp_pcb.recv_arg) 82 | * @param pcb the udp_pcb which received data 83 | * @param p the packet buffer that was received 84 | * @param addr the remote IP address from which the packet was received 85 | * @param port the remote port from which the packet was received 86 | */ 87 | typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, 88 | ip_addr_t *addr, u16_t port); 89 | 90 | 91 | struct udp_pcb { 92 | /* Common members of all PCB types */ 93 | IP_PCB; 94 | 95 | /* Protocol specific PCB members */ 96 | 97 | struct udp_pcb *next; 98 | 99 | u8_t flags; 100 | /** ports are in host byte order */ 101 | u16_t local_port, remote_port; 102 | 103 | #if LWIP_IGMP 104 | /** outgoing network interface for multicast packets */ 105 | ip_addr_t multicast_ip; 106 | #endif /* LWIP_IGMP */ 107 | 108 | #if LWIP_UDPLITE 109 | /** used for UDP_LITE only */ 110 | u16_t chksum_len_rx, chksum_len_tx; 111 | #endif /* LWIP_UDPLITE */ 112 | 113 | /** receive callback function */ 114 | udp_recv_fn recv; 115 | /** user-supplied argument for the recv callback */ 116 | void *recv_arg; 117 | }; 118 | /* udp_pcbs export for exernal reference (e.g. SNMP agent) */ 119 | extern struct udp_pcb *udp_pcbs; 120 | 121 | /* The following functions is the application layer interface to the 122 | UDP code. */ 123 | struct udp_pcb * udp_new (void)ICACHE_FLASH_ATTR; 124 | void udp_remove (struct udp_pcb *pcb)ICACHE_FLASH_ATTR; 125 | err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr, 126 | u16_t port)ICACHE_FLASH_ATTR; 127 | err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr, 128 | u16_t port)ICACHE_FLASH_ATTR; 129 | void udp_disconnect (struct udp_pcb *pcb)ICACHE_FLASH_ATTR; 130 | void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, 131 | void *recv_arg)ICACHE_FLASH_ATTR; 132 | err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, 133 | ip_addr_t *dst_ip, u16_t dst_port, 134 | struct netif *netif)ICACHE_FLASH_ATTR; 135 | err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, 136 | ip_addr_t *dst_ip, u16_t dst_port)ICACHE_FLASH_ATTR; 137 | err_t udp_send (struct udp_pcb *pcb, struct pbuf *p)ICACHE_FLASH_ATTR; 138 | 139 | #if LWIP_CHECKSUM_ON_COPY 140 | err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, 141 | ip_addr_t *dst_ip, u16_t dst_port, 142 | struct netif *netif, u8_t have_chksum, 143 | u16_t chksum)ICACHE_FLASH_ATTR; 144 | err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, 145 | ip_addr_t *dst_ip, u16_t dst_port, 146 | u8_t have_chksum, u16_t chksum)ICACHE_FLASH_ATTR; 147 | err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, 148 | u8_t have_chksum, u16_t chksum)ICACHE_FLASH_ATTR; 149 | #endif /* LWIP_CHECKSUM_ON_COPY */ 150 | 151 | #define udp_flags(pcb) ((pcb)->flags) 152 | #define udp_setflags(pcb, f) ((pcb)->flags = (f)) 153 | 154 | /* The following functions are the lower layer interface to UDP. */ 155 | void udp_input (struct pbuf *p, struct netif *inp)ICACHE_FLASH_ATTR; 156 | 157 | #define udp_init() /* Compatibility define, not init needed. */ 158 | 159 | #if UDP_DEBUG 160 | void udp_debug_print(struct udp_hdr *udphdr)ICACHE_FLASH_ATTR; 161 | #else 162 | #define udp_debug_print(udphdr) 163 | #endif 164 | 165 | #ifdef __cplusplus 166 | } 167 | #endif 168 | 169 | #endif /* LWIP_UDP */ 170 | 171 | #endif /* __LWIP_UDP_H__ */ 172 | -------------------------------------------------------------------------------- /include/netif/driver/spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 David Ogilvy (MetalPhreak) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef SPI_APP_H 26 | #define SPI_APP_H 27 | 28 | #include "spi_register.h" 29 | #include "ets_sys.h" 30 | #include "osapi.h" 31 | //#include "uart.h" 32 | #include "os_type.h" 33 | 34 | //Define SPI hardware modules 35 | #define SPI 0 36 | #define HSPI 1 37 | 38 | #define SPI_CLK_USE_DIV 0 39 | #define SPI_CLK_80MHZ_NODIV 1 40 | 41 | #define SPI_BYTE_ORDER_HIGH_TO_LOW 1 42 | #define SPI_BYTE_ORDER_LOW_TO_HIGH 0 43 | 44 | #ifndef CPU_CLK_FREQ //Should already be defined in eagle_soc.h 45 | #define CPU_CLK_FREQ 80*1000000 46 | #endif 47 | 48 | /* 49 | * Spec says maximum is 20Mhz, 50 | * so why are we running at 4??!! 51 | * 52 | * 1000000 PREDIV: 40 CNTDIV: 2 53 | * 2000000 PREDIV: 20 CNTDIV: 2 54 | * 2962962 PREDIV: 9 CNTDIV: 3 55 | * 4000000 PREDIV: 10 CNTDIV: 2 56 | * 5000000 PREDIV: 8 CNTDIV: 2 57 | * 5714285 PREDIV: 7 CNTDIV: 2 58 | * 6666666 PREDIV: 6 CNTDIV: 2 59 | * 8000000 PREDIV: 5 CNTDIV: 2 60 | * 8888888 PREDIV: 3 CNTDIV: 3 61 | * 10000000 PREDIV: 4 CNTDIV: 2 62 | * 11428571 PREDIV: 1 CNTDIV: 7 63 | * 13333333 PREDIV: 3 CNTDIV: 2 64 | * 16000000 PREDIV: 1 CNTDIV: 5 65 | * 20000000 PREDIV: 2 CNTDIV: 2 66 | * 26666666 PREDIV: 1 CNTDIV: 3 67 | * 40000000 PREDIV: 1 CNTDIV: 2 68 | */ 69 | //Define some default SPI clock settings 70 | #define SPI_CLK_PREDIV 10 71 | #define SPI_CLK_CNTDIV 2 72 | #define SPI_CLK_FREQ CPU_CLK_FREQ/(SPI_CLK_PREDIV*SPI_CLK_CNTDIV) // 80 / 20 = 4 MHz 73 | 74 | 75 | 76 | 77 | 78 | void spi_init(uint8 spi_no); 79 | void spi_mode(uint8 spi_no, uint8 spi_cpha,uint8 spi_cpol); 80 | void spi_init_gpio(uint8 spi_no, uint8 sysclk_as_spiclk); 81 | void spi_clock(uint8 spi_no, uint16 prediv, uint8 cntdiv); 82 | void spi_tx_byte_order(uint8 spi_no, uint8 byte_order); 83 | void spi_rx_byte_order(uint8 spi_no, uint8 byte_order); 84 | uint32 spi_transaction(uint8 spi_no, uint8 cmd_bits, uint16 cmd_data, uint32 addr_bits, uint32 addr_data, uint32 dout_bits, uint32 dout_data, uint32 din_bits, uint32 dummy_bits); 85 | 86 | //Expansion Macros 87 | #define spi_busy(spi_no) READ_PERI_REG(SPI_CMD(spi_no))&SPI_USR 88 | 89 | #define spi_txd(spi_no, bits, data) spi_transaction(spi_no, 0, 0, 0, 0, bits, (uint32) data, 0, 0) 90 | #define spi_tx8(spi_no, data) spi_transaction(spi_no, 0, 0, 0, 0, 8, (uint32) data, 0, 0) 91 | #define spi_tx16(spi_no, data) spi_transaction(spi_no, 0, 0, 0, 0, 16, (uint32) data, 0, 0) 92 | #define spi_tx32(spi_no, data) spi_transaction(spi_no, 0, 0, 0, 0, 32, (uint32) data, 0, 0) 93 | 94 | #define spi_rxd(spi_no, bits) spi_transaction(spi_no, 0, 0, 0, 0, 0, 0, bits, 0) 95 | #define spi_rx8(spi_no) spi_transaction(spi_no, 0, 0, 0, 0, 0, 0, 8, 0) 96 | #define spi_rx16(spi_no) spi_transaction(spi_no, 0, 0, 0, 0, 0, 0, 16, 0) 97 | #define spi_rx32(spi_no) spi_transaction(spi_no, 0, 0, 0, 0, 0, 0, 32, 0) 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /include/netif/if_llc.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: if_llc.h,v 1.12 1999/11/19 20:41:19 thorpej Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1988, 1993 5 | * The Regents of the University of California. 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 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 4. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)if_llc.h 8.1 (Berkeley) 6/10/93 32 | * $FreeBSD$ 33 | */ 34 | 35 | #ifndef _NET_IF_LLC_H_ 36 | #define _NET_IF_LLC_H_ 37 | 38 | /* 39 | * IEEE 802.2 Link Level Control headers, for use in conjunction with 40 | * 802.{3,4,5} media access control methods. 41 | * 42 | * Headers here do not use bit fields due to shortcommings in many 43 | * compilers. 44 | */ 45 | 46 | struct llc { 47 | uint8_t llc_dsap; 48 | uint8_t llc_ssap; 49 | union { 50 | struct { 51 | uint8_t control; 52 | uint8_t format_id; 53 | uint8_t class; 54 | uint8_t window_x2; 55 | } __packed type_u; 56 | struct { 57 | uint8_t num_snd_x2; 58 | uint8_t num_rcv_x2; 59 | } __packed type_i; 60 | struct { 61 | uint8_t control; 62 | uint8_t num_rcv_x2; 63 | } __packed type_s; 64 | struct { 65 | uint8_t control; 66 | /* 67 | * We cannot put the following fields in a structure because 68 | * the structure rounding might cause padding. 69 | */ 70 | uint8_t frmr_rej_pdu0; 71 | uint8_t frmr_rej_pdu1; 72 | uint8_t frmr_control; 73 | uint8_t frmr_control_ext; 74 | uint8_t frmr_cause; 75 | } __packed type_frmr; 76 | struct { 77 | uint8_t control; 78 | uint8_t org_code[3]; 79 | uint16_t ether_type; 80 | } __packed type_snap; 81 | struct { 82 | uint8_t control; 83 | uint8_t control_ext; 84 | } __packed type_raw; 85 | } __packed llc_un; 86 | } __packed; 87 | 88 | struct frmrinfo { 89 | uint8_t frmr_rej_pdu0; 90 | uint8_t frmr_rej_pdu1; 91 | uint8_t frmr_control; 92 | uint8_t frmr_control_ext; 93 | uint8_t frmr_cause; 94 | } __packed; 95 | 96 | #define llc_control llc_un.type_u.control 97 | #define llc_control_ext llc_un.type_raw.control_ext 98 | #define llc_fid llc_un.type_u.format_id 99 | #define llc_class llc_un.type_u.class 100 | #define llc_window llc_un.type_u.window_x2 101 | #define llc_frmrinfo llc_un.type_frmr.frmr_rej_pdu0 102 | #define llc_frmr_pdu0 llc_un.type_frmr.frmr_rej_pdu0 103 | #define llc_frmr_pdu1 llc_un.type_frmr.frmr_rej_pdu1 104 | #define llc_frmr_control llc_un.type_frmr.frmr_control 105 | #define llc_frmr_control_ext llc_un.type_frmr.frmr_control_ext 106 | #define llc_frmr_cause llc_un.type_frmr.frmr_cause 107 | #define llc_snap llc_un.type_snap 108 | 109 | /* 110 | * Don't use sizeof(struct llc_un) for LLC header sizes 111 | */ 112 | #define LLC_ISFRAMELEN 4 113 | #define LLC_UFRAMELEN 3 114 | #define LLC_FRMRLEN 7 115 | #define LLC_SNAPFRAMELEN 8 116 | 117 | #ifdef CTASSERT 118 | CTASSERT(sizeof (struct llc) == LLC_SNAPFRAMELEN); 119 | #endif 120 | 121 | /* 122 | * Unnumbered LLC format commands 123 | */ 124 | #define LLC_UI 0x3 125 | #define LLC_UI_P 0x13 126 | #define LLC_DISC 0x43 127 | #define LLC_DISC_P 0x53 128 | #define LLC_UA 0x63 129 | #define LLC_UA_P 0x73 130 | #define LLC_TEST 0xe3 131 | #define LLC_TEST_P 0xf3 132 | #define LLC_FRMR 0x87 133 | #define LLC_FRMR_P 0x97 134 | #define LLC_DM 0x0f 135 | #define LLC_DM_P 0x1f 136 | #define LLC_XID 0xaf 137 | #define LLC_XID_P 0xbf 138 | #define LLC_SABME 0x6f 139 | #define LLC_SABME_P 0x7f 140 | 141 | /* 142 | * Supervisory LLC commands 143 | */ 144 | #define LLC_RR 0x01 145 | #define LLC_RNR 0x05 146 | #define LLC_REJ 0x09 147 | 148 | /* 149 | * Info format - dummy only 150 | */ 151 | #define LLC_INFO 0x00 152 | 153 | /* 154 | * ISO PDTR 10178 contains among others 155 | */ 156 | #define LLC_8021D_LSAP 0x42 157 | #define LLC_X25_LSAP 0x7e 158 | #define LLC_SNAP_LSAP 0xaa 159 | #define LLC_ISO_LSAP 0xfe 160 | 161 | #define RFC1042_LEN 6 162 | #define RFC1042 {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00} 163 | #define ETHERNET_TUNNEL {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8} 164 | 165 | /* 166 | * copied from sys/net/ethernet.h 167 | */ 168 | #define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ 169 | #define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ 170 | 171 | 172 | 173 | #endif /* _NET_IF_LLC_H_ */ 174 | -------------------------------------------------------------------------------- /include/netif/slipif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef __NETIF_SLIPIF_H__ 35 | #define __NETIF_SLIPIF_H__ 36 | 37 | #include "lwip/opt.h" 38 | #include "lwip/netif.h" 39 | 40 | /** Set this to 1 to start a thread that blocks reading on the serial line 41 | * (using sio_read()). 42 | */ 43 | #ifndef SLIP_USE_RX_THREAD 44 | #define SLIP_USE_RX_THREAD !NO_SYS 45 | #endif 46 | 47 | /** Set this to 1 to enable functions to pass in RX bytes from ISR context. 48 | * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled 49 | * packets on a queue, which is fed into lwIP from slipif_poll(). 50 | * If disabled, slipif_poll() polls the serila line (using sio_tryread()). 51 | */ 52 | #ifndef SLIP_RX_FROM_ISR 53 | #define SLIP_RX_FROM_ISR 1 54 | #endif 55 | 56 | /** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets 57 | * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. 58 | * If disabled, packets will be dropped if more than one packet is received. 59 | */ 60 | #ifndef SLIP_RX_QUEUE 61 | #define SLIP_RX_QUEUE SLIP_RX_FROM_ISR 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | err_t slipif_init(struct netif * netif); 69 | void slipif_poll(struct netif *netif); 70 | #if SLIP_RX_FROM_ISR 71 | void slipif_process_rxqueue(struct netif *netif); 72 | void slipif_received_byte(struct netif *netif, u8_t data); 73 | void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); 74 | #endif /* SLIP_RX_FROM_ISR */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /include/netif/tunif.h: -------------------------------------------------------------------------------- 1 | #ifndef __TUNIF_H__ 2 | #define __TUNIF_H__ 3 | 4 | #include "c_types.h" 5 | #include "lwip/opt.h" 6 | #include "lwip/netif.h" 7 | 8 | #define NETIF_FLAG_BROADCAST 0x02U 9 | #define NETIF_FLAG_POINTTOPOINT 0x04U 10 | 11 | struct tunif_data; 12 | struct event_base; 13 | 14 | struct tunif_data *tunif_add(struct event_base *base, int fd, int header); 15 | void tunif_del(struct tunif_data *data); 16 | 17 | void tunif_set_ipaddr(struct tunif_data *data, uint32_t addr); 18 | void tunif_set_netmask(struct tunif_data *data, uint32_t addr); 19 | void tunif_set_gw(struct tunif_data *data, uint32_t addr); 20 | void tunif_set_up(struct tunif_data *data); 21 | void tunif_set_down(struct tunif_data *data); 22 | void tunif_set_mtu(struct tunif_data *data, int mtu); 23 | void tunif_set_flag(struct tunif_data *data, int flag); 24 | void tunif_clear_flag(struct tunif_data *data, int flag); 25 | void tunif_clear_dns(void); 26 | void tunif_add_dns(uint32_t addr); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/netif/wlan_lwip_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011 Espressif System 3 | * 4 | */ 5 | 6 | #ifndef _WLAN_LWIP_IF_H_ 7 | #define _WLAN_LWIP_IF_H_ 8 | 9 | #define LWIP_IF0_PRIO 28 10 | #define LWIP_IF1_PRIO 29 11 | 12 | enum { 13 | SIG_LWIP_RX = 0, 14 | }; 15 | 16 | struct netif * eagle_lwip_if_alloc(struct ieee80211_conn *conn, const uint8 *macaddr, struct ip_info *info); 17 | struct netif * eagle_lwip_getif(uint8 index); 18 | 19 | #ifndef IOT_SIP_MODE 20 | sint8 ieee80211_output_pbuf(struct netif *ifp, struct pbuf* pb); 21 | #else 22 | sint8 ieee80211_output_pbuf(struct ieee80211_conn *conn, esf_buf *eb); 23 | #endif 24 | 25 | #endif /* _WLAN_LWIP_IF_H_ */ 26 | -------------------------------------------------------------------------------- /include/user_config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-ger/esp-open-lwip/5157a11da89c2ae8aeca0653c5a44fed7377fde8/include/user_config.h -------------------------------------------------------------------------------- /lwip/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | UP_EXTRACT_DIR = .. 16 | GEN_LIBS = liblwip.a 17 | COMPONENTS_liblwip = api/liblwipapi.a \ 18 | app/liblwipapp.a \ 19 | core/liblwipcore.a \ 20 | core/ipv4/liblwipipv4.a \ 21 | netif/liblwipnetif.a 22 | endif 23 | 24 | 25 | ############################################################# 26 | # Configuration i.e. compile options etc. 27 | # Target specific stuff (defines etc.) goes in here! 28 | # Generally values applying to a tree are captured in the 29 | # makefile at its root level - these are then overridden 30 | # for a subtree within the makefile rooted therein 31 | # 32 | #DEFINES += 33 | 34 | ############################################################# 35 | # Recursion Magic - Don't touch this!! 36 | # 37 | # Each subtree potentially has an include directory 38 | # corresponding to the common APIs applicable to modules 39 | # rooted at that subtree. Accordingly, the INCLUDE PATH 40 | # of a module can only contain the include directories up 41 | # its parent path, and not its siblings 42 | # 43 | # Required for each makefile to inherit from the parent 44 | # 45 | 46 | INCLUDES := $(INCLUDES) -I $(PDIR)include 47 | INCLUDES += -I ./ 48 | PDIR := ../$(PDIR) 49 | sinclude $(PDIR)Makefile 50 | 51 | -------------------------------------------------------------------------------- /lwip/api/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipapi.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /lwip/api/err.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Error Management module 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/err.h" 40 | 41 | #ifdef LWIP_DEBUG 42 | 43 | static const char *err_strerr[] = { 44 | "Ok.", /* ERR_OK 0 */ 45 | "Out of memory error.", /* ERR_MEM -1 */ 46 | "Buffer error.", /* ERR_BUF -2 */ 47 | "Timeout.", /* ERR_TIMEOUT -3 */ 48 | "Routing problem.", /* ERR_RTE -4 */ 49 | "Operation in progress.", /* ERR_INPROGRESS -5 */ 50 | "Illegal value.", /* ERR_VAL -6 */ 51 | "Operation would block.", /* ERR_WOULDBLOCK -7 */ 52 | "Connection aborted.", /* ERR_ABRT -8 */ 53 | "Connection reset.", /* ERR_RST -9 */ 54 | "Connection closed.", /* ERR_CLSD -10 */ 55 | "Not connected.", /* ERR_CONN -11 */ 56 | "Illegal argument.", /* ERR_ARG -12 */ 57 | "Address in use.", /* ERR_USE -13 */ 58 | "Low-level netif error.", /* ERR_IF -14 */ 59 | "Already connected.", /* ERR_ISCONN -15 */ 60 | }; 61 | 62 | /** 63 | * Convert an lwip internal error to a string representation. 64 | * 65 | * @param err an lwip internal err_t 66 | * @return a string representation for err 67 | */ 68 | const char * 69 | lwip_strerr(err_t err) 70 | { 71 | return err_strerr[-err]; 72 | 73 | } 74 | 75 | #endif /* LWIP_DEBUG */ 76 | -------------------------------------------------------------------------------- /lwip/api/netbuf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-ger/esp-open-lwip/5157a11da89c2ae8aeca0653c5a44fed7377fde8/lwip/api/netbuf.c -------------------------------------------------------------------------------- /lwip/api/netifapi.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Network Interface Sequential API module 4 | * 5 | */ 6 | 7 | /* 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. The name of the author may not be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 22 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 24 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 28 | * OF SUCH DAMAGE. 29 | * 30 | * This file is part of the lwIP TCP/IP stack. 31 | * 32 | */ 33 | 34 | #include "lwip/opt.h" 35 | 36 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ 37 | 38 | #include "lwip/netifapi.h" 39 | #include "lwip/tcpip.h" 40 | 41 | /** 42 | * Call netif_add() inside the tcpip_thread context. 43 | */ 44 | void 45 | do_netifapi_netif_add(struct netifapi_msg_msg *msg) 46 | { 47 | if (!netif_add( msg->netif, 48 | msg->msg.add.ipaddr, 49 | msg->msg.add.netmask, 50 | msg->msg.add.gw, 51 | msg->msg.add.state, 52 | msg->msg.add.init, 53 | msg->msg.add.input)) { 54 | msg->err = ERR_IF; 55 | } else { 56 | msg->err = ERR_OK; 57 | } 58 | TCPIP_NETIFAPI_ACK(msg); 59 | } 60 | 61 | /** 62 | * Call netif_set_addr() inside the tcpip_thread context. 63 | */ 64 | void 65 | do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg) 66 | { 67 | netif_set_addr( msg->netif, 68 | msg->msg.add.ipaddr, 69 | msg->msg.add.netmask, 70 | msg->msg.add.gw); 71 | msg->err = ERR_OK; 72 | TCPIP_NETIFAPI_ACK(msg); 73 | } 74 | 75 | /** 76 | * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the 77 | * tcpip_thread context. 78 | */ 79 | void 80 | do_netifapi_netif_common(struct netifapi_msg_msg *msg) 81 | { 82 | if (msg->msg.common.errtfunc != NULL) { 83 | msg->err = msg->msg.common.errtfunc(msg->netif); 84 | } else { 85 | msg->err = ERR_OK; 86 | msg->msg.common.voidfunc(msg->netif); 87 | } 88 | TCPIP_NETIFAPI_ACK(msg); 89 | } 90 | 91 | /** 92 | * Call netif_add() in a thread-safe way by running that function inside the 93 | * tcpip_thread context. 94 | * 95 | * @note for params @see netif_add() 96 | */ 97 | err_t 98 | netifapi_netif_add(struct netif *netif, 99 | ip_addr_t *ipaddr, 100 | ip_addr_t *netmask, 101 | ip_addr_t *gw, 102 | void *state, 103 | netif_init_fn init, 104 | netif_input_fn input) 105 | { 106 | struct netifapi_msg msg; 107 | msg.function = do_netifapi_netif_add; 108 | msg.msg.netif = netif; 109 | msg.msg.msg.add.ipaddr = ipaddr; 110 | msg.msg.msg.add.netmask = netmask; 111 | msg.msg.msg.add.gw = gw; 112 | msg.msg.msg.add.state = state; 113 | msg.msg.msg.add.init = init; 114 | msg.msg.msg.add.input = input; 115 | TCPIP_NETIFAPI(&msg); 116 | return msg.msg.err; 117 | } 118 | 119 | /** 120 | * Call netif_set_addr() in a thread-safe way by running that function inside the 121 | * tcpip_thread context. 122 | * 123 | * @note for params @see netif_set_addr() 124 | */ 125 | err_t 126 | netifapi_netif_set_addr(struct netif *netif, 127 | ip_addr_t *ipaddr, 128 | ip_addr_t *netmask, 129 | ip_addr_t *gw) 130 | { 131 | struct netifapi_msg msg; 132 | msg.function = do_netifapi_netif_set_addr; 133 | msg.msg.netif = netif; 134 | msg.msg.msg.add.ipaddr = ipaddr; 135 | msg.msg.msg.add.netmask = netmask; 136 | msg.msg.msg.add.gw = gw; 137 | TCPIP_NETIFAPI(&msg); 138 | return msg.msg.err; 139 | } 140 | 141 | /** 142 | * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe 143 | * way by running that function inside the tcpip_thread context. 144 | * 145 | * @note use only for functions where there is only "netif" parameter. 146 | */ 147 | err_t 148 | netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc, 149 | netifapi_errt_fn errtfunc) 150 | { 151 | struct netifapi_msg msg; 152 | msg.function = do_netifapi_netif_common; 153 | msg.msg.netif = netif; 154 | msg.msg.msg.common.voidfunc = voidfunc; 155 | msg.msg.msg.common.errtfunc = errtfunc; 156 | TCPIP_NETIFAPI(&msg); 157 | return msg.msg.err; 158 | } 159 | 160 | #endif /* LWIP_NETIF_API */ 161 | -------------------------------------------------------------------------------- /lwip/api/tcpip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martin-ger/esp-open-lwip/5157a11da89c2ae8aeca0653c5a44fed7377fde8/lwip/api/tcpip.c -------------------------------------------------------------------------------- /lwip/app/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipapp.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /lwip/app/espconn_mdns.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright 2013-2014 Espressif Systems (Wuxi) 3 | * 4 | * FileName: espconn_mdns.c 5 | * 6 | * Description: udp proto interface 7 | * 8 | * Modification history: 9 | * 2014/3/31, v1.0 create this file. 10 | *******************************************************************************/ 11 | 12 | #include "ets_sys.h" 13 | #include "os_type.h" 14 | 15 | #include "lwip/mdns.h" 16 | 17 | /****************************************************************************** 18 | * FunctionName : espconn_mdns_enable 19 | * Description : join a multicast group 20 | * Parameters : host_ip -- the ip address of udp server 21 | * multicast_ip -- multicast ip given by user 22 | * Returns : none 23 | *******************************************************************************/ 24 | void ICACHE_FLASH_ATTR 25 | espconn_mdns_enable(void) 26 | { 27 | mdns_enable(); 28 | } 29 | /****************************************************************************** 30 | * FunctionName : espconn_mdns_disable 31 | * Description : join a multicast group 32 | * Parameters : host_ip -- the ip address of udp server 33 | * multicast_ip -- multicast ip given by user 34 | * Returns : none 35 | *******************************************************************************/ 36 | void ICACHE_FLASH_ATTR 37 | espconn_mdns_disable(void) 38 | { 39 | mdns_disable(); 40 | } 41 | 42 | /****************************************************************************** 43 | * FunctionName : espconn_mdns_set_hostname 44 | * Description : join a multicast group 45 | * Parameters : host_ip -- the ip address of udp server 46 | * multicast_ip -- multicast ip given by user 47 | * Returns : none 48 | *******************************************************************************/ 49 | void ICACHE_FLASH_ATTR 50 | espconn_mdns_set_hostname(char *name) 51 | { 52 | mdns_set_hostname(name); 53 | } 54 | 55 | /****************************************************************************** 56 | * FunctionName : espconn_mdns_init 57 | * Description : join a multicast group 58 | * Parameters : host_ip -- the ip address of udp server 59 | * multicast_ip -- multicast ip given by user 60 | * Returns : none 61 | *******************************************************************************/ 62 | char* ICACHE_FLASH_ATTR 63 | espconn_mdns_get_hostname(void) 64 | { 65 | return (char *)mdns_get_hostname(); 66 | } 67 | /****************************************************************************** 68 | * FunctionName : espconn_mdns_get_servername 69 | * Description : join a multicast group 70 | * Parameters : info -- the info of mdns 71 | * Returns : none 72 | *******************************************************************************/ 73 | void ICACHE_FLASH_ATTR 74 | espconn_mdns_set_servername(const char *name) 75 | { 76 | mdns_set_servername(name); 77 | } 78 | /****************************************************************************** 79 | * FunctionName : espconn_mdns_get_servername 80 | * Description : join a multicast group 81 | * Parameters : info -- the info of mdns 82 | * Returns : none 83 | *******************************************************************************/ 84 | char* ICACHE_FLASH_ATTR 85 | espconn_mdns_get_servername(void) 86 | { 87 | return (char *)mdns_get_servername(); 88 | } 89 | /****************************************************************************** 90 | * FunctionName : mdns_server_register 91 | * Description : join a multicast group 92 | * Parameters : info -- the info of mdns 93 | * Returns : none 94 | *******************************************************************************/ 95 | void ICACHE_FLASH_ATTR 96 | espconn_mdns_server_register(void) 97 | { 98 | mdns_server_register(); 99 | } 100 | /****************************************************************************** 101 | * FunctionName : mdns_server_register 102 | * Description : join a multicast group 103 | * Parameters : info -- the info of mdns 104 | * Returns : none 105 | *******************************************************************************/ 106 | void ICACHE_FLASH_ATTR 107 | espconn_mdns_server_unregister(void) 108 | { 109 | mdns_server_unregister(); 110 | } 111 | /****************************************************************************** 112 | * FunctionName : espconn_mdns_init 113 | * Description : join a multicast group 114 | * Parameters : host_ip -- the ip address of udp server 115 | * multicast_ip -- multicast ip given by user 116 | * Returns : none 117 | *******************************************************************************/ 118 | void ICACHE_FLASH_ATTR 119 | espconn_mdns_close(void) 120 | { 121 | mdns_close(); 122 | } 123 | /****************************************************************************** 124 | * FunctionName : espconn_mdns_init 125 | * Description : join a multicast group 126 | * Parameters : host_ip -- the ip address of udp server 127 | * multicast_ip -- multicast ip given by user 128 | * Returns : none 129 | *******************************************************************************/ 130 | void ICACHE_FLASH_ATTR 131 | espconn_mdns_init(struct mdns_info *info) 132 | { 133 | mdns_init(info); 134 | } 135 | -------------------------------------------------------------------------------- /lwip/core/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipcore.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /lwip/core/def.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Common functions used throughout the stack. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Simon Goldschmidt 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | #include "lwip/def.h" 41 | 42 | /** 43 | * These are reference implementations of the byte swapping functions. 44 | * Again with the aim of being simple, correct and fully portable. 45 | * Byte swapping is the second thing you would want to optimize. You will 46 | * need to port it to your architecture and in your cc.h: 47 | * 48 | * #define LWIP_PLATFORM_BYTESWAP 1 49 | * #define LWIP_PLATFORM_HTONS(x) 50 | * #define LWIP_PLATFORM_HTONL(x) 51 | * 52 | * Note ntohs() and ntohl() are merely references to the htonx counterparts. 53 | */ 54 | 55 | #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) 56 | 57 | /** 58 | * Convert an u16_t from host- to network byte order. 59 | * 60 | * @param n u16_t in host byte order 61 | * @return n in network byte order 62 | */ 63 | u16_t 64 | lwip_htons(u16_t n) 65 | { 66 | return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); 67 | } 68 | 69 | /** 70 | * Convert an u16_t from network- to host byte order. 71 | * 72 | * @param n u16_t in network byte order 73 | * @return n in host byte order 74 | */ 75 | u16_t 76 | lwip_ntohs(u16_t n) 77 | { 78 | return lwip_htons(n); 79 | } 80 | 81 | /** 82 | * Convert an u32_t from host- to network byte order. 83 | * 84 | * @param n u32_t in host byte order 85 | * @return n in network byte order 86 | */ 87 | u32_t 88 | lwip_htonl(u32_t n) 89 | { 90 | return ((n & 0xff) << 24) | 91 | ((n & 0xff00) << 8) | 92 | ((n & 0xff0000UL) >> 8) | 93 | ((n & 0xff000000UL) >> 24); 94 | } 95 | 96 | /** 97 | * Convert an u32_t from network- to host byte order. 98 | * 99 | * @param n u32_t in network byte order 100 | * @return n in host byte order 101 | */ 102 | u32_t 103 | lwip_ntohl(u32_t n) 104 | { 105 | return lwip_htonl(n); 106 | } 107 | 108 | #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ 109 | -------------------------------------------------------------------------------- /lwip/core/ipv4/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipipv4.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /lwip/core/ipv4/inet.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Functions common to all TCP/IPv4 modules, such as the byte order functions. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/inet.h" 42 | 43 | -------------------------------------------------------------------------------- /lwip/core/ipv4/ip_route.c: -------------------------------------------------------------------------------- 1 | #include "lwip/opt.h" 2 | #include "lwip/ip.h" 3 | 4 | #ifdef IP_ROUTING_TAB 5 | #include "lwip/ip_route.h" 6 | 7 | struct route_entry ip_rt_table[MAX_ROUTES]; 8 | int ip_route_max = 0; 9 | 10 | uint32_t ICACHE_FLASH_ATTR 11 | mask2clidr (ip_addr_t *mask) 12 | { 13 | uint32_t clidr; 14 | 15 | uint32_t m = mask->addr; 16 | for (clidr = 0; m; m <<= 1,clidr++); 17 | return clidr; 18 | } 19 | 20 | bool ICACHE_FLASH_ATTR 21 | ip_add_route(ip_addr_t ip, ip_addr_t mask, ip_addr_t gw) 22 | { 23 | int add_pos, i, j; 24 | 25 | // Remove it if already existing 26 | ip_rm_route(ip, mask); 27 | 28 | if (ip_route_max >= MAX_ROUTES) 29 | return false; 30 | 31 | ip.addr &= mask.addr; 32 | 33 | add_pos = ip_route_max; 34 | for (i = 0; i mask2clidr(&ip_rt_table[i].mask)) { 37 | add_pos = i; 38 | for (j = ip_route_max-1; j >= i; j--) { 39 | ip_rt_table[j+1] = ip_rt_table[j]; 40 | } 41 | break; 42 | } 43 | } 44 | 45 | ip_addr_copy(ip_rt_table[add_pos].ip, ip); 46 | ip_addr_copy(ip_rt_table[add_pos].mask, mask); 47 | ip_addr_copy(ip_rt_table[add_pos].gw, gw); 48 | ip_route_max++; 49 | return true; 50 | } 51 | 52 | bool ICACHE_FLASH_ATTR 53 | ip_rm_route(ip_addr_t ip, ip_addr_t mask) 54 | { 55 | int i; 56 | 57 | for (i = 0; i= ip_route_max) 92 | return false; 93 | 94 | ip_addr_copy(*ip, ip_rt_table[no].ip); 95 | ip_addr_copy(*mask, ip_rt_table[no].mask); 96 | ip_addr_copy(*gw, ip_rt_table[no].gw); 97 | return true; 98 | } 99 | 100 | #endif /* IP_ROUTING_TAB */ 101 | -------------------------------------------------------------------------------- /lwip/core/sys.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Operating System abstraction 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/sys.h" 42 | 43 | /* Most of the functions defined in sys.h must be implemented in the 44 | * architecture-dependent file sys_arch.c */ 45 | 46 | #if !NO_SYS 47 | 48 | /** 49 | * Sleep for some ms. Timeouts are NOT processed while sleeping. 50 | * 51 | * @param ms number of milliseconds to sleep 52 | */ 53 | void 54 | sys_msleep(u32_t ms) 55 | { 56 | if (ms > 0) { 57 | sys_sem_t delaysem; 58 | err_t err = sys_sem_new(&delaysem, 0); 59 | if (err == ERR_OK) { 60 | sys_arch_sem_wait(&delaysem, ms); 61 | sys_sem_free(&delaysem); 62 | } 63 | } 64 | } 65 | 66 | #endif /* !NO_SYS */ 67 | -------------------------------------------------------------------------------- /lwip/core/sys_arch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * copyright (c) 2010 - 2011 espressif system 3 | */ 4 | 5 | #include "c_types.h" 6 | #include "ets_sys.h" 7 | #include "osapi.h" 8 | #include "os_type.h" 9 | 10 | #include "lwip/opt.h" 11 | #include "lwip/sys.h" 12 | 13 | #include "eagle_soc.h" 14 | -------------------------------------------------------------------------------- /lwip/netif/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipnetif.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /lwip/netif/tunif.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct tunif_data { 16 | struct netif netif; 17 | int fd; 18 | int header; 19 | struct event *ev; 20 | u_char buf[4096]; 21 | }; 22 | 23 | //static pcap_dumper_t *pcap_dumper; 24 | 25 | static err_t 26 | tunif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) 27 | { 28 | struct tunif_data *data = netif->state; 29 | int len; 30 | 31 | len = pbuf_copy_partial(p, data->buf, sizeof(data->buf), 0); 32 | #if 0 33 | if (pcap_dumper) { 34 | struct pcap_pkthdr hdr = {.caplen = len, .len = len}; 35 | gettimeofday(&hdr.ts, NULL); 36 | pcap_dump((void *) pcap_dumper, &hdr, data->buf); 37 | } 38 | #endif 39 | len = write(data->fd, data->buf, len); 40 | #if 0 41 | if (len < 0) 42 | LINK_STATS_INC(link.drop); 43 | else 44 | LINK_STATS_INC(link.xmit); 45 | #endif 46 | return 0; 47 | } 48 | 49 | static void 50 | //tunif_ready(evutil_socket_t fd, short events, void *ctx) 51 | tunif_ready(int fd, short events, void *ctx) 52 | { 53 | struct tunif_data *data = ctx; 54 | int ret; 55 | 56 | // ret = read(fd, data->buf, sizeof(data->buf)); 57 | if ((ret < 0 && errno != EAGAIN) || !ret) { 58 | /* FATAL */ 59 | event_del(data->ev); 60 | } else if (ret > 0) { 61 | struct pbuf *p; 62 | p = pbuf_alloc(PBUF_IP, ret, PBUF_POOL); 63 | #if 0 64 | if (!p) { 65 | LINK_STATS_INC(link.memerr); 66 | LINK_STATS_INC(link.drop); 67 | return; 68 | } 69 | LINK_STATS_INC(link.recv); 70 | if (pcap_dumper) { 71 | struct pcap_pkthdr hdr = {.caplen = ret, .len = ret}; 72 | gettimeofday(&hdr.ts, NULL); 73 | pcap_dump((void *) pcap_dumper, &hdr, data->buf); 74 | } 75 | #endif 76 | pbuf_take(p, data->buf, ret); 77 | if (data->netif.input(p, &data->netif) < 0) 78 | pbuf_free(p); 79 | } 80 | } 81 | 82 | static err_t 83 | tunif_init(struct netif *netif) 84 | { 85 | NETIF_INIT_SNMP(netif, snmp_ifType_other, 0); 86 | netif->name[0] = 't'; 87 | netif->name[1] = 'p'; 88 | 89 | netif->output = tunif_output; 90 | netif->mtu = 1360; 91 | netif->flags = NETIF_FLAG_LINK_UP; 92 | 93 | return 0; 94 | } 95 | 96 | struct tunif_data * 97 | tunif_add(struct event_base *base, int fd, int header) 98 | { 99 | struct tunif_data *data; 100 | #if 0 101 | const char *pcap = getenv("TUNIF_PCAP_FILE"); 102 | 103 | if (pcap && !pcap_dumper) { 104 | pcap_t *p; 105 | p = pcap_open_dead(DLT_RAW, 2000); 106 | pcap_dumper = pcap_dump_open(p, pcap); 107 | } 108 | #endif 109 | 110 | data = calloc(1, sizeof(*data)); 111 | data->fd = fd; 112 | // data->header = header; 113 | // data->ev = event_new(base, fd, EV_READ | EV_PERSIST, tunif_ready, data); 114 | event_add(data->ev, NULL); 115 | netif_add(&data->netif, NULL, NULL, NULL, data, tunif_init, ip_input); 116 | netif_set_default(&data->netif); 117 | return data; 118 | } 119 | 120 | void 121 | tunif_del(struct tunif_data *data) 122 | { 123 | netif_remove(&data->netif); 124 | event_del(data->ev); 125 | event_free(data->ev); 126 | free(data); 127 | } 128 | 129 | void 130 | tunif_set_ipaddr(struct tunif_data *data, uint32_t addr) 131 | { 132 | ip_addr_t ipaddr; 133 | ipaddr.addr = addr; 134 | netif_set_ipaddr(&data->netif, &ipaddr); 135 | } 136 | 137 | void 138 | tunif_set_netmask(struct tunif_data *data, uint32_t addr) 139 | { 140 | ip_addr_t ipaddr; 141 | ipaddr.addr = addr; 142 | netif_set_netmask(&data->netif, &ipaddr); 143 | } 144 | 145 | void 146 | tunif_set_gw(struct tunif_data *data, uint32_t addr) 147 | { 148 | ip_addr_t ipaddr; 149 | ipaddr.addr = addr; 150 | netif_set_gw(&data->netif, &ipaddr); 151 | } 152 | 153 | void 154 | tunif_set_up(struct tunif_data *data) 155 | { 156 | netif_set_up(&data->netif); 157 | } 158 | 159 | void 160 | tunif_set_down(struct tunif_data *data) 161 | { 162 | netif_set_down(&data->netif); 163 | } 164 | 165 | void 166 | tunif_set_mtu(struct tunif_data *data, int mtu) 167 | { 168 | data->netif.mtu = mtu; 169 | } 170 | 171 | void 172 | tunif_set_flag(struct tunif_data *data, int flag) 173 | { 174 | data->netif.flags |= flag; 175 | } 176 | 177 | void 178 | tunif_clear_flag(struct tunif_data *data, int flag) 179 | { 180 | data->netif.flags &= ~flag; 181 | } 182 | 183 | static int dns_count; 184 | 185 | void 186 | tunif_clear_dns(void) 187 | { 188 | ip_addr_t addr; 189 | // addr.addr = INADDR_ANY; 190 | int i; 191 | for (i = 0; i < DNS_MAX_SERVERS; i++) 192 | dns_setserver(i, &addr); 193 | dns_count = 0; 194 | } 195 | 196 | void 197 | tunif_add_dns(uint32_t addr) 198 | { 199 | ip_addr_t ipaddr; 200 | ipaddr.addr = addr; 201 | dns_setserver(dns_count++, &ipaddr); 202 | } 203 | -------------------------------------------------------------------------------- /user/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libuser.a 16 | endif 17 | 18 | 19 | ############################################################# 20 | # Configuration i.e. compile options etc. 21 | # Target specific stuff (defines etc.) goes in here! 22 | # Generally values applying to a tree are captured in the 23 | # makefile at its root level - these are then overridden 24 | # for a subtree within the makefile rooted therein 25 | # 26 | #DEFINES += 27 | 28 | ############################################################# 29 | # Recursion Magic - Don't touch this!! 30 | # 31 | # Each subtree potentially has an include directory 32 | # corresponding to the common APIs applicable to modules 33 | # rooted at that subtree. Accordingly, the INCLUDE PATH 34 | # of a module can only contain the include directories up 35 | # its parent path, and not its siblings 36 | # 37 | # Required for each makefile to inherit from the parent 38 | # 39 | 40 | INCLUDES := $(INCLUDES) -I $(PDIR)include 41 | INCLUDES += -I ./ 42 | INCLUDES += -I ../../rom/include 43 | INCLUDES += -I ../../include/ets 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /user/user_main.c: -------------------------------------------------------------------------------- 1 | #include "ets_sys.h" 2 | #include "user_interface.h" 3 | 4 | void ICACHE_FLASH_ATTR 5 | user_init(void) 6 | { 7 | } 8 | --------------------------------------------------------------------------------