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

lwIP: Initial import #3551

Merged
merged 7 commits into from Mar 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions Makefile.dep
Expand Up @@ -111,6 +111,9 @@ ifneq (,$(filter ieee802154,$(USEMODULE)))
ifneq (,$(filter gnrc_ipv6_router_default, $(USEMODULE)))
USEMODULE += gnrc_sixlowpan_router_default
endif
ifneq (,$(filter lwip%, $(USEMODULE)))
USEMODULE += lwip_sixlowpan
endif
endif

ifneq (,$(filter gnrc_sixlowpan_default,$(USEMODULE)))
Expand Down Expand Up @@ -354,6 +357,60 @@ ifneq (,$(filter posix_semaphore,$(USEMODULE)))
USEMODULE += xtimer
endif

ifneq (,$(filter lwip_sixlowpan,$(USEMODULE)))
USEMODULE += lwip_ipv6_autoconfig
endif

ifneq (,$(filter lwip_ipv6_autoconfig,$(USEMODULE)))
USEMODULE += lwip_ipv6
endif

ifneq (,$(filter lwip_ipv6,$(USEMODULE)))
USEMODULE += random
endif

ifneq (,$(filter lwip_udplite,$(USEMODULE)))
USEMODULE += lwip_udp
endif

ifneq (,$(filter lwip_conn_%,$(USEMODULE)))
USEMODULE += lwip_conn
endif

ifneq (,$(filter lwip_conn_ip,$(USEMODULE)))
USEMODULE += lwip_raw
endif

ifneq (,$(filter lwip_conn_udp,$(USEMODULE)))
USEMODULE += lwip_udp
endif

ifneq (,$(filter lwip_%,$(USEMODULE)))
USEMODULE += lwip
endif

ifneq (,$(filter lwip,$(USEMODULE)))
USEPKG += lwip
USEMODULE += lwip_api
USEMODULE += lwip_contrib
USEMODULE += lwip_core
USEMODULE += lwip_netif
ifeq (,$(filter lwip_ipv4 lwip_ipv6,$(USEMODULE)))
USEMODULE += lwip_ipv4
endif
ifeq (,$(filter lwip_tcp lwip_udp lwip_udplite,$(USEMODULE)))
USEMODULE += lwip_raw
endif
endif

ifneq (,$(filter lwip_ppp,$(USEMODULE)))
USEMODULE += lwip_polarssl
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible/make sense to move this into pkg/lwip/Makefile.dep (just to keep Makefile.dep a bit smaller)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to find a general better concept for dependencies in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack


ifneq (,$(filter lwip_contrib,$(USEMODULE)))
USEMODULE += sema
endif

ifneq (,$(filter sema,$(USEMODULE)))
USEMODULE += xtimer
endif
Expand Down
12 changes: 12 additions & 0 deletions Makefile.pseudomodules
Expand Up @@ -16,6 +16,18 @@ PSEUDOMODULES += gnrc_sixlowpan_iphc_nhc
PSEUDOMODULES += gnrc_pktbuf
PSEUDOMODULES += log
PSEUDOMODULES += log_printfnoformat
PSEUDOMODULES += lwip_arp
PSEUDOMODULES += lwip_autoip
PSEUDOMODULES += lwip_dhcp
PSEUDOMODULES += lwip_ethernet
PSEUDOMODULES += lwip_igmp
PSEUDOMODULES += lwip_ipv6_autoconfig
PSEUDOMODULES += lwip_raw
PSEUDOMODULES += lwip_sixlowpan
PSEUDOMODULES += lwip_stats
PSEUDOMODULES += lwip_tcp
PSEUDOMODULES += lwip_udp
PSEUDOMODULES += lwip_udplite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for pseudo-submodules.

PSEUDOMODULES += netdev_default
PSEUDOMODULES += newlib
PSEUDOMODULES += newlib_nano
Expand Down
11 changes: 11 additions & 0 deletions pkg/lwip/Makefile
@@ -0,0 +1,11 @@
PKG_NAME=lwip
PKG_URL=git://git.savannah.nongnu.org/lwip.git
PKG_VERSION=fd4a109ffa6513b28a0c780a952cef1110423717
PKG_BUILDDIR ?= $(BINDIRBASE)/pkg/$(BOARD)/$(PKG_NAME)

.PHONY: all

all: git-download
$(MAKE) -C $(PKG_BUILDDIR)

include $(RIOTBASE)/pkg/pkg.mk
18 changes: 18 additions & 0 deletions pkg/lwip/Makefile.include
@@ -0,0 +1,18 @@
INCLUDES += -I$(RIOTBASE)/pkg/lwip/include \
-I$(BINDIRBASE)/pkg/$(BOARD)/lwip/src/include

ifneq (,$(filter lwip_conn,$(USEMODULE)))
DIRS += $(RIOTBASE)/pkg/lwip/contrib/conn
endif
ifneq (,$(filter lwip_conn_ip,$(USEMODULE)))
DIRS += $(RIOTBASE)/pkg/lwip/contrib/conn/ip
endif
ifneq (,$(filter lwip_conn_udp,$(USEMODULE)))
DIRS += $(RIOTBASE)/pkg/lwip/contrib/conn/udp
endif
ifneq (,$(filter lwip_contrib,$(USEMODULE)))
DIRS += $(RIOTBASE)/pkg/lwip/contrib
endif
ifneq (,$(filter lwip_netdev2,$(USEMODULE)))
DIRS += $(RIOTBASE)/pkg/lwip/contrib/netdev2
endif
3 changes: 3 additions & 0 deletions pkg/lwip/contrib/Makefile
@@ -0,0 +1,3 @@
MODULE := lwip_contrib

include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions pkg/lwip/contrib/conn/Makefile
@@ -0,0 +1,3 @@
MODULE := lwip_conn

include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions pkg/lwip/contrib/conn/ip/Makefile
@@ -0,0 +1,3 @@
MODULE := lwip_conn_ip

include $(RIOTBASE)/Makefile.base
73 changes: 73 additions & 0 deletions pkg/lwip/contrib/conn/ip/lwip_conn_ip.c
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @{
*
* @file
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/

#include <assert.h>
#include <errno.h>

#include "net/ipv4/addr.h"
#include "net/ipv6/addr.h"
#include "net/conn/ip.h"

#include "lwip/api.h"
#include "lwip/conn.h"

int conn_ip_create(conn_ip_t *conn, const void *addr, size_t addr_len, int family, int proto)
{
struct netconn *tmp;
int res;

res = lwip_conn_create(&tmp, addr, addr_len, family, NETCONN_RAW, proto, 0);
if (res < 0) {
return res;
}
conn->lwip_conn = tmp;

return res;
}

void conn_ip_close(conn_ip_t *conn)
{
assert(conn != NULL);
netconn_delete(conn->lwip_conn);
}

int conn_ip_getlocaladdr(conn_ip_t *conn, void *addr)
{
assert(conn != NULL);
return lwip_conn_getlocaladdr(conn->lwip_conn, addr, NULL);
}

int conn_ip_recvfrom(conn_ip_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len)
{
assert(conn != NULL);
return lwip_conn_recvfrom(conn->lwip_conn, data, max_len, addr, addr_len, NULL);
}

int conn_ip_sendto(const void *data, size_t len, const void *src, size_t src_len,
void *dst, size_t dst_len, int family, int proto)
{
struct netconn *tmp;
int res;

res = lwip_conn_create(&tmp, src, src_len, family, NETCONN_RAW, proto, 0);
if (res < 0) {
return res;
}
res = lwip_conn_sendto(tmp, data, len, dst, dst_len, 0);
netconn_delete(tmp);
return res;
}

/** @} */