aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-07 12:43:22 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-07 12:43:22 +0000
commitb7ac5f4236f1cc55078aeaf99be2c2f941199ca9 (patch)
treee7f131af91fd94b836fe9d6069402c1dd8f97e17
parent29390f2dfed7323498b1f83dcdc8219d6861d6e4 (diff)
downloadChibiOS-b7ac5f4236f1cc55078aeaf99be2c2f941199ca9.tar.gz
ChibiOS-b7ac5f4236f1cc55078aeaf99be2c2f941199ca9.tar.bz2
ChibiOS-b7ac5f4236f1cc55078aeaf99be2c2f941199ca9.zip
lwIP 2.0.3 integrated
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10790 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--ext/lwip-2.0.3-patched.7zbin0 -> 2506479 bytes
-rw-r--r--os/various/lwip_bindings/arch/cc.h22
-rw-r--r--os/various/lwip_bindings/lwip.mk52
-rw-r--r--os/various/lwip_bindings/lwipthread.c119
-rw-r--r--os/various/lwip_bindings/lwipthread.h2
-rw-r--r--readme.txt1
6 files changed, 91 insertions, 105 deletions
diff --git a/ext/lwip-2.0.3-patched.7z b/ext/lwip-2.0.3-patched.7z
new file mode 100644
index 000000000..39c12e7e9
--- /dev/null
+++ b/ext/lwip-2.0.3-patched.7z
Binary files differ
diff --git a/os/various/lwip_bindings/arch/cc.h b/os/various/lwip_bindings/arch/cc.h
index 4c1d4f379..50c677a03 100644
--- a/os/various/lwip_bindings/arch/cc.h
+++ b/os/various/lwip_bindings/arch/cc.h
@@ -53,28 +53,10 @@
#include <hal.h>
-typedef uint8_t u8_t;
-typedef int8_t s8_t;
-typedef uint16_t u16_t;
-typedef int16_t s16_t;
-typedef uint32_t u32_t;
-typedef int32_t s32_t;
-typedef uint32_t mem_ptr_t;
-
-#define PACK_STRUCT_STRUCT __attribute__((packed))
-
-#ifndef BYTE_ORDER
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
+/* Use errno provided by system. */
+#define LWIP_ERRNO_INCLUDE <errno.h>
/**
- * @brief Use lwIP provided error codes by default.
- */
-#ifndef LWIP_PROVIDE_ERRNO
-#define LWIP_PROVIDE_ERRNO 1
-#endif
-
-/**
* @brief Use system provided struct timeval by default.
*/
#ifndef LWIP_TIMEVAL_PRIVATE
diff --git a/os/various/lwip_bindings/lwip.mk b/os/various/lwip_bindings/lwip.mk
index 2ab332a09..7674931f3 100644
--- a/os/various/lwip_bindings/lwip.mk
+++ b/os/various/lwip_bindings/lwip.mk
@@ -1,54 +1,18 @@
# List of the required lwIP files.
-LWIP = $(CHIBIOS)/ext/lwip
+LWIPDIR = $(CHIBIOS)/ext/lwip/src
+
+# The various blocks of files are outlined in Filelists.mk.
+include $(LWIPDIR)/Filelists.mk
LWBINDSRC = \
$(CHIBIOS)/os/various/lwip_bindings/lwipthread.c \
$(CHIBIOS)/os/various/lwip_bindings/arch/sys_arch.c
-LWNETIFSRC = \
- $(LWIP)/src/netif/etharp.c
-
-LWCORESRC = \
- $(LWIP)/src/core/dhcp.c \
- $(LWIP)/src/core/dns.c \
- $(LWIP)/src/core/init.c \
- $(LWIP)/src/core/mem.c \
- $(LWIP)/src/core/memp.c \
- $(LWIP)/src/core/netif.c \
- $(LWIP)/src/core/pbuf.c \
- $(LWIP)/src/core/raw.c \
- $(LWIP)/src/core/stats.c \
- $(LWIP)/src/core/sys.c \
- $(LWIP)/src/core/tcp.c \
- $(LWIP)/src/core/tcp_in.c \
- $(LWIP)/src/core/tcp_out.c \
- $(LWIP)/src/core/udp.c
-
-LWIPV4SRC = \
- $(LWIP)/src/core/ipv4/autoip.c \
- $(LWIP)/src/core/ipv4/icmp.c \
- $(LWIP)/src/core/ipv4/igmp.c \
- $(LWIP)/src/core/ipv4/inet.c \
- $(LWIP)/src/core/ipv4/inet_chksum.c \
- $(LWIP)/src/core/ipv4/ip.c \
- $(LWIP)/src/core/ipv4/ip_addr.c \
- $(LWIP)/src/core/ipv4/ip_frag.c \
- $(LWIP)/src/core/def.c \
- $(LWIP)/src/core/timers.c
-
-LWAPISRC = \
- $(LWIP)/src/api/api_lib.c \
- $(LWIP)/src/api/api_msg.c \
- $(LWIP)/src/api/err.c \
- $(LWIP)/src/api/netbuf.c \
- $(LWIP)/src/api/netdb.c \
- $(LWIP)/src/api/netifapi.c \
- $(LWIP)/src/api/sockets.c \
- $(LWIP)/src/api/tcpip.c
-LWSRC = $(LWBINDSRC) $(LWNETIFSRC) $(LWCORESRC) $(LWIPV4SRC) $(LWAPISRC)
+# Add blocks of files from Filelists.mk as required for enabled options
+LWSRC = $(COREFILES) $(CORE4FILES) $(APIFILES) $(LWBINDSRC) $(NETIFFILES) $(HTTPDFILES)
LWINC = \
$(CHIBIOS)/os/various/lwip_bindings \
- $(LWIP)/src/include \
- $(LWIP)/src/include/ipv4
+ $(LWIPDIR)/include \
+ $(LWIPDIR)/include/lwip/apps
diff --git a/os/various/lwip_bindings/lwipthread.c b/os/various/lwip_bindings/lwipthread.c
index b638c7a7e..3e23118a8 100644
--- a/os/various/lwip_bindings/lwipthread.c
+++ b/os/various/lwip_bindings/lwipthread.c
@@ -69,7 +69,11 @@
#include <lwip/snmp.h>
#include <lwip/tcpip.h>
#include <netif/etharp.h>
+#include <lwip/netifapi.h>
+
+#if PPPOE_SUPPORT
#include <netif/ppp_oe.h>
+#endif
#if LWIP_DHCP
#include <lwip/dhcp.h>
@@ -141,6 +145,17 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) {
macWriteTransmitDescriptor(&td, (uint8_t *)q->payload, (size_t)q->len);
macReleaseTransmitDescriptor(&td);
+ MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
+ if (((u8_t*)p->payload)[0] & 1) {
+ /* broadcast or multicast packet*/
+ MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts);
+ }
+ else {
+ /* unicast packet */
+ MIB2_STATS_NETIF_INC(netif, ifoutucastpkts);
+ }
+ /* increase ifoutdiscards or ifouterrors on error */
+
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
#endif
@@ -152,48 +167,69 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) {
/*
* Receives a frame.
+ * Allocates a pbuf and transfers the bytes of the incoming
+ * packet from the interface into the pbuf.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return a pbuf filled with the received packet (including MAC header)
+ * NULL on memory error
*/
-static struct pbuf *low_level_input(struct netif *netif) {
+static bool low_level_input(struct netif *netif, struct pbuf **pbuf) {
MACReceiveDescriptor rd;
- struct pbuf *p, *q;
+ struct pbuf *q;
u16_t len;
(void)netif;
- if (macWaitReceiveDescriptor(&ETHD1, &rd, TIME_IMMEDIATE) == MSG_OK) {
- len = (u16_t)rd.size;
-#if ETH_PAD_SIZE
- len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
-#endif
+ osalDbgAssert(pbuf != NULL, "invalid null pointer");
- /* We allocate a pbuf chain of pbufs from the pool. */
- p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+ if (macWaitReceiveDescriptor(&ETHD1, &rd, TIME_IMMEDIATE) != MSG_OK)
+ return false;
- if (p != NULL) {
+ len = (u16_t)rd.size;
#if ETH_PAD_SIZE
- pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
+ len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
#endif
- /* Iterates through the pbuf chain. */
- for(q = p; q != NULL; q = q->next)
- macReadReceiveDescriptor(&rd, (uint8_t *)q->payload, (size_t)q->len);
- macReleaseReceiveDescriptor(&rd);
+ /* We allocate a pbuf chain of pbufs from the pool. */
+ *pbuf = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+ if (*pbuf != NULL) {
#if ETH_PAD_SIZE
- pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
+ pbuf_header(pbuf, -ETH_PAD_SIZE); /* drop the padding word */
#endif
- LINK_STATS_INC(link.recv);
- }
+ /* Iterates through the pbuf chain. */
+ for(q = *pbuf; q != NULL; q = q->next)
+ macReadReceiveDescriptor(&rd, (uint8_t *)q->payload, (size_t)q->len);
+ macReleaseReceiveDescriptor(&rd);
+
+ MIB2_STATS_NETIF_ADD(netif, ifinoctets, *pbuf->tot_len);
+
+ if (*(uint8_t *)((*pbuf)->payload) & 1) {
+ /* broadcast or multicast packet*/
+ MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
+ }
else {
- macReleaseReceiveDescriptor(&rd);
- LINK_STATS_INC(link.memerr);
- LINK_STATS_INC(link.drop);
+ /* unicast packet*/
+ MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
}
- return p;
+
+#if ETH_PAD_SIZE
+ pbuf_header(pbuf, ETH_PAD_SIZE); /* reclaim the padding word */
+#endif
+
+ LINK_STATS_INC(link.recv);
}
- return NULL;
+ else {
+ macReleaseReceiveDescriptor(&rd); // Drop packet
+ LINK_STATS_INC(link.memerr);
+ LINK_STATS_INC(link.drop);
+ MIB2_STATS_NETIF_INC(netif, ifindiscards);
+ }
+
+ return true;
}
/*
@@ -216,7 +252,7 @@ static err_t ethernetif_init(struct netif *netif) {
* The last argument should be replaced with your link speed, in units
* of bits per second.
*/
- NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LWIP_LINK_SPEED);
+ MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, LWIP_LINK_SPEED);
netif->state = NULL;
netif->name[0] = LWIP_IFNAME0;
@@ -301,7 +337,7 @@ static THD_FUNCTION(lwip_thread, p) {
};
netif_set_default(&thisif);
-
+
switch (addressMode)
{
#if LWIP_AUTOIP
@@ -349,26 +385,29 @@ static THD_FUNCTION(lwip_thread, p) {
}
}
}
+
if (mask & FRAME_RECEIVED_ID) {
struct pbuf *p;
- while ((p = low_level_input(&thisif)) != NULL) {
- struct eth_hdr *ethhdr = p->payload;
- switch (htons(ethhdr->type)) {
- /* IP or ARP packet? */
- case ETHTYPE_IP:
- case ETHTYPE_ARP:
+ while (low_level_input(&thisif, &p)) {
+ if (p != NULL) {
+ struct eth_hdr *ethhdr = p->payload;
+ switch (htons(ethhdr->type)) {
+ /* IP or ARP packet? */
+ case ETHTYPE_IP:
+ case ETHTYPE_ARP:
#if PPPOE_SUPPORT
- /* PPPoE packet? */
- case ETHTYPE_PPPOEDISC:
- case ETHTYPE_PPPOE:
+ /* PPPoE packet? */
+ case ETHTYPE_PPPOEDISC:
+ case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
- /* full packet send to tcpip_thread to process */
- if (thisif.input(p, &thisif) == ERR_OK)
- break;
- LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
+ /* full packet send to tcpip_thread to process */
+ if (thisif.input(p, &thisif) == ERR_OK)
+ break;
+ LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
/* Falls through */
- default:
- pbuf_free(p);
+ default:
+ pbuf_free(p);
+ }
}
}
}
diff --git a/os/various/lwip_bindings/lwipthread.h b/os/various/lwip_bindings/lwipthread.h
index 947d0afd7..61eb1b2dd 100644
--- a/os/various/lwip_bindings/lwipthread.h
+++ b/os/various/lwip_bindings/lwipthread.h
@@ -58,7 +58,7 @@
* @brief lwIP thread stack size.
*/
#if !defined(LWIP_THREAD_STACK_SIZE) || defined(__DOXYGEN__)
-#define LWIP_THREAD_STACK_SIZE 576
+#define LWIP_THREAD_STACK_SIZE 672
#endif
/**
diff --git a/readme.txt b/readme.txt
index edc1c2c2a..8aaf58b0a 100644
--- a/readme.txt
+++ b/readme.txt
@@ -89,6 +89,7 @@
*****************************************************************************
*** Next ***
+- NEW: Integrated lwIP 2.0.3 and improved lwIP bindings.
- NEW: The chconf.h configuration files now are tagged with the version
number for safety. The system rejects obsolete files during
compilation.