Commit a6c0873a authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Upgrade to SDK 1.5.0 + Espressif's Open LWIP 1.5.0.

Removed earlier TCP port randomisation fix - the new SDK has its own fix
even though Espressif told me they wouldn't fix it. Yay?
parent 1462d00e
# copyright (c) 2010 Espressif System # copyright (c) 2010 Espressif System
# #
.NOTPARALLEL: .NOTPARALLEL:
ifndef PDIR
endif
# SDK version NodeMCU is locked to # SDK version NodeMCU is locked to
SDK_VER:=1.4.0 SDK_VER:=1.5.0
# Ensure we search "our" SDK before the tool-chain's SDK (if any) # Ensure we search "our" SDK before the tool-chain's SDK (if any)
TOP_DIR:=$(dir $(lastword $(MAKEFILE_LIST))) TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
SDK_DIR:=$(TOP_DIR)sdk/esp_iot_sdk_v$(SDK_VER) SDK_DIR:=$(TOP_DIR)/sdk/esp_iot_sdk_v$(SDK_VER)
CCFLAGS:= -I$(TOP_DIR)sdk-overrides/include -I$(SDK_DIR)/include CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(SDK_DIR)/include
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS) LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
############################################################# #############################################################
...@@ -171,11 +168,21 @@ $(BINODIR)/%.bin: $(IMAGEODIR)/%.out ...@@ -171,11 +168,21 @@ $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
# Should be done in top-level makefile only # Should be done in top-level makefile only
# #
all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS) all: sdk_extracted .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
.PHONY: sdk_extracted
sdk_extracted: $(TOP_DIR)/sdk/.extracted
$(TOP_DIR)/sdk/.extracted:
mkdir -p "$(dir $@)"
(cd "$(dir $@)" && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_VER)*.zip esp_iot_sdk_v$(SDK_VER)/lib/* esp_iot_sdk_v$(SDK_VER)/ld/eagle.rom.addr.v6.ld esp_iot_sdk_v$(SDK_VER)/include/* )
rm -f $(SDK_DIR)/lib/liblwip.a
touch $@
clean: clean:
$(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clean;) $(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clean;)
$(RM) -r $(ODIR)/$(TARGET)/$(FLAVOR) $(RM) -r $(ODIR)/$(TARGET)/$(FLAVOR)
$(RM) -r "$(TOP_DIR)/sdk"
clobber: $(SPECIAL_CLOBBER) clobber: $(SPECIAL_CLOBBER)
$(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clobber;) $(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clobber;)
......
# **NodeMCU 1.4.0** # # **NodeMCU 1.5.0** #
[![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware) [![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware)
###A lua based firmware for wifi-soc esp8266 ###A lua based firmware for wifi-soc esp8266
- Build on [ESP8266 NONOS SDK 1.4.0](http://bbs.espressif.com/viewtopic.php?f=46&t=1124) - Build on [ESP8266 NONOS SDK 1.5.0](http://bbs.espressif.com/viewtopic.php?f=46&t=1124)
- Lua core based on [eLua project](http://www.eluaproject.net/) - Lua core based on [eLua project](http://www.eluaproject.net/)
- cjson based on [lua-cjson](https://github.com/mpx/lua-cjson) - cjson based on [lua-cjson](https://github.com/mpx/lua-cjson)
- File system based on [spiffs](https://github.com/pellepl/spiffs) - File system based on [spiffs](https://github.com/pellepl/spiffs)
...@@ -298,7 +298,7 @@ Comment-out the #define statement for unused modules. Example: ...@@ -298,7 +298,7 @@ Comment-out the #define statement for unused modules. Example:
Identify your firmware builds by editing `app/include/user_version.h` Identify your firmware builds by editing `app/include/user_version.h`
```c ```c
#define NODE_VERSION "NodeMCU 1.4.0+myname" #define NODE_VERSION "NodeMCU 1.5.0+myname"
#ifndef BUILD_DATE #ifndef BUILD_DATE
#define BUILD_DATE "YYYYMMDD" #define BUILD_DATE "YYYYMMDD"
#endif #endif
......
...@@ -112,10 +112,12 @@ LINKFLAGS_eagle.app.v6 = \ ...@@ -112,10 +112,12 @@ LINKFLAGS_eagle.app.v6 = \
-lpp \ -lpp \
-lnet80211 \ -lnet80211 \
-lwpa \ -lwpa \
-lwpa2 \
-lmain \ -lmain \
-ljson \ -ljson \
-lsmartconfig \ -lsmartconfig \
-lssl \ -lssl \
-lcrypto \
$(DEP_LIBS_eagle.app.v6) \ $(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group \ -Wl,--end-group \
-lm -lm
......
...@@ -169,7 +169,7 @@ typedef struct _espconn_msg{ ...@@ -169,7 +169,7 @@ typedef struct _espconn_msg{
struct espconn *pespconn; struct espconn *pespconn;
comon_pkt pcommon; comon_pkt pcommon;
uint8 count_opt; uint8 count_opt;
int16_t hs_status; //the status of the handshake sint16_t hs_status; //the status of the handshake
void *preverse; void *preverse;
void *pssl; void *pssl;
struct _espconn_msg *pnext; struct _espconn_msg *pnext;
......
...@@ -29,7 +29,7 @@ extern void espconn_kill_oldest_pcb(void); ...@@ -29,7 +29,7 @@ extern void espconn_kill_oldest_pcb(void);
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern void espconn_tcp_disconnect(espconn_msg *pdiscon); extern void espconn_tcp_disconnect(espconn_msg *pdiscon,u8 type);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_tcp_client * FunctionName : espconn_tcp_client
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
#define __USER_VERSION_H__ #define __USER_VERSION_H__
#define NODE_VERSION_MAJOR 1U #define NODE_VERSION_MAJOR 1U
#define NODE_VERSION_MINOR 4U #define NODE_VERSION_MINOR 5U
#define NODE_VERSION_REVISION 0U #define NODE_VERSION_REVISION 0U
#define NODE_VERSION_INTERNAL 0U #define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 1.4.0" #define NODE_VERSION "NodeMCU 1.5.0"
#ifndef BUILD_DATE #ifndef BUILD_DATE
#define BUILD_DATE "20151006" #define BUILD_DATE "unspecified"
#endif #endif
extern char SDK_VERSION[]; extern char SDK_VERSION[];
......
...@@ -880,10 +880,6 @@ union luai_Cast { double l_d; long l_l; }; ...@@ -880,10 +880,6 @@ union luai_Cast { double l_d; long l_l; };
#define LUA_INTFRMLEN "l" #define LUA_INTFRMLEN "l"
#define LUA_INTFRM_T long #define LUA_INTFRM_T long
#ifndef LUA_CROSS_COMPILER
typedef short int16_t;
typedef long int32_t;
#endif
#endif #endif
......
...@@ -847,7 +847,7 @@ espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, ui ...@@ -847,7 +847,7 @@ espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, ui
break; break;
case ESPCONN_UDP: case ESPCONN_UDP:
while(plist != NULL){ while(plist != NULL){
if (plist->pespconn && plist->pespconn->type == ESPCONN_UDP){ if (plist->pespconn == pespconn){
premot[pespconn->link_cnt].state = plist->pespconn->state; premot[pespconn->link_cnt].state = plist->pespconn->state;
premot[pespconn->link_cnt].remote_port = plist->pcommon.remote_port; premot[pespconn->link_cnt].remote_port = plist->pcommon.remote_port;
os_memcpy(premot[pespconn->link_cnt].remote_ip, plist->pcommon.remote_ip, 4); os_memcpy(premot[pespconn->link_cnt].remote_ip, plist->pcommon.remote_ip, 4);
...@@ -860,6 +860,8 @@ espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, ui ...@@ -860,6 +860,8 @@ espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, ui
break; break;
} }
*pcon_info = premot; *pcon_info = premot;
if (pespconn->link_cnt == 0)
return ESPCONN_ARG;
return ESPCONN_OK; return ESPCONN_OK;
} }
...@@ -954,12 +956,43 @@ espconn_disconnect(struct espconn *espconn) ...@@ -954,12 +956,43 @@ espconn_disconnect(struct espconn *espconn)
/*protect for redisconnection*/ /*protect for redisconnection*/
if (espconn->state == ESPCONN_CLOSE) if (espconn->state == ESPCONN_CLOSE)
return ESPCONN_INPROGRESS; return ESPCONN_INPROGRESS;
espconn_tcp_disconnect(pnode); espconn_tcp_disconnect(pnode,0); //1 force, 0 normal
return ESPCONN_OK;
} else
return ESPCONN_ARG;
}
/******************************************************************************
* FunctionName : espconn_abort
* Description : Forcely abort with host
* Parameters : espconn -- the espconn used to disconnect the connection
* Returns : none
*******************************************************************************/
sint8 ICACHE_FLASH_ATTR
espconn_abort(struct espconn *espconn)
{
espconn_msg *pnode = NULL;
bool value = false;
if (espconn == NULL) {
return ESPCONN_ARG;;
} else if (espconn ->type != ESPCONN_TCP)
return ESPCONN_ARG;
/*Find the node depend on the espconn message*/
value = espconn_find_connection(espconn, &pnode);
if (value){
/*protect for redisconnection*/
if (espconn->state == ESPCONN_CLOSE)
return ESPCONN_INPROGRESS;
espconn_tcp_disconnect(pnode,1); //1 force, 0 normal
return ESPCONN_OK; return ESPCONN_OK;
} else } else
return ESPCONN_ARG; return ESPCONN_ARG;
} }
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_get_packet_info * FunctionName : espconn_get_packet_info
* Description : get the packet info with host * Description : get the packet info with host
...@@ -1215,7 +1248,7 @@ espconn_port(void) ...@@ -1215,7 +1248,7 @@ espconn_port(void)
static uint32 randnum = 0; static uint32 randnum = 0;
do { do {
port = system_get_time(); port = os_random();
if (port < 0) { if (port < 0) {
port = os_random() - port; port = os_random() - port;
......
...@@ -38,12 +38,12 @@ os_event_t espconn_TaskQueue[espconn_TaskQueueLen]; ...@@ -38,12 +38,12 @@ os_event_t espconn_TaskQueue[espconn_TaskQueueLen];
static err_t static err_t
espconn_client_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); espconn_client_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
static void static void
espconn_client_close(void *arg, struct tcp_pcb *pcb); espconn_client_close(void *arg, struct tcp_pcb *pcb,u8 type);
static err_t static err_t
espconn_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); espconn_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
static void static void
espconn_server_close(void *arg, struct tcp_pcb *pcb); espconn_server_close(void *arg, struct tcp_pcb *pcb,u8 type);
///////////////////////////////common function///////////////////////////////// ///////////////////////////////common function/////////////////////////////////
/****************************************************************************** /******************************************************************************
...@@ -495,14 +495,14 @@ espconn_tcp_sent(void *arg, uint8 *psent, uint16 length) ...@@ -495,14 +495,14 @@ espconn_tcp_sent(void *arg, uint8 *psent, uint16 length)
* Parameters : arg -- Additional argument to pass to the callback function * Parameters : arg -- Additional argument to pass to the callback function
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
void ICACHE_FLASH_ATTR espconn_tcp_disconnect(espconn_msg *pdiscon) void ICACHE_FLASH_ATTR espconn_tcp_disconnect(espconn_msg *pdiscon,u8 type)
{ {
if (pdiscon != NULL){ if (pdiscon != NULL){
/*disconnect with the host by send the FIN frame*/ /*disconnect with the host by send the FIN frame*/
if (pdiscon->preverse != NULL) if (pdiscon->preverse != NULL)
espconn_server_close(pdiscon, pdiscon->pcommon.pcb); espconn_server_close(pdiscon, pdiscon->pcommon.pcb,type);
else else
espconn_client_close(pdiscon, pdiscon->pcommon.pcb); espconn_client_close(pdiscon, pdiscon->pcommon.pcb,type);
} else{ } else{
espconn_printf("espconn_tcp_disconnect err.\n"); espconn_printf("espconn_tcp_disconnect err.\n");
} }
...@@ -517,7 +517,7 @@ void ICACHE_FLASH_ATTR espconn_tcp_disconnect(espconn_msg *pdiscon) ...@@ -517,7 +517,7 @@ void ICACHE_FLASH_ATTR espconn_tcp_disconnect(espconn_msg *pdiscon)
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
espconn_client_close(void *arg, struct tcp_pcb *pcb) espconn_client_close(void *arg, struct tcp_pcb *pcb, u8 type)
{ {
err_t err; err_t err;
espconn_msg *pclose = arg; espconn_msg *pclose = arg;
...@@ -525,7 +525,11 @@ espconn_client_close(void *arg, struct tcp_pcb *pcb) ...@@ -525,7 +525,11 @@ espconn_client_close(void *arg, struct tcp_pcb *pcb)
pclose->pcommon.pcb = pcb; pclose->pcommon.pcb = pcb;
/*avoid recalling the disconnect function*/ /*avoid recalling the disconnect function*/
tcp_recv(pcb, NULL); tcp_recv(pcb, NULL);
err = tcp_close(pcb);
if(type == 0)
err = tcp_close(pcb);
else
{tcp_abort(pcb); err = ERR_OK;}
if (err != ERR_OK) { if (err != ERR_OK) {
/* closing failed, try again later */ /* closing failed, try again later */
...@@ -647,7 +651,7 @@ espconn_client_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) ...@@ -647,7 +651,7 @@ espconn_client_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
} }
if (err == ERR_OK && p == NULL) { if (err == ERR_OK && p == NULL) {
espconn_client_close(precv_cb, pcb); espconn_client_close(precv_cb, pcb,0);
} }
return ERR_OK; return ERR_OK;
...@@ -943,7 +947,7 @@ espconn_tcp_client(struct espconn *espconn) ...@@ -943,7 +947,7 @@ espconn_tcp_client(struct espconn *espconn)
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
espconn_server_close(void *arg, struct tcp_pcb *pcb) espconn_server_close(void *arg, struct tcp_pcb *pcb,u8 type)
{ {
err_t err; err_t err;
espconn_msg *psclose = arg; espconn_msg *psclose = arg;
...@@ -951,7 +955,11 @@ espconn_server_close(void *arg, struct tcp_pcb *pcb) ...@@ -951,7 +955,11 @@ espconn_server_close(void *arg, struct tcp_pcb *pcb)
psclose->pcommon.pcb = pcb; psclose->pcommon.pcb = pcb;
/*avoid recalling the disconnect function*/ /*avoid recalling the disconnect function*/
tcp_recv(pcb, NULL); tcp_recv(pcb, NULL);
err = tcp_close(pcb);
if(type ==0)
err = tcp_close(pcb);
else
{tcp_abort(pcb); err = ERR_OK;}
if (err != ERR_OK) { if (err != ERR_OK) {
/* closing failed, try again later */ /* closing failed, try again later */
...@@ -1024,7 +1032,7 @@ espconn_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) ...@@ -1024,7 +1032,7 @@ espconn_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
pbuf_free(p); pbuf_free(p);
} }
espconn_server_close(precv_cb, pcb); espconn_server_close(precv_cb, pcb,0);
} }
return ERR_OK; return ERR_OK;
...@@ -1086,7 +1094,7 @@ espconn_server_poll(void *arg, struct tcp_pcb *pcb) ...@@ -1086,7 +1094,7 @@ espconn_server_poll(void *arg, struct tcp_pcb *pcb)
if (pspoll_cb->pcommon.timeout != 0){/*no data sent in one active connection's set timeout, close.*/ if (pspoll_cb->pcommon.timeout != 0){/*no data sent in one active connection's set timeout, close.*/
if (pspoll_cb->pcommon.recv_check >= pspoll_cb->pcommon.timeout) { if (pspoll_cb->pcommon.recv_check >= pspoll_cb->pcommon.timeout) {
pspoll_cb->pcommon.recv_check = 0; pspoll_cb->pcommon.recv_check = 0;
espconn_server_close(pspoll_cb, pcb); espconn_server_close(pspoll_cb, pcb,0);
} }
} else { } else {
espconn_msg *ptime_msg = pserver_list; espconn_msg *ptime_msg = pserver_list;
...@@ -1095,7 +1103,7 @@ espconn_server_poll(void *arg, struct tcp_pcb *pcb) ...@@ -1095,7 +1103,7 @@ espconn_server_poll(void *arg, struct tcp_pcb *pcb)
if (ptime_msg->pcommon.timeout != 0){/*no data sent in server's set timeout, close.*/ if (ptime_msg->pcommon.timeout != 0){/*no data sent in server's set timeout, close.*/
if (pspoll_cb->pcommon.recv_check >= ptime_msg->pcommon.timeout){ if (pspoll_cb->pcommon.recv_check >= ptime_msg->pcommon.timeout){
pspoll_cb->pcommon.recv_check = 0; pspoll_cb->pcommon.recv_check = 0;
espconn_server_close(pspoll_cb, pcb); espconn_server_close(pspoll_cb, pcb,0);
} }
} else {/*don't close for ever*/ } else {/*don't close for ever*/
pspoll_cb->pcommon.recv_check = 0; pspoll_cb->pcommon.recv_check = 0;
...@@ -1106,7 +1114,7 @@ espconn_server_poll(void *arg, struct tcp_pcb *pcb) ...@@ -1106,7 +1114,7 @@ espconn_server_poll(void *arg, struct tcp_pcb *pcb)
} }
} }
} else { } else {
espconn_server_close(pspoll_cb, pcb); espconn_server_close(pspoll_cb, pcb,0);
} }
return ERR_OK; return ERR_OK;
......
...@@ -301,7 +301,7 @@ espconn_udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, ...@@ -301,7 +301,7 @@ espconn_udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
if (wifi_get_opmode() != 1) { if (wifi_get_opmode() != 1) {
wifi_get_ip_info(1, &ipconfig); wifi_get_ip_info(1, &ipconfig);
if (!ip_addr_netcmp((struct ip_addr *)precv->pespconn->proto.udp->remote_ip, &ipconfig.ip, &ipconfig.netmask)) { if (!ip_addr_netcmp(addr, &ipconfig.ip, &ipconfig.netmask)) {
wifi_get_ip_info(0, &ipconfig); wifi_get_ip_info(0, &ipconfig);
} }
} else { } else {
......
...@@ -193,8 +193,8 @@ static char host_name[MDNS_NAME_LENGTH]; ...@@ -193,8 +193,8 @@ static char host_name[MDNS_NAME_LENGTH];
static char service_name[MDNS_NAME_LENGTH]; static char service_name[MDNS_NAME_LENGTH];
static char server_name[MDNS_NAME_LENGTH]; static char server_name[MDNS_NAME_LENGTH];
//static char puck_datasheet[PUCK_DATASHEET_SIZE]; //static char puck_datasheet[PUCK_DATASHEET_SIZE];
static struct udp_pcb *mdns_pcb; static struct udp_pcb *mdns_pcb = NULL;
static struct mdns_info * ms_info = NULL;
static struct ip_addr multicast_addr; static struct ip_addr multicast_addr;
static struct ip_addr host_addr; static struct ip_addr host_addr;
static uint8 register_flag = 0; static uint8 register_flag = 0;
...@@ -887,7 +887,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, ...@@ -887,7 +887,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr,
} }
goto memerr2; goto memerr2;
memerr2: memerr2:
mem_free(mdns_payload); os_memset(mdns_payload , 0 ,DNS_MSG_SIZE);
memerr1: memerr1:
/* free pbuf */ /* free pbuf */
pbuf_free(p); pbuf_free(p);
...@@ -900,8 +900,12 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, ...@@ -900,8 +900,12 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr,
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
mdns_close(void) mdns_close(void)
{ {
if (mdns_pcb != NULL) if (mdns_pcb != NULL && ms_info != NULL)
udp_remove(mdns_pcb); udp_remove(mdns_pcb);
os_free(ms_info);
mdns_pcb = NULL;
ms_info = NULL;
} }
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
...@@ -1030,26 +1034,33 @@ mdns_init(struct mdns_info *info) { ...@@ -1030,26 +1034,33 @@ mdns_init(struct mdns_info *info) {
multicast_addr.addr = DNS_MULTICAST_ADDRESS; multicast_addr.addr = DNS_MULTICAST_ADDRESS;
struct ip_addr ap_host_addr; struct ip_addr ap_host_addr;
struct ip_info ipconfig; struct ip_info ipconfig;
if (info->ipAddr == 0) { ms_info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info));
if (ms_info != NULL) {
os_memcpy(ms_info,info,sizeof(struct mdns_info));
} else {
os_printf("ms_info alloc failed\n");
return;
}
if (ms_info->ipAddr == 0) {
os_printf("mdns ip error!\n "); os_printf("mdns ip error!\n ");
return; return;
} }
host_addr.addr = info->ipAddr ; host_addr.addr = ms_info->ipAddr ;
LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n")); LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n"));
//get the datasheet from PUCK //get the datasheet from PUCK
mdns_set_hostname(info->host_name); mdns_set_hostname(ms_info->host_name);
mdns_set_servername(info->server_name); mdns_set_servername(ms_info->server_name);
mdns_set_name(info->host_name); mdns_set_name(ms_info->host_name);
// get the host name as instrumentName_serialNumber for MDNS // get the host name as instrumentName_serialNumber for MDNS
// set the name of the service, the same as host name // set the name of the service, the same as host name
os_printf("host_name = %s\n", host_name); os_printf("host_name = %s\n", host_name);
os_printf("server_name = %s\n", PUCK_SERVICE); os_printf("server_name = %s\n", PUCK_SERVICE);
if (info->server_port == 0) if (ms_info->server_port == 0)
{ {
PUCK_PORT = 80; PUCK_PORT = 80;
} else { } else {
PUCK_PORT = info->server_port; PUCK_PORT = ms_info->server_port;
} }
/* initialize mDNS */ /* initialize mDNS */
...@@ -1080,14 +1091,14 @@ mdns_init(struct mdns_info *info) { ...@@ -1080,14 +1091,14 @@ mdns_init(struct mdns_info *info) {
/*loopback function for the multicast(224.0.0.251) messages received at port 5353*/ /*loopback function for the multicast(224.0.0.251) messages received at port 5353*/
// mdns_enable(); // mdns_enable();
udp_recv(mdns_pcb, mdns_recv, info); udp_recv(mdns_pcb, mdns_recv, ms_info);
mdns_flag = 1; mdns_flag = 1;
/* /*
* Register the name of the instrument * Register the name of the instrument
*/ */
os_timer_disarm(&mdns_timer); os_timer_disarm(&mdns_timer);
os_timer_setfn(&mdns_timer, (os_timer_func_t *)mdns_reg,info); os_timer_setfn(&mdns_timer, (os_timer_func_t *)mdns_reg,ms_info);
os_timer_arm(&mdns_timer, 1000, 1); os_timer_arm(&mdns_timer, 1000, 1);
} }
} }
......
...@@ -632,15 +632,19 @@ tcp_new_port(void) ...@@ -632,15 +632,19 @@ tcp_new_port(void)
int i; int i;
struct tcp_pcb *pcb; struct tcp_pcb *pcb;
#ifndef TCP_LOCAL_PORT_RANGE_START #ifndef TCP_LOCAL_PORT_RANGE_START
#define TCP_LOCAL_PORT_RANGE_START 4096 #define TCP_LOCAL_PORT_RANGE_START 1024
#define TCP_LOCAL_PORT_RANGE_END 0x7fff #define TCP_LOCAL_PORT_RANGE_END 0x7fff
#endif #endif
static u16_t port __attribute__((section(".port"))) = TCP_LOCAL_PORT_RANGE_START; static u16_t port = TCP_LOCAL_PORT_RANGE_START;
again: again:
if (++port >= TCP_LOCAL_PORT_RANGE_END) { // if (++port >= TCP_LOCAL_PORT_RANGE_END) {
port = TCP_LOCAL_PORT_RANGE_START; // port = TCP_LOCAL_PORT_RANGE_START;
} // }
port = os_random();
port %= TCP_LOCAL_PORT_RANGE_END;
if (port < TCP_LOCAL_PORT_RANGE_START)
port += TCP_LOCAL_PORT_RANGE_START;
/* Check all PCB lists. */ /* Check all PCB lists. */
for (i = 0; i < NUM_TCP_PCB_LISTS; i++) { for (i = 0; i < NUM_TCP_PCB_LISTS; i++) {
for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) { for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) {
......
...@@ -175,7 +175,7 @@ static int file_rename( lua_State* L ) ...@@ -175,7 +175,7 @@ static int file_rename( lua_State* L )
// Lua: fsinfo() // Lua: fsinfo()
static int file_fsinfo( lua_State* L ) static int file_fsinfo( lua_State* L )
{ {
uint32_t total, used; u32_t total, used;
SPIFFS_info(&fs, &total, &used); SPIFFS_info(&fs, &total, &used);
NODE_DBG("total: %d, used:%d\n", total, used); NODE_DBG("total: %d, used:%d\n", total, used);
if(total>0x7FFFFFFF || used>0x7FFFFFFF || used > total) if(total>0x7FFFFFFF || used>0x7FFFFFFF || used > total)
......
...@@ -13,12 +13,8 @@ ...@@ -13,12 +13,8 @@
#include "c_stdint.h" #include "c_stdint.h"
#include "c_string.h" #include "c_string.h"
typedef sint32_t s32_t; // For u32_t etc
typedef uint32_t u32_t; #include "user_interface.h"
typedef sint16_t s16_t;
typedef uint16_t u16_t;
typedef sint8_t s8_t;
typedef uint8_t u8_t;
// compile time switches // compile time switches
......
...@@ -82,21 +82,6 @@ void TEXT_SECTION_ATTR user_start_trampoline (void) ...@@ -82,21 +82,6 @@ void TEXT_SECTION_ATTR user_start_trampoline (void)
} }
/* To avoid accidentally losing the fix for the TCP port randomization
* during an LWIP upgrade, we've implemented most it outside the LWIP
* source itself. This enables us to test for the presence of the fix
* /at link time/ and error out if it's been lost.
* The fix itself consists of putting the function-static 'port' variable
* into its own section, and get the linker to provide an alias for it.
* From there we can then manually randomize it at boot.
*/
static inline void tcp_random_port_init (void)
{
extern uint16_t _tcp_new_port_port; // provided by the linker script
_tcp_new_port_port += xthal_get_ccount () % 4096;
}
void task_lua(os_event_t *e){ void task_lua(os_event_t *e){
char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL }; char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
NODE_DBG("Task task_lua started.\n"); NODE_DBG("Task task_lua started.\n");
...@@ -194,8 +179,6 @@ void nodemcu_init(void) ...@@ -194,8 +179,6 @@ void nodemcu_init(void)
// lua_main( 3, lua_argv ); // lua_main( 3, lua_argv );
// NODE_DBG("Flash sec num: 0x%x\n", flash_get_sec_num()); // NODE_DBG("Flash sec num: 0x%x\n", flash_get_sec_num());
tcp_random_port_init ();
task_init(); task_init();
system_os_post(LUA_TASK_PRIO,SIG_LUA,'s'); system_os_post(LUA_TASK_PRIO,SIG_LUA,'s');
} }
......
...@@ -123,16 +123,6 @@ SECTIONS ...@@ -123,16 +123,6 @@ SECTIONS
{ {
_data_start = ABSOLUTE(.); _data_start = ABSOLUTE(.);
*(.data) *(.data)
/* Hook for randomizing TCP start numbers */
. = ALIGN(2);
_tcp_new_port_port = ABSOLUTE(.);
*/liblwip.a:tcp.o(.port)
/* Verify that the LWIP source has been patched as needed, or fail with
* a divide by zero error (../ld/nodemcu.ld:xxx / by zero) */
_tcp_new_port_port_size = ABSOLUTE(.) - _tcp_new_port_port;
_ensure_tcp_port_randomization_fix_presence = 1 / _tcp_new_port_port_size;
*(.data.*) *(.data.*)
*(.gnu.linkonce.d.*) *(.gnu.linkonce.d.*)
*(.data1) *(.data1)
......
#ifndef _OVERRIDE_C_TYPES_H_ #ifndef _OVERRIDE_C_TYPES_H_
#define _OVERRIDE_C_TYPES_H_ #define _OVERRIDE_C_TYPES_H_
#include "../../sdk/esp_iot_sdk_v1.4.0/include/c_types.h" #include_next "c_types.h"
typedef sint64_t int64_t;
typedef long long int64_t;
typedef int8_t sint8_t;
typedef int16_t sint16_t;
typedef int32_t sint32_t;
typedef int64_t sint64_t;
#endif #endif
ESPRSSIF MIT License
Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case, it is free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
乐鑫 MIT 许可证
版权 (c) 2015 <乐鑫信息科技(上海)有限公司>
该许可证授权仅限于乐鑫信息科技 ESP8266 产品的应用开发。在此情况下,该许可证免费授权任何获得该软件及其相关文档(统称为“软件”)的人无限制地经营该软件,包括无限制的使用、复制、修改、合并、出版发行、散布、再授权、及贩售软件及软件副本的权利。被授权人在享受这些权利的同时,需服从下面的条件:
在软件和软件的所有副本中都必须包含以上的版权声明和授权声明。
该软件按本来的样子提供,没有任何明确或暗含的担保,包括但不仅限于关于试销性、适合某一特定用途和非侵权的保证。作者和版权持有人在任何情况下均不就由软件或软件使用引起的以合同形式、民事侵权或其它方式提出的任何索赔、损害或其它责任负责。
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment