Skip to content
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

Update LwIP to 2.2.0 stable #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ target_sources(LwIP INTERFACE
src/core/inet_chksum.c
src/core/init.c
src/core/ip.c
src/core/ipv4/acd.c
src/core/ipv4/autoip.c
src/core/ipv4/dhcp.c
src/core/ipv4/etharp.c
Expand Down Expand Up @@ -83,4 +84,4 @@ target_include_directories(
src/include/lwip/prot
src/include/netif
src/include/posix
)
)
34 changes: 24 additions & 10 deletions src/Filelists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
#
# This file is NOT designed (on purpose) to be used as cmake
# subdir via add_subdirectory()
# The intention is to provide greater flexibility to users to
# The intention is to provide greater flexibility to users to
# create their own targets using the *_SRCS variables.

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
include_guard(GLOBAL)
endif()

set(LWIP_VERSION_MAJOR "2")
set(LWIP_VERSION_MINOR "1")
set(LWIP_VERSION_REVISION "2")
set(LWIP_VERSION_MINOR "2")
set(LWIP_VERSION_REVISION "0")
# LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases
# LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions
# Numbers 1..31 are reserved for release candidates
Expand All @@ -24,11 +28,11 @@ elseif ("${LWIP_VERSION_RC}" STREQUAL "LWIP_RC_DEVELOPMENT")
set(LWIP_VERSION_STRING
"${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}.dev"
)
else ("${LWIP_VERSION_RC}" STREQUAL "LWIP_RC_RELEASE")
else()
set(LWIP_VERSION_STRING
"${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}.rc${LWIP_VERSION_RC}"
)
endif ("${LWIP_VERSION_RC}" STREQUAL "LWIP_RC_RELEASE")
endif()

# The minimum set of files needed for lwIP.
set(lwipcore_SRCS
Expand All @@ -54,6 +58,7 @@ set(lwipcore_SRCS
${LWIP_DIR}/src/core/udp.c
)
set(lwipcore4_SRCS
${LWIP_DIR}/src/core/ipv4/acd.c
${LWIP_DIR}/src/core/ipv4/autoip.c
${LWIP_DIR}/src/core/ipv4/dhcp.c
${LWIP_DIR}/src/core/ipv4/etharp.c
Expand Down Expand Up @@ -93,9 +98,12 @@ set(lwipnetif_SRCS
${LWIP_DIR}/src/netif/ethernet.c
${LWIP_DIR}/src/netif/bridgeif.c
${LWIP_DIR}/src/netif/bridgeif_fdb.c
${LWIP_DIR}/src/netif/slipif.c
)

if (NOT ${LWIP_EXCLUDE_SLIPIF})
list(APPEND lwipnetif_SRCS ${LWIP_DIR}/src/netif/slipif.c)
endif()

# 6LoWPAN
set(lwipsixlowpan_SRCS
${LWIP_DIR}/src/netif/lowpan6_common.c
Expand Down Expand Up @@ -194,6 +202,8 @@ set(lwipsntp_SRCS
# MDNS responder
set(lwipmdns_SRCS
${LWIP_DIR}/src/apps/mdns/mdns.c
${LWIP_DIR}/src/apps/mdns/mdns_out.c
${LWIP_DIR}/src/apps/mdns/mdns_domain.c
)

# NetBIOS name server
Expand All @@ -203,7 +213,7 @@ set(lwipnetbios_SRCS

# TFTP server files
set(lwiptftp_SRCS
${LWIP_DIR}/src/apps/tftp/tftp_server.c
${LWIP_DIR}/src/apps/tftp/tftp.c
)

# MQTT client files
Expand Down Expand Up @@ -240,7 +250,6 @@ set(lwipallapps_SRCS
${lwipnetbios_SRCS}
${lwiptftp_SRCS}
${lwipmqtt_SRCS}
${lwipmbedtls_SRCS}
)

# Generate lwip/init.h (version info)
Expand All @@ -255,7 +264,7 @@ configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT})

find_package(Doxygen)
if (DOXYGEN_FOUND)
message("Doxygen build started")
message(STATUS "Doxygen build started")

add_custom_target(lwipdocs
COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOXYGEN_DIR}/${DOXYGEN_OUTPUT_DIR}/html
Expand All @@ -264,7 +273,7 @@ if (DOXYGEN_FOUND)
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
else (DOXYGEN_FOUND)
message("Doxygen needs to be installed to generate the doxygen documentation")
message(STATUS "Doxygen needs to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)

# lwIP libraries
Expand All @@ -277,3 +286,8 @@ add_library(lwipallapps EXCLUDE_FROM_ALL ${lwipallapps_SRCS})
target_compile_options(lwipallapps PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipallapps PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipallapps PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})

add_library(lwipmbedtls EXCLUDE_FROM_ALL ${lwipmbedtls_SRCS})
target_compile_options(lwipmbedtls PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipmbedtls PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipmbedtls PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
39 changes: 21 additions & 18 deletions src/Filelists.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Copyright (c) 2001, 2002 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 All @@ -51,7 +51,8 @@ COREFILES=$(LWIPDIR)/core/init.c \
$(LWIPDIR)/core/timeouts.c \
$(LWIPDIR)/core/udp.c

CORE4FILES=$(LWIPDIR)/core/ipv4/autoip.c \
CORE4FILES=$(LWIPDIR)/core/ipv4/acd.c \
$(LWIPDIR)/core/ipv4/autoip.c \
$(LWIPDIR)/core/ipv4/dhcp.c \
$(LWIPDIR)/core/ipv4/etharp.c \
$(LWIPDIR)/core/ipv4/icmp.c \
Expand Down Expand Up @@ -176,13 +177,15 @@ SMTPFILES=$(LWIPDIR)/apps/smtp/smtp.c
SNTPFILES=$(LWIPDIR)/apps/sntp/sntp.c

# MDNSFILES: MDNS responder
MDNSFILES=$(LWIPDIR)/apps/mdns/mdns.c
MDNSFILES=$(LWIPDIR)/apps/mdns/mdns.c \
$(LWIPDIR)/apps/mdns/mdns_out.c \
$(LWIPDIR)/apps/mdns/mdns_domain.c

# NETBIOSNSFILES: NetBIOS name server
NETBIOSNSFILES=$(LWIPDIR)/apps/netbiosns/netbiosns.c

# TFTPFILES: TFTP server files
TFTPFILES=$(LWIPDIR)/apps/tftp/tftp_server.c
# TFTPFILES: TFTP client/server files
TFTPFILES=$(LWIPDIR)/apps/tftp/tftp.c

# MQTTFILES: MQTT client files
MQTTFILES=$(LWIPDIR)/apps/mqtt/mqtt.c
Expand Down
16 changes: 8 additions & 8 deletions src/api/api_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@ netconn_prepare_delete(struct netconn *conn)

API_MSG_VAR_ALLOC(msg);
API_MSG_VAR_REF(msg).conn = conn;
#if LWIP_TCP
#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
/* get the time we started, which is later compared to
sys_now() + conn->send_timeout */
API_MSG_VAR_REF(msg).msg.sd.time_started = sys_now();
#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
#if LWIP_TCP
API_MSG_VAR_REF(msg).msg.sd.polls_left =
((LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT + TCP_SLOW_INTERVAL - 1) / TCP_SLOW_INTERVAL) + 1;
#endif /* LWIP_TCP */
#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
#endif /* LWIP_TCP */
err = netconn_apimsg(lwip_netconn_do_delconn, &API_MSG_VAR_REF(msg));
API_MSG_VAR_FREE(msg);

Expand Down Expand Up @@ -323,7 +323,7 @@ netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port)
* and NETCONN_FLAG_IPV6_V6ONLY is 0, use IP_ANY_TYPE to bind
*/
if ((netconn_get_ipv6only(conn) == 0) &&
ip_addr_cmp(addr, IP6_ADDR_ANY)) {
ip_addr_eq(addr, IP6_ADDR_ANY)) {
addr = IP_ANY_TYPE;
}
#endif /* LWIP_IPV4 && LWIP_IPV6 */
Expand Down Expand Up @@ -500,7 +500,7 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)

NETCONN_MBOX_WAITING_INC(conn);
if (netconn_is_nonblocking(conn)) {
if (sys_arch_mbox_tryfetch(&conn->acceptmbox, &accept_ptr) == SYS_ARCH_TIMEOUT) {
if (sys_arch_mbox_tryfetch(&conn->acceptmbox, &accept_ptr) == SYS_MBOX_EMPTY) {
API_MSG_VAR_FREE_ACCEPT(msg);
NETCONN_MBOX_WAITING_DEC(conn);
return ERR_WOULDBLOCK;
Expand Down Expand Up @@ -597,7 +597,7 @@ netconn_recv_data(struct netconn *conn, void **new_buf, u8_t apiflags)
NETCONN_MBOX_WAITING_INC(conn);
if (netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK) ||
(conn->flags & NETCONN_FLAG_MBOXCLOSED) || (conn->pending_err != ERR_OK)) {
if (sys_arch_mbox_tryfetch(&conn->recvmbox, &buf) == SYS_ARCH_TIMEOUT) {
if (sys_arch_mbox_tryfetch(&conn->recvmbox, &buf) == SYS_MBOX_EMPTY) {
err_t err;
NETCONN_MBOX_WAITING_DEC(conn);
err = netconn_err(conn);
Expand Down Expand Up @@ -1260,13 +1260,13 @@ netconn_join_leave_group_netif(struct netconn *conn,
*
* @param name a string representation of the DNS host name to query
* @param addr a preallocated ip_addr_t where to store the resolved IP address
* @param dns_addrtype IP address type (IPv4 / IPv6)
* @return ERR_OK: resolving succeeded
* ERR_MEM: memory error, try again later
* ERR_ARG: dns client not initialized or invalid hostname
* ERR_VAL: dns server response was invalid
*/
#if LWIP_IPV4 && LWIP_IPV6
/** @param dns_addrtype IP address type (IPv4 / IPv6) */
err_t
netconn_gethostbyname_addrtype(const char *name, ip_addr_t *addr, u8_t dns_addrtype)
#else
Expand Down Expand Up @@ -1346,7 +1346,7 @@ void
netconn_thread_init(void)
{
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
if ((sem == NULL) || !sys_sem_valid(sem)) {
if (!sys_sem_valid(sem)) {
/* call alloc only once */
LWIP_NETCONN_THREAD_SEM_ALLOC();
LWIP_ASSERT("LWIP_NETCONN_THREAD_SEM_ALLOC() failed", sys_sem_valid(LWIP_NETCONN_THREAD_SEM_GET()));
Expand All @@ -1357,7 +1357,7 @@ void
netconn_thread_cleanup(void)
{
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
if ((sem != NULL) && sys_sem_valid(sem)) {
if (sys_sem_valid(sem)) {
/* call free only once */
LWIP_NETCONN_THREAD_SEM_FREE();
}
Expand Down
28 changes: 16 additions & 12 deletions src/api/api_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void netconn_drain(struct netconn *conn);
#endif /* LWIP_TCPIP_CORE_LOCKING */

#if LWIP_NETCONN_FULLDUPLEX
const u8_t netconn_deleted = 0;
static const u8_t netconn_deleted = 0;

int
lwip_netconn_is_deallocated_msg(void *msg)
Expand All @@ -106,9 +106,9 @@ lwip_netconn_is_deallocated_msg(void *msg)
#endif /* LWIP_NETCONN_FULLDUPLEX */

#if LWIP_TCP
const u8_t netconn_aborted = 0;
const u8_t netconn_reset = 0;
const u8_t netconn_closed = 0;
static const u8_t netconn_aborted = 0;
static const u8_t netconn_reset = 0;
static const u8_t netconn_closed = 0;

/** Translate an error to a unique void* passed via an mbox */
static void *
Expand Down Expand Up @@ -221,6 +221,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
struct netbuf *buf;
struct netconn *conn;
u16_t len;
err_t err;
#if LWIP_SO_RCVBUF
int recv_avail;
#endif /* LWIP_SO_RCVBUF */
Expand Down Expand Up @@ -269,8 +270,10 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
}

len = p->tot_len;
if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) {
err = sys_mbox_trypost(&conn->recvmbox, buf);
if (err != ERR_OK) {
netbuf_delete(buf);
LWIP_DEBUGF(API_MSG_DEBUG, ("recv_udp: sys_mbox_trypost failed, err=%d\n", err));
return;
} else {
#if LWIP_SO_RCVBUF
Expand Down Expand Up @@ -469,7 +472,7 @@ err_tcp(void *arg, err_t err)
}
/* pass error message to acceptmbox to wake up pending accept */
if (NETCONN_MBOX_VALID(conn, &conn->acceptmbox)) {
/* use trypost to preven deadlock */
/* use trypost to prevent deadlock */
sys_mbox_trypost(&conn->acceptmbox, mbox_msg);
}

Expand All @@ -492,7 +495,7 @@ err_tcp(void *arg, err_t err)
conn->current_msg->err = err;
}
op_completed_sem = LWIP_API_MSG_SEM(conn->current_msg);
LWIP_ASSERT("inavlid op_completed_sem", sys_sem_valid(op_completed_sem));
LWIP_ASSERT("invalid op_completed_sem", sys_sem_valid(op_completed_sem));
conn->current_msg = NULL;
/* wake up the waiting task */
sys_sem_signal(op_completed_sem);
Expand Down Expand Up @@ -716,6 +719,9 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
conn->pending_err = ERR_OK;
conn->type = t;
conn->pcb.tcp = NULL;
#if LWIP_NETCONN_FULLDUPLEX
conn->mbox_threads_waiting = 0;
#endif

/* If all sizes are the same, every compiler should optimize this switch to nothing */
switch (NETCONNTYPE_GROUP(t)) {
Expand Down Expand Up @@ -756,10 +762,8 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
sys_mbox_set_invalid(&conn->acceptmbox);
#endif
conn->state = NETCONN_NONE;
#if LWIP_SOCKET
/* initialize socket to -1 since 0 is a valid socket */
conn->socket = -1;
#endif /* LWIP_SOCKET */
conn->callback_arg.socket = -1;
conn->callback = callback;
#if LWIP_TCP
conn->current_msg = NULL;
Expand Down Expand Up @@ -975,7 +979,7 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
/* Try to close the connection */
if (shut_close) {
#if LWIP_SO_LINGER
/* check linger possibilites before calling tcp_close */
/* check linger possibilities before calling tcp_close */
err = ERR_OK;
/* linger enabled/required at all? (i.e. is there untransmitted data left?) */
if ((conn->linger >= 0) && (conn->pcb.tcp->unsent || conn->pcb.tcp->unacked)) {
Expand Down Expand Up @@ -1469,7 +1473,7 @@ lwip_netconn_do_listen(void *m)
/* "Socket API like" dual-stack support: If IP to listen to is IP6_ADDR_ANY,
* and NETCONN_FLAG_IPV6_V6ONLY is NOT set, use IP_ANY_TYPE to listen
*/
if (ip_addr_cmp(&msg->conn->pcb.ip->local_ip, IP6_ADDR_ANY) &&
if (ip_addr_eq(&msg->conn->pcb.ip->local_ip, IP6_ADDR_ANY) &&
(netconn_get_ipv6only(msg->conn) == 0)) {
/* change PCB type to IPADDR_TYPE_ANY */
IP_SET_TYPE_VAL(msg->conn->pcb.tcp->local_ip, IPADDR_TYPE_ANY);
Expand Down
2 changes: 1 addition & 1 deletion src/api/if_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ lwip_if_indextoname(unsigned int ifindex, char *ifname)

/**
* @ingroup if_api
* Returs the interface index corresponding to name ifname.
* Returns the interface index corresponding to name ifname.
* @param ifname Interface name
* @return The corresponding index if ifname is the name of an interface;
* otherwise, zero.
Expand Down
4 changes: 2 additions & 2 deletions src/api/netbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* @defgroup netbuf Network buffers
* @ingroup netconn
* Network buffer descriptor for @ref netconn. Based on @ref pbuf internally
* to avoid copying data around.\n
* Buffers must not be shared accross multiple threads, all functions except
* to avoid copying data around.<br>
* Buffers must not be shared across multiple threads, all functions except
* netbuf_new() and netbuf_delete() are not thread-safe.
*/

Expand Down
Loading