Skip to content

Lwip addons #2260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
305d060
Merge remote-tracking branch 'esp8266/master'
Apr 20, 2016
e9a5c48
Merge remote-tracking branch 'esp8266/master'
Apr 27, 2016
246edd3
Merge remote-tracking branch 'esp8266/master'
May 8, 2016
c130c17
Merge remote-tracking branch 'esp8266/master'
May 12, 2016
617206d
Merge remote-tracking branch 'esp8266/master'
May 20, 2016
039f4db
Merge remote-tracking branch 'esp8266/master'
Jun 4, 2016
e6578b4
Merge remote-tracking branch 'esp8266/master'
Jun 6, 2016
db26ef4
Merge remote-tracking branch 'esp8266/master'
Jun 12, 2016
3dba795
Merge remote-tracking branch 'esp8266/master'
Jun 16, 2016
f799ede
Merge remote-tracking branch 'esp8266/master'
Jun 23, 2016
e2ff86b
Merge remote-tracking branch 'esp8266/master'
Jun 25, 2016
7158fea
Merge remote-tracking branch 'esp8266/master'
Jun 27, 2016
0264347
Merge remote-tracking branch 'esp8266/master'
Jun 28, 2016
3cf75ca
Merge remote-tracking branch 'esp8266/master'
Jun 30, 2016
6b9edd4
Merge remote-tracking branch 'esp8266/master'
Jul 4, 2016
2aa3d3e
Merge remote-tracking branch 'esp8266/master'
Jul 4, 2016
cc132ec
Merge remote-tracking branch 'esp8266/master'
Jul 5, 2016
bdbf8ed
Merge remote-tracking branch 'esp8266/master'
Jul 5, 2016
5f7daf4
Merge remote-tracking branch 'esp8266/master'
Jul 6, 2016
4e27e14
Merge remote-tracking branch 'esp8266/master'
Jul 6, 2016
d8be9b1
Merge remote-tracking branch 'esp8266/master'
Jul 10, 2016
9d86d82
Add multicast TTL to UDP and rework UdpContext
Jul 11, 2016
1b5005e
Add limit for TCP TIME_WAIT pcbs
Jul 11, 2016
f9b23a5
Add liblwip_gcc.a
Jul 11, 2016
424b5f6
Make the changes be backward compatible with the current xcc version
Jul 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ coredev.build.lwip_flags=

coredev.menu.LwIPVariant.Espressif=Espressif (xcc)
coredev.menu.LwIPVariant.Espressif.build.lwip_lib=-llwip
coredev.menu.LwIPVariant.Espressif.build.lwip_flags=
coredev.menu.LwIPVariant.Espressif.build.lwip_flags=-DLWIP_MAYBE_XCC
coredev.menu.LwIPVariant.Prebuilt=Prebuilt Source (gcc)
coredev.menu.LwIPVariant.Prebuilt.build.lwip_lib=-llwip_gcc
coredev.menu.LwIPVariant.Prebuilt.build.lwip_flags=-DLWIP_OPEN_SRC
Expand Down
41 changes: 21 additions & 20 deletions libraries/ESP8266WiFi/src/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class UdpContext
, _tx_buf_head(0)
, _tx_buf_cur(0)
, _tx_buf_offset(0)
, _multicast_ttl(1)
, _dest_port(0)
{
_pcb = udp_new();
_dest_addr.addr = 0;
#ifdef LWIP_MAYBE_XCC
_mcast_ttl = 1;
#endif
}

~UdpContext()
Expand Down Expand Up @@ -87,8 +87,8 @@ class UdpContext

bool connect(ip_addr_t addr, uint16_t port)
{
_dest_addr = addr;
_dest_port = port;
ip_addr_copy(_pcb->remote_ip, addr);
_pcb->remote_port = port;
return true;
}

Expand All @@ -106,17 +106,16 @@ class UdpContext

void setMulticastInterface(ip_addr_t addr)
{
// newer versions of lwip have a macro to set the multicast ip
// udp_set_multicast_netif_addr(_pcb, addr);
_pcb->multicast_ip = addr;
udp_set_multicast_netif_addr(_pcb, addr);
}

void setMulticastTTL(int ttl)
{
// newer versions of lwip have an additional field (mcast_ttl) for this purpose
// and a macro to set it instead of direct field access
// udp_set_multicast_ttl(_pcb, ttl);
_multicast_ttl = ttl;
#ifdef LWIP_MAYBE_XCC
_mcast_ttl = ttl;
#else
udp_set_multicast_ttl(_pcb, ttl);
#endif
}

// warning: handler is called from tcp stack context
Expand Down Expand Up @@ -275,20 +274,22 @@ class UdpContext


if (!addr) {
addr = &_dest_addr;
port = _dest_port;
addr = &_pcb->remote_ip;
port = _pcb->remote_port;
}

#ifdef LWIP_MAYBE_XCC
uint16_t old_ttl = _pcb->ttl;
if (ip_addr_ismulticast(addr)) {
_pcb->ttl = _multicast_ttl;
_pcb->ttl = _mcast_ttl;
}

#endif
err_t err = udp_sendto(_pcb, tx_copy, addr, port);
if (err != ERR_OK) {
DEBUGV(":ust rc=%d\r\n", err);
}
#ifdef LWIP_MAYBE_XCC
_pcb->ttl = old_ttl;
#endif
pbuf_free(tx_copy);
return err == ERR_OK;
}
Expand Down Expand Up @@ -365,10 +366,10 @@ class UdpContext
pbuf* _tx_buf_head;
pbuf* _tx_buf_cur;
size_t _tx_buf_offset;
uint16_t _multicast_ttl;
uint16_t _dest_port;
ip_addr_t _dest_addr;
rxhandler_t _on_rx;
#ifdef LWIP_MAYBE_XCC
uint16_t _mcast_ttl;
#endif
};


Expand Down
Binary file modified tools/sdk/lib/liblwip_gcc.a
Binary file not shown.
54 changes: 37 additions & 17 deletions tools/sdk/lwip/include/lwip/tcp_impl.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
Expand All @@ -11,21 +11,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <[email protected]>
*
*/
Expand Down Expand Up @@ -284,7 +284,7 @@ struct tcp_seg {
u16_t oversize_left; /* Extra bytes available at the end of the last
pbuf in unsent (used for asserting vs.
tcp_pcb.unsent_oversized only) */
#endif /* TCP_OVERSIZE_DBGCHECK */
#endif /* TCP_OVERSIZE_DBGCHECK */
#if TCP_CHECKSUM_ON_COPY
u16_t chksum;
u8_t chksum_swapped;
Expand Down Expand Up @@ -313,7 +313,7 @@ extern u32_t tcp_ticks;

/* The TCP PCB lists. */
union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
struct tcp_pcb_listen *listen_pcbs;
struct tcp_pcb_listen *listen_pcbs;
struct tcp_pcb *pcbs;
};
extern struct tcp_pcb *tcp_bound_pcbs;
Expand All @@ -325,7 +325,7 @@ extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. *

extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */

/* Axioms about the above lists:
/* Axioms about the above lists:
1) Every TCP PCB that is not CLOSED is in one of the lists.
2) A PCB is only in one of the lists.
3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
Expand Down Expand Up @@ -396,6 +396,26 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */

#endif /* LWIP_DEBUG */

#define TCP_TW_LIMIT(l) \
do { \
u32_t tcp_tmp_pcbs_count = 0; \
tcp_tmp_pcb = tcp_tw_pcbs; \
while(tcp_tmp_pcb != NULL) { \
if(++tcp_tmp_pcbs_count == (l)) { \
struct tcp_pcb *_tcp_tmp_pcb = tcp_tmp_pcb->next; \
tcp_tmp_pcb->next = NULL; \
tcp_tmp_pcb = _tcp_tmp_pcb; \
while(tcp_tmp_pcb != NULL) { \
_tcp_tmp_pcb = tcp_tmp_pcb; \
tcp_pcb_purge(tcp_tmp_pcb); \
tcp_tmp_pcb = tcp_tmp_pcb->next; \
memp_free(MEMP_TCP_PCB, _tcp_tmp_pcb); \
} \
break; \
} \
tcp_tmp_pcb = tcp_tmp_pcb->next; \
} \
} while(0)

/* Internal functions: */
struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb)ICACHE_FLASH_ATTR;
Expand Down
43 changes: 28 additions & 15 deletions tools/sdk/lwip/include/lwip/udp.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
Expand All @@ -11,21 +11,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <[email protected]>
*
*/
Expand Down Expand Up @@ -103,6 +103,10 @@ struct udp_pcb {
#if LWIP_IGMP
/** outgoing network interface for multicast packets */
ip_addr_t multicast_ip;
#ifndef LWIP_MAYBE_XCC
/** TTL for outgoing multicast packets */
u8_t mcast_ttl;
#endif /* LWIP_MAYBE_XCC */
#endif /* LWIP_IGMP */

#if LWIP_UDPLITE
Expand All @@ -113,7 +117,7 @@ struct udp_pcb {
/** receive callback function */
udp_recv_fn recv;
/** user-supplied argument for the recv callback */
void *recv_arg;
void *recv_arg;
};
/* udp_pcbs export for exernal reference (e.g. SNMP agent) */
extern struct udp_pcb *udp_pcbs;
Expand Down Expand Up @@ -156,6 +160,15 @@ void udp_input (struct pbuf *p, struct netif *inp)ICACHE_FLASH_

#define udp_init() /* Compatibility define, not init needed. */

#if LWIP_IGMP
#define udp_set_multicast_netif_addr(pcb, ipaddr) ip_addr_copy((pcb)->multicast_ip, (ipaddr))
#define udp_get_multicast_netif_addr(pcb) ((pcb)->multicast_ip)
#ifndef LWIP_MAYBE_XCC
#define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0)
#define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl)
#endif /* LWIP_MAYBE_XCC */
#endif /* LWIP_IGMP */

#if UDP_DEBUG
void udp_debug_print(struct udp_hdr *udphdr)ICACHE_FLASH_ATTR;
#else
Expand Down
Loading