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

Upgraded open-source LWIP.

From Espressif's lwip_open_src_template_proj_for_v1.3.0.zip
parent c1cd58e0
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
#include <string.h> #include <string.h>
#ifdef EBUF_LWIP #ifdef EBUF_LWIP
#include "pp/esf_buf.h" #define EP_OFFSET 36
#else #else
#define EP_OFFSET 0 #define EP_OFFSET 0
#endif /* ESF_LWIP */ #endif /* ESF_LWIP */
...@@ -329,6 +329,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) ...@@ -329,6 +329,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
p->len = p->tot_len = length; p->len = p->tot_len = length;
p->next = NULL; p->next = NULL;
p->type = type; p->type = type;
p->eb = NULL;
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",
((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
...@@ -363,6 +364,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) ...@@ -363,6 +364,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
/* set flags */ /* set flags */
p->flags = 0; p->flags = 0;
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
return p; return p;
} }
...@@ -1204,7 +1206,7 @@ pbuf_strstr(struct pbuf* p, const char* substr) ...@@ -1204,7 +1206,7 @@ pbuf_strstr(struct pbuf* p, const char* substr)
if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) {
return 0xFFFF; return 0xFFFF;
} }
substr_len = strlen(substr); substr_len = os_strlen(substr);
if (substr_len >= 0xFFFF) { if (substr_len >= 0xFFFF) {
return 0xFFFF; return 0xFFFF;
} }
......
...@@ -342,7 +342,7 @@ raw_new(u8_t proto) ...@@ -342,7 +342,7 @@ raw_new(u8_t proto)
/* could allocate RAW PCB? */ /* could allocate RAW PCB? */
if (pcb != NULL) { if (pcb != NULL) {
/* initialize PCB to all zeroes */ /* initialize PCB to all zeroes */
memset(pcb, 0, sizeof(struct raw_pcb)); os_memset(pcb, 0, sizeof(struct raw_pcb));
pcb->protocol = proto; pcb->protocol = proto;
pcb->ttl = RAW_TTL; pcb->ttl = RAW_TTL;
pcb->next = raw_pcbs; pcb->next = raw_pcbs;
......
This diff is collapsed.
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
#include <string.h> #include <string.h>
const char * const tcp_state_str[] = { #if TCP_DEBUG
const char tcp_state_str_rodata[][12] ICACHE_RODATA_ATTR = {
"CLOSED", "CLOSED",
"LISTEN", "LISTEN",
"SYN_SENT", "SYN_SENT",
...@@ -69,12 +70,15 @@ const char * const tcp_state_str[] = { ...@@ -69,12 +70,15 @@ const char * const tcp_state_str[] = {
"TIME_WAIT" "TIME_WAIT"
}; };
char tcp_state_str[12];
#endif
/* Incremented every coarse grained timer shot (typically every 500 ms). */ /* Incremented every coarse grained timer shot (typically every 500 ms). */
u32_t tcp_ticks; u32_t tcp_ticks;
const u8_t tcp_backoff[13] = const u8_t tcp_backoff[13] ICACHE_RODATA_ATTR =
{ 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7}; { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};
/* Times per slowtmr hits */ /* Times per slowtmr hits */
const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; const u8_t tcp_persist_backoff[7] ICACHE_RODATA_ATTR = { 3, 6, 12, 24, 48, 96, 120 };
/* The TCP PCB lists. */ /* The TCP PCB lists. */
...@@ -91,7 +95,7 @@ struct tcp_pcb *tcp_tw_pcbs; ...@@ -91,7 +95,7 @@ struct tcp_pcb *tcp_tw_pcbs;
#define NUM_TCP_PCB_LISTS 4 #define NUM_TCP_PCB_LISTS 4
#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 #define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3
/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */ /** An array with all (non-temporary) PCB lists, mainly used for smaller code size */
struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs, struct tcp_pcb ** const tcp_pcb_lists[] ICACHE_RODATA_ATTR = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs,
&tcp_active_pcbs, &tcp_tw_pcbs}; &tcp_active_pcbs, &tcp_tw_pcbs};
/** Only used for temporary storage. */ /** Only used for temporary storage. */
...@@ -798,7 +802,7 @@ tcp_slowtmr(void) ...@@ -798,7 +802,7 @@ tcp_slowtmr(void)
/* If snd_wnd is zero, use persist timer to send 1 byte probes /* If snd_wnd is zero, use persist timer to send 1 byte probes
* instead of using the standard retransmission mechanism. */ * instead of using the standard retransmission mechanism. */
pcb->persist_cnt++; pcb->persist_cnt++;
if (pcb->persist_cnt >= tcp_persist_backoff[pcb->persist_backoff-1]) { if (pcb->persist_cnt >= system_get_data_of_array_8(tcp_persist_backoff, pcb->persist_backoff-1)) {
pcb->persist_cnt = 0; pcb->persist_cnt = 0;
if (pcb->persist_backoff < sizeof(tcp_persist_backoff)) { if (pcb->persist_backoff < sizeof(tcp_persist_backoff)) {
pcb->persist_backoff++; pcb->persist_backoff++;
...@@ -819,7 +823,7 @@ tcp_slowtmr(void) ...@@ -819,7 +823,7 @@ tcp_slowtmr(void)
/* Double retransmission time-out unless we are trying to /* Double retransmission time-out unless we are trying to
* connect to somebody (i.e., we are in SYN_SENT). */ * connect to somebody (i.e., we are in SYN_SENT). */
if (pcb->state != SYN_SENT) { if (pcb->state != SYN_SENT) {
pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx]; pcb->rto = ((pcb->sa >> 3) + pcb->sv) << system_get_data_of_array_8(tcp_backoff, pcb->nrtx);
// if (pcb->rto >= TCP_MAXRTO) // if (pcb->rto >= TCP_MAXRTO)
// pcb->rto >>= 1; // pcb->rto >>= 1;
} }
...@@ -1221,7 +1225,7 @@ tcp_alloc(u8_t prio) ...@@ -1221,7 +1225,7 @@ tcp_alloc(u8_t prio)
} }
} }
if (pcb != NULL) { if (pcb != NULL) {
memset(pcb, 0, sizeof(struct tcp_pcb)); //��0 os_memset(pcb, 0, sizeof(struct tcp_pcb)); //��0
pcb->prio = prio; //�������ȼ� pcb->prio = prio; //�������ȼ�
pcb->snd_buf = TCP_SND_BUF; //��ʹ�õķ��ͻ������С pcb->snd_buf = TCP_SND_BUF; //��ʹ�õķ��ͻ������С
pcb->snd_queuelen = 0; //��������ռ�õ�pbuf���� pcb->snd_queuelen = 0; //��������ռ�õ�pbuf����
...@@ -1259,7 +1263,6 @@ tcp_alloc(u8_t prio) ...@@ -1259,7 +1263,6 @@ tcp_alloc(u8_t prio)
#endif /* LWIP_TCP_KEEPALIVE */ #endif /* LWIP_TCP_KEEPALIVE */
pcb->keep_cnt_sent = 0; //���ķ��ʹ��� pcb->keep_cnt_sent = 0; //���ķ��ʹ���
pcb->hold = 0;
} }
return pcb; return pcb;
} }
...@@ -1482,7 +1485,11 @@ tcp_next_iss(void) ...@@ -1482,7 +1485,11 @@ tcp_next_iss(void)
{ {
static u32_t iss = 6510; static u32_t iss = 6510;
again:
iss += tcp_ticks; /* XXX */ iss += tcp_ticks; /* XXX */
if (iss == 0)
goto again;
return iss; return iss;
} }
...@@ -1511,11 +1518,15 @@ tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr) ...@@ -1511,11 +1518,15 @@ tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr)
} }
#endif /* TCP_CALCULATE_EFF_SEND_MSS */ #endif /* TCP_CALCULATE_EFF_SEND_MSS */
#if TCP_DEBUG
const char* const char*
tcp_debug_state_str(enum tcp_state s) tcp_debug_state_str(enum tcp_state s)
{ {
return tcp_state_str[s]; system_get_string_from_flash(tcp_state_str_rodata[s], tcp_state_str, 12);
return tcp_state_str;
} }
#endif
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG #if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
/** /**
......
This diff is collapsed.
This diff is collapsed.
...@@ -389,9 +389,9 @@ sys_check_timeouts(void) ...@@ -389,9 +389,9 @@ sys_check_timeouts(void)
if (next_timeout) { if (next_timeout) {
/* this cares for wraparounds */ /* this cares for wraparounds */
if (timer2_ms_flag == 0) { if (timer2_ms_flag == 0) {
diff = LWIP_U32_DIFF(now, timeouts_last_time)/((CPU_CLK_FREQ>>4)/1000); diff = LWIP_U32_DIFF(now, timeouts_last_time)/((APB_CLK_FREQ>>4)/1000);
} else { } else {
diff = LWIP_U32_DIFF(now, timeouts_last_time)/((CPU_CLK_FREQ>>8)/1000); diff = LWIP_U32_DIFF(now, timeouts_last_time)/((APB_CLK_FREQ>>8)/1000);
} }
do do
{ {
......
...@@ -148,6 +148,15 @@ udp_input(struct pbuf *p, struct netif *inp) ...@@ -148,6 +148,15 @@ udp_input(struct pbuf *p, struct netif *inp)
pcb = inp->dhcp->pcb; pcb = inp->dhcp->pcb;
} }
} }
} else if (dest == DHCP_SERVER_PORT) {
if (src == DHCP_CLIENT_PORT) {
if ( inp->dhcps_pcb != NULL ) {
if ((ip_addr_isany(&inp->dhcps_pcb->local_ip) ||
ip_addr_cmp(&(inp->dhcps_pcb->local_ip), &current_iphdr_dest))) {
pcb = inp->dhcps_pcb;
}
}
}
} }
} else } else
#endif /* LWIP_DHCP */ #endif /* LWIP_DHCP */
...@@ -935,7 +944,7 @@ udp_new(void) ...@@ -935,7 +944,7 @@ udp_new(void)
* which means checksum is generated over the whole datagram per default * which means checksum is generated over the whole datagram per default
* (recommended as default by RFC 3828). */ * (recommended as default by RFC 3828). */
/* initialize PCB to all zeroes */ /* initialize PCB to all zeroes */
memset(pcb, 0, sizeof(struct udp_pcb)); os_memset(pcb, 0, sizeof(struct udp_pcb));
pcb->ttl = UDP_TTL; pcb->ttl = UDP_TTL;
} }
return pcb; return pcb;
......
This diff is collapsed.
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