├── Makefile ├── README.markdown ├── compile_and_flash.sh ├── disas ├── app.out ├── callstack ├── data ├── disas ├── net80211 │ ├── _ieee80211.h │ ├── ieee80211.c │ ├── ieee80211_crypto.c │ ├── ieee80211_ht.c │ ├── ieee80211_proto.c │ ├── ieee80211_scan.c │ ├── ieee80211_var.h │ └── temp │ │ ├── ieee80211_output_pbuf.c │ │ └── net80211.c ├── pp │ ├── esf_buf.c │ ├── lmac.c │ ├── old │ │ ├── old_wdev.c │ │ ├── old_wdev2.c │ │ ├── old_wdev3.c │ │ ├── old_wdev4.c │ │ ├── old_wdev5.c │ │ └── wdev.h │ ├── pp.c │ ├── trc.c │ └── wdev.c ├── ppTxPkt └── wifi │ ├── wifi_promiscuous.c │ └── wifi_set_opmode.c ├── include ├── api.h ├── api_msg.h ├── arch.h ├── arch │ ├── cc.h │ ├── perf.h │ └── sys_arch.h ├── autoip.h ├── debug.h ├── def.h ├── dhcp.h ├── dns.h ├── driver │ ├── gpio16.h │ ├── i2c_master.h │ ├── key.h │ ├── pwm.h │ ├── spi.h │ ├── spi_register.h │ ├── uart.h │ └── uart_register.h ├── err.h ├── icmp.h ├── igmp.h ├── inet.h ├── inet_chksum.h ├── init.h ├── ip.h ├── ip_addr.h ├── ip_frag.h ├── lwip │ ├── .pbuf.h.swp │ ├── api.h │ ├── api_msg.h │ ├── app │ │ ├── dhcpserver.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 │ ├── mem.h │ ├── memp.h │ ├── memp_std.h │ ├── netbuf.h │ ├── netdb.h │ ├── netif.h │ ├── netifapi.h │ ├── opt.h │ ├── pbuf.h │ ├── raw.h │ ├── sio.h │ ├── snmp.h │ ├── snmp_asn1.h │ ├── snmp_msg.h │ ├── snmp_structs.h │ ├── sockets.h │ ├── stats.h │ ├── sys.h │ ├── tcp.h │ ├── tcp_impl.h │ ├── tcpip.h │ ├── timers.h │ └── udp.h ├── lwipopts.h ├── mem.h ├── mem_manager.h ├── memp.h ├── memp_std.h ├── netbuf.h ├── netdb.h ├── netif.h ├── netif │ ├── etharp.h │ ├── if_llc.h │ ├── ppp_oe.h │ └── wlan_lwip_if.h ├── netifapi.h ├── opt.h ├── pbuf.h ├── pp │ └── esf_buf.h ├── raw.h ├── sio.h ├── snmp.h ├── snmp_asn1.h ├── snmp_msg.h ├── snmp_structs.h ├── sockets.h ├── ssl │ ├── app │ │ ├── espconn_secure.h │ │ └── espconn_ssl.h │ ├── cert.h │ ├── private_key.h │ ├── ssl_bigint.h │ ├── ssl_bigint_impl.h │ ├── ssl_cert.h │ ├── ssl_config.h │ ├── ssl_crypto.h │ ├── ssl_crypto_misc.h │ ├── ssl_os_int.h │ ├── ssl_os_port.h │ ├── ssl_private_key.h │ ├── ssl_ssl.h │ ├── ssl_tls1.h │ └── ssl_version.h ├── stats.h ├── sys.h ├── tcp.h ├── tcp_impl.h ├── tcpip.h ├── timers.h ├── udp.h ├── user_config.h ├── user_devicefind.h ├── user_esp_platform.h ├── user_esp_platform_timer.h ├── user_iot_version.h ├── user_json.h ├── user_light.h ├── user_plug.h ├── user_sensor.h └── user_webserver.h └── user ├── empty_user_rf_pre_init.c ├── header.h ├── tests ├── raw_packets ├── success └── success2 ├── user_config.h ├── user_main.c ├── wifi_raw.c └── wifi_raw.h /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for ESP8266 projects 2 | # 3 | # Thanks to: 4 | # - zarya 5 | # - Jeroen Domburg (Sprite_tm) 6 | # - Christian Klippel (mamalala) 7 | # - Tommie Gannert (tommie) 8 | # 9 | # Changelog: 10 | # - 2014-10-06: Changed the variables to include the header file directory 11 | # - 2014-10-06: Added global var for the Xtensa tool root 12 | # - 2014-11-23: Updated for SDK 0.9.3 13 | # - 2014-12-25: Replaced esptool by esptool.py 14 | 15 | # Output directors to store intermediate compiled files 16 | # relative to the project directory 17 | BUILD_BASE = build 18 | FW_BASE = firmware 19 | 20 | # base directory for the compiler 21 | XTENSA_TOOLS_ROOT ?= /opt/esp-open-sdk/xtensa-lx106-elf/bin 22 | 23 | # base directory of the ESP8266 SDK package, absolute 24 | SDK_BASE ?= /opt/esp-open-sdk/sdk 25 | 26 | # esptool.py path and port 27 | ESPTOOL ?= esptool.py 28 | ESPPORT ?= /dev/ttyUSB0 29 | 30 | # name for the target project 31 | TARGET = app 32 | 33 | # which modules (subdirectories) of the project to include in compiling 34 | MODULES = driver user 35 | EXTRA_INCDIR = include 36 | 37 | # libraries used in this project, mainly provided by the SDK 38 | LIBS = c gcc hal pp phy net80211 lwip wpa main 39 | 40 | # compiler flags using during compilation of source files 41 | CFLAGS = -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH 42 | 43 | # linker flags used to generate the main object file 44 | LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,-wrap=ppEnqueueRxq -Wl,-wrap=ppTxPkt 45 | 46 | # linker script used for the above linkier step 47 | LD_SCRIPT = eagle.app.v6.ld 48 | 49 | # various paths from the SDK used in this project 50 | SDK_LIBDIR = lib 51 | SDK_LDDIR = ld 52 | SDK_INCDIR = include include/json 53 | 54 | # we create two different files for uploading into the flash 55 | # these are the names and options to generate them 56 | FW_FILE_1_ADDR = 0x00000 57 | FW_FILE_2_ADDR = 0x40000 58 | 59 | # select which tools to use as compiler, librarian and linker 60 | CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc 61 | AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar 62 | LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc 63 | 64 | 65 | 66 | #### 67 | #### no user configurable options below here 68 | #### 69 | SRC_DIR := $(MODULES) 70 | BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES)) 71 | 72 | SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR)) 73 | SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR)) 74 | 75 | SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) 76 | OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC)) 77 | LIBS := $(addprefix -l,$(LIBS)) 78 | APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) 79 | TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) 80 | 81 | LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT)) 82 | 83 | INCDIR := $(addprefix -I,$(SRC_DIR)) 84 | EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) 85 | MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) 86 | 87 | FW_FILE_1 := $(addprefix $(FW_BASE)/,$(FW_FILE_1_ADDR).bin) 88 | FW_FILE_2 := $(addprefix $(FW_BASE)/,$(FW_FILE_2_ADDR).bin) 89 | 90 | V ?= $(VERBOSE) 91 | ifeq ("$(V)","1") 92 | Q := 93 | vecho := @true 94 | else 95 | Q := @ 96 | vecho := @echo 97 | endif 98 | 99 | vpath %.c $(SRC_DIR) 100 | 101 | define compile-objects 102 | $1/%.o: %.c 103 | $(vecho) "CC $$<" 104 | $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ 105 | endef 106 | 107 | .PHONY: all checkdirs flash clean 108 | 109 | all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2) 110 | 111 | $(FW_BASE)/%.bin: $(TARGET_OUT) | $(FW_BASE) 112 | $(vecho) "FW $(FW_BASE)/" 113 | $(Q) $(ESPTOOL) elf2image -o $(FW_BASE)/ $(TARGET_OUT) 114 | 115 | $(TARGET_OUT): $(APP_AR) 116 | $(vecho) "LD $@" 117 | $(Q) $(LD) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@ 118 | 119 | $(APP_AR): $(OBJ) 120 | $(vecho) "AR $@" 121 | $(Q) $(AR) cru $@ $^ 122 | 123 | checkdirs: $(BUILD_DIR) $(FW_BASE) 124 | 125 | $(BUILD_DIR): 126 | $(Q) mkdir -p $@ 127 | 128 | $(FW_BASE): 129 | $(Q) mkdir -p $@ 130 | 131 | flash: $(FW_FILE_1) $(FW_FILE_2) 132 | $(ESPTOOL) --port $(ESPPORT) write_flash $(FW_FILE_1_ADDR) $(FW_FILE_1) $(FW_FILE_2_ADDR) $(FW_FILE_2) 133 | 134 | clean: 135 | $(Q) rm -rf $(FW_BASE) $(BUILD_BASE) 136 | 137 | $(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir)))) 138 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | This is an experiment attempting to send and receive raw IEEE-802.11 packets from the ESP8266. 2 | 3 | This is currently a dirty hack, and not quite perfect. 4 | 5 | DISCLAIMER: THIS IS A PROOF OF CONCEPT ONLY. USE AT YOUR OWN RISK! 6 | 7 | The code in this project was compiled and linked against the esp_iot_sdk_v1.2.0. and also works with esp_iot_sdk_v0.9.3. 8 | 9 | SENDING 10 | -------- 11 | 12 | Currently, one can set the bytes 0, 1, and 4, 5, ..., etc of the frame to any arbitrary value. 13 | But the bytes 2 and 3 (Duration ID in a normal IEEE-802.11 frame) are somehow overwritten 14 | by the lower level driver functions, and appear to be always zero. 15 | 16 | Also, the length of the packet as sent over the air does not always correspond 17 | to the length of the buffer given as input. The lower layer functions appear to be allocating 18 | enough memory for the whole IEEE-802.11 frame, and these additional bytes will be sent even if 19 | our actual buffer is shorter... But we do not yet understand what goes on below. 20 | 21 | Another issue is that the method only works when the ESP is in SOFTAP_MODE. 22 | In STATION_MODE, the eagle_lwip_getif function may crash, or the ieee80211_output_pbuf function 23 | may return an error. We don't know why. 24 | 25 | 26 | RECEIVING 27 | --------- 28 | 29 | ~~The method currently allows the device to enter in monitor mode, and sniff every packet 30 | that can be found in the air, including control and management frames. There are no 31 | limitations on the packet size as in the official sniffer APIs. You have access to 32 | the complete frame.~~ 33 | 34 | Make sure you are listening in the correct channel and PHY mode. 35 | Note that the ESP8266 does not seem to support the 5GHz wifi. 36 | 37 | Update: It turns out the method only sniffs frames which are broadcast or directed to 38 | the device's own MAC address. It is not in promiscuous mode, so it can't receive 39 | all packets sent over the air. It does receive the complete frames for packets 40 | that are actually processed by the driver. If we set the device to promiscuous 41 | mode (using wifi_enable_promiscuous(1)) the callback we set up does not get called anymore. 42 | It seems promiscuous mode is dealt with differently, and the hardware may not be able 43 | to give the complete frames in this mode... 44 | 45 | This can be thought of as a proof of concept, but there is still 46 | a lot to work on. We don't know if we'll have the patience or ability to do so... 47 | 48 | REVERSE ENGINEERING 49 | ------------------- 50 | 51 | I have started some work on reverse-engineering the wifi stack of the ESP8266. 52 | Currently I have been focusing on the libpp.a library, and have decompiled 53 | most of the important functions from wdev.c, and started a little bit on lmac.c 54 | 55 | This is a tedious and error-prone process, so there might be mistakes creeping 56 | here and there. Please let me know if you find something interesting. 57 | 58 | 59 | NOTES 60 | ----- 61 | 62 | Update: Better method for hooking into ppEnqueueRxq and ppTxPkt https://github.com/ernacktob/esp8266_wifi_raw/issues/1 63 | 64 | This program requires a modified libnet80211 and libpp library, which we called libnet80211_2.a and libpp2.a. 65 | The modified libraries can be seen in the lib/ folder. 66 | 67 | The modified net80211 library has its symbol table changed so that all references to ppTxPkt 68 | are replaced with a dummy function called 'aaTxPkt' defined in user_main.c. 69 | A simple way to do this is to go in the `/opt/esp_open_sdk/sdk/lib/` folder, and do 70 | 71 | `sed s/ppTxPkt/aaTxPkt/g libnet80211.a > libnet80211_2.a` 72 | 73 | The libpp2.a library is a modified libpp.a library where the *undefined* references to ppEnqueueRxq 74 | are replaced to references to aaEnqueueRxq. There will be one ppEnqueueRxq symbol corresponding to 75 | the actual function definition, and this one should not be changed. Follow these steps: 76 | 77 | `sed s/ppTxPkt/aaTxPkt/g2 libpp.a > libpp2.a` 78 | 79 | The Makefile must also be modified to link to net80211_2 and pp2 instead of net80211 and pp. 80 | Use `make -f Makefile2` to build, or run the `./compile_and_flash` script (pass the port as a command line argument). 81 | 82 | The makefile is modified in order to wrap the ppTxPkt and ppEnqueueRxq functions (see LDFLAGS). -------------------------------------------------------------------------------- /compile_and_flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PORT=$1 4 | make clean 5 | make 6 | 7 | until sudo -E env "PATH=$PATH" make flash ESPPORT=$PORT; do 8 | sleep 1 9 | done 10 | 11 | sudo screen $PORT 115200 12 | -------------------------------------------------------------------------------- /disas/app.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/disas/app.out -------------------------------------------------------------------------------- /disas/callstack: -------------------------------------------------------------------------------- 1 | call_user_start 2 | call_user_start_local 3 | _0x401004e4 4 | _0x40240368 5 | _0x40240024 <_irom0_text_start+0x24> 6 | 7 | This function calls: 8 | ieee80211_phy_init 9 | lmacInit 10 | wDev_Initialize 11 | pp_attach 12 | ieee80211_ifattach 13 | pm_attach 14 | cnx_attach 15 | wDevEnableRx 16 | 17 | 18 | When sending packets: 19 | ieee80211_output_pbuf 20 | ebuf = esf_buf_alloc(pbuf, 1) 21 | ppTxPkt(ebuf) 22 | pp_post 23 | task with priority 32 24 | ppProcessTxQ 25 | lmacTxFrame 26 | wDev_EnableTransmit 27 | 28 | When receiving frames: 29 | wDev_ProcessFiq (created by ets_isr_attach in _0x40240024) 30 | erxbuf = esf_rx_buf_alloc(...) 31 | lmacRxDone(erxbuf) 32 | pp_post(5) 33 | task with priority 32 34 | sta_input / hostap_input etc. 35 | -------------------------------------------------------------------------------- /disas/net80211/_ieee80211.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 802.11g/802.11n protection mode. 3 | */ 4 | enum ieee80211_protmode { 5 | IEEE80211_PROT_NONE = 0, /* no protection */ 6 | IEEE80211_PROT_CTSONLY = 1, /* CTS to self */ 7 | IEEE80211_PROT_RTSCTS = 2, /* RTS-CTS */ 8 | }; 9 | -------------------------------------------------------------------------------- /disas/net80211/ieee80211.c: -------------------------------------------------------------------------------- 1 | /* 0x402502cc */ 2 | void ICACHE_FLASH_ATTR ieee80211_ifattach(struct ieee80211com *ic) 3 | { 4 | _0x4025023c(ic); 5 | 6 | *(uint16 *)((uint8 *)ic + 40) = 100; /* ic->ic_bintval or ic->ic_txpowlimit */ 7 | ieee80211_crypto_attach(ic); 8 | ieee80211_proto_attach(ic); 9 | 10 | $a4 = (uint8 *)ic + 0x500; 11 | $a2 = *(uint32 *)((uint8 *)$a4 + 44); 12 | *(uint32 *)((uint8 *)$a4 + 28) = 0; 13 | 14 | if ($a2 == 3) 15 | ieee80211_ht_attach(ic); 16 | 17 | chm_init(&g_ic); 18 | ieee80211_scan_attach(ic); 19 | } 20 | -------------------------------------------------------------------------------- /disas/net80211/ieee80211_crypto.c: -------------------------------------------------------------------------------- 1 | /* 0x402505c8 */ 2 | void ICACHE_FLASH_ATTR ieee80211_crypto_attach(struct ieee80211com *ic) 3 | { 4 | return; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /disas/net80211/ieee80211_ht.c: -------------------------------------------------------------------------------- 1 | /* 0x402517e0 */ 2 | void ICACHE_FLASH_ATTR ieee80211_ht_attach(struct ieee80211com *ic) 3 | { 4 | $a4 = (uint8 *)ic + 0x4a6; 5 | $a5 = (uint8 *)ic + 0x2bc; 6 | 7 | *(uint32 *)((uint8 *)$a5 + 0x260) = 0x04080000; 8 | $a5 += 0x200; 9 | 10 | *(uint16 *)((uint8 *)$a5 + 102) = 28; 11 | *(uint16 *)((uint8 *)$a5 + 104) = 0; 12 | *(uint16 *)((uint8 *)$a5 + 100) = 0x110c; 13 | *(uint8 *)((uint8 *)$a4 + 128) = 1; 14 | *(uint8 *)((uint8 *)$a4 + 129) = 1; 15 | 16 | ieee80211_recv_action_register(3, 0, _0x40252064); 17 | ieee80211_send_action_register(3, 1, _0x402520d8); 18 | } 19 | -------------------------------------------------------------------------------- /disas/net80211/ieee80211_proto.c: -------------------------------------------------------------------------------- 1 | /* 0x402545a0 */ 2 | void ICACHE_FLASH_ATTR ieee80211_proto_attach(struct ieee80211com *ic) 3 | { 4 | ic->ic_protmode = IEEE80211_PROT_CTSONLY; 5 | *(uint32 *)((uint8 *)ic + 28) |= 0x00040000; 6 | ppRegisterTxCallback(ieee80211_tx_mgt_cb, 2); /* same as ieee80211_add_callback ? */ 7 | } 8 | -------------------------------------------------------------------------------- /disas/net80211/ieee80211_scan.c: -------------------------------------------------------------------------------- 1 | /* 0x40254704 */ 2 | void ICACHE_FLASH_ATTR ieee80211_scan_attach(struct ieee80211com *ic) 3 | { 4 | *(uint32 *)((uint8 *)ic + 4) = &gScanStruct; 5 | *(uint32 *)((uint8 *)&gScanStruct + 52) = 120; 6 | *(uint32 *)((uint8 *)&gScanStruct + 56) = 120; 7 | *(uint32 *)((uint8 *)&gScanStruct + 60) = 0x168; 8 | *(uint8 *)((uint8 *)&gScanStruct + 155) = 0xff; 9 | 10 | ets_timer_setfn((uint8 *)&gScanStruct + 8, _0x40254df0, 0); 11 | ets_timer_setfn((uint8 *)&gScanStruct + 28, _0x40254de0, 0); 12 | 13 | *(uint32 *)((uint8 *)ic + 0x1d0) = NULL; 14 | *(uint32 *)((uint8 *)ic + 0x1d4) = (uint8 *)ic + 0x1d0; 15 | } 16 | -------------------------------------------------------------------------------- /disas/net80211/ieee80211_var.h: -------------------------------------------------------------------------------- 1 | struct ieee80211com { 2 | enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ /* @12 */ 3 | }; 4 | -------------------------------------------------------------------------------- /disas/pp/lmac.c: -------------------------------------------------------------------------------- 1 | /* 0x401011e4 */ 2 | bool lmacIsActive() 3 | { 4 | /* 0x3ffe8e50 = &lmacConfMib - 0x4 */ 5 | if (((uint8 *)&lmacConfMib)[-0x4] < 8) 6 | return true; 7 | 8 | return false; 9 | } 10 | 11 | /* 0x401011f8 */ 12 | bool lmacIsIdle(uint8 sig) 13 | { 14 | $a4 = *(uint8 *)((uint8 *)0x3ffe8e80 + 36 * $a2 + 17); 15 | 16 | if ($a4 == 0) 17 | return true; 18 | 19 | return false; 20 | } 21 | 22 | static void _0x401012ac() 23 | { 24 | // stub. Might be important 25 | } 26 | 27 | /* 0x40102398 */ 28 | void lmacProcessRtsStart(uint8 arg1) 29 | { 30 | /* 0x3ffe8e50 = &lmacConfMib - 0x4 */ 31 | ((uint8 *)&lmacConfMib)[-0x4] = arg1; 32 | } 33 | 34 | /* 0x401024cc */ 35 | void lmacTxFrame(uint8 *arg1, uint8 arg2) 36 | { 37 | $a2 = arg1; 38 | $a3 = arg2; 39 | 40 | $a12 = (uint8 *)&lmacConfMib + 44 + 36 * arg2; 41 | $a0 = ((uint8 *)&lmacConfMib + 44 + 36 * arg2)[17]; 42 | 43 | if ($a0 == 0 || $a0 == 3) { 44 | ((uint8 **)&lmacConfMib + 11 + 9 * arg2)[0] = arg1; 45 | 46 | if (arg1 == NULL) { 47 | ets_printf("%s %u\n", "lmac.c", 1519); 48 | while (1); 49 | } 50 | 51 | $a5 = ((uint16 *)arg1)[10] + ((uint16 *)arg1)[11]; 52 | $a6 = ((uint32 **)arg1)[9]; 53 | $a3 = ((uint32 **)arg1)[9][0]; 54 | $a4 = ((uint16 *)&lmacConfMib)[5]; 55 | 56 | if (($a4 < $a5) && !($a3 & (1 << 7))) { 57 | /* Set bit 14 of $a3, clear bit 18 of $a3. 58 | Done in a convoluted way by the compiler. */ 59 | ((uint32 **)arg1)[9][0] |= (1 << 14); 60 | ((uint32 **)arg1)[9][0] &= 0xfffbffff; 61 | } 62 | 63 | /* Again, this this was done in a convoluted way by the compiler, 64 | perhaps for optimization or processor quirks...? */ 65 | if ($a3 & (1 << 18)) { 66 | $a9 = ((uint8 *)&lmacConfMib + 44 + 36 * arg2)[17]; 67 | 68 | if ($a9 == 3) { 69 | if ((((uint8 **)arg1)[9][4] >> 4) >= 3) { 70 | $a5 = ((uint8 **)arg1)[9][5]; 71 | $a11 = ($a5 & 0x3f) << 6; 72 | $a10 = (((uint8 **)arg1)[9][6] << 8) | ((uint8 **)arg1)[9][5]; 73 | $a10 &= 0x0000f03f; 74 | $a10 |= $a11; 75 | ((uint8 **)arg1)[9][5] = $a10; 76 | ((uint8 **)arg1)[9][6] = $a10 >> 8; 77 | ((uint32 **)arg1)[9][0] |= (1 << 14); 78 | ((uint32 **)arg1)[9][0] &= 0xfffbffff; 79 | ((uint8 **)arg1)[9][5] &= 0xc0; 80 | } 81 | } 82 | } 83 | 84 | _0x401012ac($a12, 0); /* */ 85 | } else if ($a0 == 4) { 86 | if (arg1 != ((uint8 **)&lmacConfMib + 11 + 9 * arg2)[0]) { 87 | ets_printf("%s %u\n", "lmac.c", 1514); 88 | while (1); 89 | } 90 | } else { 91 | ets_printf("%s %u\n", "lmac.c", 1511); 92 | while (1); 93 | } 94 | 95 | $a7 = ((uint8 *)$a12)[6]; 96 | $a5 = (1 << $a7) - 1; 97 | $a4 = ((volatile uint32 *)0x3ff20e00)[17] & $a5; 98 | ((uint8 *)$a12)[17] = 1; 99 | $a4 &= 0xffff; 100 | wDev_EnableTransmit(((uint8 *)$a12)[4], ((uint8 *)$a12)[5], $a4); 101 | } 102 | 103 | /* 0x40102680 */ 104 | void lmacRxDone(void *arg1) 105 | { 106 | ppEnqueueRxq(arg1); 107 | pp_post(5); 108 | } 109 | 110 | /* 0x40101694 */ 111 | void lmacProcessTXStartData(uint8 arg1) 112 | { 113 | uint8 a5; /* $a5 */ 114 | 115 | a5 = arg1; 116 | 117 | if (arg1 == 10) 118 | a5 = ((uint8 *)&lmacConfMib)[-0x4]; 119 | 120 | if (a5 >= 8) { 121 | ets_printf("%s %u\n", "lmac.c", 559); 122 | while (1); 123 | } 124 | 125 | $a0 = (uint8 *)&lmacConfMib + 44 + 36 * a5; 126 | 127 | if (((uint8 *)$a0)[17] != 1) { 128 | ets_printf("%s %u\n", "lmac.c", 567); 129 | while (1); 130 | } 131 | 132 | ((uint8 *)&lmacConfMib)[-0x4] = a5; 133 | 134 | if (arg1 == 10) { 135 | _0x40101254($a0, ((uint8 *)&lmacConfMib)[40]); /* */ 136 | ((uint32 *)&lmacConfMib)[8] = 0; 137 | } 138 | 139 | if (((uint32 *)$a0)[0] == 0) { 140 | ets_printf("%s %u\n", "lmac.c", 575); 141 | while (1); 142 | } 143 | 144 | ((uint8 *)$a0)[17] = 2; 145 | 146 | _0x40101728($a0); /* */ 147 | lmacProcessCollisions(); 148 | } 149 | -------------------------------------------------------------------------------- /disas/pp/old/wdev.h: -------------------------------------------------------------------------------- 1 | #ifndef wdev_h 2 | #define wdev_h 3 | 4 | struct _wdev_ctrl_sub1 { 5 | unsigned:12 f_b0; /* length of the sniffer_buf ? */ 6 | unsigned:12 f_b12; 7 | unsigned:8 f_b24; /* last packet in queue? */ 8 | struct sniffer_buf *f_4; /* the sniffer buf data */ 9 | struct _wdev_ctrl_sub1 *f_8; /* pointer to next element in queue? */ 10 | }; 11 | 12 | /* total size of this struct should be 4 bytes */ 13 | struct _wdev_ctrl_sub3 { 14 | unsigned:8 f_b0; /* Thing that should be 0 or between 224 and 252 */ 15 | unsigned:12 f_b8; /* length field? */ 16 | unsigned:12 f_b20; 17 | }; 18 | 19 | /* This might actually be the same as struct _wdev_ctrl_sub1. 20 | There are cases where a pointer to one is used as pointer to the other. 21 | The only difference between these structs is that f_4 is a sniffer_buf 22 | or a pointer to an array of _wdev_ctrl_sub3. */ 23 | struct _wdev_ctrl_sub2 { 24 | unsigned:12 f_b0; 25 | unsigned:12 f_b12; /* length field ?*/ 26 | unsigned:8 f_b24; 27 | struct _wdev_ctrl_sub3 *f_4; /* Points to an array of these structs */ 28 | struct _wdev_ctrl_sub2 *f_8; /* pointer to next element in queue? */ 29 | }; 30 | 31 | /* It is possible that some of the fields are part of separate structs 32 | which have been declared as static, and are thus not associated with 33 | a name in the symbol table. I can't really determine this, so for 34 | now, every field referenced relatively to wDevCtrl is assumed to be 35 | a subfield of this hypothetical _wdev_ctrl struct. This remark 36 | also applies to most of the other struct reconstructions and pointer casts. */ 37 | struct _wdev_ctrl { 38 | /* stub... most of the fields I have no idea what they mean */ 39 | uint16 f_0; /* some counter ? */ 40 | uint16 f_2; /* other counter ? */ 41 | uint8 f_4; /* counter or flag? */ 42 | uint8 f_5; /* whether in promiscuous mode or not */ 43 | struct _wdev_ctrl_sub1 *f_8; /* possibly a queue for sniffer bufs */ 44 | struct _wdev_ctrl_sub1 *f_12; 45 | struct _wdev_ctrl_sub1 *f_16; /* also a queue, move from here to f_8 */ 46 | struct _wdev_ctrl_sub1 *f_20; 47 | 48 | struct _wdev_ctrl_sub1 f_24; /* This could be a static struct... */ 49 | 50 | struct _wdev_ctrl_sub2 *f_48; 51 | struct _wdev_ctrl_sub2 *f_52; 52 | uint32 f_356; /* counts number of full packets? */ 53 | // bunch of counters, I'll add them later 54 | // other fields... 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /disas/pp/trc.c: -------------------------------------------------------------------------------- 1 | /* 0x40103478 */ 2 | void rcGetSched(void *arg1, struct _ebuf_sub1 *ep) 3 | { 4 | struct _ebuf_sub1 *a1_8; 5 | 6 | $a12 = arg1; 7 | $a2 = ep; 8 | 9 | if (arg1 == NULL || *(uint32 *)((uint8 *)arg1 + 96) == 0) { 10 | $a3 = ep->data[0]; 11 | $a0 = *(uint32 *)0x40103464; /* 0x3ffe80d4 */ 12 | 13 | if (!($a3 & 0x01)) 14 | $a0 = *(uint32 *)0x4010346c; /* 0x3ffe8194 */ 15 | } else { 16 | $a0 = *(uint32 *)((uint8 *)ep + 0); 17 | $a3 = $a0 << 6; 18 | 19 | if ($a0 & (1 << 7)) { 20 | $a0 = *(uint32 *)((uint8 *)arg1 + 100); 21 | } else { 22 | a1_8 = $a2; 23 | 24 | if ($a0 & (1 << 9)) { 25 | $a2 = arg1; 26 | _0x4010377c(arg1); /* */ 27 | $a2 = a1_8; 28 | $a0 = *(uint32 *)((uint8 *)arg1 + 96); 29 | $a4 = *(uint32 *)(ep->data + 0); 30 | $a5 = 0x00001000; 31 | $a3 = $a4 & 0x3f; 32 | $a4 >>= 6; 33 | $a4 |= $a5; 34 | $a4 <<= 6; 35 | $a3 |= $a4; 36 | *(uint32 *)(ep->data + 0) = $a3; 37 | } else { 38 | $a5 = 0x00200800; 39 | 40 | if (!($a5 & $a3)) { 41 | $a0 = *(uint32 *)((uint8 *)arg1 + 100); 42 | } else { 43 | $a6 = *(uint32 *)((uint8 *)arg1 + 92); 44 | $a0 = *(uint32 *)0x40103474; /* 0x3ffe8070 */ 45 | 46 | if ($a6 == 0) 47 | $a0 = *(uint32 *)((uint8 *)arg1 + 100); 48 | } 49 | } 50 | } 51 | } 52 | 53 | a1_8 = $a2; 54 | *(uint32 *)(ep->data + 20) = $a0; 55 | 56 | if ($a0 == 0) { 57 | os_printf_plus("==dl\n"); 58 | $a2 = a1_8; 59 | } 60 | 61 | if (arg1 == NULL) { 62 | $a0 = *(uint32 *)(ep->data + 20); 63 | $a0 = *(uint8 *)((uint8 *)$a0 + 0); 64 | } else { 65 | $a4 = *(uint8 *)((uint8 *)arg1 + 20); 66 | $a0 = *(uint8 *)((uint8 *)arg1 + 7); 67 | 68 | if (!($a4 & (1 << 6))) { 69 | $a0 = *(uint32 *)(ep->data + 20); 70 | $a0 = *(uint8 *)((uint8 *)$a0 + 0); 71 | } else { 72 | $a5 = *(uint32 *)(ep->data + 0); 73 | 74 | if (!($a5 & (1 << 9))) { 75 | $a0 = *(uint32 *)(ep->data + 20); 76 | $a0 = *(uint8 *)((uint8 *)$a0 + 0); 77 | } 78 | } 79 | } 80 | 81 | ep->data[8] = $a0; 82 | } 83 | 84 | static void _0x4010377c(void *arg1) 85 | { 86 | 87 | } 88 | -------------------------------------------------------------------------------- /disas/ppTxPkt: -------------------------------------------------------------------------------- 1 | By experimentation and debugging, I found out some info 2 | on the structure of the ppTxPkt arguments. 3 | 4 | From what I can understand, ppTxPkt takes one pointer to a struct of some kind. 5 | This struct contains various pointers. The first pointer points to the pbuf struct 6 | passed to the ieee80211_output_pbuf function. The 5th 4-byte group is a pointer to 7 | the actual IEEE-802.11 payload data. 8 | -------------------------------------------------------------------------------- /disas/wifi/wifi_promiscuous.c: -------------------------------------------------------------------------------- 1 | int wifi_promiscuous_enable(uint8 promiscuous) 2 | { 3 | if (((uint8 *)&user_init_flag)[0] == 0) 4 | return 0; 5 | 6 | if (wifi_get_opmode() != 1) 7 | return 0; 8 | 9 | if (promiscuous == 0) { 10 | if (((uint8 **)&g_ic)[96][100] != 0) { 11 | wDevDisableRx(); 12 | wdev_exit_sniffer(); 13 | ((volatile uint32 *)0x3ff1fe00)[155] |= 1; 14 | ((volatile uint32 *)0x3ff1fe00)[155] |= 2; 15 | ((volatile uint32 *)0x3ff1fe00)[155] |= 4; 16 | wDev_SetMacAddress(0, (uint8 *)&info + 30); 17 | ((uint8 **)&g_ic)[96][100] = 0; 18 | wDevEnableRx(); 19 | return 1; 20 | } else { 21 | return 1; 22 | } 23 | } 24 | 25 | if (((uint8 **)&g_ic)[96][100] == 1) 26 | return 1; 27 | 28 | wifi_station_disconnect(); 29 | wDevDisableRx(); 30 | ((volatile uint32 *)0x3ff1fe00)[155] &= (~1); 31 | ((volatile uint32 *)0x3ff1fe00)[155] &= (~2); 32 | ((volatile uint32 *)0x3ff1fe00)[155] &= (~4); 33 | ((uint8 **)&g_ic)[96][100] = 1; 34 | wdev_go_sniffer(); 35 | wDevEnableRx(); 36 | return 1; 37 | } 38 | 39 | void wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb) 40 | { 41 | promiscuous_cb = cb; 42 | } 43 | -------------------------------------------------------------------------------- /disas/wifi/wifi_set_opmode.c: -------------------------------------------------------------------------------- 1 | bool wifi_set_broadcast_if(uint8 interface) 2 | { 3 | if (interface == 0 || interface >= 4) { 4 | os_printf_plus("error parameter\n"); 5 | return false; 6 | } 7 | 8 | switch (interface) { 9 | case 1: 10 | if ((wifi_get_opmode() != 1) && (wifi_get_opmode() != 3)) 11 | return false; 12 | 13 | if (((uint8 **)g_ic)[4] == NULL) 14 | return false; 15 | 16 | netif_set_default(((struct netif **)g_ic)[4]); 17 | break; 18 | 19 | case 2: 20 | if ((wifi_get_opmode() != 2) && (wifi_get_opmode() != 3)) 21 | return false; 22 | 23 | if (((uint8 **)g_ic)[5] == NULL) 24 | return false; 25 | 26 | netif_set_default(((struct netif **)g_ic)[4]); 27 | break; 28 | 29 | case 3: 30 | if (wifi_get_opmode() != 3) 31 | return false; 32 | 33 | break; 34 | 35 | default: 36 | return true; 37 | } 38 | 39 | ((uint8 *)default_interface)[128] = mode; 40 | return true; 41 | } 42 | 43 | int func1(int val) 44 | { 45 | if (!pm_is_open()) 46 | return 0; 47 | 48 | if (((uint8 *)default_interface)[0] == 0) { 49 | __func2(promiscuous_cb, 0x4024081c, 0); 50 | ((uint8 *)default_interface)[0] = 1; 51 | } 52 | 53 | if (!pm_is_waked() || (((uint8 *)user_init_flag)[60] == 1)) { 54 | if (((uint8 *)user_init_flag)[60] == 0) { 55 | pm_post(1); 56 | __func3(((uint8 *)user_init_flag)[24]); 57 | ets_timer_arm_new(((uint8 *)user_init_flag)[24], 10, 0, 1); 58 | ((uint8 *)user_init_flag)[60] = 1; 59 | } 60 | 61 | ((uint8 *)user_init_flag)[61] = (((uint8 *)user_init_flag)[61] + 1) & 0xff; 62 | 63 | if (((uint8 *)user_init_flag)[61] > 10) { 64 | os_printf_plus("DEFERRED FUNC NUMBER IS BIGGER THAN 10\n"); 65 | ((uint8 *)user_init_flag)[61] = 10; 66 | } 67 | 68 | ((uint8 *)user_init_flag)[62] += 9; 69 | 70 | if (((uint8 *)user_init_flag)[62] >= 10) { 71 | *(((uint8 *)user_init_flag)[62] + ((uint8 *)user_init_flag)[175] + 122) = val; 72 | return -1; 73 | } 74 | 75 | *(((uint8 *)user_init_flag)[62] + ((uint8 *)user_init_flag)[175] + 132) = val; 76 | return -1; 77 | } 78 | 79 | return 0; 80 | } 81 | 82 | bool wifi_set_opmode_deeper(uint8 mode, uint8 a) 83 | { 84 | int res; 85 | int stuff; 86 | 87 | if (mode >= 4) 88 | return false; 89 | 90 | if (((uint8 *)g_ic)[468] == 1) 91 | return false; 92 | 93 | res = func(5); 94 | 95 | if (res == -1) { 96 | if (((uint8 *)g_ic)[480] == mode) 97 | return true; 98 | 99 | stuff = (uint8 *)g_ic + 352; 100 | 101 | if (((uint8 *)user_init_flag)[0] != 1) { 102 | *((uint8 *)(stuff + 128)) = a; 103 | wifi_param_save_protect((uint8 *)g_ic + 472); 104 | } 105 | 106 | return true; 107 | } 108 | 109 | *(res + 130) = mode; 110 | return true; 111 | } 112 | 113 | bool wifi_set_opmode(uint8 mode) 114 | { 115 | return wifi_set_opmode_deeper(mode, 1); 116 | } 117 | -------------------------------------------------------------------------------- /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) ETS_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/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/include/arch/sys_arch.h -------------------------------------------------------------------------------- /include/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "lwip/arch.h" 36 | 37 | /** lower two bits indicate debug level 38 | * - 0 all 39 | * - 1 warning 40 | * - 2 serious 41 | * - 3 severe 42 | */ 43 | #define LWIP_DBG_LEVEL_ALL 0x00 44 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 45 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 46 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 47 | #define LWIP_DBG_LEVEL_SEVERE 0x03 48 | #define LWIP_DBG_MASK_LEVEL 0x03 49 | 50 | /** flag for LWIP_DEBUGF to enable that debug message */ 51 | #define LWIP_DBG_ON 0x80U 52 | /** flag for LWIP_DEBUGF to disable that debug message */ 53 | #define LWIP_DBG_OFF 0x00U 54 | 55 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 56 | #define LWIP_DBG_TRACE 0x40U 57 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 58 | #define LWIP_DBG_STATE 0x20U 59 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 60 | #define LWIP_DBG_FRESH 0x10U 61 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 62 | #define LWIP_DBG_HALT 0x08U 63 | 64 | #ifndef LWIP_NOASSERT 65 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 66 | LWIP_PLATFORM_ASSERT(message); } while(0) 67 | #else /* LWIP_NOASSERT */ 68 | #define LWIP_ASSERT(message, assertion) 69 | #endif /* LWIP_NOASSERT */ 70 | 71 | /** if "expression" isn't true, then print "message" and execute "handler" expression */ 72 | #ifndef LWIP_ERROR 73 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 74 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 75 | #endif /* LWIP_ERROR */ 76 | 77 | #ifdef LWIP_DEBUG 78 | /** print debug message only if debug message type is enabled... 79 | * AND is of correct type AND is at least LWIP_DBG_LEVEL 80 | */ 81 | #define LWIP_DEBUGF(debug, message) do { \ 82 | if ( \ 83 | ((debug) & LWIP_DBG_ON) && \ 84 | ((debug) & LWIP_DBG_TYPES_ON) && \ 85 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 86 | LWIP_PLATFORM_DIAG(message); \ 87 | if ((debug) & LWIP_DBG_HALT) { \ 88 | while(1); \ 89 | } \ 90 | } \ 91 | } while(0) 92 | 93 | #else /* LWIP_DEBUG */ 94 | #define LWIP_DEBUGF(debug, message) 95 | #endif /* LWIP_DEBUG */ 96 | 97 | #endif /* __LWIP_DEBUG_H__ */ 98 | 99 | -------------------------------------------------------------------------------- /include/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/driver/gpio16.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPIO16_H__ 2 | #define __GPIO16_H__ 3 | 4 | void gpio16_output_conf(void); 5 | void gpio16_output_set(uint8 value); 6 | void gpio16_input_conf(void); 7 | uint8 gpio16_input_get(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /include/driver/i2c_master.h: -------------------------------------------------------------------------------- 1 | #ifndef __I2C_MASTER_H__ 2 | #define __I2C_MASTER_H__ 3 | 4 | #define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U 5 | #define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_MTMS_U 6 | #define I2C_MASTER_SDA_GPIO 2 7 | #define I2C_MASTER_SCL_GPIO 14 8 | #define I2C_MASTER_SDA_FUNC FUNC_GPIO2 9 | #define I2C_MASTER_SCL_FUNC FUNC_GPIO14 10 | 11 | //#define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U 12 | //#define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_GPIO0_U 13 | //#define I2C_MASTER_SDA_GPIO 2 14 | //#define I2C_MASTER_SCL_GPIO 0 15 | //#define I2C_MASTER_SDA_FUNC FUNC_GPIO2 16 | //#define I2C_MASTER_SCL_FUNC FUNC_GPIO0 17 | 18 | #if 0 19 | #define I2C_MASTER_GPIO_SET(pin) \ 20 | gpio_output_set(1< 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 | extern const char *lwip_strerr(err_t err)ICACHE_FLASH_ATTR; 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/icmp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/include/icmp.h -------------------------------------------------------------------------------- /include/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() rand() 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* LWIP_IGMP */ 105 | 106 | #endif /* __LWIP_IGMP_H__ */ 107 | -------------------------------------------------------------------------------- /include/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/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/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/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/.pbuf.h.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/include/lwip/.pbuf.h.swp -------------------------------------------------------------------------------- /include/lwip/app/dhcpserver.h: -------------------------------------------------------------------------------- 1 | #ifndef __DHCPS_H__ 2 | #define __DHCPS_H__ 3 | 4 | typedef struct dhcps_state{ 5 | sint16_t state; 6 | } dhcps_state; 7 | 8 | // ����dhcpclient�Զ����һ��DHCP msg�ṹ�� 9 | typedef struct dhcps_msg { 10 | uint8_t op, htype, hlen, hops; 11 | uint8_t xid[4]; 12 | uint16_t secs, flags; 13 | uint8_t ciaddr[4]; 14 | uint8_t yiaddr[4]; 15 | uint8_t siaddr[4]; 16 | uint8_t giaddr[4]; 17 | uint8_t chaddr[16]; 18 | uint8_t sname[64]; 19 | uint8_t file[128]; 20 | uint8_t options[312]; 21 | }dhcps_msg; 22 | 23 | #ifndef LWIP_OPEN_SRC 24 | struct dhcps_lease { 25 | uint32 start_ip; 26 | uint32 end_ip; 27 | }; 28 | #endif 29 | 30 | struct dhcps_pool{ 31 | struct ip_addr ip; 32 | uint8 mac[6]; 33 | uint32 lease_timer; 34 | }; 35 | 36 | typedef struct _list_node{ 37 | void *pnode; 38 | struct _list_node *pnext; 39 | }list_node; 40 | 41 | #define DHCPS_LEASE_TIMER 0x05A0 42 | #define DHCPS_MAX_LEASE 0x64 43 | #define BOOTP_BROADCAST 0x8000 44 | 45 | #define DHCP_REQUEST 1 46 | #define DHCP_REPLY 2 47 | #define DHCP_HTYPE_ETHERNET 1 48 | #define DHCP_HLEN_ETHERNET 6 49 | #define DHCP_MSG_LEN 236 50 | 51 | #define DHCPS_SERVER_PORT 67 52 | #define DHCPS_CLIENT_PORT 68 53 | 54 | #define DHCPDISCOVER 1 55 | #define DHCPOFFER 2 56 | #define DHCPREQUEST 3 57 | #define DHCPDECLINE 4 58 | #define DHCPACK 5 59 | #define DHCPNAK 6 60 | #define DHCPRELEASE 7 61 | 62 | #define DHCP_OPTION_SUBNET_MASK 1 63 | #define DHCP_OPTION_ROUTER 3 64 | #define DHCP_OPTION_DNS_SERVER 6 65 | #define DHCP_OPTION_REQ_IPADDR 50 66 | #define DHCP_OPTION_LEASE_TIME 51 67 | #define DHCP_OPTION_MSG_TYPE 53 68 | #define DHCP_OPTION_SERVER_ID 54 69 | #define DHCP_OPTION_INTERFACE_MTU 26 70 | #define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31 71 | #define DHCP_OPTION_BROADCAST_ADDRESS 28 72 | #define DHCP_OPTION_REQ_LIST 55 73 | #define DHCP_OPTION_END 255 74 | 75 | //#define USE_CLASS_B_NET 1 76 | #define DHCPS_DEBUG 0 77 | 78 | 79 | #define DHCPS_STATE_OFFER 1 80 | #define DHCPS_STATE_DECLINE 2 81 | #define DHCPS_STATE_ACK 3 82 | #define DHCPS_STATE_NAK 4 83 | #define DHCPS_STATE_IDLE 5 84 | 85 | void dhcps_start(struct ip_info *info); 86 | void dhcps_stop(void); 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /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 | /****************************************************************************** 14 | * FunctionName : espconn_tcp_disconnect 15 | * Description : A new incoming connection has been disconnected. 16 | * Parameters : espconn -- the espconn used to disconnect with host 17 | * Returns : none 18 | *******************************************************************************/ 19 | 20 | extern void espconn_tcp_disconnect(espconn_msg *pdiscon); 21 | 22 | /****************************************************************************** 23 | * FunctionName : espconn_tcp_client 24 | * Description : Initialize the client: set up a connect PCB and bind it to 25 | * the defined port 26 | * Parameters : espconn -- the espconn used to build client 27 | * Returns : none 28 | *******************************************************************************/ 29 | 30 | extern sint8 espconn_tcp_client(struct espconn* espconn); 31 | 32 | /****************************************************************************** 33 | * FunctionName : espconn_tcp_server 34 | * Description : Initialize the server: set up a listening PCB and bind it to 35 | * the defined port 36 | * Parameters : espconn -- the espconn used to build server 37 | * Returns : none 38 | *******************************************************************************/ 39 | 40 | extern sint8 espconn_tcp_server(struct espconn *espconn); 41 | 42 | #endif /* __CLIENT_TCP_H__ */ 43 | 44 | -------------------------------------------------------------------------------- /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 void espconn_udp_sent(void *arg, uint8 *psent, uint16 length); 47 | 48 | 49 | #endif /* __ESPCONN_UDP_H__ */ 50 | 51 | 52 | -------------------------------------------------------------------------------- /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/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "lwip/arch.h" 36 | 37 | /** lower two bits indicate debug level 38 | * - 0 all 39 | * - 1 warning 40 | * - 2 serious 41 | * - 3 severe 42 | */ 43 | #define LWIP_DBG_LEVEL_ALL 0x00 44 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 45 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 46 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 47 | #define LWIP_DBG_LEVEL_SEVERE 0x03 48 | #define LWIP_DBG_MASK_LEVEL 0x03 49 | 50 | /** flag for LWIP_DEBUGF to enable that debug message */ 51 | #define LWIP_DBG_ON 0x80U 52 | /** flag for LWIP_DEBUGF to disable that debug message */ 53 | #define LWIP_DBG_OFF 0x00U 54 | 55 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 56 | #define LWIP_DBG_TRACE 0x40U 57 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 58 | #define LWIP_DBG_STATE 0x20U 59 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 60 | #define LWIP_DBG_FRESH 0x10U 61 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 62 | #define LWIP_DBG_HALT 0x08U 63 | 64 | #ifndef LWIP_NOASSERT 65 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 66 | LWIP_PLATFORM_ASSERT(message); } while(0) 67 | #else /* LWIP_NOASSERT */ 68 | #define LWIP_ASSERT(message, assertion) 69 | #endif /* LWIP_NOASSERT */ 70 | 71 | /** if "expression" isn't true, then print "message" and execute "handler" expression */ 72 | #ifndef LWIP_ERROR 73 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 74 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 75 | #endif /* LWIP_ERROR */ 76 | 77 | #ifdef LWIP_DEBUG 78 | /** print debug message only if debug message type is enabled... 79 | * AND is of correct type AND is at least LWIP_DBG_LEVEL 80 | */ 81 | #define LWIP_DEBUGF(debug, message) do { \ 82 | if ( \ 83 | ((debug) & LWIP_DBG_ON) && \ 84 | ((debug) & LWIP_DBG_TYPES_ON) && \ 85 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 86 | LWIP_PLATFORM_DIAG(message); \ 87 | if ((debug) & LWIP_DBG_HALT) { \ 88 | while(1); \ 89 | } \ 90 | } \ 91 | } while(0) 92 | 93 | #else /* LWIP_DEBUG */ 94 | #define LWIP_DEBUGF(debug, message) 95 | #endif /* LWIP_DEBUG */ 96 | 97 | #endif /* __LWIP_DEBUG_H__ */ 98 | 99 | -------------------------------------------------------------------------------- /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/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 | extern const char *lwip_strerr(err_t err)ICACHE_FLASH_ATTR; 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/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/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() 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/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 u16_t memp_sizes[MEMP_MAX]; 80 | #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ 81 | 82 | #if MEMP_MEM_MALLOC 83 | 84 | #include "mem.h" 85 | 86 | #define memp_init() 87 | #define memp_malloc(type) mem_malloc(memp_sizes[type]) 88 | #define memp_free(type, mem) mem_free(mem) 89 | 90 | #else /* MEMP_MEM_MALLOC */ 91 | 92 | #if MEM_USE_POOLS 93 | /** This structure is used to save the pool one element came from. */ 94 | struct memp_malloc_helper 95 | { 96 | memp_t poolnr; 97 | }; 98 | #endif /* MEM_USE_POOLS */ 99 | 100 | void memp_init(void)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/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/netif.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/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/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/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/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/mem_manager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/include/mem_manager.h -------------------------------------------------------------------------------- /include/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 u16_t memp_sizes[MEMP_MAX]; 80 | #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ 81 | 82 | #if MEMP_MEM_MALLOC 83 | 84 | #include "mem.h" 85 | 86 | #define memp_init() 87 | #define memp_malloc(type) mem_malloc(memp_sizes[type]) 88 | #define memp_free(type, mem) mem_free(mem) 89 | 90 | #else /* MEMP_MEM_MALLOC */ 91 | 92 | #if MEM_USE_POOLS 93 | /** This structure is used to save the pool one element came from. */ 94 | struct memp_malloc_helper 95 | { 96 | memp_t poolnr; 97 | }; 98 | #endif /* MEM_USE_POOLS */ 99 | 100 | void memp_init(void)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/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/netif.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/include/netif.h -------------------------------------------------------------------------------- /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/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/pp/esf_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * copyright (c) 2008 - 2012 Espressif System 3 | * 4 | * esf buffer data structure 5 | */ 6 | 7 | #ifndef _ESF_BUF_H_ 8 | #define _ESF_BUF_H_ 9 | 10 | #define EP_OFFSET 36 /* see comments in pbuf.h */ 11 | 12 | #endif /* _ESF_BUF_H_ */ 13 | -------------------------------------------------------------------------------- /include/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/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/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/ssl/app/espconn_secure.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESPCONN_ENCRY_H__ 2 | #define __ESPCONN_ENCRY_H__ 3 | 4 | #include "espconn/espconn.h" 5 | 6 | /****************************************************************************** 7 | * FunctionName : espconn_encry_connect 8 | * Description : The function given as connection 9 | * Parameters : espconn -- the espconn used to connect with the host 10 | * Returns : none 11 | *******************************************************************************/ 12 | 13 | sint8 espconn_secure_connect(struct espconn *espconn); 14 | 15 | /****************************************************************************** 16 | * FunctionName : espconn_encry_disconnect 17 | * Description : The function given as the disconnection 18 | * Parameters : espconn -- the espconn used to disconnect with the host 19 | * Returns : none 20 | *******************************************************************************/ 21 | 22 | extern sint8 espconn_secure_disconnect(struct espconn *espconn); 23 | 24 | /****************************************************************************** 25 | * FunctionName : espconn_encry_sent 26 | * Description : sent data for client or server 27 | * Parameters : espconn -- espconn to set for client or server 28 | * psent -- data to send 29 | * length -- length of data to send 30 | * Returns : none 31 | *******************************************************************************/ 32 | 33 | extern sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length); 34 | 35 | /****************************************************************************** 36 | * FunctionName : espconn_secure_accept 37 | * Description : The function given as the listen 38 | * Parameters : espconn -- the espconn used to listen the connection 39 | * Returns : none 40 | *******************************************************************************/ 41 | 42 | extern sint8 espconn_secure_accept(struct espconn *espconn); 43 | 44 | #endif 45 | 46 | 47 | -------------------------------------------------------------------------------- /include/ssl/app/espconn_ssl.h: -------------------------------------------------------------------------------- 1 | #ifndef ESPCONN_SSL_CLIENT_H 2 | #define ESPCONN_SSL_CLIENT_H 3 | 4 | #include "ssl/ssl_ssl.h" 5 | #include "ssl/ssl_tls1.h" 6 | 7 | #include "lwip/app/espconn.h" 8 | 9 | typedef struct _ssl_msg { 10 | SSL_CTX *ssl_ctx; 11 | SSL *ssl; 12 | bool quiet; 13 | char *private_key_file; 14 | uint8_t session_id[SSL_SESSION_ID_SIZE]; 15 | u16_t pkt_length; 16 | } ssl_msg; 17 | 18 | /****************************************************************************** 19 | * FunctionName : sslserver_start 20 | * Description : Initialize the server: set up a listen PCB and bind it to 21 | * the defined port 22 | * Parameters : espconn -- the espconn used to build client 23 | * Returns : none 24 | *******************************************************************************/ 25 | 26 | extern sint8 espconn_ssl_server(struct espconn *espconn); 27 | 28 | /****************************************************************************** 29 | * FunctionName : espconn_ssl_client 30 | * Description : Initialize the client: set up a connect PCB and bind it to 31 | * the defined port 32 | * Parameters : espconn -- the espconn used to build client 33 | * Returns : none 34 | *******************************************************************************/ 35 | 36 | extern sint8 espconn_ssl_client(struct espconn *espconn); 37 | 38 | /****************************************************************************** 39 | * FunctionName : espconn_ssl_write 40 | * Description : sent data for client or server 41 | * Parameters : void *arg -- client or server to send 42 | * uint8* psent -- Data to send 43 | * uint16 length -- Length of data to send 44 | * Returns : none 45 | *******************************************************************************/ 46 | 47 | extern void espconn_ssl_sent(void *arg, uint8 *psent, uint16 length); 48 | 49 | /****************************************************************************** 50 | * FunctionName : espconn_ssl_disconnect 51 | * Description : A new incoming connection has been disconnected. 52 | * Parameters : espconn -- the espconn used to disconnect with host 53 | * Returns : none 54 | *******************************************************************************/ 55 | 56 | extern void espconn_ssl_disconnect(espconn_msg *pdis); 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /include/ssl/cert.h: -------------------------------------------------------------------------------- 1 | unsigned char default_certificate[] = { 2 | 0x30, 0x82, 0x01, 0x82, 0x30, 0x81, 0xec, 0x02, 0x09, 0x00, 0x88, 0xf2, 3 | 0x5f, 0x46, 0x12, 0x2e, 0x3d, 0x3a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 4 | 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x1c, 0x31, 5 | 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x11, 0x77, 0x77, 6 | 0x77, 0x2e, 0x65, 0x73, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x66, 0x2e, 7 | 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x30, 0x36, 0x32, 8 | 0x34, 0x31, 0x30, 0x32, 0x32, 0x33, 0x33, 0x5a, 0x17, 0x0d, 0x32, 0x38, 9 | 0x30, 0x33, 0x30, 0x32, 0x31, 0x30, 0x32, 0x32, 0x33, 0x33, 0x5a, 0x30, 10 | 0x34, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x09, 11 | 0x65, 0x73, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x66, 0x31, 0x1e, 0x30, 12 | 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x15, 0x65, 0x73, 0x70, 0x72, 13 | 0x65, 0x73, 0x73, 0x69, 0x66, 0x20, 0x49, 0x6f, 0x54, 0x20, 0x70, 0x72, 14 | 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 15 | 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 16 | 0x00, 0x30, 0x48, 0x02, 0x41, 0x00, 0xb9, 0x83, 0x30, 0xca, 0xfb, 0xec, 17 | 0x11, 0x9e, 0x94, 0xb7, 0x89, 0xf2, 0x84, 0x2c, 0xda, 0xe1, 0x9a, 0x53, 18 | 0x3a, 0x1b, 0x6e, 0xc9, 0x85, 0x81, 0xf9, 0xa3, 0x41, 0xdb, 0xe2, 0x82, 19 | 0x3b, 0xfa, 0x80, 0x22, 0x3b, 0x81, 0x6d, 0x25, 0x73, 0x7e, 0xf6, 0x49, 20 | 0xcc, 0x69, 0x3c, 0x6c, 0xd8, 0x05, 0xfb, 0x92, 0x02, 0xcf, 0x19, 0x2a, 21 | 0x10, 0x7d, 0x69, 0x7a, 0xd8, 0x9d, 0xd3, 0xcf, 0x6c, 0xef, 0x02, 0x03, 22 | 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 23 | 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x2d, 0x63, 24 | 0x58, 0x21, 0xe3, 0x8b, 0x37, 0x0d, 0x28, 0x68, 0x11, 0x0e, 0x4d, 0xdd, 25 | 0xf3, 0xea, 0xdb, 0xec, 0xd7, 0x09, 0x47, 0x2c, 0xa1, 0xd8, 0xd1, 0x71, 26 | 0x83, 0x11, 0xb4, 0x17, 0xbc, 0x83, 0xea, 0x5a, 0xd6, 0x73, 0x02, 0x25, 27 | 0x87, 0x01, 0x76, 0xfc, 0x59, 0x1a, 0xcf, 0xd9, 0x49, 0xc9, 0xf9, 0x1f, 28 | 0x5c, 0x3b, 0x24, 0x6a, 0x5c, 0xa5, 0xca, 0xe6, 0x5d, 0x34, 0x5b, 0x5f, 29 | 0xcf, 0x56, 0x9c, 0x71, 0xd2, 0x6b, 0xdd, 0x1f, 0x15, 0xae, 0x4d, 0xf1, 30 | 0xca, 0x35, 0xc8, 0xdd, 0x93, 0x1b, 0x58, 0x1e, 0x94, 0x08, 0xcf, 0xa0, 31 | 0x20, 0xb9, 0x75, 0xa5, 0x4c, 0x77, 0xf5, 0x7f, 0xed, 0xd5, 0xcd, 0x53, 32 | 0xaa, 0x87, 0xa6, 0x3c, 0xf5, 0x72, 0xd8, 0xd2, 0xb0, 0xf7, 0x11, 0xb0, 33 | 0x0e, 0xe9, 0x41, 0xd6, 0x8e, 0xd9, 0x07, 0xf8, 0xed, 0xf8, 0x67, 0x7f, 34 | 0x28, 0x18, 0xf0, 0x1b, 0x29, 0x11 35 | }; 36 | unsigned int default_certificate_len = 390; 37 | -------------------------------------------------------------------------------- /include/ssl/private_key.h: -------------------------------------------------------------------------------- 1 | unsigned char default_private_key[] = { 2 | 0x30, 0x82, 0x01, 0x3a, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00, 0xb9, 0x83, 3 | 0x30, 0xca, 0xfb, 0xec, 0x11, 0x9e, 0x94, 0xb7, 0x89, 0xf2, 0x84, 0x2c, 4 | 0xda, 0xe1, 0x9a, 0x53, 0x3a, 0x1b, 0x6e, 0xc9, 0x85, 0x81, 0xf9, 0xa3, 5 | 0x41, 0xdb, 0xe2, 0x82, 0x3b, 0xfa, 0x80, 0x22, 0x3b, 0x81, 0x6d, 0x25, 6 | 0x73, 0x7e, 0xf6, 0x49, 0xcc, 0x69, 0x3c, 0x6c, 0xd8, 0x05, 0xfb, 0x92, 7 | 0x02, 0xcf, 0x19, 0x2a, 0x10, 0x7d, 0x69, 0x7a, 0xd8, 0x9d, 0xd3, 0xcf, 8 | 0x6c, 0xef, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x40, 0x1d, 0x13, 0x92, 9 | 0xf2, 0x3d, 0xca, 0x22, 0x78, 0xd8, 0x96, 0x6b, 0xe8, 0xb7, 0x0e, 0xd0, 10 | 0xbf, 0xcb, 0x90, 0x7f, 0xeb, 0x0c, 0xd2, 0x49, 0x3a, 0xb6, 0x06, 0x00, 11 | 0xac, 0x96, 0x34, 0x13, 0x72, 0x4b, 0x8c, 0xd2, 0xb9, 0x35, 0xf5, 0x64, 12 | 0x18, 0xb2, 0x47, 0x5b, 0x9f, 0xbb, 0xf2, 0x5b, 0x2f, 0x66, 0x78, 0x2d, 13 | 0x0a, 0x76, 0x44, 0xc5, 0x4f, 0xdb, 0x7d, 0x13, 0xcf, 0xa5, 0x08, 0xdc, 14 | 0x01, 0x02, 0x21, 0x00, 0xdf, 0x9a, 0x89, 0xd0, 0xef, 0x23, 0xcf, 0x12, 15 | 0xac, 0x8a, 0x63, 0x1a, 0x8c, 0xc0, 0x3f, 0xf4, 0x38, 0x52, 0x3c, 0x9f, 16 | 0x19, 0x0a, 0x37, 0xd2, 0xcb, 0x5d, 0xeb, 0xb6, 0x2a, 0x33, 0xb0, 0x91, 17 | 0x02, 0x21, 0x00, 0xd4, 0x63, 0xd9, 0x6a, 0x18, 0x5b, 0xe8, 0xa8, 0x57, 18 | 0x4d, 0xd1, 0x9a, 0xa8, 0xd7, 0xe1, 0x65, 0x75, 0xb3, 0xb9, 0x5c, 0x94, 19 | 0x14, 0xca, 0x98, 0x41, 0x47, 0x9c, 0x0a, 0x22, 0x38, 0x05, 0x7f, 0x02, 20 | 0x20, 0x6a, 0xce, 0xfd, 0xef, 0xe0, 0x9b, 0x61, 0x49, 0x91, 0x43, 0x95, 21 | 0x6d, 0x54, 0x38, 0x6d, 0x14, 0x32, 0x67, 0x0d, 0xf0, 0x0d, 0x5c, 0xf5, 22 | 0x27, 0x6a, 0xdf, 0x55, 0x3d, 0xb1, 0xd0, 0xf9, 0x11, 0x02, 0x21, 0x00, 23 | 0xba, 0x94, 0xa0, 0xf9, 0xb0, 0x3e, 0x85, 0x8b, 0xe5, 0x6e, 0x4a, 0x95, 24 | 0x88, 0x80, 0x65, 0xd5, 0x00, 0xea, 0x8b, 0x0b, 0x46, 0x57, 0x61, 0x87, 25 | 0x11, 0xc9, 0xfb, 0xcd, 0x77, 0x34, 0x29, 0xb7, 0x02, 0x20, 0x06, 0x8d, 26 | 0x41, 0x11, 0x47, 0x93, 0xcb, 0xad, 0xda, 0x5d, 0xe1, 0x9d, 0x49, 0x8d, 27 | 0xe0, 0xab, 0x48, 0xe6, 0x18, 0x28, 0x4a, 0x94, 0xae, 0xf9, 0xad, 0xc5, 28 | 0x5b, 0x0b, 0x15, 0xc6, 0x73, 0x17 29 | }; 30 | unsigned int default_private_key_len = 318; 31 | -------------------------------------------------------------------------------- /include/ssl/ssl_bigint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Cameron Rich 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * * Neither the name of the axTLS project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef BIGINT_HEADER 32 | #define BIGINT_HEADER 33 | 34 | #include "ssl/ssl_crypto.h" 35 | 36 | BI_CTX *bi_initialize(void); 37 | void bi_terminate(BI_CTX *ctx); 38 | void bi_permanent(bigint *bi); 39 | void bi_depermanent(bigint *bi); 40 | void bi_clear_cache(BI_CTX *ctx); 41 | void bi_free(BI_CTX *ctx, bigint *bi); 42 | bigint *bi_copy(bigint *bi); 43 | bigint *bi_clone(BI_CTX *ctx, const bigint *bi); 44 | void bi_export(BI_CTX *ctx, bigint *bi, uint8_t *data, int size); 45 | bigint *bi_import(BI_CTX *ctx, const uint8_t *data, int len); 46 | bigint *int_to_bi(BI_CTX *ctx, comp i); 47 | 48 | /* the functions that actually do something interesting */ 49 | bigint *bi_add(BI_CTX *ctx, bigint *bia, bigint *bib); 50 | bigint *bi_subtract(BI_CTX *ctx, bigint *bia, 51 | bigint *bib, int *is_negative); 52 | bigint *bi_divide(BI_CTX *ctx, bigint *bia, bigint *bim, int is_mod); 53 | bigint *bi_multiply(BI_CTX *ctx, bigint *bia, bigint *bib); 54 | bigint *bi_mod_power(BI_CTX *ctx, bigint *bi, bigint *biexp); 55 | bigint *bi_mod_power2(BI_CTX *ctx, bigint *bi, bigint *bim, bigint *biexp); 56 | int bi_compare(bigint *bia, bigint *bib); 57 | void bi_set_mod(BI_CTX *ctx, bigint *bim, int mod_offset); 58 | void bi_free_mod(BI_CTX *ctx, int mod_offset); 59 | 60 | #ifdef CONFIG_SSL_FULL_MODE 61 | void bi_print(const char *label, bigint *bi); 62 | bigint *bi_str_import(BI_CTX *ctx, const char *data); 63 | #endif 64 | 65 | /** 66 | * @def bi_mod 67 | * Find the residue of B. bi_set_mod() must be called before hand. 68 | */ 69 | #define bi_mod(A, B) bi_divide(A, B, ctx->bi_mod[ctx->mod_offset], 1) 70 | 71 | /** 72 | * bi_residue() is technically the same as bi_mod(), but it uses the 73 | * appropriate reduction technique (which is bi_mod() when doing classical 74 | * reduction). 75 | */ 76 | #if defined(CONFIG_BIGINT_MONTGOMERY) 77 | #define bi_residue(A, B) bi_mont(A, B) 78 | bigint *bi_mont(BI_CTX *ctx, bigint *bixy); 79 | #elif defined(CONFIG_BIGINT_BARRETT) 80 | #define bi_residue(A, B) bi_barrett(A, B) 81 | bigint *bi_barrett(BI_CTX *ctx, bigint *bi); 82 | #else /* if defined(CONFIG_BIGINT_CLASSICAL) */ 83 | #define bi_residue(A, B) bi_mod(A, B) 84 | #endif 85 | 86 | #ifdef CONFIG_BIGINT_SQUARE 87 | bigint *bi_square(BI_CTX *ctx, bigint *bi); 88 | #else 89 | #define bi_square(A, B) bi_multiply(A, bi_copy(B), B) 90 | #endif 91 | 92 | #ifdef CONFIG_BIGINT_CRT 93 | bigint *bi_crt(BI_CTX *ctx, bigint *bi, 94 | bigint *dP, bigint *dQ, 95 | bigint *p, bigint *q, 96 | bigint *qInv); 97 | #endif 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /include/ssl/ssl_cert.h: -------------------------------------------------------------------------------- 1 | unsigned char default_certificate[] = { 2 | 0x30, 0x82, 0x01, 0xd7, 0x30, 0x82, 0x01, 0x40, 0x02, 0x09, 0x00, 0xab, 3 | 0x08, 0x18, 0xa7, 0x03, 0x07, 0x27, 0xfd, 0x30, 0x0d, 0x06, 0x09, 0x2a, 4 | 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x34, 5 | 0x31, 0x32, 0x30, 0x30, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x29, 0x61, 6 | 0x78, 0x54, 0x4c, 0x53, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 7 | 0x20, 0x44, 0x6f, 0x64, 0x67, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 8 | 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 9 | 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, 0x31, 0x32, 10 | 0x32, 0x36, 0x32, 0x32, 0x33, 0x33, 0x33, 0x39, 0x5a, 0x17, 0x0d, 0x32, 11 | 0x34, 0x30, 0x39, 0x30, 0x33, 0x32, 0x32, 0x33, 0x33, 0x33, 0x39, 0x5a, 12 | 0x30, 0x2c, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 13 | 0x0d, 0x61, 0x78, 0x54, 0x4c, 0x53, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 14 | 0x63, 0x74, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 15 | 0x09, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x81, 16 | 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 17 | 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 18 | 0x81, 0x81, 0x00, 0xcd, 0xfd, 0x89, 0x48, 0xbe, 0x36, 0xb9, 0x95, 0x76, 19 | 0xd4, 0x13, 0x30, 0x0e, 0xbf, 0xb2, 0xed, 0x67, 0x0a, 0xc0, 0x16, 0x3f, 20 | 0x51, 0x09, 0x9d, 0x29, 0x2f, 0xb2, 0x6d, 0x3f, 0x3e, 0x6c, 0x2f, 0x90, 21 | 0x80, 0xa1, 0x71, 0xdf, 0xbe, 0x38, 0xc5, 0xcb, 0xa9, 0x9a, 0x40, 0x14, 22 | 0x90, 0x0a, 0xf9, 0xb7, 0x07, 0x0b, 0xe1, 0xda, 0xe7, 0x09, 0xbf, 0x0d, 23 | 0x57, 0x41, 0x86, 0x60, 0xa1, 0xc1, 0x27, 0x91, 0x5b, 0x0a, 0x98, 0x46, 24 | 0x1b, 0xf6, 0xa2, 0x84, 0xf8, 0x65, 0xc7, 0xce, 0x2d, 0x96, 0x17, 0xaa, 25 | 0x91, 0xf8, 0x61, 0x04, 0x50, 0x70, 0xeb, 0xb4, 0x43, 0xb7, 0xdc, 0x9a, 26 | 0xcc, 0x31, 0x01, 0x14, 0xd4, 0xcd, 0xcc, 0xc2, 0x37, 0x6d, 0x69, 0x82, 27 | 0xd6, 0xc6, 0xc4, 0xbe, 0xf2, 0x34, 0xa5, 0xc9, 0xa6, 0x19, 0x53, 0x32, 28 | 0x7a, 0x86, 0x0e, 0x91, 0x82, 0x0f, 0xa1, 0x42, 0x54, 0xaa, 0x01, 0x02, 29 | 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 30 | 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x40, 31 | 0xb4, 0x94, 0x9a, 0xa8, 0x89, 0x72, 0x1d, 0x07, 0xe5, 0xb3, 0x6b, 0x88, 32 | 0x21, 0xc2, 0x38, 0x36, 0x9e, 0x7a, 0x8c, 0x49, 0x48, 0x68, 0x0c, 0x06, 33 | 0xe8, 0xdb, 0x1f, 0x4e, 0x05, 0xe6, 0x31, 0xe3, 0xfd, 0xe6, 0x0d, 0x6b, 34 | 0xd8, 0x13, 0x17, 0xe0, 0x2d, 0x0d, 0xb8, 0x7e, 0xcb, 0x20, 0x6c, 0xa8, 35 | 0x73, 0xa7, 0xfd, 0xe3, 0xa7, 0xfa, 0xf3, 0x02, 0x60, 0x78, 0x1f, 0x13, 36 | 0x40, 0x45, 0xee, 0x75, 0xf5, 0x10, 0xfd, 0x8f, 0x68, 0x74, 0xd4, 0xac, 37 | 0xae, 0x04, 0x09, 0x55, 0x2c, 0xdb, 0xd8, 0x07, 0x07, 0x65, 0x69, 0x27, 38 | 0x6e, 0xbf, 0x5e, 0x61, 0x40, 0x56, 0x8b, 0xd7, 0x33, 0x3b, 0xff, 0x6e, 39 | 0x53, 0x7e, 0x9d, 0x3f, 0xc0, 0x40, 0x3a, 0xab, 0xa0, 0x50, 0x4e, 0x80, 40 | 0x47, 0x46, 0x0d, 0x1e, 0xdb, 0x4c, 0xf1, 0x1b, 0x5d, 0x3c, 0x2a, 0x54, 41 | 0xa7, 0x4d, 0xfa, 0x7b, 0x72, 0x66, 0xc5 42 | }; 43 | unsigned int default_certificate_len = 475; 44 | -------------------------------------------------------------------------------- /include/ssl/ssl_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically generated header file: don't edit 3 | */ 4 | 5 | #define HAVE_DOT_CONFIG 1 6 | #undef CONFIG_PLATFORM_LINUX 7 | #define CONFIG_PLATFORM_CYGWIN 1 8 | #undef CONFIG_PLATFORM_WIN32 9 | 10 | /* 11 | * General Configuration 12 | */ 13 | #define PREFIX "/usr/local" 14 | #define CONFIG_DEBUG 1 15 | #undef CONFIG_STRIP_UNWANTED_SECTIONS 16 | #undef CONFIG_VISUAL_STUDIO_7_0 17 | #undef CONFIG_VISUAL_STUDIO_8_0 18 | #undef CONFIG_VISUAL_STUDIO_10_0 19 | #define CONFIG_VISUAL_STUDIO_7_0_BASE "" 20 | #define CONFIG_VISUAL_STUDIO_8_0_BASE "" 21 | #define CONFIG_VISUAL_STUDIO_10_0_BASE "" 22 | #define CONFIG_EXTRA_CFLAGS_OPTIONS "" 23 | #define CONFIG_EXTRA_LDFLAGS_OPTIONS "" 24 | 25 | /* 26 | * SSL Library 27 | */ 28 | #undef CONFIG_SSL_SERVER_ONLY 29 | #undef CONFIG_SSL_CERT_VERIFICATION 30 | #undef CONFIG_SSL_ENABLE_CLIENT 31 | #define CONFIG_SSL_FULL_MODE 1 32 | #undef CONFIG_SSL_SKELETON_MODE 33 | #undef CONFIG_SSL_PROT_LOW 34 | #define CONFIG_SSL_PROT_MEDIUM 1 35 | #undef CONFIG_SSL_PROT_HIGH 36 | #define CONFIG_SSL_USE_DEFAULT_KEY 37 | #define CONFIG_SSL_PRIVATE_KEY_LOCATION "" 38 | #define CONFIG_SSL_PRIVATE_KEY_PASSWORD "" 39 | #define CONFIG_SSL_X509_CERT_LOCATION "" 40 | #undef CONFIG_SSL_GENERATE_X509_CERT 41 | #define CONFIG_SSL_X509_COMMON_NAME "" 42 | #define CONFIG_SSL_X509_ORGANIZATION_NAME "" 43 | #define CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME "" 44 | #undef CONFIG_SSL_ENABLE_V23_HANDSHAKE 45 | #define CONFIG_SSL_HAS_PEM 1 46 | #undef CONFIG_SSL_USE_PKCS12 47 | #define CONFIG_SSL_EXPIRY_TIME 24 48 | #define CONFIG_X509_MAX_CA_CERTS 150 49 | #define CONFIG_SSL_MAX_CERTS 3 50 | #undef CONFIG_SSL_CTX_MUTEXING 51 | //#define CONFIG_USE_DEV_URANDOM 1 52 | #undef CONFIG_WIN32_USE_CRYPTO_LIB 53 | #undef CONFIG_OPENSSL_COMPATIBLE 54 | #undef CONFIG_PERFORMANCE_TESTING 55 | #define CONFIG_SSL_TEST 1 56 | #undef CONFIG_AXTLSWRAP 57 | #define CONFIG_AXHTTPD 1 58 | 59 | /* 60 | * Axhttpd Configuration 61 | */ 62 | #undef CONFIG_HTTP_STATIC_BUILD 63 | #define CONFIG_HTTP_PORT 80 64 | #define CONFIG_HTTP_HTTPS_PORT 443 65 | #define CONFIG_HTTP_SESSION_CACHE_SIZE 5 66 | #define CONFIG_HTTP_WEBROOT "../www" 67 | #define CONFIG_HTTP_TIMEOUT 300 68 | 69 | /* 70 | * CGI 71 | */ 72 | #undef CONFIG_HTTP_HAS_CGI 73 | #define CONFIG_HTTP_CGI_EXTENSIONS ".lua,.lp,.php" 74 | #define CONFIG_HTTP_ENABLE_LUA 1 75 | #define CONFIG_HTTP_LUA_PREFIX "/usr" 76 | #undef CONFIG_HTTP_BUILD_LUA 77 | #define CONFIG_HTTP_CGI_LAUNCHER "/usr/bin/cgi" 78 | #define CONFIG_HTTP_DIRECTORIES 1 79 | #define CONFIG_HTTP_HAS_AUTHORIZATION 1 80 | #undef CONFIG_HTTP_HAS_IPV6 81 | #undef CONFIG_HTTP_ENABLE_DIFFERENT_USER 82 | #define CONFIG_HTTP_USER "" 83 | #define CONFIG_HTTP_VERBOSE 0 84 | #undef CONFIG_HTTP_IS_DAEMON 85 | 86 | /* 87 | * Language Bindings 88 | */ 89 | #undef CONFIG_BINDINGS 90 | #undef CONFIG_CSHARP_BINDINGS 91 | #undef CONFIG_VBNET_BINDINGS 92 | #define CONFIG_DOT_NET_FRAMEWORK_BASE "" 93 | #undef CONFIG_JAVA_BINDINGS 94 | #define CONFIG_JAVA_HOME "" 95 | #undef CONFIG_PERL_BINDINGS 96 | #define CONFIG_PERL_CORE "" 97 | #define CONFIG_PERL_LIB "" 98 | #undef CONFIG_LUA_BINDINGS 99 | #define CONFIG_LUA_CORE "" 100 | 101 | /* 102 | * Samples 103 | */ 104 | #define CONFIG_SAMPLES 1 105 | #define CONFIG_C_SAMPLES 1 106 | #undef CONFIG_CSHARP_SAMPLES 107 | #undef CONFIG_VBNET_SAMPLES 108 | #undef CONFIG_JAVA_SAMPLES 109 | #undef CONFIG_PERL_SAMPLES 110 | #undef CONFIG_LUA_SAMPLES 111 | 112 | /* 113 | * BigInt Options 114 | */ 115 | #undef CONFIG_BIGINT_CLASSICAL 116 | #undef CONFIG_BIGINT_MONTGOMERY 117 | #define CONFIG_BIGINT_BARRETT 1 118 | #define CONFIG_BIGINT_CRT 1 119 | #undef CONFIG_BIGINT_KARATSUBA 120 | #define MUL_KARATSUBA_THRESH 121 | #define SQU_KARATSUBA_THRESH 122 | #define CONFIG_BIGINT_SLIDING_WINDOW 1 123 | #define CONFIG_BIGINT_SQUARE 1 124 | #define CONFIG_BIGINT_CHECK_ON 1 125 | #define CONFIG_INTEGER_32BIT 1 126 | #undef CONFIG_INTEGER_16BIT 127 | #undef CONFIG_INTEGER_8BIT 128 | -------------------------------------------------------------------------------- /include/ssl/ssl_os_int.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Cameron Rich 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * * Neither the name of the axTLS project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /** 32 | * @file os_int.h 33 | * 34 | * Ensure a consistent bit size 35 | */ 36 | 37 | #ifndef HEADER_OS_INT_H 38 | #define HEADER_OS_INT_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #if defined(WIN32) 45 | typedef UINT8 uint8_t; 46 | typedef INT8 int8_t; 47 | typedef UINT16 uint16_t; 48 | typedef INT16 int16_t; 49 | typedef UINT32 uint32_t; 50 | typedef INT32 int32_t; 51 | typedef UINT64 uint64_t; 52 | typedef INT64 int64_t; 53 | #else /* Not Win32 */ 54 | 55 | #ifdef CONFIG_PLATFORM_SOLARIS 56 | #include 57 | #else 58 | //#include 59 | #endif /* Not Solaris */ 60 | 61 | #endif /* Not Win32 */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/ssl/ssl_os_port.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Cameron Rich 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * * Neither the name of the axTLS project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /** 32 | * @file os_port.h 33 | * 34 | * Some stuff to minimise the differences between windows and linux/unix 35 | */ 36 | 37 | #ifndef HEADER_OS_PORT_H 38 | #define HEADER_OS_PORT_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | //#include "../crypto/os_int.h" 45 | #include "c_types.h" 46 | #include "osapi.h" 47 | #include 48 | 49 | #if 0 50 | #define ssl_printf(fmt, args...) os_printf(fmt,## args) 51 | #else 52 | #define ssl_printf(fmt, args...) 53 | #endif 54 | 55 | #define STDCALL 56 | #define EXP_FUNC 57 | 58 | struct timeval { 59 | long tv_sec; /* seconds */ 60 | long tv_usec; /* and microseconds */ 61 | }; 62 | 63 | /* Mutexing definitions */ 64 | 65 | #define SSL_CTX_MUTEX_INIT(A) 66 | #define SSL_CTX_MUTEX_DESTROY(A) 67 | #define SSL_CTX_LOCK(A) 68 | #define SSL_CTX_UNLOCK(A) 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/ssl/ssl_private_key.h: -------------------------------------------------------------------------------- 1 | unsigned char default_private_key[] = { 2 | 0x30, 0x82, 0x02, 0x5d, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xcd, 3 | 0xfd, 0x89, 0x48, 0xbe, 0x36, 0xb9, 0x95, 0x76, 0xd4, 0x13, 0x30, 0x0e, 4 | 0xbf, 0xb2, 0xed, 0x67, 0x0a, 0xc0, 0x16, 0x3f, 0x51, 0x09, 0x9d, 0x29, 5 | 0x2f, 0xb2, 0x6d, 0x3f, 0x3e, 0x6c, 0x2f, 0x90, 0x80, 0xa1, 0x71, 0xdf, 6 | 0xbe, 0x38, 0xc5, 0xcb, 0xa9, 0x9a, 0x40, 0x14, 0x90, 0x0a, 0xf9, 0xb7, 7 | 0x07, 0x0b, 0xe1, 0xda, 0xe7, 0x09, 0xbf, 0x0d, 0x57, 0x41, 0x86, 0x60, 8 | 0xa1, 0xc1, 0x27, 0x91, 0x5b, 0x0a, 0x98, 0x46, 0x1b, 0xf6, 0xa2, 0x84, 9 | 0xf8, 0x65, 0xc7, 0xce, 0x2d, 0x96, 0x17, 0xaa, 0x91, 0xf8, 0x61, 0x04, 10 | 0x50, 0x70, 0xeb, 0xb4, 0x43, 0xb7, 0xdc, 0x9a, 0xcc, 0x31, 0x01, 0x14, 11 | 0xd4, 0xcd, 0xcc, 0xc2, 0x37, 0x6d, 0x69, 0x82, 0xd6, 0xc6, 0xc4, 0xbe, 12 | 0xf2, 0x34, 0xa5, 0xc9, 0xa6, 0x19, 0x53, 0x32, 0x7a, 0x86, 0x0e, 0x91, 13 | 0x82, 0x0f, 0xa1, 0x42, 0x54, 0xaa, 0x01, 0x02, 0x03, 0x01, 0x00, 0x01, 14 | 0x02, 0x81, 0x81, 0x00, 0x95, 0xaa, 0x6e, 0x11, 0xf5, 0x6a, 0x8b, 0xa2, 15 | 0xc6, 0x48, 0xc6, 0x7c, 0x37, 0x6b, 0x1f, 0x55, 0x10, 0x76, 0x26, 0x24, 16 | 0xc3, 0xf2, 0x5c, 0x5a, 0xdd, 0x2e, 0xf3, 0xa4, 0x1e, 0xbc, 0x7b, 0x1c, 17 | 0x80, 0x10, 0x85, 0xbc, 0xd8, 0x45, 0x3c, 0xb8, 0xb2, 0x06, 0x53, 0xb5, 18 | 0xd5, 0x7a, 0xe7, 0x0e, 0x92, 0xe6, 0x42, 0xc2, 0xe2, 0x2a, 0xd5, 0xd1, 19 | 0x03, 0x9f, 0x6f, 0x53, 0x74, 0x68, 0x72, 0x8e, 0xbf, 0x03, 0xbb, 0xab, 20 | 0xbd, 0xa1, 0xf9, 0x81, 0x7d, 0x12, 0xd4, 0x9d, 0xb6, 0xae, 0x4c, 0xad, 21 | 0xca, 0xa8, 0xc9, 0x80, 0x8d, 0x0d, 0xd5, 0xd0, 0xa1, 0xbf, 0xec, 0x60, 22 | 0x48, 0x49, 0xed, 0x97, 0x0f, 0x5e, 0xed, 0xfc, 0x39, 0x15, 0x96, 0x9e, 23 | 0x5d, 0xe2, 0xb4, 0x5d, 0x2e, 0x04, 0xdc, 0x08, 0xa2, 0x65, 0x29, 0x2d, 24 | 0x37, 0xfb, 0x62, 0x90, 0x1b, 0x7b, 0xe5, 0x3a, 0x58, 0x05, 0x55, 0xc1, 25 | 0x02, 0x41, 0x00, 0xfc, 0x69, 0x28, 0xc9, 0xa8, 0xc4, 0x5c, 0xe3, 0xd0, 26 | 0x5e, 0xaa, 0xda, 0xde, 0x87, 0x74, 0xdb, 0xcb, 0x40, 0x78, 0x8e, 0x1d, 27 | 0x12, 0x96, 0x16, 0x61, 0x3f, 0xb3, 0x3e, 0xa3, 0x0d, 0xdc, 0x49, 0xa5, 28 | 0x25, 0x87, 0xc5, 0x97, 0x85, 0x9d, 0xbb, 0xb4, 0xf0, 0x44, 0xfd, 0x6c, 29 | 0xe8, 0xd2, 0x8c, 0xec, 0x33, 0x81, 0x46, 0x1e, 0x10, 0x12, 0x33, 0x16, 30 | 0x95, 0x00, 0x4f, 0x75, 0xb4, 0xe5, 0x79, 0x02, 0x41, 0x00, 0xd0, 0xeb, 31 | 0x65, 0x07, 0x10, 0x3b, 0xd9, 0x03, 0xeb, 0xdc, 0x6f, 0x4b, 0x8f, 0xc3, 32 | 0x87, 0xce, 0x76, 0xd6, 0xc5, 0x14, 0x21, 0x4e, 0xe7, 0x4f, 0x1b, 0xe8, 33 | 0x05, 0xf8, 0x84, 0x1a, 0xe0, 0xc5, 0xd6, 0xe3, 0x08, 0xb3, 0x54, 0x57, 34 | 0x02, 0x1f, 0xd4, 0xd9, 0xfb, 0xff, 0x40, 0xb1, 0x56, 0x1c, 0x60, 0xf7, 35 | 0xac, 0x91, 0xf3, 0xd3, 0xc6, 0x7f, 0x84, 0xfd, 0x84, 0x9d, 0xea, 0x26, 36 | 0xee, 0xc9, 0x02, 0x41, 0x00, 0xa6, 0xcf, 0x1c, 0x6c, 0x81, 0x03, 0x1c, 37 | 0x5c, 0x56, 0x05, 0x6a, 0x26, 0x70, 0xef, 0xd6, 0x13, 0xb7, 0x74, 0x28, 38 | 0xf7, 0xca, 0x50, 0xd1, 0x2d, 0x83, 0x21, 0x64, 0xe4, 0xdd, 0x3f, 0x38, 39 | 0xb8, 0xd6, 0xd2, 0x41, 0xb3, 0x1c, 0x9a, 0xea, 0x0d, 0xf5, 0xda, 0xdf, 40 | 0xcd, 0x17, 0x9f, 0x9a, 0x1e, 0x15, 0xaf, 0x48, 0x1c, 0xbd, 0x9b, 0x63, 41 | 0x5b, 0xad, 0xed, 0xd4, 0xa1, 0xae, 0xa9, 0x59, 0x09, 0x02, 0x40, 0x4e, 42 | 0x08, 0xce, 0xa8, 0x8f, 0xc0, 0xba, 0xf3, 0x83, 0x02, 0xc8, 0x33, 0x62, 43 | 0x14, 0x77, 0xc2, 0x7f, 0x93, 0x02, 0xf3, 0xdc, 0xe9, 0x1a, 0xee, 0xea, 44 | 0x8e, 0x84, 0xc4, 0x69, 0x9b, 0x9c, 0x7f, 0x69, 0x1f, 0x4e, 0x1d, 0xa5, 45 | 0x90, 0x06, 0x44, 0x1b, 0x7d, 0xfc, 0x69, 0x40, 0x21, 0xbc, 0xf7, 0x46, 46 | 0xa4, 0xdc, 0x39, 0x7b, 0xe8, 0x8b, 0x49, 0x10, 0x44, 0x9d, 0x67, 0x5a, 47 | 0x91, 0x86, 0x39, 0x02, 0x40, 0x41, 0x2c, 0x4e, 0xfe, 0xd9, 0x90, 0x89, 48 | 0x00, 0x5c, 0x94, 0x0a, 0x4a, 0x7e, 0x1b, 0x1a, 0x80, 0x06, 0x01, 0x37, 49 | 0xda, 0x50, 0x61, 0x9d, 0x9c, 0xfe, 0x25, 0x7f, 0xd8, 0xd4, 0xc4, 0x9e, 50 | 0x81, 0xf2, 0x0c, 0x1e, 0x38, 0x21, 0x1e, 0x90, 0x3f, 0xd4, 0xba, 0x6c, 51 | 0x53, 0xcb, 0xf0, 0x77, 0x79, 0x9b, 0xf1, 0xfa, 0x3f, 0x81, 0xdc, 0xf3, 52 | 0x21, 0x02, 0x6d, 0xb7, 0x95, 0xc3, 0x2e, 0xce, 0xd5 53 | }; 54 | unsigned int default_private_key_len = 609; 55 | -------------------------------------------------------------------------------- /include/ssl/ssl_version.h: -------------------------------------------------------------------------------- 1 | #define AXTLS_VERSION "1.4.9" 2 | -------------------------------------------------------------------------------- /include/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/user_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_CONFIG_H__ 2 | #define __USER_CONFIG_H__ 3 | 4 | #define ESP_PLATFORM 1 5 | #define LEWEI_PLATFORM 0 6 | 7 | #if ESP_PLATFORM 8 | #define PLUG_DEVICE 0 9 | #define LIGHT_DEVICE 0 10 | #define SENSOR_DEVICE 1 11 | 12 | #if SENSOR_DEVICE 13 | #define HUMITURE_SUB_DEVICE 1 14 | #define FLAMMABLE_GAS_SUB_DEVICE 0 15 | #endif 16 | 17 | //#define SERVER_SSL_ENABLE 18 | //#define CLIENT_SSL_ENABLE 19 | //#define UPGRADE_SSL_ENABLE 20 | 21 | #define USE_DNS 22 | 23 | #ifdef USE_DNS 24 | #define ESP_DOMAIN "iot.espressif.cn" 25 | #endif 26 | 27 | #define SOFTAP_ENCRYPT 28 | 29 | #ifdef SOFTAP_ENCRYPT 30 | #define PASSWORD "v*%W>L<@i&Nxe!" 31 | #endif 32 | 33 | #if SENSOR_DEVICE 34 | #define SENSOR_DEEP_SLEEP 35 | 36 | #if HUMITURE_SUB_DEVICE 37 | #define SENSOR_DEEP_SLEEP_TIME 30000000 38 | #elif FLAMMABLE_GAS_SUB_DEVICE 39 | #define SENSOR_DEEP_SLEEP_TIME 60000000 40 | #endif 41 | #endif 42 | 43 | #if LIGHT_DEVICE 44 | #define USE_US_TIMER 45 | #endif 46 | 47 | #if PLUG_DEVICE || LIGHT_DEVICE 48 | #define BEACON_TIMEOUT 150000000 49 | #define BEACON_TIME 50000 50 | #endif 51 | 52 | #define AP_CACHE 1 53 | 54 | #if AP_CACHE 55 | #define AP_CACHE_NUMBER 5 56 | #endif 57 | 58 | #elif LEWEI_PLATFORM 59 | #endif 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /include/user_devicefind.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_DEVICEFIND_H__ 2 | #define __USER_DEVICEFIND_H__ 3 | 4 | void user_devicefind_init(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /include/user_esp_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_DEVICE_H__ 2 | #define __USER_DEVICE_H__ 3 | 4 | /* NOTICE---this is for 512KB spi flash. 5 | * you can change to other sector if you use other size spi flash. */ 6 | #define ESP_PARAM_START_SEC 0x3C 7 | 8 | #define ESP_PARAM_SAVE_0 1 9 | #define ESP_PARAM_SAVE_1 2 10 | #define ESP_PARAM_FLAG 3 11 | 12 | #define packet_size (2 * 1024) 13 | 14 | #define token_size 41 15 | 16 | struct esp_platform_saved_param { 17 | uint8 devkey[40]; 18 | uint8 token[40]; 19 | uint8 activeflag; 20 | uint8 pad[3]; 21 | }; 22 | 23 | struct esp_platform_sec_flag_param { 24 | uint8 flag; 25 | uint8 pad[3]; 26 | }; 27 | 28 | enum { 29 | DEVICE_CONNECTING = 40, 30 | DEVICE_ACTIVE_DONE, 31 | DEVICE_ACTIVE_FAIL, 32 | DEVICE_CONNECT_SERVER_FAIL 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/user_esp_platform_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_DEVICEFIND_H__ 2 | #define __USER_DEVICEFIND_H__ 3 | 4 | void user_platform_timer_start(char* pbuffer, struct espconn *pespconn); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /include/user_iot_version.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_IOT_VERSION_H__ 2 | #define __USER_IOT_VERSION_H__ 3 | 4 | #include "user_config.h" 5 | 6 | #define IOT_VERSION_MAJOR 1U 7 | #define IOT_VERSION_MINOR 0U 8 | #define IOT_VERSION_REVISION 1U 9 | 10 | #define VERSION_NUM (IOT_VERSION_MAJOR * 1000 + IOT_VERSION_MINOR * 100 + IOT_VERSION_REVISION) 11 | 12 | #define VERSION_TYPE "b" 13 | //#define VERSION_TYPE "v" 14 | 15 | #if LIGHT_DEVICE 16 | #define device_type 45772 17 | #elif PLUG_DEVICE 18 | #define device_type 23701 19 | #elif SENSOR_DEVICE 20 | #define device_type 12335 21 | #endif 22 | 23 | 24 | #define ONLINE_UPGRADE 0 25 | #define LOCAL_UPGRADE 0 26 | #define ALL_UPGRADE 1 27 | #define NONE_UPGRADE 0 28 | 29 | #if ONLINE_UPGRADE 30 | #define UPGRADE_FALG "O" 31 | #elif LOCAL_UPGRADE 32 | #define UPGRADE_FALG "l" 33 | #elif ALL_UPGRADE 34 | #define UPGRADE_FALG "a" 35 | #elif NONE_UPGRADE 36 | #define UPGRADE_FALG "n" 37 | #endif 38 | 39 | #define IOT_VERSION 40 | 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /include/user_json.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_JSON_H__ 2 | #define __USER_JSON_H__ 3 | 4 | #include "json/jsonparse.h" 5 | #include "json/jsontree.h" 6 | 7 | #define jsonSize 2*1024 8 | 9 | void json_parse(struct jsontree_context *json, char *ptrJSONMessage); 10 | 11 | void json_ws_send(struct jsontree_value *tree, const char *path, char *pbuf); 12 | 13 | int json_putchar(int c); 14 | 15 | struct jsontree_value *find_json_path(struct jsontree_context *json, const char *path); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/user_light.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_LIGHT_H__ 2 | #define __USER_LIGHT_H__ 3 | 4 | #include "driver/pwm.h" 5 | 6 | /* NOTICE---this is for 512KB spi flash. 7 | * you can change to other sector if you use other size spi flash. */ 8 | #define PRIV_PARAM_START_SEC 0x3C 9 | 10 | #define PRIV_PARAM_SAVE 0 11 | 12 | #define LIGHT_RED 0 13 | #define LIGHT_GREEN 1 14 | #define LIGHT_BLUE 2 15 | #define LIGHE_LEVEL 3 16 | 17 | struct light_saved_param { 18 | uint16 pwm_freq; 19 | uint8 pwm_duty[PWM_CHANNEL]; 20 | uint8 pad[6-PWM_CHANNEL]; 21 | }; 22 | 23 | void user_light_init(void); 24 | uint8 user_light_get_duty(uint8 channel); 25 | void user_light_set_duty(uint8 duty, uint8 channel); 26 | uint16 user_light_get_freq(void); 27 | void user_light_set_freq(uint16 freq); 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /include/user_plug.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_ESPSWITCH_H__ 2 | #define __USER_ESPSWITCH_H__ 3 | 4 | #include "driver/key.h" 5 | 6 | /* NOTICE---this is for 512KB spi flash. 7 | * you can change to other sector if you use other size spi flash. */ 8 | #define PRIV_PARAM_START_SEC 0x3C 9 | 10 | #define PRIV_PARAM_SAVE 0 11 | 12 | #define PLUG_KEY_NUM 1 13 | 14 | #define PLUG_KEY_0_IO_MUX PERIPHS_IO_MUX_MTCK_U 15 | #define PLUG_KEY_0_IO_NUM 13 16 | #define PLUG_KEY_0_IO_FUNC FUNC_GPIO13 17 | 18 | #define PLUG_WIFI_LED_IO_MUX PERIPHS_IO_MUX_GPIO0_U 19 | #define PLUG_WIFI_LED_IO_NUM 0 20 | #define PLUG_WIFI_LED_IO_FUNC FUNC_GPIO0 21 | 22 | #define PLUG_LINK_LED_IO_MUX PERIPHS_IO_MUX_MTDI_U 23 | #define PLUG_LINK_LED_IO_NUM 12 24 | #define PLUG_LINK_LED_IO_FUNC FUNC_GPIO12 25 | 26 | #define PLUG_RELAY_LED_IO_MUX PERIPHS_IO_MUX_MTDO_U 27 | #define PLUG_RELAY_LED_IO_NUM 15 28 | #define PLUG_RELAY_LED_IO_FUNC FUNC_GPIO15 29 | 30 | #define PLUG_STATUS_OUTPUT(pin, on) GPIO_OUTPUT_SET(pin, on) 31 | 32 | struct plug_saved_param { 33 | uint8_t status; 34 | uint8_t pad[3]; 35 | }; 36 | 37 | void user_plug_init(void); 38 | uint8 user_plug_get_status(void); 39 | void user_plug_set_status(bool status); 40 | 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /include/user_sensor.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_SENSOR_H__ 2 | #define __USER_SENSOR_H__ 3 | 4 | #include "user_config.h" 5 | #include "driver/key.h" 6 | 7 | #define SENSOR_KEY_NUM 1 8 | 9 | #define SENSOR_KEY_IO_MUX PERIPHS_IO_MUX_MTCK_U 10 | #define SENSOR_KEY_IO_NUM 13 11 | #define SENSOR_KEY_IO_FUNC FUNC_GPIO13 12 | 13 | #define SENSOR_WIFI_LED_IO_MUX PERIPHS_IO_MUX_GPIO0_U 14 | #define SENSOR_WIFI_LED_IO_NUM 0 15 | #define SENSOR_WIFI_LED_IO_FUNC FUNC_GPIO0 16 | 17 | #define SENSOR_LINK_LED_IO_MUX PERIPHS_IO_MUX_MTDI_U 18 | #define SENSOR_LINK_LED_IO_NUM 12 19 | #define SENSOR_LINK_LED_IO_FUNC FUNC_GPIO12 20 | 21 | #define SENSOR_UNUSED_LED_IO_MUX PERIPHS_IO_MUX_MTDO_U 22 | #define SENSOR_UNUSED_LED_IO_NUM 15 23 | #define SENSOR_UNUSED_LED_IO_FUNC FUNC_GPIO15 24 | 25 | #if HUMITURE_SUB_DEVICE 26 | bool user_mvh3004_read_th(uint8 *data); 27 | void user_mvh3004_init(void); 28 | #endif 29 | 30 | void user_sensor_init(uint8 active); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/user_webserver.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_WEBSERVER_H__ 2 | #define __USER_WEBSERVER_H__ 3 | 4 | #define SERVER_PORT 80 5 | #define SERVER_SSL_PORT 443 6 | 7 | #define URLSize 10 8 | 9 | typedef enum Result_Resp { 10 | RespFail = 0, 11 | RespSuc, 12 | } Result_Resp; 13 | 14 | typedef enum ProtocolType { 15 | GET = 0, 16 | POST, 17 | } ProtocolType; 18 | 19 | typedef enum _ParmType { 20 | SWITCH_STATUS = 0, 21 | INFOMATION, 22 | WIFI, 23 | SCAN, 24 | REBOOT, 25 | DEEP_SLEEP, 26 | LIGHT_STATUS, 27 | CONNECT_STATUS, 28 | USER_BIN 29 | } ParmType; 30 | 31 | typedef struct URL_Frame { 32 | enum ProtocolType Type; 33 | char pSelect[URLSize]; 34 | char pCommand[URLSize]; 35 | char pFilename[URLSize]; 36 | } URL_Frame; 37 | 38 | typedef struct _rst_parm { 39 | ParmType parmtype; 40 | struct espconn *pespconn; 41 | } rst_parm; 42 | 43 | void user_webserver_init(uint32 port); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /user/empty_user_rf_pre_init.c: -------------------------------------------------------------------------------- 1 | // Provide default empty implementation of user_rf_pre_init 2 | // to maintain compatibility with older SDK versions. 3 | void user_rf_pre_init(void) 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /user/header.h: -------------------------------------------------------------------------------- 1 | struct ieee80211_frame { 2 | uint8 i_fc[2]; 3 | uint8 i_dur[2]; 4 | uint8 i_addr1[6]; 5 | uint8 i_addr2[6]; 6 | uint8 i_addr3[6]; 7 | uint8 i_seq[2]; 8 | uint8 i_data[]; 9 | }; 10 | 11 | struct _ebuf_sub1 { 12 | uint8 data[24]; 13 | /* byte 10 increases by 8 for a 1 byte increase in the length. */ 14 | /* bytes 16 to 19 appear to be a timestamp in microseconds */ 15 | }; 16 | 17 | struct esf_buf { 18 | struct pbuf *pb1; /* 0 */ 19 | struct pbuf *pb2; /* 4 */ 20 | struct pbuf *pb3; /* 8 */ 21 | uint16 cnt1; /* 12 */ 22 | uint8 flg; /* 14 */ 23 | uint8 pad1[1]; 24 | struct ieee80211_frame *e_data; /* 16 */ 25 | uint16 len1; /* 20 */ 26 | uint16 len2; /* 22 */ 27 | uint8 pad2[4]; 28 | uint32 type1; /* 28 */ 29 | struct esf_buf *next; /* 32 */ 30 | struct _ebuf_sub1 *ep; /* 36 */ 31 | }; 32 | 33 | static void print_esf_buf(struct esf_buf *ebuf) 34 | { 35 | int i; 36 | 37 | ets_uart_printf("ebuf = %p {\n", ebuf); 38 | ets_uart_printf("\tpb1 = %p\n", ebuf->pb1); 39 | ets_uart_printf("\tpb2 = %p\n", ebuf->pb2); 40 | ets_uart_printf("\tpb3 = %p\n", ebuf->pb3); 41 | ets_uart_printf("\tcnt1 = %d\n", ebuf->cnt1); 42 | ets_uart_printf("\tflg = 0x%02x\n", ebuf->flg); 43 | ets_uart_printf("\tpad1 = 0x%02x\n", ebuf->pad1[0]); 44 | ets_uart_printf("\te_data = %p {", ebuf->e_data); 45 | 46 | for (i = 0; i < 32; i++) { 47 | ets_uart_printf("0x%02x, ", ((uint8 *)(ebuf->e_data))[i]); 48 | } 49 | 50 | ets_uart_printf("0x%02x}\n", ((uint8 *)(ebuf->e_data))[32]); 51 | ets_uart_printf("\tlen1 = %d\n", ebuf->len1); 52 | ets_uart_printf("\tlen2 = %d\n", ebuf->len2); 53 | ets_uart_printf("\tpad2 = %02x %02x %02x %02x\n", ebuf->pad2[0], ebuf->pad2[1], ebuf->pad2[2], ebuf->pad2[3]); 54 | ets_uart_printf("\ttype1 = %p\n", (void *)(ebuf->type1)); 55 | ets_uart_printf("\tep = %p {", ebuf->ep); 56 | 57 | for (i = 0; i < 23; i++) { 58 | ets_uart_printf("0x%02x, ", ebuf->ep->data[i]); 59 | } 60 | 61 | ets_uart_printf("0x%02x}\n"); 62 | ets_uart_printf("}\n"); 63 | } 64 | -------------------------------------------------------------------------------- /user/tests/raw_packets: -------------------------------------------------------------------------------- 1 | #include "netif.h" 2 | #include "pbuf.h" 3 | #include "osapi.h" 4 | 5 | #define STATION_IF 0x00 6 | #define STATION_MODE 0x01 7 | 8 | #define SOFTAP_IF 0x01 9 | #define SOFTAP_MODE 0x02 10 | 11 | extern void ICACHE_FLASH_ATTR ppTxPkt(void *); 12 | 13 | static bool called = false; 14 | ETSTimer timer; 15 | 16 | void ICACHE_FLASH_ATTR send_paket(void *arg) 17 | { 18 | struct netif *ifp; 19 | struct pbuf *pb; 20 | err_t rc; 21 | char header[] = {0xff}; 22 | char payload[] = {'W', 'A', 'S', 'S', 'U', 'P', ' ', 'P', 'E', 'O', 'P', 'L', 'E', '?', '$'}; 23 | char packet[sizeof header + sizeof payload]; 24 | 25 | os_memcpy(packet, header, sizeof header); 26 | os_memcpy(packet + sizeof header, payload, sizeof payload); 27 | 28 | ifp = (struct netif *)eagle_lwip_getif(SOFTAP_IF); 29 | ((uint32 *)(ifp->state))[11] = 5; 30 | 31 | pb = pbuf_alloc(PBUF_LINK, sizeof packet, PBUF_RAM); 32 | 33 | ets_uart_printf("pbuf_alloc\n"); 34 | 35 | if (pb == NULL) 36 | ets_uart_printf("pbuf_alloc failed.\n"); 37 | 38 | ets_uart_printf("pbuf_take\n"); 39 | if (pbuf_take(pb, packet, sizeof packet) != ERR_OK) 40 | ets_uart_printf("pbuf_take failed.\n"); 41 | 42 | called = true; 43 | if (rc = ieee80211_output_pbuf(ifp, pb)) 44 | ets_uart_printf("ieee80211_output_pbuf failed: rc = %d\n", rc); 45 | else 46 | ets_uart_printf("greeeaaat sucess!\n"); 47 | 48 | called = false; 49 | pbuf_free(pb); 50 | } 51 | 52 | void ICACHE_FLASH_ATTR aaTxPkt(void *a) 53 | { 54 | int i; 55 | char *b; 56 | 57 | if (called) { 58 | b = ((char **)a)[4]; 59 | ets_uart_printf("%p:\n", b); 60 | 61 | for (i = 0; i < 104; i++) 62 | ets_uart_printf("%02x ", ((uint8 *)b)[i]); 63 | 64 | ets_uart_printf("\n\n"); 65 | // for (i = 0; i < 47; i++) 66 | // b[i] = '\xde'; 67 | } 68 | 69 | ppTxPkt(a); 70 | } 71 | 72 | void ICACHE_FLASH_ATTR init_done() 73 | { 74 | int i; 75 | 76 | os_timer_disarm(&timer); 77 | os_timer_setfn(&timer, send_paket, NULL); 78 | os_timer_arm(&timer, 1000, 1); 79 | } 80 | 81 | void ICACHE_FLASH_ATTR user_init() 82 | { 83 | uart_div_modify(0, UART_CLK_FREQ / 115200); 84 | wifi_set_opmode(SOFTAP_MODE); 85 | wifi_station_set_auto_connect(0); 86 | system_init_done_cb(init_done); 87 | } 88 | -------------------------------------------------------------------------------- /user/tests/success: -------------------------------------------------------------------------------- 1 | #include "netif.h" 2 | #include "pbuf.h" 3 | 4 | #define STATION_IF 0x00 5 | #define STATION_MODE 0x01 6 | 7 | #define HOSTAP_IF 0x01 8 | #define HOSTAP_MODE 0x02 9 | 10 | void ICACHE_FLASH_ATTR init_done() 11 | { 12 | struct netif *ifp; 13 | struct pbuf *pb; 14 | err_t rc; 15 | char payload[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 'k', 'a', 'w', 'q'}; 16 | 17 | ifp = (struct netif *)eagle_lwip_getif(HOSTAP_IF); 18 | pb = pbuf_alloc(PBUF_LINK, 100, PBUF_RAM); 19 | 20 | ets_uart_printf("pbuf_alloc\n"); 21 | 22 | if (pb == NULL) 23 | ets_uart_printf("pbuf_alloc failed.\n"); 24 | 25 | ets_uart_printf("pbuf_take\n"); 26 | if (pbuf_take(pb, payload, 18) != ERR_OK) 27 | ets_uart_printf("pbuf_take failed.\n"); 28 | 29 | ets_uart_printf("state + 44: 0x%08x\n", *((uint32 *)((uint8 *)(ifp->state) + 44))); 30 | ets_uart_printf("pbuf: %p\n", pb); 31 | ets_uart_printf("checker(?): %p\n", *((uint32 *)((uint8 *)(ifp->state) + 160))); 32 | ets_uart_printf("node(?): %p\n", *((uint32 *)((uint8 *)(ifp->state) + 120))); 33 | ets_uart_printf("$a4: 0x%04x\n", *(uint16 *)(*((uint32 *)((uint8 *)(ifp->state) + 120))) + 26); 34 | ets_uart_printf("$a5: 0x%08x\n", *(uint32 *)(*((uint32 *)((uint8 *)(ifp->state) + 120))) + 8); 35 | 36 | if (rc = ieee80211_output_pbuf(ifp, pb)) 37 | ets_uart_printf("ieee80211_output_pbuf failed: rc = %d\n", rc); 38 | else 39 | ets_uart_printf("greeeaaat sucess!\n"); 40 | } 41 | 42 | void ICACHE_FLASH_ATTR user_init() 43 | { 44 | wifi_set_opmode(HOSTAP_MODE); 45 | system_init_done_cb(init_done); 46 | uart_div_modify(0, UART_CLK_FREQ / 115200); 47 | } 48 | -------------------------------------------------------------------------------- /user/tests/success2: -------------------------------------------------------------------------------- 1 | #include "netif.h" 2 | #include "pbuf.h" 3 | 4 | #define STATION_IF 0x00 5 | #define STATION_MODE 0x01 6 | 7 | #define HOSTAP_IF 0x01 8 | #define HOSTAP_MODE 0x02 9 | 10 | void ICACHE_FLASH_ATTR init_done() 11 | { 12 | struct netif *ifp; 13 | struct pbuf *pb; 14 | err_t rc; 15 | char payload[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 'k', 'a', 'w', 'q'}; 16 | 17 | ifp = (struct netif *)eagle_lwip_getif(HOSTAP_IF); 18 | pb = pbuf_alloc(PBUF_LINK, 100, PBUF_RAM); 19 | 20 | ets_uart_printf("pbuf_alloc\n"); 21 | 22 | if (pb == NULL) 23 | ets_uart_printf("pbuf_alloc failed.\n"); 24 | 25 | ets_uart_printf("pbuf_take\n"); 26 | if (pbuf_take(pb, payload, 18) != ERR_OK) 27 | ets_uart_printf("pbuf_take failed.\n"); 28 | 29 | ets_uart_printf("state + 44: 0x%08x\n", *((uint32 *)((uint8 *)(ifp->state) + 44))); 30 | ets_uart_printf("pbuf: %p\n", pb); 31 | ets_uart_printf("checker(?): %p\n", *((uint32 *)((uint8 *)(ifp->state) + 160))); 32 | ets_uart_printf("node(?): %p\n", *((uint32 *)((uint8 *)(ifp->state) + 120))); 33 | ets_uart_printf("$a4: 0x%04x\n", *(uint16 *)(*((uint32 *)((uint8 *)(ifp->state) + 120))) + 26); 34 | ets_uart_printf("$a5: 0x%08x\n", *(uint32 *)(*((uint32 *)((uint8 *)(ifp->state) + 120))) + 8); 35 | 36 | if (rc = ieee80211_output_pbuf(ifp, pb)) 37 | ets_uart_printf("ieee80211_output_pbuf failed: rc = %d\n", rc); 38 | else 39 | ets_uart_printf("greeeaaat sucess!\n"); 40 | } 41 | 42 | void ICACHE_FLASH_ATTR user_init() 43 | { 44 | wifi_set_opmode(HOSTAP_MODE); 45 | system_init_done_cb(init_done); 46 | uart_div_modify(0, UART_CLK_FREQ / 115200); 47 | } 48 | -------------------------------------------------------------------------------- /user/user_config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ernacktob/esp8266_wifi_raw/9223f28b264daf03056cc057e8c97103716c6355/user/user_config.h -------------------------------------------------------------------------------- /user/user_main.c: -------------------------------------------------------------------------------- 1 | #define LWIP_OPEN_SRC 2 | 3 | #include "netif.h" 4 | #include "pbuf.h" 5 | #include "osapi.h" 6 | #include "mem.h" 7 | #include "user_interface.h" 8 | 9 | #include "wifi_raw.h" 10 | 11 | #define STATION_IF 0x00 12 | #define STATION_MODE 0x01 13 | 14 | #define SOFTAP_IF 0x01 15 | #define SOFTAP_MODE 0x02 16 | 17 | ETSTimer timer; 18 | 19 | /* function that sends the raw packet. 20 | Note: the actual packet sent over the air may be longer because 21 | the driver functions seem to allocate memory for the whole IEEE-802.11 22 | header even if the packet is shorter... 23 | 24 | Currently, packets of length less than or equal to 18 bytes have 25 | additional bytes over the air until it reaches 19 bytes. For larger packets, 26 | the length should be correct. */ 27 | void ICACHE_FLASH_ATTR send_packet(void *arg) 28 | { 29 | char packet[64]; 30 | 31 | packet[0] = '\xde'; 32 | packet[1] = '\xad'; 33 | packet[2] = '\xbe'; /* This will become \x00 */ 34 | packet[3] = '\xef'; /* This too. */ 35 | os_sprintf(packet + 4, "%s%s%s%s%s", "HELLO WORLD!", "HELLO WORLD!", "HELLO WORLD!", "HELLO WORLD!", "HaLLO w0RLD!"); 36 | 37 | wifi_send_raw_packet(packet, sizeof packet); 38 | wifi_set_channel(1); 39 | } 40 | 41 | void ICACHE_FLASH_ATTR my_recv_cb(struct RxPacket *pkt) 42 | { 43 | static int counter = 0; 44 | uint16 len; 45 | uint16 i, j; 46 | 47 | len = pkt->rx_ctl.legacy_length; 48 | ets_uart_printf("Recv callback #%d: %d bytes\n", counter++, len); 49 | ets_uart_printf("Channel: %d PHY: %d\n", pkt->rx_ctl.channel, wifi_get_phy_mode()); 50 | 51 | i = 0; 52 | 53 | while (i < len / 16) { 54 | ets_uart_printf("0x%04x: ", i); 55 | 56 | for (j = 0; j < 8; j++) { 57 | ets_uart_printf("%02x", pkt->data[16 * i + 2 * j]); 58 | ets_uart_printf("%02x ", pkt->data[16 * i + 2 * j + 1]); 59 | } 60 | 61 | ets_uart_printf("\t"); 62 | 63 | for (j = 0; j < 16; j++) { 64 | if ((pkt->data[16 * i + j] >= ' ') && (pkt->data[16 * i + j] <= '~')) 65 | ets_uart_printf("%c", pkt->data[16 * i + j]); 66 | else 67 | ets_uart_printf("."); 68 | } 69 | 70 | ets_uart_printf("\n"); 71 | ++i; 72 | } 73 | 74 | if (len % 16 != 0) { 75 | ets_uart_printf("0x%04x: ", i); 76 | 77 | for (j = 0; j < len % 16; j++) { 78 | ets_uart_printf("%02x", pkt->data[16 * i + j]); 79 | 80 | if (j % 2 == 1) 81 | ets_uart_printf(" "); 82 | } 83 | 84 | for (; j < 16; j++) { 85 | ets_uart_printf(" "); 86 | ets_uart_printf(" "); 87 | 88 | if (j % 2 == 1) 89 | ets_uart_printf(" "); 90 | } 91 | 92 | ets_uart_printf("\t"); 93 | 94 | for (j = 0; j < len % 16; j++) { 95 | if ((pkt->data[16 * i + j] >= ' ') && (pkt->data[16 * i + j] <= '~')) 96 | ets_uart_printf("%c", pkt->data[16 * i + j]); 97 | else 98 | ets_uart_printf("."); 99 | } 100 | 101 | ets_uart_printf("\n"); 102 | } 103 | 104 | ets_uart_printf("\n"); 105 | } 106 | 107 | void ICACHE_FLASH_ATTR init_done() 108 | { 109 | // Note that it is impossible to see all packets 110 | // on all channels and physical modes 111 | // Select a phy 802.11 b/g/n etc. and a channel 112 | // in order to receive packets. 113 | // Note: ESP8266 does not appear to support 5GHz. 114 | wifi_set_channel(1); 115 | wifi_set_phy_mode(2); 116 | /* Note: it appears the channel might get reset to default (6) 117 | after a wifi_set_opmode call (maybe, we aren't sure 118 | if that's the case). Also, we got some watchdog resets once. */ 119 | os_timer_disarm(&timer); 120 | os_timer_setfn(&timer, send_packet, NULL); 121 | os_timer_arm(&timer, 500, 1); 122 | wifi_raw_set_recv_cb(my_recv_cb); 123 | } 124 | 125 | void ICACHE_FLASH_ATTR user_init() 126 | { 127 | system_set_os_print(0); 128 | uart_div_modify(0, UART_CLK_FREQ / 115200); 129 | wifi_set_opmode(STATION_MODE); 130 | system_init_done_cb(init_done); 131 | } 132 | -------------------------------------------------------------------------------- /user/wifi_raw.h: -------------------------------------------------------------------------------- 1 | #ifndef WIFI_RAW 2 | #define WIFI_RAW 3 | 4 | #include "c_types.h" 5 | 6 | struct RxControl { 7 | signed rssi:8; 8 | unsigned rate:4; 9 | unsigned is_group:1; 10 | unsigned:1; 11 | unsigned sig_mode:2; 12 | unsigned legacy_length:12; 13 | unsigned damatch0:1; 14 | unsigned damatch1:1; 15 | unsigned bssidmatch0:1; 16 | unsigned bssidmatch1:1; 17 | unsigned MCS:7; 18 | unsigned CWB:1; 19 | unsigned HT_length:16; 20 | unsigned Smoothing:1; 21 | unsigned Not_Sounding:1; 22 | unsigned:1; 23 | unsigned Aggregation:1; 24 | unsigned STBC:2; 25 | unsigned FEC_CODING:1; 26 | unsigned SGI:1; 27 | unsigned rxend_state:8; 28 | unsigned ampdu_cnt:8; 29 | unsigned channel:4; 30 | unsigned:12; 31 | }; 32 | 33 | struct RxPacket { 34 | struct RxControl rx_ctl; 35 | uint8 data[]; 36 | }; 37 | 38 | typedef void (*wifi_raw_recv_cb_fn)(struct RxPacket *); 39 | 40 | void ICACHE_FLASH_ATTR wifi_set_raw_recv_cb(wifi_raw_recv_cb_fn rx_fn); 41 | void ICACHE_FLASH_ATTR wifi_send_raw_packet(void *buf, uint16 len); 42 | 43 | #endif 44 | --------------------------------------------------------------------------------