changeset 2934:d6c0c0e0431c

* net/lwip_tcpip/current/*: Major update of lwIP TCP/IP stack to version 1.3.2. * io/eth/current/cdl/eth_drivers.cdl, include/eth_drv.h: Minor changes for lwIP 1.3.x. * io/eth/current/src/lwip/eth_drv.c: Rework for lwIP 1.3.x based on standalone driver for RedBoot. * io/eth/current/src/lwip/eth_conf.inl: Add static interface configuration.
author jld
date Tue, 26 Jan 2010 11:27:47 +0000
parents 0cdf7781a5ab
children 918ae79235a2
files packages/io/eth/current/ChangeLog packages/io/eth/current/cdl/eth_drivers.cdl packages/io/eth/current/include/eth_drv.h packages/io/eth/current/src/lwip/eth_conf.inl packages/io/eth/current/src/lwip/eth_drv.c packages/net/lwip_tcpip/current/ChangeLog packages/net/lwip_tcpip/current/cdl/lwip_net.cdl packages/net/lwip_tcpip/current/doc/contrib.txt packages/net/lwip_tcpip/current/doc/rawapi.txt packages/net/lwip_tcpip/current/doc/savannah.txt packages/net/lwip_tcpip/current/doc/snmp_agent.txt packages/net/lwip_tcpip/current/doc/sys_arch.txt packages/net/lwip_tcpip/current/host/extractdump.py packages/net/lwip_tcpip/current/include/arch/cc.h packages/net/lwip_tcpip/current/include/arch/perf.h packages/net/lwip_tcpip/current/include/arch/sys_arch.h packages/net/lwip_tcpip/current/include/lwip.h packages/net/lwip_tcpip/current/include/lwip/api.h packages/net/lwip_tcpip/current/include/lwip/api_msg.h packages/net/lwip_tcpip/current/include/lwip/arch.h packages/net/lwip_tcpip/current/include/lwip/autoip.h packages/net/lwip_tcpip/current/include/lwip/debug.h packages/net/lwip_tcpip/current/include/lwip/def.h packages/net/lwip_tcpip/current/include/lwip/dhcp.h packages/net/lwip_tcpip/current/include/lwip/dns.h packages/net/lwip_tcpip/current/include/lwip/err.h packages/net/lwip_tcpip/current/include/lwip/icmp.h packages/net/lwip_tcpip/current/include/lwip/igmp.h packages/net/lwip_tcpip/current/include/lwip/inet.h packages/net/lwip_tcpip/current/include/lwip/inet_chksum.h packages/net/lwip_tcpip/current/include/lwip/init.h packages/net/lwip_tcpip/current/include/lwip/ip.h packages/net/lwip_tcpip/current/include/lwip/ip_addr.h packages/net/lwip_tcpip/current/include/lwip/ip_frag.h packages/net/lwip_tcpip/current/include/lwip/mem.h packages/net/lwip_tcpip/current/include/lwip/memp.h packages/net/lwip_tcpip/current/include/lwip/memp_std.h packages/net/lwip_tcpip/current/include/lwip/netbuf.h packages/net/lwip_tcpip/current/include/lwip/netdb.h packages/net/lwip_tcpip/current/include/lwip/netif.h packages/net/lwip_tcpip/current/include/lwip/netifapi.h packages/net/lwip_tcpip/current/include/lwip/opt.h packages/net/lwip_tcpip/current/include/lwip/pbuf.h packages/net/lwip_tcpip/current/include/lwip/raw.h packages/net/lwip_tcpip/current/include/lwip/sio.h packages/net/lwip_tcpip/current/include/lwip/snmp.h packages/net/lwip_tcpip/current/include/lwip/snmp_asn1.h packages/net/lwip_tcpip/current/include/lwip/snmp_msg.h packages/net/lwip_tcpip/current/include/lwip/snmp_structs.h packages/net/lwip_tcpip/current/include/lwip/sockets.h packages/net/lwip_tcpip/current/include/lwip/stats.h packages/net/lwip_tcpip/current/include/lwip/sys.h packages/net/lwip_tcpip/current/include/lwip/tcp.h packages/net/lwip_tcpip/current/include/lwip/tcpip.h packages/net/lwip_tcpip/current/include/lwip/udp.h packages/net/lwip_tcpip/current/include/lwipopts.h packages/net/lwip_tcpip/current/include/netif/etharp.h packages/net/lwip_tcpip/current/include/netif/loopif.h packages/net/lwip_tcpip/current/include/netif/ppp/chat.h packages/net/lwip_tcpip/current/include/netif/ppp/ppp.h packages/net/lwip_tcpip/current/include/netif/ppp_oe.h packages/net/lwip_tcpip/current/include/netif/slipif.h packages/net/lwip_tcpip/current/include/network.h packages/net/lwip_tcpip/current/src/api/api_lib.c packages/net/lwip_tcpip/current/src/api/api_msg.c packages/net/lwip_tcpip/current/src/api/err.c packages/net/lwip_tcpip/current/src/api/netbuf.c packages/net/lwip_tcpip/current/src/api/netdb.c packages/net/lwip_tcpip/current/src/api/netifapi.c packages/net/lwip_tcpip/current/src/api/sockets.c packages/net/lwip_tcpip/current/src/api/tcpip.c packages/net/lwip_tcpip/current/src/core/dhcp.c packages/net/lwip_tcpip/current/src/core/dns.c packages/net/lwip_tcpip/current/src/core/init.c packages/net/lwip_tcpip/current/src/core/ipv4/autoip.c packages/net/lwip_tcpip/current/src/core/ipv4/icmp.c packages/net/lwip_tcpip/current/src/core/ipv4/igmp.c packages/net/lwip_tcpip/current/src/core/ipv4/inet.c packages/net/lwip_tcpip/current/src/core/ipv4/inet_chksum.c packages/net/lwip_tcpip/current/src/core/ipv4/ip.c packages/net/lwip_tcpip/current/src/core/ipv4/ip_addr.c packages/net/lwip_tcpip/current/src/core/ipv4/ip_frag.c packages/net/lwip_tcpip/current/src/core/mem.c packages/net/lwip_tcpip/current/src/core/memp.c packages/net/lwip_tcpip/current/src/core/netif.c packages/net/lwip_tcpip/current/src/core/pbuf.c packages/net/lwip_tcpip/current/src/core/raw.c packages/net/lwip_tcpip/current/src/core/snmp/asn1_dec.c packages/net/lwip_tcpip/current/src/core/snmp/asn1_enc.c packages/net/lwip_tcpip/current/src/core/snmp/mib2.c packages/net/lwip_tcpip/current/src/core/snmp/mib_structs.c packages/net/lwip_tcpip/current/src/core/snmp/msg_in.c packages/net/lwip_tcpip/current/src/core/snmp/msg_out.c packages/net/lwip_tcpip/current/src/core/stats.c packages/net/lwip_tcpip/current/src/core/sys.c packages/net/lwip_tcpip/current/src/core/tcp.c packages/net/lwip_tcpip/current/src/core/tcp_in.c packages/net/lwip_tcpip/current/src/core/tcp_out.c packages/net/lwip_tcpip/current/src/core/udp.c packages/net/lwip_tcpip/current/src/ecos/ppp.c packages/net/lwip_tcpip/current/src/ecos/sequential.c packages/net/lwip_tcpip/current/src/ecos/simple.c packages/net/lwip_tcpip/current/src/ecos/sio.c packages/net/lwip_tcpip/current/src/ecos/sys_arch.c packages/net/lwip_tcpip/current/src/netif/etharp.c packages/net/lwip_tcpip/current/src/netif/ethernetif.c packages/net/lwip_tcpip/current/src/netif/loopif.c packages/net/lwip_tcpip/current/src/netif/ppp/auth.c packages/net/lwip_tcpip/current/src/netif/ppp/auth.h packages/net/lwip_tcpip/current/src/netif/ppp/chap.c packages/net/lwip_tcpip/current/src/netif/ppp/chap.h packages/net/lwip_tcpip/current/src/netif/ppp/chat.c packages/net/lwip_tcpip/current/src/netif/ppp/chpms.c packages/net/lwip_tcpip/current/src/netif/ppp/chpms.h packages/net/lwip_tcpip/current/src/netif/ppp/fsm.c packages/net/lwip_tcpip/current/src/netif/ppp/fsm.h packages/net/lwip_tcpip/current/src/netif/ppp/ipcp.c packages/net/lwip_tcpip/current/src/netif/ppp/ipcp.h packages/net/lwip_tcpip/current/src/netif/ppp/lcp.c packages/net/lwip_tcpip/current/src/netif/ppp/lcp.h packages/net/lwip_tcpip/current/src/netif/ppp/magic.c packages/net/lwip_tcpip/current/src/netif/ppp/magic.h packages/net/lwip_tcpip/current/src/netif/ppp/md5.c packages/net/lwip_tcpip/current/src/netif/ppp/md5.h packages/net/lwip_tcpip/current/src/netif/ppp/pap.c packages/net/lwip_tcpip/current/src/netif/ppp/pap.h packages/net/lwip_tcpip/current/src/netif/ppp/ppp.c packages/net/lwip_tcpip/current/src/netif/ppp/ppp_oe.c packages/net/lwip_tcpip/current/src/netif/ppp/pppdebug.h packages/net/lwip_tcpip/current/src/netif/ppp/randm.c packages/net/lwip_tcpip/current/src/netif/ppp/randm.h packages/net/lwip_tcpip/current/src/netif/ppp/record.c packages/net/lwip_tcpip/current/src/netif/ppp/record.h packages/net/lwip_tcpip/current/src/netif/ppp/timesys.c packages/net/lwip_tcpip/current/src/netif/ppp/timesys.h packages/net/lwip_tcpip/current/src/netif/ppp/vj.c packages/net/lwip_tcpip/current/src/netif/ppp/vj.h packages/net/lwip_tcpip/current/src/netif/ppp/vjbsdhdr.h packages/net/lwip_tcpip/current/src/netif/slipif.c packages/net/lwip_tcpip/current/tests/httpd_sequential.c packages/net/lwip_tcpip/current/tests/httpd_simple.c packages/net/lwip_tcpip/current/tests/nc_test_framework.h packages/net/lwip_tcpip/current/tests/nc_test_slave.c packages/net/lwip_tcpip/current/tests/ppp.c packages/net/lwip_tcpip/current/tests/socket.c packages/net/lwip_tcpip/current/tests/sys_timeout.c packages/net/lwip_tcpip/current/tests/tcpecho.c packages/net/lwip_tcpip/current/tests/udpecho.c
diffstat 148 files changed, 46272 insertions(+), 15423 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/eth/current/ChangeLog
+++ b/packages/io/eth/current/ChangeLog
@@ -1,3 +1,11 @@
+2010-01-25  Simon Kallweit  <simon.kallweit@intefo.ch>
+
+	* cdl/eth_drivers.cdl, include/eth_drv.h: Minor changes for
+	lwIP 1.3.x.
+	* src/lwip/eth_drv.c: Rework for lwIP 1.3.x based on standalone
+	driver for RedBoot.
+	* src/lwip/eth_conf.inl: Add static interface configuration.
+
 2009-07-24  Edgar Grimberg  <edgar.grimberg@zylin.com>
 
 	* cdl/eth_drivers.cdl: Added the suppress option for 
--- a/packages/io/eth/current/cdl/eth_drivers.cdl
+++ b/packages/io/eth/current/cdl/eth_drivers.cdl
@@ -173,7 +173,7 @@ cdl_package CYGPKG_IO_ETH_DRIVERS {
     cdl_component CYGPKG_IO_ETH_DRIVERS_STAND_ALONE {
         display       "Support for stand-alone network stack."
         flavor        bool
-        active_if     !CYGPKG_NET
+        active_if     { !CYGPKG_NET && !CYGPKG_NET_LWIP }
         requires      CYGINT_ISO_STRING_MEMFUNCS 
         default_value 1
         compile       stand_alone/eth_drv.c
--- a/packages/io/eth/current/include/eth_drv.h
+++ b/packages/io/eth/current/include/eth_drv.h
@@ -8,7 +8,7 @@
 // ####ECOSGPLCOPYRIGHTBEGIN####                                            
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
 //
 // eCos is free software; you can redistribute it and/or modify it under    
 // the terms of the GNU General Public License as published by the Free     
@@ -154,6 +154,9 @@ struct arpcom {
 #ifdef CYGPKG_NET_LWIP
 struct arpcom {
     struct netif ac_if;
+# ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
+    cyg_sem_t send_sem;
+# endif
 };
 #endif
 
new file mode 100644
--- /dev/null
+++ b/packages/io/eth/current/src/lwip/eth_conf.inl
@@ -0,0 +1,157 @@
+//==========================================================================
+//
+//      src/lwip/eth_conf.inl
+//
+//      Static interface configuration
+//
+//==========================================================================
+// ####ECOSGPLCOPYRIGHTBEGIN####                                            
+// -------------------------------------------                              
+// This file is part of eCos, the Embedded Configurable Operating System.   
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under    
+// the terms of the GNU General Public License as published by the Free     
+// Software Foundation; either version 2 or (at your option) any later      
+// version.                                                                 
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT      
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
+// for more details.                                                        
+//
+// You should have received a copy of the GNU General Public License        
+// along with eCos; if not, write to the Free Software Foundation, Inc.,    
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
+//
+// As a special exception, if other files instantiate templates or use      
+// macros or inline functions from this file, or you compile this file      
+// and link it with other works to produce a work based on this file,       
+// this file does not by itself cause the resulting work to be covered by   
+// the GNU General Public License. However the source code for this file    
+// must still be made available in accordance with section (3) of the GNU   
+// General Public License v2.                                               
+//
+// This exception does not invalidate any other reasons why a work based    
+// on this file might be covered by the GNU General Public License.         
+// -------------------------------------------                              
+// ####ECOSGPLCOPYRIGHTEND####                                              
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    Simon Kallweit
+// Contributors:
+// Date:         2009-06-09
+// Purpose:      Static interface configuration
+// Description:  
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/net_lwip.h>
+
+// Ethernet device configuration
+struct eth_conf {
+    cyg_uint8 def;          // This is the default netif
+    cyg_uint8 dhcp;         // Use DHCP client to get address
+    cyg_uint8 addr[4];      // IPv4 address
+    cyg_uint8 netmask[4];   // IPv4 netmask
+    cyg_uint8 gateway[4];   // IPv4 gateway
+};
+
+// Ethernet device configuration table
+static struct eth_conf eth_conf_table[] = {
+// Ethernet device 0
+#ifdef CYGPKG_LWIP_ETH0_CONF
+    {
+# ifdef CYGDAT_LWIP_ETH0_DEFAULT
+        .def = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH0_DHCP
+        .dhcp = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH0_NETCONF_ADDR
+        .addr = { CYGDAT_LWIP_ETH0_NETCONF_ADDR },
+# endif
+# ifdef CYGDAT_LWIP_ETH0_NETCONF_NETMASK
+        .netmask = { CYGDAT_LWIP_ETH0_NETCONF_NETMASK },
+# endif
+# ifdef CYGDAT_LWIP_ETH0_NETCONF_GATEWAY
+        .gateway = { CYGDAT_LWIP_ETH0_NETCONF_GATEWAY },
+# endif
+    },
+#endif // CYGPKG_LWIP_ETH0_CONF
+// Ethernet device 1
+#ifdef CYGPKG_LWIP_ETH1_CONF
+    {
+# ifdef CYGDAT_LWIP_ETH1_DEFAULT
+        .def = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH1_DHCP
+        .dhcp = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH1_NETCONF_ADDR
+        .addr = { CYGDAT_LWIP_ETH1_NETCONF_ADDR },
+# endif
+# ifdef CYGDAT_LWIP_ETH1_NETCONF_NETMASK
+        .netmask = { CYGDAT_LWIP_ETH1_NETCONF_NETMASK },
+# endif
+# ifdef CYGDAT_LWIP_ETH1_NETCONF_GATEWAY
+        .gateway = { CYGDAT_LWIP_ETH1_NETCONF_GATEWAY },
+# endif
+    },
+#endif // CYGPKG_LWIP_ETH1_CONF
+// Ethernet device 2
+#ifdef CYGPKG_LWIP_ETH2_CONF
+    {
+# ifdef CYGDAT_LWIP_ETH2_DEFAULT
+        .def = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH2_DHCP
+        .dhcp = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH2_NETCONF_ADDR
+        .addr = { CYGDAT_LWIP_ETH2_NETCONF_ADDR },
+# endif
+# ifdef CYGDAT_LWIP_ETH2_NETCONF_NETMASK
+        .netmask = { CYGDAT_LWIP_ETH2_NETCONF_NETMASK },
+# endif
+# ifdef CYGDAT_LWIP_ETH2_NETCONF_GATEWAY
+        .gateway = { CYGDAT_LWIP_ETH2_NETCONF_GATEWAY },
+# endif
+    },
+#endif // CYGPKG_LWIP_ETH2_CONF
+// Ethernet device 3
+#ifdef CYGPKG_LWIP_ETH3_CONF
+    {
+# ifdef CYGDAT_LWIP_ETH3_DEFAULT
+        .def = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH3_DHCP
+        .dhcp = 1,
+# endif
+# ifdef CYGDAT_LWIP_ETH3_NETCONF_ADDR
+        .addr = { CYGDAT_LWIP_ETH3_NETCONF_ADDR },
+# endif
+# ifdef CYGDAT_LWIP_ETH3_NETCONF_NETMASK
+        .netmask = { CYGDAT_LWIP_ETH3_NETCONF_NETMASK },
+# endif
+# ifdef CYGDAT_LWIP_ETH3_NETCONF_GATEWAY
+        .gateway = { CYGDAT_LWIP_ETH3_NETCONF_GATEWAY },
+# endif
+    },
+#endif // CYGPKG_LWIP_ETH3_CONF
+};
+
+#define NUM_ETH_CONF (sizeof(eth_conf_table) / sizeof(struct eth_conf))
+
+static int eth_conf_index; 
+
+static struct eth_conf *next_eth_conf(void)
+{
+    if (eth_conf_index < NUM_ETH_CONF)
+        return &eth_conf_table[eth_conf_index++];
+    
+    return NULL;
+}
--- a/packages/io/eth/current/src/lwip/eth_drv.c
+++ b/packages/io/eth/current/src/lwip/eth_drv.c
@@ -2,13 +2,13 @@
 //
 //      src/lwip/eth_drv.c
 //
-//      Hardware independent ethernet driver for lwIP
+//      Hardware independent networking support for lwIP
 //
 //==========================================================================
 // ####ECOSGPLCOPYRIGHTBEGIN####                                            
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 //
 // eCos is free software; you can redistribute it and/or modify it under    
 // the terms of the GNU General Public License as published by the Free     
@@ -39,12 +39,12 @@
 //==========================================================================
 //#####DESCRIPTIONBEGIN####
 //
-// Author(s):    Jani Monoses <jani@iv.ro>
-// Contributors: 
-// Date:         2002-04-05
-// Purpose:      Hardware independent ethernet driver
+// Author(s):    Simon Kallweit
+// Contributors:
+// Date:         2008-12-09
+// Purpose:      Hardware independent networking support for lwIP.
 // Description:  Based on the standalone driver for RedBoot.
-//               
+//
 //####DESCRIPTIONEND####
 //
 //==========================================================================
@@ -64,77 +64,52 @@
 #include <cyg/hal/hal_tables.h>
 #include <cyg/kernel/kapi.h>
 
-#include "lwip/opt.h"
-#include "lwip/ip.h"
-#include "lwip/mem.h"
-#include "lwip/pbuf.h"
-#include "lwip/sys.h"
-
-#include "netif/etharp.h"
-
-
-// Interfaces exported to drivers
-
-static void eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr);
-static void eth_drv_recv(struct eth_drv_sc *sc, int total_len);
-static void eth_drv_tx_done(struct eth_drv_sc *sc, CYG_ADDRWORD key, int status);
-
-struct eth_drv_funs eth_drv_funs = { eth_drv_init, eth_drv_recv, eth_drv_tx_done };
+#include <lwip/opt.h>
+#include <lwip/ip.h>
+#include <lwip/mem.h>
+#include <lwip/pbuf.h>
+#include <lwip/sys.h>
+#include <lwip/dhcp.h>
+#include <netif/etharp.h>
 
-#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG 
-int cyg_io_eth_net_debug = CYGDBG_IO_ETH_DRIVERS_DEBUG_VERBOSITY;
-#endif
-
-extern void lwip_dsr_stuff(void);
-extern void lwip_set_addr(struct netif *);
-extern void lwip_dhcp_init(struct netif *);
+#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
 
-//DSR called from the low level driver.Signals the input_thread
-void
-eth_drv_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
-{
-  struct eth_drv_sc *sc = (struct eth_drv_sc *) data;
-  sc->state |= ETH_DRV_NEEDS_DELIVERY;
-  lwip_dsr_stuff();	
-}
+#include <cyg/hal/hal_if.h>
 
-err_t ecosif_init(struct netif *netif);
+// Use with care!  Local variable defined!
+#define START_CONSOLE()                                                                 \
+{   /* NEW BLOCK */                                                                     \
+    int _cur_console =                                                                  \
+        CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);      \
+    {                                                                                   \
+        int i;                                                                          \
+        if ( CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,                 \
+                                          "info_console_force", &i,                     \
+                                          CYGNUM_FLASH_CFG_TYPE_CONFIG_BOOL ) ) {       \
+            if ( i ) {                                                                  \
+                if ( CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,         \
+                                                  "info_console_number", &i,            \
+                                                  CYGNUM_FLASH_CFG_TYPE_CONFIG_INT ) ){ \
+                    /* Then i is the console to force it to: */                         \
+                    CYGACC_CALL_IF_SET_CONSOLE_COMM( i );                               \
+                }                                                                       \
+            }                                                                           \
+        }                                                                               \
+    }
 
-// This function is called during system initialization to register a
-// network interface with the system.
-static void
-eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr)
-{
-  struct netif *netif = &sc->sc_arpcom.ac_if;
-  
-  netif->state = sc;
-  ecosif_init(netif);
-  
-  // enaddr == 0 -> hardware init was incomplete (no ESA)
-  if (enaddr != 0) {
-    // Set up hardware address
-    memcpy(netif->hwaddr, enaddr, ETHER_ADDR_LEN);
-    // Perform any hardware initialization
-    (sc->funs->start) (sc, (unsigned char *) &netif->hwaddr, 0);
-  }
-#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
-// Set up interfaces so debug environment can share this device
-    {
-        void *dbg = CYGACC_CALL_IF_DBG_DATA();
-        if (!dbg) {
-            CYGACC_CALL_IF_DBG_DATA_SET((void *)sc);
-        }
-    }
+#define END_CONSOLE()                                   \
+    CYGACC_CALL_IF_SET_CONSOLE_COMM(_cur_console);      \
+}   /* END BLOCK */
+
+#else
+#define START_CONSOLE()
+#define END_CONSOLE()
 #endif
-    //
-    // we call this after the driver was started successfully
-    //
-    lwip_dhcp_init(netif);
-}
+// ------------------------------------------------------------------------
 
 //
 // Control whether any special locking needs to take place if we intend to
-// cooperate with a ROM monitor (e.g. RedBoot) using this hardware.  
+// cooperate with a ROM monitor (e.g. RedBoot) using this hardware.
 //
 #if defined(CYGSEM_HAL_USE_ROM_MONITOR) && \
     defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG) && \
@@ -147,49 +122,142 @@ eth_drv_init(struct eth_drv_sc *sc, unsi
 // using the network hardware for the debug channel.
 #define RedBoot_TCP_CHANNEL CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
 
+// Define this if you ever need to call 'diag_printf()' from interrupt level
+// code (ISR) and the debug channel might be using the network hardware. If
+// this is not the case, then disabling interrupts here is over-kill.
+//#define _LOCK_USING_INTERRUPTS
 #endif
 
-//
-// Send a packet of data to the hardware
-//
+// Static device configurations
+
+#include "eth_conf.inl"
+
+// Interfaces exported to drivers
+
+static void eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr);
+static void eth_drv_recv(struct eth_drv_sc *sc, int total_len);
+static void eth_drv_tx_done(struct eth_drv_sc *sc, CYG_ADDRWORD key, int status);
 
-static void
-eth_drv_send(struct netif *netif, struct pbuf *p)
-{
-  struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
-  struct eth_drv_sc *sc = netif->state;
-  int sg_len = 0;
-  struct pbuf *q;
+struct eth_drv_funs eth_drv_funs = {eth_drv_init, eth_drv_recv, eth_drv_tx_done};
+
+static void eth_drv_send(struct netif *netif, struct pbuf *p);
 
-#ifdef _LOCK_WITH_ROM_MONITOR
-    bool need_lock = false;
-    int debug_chan;
+#ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG
+int cyg_io_eth_net_debug = CYGDBG_IO_ETH_DRIVERS_DEBUG_VERBOSITY;
+// Usually just the header is enough, the body slows things too much.
+#define DIAG_DUMP_BUF_HDR( a, b ) if (0 < cyg_io_eth_net_debug) diag_dump_buf( (a), (b) )
+#define DIAG_DUMP_BUF_BDY( a, b ) if (1 < cyg_io_eth_net_debug) diag_dump_buf( (a), (b) )
+#else
+#define DIAG_DUMP_BUF_HDR( a, b )
+#define DIAG_DUMP_BUF_BDY( a, b )
 #endif
 
-  while (!(sc->funs->can_send) (sc)); 
+#define MAX_ETH_MSG 1540
+
+// Interface to lwIP glue code
+
+extern void lwip_eth_drv_new(struct netif *netif);
+extern void lwip_eth_drv_dsr(void);
+extern err_t lwip_eth_drv_input(struct pbuf *p, struct netif *netif);
+
+
+
+//
+// Called by lwIP to do the actual transmission of a packet. The packet passed
+// to this function may be chained. This function passes the data to the
+// hardware driver
+//
+static err_t eth_netif_linkoutput(struct netif *netif, struct pbuf *p)
+{
+    eth_drv_send(netif, p);
+    
+    return ERR_OK;
+}
+
+//
+// Called by lwIP when an IP packet should be sent.
+//
+static err_t eth_netif_output(struct netif *netif, struct pbuf *p,
+                          struct ip_addr *ipaddr)
+{
+    // Resolve hardware address, then send (or queue) packet
+    return etharp_output(netif, p, ipaddr);
+}
+
+//
+// Called by lwIP to init the netif.
+//
+static err_t eth_netif_init(struct netif *netif)
+{
+    netif->name[0] = 'e';
+    netif->name[1] = 't';
+    netif->hwaddr_len = 6;
+    netif->output = eth_netif_output;
+    netif->linkoutput = eth_netif_linkoutput;
+    netif->mtu = 1500;
+
+    netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
+    
+    return ERR_OK;
+}
 
-  for (q = p; q != NULL; q = q->next) {
-    sg_list[sg_len].buf = (CYG_ADDRESS) q->payload;
-    sg_list[sg_len++].len = q->len;
-  }
-#ifdef _LOCK_WITH_ROM_MONITOR
-  debug_chan = CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-  if (debug_chan == RedBoot_TCP_CHANNEL) {
-    need_lock = true;
-    cyg_drv_dsr_lock();
-  }
-#endif // _LOCK_WITH_ROM_MONITOR
+//
+// This function is called during system initialization to register a
+// network interface with the system.
+//
+static void
+eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr)
+{
+    struct netif *netif = &sc->sc_arpcom.ac_if;
+    struct eth_conf *conf;
+    struct ip_addr addr, netmask, gateway;
+    
+#ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
+    cyg_semaphore_init(&sc->sc_arpcom.send_sem, 1);
+#endif
+
+    // enaddr == 0 -> hardware init was incomplete (no ESA)
+    if (enaddr == 0)
+        return;
+    
+    netif->state = sc;
 
-  (sc->funs->send) (sc, sg_list, sg_len, p->tot_len,
-		    (CYG_ADDRWORD) p);
-
-#ifdef _LOCK_WITH_ROM_MONITOR
-  // Unlock the driver & hardware.  It can once again be safely shared.
-  if (need_lock) {
-    cyg_drv_dsr_unlock();
-  }
-#endif // _LOCK_WITH_ROM_MONITOR
-
+    // Configure the IP address
+    conf = next_eth_conf();
+    if (conf && !conf->dhcp) {
+        IP4_ADDR(&addr,    conf->addr[0], conf->addr[1],
+                           conf->addr[2], conf->addr[3]);
+        IP4_ADDR(&netmask, conf->netmask[0], conf->netmask[1],
+                           conf->netmask[2], conf->netmask[3]);
+        IP4_ADDR(&gateway, conf->gateway[0], conf->gateway[1],
+                           conf->gateway[2], conf->gateway[3]);
+    } else {
+        IP4_ADDR(&addr,    0, 0, 0, 0);
+        IP4_ADDR(&netmask, 0, 0, 0, 0);
+        IP4_ADDR(&gateway, 0, 0, 0, 0);
+    }
+    
+    netif_add(netif, &addr, &netmask, &gateway, netif->state,
+              eth_netif_init, lwip_eth_drv_input);
+    
+    lwip_eth_drv_new(netif);
+    
+    if (conf && conf->def)
+        netif_set_default(netif);
+    
+    // Set up hardware address
+    memcpy(netif->hwaddr, enaddr, ETHER_ADDR_LEN);
+    (sc->funs->start)(sc, (unsigned char *) &netif->hwaddr, 0);
+    
+    if (conf && !conf->dhcp)
+        netif_set_up(netif);
+    
+#if LWIP_DHCP
+    // Start DHCP if configured
+    if (conf && conf->dhcp) {
+        dhcp_start(netif);
+    }
+#endif
 }
 
 //
@@ -199,18 +267,127 @@ eth_drv_send(struct netif *netif, struct
 static void
 eth_drv_tx_done(struct eth_drv_sc *sc, CYG_ADDRWORD key, int status)
 {
-#if 0	
-  struct pbuf *p = (struct pbuf *)key;
-  struct netif *netif = &sc->sc_arpcom.ac_if;
-
-  CYGARC_HAL_SAVE_GP();
-  CYGARC_HAL_RESTORE_GP();
-#endif  
+#ifdef CYGFUN_LWIP_MODE_SIMPLE
+    // Stop polling
+    cyg_bool *done = (cyg_bool *) key;
+    *done = true;
+#endif
+#ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
+    // Wake-up the lwip-thread
+    cyg_semaphore_post(&sc->sc_arpcom.send_sem);
+#endif    
 }
 
-static void ecosif_input(struct netif *netif, struct pbuf* pbuf);
+//
+// Send a packet of data to the hardware.
+//
+static void
+eth_drv_send(struct netif *netif, struct pbuf *p)
+{
+    struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
+    struct eth_drv_sc *sc = netif->state;
+    int sg_len = 0;
+    struct pbuf *q;
+#ifdef _LOCK_WITH_ROM_MONITOR
+#ifdef _LOCK_USING_INTERRUPTS
+    cyg_uint32 ints;
+#endif
+    bool need_lock = false;
+    int debug_chan;
+#endif
+#ifdef CYGFUN_LWIP_MODE_SIMPLE
+    cyg_bool done = false;
+    int wait_cycles = 100;
+#endif
+    
+#ifdef CYGFUN_LWIP_MODE_SIMPLE
+    // Wait until we can send
+    while (!(sc->funs->can_send)(sc)) {
+        // Give driver a chance to service hardware
+        (sc->funs->poll)(sc);
+        if (--wait_cycles <= 0) {
+            START_CONSOLE();
+            diag_printf("cannot send packet\n");
+            END_CONSOLE();
+            return;
+        }
+    }
+#endif // CYGFUN_LWIP_MODE_SIMPLE
+    
+#ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
+    // Wait until we can send
+    if ((sc->funs->can_send)(sc) < 1)
+        cyg_semaphore_wait(&sc->sc_arpcom.send_sem);
+    if ((sc->funs->can_send)(sc) < 1)
+        CYG_FAIL("cannot send packet");
+#endif // CYGFUN_LWIP_MODE_SEQUENTIAL
+    
+    // Create scatter list
+    for (q = p; q != NULL && sg_len < MAX_ETH_DRV_SG; q = q->next) {
+        sg_list[sg_len].buf = (CYG_ADDRESS) q->payload;
+        sg_list[sg_len++].len = q->len;
+    }
+    
+#ifdef _LOCK_WITH_ROM_MONITOR
+    // Firm lock on this portion of the driver.  Since we are about to
+    // start messing with the actual hardware, it is imperative that the
+    // current thread not loose control of the CPU at this time.  Otherwise,
+    // the hardware could be left in an unusable state.  This caution is
+    // only warranted if there is a possibility of some other thread trying
+    // to use the hardware simultaneously.  The network stack would prevent
+    // this implicitly since all accesses are controlled by the "splX()"
+    // locks, but if there is a ROM monitor, such as RedBoot, also using
+    // the hardware, all bets are off.
 
-#define MAX_ETH_MSG 1540
+    // Note: these operations can be avoided if it were well known that
+    // RedBoot was not using the network hardware for diagnostic I/O.  This
+    // can be inferred by checking which I/O channel RedBoot is currently
+    // hooked to.
+    debug_chan = CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
+    if (debug_chan == RedBoot_TCP_CHANNEL) {
+        need_lock = true;
+#ifdef _LOCK_USING_INTERRUPTS
+        HAL_DISABLE_INTERRUPTS(ints);
+#endif
+        cyg_drv_dsr_lock();
+    }
+#endif // _LOCK_WITH_ROM_MONITOR
+
+#ifdef CYGFUN_LWIP_MODE_SIMPLE
+    // Tell hardware to send this packet
+    if (sg_len)
+        (sc->funs->send)(sc, sg_list, sg_len, p->tot_len, (CYG_ADDRWORD) &done);
+    // Wait until packet has been sent
+    wait_cycles = 100;
+    while (!done) {
+        (sc->funs->poll)(sc);
+        if (--wait_cycles <= 0) {
+            START_CONSOLE();
+            diag_printf("packet failed to send\n");
+            END_CONSOLE();
+            break;
+        }
+    }
+#endif // CYGFUN_LWIP_MODE_SIMPLE
+
+#ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
+    // Tell hardware to send this packet
+    if (sg_len)
+        (sc->funs->send)(sc, sg_list, sg_len, p->tot_len, 0);
+#endif // CYGFUN_LWIP_MODE_SEQUENTIAL
+
+#ifdef _LOCK_WITH_ROM_MONITOR
+    // Unlock the driver & hardware.  It can once again be safely shared.
+    if (need_lock) {
+        cyg_drv_dsr_unlock();
+#ifdef _LOCK_USING_INTERRUPTS
+        HAL_RESTORE_INTERRUPTS(ints);
+#endif
+    }
+#endif // _LOCK_WITH_ROM_MONITOR
+#undef _LOCK_WITH_ROM_MONITOR
+}
+
 //
 // This function is called from a hardware driver to indicate that an input
 // packet has arrived.  The routine will set up appropriate network resources
@@ -219,112 +396,51 @@ static void ecosif_input(struct netif *n
 static void
 eth_drv_recv(struct eth_drv_sc *sc, int total_len)
 {
-  struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
-  struct netif *netif = &sc->sc_arpcom.ac_if;
-
-  struct pbuf *p, *q;
-
-  int sg_len = 0;
-  CYGARC_HAL_SAVE_GP();
+    struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
+    struct netif *netif = &sc->sc_arpcom.ac_if;
+    struct pbuf *p, *q;
+    int sg_len = 0;
+    
+    CYG_ASSERT(total_len != 0, "total_len is zero!");
+    CYG_ASSERT(total_len >= 0, "total_len is negative!");
+    
+    CYGARC_HAL_SAVE_GP();
 
-  if ((total_len > MAX_ETH_MSG) || (total_len < 0)) {
-    total_len = MAX_ETH_MSG;
-  }
-
-  p = pbuf_alloc(PBUF_RAW, total_len, PBUF_POOL);
-
-  if (p == NULL) {
-    LWIP_DEBUGF(0, ("ecosif_input: low_level_input returned NULL\n"));
-    return;
-  }
+    if ((total_len > MAX_ETH_MSG) || (total_len < 0))
+        total_len = MAX_ETH_MSG;
 
-  for (q = p; q != NULL; q = q->next) {
-    sg_list[sg_len].buf = (CYG_ADDRESS) q->payload;
-    sg_list[sg_len++].len = q->len;
-  }
-  (sc->funs->recv) (sc, sg_list, sg_len);
-  ecosif_input(netif, p);
-  CYGARC_HAL_RESTORE_GP();
-}
-
-
-#define IFNAME0 'e'
-#define IFNAME1 't'
-
-
+    // Allocate buffer to store received packet
+    p = pbuf_alloc(PBUF_RAW, total_len, PBUF_POOL);
+    if (p == NULL) {
+        START_CONSOLE();
+        diag_printf("cannot allocate pbuf to receive packet\n");
+        END_CONSOLE();
+        return;
+    }
 
-//
-// low_level_output():
-//
-// Should do the actual transmission of the packet. The packet is
-// contained in the pbuf that is passed to the function. This pbuf
-// might be chained.We pass the data down to the eCos hw independent 
-// ethernet driver
-//
+    // Create scatter list
+    for (q = p; q != NULL && sg_len < MAX_ETH_DRV_SG; q = q->next) {
+        sg_list[sg_len].buf = (CYG_ADDRESS) q->payload;
+        sg_list[sg_len++].len = q->len;
+    }
+    
+    // Get buffers from hardware
+    (sc->funs->recv)(sc, sg_list, sg_len);
+    
+    // Pass received packet to the interface
+    netif->input(p, netif);
 
-static err_t
-low_level_output(struct netif *netif, struct pbuf *p)
-{
-  eth_drv_send(netif, p);
-  return ERR_OK;
+    CYGARC_HAL_RESTORE_GP();
 }
 
 //
-// ecosif_output():
+// DSR called from the low level driver.
 //
-// This function is called by the TCP/IP stack when an IP packet
-// should be sent. It calls the function called low_level_output() to
-// do the actual transmission of the packet.
-//
-//
-static err_t
-ecosif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
+void
+eth_drv_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
 {
-  // resolve hardware address, then send (or queue) packet
-  return etharp_output(netif, ipaddr, p);
-}
-
-
-
-//
-// ecosif_input():
-// This function is called when the eCos hw independent driver
-// has some data to pass up to lwIP.It does it through ecosif_input.
-//
-static void
-ecosif_input(struct netif *netif, struct pbuf *p)
-{
-  struct eth_hdr *ethhdr;
-  
-  ethhdr = p->payload;
+    struct eth_drv_sc *sc = (struct eth_drv_sc *) data;
 
-  switch (htons(ethhdr->type)) {
-  case ETHTYPE_IP:
-    LWIP_DEBUGF(0, ("ecosif_input: IP packet\n"));
-    etharp_ip_input(netif, p);
-    pbuf_header(p, -14);
-    netif->input(p, netif);
-    break;
-  case ETHTYPE_ARP:
-    LWIP_DEBUGF(0, ("ecosif_input: ARP packet\n"));
-    etharp_arp_input(netif, (struct eth_addr *) &netif->hwaddr, p);
-    break;
-  default:
-    pbuf_free(p);
-    break;
-  }
-
+    sc->state |= ETH_DRV_NEEDS_DELIVERY;
+    lwip_eth_drv_dsr();
 }
-
-err_t
-ecosif_init(struct netif *netif)
-{
-  netif->name[0] = IFNAME0;
-  netif->name[1] = IFNAME1;
-  netif->hwaddr_len = 6;
-  netif->output = ecosif_output;
-  netif->linkoutput = low_level_output;
-  netif->mtu = 1500;
-  lwip_set_addr(netif);
-  return ERR_OK;
-}
--- a/packages/net/lwip_tcpip/current/ChangeLog
+++ b/packages/net/lwip_tcpip/current/ChangeLog
@@ -1,7 +1,6 @@
-2009-03-12  Sergei Gavrikov <sergei.gavrikov@gmail.com>
+2010-01-25  Simon Kallweit  <simon.kallweit@intefo.ch>
 
-	* src/netif/slipif.c (slipif_init): in SLIP mode it quite erases
-	NETIF_FLAG_UP bit. Fixed.
+	* all: Updated to lwIP 1.3.2
 
 2007-03-22  John Eigelaar  <jeigelaar@mweb.co.za>
                                                      
@@ -210,25 +209,34 @@ 2004-05-04  Jani Monoses <jani@iv.ro>
 	* include/lwipopts.h : Initial import of the lwIP TCP/IP stack.
 
 //===========================================================================
-// ####GPLCOPYRIGHTBEGIN####                                                
-// -------------------------------------------                              
-// This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 2004 Free Software Foundation, Inc.                        
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2004 eCosCentric  
 //
-// This program is free software; you can redistribute it and/or modify     
-// it under the terms of the GNU General Public License as published by     
-// the Free Software Foundation; either version 2 or (at your option) any   
-// later version.                                                           
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
 //
-// This program is distributed in the hope that it will be useful, but      
-// WITHOUT ANY WARRANTY; without even the implied warranty of               
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
-// General Public License for more details.                                 
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 //
-// You should have received a copy of the GNU General Public License        
-// along with this program; if not, write to the                            
-// Free Software Foundation, Inc., 51 Franklin Street,                      
-// Fifth Floor, Boston, MA  02110-1301, USA.                                
-// -------------------------------------------                              
-// ####GPLCOPYRIGHTEND####                                                  
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
 //===========================================================================
--- a/packages/net/lwip_tcpip/current/cdl/lwip_net.cdl
+++ b/packages/net/lwip_tcpip/current/cdl/lwip_net.cdl
@@ -1,703 +1,1930 @@
-#====================================================================
+# ====================================================================
 #
 #      lwip_net.cdl
 #
-#      lwIP network stack configuration data
+#      lwIP networking stack configuration data.
 #
 # ====================================================================
-## ####ECOSGPLCOPYRIGHTBEGIN####                                            
-## -------------------------------------------                              
-## This file is part of eCos, the Embedded Configurable Operating System.   
-## Copyright (C) 2004 Free Software Foundation, Inc.                        
+#####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 2008, 2009, 2010 Free Software Foundation
 ##
-## eCos is free software; you can redistribute it and/or modify it under    
-## the terms of the GNU General Public License as published by the Free     
-## Software Foundation; either version 2 or (at your option) any later      
-## version.                                                                 
+## eCos is free software; you can redistribute it and/or modify it under
+## the terms of the GNU General Public License as published by the Free
+## Software Foundation; either version 2 or (at your option) any later version.
 ##
-## eCos is distributed in the hope that it will be useful, but WITHOUT      
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
-## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
-## for more details.                                                        
+## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+## WARRANTY; without even the implied warranty of MERCHANTABILITY or
+## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+## for more details.
 ##
-## You should have received a copy of the GNU General Public License        
-## along with eCos; if not, write to the Free Software Foundation, Inc.,    
-## 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
+## You should have received a copy of the GNU General Public License along
+## with eCos; if not, write to the Free Software Foundation, Inc.,
+## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 ##
-## As a special exception, if other files instantiate templates or use      
-## macros or inline functions from this file, or you compile this file      
-## and link it with other works to produce a work based on this file,       
-## this file does not by itself cause the resulting work to be covered by   
-## the GNU General Public License. However the source code for this file    
-## must still be made available in accordance with section (3) of the GNU   
-## General Public License v2.                                               
+## As a special exception, if other files instantiate templates or use macros
+## or inline functions from this file, or you compile this file and link it
+## with other works to produce a work based on this file, this file does not
+## by itself cause the resulting work to be covered by the GNU General Public
+## License. However the source code for this file must still be made available
+## in accordance with section (3) of the GNU General Public License.
 ##
-## This exception does not invalidate any other reasons why a work based    
-## on this file might be covered by the GNU General Public License.         
-## -------------------------------------------                              
-## ####ECOSGPLCOPYRIGHTEND####                                              
+## This exception does not invalidate any other reasons why a work based on
+## this file might be covered by the GNU General Public License.
+## -------------------------------------------
+#####ECOSGPLCOPYRIGHTEND####
 # ====================================================================
 ######DESCRIPTIONBEGIN####
 #
-# Author(s):	 cris@iv.ro, jani@iv.ro
-# Original data: jani@iv.ro 
-# Contributors:   
-# Date:           2002-06-21
+# Author(s):	 Simon Kallweit
+# Contributors:  John Dallaway
+# Date:          2008-12-01
 #
 #####DESCRIPTIONEND####
 #
 # ====================================================================
 
 cdl_package CYGPKG_NET_LWIP {
-	display "lwIP"
-	description	"Lightweight TCP/IP stack"	
-	requires {(CYGPKG_LWIP_ETH ==  1) || (CYGPKG_LWIP_SLIP == 1) || (CYGPKG_LWIP_PPP == 1)}
-
-        cdl_interface CYGPKG_NET_STACK {
-            display   "Suitable network stack implementation"
-            description "
-               Normally the interface if declared in the net common
-               package. However LWIP does not use that package
-               so we declare this interface here. Some of the device
-               drivers use it to decide if they should be build."
+    display         "lwIP networking stack"
+    description     "The lightweight TCP/IP stack."
+    requires        CYGINT_ISO_ERRNO_CODES
+	
+    compile         core/dns.c                  \
+                    core/init.c                 \
+                    core/mem.c                  \
+                    core/memp.c	                \
+                    core/netif.c                \
+                    core/pbuf.c                 \
+                    core/raw.c                  \
+                    core/stats.c                \
+                    core/sys.c                  \
+                    core/tcp_in.c               \
+                    core/tcp_out.c              \
+                    core/tcp.c                  \
+                    core/udp.c                  \
+                    core/ipv4/icmp.c            \
+                    core/ipv4/igmp.c            \
+                    core/ipv4/inet_chksum.c     \
+                    core/ipv4/inet.c            \
+                    core/ipv4/ip_addr.c         \
+                    core/ipv4/ip_frag.c         \
+                    core/ipv4/ip.c              \
+                    api/api_lib.c               \
+                    api/api_msg.c               \
+                    api/err.c                   \
+                    api/netbuf.c                \
+                    api/netdb.c                 \
+                    api/netifapi.c              \
+                    api/sockets.c               \
+                    api/tcpip.c                 \
+                    ecos/sys_arch.c
+                    
+    cdl_interface CYGINT_LWIP_MODES {
+        display         "Enabled lwIP modes"
+        no_define
+        requires        CYGINT_LWIP_MODES == 1
+        description     "
+            This interface is used to force mutually exclusive selection of
+            the available lwIP modes."
+    }
+    
+    cdl_option CYGFUN_LWIP_MODE_SIMPLE {
+        display         "Simple mode"
+        default_value   1
+        implements      CYGINT_LWIP_MODES
+        compile         ecos/simple.c
+        description     "
+            lwIP stack is configured to run in a single thread. Use this mode
+            if lwIP should run with a minimum of resources. Note that you can
+            only use the event based APIs in this mode."  
+    }
+    
+    cdl_option CYGFUN_LWIP_MODE_SEQUENTIAL {
+        display         "Sequential mode"
+        implements      CYGINT_LWIP_MODES
+        compile         ecos/sequential.c
+        description     "
+            lwIP stack is configured to run in multiple threads. Use this mode
+            if you can spend some more resources on lwIP and you want to use
+            the networking stack from within other threads using the more
+            convenient netcomm and socket APIs." 
+    }
+    
+    cdl_interface CYGINT_LWIP_SIO_REQUIRED {
+        no_define
+        display         "Items requiring lwIP serial operations"
+        description     "
+            Items requiring use of the lwIP serial operations code should
+            implement this interface."
+    }
+    
+    cdl_option CYGFUN_LWIP_SIO {
+        display         "Serial operations support"
+        calculated      { CYGINT_LWIP_SIO_REQUIRED > 0 }
+        requires        CYGPKG_IO_SERIAL
+        compile         ecos/sio.c
+    }
+    
+    cdl_component CYGPKG_LWIP_APIS {
+        display         "APIs"
+        flavor          none
+        no_define
+        description     "
+            Configuration for Application-Programming-Interfaces."
+            
+        cdl_component CYGPKG_LWIP_RAW {
+            display         "RAW support"
+            flavor          bool
+            default_value   1
+            description     "
+                Enable application layer to hook into the IP layer itself."
+            
+            cdl_option CYGNUM_LWIP_RAW_TTL {
+                display         "RAW Time-To-Live"
+                flavor          data
+                default_value   { CYGNUM_LWIP_IP_DEFAULT_TTL }
+                description     "
+                    Default value for Time-To-Live used by RAW packets."
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_NETIF_API {
+            display         "Netif support"
+            flavor          bool
+            default_value   0
+            description     "
+                Support for the netif API."
         }
-        cdl_interface CYGPKG_NET_STACK_INET {
-            display   "Network stack support for IPv4"
+        
+        cdl_component CYGPKG_LWIP_NETCONN_API {
+            display         "Netconn support"
+            flavor          bool
+            default_value   1
+            active_if       CYGFUN_LWIP_MODE_SEQUENTIAL
+            requires        CYGFUN_LWIP_MODE_SEQUENTIAL
+            description     "
+                Support for the netconn API. Requires the \"Sequential\" mode."
+        }
+        
+        cdl_component CYGPKG_LWIP_SOCKET_API {
+            display         "Socket support"
+            flavor          bool
+            default_value   1
+            active_if       CYGFUN_LWIP_MODE_SEQUENTIAL
+            requires        CYGFUN_LWIP_MODE_SEQUENTIAL
+            requires        CYGPKG_LWIP_NETCONN_API
+            description     "
+                Support for the socket API. Requires the \"Sequential\" mode."
+                
+            cdl_option CYGFUN_LWIP_COMPAT_SOCKETS {
+                display         "BSD-style sockets"
+                flavor          bool
+                default_value   1
+                description     "
+                    Enable BSD-style sockets functions names."
+            }
+            
+            cdl_option CYGFUN_LWIP_POSIX_SOCKETS_IO_NAMES {
+                display         "POSIX-style sockets"
+                flavor          bool
+                default_value   1
+                description     "
+                    Enable POSIX-style sockets functions names. Disable this
+                    option if you use a POSIX operating system that uses the
+                    same names (read, write & close)."
+            }
+        
+            cdl_option CYGFUN_LWIP_TCP_KEEPALIVE {
+                display         "Keepalive options"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT options
+                    processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have
+                    to be set in seconds."
+            }
+            
+            cdl_option CYGFUN_LWIP_SO_RCVTIMEO {
+                display         "SO_RCVTIMEO option"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable SO_RCVTIMEO processing."
+            }
+            
+            cdl_option CYGFUN_LWIP_SO_RCVBUF {
+                display         "SO_RCVBUF option"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable SO_RCVBUF processing."
+            }
+        }
+    }
+    
+    cdl_component CYGPKG_LWIP_PROTOCOLS {
+        display         "Protocols"
+        flavor          none
+        no_define
+        description     "
+            Configuration options for protocols."
+            
+        cdl_component CYGPKG_LWIP_ARP {
+            display         "ARP support"
+            flavor          bool
+            default_value   1
+            compile         netif/etharp.c
+            description     "
+                Support for ARP functionality."
+                
+            cdl_option CYGNUM_LWIP_ARP_TABLE_SIZE {
+                display         "ARP table size"
+                flavor          data
+                default_value   10
+                description     "
+                    Number of active MAC-IP address pairs cached."
+            }
+            
+            cdl_option CYGFUN_LWIP_ARP_QUEUEING {
+                display         "ARP queueing"
+                flavor          bool
+                default_value   1
+                description     "
+                    Outgoing packets are queued during hardware address
+                    resolution."
+            }
+            
+            cdl_option CYGFUN_LWIP_ETHARP_TRUST_IP_MAC {
+                display         "Trust IP/MAC"
+                flavor          bool
+                default_value   1
+                description     "
+                    Incoming IP packets cause the ARP table to be updated with
+                    the source MAC and IP addresses supplied in the packet. You
+                    may want to disable this if you do not trust LAN peers to
+                    have the correct addresses, or as a limited approach to
+                    attempt to handle spoofing. If disabled, lwIP will need to
+                    make a new ARP request if the peer is not already in the
+                    ARP table, adding a little latency."
+            }
         }
 
-        cdl_interface CYGPKG_NET_STACK_INET6 {
-            display   "Network stack support for IPv6"
+        cdl_component CYGPKG_LWIP_IP {
+            display         "IP options"
+            flavor          none
+            no_define
+            description     "
+                Configuration options for IP protocol."
+        
+            cdl_option CYGFUN_LWIP_IP_FORWARD {
+                display         "Support IP forwarding"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enables the ability to forward IP packets across network
+                    interfaces. If you are going to run lwIP on a device with
+                    only one network interface, define this to 0."
+            }
+            
+            cdl_option CYGFUN_LWIP_IP_OPTIONS_ALLOWED {
+                display         "Allow IP options"
+                flavor          bool
+                default_value   1
+                description     "
+                    Defines the behavior for IP options:
+                    0 = All packets with IP options are dropped.
+                    1 = IP options are allowed (but not parsed)."
+            }
+    
+            cdl_option CYGFUN_LWIP_IP_REASSEMBLY {
+                display         "Support IP reassembly"
+                flavor          bool
+                default_value   1
+                description     "
+                    Reassemble incoming fragmented IP packets. Note that this
+                    option does not affect outgoing packet sizes, which can be
+                    controlled via CYGFUN_LWIP_IP_FRAG."
+            }
+            
+            cdl_option CYGFUN_LWIP_IP_FRAG {
+                display         "Support IP fragmentation"
+                flavor          bool
+                default_value   1
+                description     "
+                    Fragment outgoing IP packets if their size exceeds MTU.
+                    Note that this option does not affect incoming packet
+                    sizes, which can be controlled via
+                    CYGFUN_LWIP_IP_REASSEMBLY."
+            }
+            
+            cdl_option CYGNUM_LWIP_IP_REASS_MAXAGE {
+                display         "Max reassembly time"
+                flavor          data
+                default_value   3
+                description     "
+                    Maximum time (in multiples of IP_TMR_INTERVAL - so seconds,
+                    normally) a fragmented IP packet waits for all fragments to
+                    arrive. If not all fragments arrived in this time, the
+                    whole packet is discarded."
+            }
+            
+            cdl_option CYGNUM_LWIP_IP_REASS_MAX_PBUFS {
+                display         "Max reassembly time"
+                flavor          data
+                default_value   10
+                requires        { CYGNUM_LWIP_PBUF_BOOL_SIZE <
+                                  CYGNUM_LWIP_IP_REASS_MAX_PBUFS }
+                description     "
+                    Total maximum amount of pbufs waiting to be reassembled.
+                    Since the received pbufs are enqueued, be sure to configure
+                    CYGNUM_LWIP_PBUF_BOOL_SIZE > CYGNUM_LWIP_IP_REASS_MAX_PBUFS
+                    so that the stack is still able to receive packets even if
+                    the maximum amount of fragments is enqueued for reassembly!"
+            }
+            
+            cdl_option CYGFUN_LWIP_IP_FRAG_USES_STATIC_BUF {
+                display         "Use static buffer for IP fragmentation"
+                flavor          bool
+                default_value   1
+                description     "
+                    Use a static MTU-sized buffer for IP fragmentation.
+                    Otherwise pbufs are allocated and reference the original
+                    packet data to be fragmented."
+            }
+            
+            cdl_option CYGNUM_LWIP_IP_FRAG_MAX_MTU {
+                display         "Max MTU size"
+                flavor          data
+                default_value   1500
+                active_if       { CYGFUN_LWIP_IP_FRAG_USES_STATIC_BUF }
+                description     "
+                    Assumed max MTU on any interface for IP frag buffer."
+            }
+            
+            cdl_option CYGNUM_LWIP_IP_DEFAULT_TTL {
+                display         "Default Time-To-Live"
+                flavor          data
+                default_value   255
+                description     "
+                    Default value for Time-To-Live used by transport layers."
+            }
+            
+            cdl_component CYGFUN_LWIP_IP_SOF_BROADCAST {
+                display         "Support broadcast filter"
+                flavor          bool
+                default_value   0
+                description     "
+                    Use the SOF_BROADCAST field to enable broadcast filter
+                    per pcb on udp and raw send operations. To enable
+                    broadcast filter on recv operations, you also have to set
+                    IP_SOF_BROADCAST_RECV=1."
+                    
+                cdl_option CYGFUN_LWIP_IP_SOF_BROADCAST_RECV {
+                    display         "Receive support"
+                    flavor          bool
+                    default_value   0
+                    active_if       CYGFUN_LWIP_IP_SOF_BROADCAST
+                    description     "
+                        Enable the broadcast filter on recv operations."
+                }
+            }
+        }
+    
+        cdl_component CYGPKG_LWIP_ICMP {
+            display         "ICMP support"
+            flavor          bool
+            default_value   1
+            description     "
+                Support for ICMP functionality. Be careful, disabling this
+                makes your product non-compliant to RFC1122."
+    
+            cdl_option CYGNUM_LWIP_ICMP_TTL {
+                display         "ICMP Time-To-Live"
+                flavor          data
+                default_value   { CYGNUM_LWIP_IP_DEFAULT_TTL }
+                description     "
+                    Default value for Time-To-Live used by ICMP packets."
+            }
+            
+            cdl_option CYGFUN_LWIP_BROADCAST_PING {
+                display         "Respond broadcast pings"
+                flavor          bool
+                default_value   0
+                description     "
+                    Respond to broadcast pings (default is unicast only)."
+            }
+    
+            cdl_option CYGFUN_LWIP_MULTICAST_PING {
+                display         "Respond multicast pings"
+                flavor          bool
+                default_value   0
+                description     "
+                    Respond to multicast pings (default is unicast only)."
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_IGMP {
+            display         "IGMP support"
+            flavor          bool
+            default_value   1
+            description     "
+                Support for IGMP functionality."
+        }
+            
+        cdl_component CYGPKG_LWIP_UDP {
+            display         "UDP support"
+            flavor          bool
+            default_value   1
+            requires        CYGPKG_LWIP_IP
+            description     "
+                Support for UDP functionality."
+                
+            cdl_option CYGFUN_LWIP_UDPLITE {
+                display         "UDP lite"
+                flavor          bool
+                default_value   1
+                description     "
+                    Enable UDP lite."
+            }
+            
+            cdl_option CYGNUM_LWIP_UDP_TTL {
+                display         "UDP Time-To-Live"
+                flavor          data
+                default_value   { CYGNUM_LWIP_IP_DEFAULT_TTL }
+                description     "
+                    Default value for Time-To-Live used by UDP packets."
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_TCP {
+            display         "TCP support"
+            flavor          bool
+            default_value   1
+            requires        CYGPKG_LWIP_IP
+            description     "
+                Support for TCP functionality."
+                
+            cdl_option CYGNUM_LWIP_TCP_TTL {
+                display         "TCP Time-To-Live"
+                flavor          data
+                default_value   { CYGNUM_LWIP_IP_DEFAULT_TTL }
+                description     "
+                    Default value for Time-To-Live used by TCP packets."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_WND {
+                display         "Receive window"
+                flavor          data
+                default_value   { CYGNUM_LWIP_TCP_MSS * 4 }
+                requires        { CYGNUM_LWIP_TCP_WND >=
+                                  CYGNUM_LWIP_TCP_MSS * 2 }
+                description     "
+                    The size of a TCP window. This must be at least
+                    (2 * TCP_MSS) for things to work well."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_MAXRTX {
+                display         "Segment retransmissions"
+                flavor          data
+                default_value   12
+                description     "
+                     Maximum number of retransmissions of data segments."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_SYNMAXRTX {
+                display         "Syn retransmissions"
+                flavor          data
+                default_value   6
+                description     "
+                    Maximum number of retransmissions of SYN segments."
+            }
+            
+            cdl_option CYGFUN_LWIP_TCP_QUEUE_OOSEQ {
+                display         "Queue segments"
+                flavor          bool
+                default_value   1
+                description     "
+                    TCP will queue segments that arrive out of order. Define
+                    to 0 if your device is low on memory."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_MSS {
+                display         "Maximum segment size"
+                flavor          data
+                default_value   536
+                description     "
+                    TCP Maximum segment size. (default is 128, a *very*
+                    conservative default.) For the receive side, this MSS is
+                    advertised to the remote side when opening a connection.
+                    For the transmit size, this MSS sets an upper limit on the
+                    MSS advertised by the remote host."
+            }
+            
+            cdl_option CYGFUN_LWIP_TCP_CALCULATE_EFF_SEND_MSS {
+                display         "Calculate effective MSS"
+                flavor          bool
+                default_value   1
+                description     "
+                    \"The maximum size of a segment that TCP really sends, the
+                    'effective send MSS,' MUST be the smaller of the send MSS
+                    (which reflects the available reassembly buffer size at the
+                    remote host) and the largest size permitted by the IP
+                    layer\" (RFC 1122) Setting this to 1 enables code that
+                    checks TCP_MSS against the MTU of the netif used for a
+                    connection and limits the MSS if it would be too big
+                    otherwise."            
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_SND_BUF {
+                display         "Sender buffer space"
+                flavor          data
+                default_value   CYGNUM_LWIP_TCP_SND_QUEUELEN * CYGNUM_LWIP_TCP_MSS / 4
+                requires        { CYGNUM_LWIP_TCP_SND_BUF * 2 <
+                                  CYGNUM_LWIP_TCP_SND_QUEUELEN * CYGNUM_LWIP_TCP_MSS }
+                description     "
+                    TCP sender buffer space (bytes)."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_SND_QUEUELEN {
+                display         "Sender pbufs"
+                flavor          data
+                default_value   8
+                description     "
+                    TCP sender buffer space (pbufs). This must be at least as
+                    much as (2 * TCP_SND_BUF/TCP_MSS) for things to work."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_SNDLOWAT {
+                display         "TCP writeable space"
+                flavor          data
+                default_value   { CYGNUM_LWIP_TCP_SND_BUF / 2 }
+                description     "
+                    TCP writable space (bytes). This must be less than or equal
+                    to TCP_SND_BUF. It is the amount of space which must be
+                    available in the TCP snd_buf for select to return writable."
+            }
+            
+            cdl_option CYGFUN_LWIP_TCP_LISTEN_BACKLOG {
+                display         "Listen backlog"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable the backlog option for tcp listen pcb."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_DEFAULT_LISTEN_BACKLOG {
+                display         "Maximum listen backlog"
+                flavor          data
+                active_if       { CYGFUN_LWIP_TCP_LISTEN_BACKLOG }
+                default_value   255
+                legal_values    { 1 to 255 }
+                description     "
+                    The maximum allowed backlog for TCP listen netconns."
+            }
+            
+            cdl_option CYGFUN_LWIP_TCP_TIMESTAMPS {
+                display         "TCP timestamp"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support the TCP timestamp option."
+            }
+            
+            cdl_option CYGNUM_LWIP_TCP_WND_UPDATE_THRESHOLD {
+                display         "Update threshold"
+                flavor          bool
+                default_value   { CYGNUM_LWIP_TCP_WND / 4 }
+                description     "
+                    Difference in window to trigger an explicit window update."
+            }
+            
+            cdl_option CYGFUN_LWIP_EVENT_API {
+                display         "Event API"
+                flavor          bool
+                default_value   0
+                requires        { !CYGFUN_LWIP_CALLBACK_API }
+                description     "
+                    The user defines lwip_tcp_event() to receive all events
+                    (accept, sent, etc) that happen in the system."
+            }
+    
+            cdl_option CYGFUN_LWIP_CALLBACK_API {
+                display         "Callback API"
+                flavor          bool
+                default_value   1
+                requires        { !CYGFUN_LWIP_EVENT_API }
+                description     "
+                    The PCB callback function is called directly for the event."
+            }
+        }   
+            
+        cdl_component CYGPKG_LWIP_DHCP {
+            display         "DHCP support"
+            flavor          bool
+            default_value   1
+            requires        CYGPKG_LWIP_UDP
+            compile         core/dhcp.c
+            description "
+                Support for DHCP functionality."
+                
+            cdl_option CYGFUN_LWIP_DHCP_DOES_ARP_CHECK {
+                display         "Check offered address"
+                flavor          bool
+                default_value   1
+                requires        CYGPKG_LWIP_ARP
+                description     "
+                    Do an ARP check on the offered address."
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_AUTOIP {
+            display         "AUTOIP support"
+            flavor          bool
+            default_value   0
+            requires        CYGPKG_LWIP_UDP
+            requires        CYGPKG_LWIP_ARP
+            compile         core/ipv4/autoip.c
+            description "
+                Support for AUTOIP functionality."
+                
+            cdl_option CYGFUN_LWIP_DHCP_AUTOIP_COOP {
+                display         "Simultaneous AUTOIP/DHCP"
+                flavor          bool
+                default_value   1
+                requires        CYGPKG_LWIP_DHCP
+                description     "
+                    Allow DHCP and AUTOIP to be both enabled on the same
+                    interface at the same time."
+            }
+            
+            cdl_option CYGNUM_LWIP_DHCP_AUTOIP_COOP_TRIES {
+                display         "DHCP retries before AUTOIP"
+                flavor          data
+                default_value   9
+                legal_values    { 1 to 10000 }
+                requires        CYGFUN_LWIP_DHCP_AUTOIP_COOP
+                description     "
+                    Set to the number of DHCP DISCOVER probes that should be
+                    sent before falling back on AUTOIP. This can be set as low
+                    as 1 to get an AutoIP address very quickly, but you should
+                    be prepared to handle a changing IP address when DHCP
+                    overrides AutoIP."
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_SNMP {
+            display         "SNMP support"
+            flavor          bool
+            default_value   0
+            requires        CYGPKG_LWIP_UDP
+            compile         core/snmp/asn1_dec.c            \
+                            core/snmp/asn1_enc.c            \
+                            core/snmp/mib_structs.c         \
+                            core/snmp/mib2.c                \
+                            core/snmp/msg_in.c              \
+                            core/snmp/msg_out.c
+            description "
+                Support for SNMP functionality."
+    
+            cdl_option CYGNUM_LWIP_SNMP_CONCURRENT_REQUESTS {
+                display         "Concurrent requests"
+                flavor          data
+                default_value   1
+                description     "
+                    Number of concurrent requests the module will allow. At
+                    least one request buffer is required." 
+            }
+                
+            cdl_option CYGNUM_LWIP_SNMP_TRAP_DESTINATIONS {
+                display         "Trap destinations"
+                flavor          data
+                default_value   1
+                description     "
+                    Number of trap destinations. At least one trap destination
+                    is required."
+            }
+            
+            cdl_option CYGFUN_LWIP_SNMP_PRIVATE_MIB {
+                display         "Private MIB"
+                flavor          bool
+                default_value   0
+                description     ""
+            }
+                
+            cdl_option CYGFUN_LWIP_SNMP_SAFE_REQUESTS {
+                display         "Safe requests"
+                flavor          bool
+                default_value   1
+                description     "
+                    Only allow SNMP write actions that are 'safe' (e.g.
+                    disabling netifs is not a safe action and disabled when
+                    SNMP_SAFE_REQUESTS = 1). Unsafe requests are disabled by
+                    default!"
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_DNS {
+            display         "DNS support"
+            flavor          bool
+            default_value   0
+            requires        CYGPKG_LWIP_UDP
+            description     "
+                Support for DNS functionality."
+    
+            cdl_option CYGNUM_LWIP_DNS_TABLE_SIZE {
+                display         "Table size"
+                flavor          data
+                default_value   4
+                description     "
+                    DNS maximum number of entries to maintain locally."
+            }
+                
+            cdl_option CYGNUM_LWIP_DNS_MAX_NAME_LENGTH {
+                display         "Host name size"
+                flavor          data
+                default_value   256
+                description     "
+                    DNS maximum host name length supported in the name table."
+            }
+            
+            cdl_option CYGNUM_LWIP_DNS_MAX_SERVERS {
+                display         "DNS servers"
+                flavor          data
+                default_value   2
+                description     "
+                    The maximum of DNS servers."
+            }
+            
+            cdl_option CYGFUN_LWIP_DNS_DOES_NAME_CHECK {
+                display         "Name checking"
+                flavor          bool
+                default_value   1
+                description     "
+                    DNS do a name checking between the query and the response."
+            }
+                
+            cdl_option CYGNUM_LWIP_DNS_USES_STATIC_BUF {
+                display         "Static buffer"
+                flavor          data
+                default_value   1
+                legal_values    { 0 to 2 }
+                description     "
+                    DNS use a local buffer if DNS_USES_STATIC_BUF=0, a static
+                    one if DNS_USES_STATIC_BUF=1, or a dynamic one if
+                    DNS_USES_STATIC_BUF=2. The buffer will be of size
+                    DNS_MSG_SIZE."
+            }
+            
+            cdl_option CYGNUM_LWIP_DNS_MSG_SIZE {
+                display         "Message size"
+                flavor          data
+                default_value   512
+                description     "
+                    DNS message max. size. Default value is RFC compliant."
+            }
+            
+            cdl_component CYGPKG_LWIP_DNS_LOCAL_HOSTLIST {
+                display         "Local host list"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support for a local host-to-address list."
+                    
+                cdl_option CYGDAT_LWIP_DNS_LOCAL_HOSTLIST_INIT {
+                    display         "Host list"
+                    flavor          data
+                    default_value   { "{{\"host1\", 0x123},\
+                                        {\"host2\", 0x234}}" }
+                    description     "
+                        An array of structs name/address, where address is an
+                        u32_t in network byte order."
+                }
+                
+                cdl_option CYGFUN_LWIP_DNS_LOCAL_HOSTLIST_IS_DYNAMIC {
+                    display         "Dynamic host list"
+                    flavor          bool
+                    default_value   1
+                    description     "
+                        If this is turned on, the local host-list can be
+                        dynamically changed at runtime."
+                }
+            }
+        }
+    }
+    
+    cdl_component CYGPKG_LWIP_INTERFACES {
+        display         "Interfaces"
+        flavor          none
+        no_define
+        description     "
+            Configuration options for support of different network interface
+            devices."
+            
+        cdl_interface CYGPKG_LWIP_NETIF_DEFAULT {
+            display         "Items claiming default network interface status"
+            flavor          data
+            no_define
+            requires        { CYGPKG_LWIP_NETIF_DEFAULT <= 1 }
+            description     "
+                Items which claim that a specific networking interface should
+                be the default interface should implement this CDL interface.
+                Only one networking interface can claim default networking
+                interface status."
+        }
+            
+        cdl_component CYGPKG_LWIP_NETIF {
+            display         "Netif options"
+            flavor          none
+            no_define
+            description     "
+                Configuration options for netif."
+                
+            cdl_option CYGIMP_LWIP_NETIF_HOSTNAME {
+                display         "Hostname support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Adds a 'hostname' field to the netif structure and enables
+                    support for retrieving the hostname via DHCP."
+            }
+            
+            cdl_option CYGFUN_LWIP_NETIF_STATUS_CALLBACK {
+                display         "Status callback"
+                flavor          bool
+                default_value   1
+                description     "
+                    Support a callback function whenever an interface changes
+                    its up/down status (i.e., due to DHCP IP acquistion)."
+            }
+            
+            cdl_option CYGFUN_LWIP_NETIF_LINK_CALLBACK {
+                display         "Link callback"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support a callback function from an interface whenever the
+                    link changes (i.e., link down)."
+            }
+            
+            cdl_option CYGIMP_LWIP_NETIF_HWADDRHINT {
+                display         "Cache link-layer-address hints"
+                flavor          bool
+                default_value   0
+                description     "
+                    Cache link-layer-address hints (e.g. table indices) in
+                    struct netif. TCP and UDP can make use of this to prevent
+                    scanning the ARP table for every sent packet. While this is
+                    faster for big ARP tables or many concurrent connections,
+                    it might be counterproductive if you have a tiny ARP table
+                    or if there never are concurrent connections."
+            }
+            
+            cdl_component CYGIMP_LWIP_NETIF_LOOPBACK {
+                display         "Loopback support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support sending packets with a destination IP address equal
+                    to the netif IP address, looping them back up the stack."
+                    
+                cdl_option CYGNUM_LWIP_NETIF_LOOPBACK_MAX_PBUFS {
+                    display         "PBUF queue length"
+                    flavor          data
+                    default_value   0
+                    description     "
+                        Maximum number of pbufs on queue for loopback sending
+                        for each netif (0 = disabled)."
+                }
+            }
         }
 
-        implements    CYGPKG_NET_STACK
-        implements    CYGPKG_NET_STACK_INET
-
-	compile	core/mem.c	\
-		core/memp.c	\
-		core/netif.c	\
-		core/pbuf.c	\
-		core/stats.c	\
-		core/sys.c	\
-		core/tcp.c	\
-		core/tcp_in.c	\
-		core/tcp_out.c	\
-		core/inet.c	\
-		core/ipv4/icmp.c	\
-		core/ipv4/ip.c	\
-		core/ipv4/ip_addr.c	\
-		core/ipv4/ip_frag.c	\
-		api/api_lib.c	\
-		api/api_msg.c	\
-		api/tcpip.c	\
-		api/err.c	\
-		api/sockets.c	\
-		ecos/sys_arch.c	\
-		ecos/init.c	
-	
-	
-	cdl_option CYGDBG_LWIP_STATS {
-		display		"Maintain traffic statistics"
-		flavor 		bool
-		default_value	0
-		description	"
-			Check this box to turn ON statistics options for lwIP."
-	}
-		
-	cdl_component CYGDBG_LWIP_DEBUG {
-		display		"Support printing debug information"
-		flavor 		bool
-		default_value	0
-		description	"
-			Check this box to turn ON debug options for lwIP."
+        cdl_component CYGPKG_LWIP_ETH {
+            display         "Ethernet support"
+            flavor          bool
+            requires        CYGPKG_IO
+            requires        CYGPKG_IO_ETH_DRIVERS
+            requires        CYGPKG_LWIP_ARP
+            default_value   CYGPKG_IO_ETH_DRIVERS
+            description     "
+                Support for ethernet devices"
+                
+            # Support static configuration of up to 4 interfaces
+            for { set ::channel 0 } { $::channel < 4 } { incr ::channel } {
+            
+                cdl_component CYGPKG_LWIP_ETH[set ::channel]_CONF {
+                    display         "eth[set ::channel] configuration"
+                    flavor          bool
+                    default_value   $::channel == 0
+                    description     "
+                        Static configuration of the ethernet device
+                        eth[set ::channel]."
 
-		cdl_option CYGDBG_LWIP_DEBUG_TCP {
-			display	"Control TCP debug"
-			flavor 		bool
-			default_value	0
-			description	"
-				Generic TCP debug switch."
-			
-		}
-		
-	}
-
-	cdl_option CYGDBG_LWIP_ASSERTS {
-		display		"Enable assertions"
-		flavor 		bool
-		default_value	0
-		description	"
-			Check this box to turn ON assertions for lwIP."
-	}
+                    cdl_option CYGDAT_LWIP_ETH[set ::channel]_DEFAULT {
+                        display         "Default netif"
+                        flavor          bool
+                        default_value   $::channel == 0
+                        implements      CYGPKG_LWIP_NETIF_DEFAULT
+                        description     "
+                            Use this interface as the default network
+                            interface."
+                    }
 
-	cdl_component CYGPKG_LWIP_IPV4_CONF {
-		display		"IPV4 netconf"
-		flavor 		none
-		no_define
-		description   	"
-			See suboptions to define gateway IP, local IP and netmask."
-		
-		cdl_option CYGDAT_LWIP_SERV_ADDR {
-			display		"Gateway IP"
-			flavor		data
-			default_value 	{"192,168,1,1"}
-			description   	"
-				Gateway's IP address."
+                    cdl_option CYGDAT_LWIP_ETH[set ::channel]_DHCP {
+                        display         "Use DHCP"
+                        flavor          bool
+                        default_value   $::channel == 0
+                        requires        CYGPKG_LWIP_DHCP
+                        description     "
+                            Use DHCP to discover the IP address for this
+                            interface."
+                    }
 
-		}
-		
-		cdl_option CYGDAT_LWIP_MY_ADDR {
-			display		"My IP"
-			flavor		data
-			default_value 	{"192,168,1,222"}
-			description   	"
-				The IP address for this device."
+                    cdl_component CYGPKG_LWIP_ETH[set ::channel]_NETCONF {
+                        display         "Network configuration"
+                        flavor          none
+                        no_define
+                        active_if       CYGDAT_LWIP_ETH[set ::channel]_DHCP == 0
+                        description     "
+                            See suboptions to define IP address, netmask and
+                            gateway."
 
-		}
-		
-		cdl_option CYGDAT_LWIP_NETMASK {
-			display		"Netmask"
-			flavor		data
-			default_value 	{"255,255,255,0"}
-			description   	"
-				Netmask of the local network."
+                        cdl_option CYGDAT_LWIP_ETH[set ::channel]_NETCONF_ADDR {
+                            display         "Address"
+                            flavor          data
+                            default_value   { "192,168,1,222" }
+                            description     "
+                                The IP address of this device."
+                        }
 
-		}
-	}
-	
-	cdl_component CYGPKG_LWIP_MEM_OPTIONS {
-		display		"Memory options"
-		flavor 		none
-		no_define
-		description   	"
-			Tunables for various aspects of memory usage throughout the stack."
-				
-		cdl_option CYGNUM_LWIP_MEM_ALIGNMENT {
-			display		"Memory alignment"
-			flavor		data
-			default_value 	4
-			description   	"
-				 MEM_ALIGNMENT: should be set to the alignment of the CPU for which
-				 lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4,
-				 2 byte alignment -> define MEM_ALIGNMENT to 2."
-		}		 
-		cdl_option CYGNUM_LWIP_MEM_SIZE {
-			display		"Memory size"
-			flavor		data
-			default_value 	4000
-			description   	"
-				MEM_SIZE: the size of the heap memory. If the application will send
-				a lot of data that needs to be copied, this should be set high."		
-		}		 
-		
-		cdl_option CYGNUM_LWIP_MEMP_NUM_PBUF {
-			display		"Number of memp struct pbufs"
-			flavor		data
-			default_value 	8
-			description   	"
-				 MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
-				 sends a lot of data out of ROM (or other static memory), this
-				 should be set high."
-				 
-		}		 
-		cdl_option CYGNUM_LWIP_MEMP_NUM_UDP_PCB {
-			display		"Simultaneous UDP control blocks "
-			flavor		data
-			default_value 	4
-			description   	"
-				MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
-				per active UDP 'connection'."
-				
-		}		 
-		cdl_option CYGNUM_LWIP_MEMP_NUM_TCP_PCB {
-			display		"Simultaneous active TCP connections "
-			flavor		data
-			default_value 	5
-			description   	"
-				MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
-				connections."
-				
-		}		 
-		cdl_option CYGNUM_LWIP_MEMP_NUM_TCP_PCB_LISTEN {
-			display		"Listening TCP connections"
-			flavor		data
-			default_value 	8
-			description   	"
-				 MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
-				 connections."
-				 
-		}		 
-		cdl_option CYGNUM_LWIP_MEMP_NUM_TCP_SEG {
-			display		"Simultaneous TCP segments queued"
-			flavor		data
-			default_value 	8
-			description   	"
-				MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
-				segments."
-				
-		}		 
-		cdl_option CYGNUM_LWIP_MEMP_NUM_SYS_TIMEOUT {
-			display		"Simultaneous active timeouts"
-			flavor		data
-			default_value 	CYGPKG_LWIP_DHCP ? 6 : 4
-			description   	"
-				MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
-				timeouts."
-		
-		}		 
-		cdl_component CYGPKG_LWIP_MEM_SEQ_API {
-			display		"Sequential API settings"
-			flavor 		none
-			no_define
-			description	"
-				The following four are used only with the sequential API and can be
-  			    set to 0 if the application only will use the raw API."
-		
+                        cdl_option CYGDAT_LWIP_ETH[set ::channel]_NETCONF_NETMASK {
+                            display         "Netmask"
+                            flavor          data
+                            default_value   { "255,255,255,0" }
+                            description     "
+                                The netmask of the local network."
+                        }
+        
+                        cdl_option CYGDAT_LWIP_ETH[set ::channel]_NETCONF_GATEWAY {
+                            display         "Gateway"
+                            flavor          data
+                            default_value   { "192,168,1,1" }
+                            description     "
+                                The IP address of the gateway."
+                        }
+                    }
+                }
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_LOOPIF {
+            display         "Loop interface support"
+            flavor          bool
+            default_value   0
+            compile         netif/loopif.c
+            description     "
+                Support loop interface."
+                
+            cdl_component CYGIMP_LWIP_LOOPIF_INSTANCE {
+                display         "Default instance"
+                flavor          bool
+                default_value   1
+                description     "
+                    When enabled, a default loop interface is automatically
+                    set up."
+                    
+                cdl_option CYGDAT_LWIP_LOOPIF_DEFAULT {
+                    display         "Default netif"
+                    flavor          bool
+                    default_value   0
+                    implements      CYGPKG_LWIP_NETIF_DEFAULT
+                    description     "
+                        Use this interface as the default network interface."
+                }
+                    
+                cdl_option CYGDAT_LWIP_LOOPIF_ADDR {
+                    display         "Address"
+                    flavor          data
+                    default_value   { "127,0,0,1" }
+                    description     "
+                        The IP address of this device."
+                }
+            
+                cdl_option CYGDAT_LWIP_LOOPIF_NETMASK {
+                    display         "Netmask"
+                    flavor          data
+                    default_value   { "255,255,255,0" }
+                    description     "
+                        The netmask of the local network."
+                }
+        
+                cdl_option CYGDAT_LWIP_LOOPIF_GATEWAY {
+                    display         "Gateway"
+                    flavor          data
+                    default_value   { "127,0,0,1" }
+                    description     "
+                        The IP address of the gateway."
+                }
+            }
+        }
 
-			cdl_option CYGNUM_LWIP_MEMP_NUM_NETBUF {
-				display		"Struct netbufs"
-				flavor		data
-				default_value 	2
-				description   	"
-					MEMP_NUM_NETBUF: the number of struct netbufs."
-					
-			}		 
-			cdl_option CYGNUM_LWIP_MEMP_NUM_NETCONN {
-				display		"Struct netconns"
-				flavor		data
-				default_value 	4
-				description   	"
-					MEMP_NUM_NETCONN: the number of struct netconns."
-					
-			}		 
-			cdl_option CYGNUM_LWIP_MEMP_NUM_APIMSG {
-				display		"Struct api_msgs"
-				flavor		data
-				default_value 	8
-				description   	"
-					MEMP_NUM_APIMSG: the number of struct api_msg, used for
-					communication between the TCP/IP stack and the sequential
-					programs."
-					
-			}		 
-			cdl_option CYGNUM_LWIP_MEMP_NUM_TCPIP_MSG {
-				display		"Struct tcpip_msgs"
-				flavor		data
-				default_value 	8
-				description   	"
-					MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
-					for sequential API communication and incoming packets. Used in
-					src/api/tcpip.c."
-
-			}		 
-		}
-
-	}
-	
-	cdl_component CYGPKG_LWIP_PBUF_OPTIONS {
-		display		"PBUF"
-		flavor 		none
-		no_define
-		description   	"
-		Packet buffer related tunings."
-
-			
-		cdl_option CYGNUM_LWIP_PBUF_POOL_SIZE {
-			display		"PBUF pool size"
-			flavor		data
-			default_value 	60
-			description   	"
-			PBUF_POOL_SIZE: the number of buffers in the pbuf pool."
-	
-		}
-		
-		cdl_option CYGNUM_LWIP_PBUF_POOL_BUFSIZE {
-			display		"PBUF buffer size"
-			flavor		data
-			default_value 	1024
-			description   	"
-			PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool."
-		}		
-		 
-		cdl_option CYGNUM_LWIP_PBUF_LINK_HLEN {
-			display		"Allocation for a link level header"
-			flavor		data
-			calculated 	{CYGPKG_LWIP_SLIP || CYGPKG_LWIP_PPP ? 0 : 16}
-			description   	"
-				PBUF_LINK_HLEN: the number of bytes that should be allocated for a
-				link level header."
-			}		 
-	}
-	
-	cdl_component CYGPKG_LWIP_TCP {
-		display		    "TCP"
-		flavor 		    bool
-		default_value 	1
-		description   	"
-		           Support TCP protocol."
-		
-		cdl_option CYGNUM_LWIP_TCP_TTL {
-			display		"Time To Live"
-			flavor		data
-			default_value 	255
-			description   	""
-
-		}		 
-		cdl_option CYGIMP_LWIP_TCP_QUEUE_OOSEQ {
-			display		"Queue segments"
-			flavor		bool
-			default_value 	1
-			description   	"
-				Controls if TCP should queue segments that arrive out of
-				order. Disable this option if your device is low on memory."
-		
-		}		 
-		cdl_option CYGNUM_LWIP_TCP_MSS {
-			display		"Maximum segment size"
-			flavor		data
-			default_value 	2048
-			description   	"
-				TCP Maximum segment size."
-		}	
-			 
-		cdl_option CYGNUM_LWIP_TCP_SND_BUF {
-			display		"Sender buffer space"
-			flavor		data
-			default_value 	2048	
-			description   	"
-				TCP sender buffer space (bytes)."
+        cdl_component CYGPKG_LWIP_SLIP {
+            display         "SLIP support"
+            flavor          bool
+            implements      CYGINT_LWIP_SIO_REQUIRED
+            default_value   0
+            compile         netif/slipif.c
+            description     "
+                Support SLIP functionality."
+                
+            cdl_option CYGDAT_LWIP_SLIPIF_DEV {
+                display         "Serial device"
+                flavor          data
+                default_value   { "\"/dev/ser0\"" }
+                description     "
+                    Serial port to use for SLIP."
+            }
+            
+            cdl_component CYGIMP_LWIP_SLIPIF_INSTANCE {
+                display         "Default instance"
+                flavor          bool
+                default_value   1
+                description     "
+                    When enabled, a default loop interface is automatically
+                    set up."
+                    
+                cdl_option CYGDAT_LWIP_SLIPIF_DEFAULT {
+                    display         "Default netif"
+                    flavor          bool
+                    default_value   0
+                    implements      CYGPKG_LWIP_NETIF_DEFAULT
+                    description     "
+                        Use this interface as the default network interface."
+                }
+            
+                cdl_option CYGDAT_LWIP_SLIPIF_ADDR {
+                    display         "Address"
+                    flavor          data
+                    default_value   { "172,16,1,1" }
+                    description     "
+                        The IP address of this device."
+                }
+            
+                cdl_option CYGDAT_LWIP_SLIPIF_NETMASK {
+                    display         "Netmask"
+                    flavor          data
+                    default_value   { "255,255,255,0" }
+                    description     "
+                        The netmask of the local network."
+                }
+        
+                cdl_option CYGDAT_LWIP_SLIPIF_GATEWAY {
+                    display         "Gateway"
+                    flavor          data
+                    default_value   { "172,16,1,2" }
+                    description     "
+                        The IP address of the gateway."
+                }
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_PPP {
+            display         "PPP support (experimental)"
+            flavor          bool
+            default_value   0
+            compile         ecos/ppp.c          \
+                            netif/ppp/auth.c    \
+                            netif/ppp/chap.c    \
+                            netif/ppp/chat.c    \
+                            netif/ppp/chpms.c   \
+                            netif/ppp/fsm.c     \
+                            netif/ppp/ipcp.c    \
+                            netif/ppp/lcp.c     \
+                            netif/ppp/magic.c   \
+                            netif/ppp/md5.c     \
+                            netif/ppp/pap.c     \
+                            netif/ppp/ppp_oe.c  \
+                            netif/ppp/ppp.c     \
+                            netif/ppp/randm.c   \
+                            netif/ppp/record.c  \
+                            netif/ppp/timesys.c \
+                            netif/ppp/vj.c
+            description     "
+                Support PPP functionality. Current PPP support is marked
+                experimental as it is subject to change for alignment to the
+                PPP API of the upcoming lwIP 1.4.x releases."
+    
+            cdl_option CYGFUN_LWIP_PPPOE_SUPPORT {
+                display         "PPPoE support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable PPP Over Ethernet."
+            }
+                
+            cdl_option CYGFUN_LWIP_PPPOS_SUPPORT {
+                display         "PPPoS support"
+                flavor          bool
+                implements      CYGINT_LWIP_SIO_REQUIRED
+                default_value   0
+                description     "
+                    Enable PPP Over Serial."
+            }
+            
+            cdl_option CYGDAT_LWIP_PPPOS_DEV {
+                display         "Serial device"
+                flavor          data
+                default_value   { "\"/dev/ser0\"" }
+                active_if       { CYGFUN_LWIP_PPPOS_SUPPORT }
+                description     "
+                    Serial port to use for PPPoS."
+            }
+            
+            cdl_option CYGNUM_LWIP_NUM_PPP {
+                display         "Max sessions"
+                flavor          data
+                default_value   1
+                description     "
+                    Max PPP sessions."
+            }
+            
+            cdl_option CYGFUN_LWIP_PAP_SUPPORT {
+                display         "PAP support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable PAP support."
+            }
+            
+            cdl_option CYGFUN_LWIP_CHAP_SUPPORT {
+                display         "CHAP support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Enable CHAP support."
+            }
+            
+            cdl_option CYGFUN_LWIP_VJ_SUPPORT {
+                display         "VJ support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support VJ header compression."
+            }
+            
+            cdl_option CYGFUN_LWIP_MD5_SUPPORT {
+                display         "MD5 support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support MD5 (see also CHAP)."
+            }
+            
+            cdl_option CYGFUN_LWIP_RECORD_SUPPORT {
+                display         "Recording support"
+                flavor          bool
+                default_value   0
+                description     "
+                    Support for dumping incoming/outgoing records."
+            }
+        }
+    }
+    
+    cdl_component CYGPKG_LWIP_MEM_OPTIONS {
+        display         "Memory options"
+        flavor          none
+        no_define
+        description     "
+            Tunables for various aspects of memory usage throughout the stack."
+            
+        cdl_option CYGIMP_LWIP_MEM_LIBC_MALLOC {
+            display         "Use malloc for internal allocations"
+            flavor          bool
+            default_value   0
+            requires        { CYGINT_ISO_MEMALLOC != 0 }
+            description     "
+                Use malloc/free/realloc provided by the C-library instead of
+                the lwip internal allocator. Can save code size if you already
+                use it."
+        }
+                
+        cdl_option CYGIMP_LWIP_MEMP_MEM_MALLOC {
+            display         "Use malloc for pool allocations"
+            flavor          bool
+            default_value   0
+            description     "
+                Use mem_malloc/mem_free instead of the lwip pool allocator.
+                Especially useful with MEM_LIBC_MALLOC but handle with care
+                regarding execution speed and usage from interrupts!"
+        }
+                
+        cdl_option CYGNUM_LWIP_MEM_ALIGNMENT {
+            display         "Memory alignment"
+            flavor          data
+            default_value   4
+            description     "
+                Should be set to the alignment of the CPU."
+        }
+                
+        cdl_option CYGNUM_LWIP_MEM_SIZE {
+            display         "Memory size"
+            flavor          data
+            default_value   { 1600 + ((CYGNUM_LWIP_NUM_PPP * 2) * 1504) }
+            description     "
+                The size of the heap memory. If the application will send a lot
+                of data that needs to be copied, this should be set high."
+        }
+        
+        cdl_option CYGDBG_LWIP_MEMP_OVERFLOW_CHECK {
+            display         "Memory pool overflow protection"
+            flavor          data
+            default_value   0
+            description     "
+                Memory pool overflow protection reserves a configurable amount
+                of bytes before and after each memp element in every pool and
+                fills it with a prominent default value.
+                MEMP_OVERFLOW_CHECK == 0 no checking,
+                MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed,
+                MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool
+                every time memp_malloc() or memp_free() is called
+                (useful but slow!)"
+        }
+        
+        cdl_option CYGDBG_LWIP_MEMP_SANITY_CHECK {
+            display         "Memory pool sanity check"
+            flavor          bool
+            default_value   0
+            description     "
+                Run a sanity check after each memp_free() to make sure that
+                there are no cycles in the linked lists."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_PBUF {
+            display         "Number of memp struct pbufs"
+            flavor          data
+            default_value   16
+            description     "
+                 The number of memp struct pbufs (used for PBUF_ROM and
+                 PBUF_REF). If the application sends a lot of data out of ROM
+                 (or other static memory), this should be set high."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_TCP_PCB {
+            display         "Simultaneous active TCP connections"
+            flavor          data
+            default_value   5
+            active_if       { CYGPKG_LWIP_TCP }
+            description     "
+                The number of simulatenously active TCP connections."
+        }
+            
+        cdl_option CYGNUM_LWIP_MEMP_NUM_TCP_PCB_LISTEN {
+            display         "Listening TCP connections"
+            flavor          data
+            default_value   8
+            active_if       { CYGPKG_LWIP_TCP }
+            description     "
+                The number of listening TCP connections."
+        }
+            
+        cdl_option CYGNUM_LWIP_MEMP_NUM_TCP_SEG {
+            display         "Simultaneous queued TCP segments"
+            flavor          data
+            default_value   16
+            active_if       { CYGPKG_LWIP_TCP }
+            description     "
+                The number of simultaneously queued TCP segments."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_REASSDATA {
+            display         "Simultaneous queued IP packets for reassembly"
+            flavor          data
+            default_value   5
+            description     "
+                The number of simultaneously IP packets queued for reassembly
+                (whole packets, not fragments!)."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_ARP_QUEUE {
+            display         "Simultaneous queued ARP requests"
+            flavor          data
+            default_value   30
+            active_if       { CYGFUN_LWIP_ARP_QUEUEING }
+            description     "
+                The number of simulateously queued outgoing packets (pbufs)
+                that are waiting for an ARP request (to resolve their
+                destination address) to finish."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_IGMP_GROUP {
+            display         "Multicast groups"
+            flavor          data
+            default_value   8
+            active_if       { CYGPKG_LWIP_IGMP }
+            description     "
+                The number of multicast groups whose network interfaces can be
+                members et the same time (one per netif - allsystems group -,
+                plus one per netif membership)."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_CORE_SYS_TIMEOUT {
+            display         "Simultaneous active timeouts by core modules"
+            flavor          data
+            calculated      { CYGPKG_LWIP_TCP + CYGFUN_LWIP_IP_REASSEMBLY +
+                              CYGPKG_LWIP_ARP + (CYGPKG_LWIP_DHCP * 2) +
+                              CYGPKG_LWIP_AUTOIP + CYGPKG_LWIP_IGMP +
+                              CYGPKG_LWIP_DNS + CYGPKG_LWIP_PPP }
+            description     "
+                The number of simulateously active timeouts used by the lwIP
+                core modules."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_USER_SYS_TIMEOUT {
+            display         "Simultaneous active timeouts by user modules"
+            flavor          data
+            default_value   { 0 }
+            description     "
+                The number of simulateously active timeouts used by user
+                modules."
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_NETBUF {
+            display         "Struct netbufs"
+            flavor          data
+            default_value   2
+            description     "
+               The number of struct netbufs. (only needed if you use the
+               sequential API, like api_lib.c)"
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_NETCONN {
+            display         "Struct netconns"
+            flavor          data
+            default_value   4
+            description     "
+                The number of struct netconns. (only needed if you use the
+                sequential API, like api_lib.c)"
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_TCPIP_MSG_API {
+            display         "Struct tcpip_msg"
+            flavor          data
+            default_value   8
+            description     "
+                The number of struct tcpip_msg, which are used for
+                callback/timeout API communication. (only needed if you use
+                tcpip.c)"
+        }
+        
+        cdl_option CYGNUM_LWIP_MEMP_NUM_TCPIP_MSG_INPKT {
+            display         "Incoming struct tcpip_msg"
+            flavor          data
+            default_value   8
+            description     "
+                The number of struct tcpip_msg, which are used for incoming
+                packets. (only needed if you use tcpip.c)"
+        }
+        
+        cdl_option CYGNUM_LWIP_PBUF_POOL_SIZE {
+            display         "Pbuf pool buffers"
+            flavor          data
+            default_value   16
+            description     "
+                The number of buffers in the pbuf pool."
+        }
 
-		}		 
-		cdl_option CYGNUM_LWIP_TCP_SND_QUEUELEN {
-			display		"Sender pbufs"
-			flavor		data
-			calculated 	CYGPKG_LWIP_TCP ? "4 * CYGNUM_LWIP_TCP_SND_BUF/CYGNUM_LWIP_TCP_MSS" : 0
-			description   	"
-				TCP sender buffer space (pbufs). This must be at least = 2 *
-				TCP_SND_BUF/TCP_MSS for things to work."
-
-		}		 
-		cdl_option CYGNUM_LWIP_TCP_WND {
-			display		"Receive window"
-			flavor		data
-			default_value 	4096
-			description   	"
-				TCP receive window."
-
-		}		 
-		cdl_option CYGNUM_LWIP_TCP_MAXRTX {
-			display		"Segment retransmissions"
-			flavor		data
-			default_value 	12
-			description   	"
-				 Maximum number of retransmissions of data segments."
-
-		}		 
-		cdl_option CYGNUM_LWIP_TCP_SYNMAXRTX {
-			display		"Syn retransmissions"
-			flavor		data
-			default_value 	4
-			description   	"
-				Maximum number of retransmissions of SYN segments."
-			}		 
-	}	
-	
-	cdl_component CYGPKG_LWIP_ARP_OPTIONS {
-		display		"ARP"
-		flavor 		none
-		no_define
-		
-		cdl_option CYGNUM_LWIP_ARP_TABLE_SIZE {
-			display		"ARP table size"
-			flavor		data
-			default_value 	10
-			description   	""
-		
-		}
-	}
-
-	cdl_component CYGPKG_LWIP_IP {
-		display		"IP"
-		flavor		none
-		no_define
-	
-		cdl_option CYGFUN_LWIP_IP_FORWARD {
-			display		"Support IP forwarding"
-			flavor		bool
-			default_value 	1
-			description   	"
-				Enable this option if you wish to have the ability to forward
-				IP packets across network interfaces. If you are going to run lwIP
-				on a device with only one network interface, disable this option."
-		
-		}
-		cdl_option CYGFUN_LWIP_IP_OPTIONS {
-			display		"Allow IP options"
-			flavor		bool
-			default_value 	1
-			description   	"
-				If enabled, IP options are allowed (but not parsed). If
-				   disabled, all packets with IP options are dropped."
-		
-		}
-		
-		cdl_option CYGFUN_LWIP_IP_FRAG {
-			display		"Support IP fragmentation"
-			flavor		bool
-			default_value 	1
-			description   	"
-			"	
-		}
-
-		cdl_option CYGFUN_LWIP_IP_REASS {
-			display		"Support IP reassembly"
-			flavor		bool
-			default_value 	1
-			description   	"
-			"	
-		}
-
-	}
-
-	cdl_component CYGPKG_LWIP_ICMP_OPTIONS {
-		display		"ICMP"
-		flavor		none
-		no_define
-
-		cdl_option CYGNUM_LWIP_ICMP_TTL {
-			display		"ICMP Time To Live"
-			flavor		data
-			default_value 	255
-			description   	""
-		}
-	}
-
-	cdl_component CYGPKG_LWIP_DHCP {
-		display		  "DHCP"
-		flavor		  bool
-		requires  CYGPKG_LWIP_UDP
-		default_value 0
-		requires  { CYGNUM_LWIP_MEMP_NUM_SYS_TIMEOUT >= 6 }
-		description "
-		    Provide DHCP support for initializing the IP address of network interfaces."
-		compile core/dhcp.c
-
-        cdl_option CYGOPT_LWIP_DHCP_MANAGEMENT {
-            display    "DHCP management"
-            flavor     bool
-            default_value 1
-            description "
-                If enabled then the lwIP stack automatically calls dhcp_start(), 
-                dhcp_fine_tmr() and dhcp_coarse_tmr(). The DHCP stuff is handled 
-                in the TCP/IP thread. If this causes trouble on high traffic loads 
-                or if the application need to be aware of the DHCP state then it 
-                is better to disable this option. In this case managing the DHCP 
-                state in an application aware thread is recommended."        
+        cdl_option CYGNUM_LWIP_VARMEMPOOL_SIZE {
+            display         "Size of variable memory pool"
+            flavor          data
+            default_value   2048
+            description     "
+                Memory required to hold semaphore, mbox and thread structures
+                is allocated from this memory pool."
+        }
+        
+        cdl_option CYGNUM_LWIP_PBUF_LINK_HLEN {
+            display         "Allocation for a link level header"
+            flavor          data
+            default_value   { (CYGPKG_LWIP_ETH) ? 14 : 0 }
+            requires        { CYGNUM_LWIP_PBUF_LINK_HLEN >= 
+                              (CYGPKG_LWIP_ETH) ? 14 : 0 }
+            description     "
+                The number of bytes that should be allocated for a link level
+                header. The default is 14, the standard value for Ethernet."
         }
         
-		cdl_option CYGOPT_LWIP_DHCP_DOES_ARP_CHECK {
-			display		"Check offered address"
-			flavor		bool
-			default_value 	1
-			description   	"
-				Enable this option if you want to do an ARP check on the offered address
-				(recommended)."
-		}
-	}
-	
-	cdl_component CYGFUN_LWIP_LOOPIF {
-		display		"Support loop interface (127.0.0.1)"
-		flavor		bool
-		default_value 	1
-		compile netif/loopif.c
-	}
+        cdl_option CYGNUM_LWIP_PBUF_POOL_BUFSIZE {
+            display         "PBUF buffer size"
+            flavor          data
+            default_value   { CYGNUM_LWIP_TCP_MSS + 40 + CYGNUM_LWIP_PBUF_LINK_HLEN }
+            description     "
+                The size of each pbuf in the pbuf pool. The default is designed
+                to accomodate single full size TCP frame in one pbuf, including
+                TCP_MSS, IP header, and link header."
+        }       
+    }
+    
+    cdl_component CYGPKG_LWIP_THREADS {
+        display         "Thread options"
+        flavor          none
+        no_define
+        active_if       CYGFUN_LWIP_MODE_SEQUENTIAL
+        
+        cdl_component CYGPKG_LWIP_THREAD_TCPIP {
+            display         "TCP/IP thread"
+            flavor          none
+            no_define
+            description     "
+                The TCP/IP thread is handling the central message queue in the
+                lwIP stack. The name is misleading, as it does not only handle
+                TCP/IP, but all of the stack."
+
+            cdl_option CYGNUM_LWIP_THREAD_TCPIP_STACKSIZE {
+                display         "Stack size"
+                flavor          data
+                default_value   1024
+            }
+        
+            cdl_option CYGNUM_LWIP_THREAD_TCPIP_PRIORITY {
+                display         "Thread priority"
+                flavor          data
+                default_value   8
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_THREAD_ETH {
+            display         "Ethernet thread"
+            flavor          none
+            no_define
+            active_if       { CYGPKG_LWIP_ETH }
+            description     "
+                The ethernet thread is responsible for receiving data packets
+                from ethernet devices and queueing them to be processed in the
+                TCP/IP thread."
 
-	cdl_component CYGPKG_LWIP_ETH {
-		display "Ethernet support"
-		flavor bool
-		requires CYGPKG_IO_ETH_DRIVERS
-		default_value	1
-		description "Ethernet support"
-		compile netif/etharp.c
-		
-		cdl_option CYGNUM_LWIP_ETH_THREAD_PRIORITY {
-			display "ethernet input thread priority"
-			flavor data
-			default_value	6
-			description "Priority of the thernet input thread"
-		}
-		
-	}
-	
-    cdl_option CYGNUM_LWIP_NETWORK_THREAD_PRIORITY {
-			display "Network thread priority"
-			flavor data
-			default_value	7
-			description "Priority of the lwIP network thread.This thread handles all API messages and
-					network packets."
-		}	
+            cdl_option CYGNUM_LWIP_THREAD_ETH_STACKSIZE {
+                display         "Stack size"
+                flavor          data
+                default_value   1024
+            }
+        
+            cdl_option CYGNUM_LWIP_THREAD_ETH_PRIORITY {
+                display         "Thread priority"
+                flavor          data
+                default_value   4
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_THREAD_SLIP {
+            display         "SLIP thread"
+            flavor          none
+            no_define
+            active_if       { CYGPKG_LWIP_SLIP }
+            description     "
+                The SLIP thread is responsible for reading data from the SLIP
+                serial device and queue them to be processed in the TCP/IP
+                thread."
+
+            cdl_option CYGNUM_LWIP_THREAD_SLIP_STACKSIZE {
+                display         "Stack size"
+                flavor          data
+                default_value   1024
+            }
+        
+            cdl_option CYGNUM_LWIP_THREAD_SLIP_PRIORITY {
+                display         "Thread priority"
+                flavor          data
+                default_value   8
+            }
+        }
+        
+        cdl_component CYGPKG_LWIP_THREAD_PPPOS {
+            display         "PPPoS thread"
+            flavor          none
+            no_define
+            active_if       { CYGFUN_LWIP_PPPOS_SUPPORT }
+            description     "
+                The PPPoS thread is responsible for reading data from the PPP
+                serial device and queue them to be processed in the TCP/IP
+                thread."
+
+            cdl_option CYGNUM_LWIP_THREAD_PPPOS_STACKSIZE {
+                display         "Stack size"
+                flavor          data
+                default_value   1024
+            }
+        
+            cdl_option CYGNUM_LWIP_THREAD_PPPOS_PRIORITY {
+                display         "Thread priority"
+                flavor          data
+                default_value   8
+            }
+        }
+    }
 
-	cdl_component CYGPKG_LWIP_SLIP {
-		display "SLIP"
-		flavor bool
-		requires CYGPKG_IO_SERIAL_DEVICES
-		default_value	0
-		description "IP over Serial Line"
-		compile netif/slipif.c ecos/sio.c
-		
-		cdl_option CYGNUM_LWIP_SLIPIF_THREAD_PRIORITY {
-			display "SLIP thread priority"
-			flavor data
-			default_value	8
-			description "Priority of the SLIP input thread"
-		}
-		
-		cdl_option CYGDAT_LWIP_SLIP_DEV {
-			display "Serial device"
-			flavor 	data
-			default_value {"\"/dev/ser0\""}
-			description "
-			        Which serial port to use SLIP on."
-		}
-	}
-	
-	cdl_component CYGPKG_LWIP_PPP {
-		display "PPP"
-		flavor bool
-		requires CYGPKG_IO_SERIAL_DEVICES
-		default_value	0
-		description "The Point-to-Point Protocol"
-		compile netif/ppp/ppp.c		\
-			netif/ppp/auth.c	\
-			netif/ppp/chpms.c	\
-			netif/ppp/fsm.c		\
-			netif/ppp/ipcp.c	\
-			netif/ppp/lcp.c		\
-			netif/ppp/magic.c	\
-			netif/ppp/md5.c		\
-			netif/ppp/randm.c	\
-			netif/ppp/vj.c		\
-			ecos/sio.c
-			
+    cdl_component CYGPKG_LWIP_CHECKSUMS {
+        display         "Checksum generation/checking"
+        flavor          none
+        no_define
+        description     "
+            Options for checksum generation and checking."
+            
+        cdl_option CYGIMP_LWIP_CHECKSUM_GEN_IP {
+            display         "Generate IP checksums"
+            flavor          bool
+            default_value   1
+            description     "
+                Generate checksums in software for outgoing IP packets."
+        }
+            
+        cdl_option CYGIMP_LWIP_CHECKSUM_GEN_UDP {
+            display         "Generate UDP checksums"
+            flavor          bool
+            default_value   1
+            description     "
+                Generate checksums in software for outgoing UDP packets."
+        }
+            
+        cdl_option CYGIMP_LWIP_CHECKSUM_GEN_TCP {
+            display         "Generate TCP checksums"
+            flavor          bool
+            default_value   1
+            description     "
+                Generate checksums in software for outgoing TCP packets."
+        }
 
-		cdl_option CYGIMP_LWIP_PPP_PAP_AUTH {
-			display "Support PAP authentication"
-			flavor bool
-			default_value 1
-			compile netif/ppp/pap.c		
-		}
-		
-		cdl_option CYGIMP_LWIP_PPP_CHAP_AUTH {
-			display "Support CHAP authentication"
-			flavor bool
-			default_value 1
-			compile netif/ppp/chap.c		
-		}
-	
-		cdl_option CYGDAT_LWIP_PPP_DEV {
-			display "Serial device for PPP"
-			flavor 	data
-			default_value {"\"/dev/ser0\""}
-			description "
-			Which serial port to use PPP on."
-		}
-
-		cdl_option CYGNUM_LWIP_PPP_THREAD_PRIORITY {
-			display "PPP main thread priority"
-			flavor data
-			default_value	8
-			description "Priority of the PPP input thread"
-		}	
-	}
-
-	cdl_component CYGPKG_LWIP_UDP {
-		display		"UDP"
-		flavor		bool
-		default_value 	1
-		description   	"Support UDP protocol."
-		compile core/udp.c
-
-		cdl_option CYGNUM_LWIP_UDP_TTL {
-			display		"Time To Live"
-			flavor		data
-			default_value 	255
-			description   	""
-		}
-	}
-	
-	cdl_option CYGFUN_LWIP_RAW {
-		display		"Enable RAW socket support"
-		flavor		bool
-		default_value 	1
-		description   	""
-		compile core/raw.c
-	}
-	
-	cdl_option CYGFUN_LWIP_COMPAT_SOCKETS {
-	    display       "Provide compatible socket API"
-	    flavor        bool
-	    default_value 1
-	    description "
-	         The lwIP socket API uses defines to map the lwip socket functions 
-	         (lwip_accept(), lwip_bind(), lwip_listen()...) to BSD like names
-	         (accept(), bind(), listen()...). If this causes trouble or naming
-	         conficts for your application, then disable this option"
+        cdl_option CYGIMP_LWIP_CHECKSUM_CHECK_IP {
+            display         "Check IP checksums"
+            flavor          bool
+            default_value   1
+            description     "
+                Check checksums in software for incoming IP packets."
+        }
+            
+        cdl_option CYGIMP_LWIP_CHECKSUM_CHECK_UDP {
+            display         "Check UDP checksums"
+            flavor          bool
+            default_value   1
+            description     "
+                Check checksums in software for incoming UDP packets."
+        }
+            
+        cdl_option CYGIMP_LWIP_CHECKSUM_CHECK_TCP {
+            display         "Check TCP checksums"
+            flavor          bool
+            default_value   1
+            description     "
+                Check checksums in software for incoming TCP packets."
+        }
+    }
+    
+    cdl_component CYGPKG_LWIP_STATS {
+        display         "Traffic statistics"
+        flavor          bool
+        default_value   0
+        description     "
+            Enable statistics collection in lwip_stats."
+            
+        cdl_option CYGVAR_LWIP_LINK_STATS {
+            display         "Link stats"
+            flavor          bool
+            default_value   1
+        }
+        
+        cdl_option CYGVAR_LWIP_ETHARP_STATS {
+            display         "Etharp stats"
+            flavor          bool
+            default_value   1
+        }
+        
+        cdl_option CYGVAR_LWIP_IP_STATS {
+            display         "IP stats"
+            flavor          bool
+            default_value   1
+        }
+        
+        cdl_option CYGVAR_LWIP_IPFARG_STATS {
+            display         "IP fragmentation stats"
+            flavor          bool
+            default_value   1
+            active_if       { CYGFUN_LWIP_IP_REASSEMBLY ||
+                              CYGFUN_LWIP_IP_FRAG }
+        }
+        
+        cdl_option CYGVAR_LWIP_ICMP_STATS {
+            display         "ICMP stats"
+            flavor          bool
+            default_value   1
+            active_if       { CYGPKG_LWIP_ICMP }
+        }
+        
+        cdl_option CYGVAR_LWIP_IGMP_STATS {
+            display         "IGMP stats"
+            flavor          bool
+            default_value   1
+            active_if       { CYGPKG_LWIP_IGMP }
+        }
+        
+        cdl_option CYGVAR_LWIP_UDP_STATS {
+            display         "UDP stats"
+            flavor          bool
+            default_value   1
+            active_if       { CYGPKG_LWIP_UDP }
+        }
+        
+        cdl_option CYGVAR_LWIP_TCP_STATS {
+            display         "TCP stats"
+            flavor          bool
+            default_value   1
+            active_if       { CYGPKG_LWIP_TCP }
+        }
+        
+        cdl_option CYGVAR_LWIP_MEM_STATS {
+            display         "Memory stats"
+            flavor          bool
+            default_value   1
+        }
+        
+        cdl_option CYGVAR_LWIP_MEMP_STATS {
+            display         "Memory pool stats"
+            flavor          bool
+            default_value   1
+        }
+        
+        cdl_option CYGVAR_LWIP_SYS_STATS {
+            display         "System stats"
+            flavor          bool
+            default_value   1
+        }
+    }
+    
+    cdl_option CYGFUN_LWIP_SHOW_NETIF_CONFIG {
+        display         "Show netif configuration"
+        flavor          bool
+        default_value   1
+        requires        CYGFUN_LWIP_NETIF_STATUS_CALLBACK
+        description     "
+            Shows the netif configuration on the diagnostic output."
     }
 
-	cdl_component CYGPKG_LWIP_APP_MEM_OPTIONS {
-		display		"Memory options for apps"
-		flavor 		none
-		no_define
-		description   	"Memory options for applications."
-
-		cdl_option CYGNUM_LWIP_VARMEMPOOL_SIZE {
-			display		"Size of variable memory pool"
-			flavor		data
-			default_value 	2048	
-			description   	"
-					Memory required to hold semaphore, mbox and thread structures
-					are allocated from this memory pool.
-					"
-		}
-
-	
+    cdl_component CYGDBG_LWIP_DEBUG {
+        display         "Debugging"
+        flavor          bool
+        default_value   0
+        description     "
+            Configuration options for debug output."
+            
+        cdl_component CYGDBG_LWIP_DEBUG_OPTIONS {
+            display         "Debug options"
+            flavor          none
+            
+            cdl_option CYGDBG_LWIP_DEBUG_LEVEL {
+                display         "Log level"
+                flavor          data
+                default_value   0
+                legal_values    { 0 to 3 }
+                description     "
+                    Sets the minimum log level needed to for log output.
+                    0 = Info, 1 = Warning, 2 = Serious, 3 = Severe" 
+            }
+            
+            cdl_option CYGDBG_LWIP_DEBUG_TRACE {
+                display         "Trace messages"
+                flavor          bool
+                default_value   1
+                description     "
+                    Log state tracing messages (to follow module flow)." 
+            }
+            
+            cdl_option CYGDBG_LWIP_DEBUG_STATE {
+                display         "State messages"
+                flavor          bool
+                default_value   1
+                description     "
+                    Log state debug messages (to follow module states)." 
+            }
+            
+            cdl_option CYGDBG_LWIP_DEBUG_FRESH {
+                display         "Fresh messages"
+                flavor          bool
+                default_value   1
+                description     "
+                    Log messages from newly added code, not thoroughly tested
+                    yet."
+            }
+        }
+        
+        cdl_option CYGDBG_LWIP_DEBUG_ETHARP {
+            display         "Etharp debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_NETIF {
+            display         "Netif debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_PBUF {
+            display         "PBUF debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_API {
+            display         "API debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_SOCKETS {
+            display         "Sockets debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_ICMP {
+            display         "ICMP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_IGMP {
+            display         "IGMP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_IP {
+            display         "IP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_RAW {
+            display         "RAW debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_MEM {
+            display         "Memory debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_SYS {
+            display         "System debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_TCP {
+            display         "TCP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_UDP {
+            display         "UDP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_TCPIP {
+            display         "TCPIP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_PPP {
+            display         "PPP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_SLIP {
+            display         "SLIP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_DHCP {
+            display         "DHCP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_AUTOIP {
+            display         "AUTOIP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_SNMP {
+            display         "SNMP debugging"
+            flavor          bool
+            default_value   1
+        }
+                    
+        cdl_option CYGDBG_LWIP_DEBUG_DNS {
+            display         "DNS debugging"
+            flavor          bool
+            default_value   1
+        }
+        
+        cdl_option CYGDBG_LWIP_DEBUG_SIO {
+            display         "SIO debugging"
+            flavor          bool
+            default_value   1
+        }
+    }
+    
+    cdl_component CYGPKG_NET_LWIP_TESTS {
+        display         "lwIP tests"
+        flavor          data
+        no_define
+        calculated      { "tests/httpd_sequential tests/httpd_simple " .
+                          "tests/nc_test_slave tests/ppp " . 
+                          "tests/socket tests/sys_timeout tests/tcpecho " .
+                          "tests/udpecho" }
+        description     "
+            This option specifies the set of tests for lwIP. They show the
+            usage of the raw, the sequential and the BSD socket compatible APIs"
+            
+        cdl_component CYGPKG_NET_LWIP_PPP_TEST {
+            display         "PPP test options"
+            flavor          none
+            no_define
+            
+            cdl_option CYGDAT_NET_LWIP_PPP_TEST_APN {
+                display         "APN"
+                flavor          data
+                default_value   { "\"gprs.swisscom.ch\"" }
+                description     "
+                    Access Point Name used to open PPP connection."
+            }
+            
+            cdl_option CYGDAT_NET_LWIP_PPP_TEST_NUMBER {
+                display         "Number"
+                flavor          data
+                default_value   { "\"*99#\"" }
+                description     "
+                    Dial number used to open PPP connection."
+            }
+            
+            cdl_option CYGDAT_NET_LWIP_PPP_TEST_USERNAME {
+                display         "Username"
+                flavor          data
+                default_value   { "\"gprs\"" }
+                description     "
+                    Username used for PPP authentication."
+            }
+            
+            cdl_option CYGDAT_NET_LWIP_PPP_TEST_PASSWORD {
+                display         "Password"
+                flavor          data
+                default_value   { "\"gprs\"" }
+                description     "
+                    Password used for PPP authentication."
+            }
+            
+            cdl_option CYGDAT_NET_LWIP_PPP_TEST_HOST {
+                display         "Host to ping"
+                flavor          data
+                default_value   { "\"www.ping.ch\"" }
+                description     "
+                    Hostname for DNS resolve and ping."
+            }
+        }
+    }
 
-		cdl_option CYGNUM_LWIP_APP_THREADS {
-			display		"Number of network threads in application"
-			flavor		data
-			default_value 	1
-			description   	"
-					At startup at least two lwIP threads are created:the polling(input) thread 
-					and the TCP/IP (output) thread.Additionally your application creates one
-					or more threads.
-					Set this option to the maximum number of threads you will create through
-					sys_thread_new().Threads which you create through cyg_thread_create() 
-					are not lwIP threads and don't count.This number is needed so that enough
-					static memory is reserved for stack space.
-					"
-		}
-	
-		cdl_option CYGNUM_LWIP_THREAD_STACK_SIZE {
-			display		"Size of per thread stack in lwIP"
-			flavor		data
-			default_value 	4096
-			description	"
-					Since stack space for threads needs to be statically allocated you can
-					specify the amount of memory to use for each network thread.
-					"
-		}				
-	}
-	
-	    
-    	cdl_option CYGPKG_NET_LWIP_TESTS {
-       		display "Some lwIP tests"
-	        flavor  data
-       		no_define
-        	calculated { 
-                   	"tests/tcpecho tests/udpecho tests/httpd tests/socket tests/nc_test_slave tests/sys_timeout"
-		}  
-       		description   "
-        	    This option specifies the set of tests for lwIP.They show the usage of 
-		    the raw, the sequential and the BSD socket compatible APIs"
-    	}
-		
+    cdl_component CYGPKG_LWIP_OPTIONS {
+        display         "lwIP build options"
+        flavor          none
+        no_define
+
+        cdl_option CYGPKG_LWIP_CFLAGS_ADD {
+            display         "Additional compiler flags"
+            flavor          data
+            no_define
+            default_value   { "" }
+            description     "
+                This option modifies the set of compiler flags for building the
+                lwIP package. These flags are used in addition to the set of
+                global flags."
+        }
+
+        cdl_option CYGPKG_LWIP_CFLAGS_REMOVE {
+            display         "Suppressed compiler flags"
+            flavor          data
+            no_define
+            default_value   { "" }
+            description     "
+                This option modifies the set of compiler flags for building the
+                lwIP package. These flags are removed from the set of global
+                flags if present."
+        }
+    }
 }
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/doc/contrib.txt
@@ -0,0 +1,63 @@
+1 Introduction
+
+This document describes some guidelines for people participating
+in lwIP development.
+
+2 How to contribute to lwIP
+
+Here is a short list of suggestions to anybody working with lwIP and 
+trying to contribute bug reports, fixes, enhancements, platform ports etc.
+First of all as you may already know lwIP is a volunteer project so feedback
+to fixes or questions might often come late. Hopefully the bug and patch tracking 
+features of Savannah help us not lose users' input.
+
+2.1 Source code style:
+
+1. do not use tabs.
+2. indentation is two spaces per level (i.e. per tab).
+3. end debug messages with a trailing newline (\n).
+4. one space between keyword and opening bracket.
+5. no space between function and opening bracket.
+6. one space and no newline before opening curly braces of a block.
+7. closing curly brace on a single line.
+8. spaces surrounding assignment and comparisons.
+9. don't initialize static and/or global variables to zero, the compiler takes care of that.
+10. use current source code style as further reference.
+
+2.2 Source code documentation style:
+
+1. JavaDoc compliant and Doxygen compatible.
+2. Function documentation above functions in .c files, not .h files.
+   (This forces you to synchronize documentation and implementation.)
+3. Use current documentation style as further reference.
+ 
+2.3 Bug reports and patches:
+
+1. Make sure you are reporting bugs or send patches against the latest
+   sources. (From the latest release and/or the current CVS sources.)
+2. If you think you found a bug make sure it's not already filed in the
+   bugtracker at Savannah.
+3. If you have a fix put the patch on Savannah. If it is a patch that affects
+   both core and arch specific stuff please separate them so that the core can
+   be applied separately while leaving the other patch 'open'. The prefered way
+   is to NOT touch archs you can't test and let maintainers take care of them.
+   This is a good way to see if they are used at all - the same goes for unix
+   netifs except tapif.
+4. Do not file a bug and post a fix to it to the patch area. Either a bug report
+   or a patch will be enough.
+   If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area.
+5. Trivial patches (compiler warning, indentation and spelling fixes or anything obvious which takes a line or two)
+   can go to the lwip-users list. This is still the fastest way of interaction and the list is not so crowded
+   as to allow for loss of fixes. Putting bugs on Savannah and subsequently closing them is too much an overhead
+   for reporting a compiler warning fix.
+6. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other
+   trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you
+   change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than
+   if it's not to the point and long :) so the chances for it to be applied are greater. 
+
+2.4 Platform porters:
+
+1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and
+   you think it could benefit others[1] you might want discuss this on the mailing list. You
+   can also ask for CVS access to submit and maintain your port in the contrib CVS module.
+   
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/doc/rawapi.txt
@@ -0,0 +1,478 @@
+Raw TCP/IP interface for lwIP
+
+Authors: Adam Dunkels, Leon Woestenberg, Christiaan Simons
+
+lwIP provides three Application Program's Interfaces (APIs) for programs
+to use for communication with the TCP/IP code:
+* low-level "core" / "callback" or "raw" API.
+* higher-level "sequential" API.
+* BSD-style socket API.
+
+The sequential API provides a way for ordinary, sequential, programs
+to use the lwIP stack. It is quite similar to the BSD socket API. The
+model of execution is based on the blocking open-read-write-close
+paradigm. Since the TCP/IP stack is event based by nature, the TCP/IP
+code and the application program must reside in different execution
+contexts (threads).
+
+The socket API is a compatibility API for existing applications,
+currently it is built on top of the sequential API. It is meant to
+provide all functions needed to run socket API applications running
+on other platforms (e.g. unix / windows etc.). However, due to limitations
+in the specification of this API, there might be incompatibilities
+that require small modifications of existing programs.
+
+** Threading
+
+lwIP started targeting single-threaded environments. When adding multi-
+threading support, instead of making the core thread-safe, another
+approach was chosen: there is one main thread running the lwIP core
+(also known as the "tcpip_thread"). The raw API may only be used from
+this thread! Application threads using the sequential- or socket API
+communicate with this main thread through message passing.
+
+      As such, the list of functions that may be called from
+      other threads or an ISR is very limited! Only functions
+      from these API header files are thread-safe:
+      - api.h
+      - netbuf.h
+      - netdb.h
+      - netifapi.h
+      - sockets.h
+      - sys.h
+
+      Additionaly, memory (de-)allocation functions may be
+      called from multiple threads (not ISR!) with NO_SYS=0
+      since they are protected by SYS_LIGHTWEIGHT_PROT and/or
+      semaphores.
+
+      Only since 1.3.0, if SYS_LIGHTWEIGHT_PROT is set to 1
+      and LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT is set to 1,
+      pbuf_free() may also be called from another thread or
+      an ISR (since only then, mem_free - for PBUF_RAM - may
+      be called from an ISR: otherwise, the HEAP is only
+      protected by semaphores).
+      
+
+** The remainder of this document discusses the "raw" API. **
+
+The raw TCP/IP interface allows the application program to integrate
+better with the TCP/IP code. Program execution is event based by
+having callback functions being called from within the TCP/IP
+code. The TCP/IP code and the application program both run in the same
+thread. The sequential API has a much higher overhead and is not very
+well suited for small systems since it forces a multithreaded paradigm
+on the application.
+
+The raw TCP/IP interface is not only faster in terms of code execution
+time but is also less memory intensive. The drawback is that program
+development is somewhat harder and application programs written for
+the raw TCP/IP interface are more difficult to understand. Still, this
+is the preferred way of writing applications that should be small in
+code size and memory usage.
+
+Both APIs can be used simultaneously by different application
+programs. In fact, the sequential API is implemented as an application
+program using the raw TCP/IP interface.
+
+--- Callbacks
+
+Program execution is driven by callbacks. Each callback is an ordinary
+C function that is called from within the TCP/IP code. Every callback
+function is passed the current TCP or UDP connection state as an
+argument. Also, in order to be able to keep program specific state,
+the callback functions are called with a program specified argument
+that is independent of the TCP/IP state.
+
+The function for setting the application connection state is:
+
+- void tcp_arg(struct tcp_pcb *pcb, void *arg)
+
+  Specifies the program specific state that should be passed to all
+  other callback functions. The "pcb" argument is the current TCP
+  connection control block, and the "arg" argument is the argument
+  that will be passed to the callbacks.
+
+  
+--- TCP connection setup
+
+The functions used for setting up connections is similar to that of
+the sequential API and of the BSD socket API. A new TCP connection
+identifier (i.e., a protocol control block - PCB) is created with the
+tcp_new() function. This PCB can then be either set to listen for new
+incoming connections or be explicitly connected to another host.
+
+- struct tcp_pcb *tcp_new(void)
+
+  Creates a new connection identifier (PCB). If memory is not
+  available for creating the new pcb, NULL is returned.
+
+- err_t tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr,
+                 u16_t port)
+
+  Binds the pcb to a local IP address and port number. The IP address
+  can be specified as IP_ADDR_ANY in order to bind the connection to
+  all local IP addresses.
+
+  If another connection is bound to the same port, the function will
+  return ERR_USE, otherwise ERR_OK is returned.
+
+- struct tcp_pcb *tcp_listen(struct tcp_pcb *pcb)
+
+  Commands a pcb to start listening for incoming connections. When an
+  incoming connection is accepted, the function specified with the
+  tcp_accept() function will be called. The pcb will have to be bound
+  to a local port with the tcp_bind() function.
+
+  The tcp_listen() function returns a new connection identifier, and
+  the one passed as an argument to the function will be
+  deallocated. The reason for this behavior is that less memory is
+  needed for a connection that is listening, so tcp_listen() will
+  reclaim the memory needed for the original connection and allocate a
+  new smaller memory block for the listening connection.
+
+  tcp_listen() may return NULL if no memory was available for the
+  listening connection. If so, the memory associated with the pcb
+  passed as an argument to tcp_listen() will not be deallocated.
+
+- struct tcp_pcb *tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
+
+  Same as tcp_listen, but limits the number of outstanding connections
+  in the listen queue to the value specified by the backlog argument.
+  To use it, your need to set TCP_LISTEN_BACKLOG=1 in your lwipopts.h.
+
+- void tcp_accepted(struct tcp_pcb *pcb)
+
+  Inform lwIP that an incoming connection has been accepted. This would
+  usually be called from the accept callback. This allows lwIP to perform
+  housekeeping tasks, such as allowing further incoming connections to be
+  queued in the listen backlog.
+
+- void tcp_accept(struct tcp_pcb *pcb,
+                  err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
+                                   err_t err))
+
+  Specified the callback function that should be called when a new
+  connection arrives on a listening connection.
+      
+- err_t tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr,
+                    u16_t port, err_t (* connected)(void *arg,
+                                                    struct tcp_pcb *tpcb,
+                                                    err_t err));
+
+  Sets up the pcb to connect to the remote host and sends the
+  initial SYN segment which opens the connection. 
+
+  The tcp_connect() function returns immediately; it does not wait for
+  the connection to be properly setup. Instead, it will call the
+  function specified as the fourth argument (the "connected" argument)
+  when the connection is established. If the connection could not be
+  properly established, either because the other host refused the
+  connection or because the other host didn't answer, the "err"
+  callback function of this pcb (registered with tcp_err, see below)
+  will be called.
+
+  The tcp_connect() function can return ERR_MEM if no memory is
+  available for enqueueing the SYN segment. If the SYN indeed was
+  enqueued successfully, the tcp_connect() function returns ERR_OK.
+
+  
+--- Sending TCP data
+
+TCP data is sent by enqueueing the data with a call to
+tcp_write(). When the data is successfully transmitted to the remote
+host, the application will be notified with a call to a specified
+callback function.
+
+- err_t tcp_write(struct tcp_pcb *pcb, void *dataptr, u16_t len,
+                  u8_t copy)
+
+  Enqueues the data pointed to by the argument dataptr. The length of
+  the data is passed as the len parameter. The copy argument is either
+  0 or 1 and indicates whether the new memory should be allocated for
+  the data to be copied into. If the argument is 0, no new memory
+  should be allocated and the data should only be referenced by
+  pointer.
+
+  The tcp_write() function will fail and return ERR_MEM if the length
+  of the data exceeds the current send buffer size or if the length of
+  the queue of outgoing segment is larger than the upper limit defined
+  in lwipopts.h. The number of bytes available in the output queue can
+  be retrieved with the tcp_sndbuf() function.
+
+  The proper way to use this function is to call the function with at
+  most tcp_sndbuf() bytes of data. If the function returns ERR_MEM,
+  the application should wait until some of the currently enqueued
+  data has been successfully received by the other host and try again.
+
+- void tcp_sent(struct tcp_pcb *pcb,
+                err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
+                u16_t len))
+
+  Specifies the callback function that should be called when data has
+  successfully been received (i.e., acknowledged) by the remote
+  host. The len argument passed to the callback function gives the
+  amount bytes that was acknowledged by the last acknowledgment.
+
+  
+--- Receiving TCP data
+
+TCP data reception is callback based - an application specified
+callback function is called when new data arrives. When the
+application has taken the data, it has to call the tcp_recved()
+function to indicate that TCP can advertise increase the receive
+window.
+
+- void tcp_recv(struct tcp_pcb *pcb,
+                err_t (* recv)(void *arg, struct tcp_pcb *tpcb,
+                               struct pbuf *p, err_t err))
+
+  Sets the callback function that will be called when new data
+  arrives. The callback function will be passed a NULL pbuf to
+  indicate that the remote host has closed the connection. If
+  there are no errors and the callback function is to return
+  ERR_OK, then it must free the pbuf. Otherwise, it must not
+  free the pbuf so that lwIP core code can store it.
+
+- void tcp_recved(struct tcp_pcb *pcb, u16_t len)
+
+  Must be called when the application has received the data. The len
+  argument indicates the length of the received data.
+    
+
+--- Application polling
+
+When a connection is idle (i.e., no data is either transmitted or
+received), lwIP will repeatedly poll the application by calling a
+specified callback function. This can be used either as a watchdog
+timer for killing connections that have stayed idle for too long, or
+as a method of waiting for memory to become available. For instance,
+if a call to tcp_write() has failed because memory wasn't available,
+the application may use the polling functionality to call tcp_write()
+again when the connection has been idle for a while.
+
+- void tcp_poll(struct tcp_pcb *pcb, u8_t interval,
+                err_t (* poll)(void *arg, struct tcp_pcb *tpcb))
+
+  Specifies the polling interval and the callback function that should
+  be called to poll the application. The interval is specified in
+  number of TCP coarse grained timer shots, which typically occurs
+  twice a second. An interval of 10 means that the application would
+  be polled every 5 seconds.
+
+
+--- Closing and aborting connections
+
+- err_t tcp_close(struct tcp_pcb *pcb)
+
+  Closes the connection. The function may return ERR_MEM if no memory
+  was available for closing the connection. If so, the application
+  should wait and try again either by using the acknowledgment
+  callback or the polling functionality. If the close succeeds, the
+  function returns ERR_OK.
+
+  The pcb is deallocated by the TCP code after a call to tcp_close(). 
+
+- void tcp_abort(struct tcp_pcb *pcb)
+
+  Aborts the connection by sending a RST (reset) segment to the remote
+  host. The pcb is deallocated. This function never fails.
+
+If a connection is aborted because of an error, the application is
+alerted of this event by the err callback. Errors that might abort a
+connection are when there is a shortage of memory. The callback
+function to be called is set using the tcp_err() function.
+
+- void tcp_err(struct tcp_pcb *pcb, void (* err)(void *arg,
+       err_t err))
+
+  The error callback function does not get the pcb passed to it as a
+  parameter since the pcb may already have been deallocated.
+
+
+--- Lower layer TCP interface
+
+TCP provides a simple interface to the lower layers of the
+system. During system initialization, the function tcp_init() has
+to be called before any other TCP function is called. When the system
+is running, the two timer functions tcp_fasttmr() and tcp_slowtmr()
+must be called with regular intervals. The tcp_fasttmr() should be
+called every TCP_FAST_INTERVAL milliseconds (defined in tcp.h) and
+tcp_slowtmr() should be called every TCP_SLOW_INTERVAL milliseconds. 
+
+
+--- UDP interface
+
+The UDP interface is similar to that of TCP, but due to the lower
+level of complexity of UDP, the interface is significantly simpler.
+
+- struct udp_pcb *udp_new(void)
+
+  Creates a new UDP pcb which can be used for UDP communication. The
+  pcb is not active until it has either been bound to a local address
+  or connected to a remote address.
+
+- void udp_remove(struct udp_pcb *pcb)
+
+  Removes and deallocates the pcb.  
+  
+- err_t udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr,
+                 u16_t port)
+
+  Binds the pcb to a local address. The IP-address argument "ipaddr"
+  can be IP_ADDR_ANY to indicate that it should listen to any local IP
+  address. The function currently always return ERR_OK.
+
+- err_t udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr,
+                    u16_t port)
+
+  Sets the remote end of the pcb. This function does not generate any
+  network traffic, but only set the remote address of the pcb.
+
+- err_t udp_disconnect(struct udp_pcb *pcb)
+
+  Remove the remote end of the pcb. This function does not generate
+  any network traffic, but only removes the remote address of the pcb.
+
+- err_t udp_send(struct udp_pcb *pcb, struct pbuf *p)
+
+  Sends the pbuf p. The pbuf is not deallocated.
+
+- void udp_recv(struct udp_pcb *pcb,
+                void (* recv)(void *arg, struct udp_pcb *upcb,
+                                         struct pbuf *p,
+                                         struct ip_addr *addr,
+                                         u16_t port),
+                              void *recv_arg)
+
+  Specifies a callback function that should be called when a UDP
+  datagram is received.
+  
+
+--- System initalization
+
+A truly complete and generic sequence for initializing the lwip stack
+cannot be given because it depends on the build configuration (lwipopts.h)
+and additional initializations for your runtime environment (e.g. timers).
+
+We can give you some idea on how to proceed when using the raw API.
+We assume a configuration using a single Ethernet netif and the
+UDP and TCP transport layers, IPv4 and the DHCP client.
+
+Call these functions in the order of appearance:
+
+- stats_init()
+
+  Clears the structure where runtime statistics are gathered.
+
+- sys_init()
+  
+  Not of much use since we set the NO_SYS 1 option in lwipopts.h,
+  to be called for easy configuration changes.
+
+- mem_init()
+
+  Initializes the dynamic memory heap defined by MEM_SIZE.
+
+- memp_init()
+
+  Initializes the memory pools defined by MEMP_NUM_x.
+
+- pbuf_init()
+
+  Initializes the pbuf memory pool defined by PBUF_POOL_SIZE.
+  
+- etharp_init()
+
+  Initializes the ARP table and queue.
+  Note: you must call etharp_tmr at a ARP_TMR_INTERVAL (5 seconds) regular interval
+  after this initialization.
+
+- ip_init()
+
+  Doesn't do much, it should be called to handle future changes.
+
+- udp_init()
+
+  Clears the UDP PCB list.
+
+- tcp_init()
+
+  Clears the TCP PCB list and clears some internal TCP timers.
+  Note: you must call tcp_fasttmr() and tcp_slowtmr() at the
+  predefined regular intervals after this initialization. 
+  
+- netif_add(struct netif *netif, struct ip_addr *ipaddr,
+            struct ip_addr *netmask, struct ip_addr *gw,
+            void *state, err_t (* init)(struct netif *netif),
+            err_t (* input)(struct pbuf *p, struct netif *netif))
+
+  Adds your network interface to the netif_list. Allocate a struct
+  netif and pass a pointer to this structure as the first argument.
+  Give pointers to cleared ip_addr structures when using DHCP,
+  or fill them with sane numbers otherwise. The state pointer may be NULL.
+
+  The init function pointer must point to a initialization function for
+  your ethernet netif interface. The following code illustrates it's use.
+  
+  err_t netif_if_init(struct netif *netif)
+  {
+    u8_t i;
+    
+    for(i = 0; i < ETHARP_HWADDR_LEN; i++) netif->hwaddr[i] = some_eth_addr[i];
+    init_my_eth_device();
+    return ERR_OK;
+  }
+  
+  For ethernet drivers, the input function pointer must point to the lwip
+  function ethernet_input() declared in "netif/etharp.h". Other drivers
+  must use ip_input() declared in "lwip/ip.h".
+  
+- netif_set_default(struct netif *netif)
+
+  Registers the default network interface.
+
+- netif_set_up(struct netif *netif)
+
+  When the netif is fully configured this function must be called.
+
+- dhcp_start(struct netif *netif)
+
+  Creates a new DHCP client for this interface on the first call.
+  Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
+  the predefined regular intervals after starting the client.
+  
+  You can peek in the netif->dhcp struct for the actual DHCP status.
+
+
+--- Optimalization hints
+
+The first thing you want to optimize is the lwip_standard_checksum()
+routine from src/core/inet.c. You can override this standard
+function with the #define LWIP_CHKSUM <your_checksum_routine>.
+
+There are C examples given in inet.c or you might want to
+craft an assembly function for this. RFC1071 is a good
+introduction to this subject.
+
+Other significant improvements can be made by supplying
+assembly or inline replacements for htons() and htonl()
+if you're using a little-endian architecture.
+#define LWIP_PLATFORM_BYTESWAP 1
+#define LWIP_PLATFORM_HTONS(x) <your_htons>
+#define LWIP_PLATFORM_HTONL(x) <your_htonl>
+
+Check your network interface driver if it reads at
+a higher speed than the maximum wire-speed. If the
+hardware isn't serviced frequently and fast enough
+buffer overflows are likely to occur.
+
+E.g. when using the cs8900 driver, call cs8900if_service(ethif)
+as frequently as possible. When using an RTOS let the cs8900 interrupt
+wake a high priority task that services your driver using a binary
+semaphore or event flag. Some drivers might allow additional tuning
+to match your application and network.
+
+For a production release it is recommended to set LWIP_STATS to 0.
+Note that speed performance isn't influenced much by simply setting
+high values to the memory options.
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/doc/savannah.txt
@@ -0,0 +1,135 @@
+Daily Use Guide for using Savannah for lwIP
+
+Table of Contents:
+
+1 - Obtaining lwIP from the CVS repository
+2 - Committers/developers CVS access using SSH (to be written)
+3 - Merging from DEVEL branch to main trunk (stable branch)
+4 - How to release lwIP
+
+
+
+1 Obtaining lwIP from the CVS repository
+----------------------------------------
+
+To perform an anonymous CVS checkout of the main trunk (this is where
+bug fixes and incremental enhancements occur), do this:
+
+cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout lwip
+ 
+Or, obtain a stable branch (updated with bug fixes only) as follows:
+cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \
+  -r STABLE-0_7 -d lwip-0.7 lwip
+
+Or, obtain a specific (fixed) release as follows:
+cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \
+  -r STABLE-0_7_0 -d lwip-0.7.0 lwip
+
+3 Committers/developers CVS access using SSH
+--------------------------------------------
+
+The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption.
+As such, CVS commits to the server occur through a SSH tunnel for project members.
+To create a SSH2 key pair in UNIX-like environments, do this:
+
+ssh-keygen -t dsa
+
+Under Windows, a recommended SSH client is "PuTTY", freely available with good
+documentation and a graphic user interface. Use its key generator.
+
+Now paste the id_dsa.pub contents into your Savannah account public key list. Wait
+a while so that Savannah can update its configuration (This can take minutes).
+
+Try to login using SSH:
+
+ssh -v your_login@cvs.sv.gnu.org
+
+If it tells you:
+
+Authenticating with public key "your_key_name"...
+Server refused to allocate pty
+
+then you could login; Savannah refuses to give you a shell - which is OK, as we
+are allowed to use SSH for CVS only. Now, you should be able to do this:
+
+export CVS_RSH=ssh
+cvs -z3 -d:ext:your_login@cvs.sv.gnu.org:/sources/lwip co lwip
+ 
+after which you can edit your local files with bug fixes or new features and
+commit them. Make sure you know what you are doing when using CVS to make
+changes on the repository. If in doubt, ask on the lwip-members mailing list.
+
+(If SSH asks about authenticity of the host, you can check the key
+ fingerprint against http://savannah.nongnu.org/cvs/?group=lwip)
+
+
+3 Merging from DEVEL branch to main trunk (stable)
+--------------------------------------------------
+
+Merging is a delicate process in CVS and requires the
+following disciplined steps in order to prevent conflicts
+in the future. Conflicts can be hard to solve!
+
+Merging from branch A to branch B requires that the A branch
+has a tag indicating the previous merger. This tag is called
+'merged_from_A_to_B'. After merging, the tag is moved in the
+A branch to remember this merger for future merge actions.
+
+IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE
+REPOSITORY, THE TAG MUST BE SET ON THE SOURCE BRANCH OF THE
+MERGE ACTION (REPLACING EXISTING TAGS WITH THE SAME NAME).
+
+Merge all changes in DEVEL since our last merge to main:
+
+In the working copy of the main trunk:
+cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL 
+
+(This will apply the changes between 'merged_from_DEVEL_to_main'
+and 'DEVEL' to your work set of files)
+
+We can now commit the merge result.
+cvs commit -R -m "Merged from DEVEL to main." 
+
+If this worked out OK, we now move the tag in the DEVEL branch
+to this merge point, so we can use this point for future merges:
+
+cvs rtag -F -r DEVEL merged_from_DEVEL_to_main lwip 
+
+4 How to release lwIP
+---------------------
+
+First, checkout a clean copy of the branch to be released. Tag this set with
+tag name "STABLE-0_6_3". (I use release number 0.6.3 throughout this example).
+
+Login CVS using pserver authentication, then export a clean copy of the
+tagged tree. Export is similar to a checkout, except that the CVS metadata
+is not created locally. 
+
+export CVS_RSH=ssh
+cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \
+  -r STABLE-0_6_3 -d lwip-0.6.3 lwip
+
+Archive this directory using tar, gzip'd, bzip2'd and zip'd.
+
+tar czvf lwip-0.6.3.tar.gz lwip-0.6.3
+tar cjvf lwip-0.6.3.tar.bz2 lwip-0.6.3
+zip -r lwip-0.6.3.zip lwip-0.6.3
+
+Now, sign the archives with a detached GPG binary signature as follows:
+
+gpg -b lwip-0.6.3.tar.gz
+gpg -b lwip-0.6.3.tar.bz2
+gpg -b lwip-0.6.3.zip
+
+Upload these files using anonymous FTP:
+ncftp ftp://savannah.gnu.org/incoming/savannah/lwip
+
+ncftp>mput *0.6.3.*
+
+Additionally, you may post a news item on Savannah, like this:
+
+A new 0.6.3 release is now available here:
+http://savannah.nongnu.org/files/?group=lwip&highlight=0.6.3
+
+You will have to submit this via the user News interface, then approve
+this via the Administrator News interface.
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/doc/snmp_agent.txt
@@ -0,0 +1,181 @@
+SNMPv1 agent for lwIP
+
+Author: Christiaan Simons
+
+This is a brief introduction how to use and configure the SNMP agent.
+Note the agent uses the raw-API UDP interface so you may also want to
+read rawapi.txt to gain a better understanding of the SNMP message handling.
+
+0 Agent Capabilities
+====================
+
+SNMPv1 per RFC1157
+  This is an old(er) standard but is still widely supported.
+  For SNMPv2c and v3 have a greater complexity and need many
+  more lines of code. IMHO this breaks the idea of "lightweight IP".
+
+  Note the S in SNMP stands for "Simple". Note that "Simple" is
+  relative. SNMP is simple compared to the complex ISO network
+  management protocols CMIP (Common Management Information Protocol)
+  and CMOT (CMip Over Tcp).
+
+MIB II per RFC1213
+  The standard lwIP stack management information base.
+  This is a required MIB, so this is always enabled.
+  When builing lwIP without TCP, the mib-2.tcp group is omitted.
+  The groups EGP, CMOT and transmission are disabled by default.
+  
+  Most mib-2 objects are not writable except:
+  sysName, sysLocation, sysContact, snmpEnableAuthenTraps.
+  Writing to or changing the ARP and IP address and route
+  tables is not possible.
+ 
+  Note lwIP has a very limited notion of IP routing. It currently
+  doen't have a route table and doesn't have a notion of the U,G,H flags.
+  Instead lwIP uses the interface list with only one default interface
+  acting as a single gateway interface (G) for the default route.
+
+  The agent returns a "virtual table" with the default route 0.0.0.0
+  for the default interface and network routes (no H) for each
+  network interface in the netif_list.
+  All routes are considered to be up (U).
+
+Loading additional MIBs
+  MIBs can only be added in compile-time, not in run-time.
+  There is no MIB compiler thus additional MIBs must be hand coded.
+
+Large SNMP message support
+  The packet decoding and encoding routines are designed
+  to use pbuf-chains. Larger payloads then the minimum
+  SNMP requirement of 484 octets are supported if the 
+  PBUF_POOL_SIZE and IP_REASS_BUFSIZE are set to match your
+  local requirement.
+
+1 Building the Agent
+====================
+
+First of all you'll need to add the following define
+to your local lwipopts.h:
+
+#define LWIP_SNMP               1
+
+and add the source files in lwip/src/core/snmp
+and some snmp headers in lwip/src/include/lwip to your makefile.
+
+Note you'll might need to adapt you network driver to update
+the mib2 variables for your interface.
+
+2 Running the Agent
+===================
+
+The following function calls must be made in your program to
+actually get the SNMP agent running.
+
+Before starting the agent you should supply pointers
+to non-volatile memory for sysContact, sysLocation,
+and snmpEnableAuthenTraps. You can do this by calling
+
+snmp_set_syscontact()
+snmp_set_syslocation()
+snmp_set_snmpenableauthentraps()
+
+Additionally you may want to set
+
+snmp_set_sysdescr()
+snmp_set_sysobjid() (if you have a private MIB)
+snmp_set_sysname()
+
+Also before starting the agent you need to setup
+one or more trap destinations using these calls:
+
+snmp_trap_dst_enable();
+snmp_trap_dst_ip_set();
+
+In the lwIP initialisation sequence call snmp_init() just after
+the call to udp_init().
+
+Exactly every 10 msec the SNMP uptime timestamp must be updated with
+snmp_inc_sysuptime(). You should call this from a timer interrupt
+or a timer signal handler depending on your runtime environment.
+
+An alternative way to update the SNMP uptime timestamp is to do a call like
+snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but call to
+a lower frequency). Another one is to not call snmp_inc_sysuptime() or
+snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro.
+This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside
+snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only
+when it's queried (any function which need "sysuptime" have to call
+snmp_get_sysuptime).
+
+
+3 Private MIBs
+==============
+
+If want to extend the agent with your own private MIB you'll need to
+add the following define to your local lwipopts.h:
+
+#define SNMP_PRIVATE_MIB        1
+
+You must provide the private_mib.h and associated files yourself.
+Note we don't have a "MIB compiler" that generates C source from a MIB,
+so you're required to do some serious coding if you enable this!
+
+Note the lwIP enterprise ID (26381) is assigned to the lwIP project,
+ALL OBJECT IDENTIFIERS LIVING UNDER THIS ID ARE ASSIGNED BY THE lwIP
+MAINTAINERS!
+
+If you need to create your own private MIB you'll need
+to apply for your own enterprise ID with IANA: http://www.iana.org/numbers.html 
+
+You can set it by passing a struct snmp_obj_id to the agent
+using snmp_set_sysobjid(&my_object_id), just before snmp_init().
+
+Note the object identifiers for thes MIB-2 and your private MIB
+tree must be kept in sorted ascending (lexicographical) order.
+This to ensure correct getnext operation.
+
+An example for a private MIB is part of the "minimal Unix" project:
+contrib/ports/unix/proj/minimal/lwip_prvmib.c
+
+The next chapter gives a more detailed description of the
+MIB-2 tree and the optional private MIB.
+
+4 The Gory Details
+==================
+
+4.0 Object identifiers and the MIB tree.
+
+We have three distinct parts for all object identifiers:
+
+The prefix
+  .iso.org.dod.internet
+
+the middle part 
+  .mgmt.mib-2.ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress
+
+and the index part
+  .1.192.168.0.1
+
+Objects located above the .internet hierarchy aren't supported.
+Currently only the .mgmt sub-tree is available and
+when the SNMP_PRIVATE_MIB is enabled the .private tree
+becomes available too.
+
+Object identifiers from incoming requests are checked
+for a matching prefix, middle part and index part
+or are expanded(*) for GetNext requests with short
+or inexisting names in the request.
+(* we call this "expansion" but this also
+resembles the "auto-completion" operation)
+
+The middle part is usually located in ROM (const)
+to preserve precious RAM on small microcontrollers.
+However RAM location is possible for an dynamically
+changing private tree.
+
+The index part is handled by functions which in
+turn use dynamically allocated index trees from RAM.
+These trees are updated by e.g. the etharp code
+when new entries are made or removed form the ARP cache.
+
+/** @todo more gory details */
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/doc/sys_arch.txt
@@ -0,0 +1,228 @@
+sys_arch interface for lwIP 0.6++
+
+Author: Adam Dunkels
+
+The operating system emulation layer provides a common interface
+between the lwIP code and the underlying operating system kernel. The
+general idea is that porting lwIP to new architectures requires only
+small changes to a few header files and a new sys_arch
+implementation. It is also possible to do a sys_arch implementation
+that does not rely on any underlying operating system.
+
+The sys_arch provides semaphores and mailboxes to lwIP. For the full
+lwIP functionality, multiple threads support can be implemented in the
+sys_arch, but this is not required for the basic lwIP
+functionality. Previous versions of lwIP required the sys_arch to
+implement timer scheduling as well but as of lwIP 0.5 this is
+implemented in a higher layer.
+
+In addition to the source file providing the functionality of sys_arch,
+the OS emulation layer must provide several header files defining
+macros used throughout lwip.  The files required and the macros they
+must define are listed below the sys_arch description.
+
+Semaphores can be either counting or binary - lwIP works with both
+kinds. Mailboxes are used for message passing and can be implemented
+either as a queue which allows multiple messages to be posted to a
+mailbox, or as a rendez-vous point where only one message can be
+posted at a time. lwIP works with both kinds, but the former type will
+be more efficient. A message in a mailbox is just a pointer, nothing
+more. 
+
+Semaphores are represented by the type "sys_sem_t" which is typedef'd
+in the sys_arch.h file. Mailboxes are equivalently represented by the
+type "sys_mbox_t". lwIP does not place any restrictions on how
+sys_sem_t or sys_mbox_t are represented internally.
+
+The following functions must be implemented by the sys_arch:
+
+- void sys_init(void)
+
+  Is called to initialize the sys_arch layer.
+
+- sys_sem_t sys_sem_new(u8_t count)
+
+  Creates and returns a new semaphore. The "count" argument specifies
+  the initial state of the semaphore.
+
+- void sys_sem_free(sys_sem_t sem)
+
+  Deallocates a semaphore.
+
+- void sys_sem_signal(sys_sem_t sem)
+
+  Signals a semaphore.
+
+- u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
+
+  Blocks the thread while waiting for the semaphore to be
+  signaled. If the "timeout" argument is non-zero, the thread should
+  only be blocked for the specified time (measured in
+  milliseconds). If the "timeout" argument is zero, the thread should be
+  blocked until the semaphore is signalled.
+
+  If the timeout argument is non-zero, the return value is the number of
+  milliseconds spent waiting for the semaphore to be signaled. If the
+  semaphore wasn't signaled within the specified time, the return value is
+  SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
+  (i.e., it was already signaled), the function may return zero.
+
+  Notice that lwIP implements a function with a similar name,
+  sys_sem_wait(), that uses the sys_arch_sem_wait() function.
+
+- sys_mbox_t sys_mbox_new(int size)
+
+  Creates an empty mailbox for maximum "size" elements. Elements stored
+  in mailboxes are pointers. You have to define macros "_MBOX_SIZE"
+  in your lwipopts.h, or ignore this parameter in your implementation
+  and use a default size.
+
+- void sys_mbox_free(sys_mbox_t mbox)
+
+  Deallocates a mailbox. If there are messages still present in the
+  mailbox when the mailbox is deallocated, it is an indication of a
+  programming error in lwIP and the developer should be notified.
+
+- void sys_mbox_post(sys_mbox_t mbox, void *msg)
+
+  Posts the "msg" to the mailbox. This function have to block until
+  the "msg" is really posted.
+
+- err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg)
+
+  Try to post the "msg" to the mailbox. Returns ERR_MEM if this one
+  is full, else, ERR_OK if the "msg" is posted.
+
+- u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
+
+  Blocks the thread until a message arrives in the mailbox, but does
+  not block the thread longer than "timeout" milliseconds (similar to
+  the sys_arch_sem_wait() function). If "timeout" is 0, the thread should
+  be blocked until a message arrives. The "msg" argument is a result
+  parameter that is set by the function (i.e., by doing "*msg =
+  ptr"). The "msg" parameter maybe NULL to indicate that the message
+  should be dropped.
+
+  The return values are the same as for the sys_arch_sem_wait() function:
+  Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
+  timeout.
+
+  Note that a function with a similar name, sys_mbox_fetch(), is
+  implemented by lwIP. 
+
+- u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg)
+
+  This is similar to sys_arch_mbox_fetch, however if a message is not
+  present in the mailbox, it immediately returns with the code
+  SYS_MBOX_EMPTY. On success 0 is returned.
+
+  To allow for efficient implementations, this can be defined as a
+  function-like macro in sys_arch.h instead of a normal function. For
+  example, a naive implementation could be:
+    #define sys_arch_mbox_tryfetch(mbox,msg) \
+      sys_arch_mbox_fetch(mbox,msg,1)
+  although this would introduce unnecessary delays.
+  
+- struct sys_timeouts *sys_arch_timeouts(void)
+
+  Returns a pointer to the per-thread sys_timeouts structure. In lwIP,
+  each thread has a list of timeouts which is repressented as a linked
+  list of sys_timeout structures. The sys_timeouts structure holds a
+  pointer to a linked list of timeouts. This function is called by
+  the lwIP timeout scheduler and must not return a NULL value. 
+
+  In a single thread sys_arch implementation, this function will
+  simply return a pointer to a global sys_timeouts variable stored in
+  the sys_arch module.
+  
+If threads are supported by the underlying operating system and if
+such functionality is needed in lwIP, the following function will have
+to be implemented as well:
+
+- sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio)
+
+  Starts a new thread named "name" with priority "prio" that will begin its
+  execution in the function "thread()". The "arg" argument will be passed as an
+  argument to the thread() function. The stack size to used for this thread is
+  the "stacksize" parameter. The id of the new thread is returned. Both the id
+  and the priority are system dependent.
+
+- sys_prot_t sys_arch_protect(void)
+
+  This optional function does a "fast" critical region protection and returns
+  the previous protection level. This function is only called during very short
+  critical regions. An embedded system which supports ISR-based drivers might
+  want to implement this function by disabling interrupts. Task-based systems
+  might want to implement this by using a mutex or disabling tasking. This
+  function should support recursive calls from the same task or interrupt. In
+  other words, sys_arch_protect() could be called while already protected. In
+  that case the return value indicates that it is already protected.
+
+  sys_arch_protect() is only required if your port is supporting an operating
+  system.
+
+- void sys_arch_unprotect(sys_prot_t pval)
+
+  This optional function does a "fast" set of critical region protection to the
+  value specified by pval. See the documentation for sys_arch_protect() for
+  more information. This function is only required if your port is supporting
+  an operating system.
+
+Note:
+
+Be carefull with using mem_malloc() in sys_arch. When malloc() refers to
+mem_malloc() you can run into a circular function call problem. In mem.c
+mem_init() tries to allcate a semaphore using mem_malloc, which of course
+can't be performed when sys_arch uses mem_malloc.
+
+-------------------------------------------------------------------------------
+Additional files required for the "OS support" emulation layer:
+-------------------------------------------------------------------------------
+
+cc.h       - Architecture environment, some compiler specific, some
+             environment specific (probably should move env stuff 
+             to sys_arch.h.)
+
+  Typedefs for the types used by lwip -
+    u8_t, s8_t, u16_t, s16_t, u32_t, s32_t, mem_ptr_t
+
+  Compiler hints for packing lwip's structures -
+    PACK_STRUCT_FIELD(x)
+    PACK_STRUCT_STRUCT
+    PACK_STRUCT_BEGIN
+    PACK_STRUCT_END
+
+  Platform specific diagnostic output -
+    LWIP_PLATFORM_DIAG(x)    - non-fatal, print a message.
+    LWIP_PLATFORM_ASSERT(x)  - fatal, print message and abandon execution.
+    Portability defines for printf formatters:
+    U16_F, S16_F, X16_F, U32_F, S32_F, X32_F, SZT_F
+
+  "lightweight" synchronization mechanisms -
+    SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable.
+    SYS_ARCH_PROTECT(x)      - enter protection mode.
+    SYS_ARCH_UNPROTECT(x)    - leave protection mode.
+
+  If the compiler does not provide memset() this file must include a
+  definition of it, or include a file which defines it.
+
+  This file must either include a system-local <errno.h> which defines
+  the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO
+  to make lwip/arch.h define the codes which are used throughout.
+
+
+perf.h     - Architecture specific performance measurement.
+  Measurement calls made throughout lwip, these can be defined to nothing.
+    PERF_START               - start measuring something.
+    PERF_STOP(x)             - stop measuring something, and record the result.
+
+sys_arch.h - Tied to sys_arch.c
+
+  Arch dependent types for the following objects:
+    sys_sem_t, sys_mbox_t, sys_thread_t,
+  And, optionally:
+    sys_prot_t
+
+  Defines to set vars of sys_mbox_t and sys_sem_t to NULL.
+    SYS_MBOX_NULL NULL
+    SYS_SEM_NULL NULL
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/host/extractdump.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import sys
+import re
+import binascii
+
+def extract_pppdump(input, output):
+
+	fi = open(input, "r")
+	fo = open(output, "wb")
+	p = re.compile("PPPDUMP:(.*)")
+	for line in fi.readlines():
+		m = p.match(line)
+		if m == None:
+			continue
+		hex = m.group(1).strip()
+		data = binascii.unhexlify(hex)
+		fo.write(data)
+	fi.close()
+	fo.close()
+
+# command line parsing
+if len(sys.argv) != 3:
+	print "Usage: extractdump.py [input] [output]"
+	sys.exit()
+
+extract_pppdump(sys.argv[1], sys.argv[2])
--- a/packages/net/lwip_tcpip/current/include/arch/cc.h
+++ b/packages/net/lwip_tcpip/current/include/arch/cc.h
@@ -1,99 +1,93 @@
 //==========================================================================
-// ####ECOSGPLCOPYRIGHTBEGIN####                                            
-// -------------------------------------------                              
-// This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2008 Free Software Foundation
 //
-// eCos is free software; you can redistribute it and/or modify it under    
-// the terms of the GNU General Public License as published by the Free     
-// Software Foundation; either version 2 or (at your option) any later      
-// version.                                                                 
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
 //
-// eCos is distributed in the hope that it will be useful, but WITHOUT      
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
-// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
-// for more details.                                                        
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
 //
-// You should have received a copy of the GNU General Public License        
-// along with eCos; if not, write to the Free Software Foundation, Inc.,    
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 //
-// As a special exception, if other files instantiate templates or use      
-// macros or inline functions from this file, or you compile this file      
-// and link it with other works to produce a work based on this file,       
-// this file does not by itself cause the resulting work to be covered by   
-// the GNU General Public License. However the source code for this file    
-// must still be made available in accordance with section (3) of the GNU   
-// General Public License v2.                                               
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
 //
-// This exception does not invalidate any other reasons why a work based    
-// on this file might be covered by the GNU General Public License.         
-// -------------------------------------------                              
-// ####ECOSGPLCOPYRIGHTEND####                                              
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
 //==========================================================================
 
-/*
- * Copyright (c) 2001, Swedish Institute of Computer Science.
- * 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, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
- * 3. Neither the name of the Institute nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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 <adam@sics.se>
- *
- */
-#ifndef __ARCH_CC_H__
-#define __ARCH_CC_H__
+#ifndef __LWIP_ARCH_CC_H__
+#define __LWIP_ARCH_CC_H__
 
 #include <string.h>
 #include <cyg/error/codes.h>
-//while EFAULT should have no meaning in eCos since there are no address spaces
-//it is defined here because set/getsockopt in lwIP use it.
-#define EFAULT 14
+#include <cyg/infra/cyg_type.h>
+
+typedef int sys_prot_t;
+
+#define LWIP_ERR_T int
 
-//found no better place for this prototype
-int lwip_init(void);
+// Define error codes used by lwIP but not by eCos
+#define EFAULT          14
+#define ELOOP           40
+#define ETIME           62
+#define ENSRNOTFOUND    163
 
-//#define LWIP_PROVIDE_ERRNO
-#include <cyg/infra/cyg_type.h>
+// Platform byteorder
 #if (CYG_BYTEORDER == CYG_LSBFIRST)
 #define BYTE_ORDER LITTLE_ENDIAN
 #else
 #define BYTE_ORDER BIG_ENDIAN
 #endif
 
+// Define generic types used in lwIP
+#ifndef __U8_T__
+typedef unsigned char u8_t;
+# define __U8_T__
+#endif
 
-typedef unsigned   char    u8_t;
-typedef signed     char    s8_t;
-typedef unsigned   short   u16_t;
-typedef signed     short   s16_t;
-typedef unsigned   long    u32_t;
-typedef signed     long    s32_t;
-typedef unsigned long	mem_ptr_t;
+#ifndef __S8_T__
+typedef signed char s8_t;
+# define __S8_T__
+#endif
+
+#ifndef __U16_T__
+typedef unsigned short u16_t;
+# define __U16_T__
+#endif
 
+#ifndef __S16_T__
+typedef signed short s16_t;
+# define __S16_T__
+#endif
+
+#ifndef __U32_T__
+typedef unsigned long u32_t;
+# define __U32_T__
+#endif
+
+#ifndef __S32_T__
+typedef signed long s32_t;
+# define __S32_T__
+#endif
+
+typedef unsigned    long    mem_ptr_t;
+
+// Define (sn)printf formatters for these lwIP types
 #define U16_F "u"
 #define S16_F "d"
 #define X16_F "x"
@@ -101,18 +95,17 @@ typedef unsigned long	mem_ptr_t;
 #define S32_F "ld"
 #define X32_F "lx"
 
-#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
+// Compiler hints for packing structures
+#define PACK_STRUCT_FIELD(x) x
 #define PACK_STRUCT_STRUCT __attribute__((packed))
 #define PACK_STRUCT_BEGIN
 #define PACK_STRUCT_END
 
+// Prototypes for printf() and abort()
 #include <cyg/infra/diag.h>
 #include <cyg/infra/cyg_ass.h>
-#define LWIP_PLATFORM_DIAG(x)	{diag_printf x;}
-#define LWIP_PLATFORM_ASSERT(x) {CYG_FAIL(x);}
+// Plaform specific diagnostic output
+#define LWIP_PLATFORM_DIAG(x) do {diag_printf x;} while(0)
+#define LWIP_PLATFORM_ASSERT(x) do {CYG_FAIL(x);} while(0)
 
-#define SYS_ARCH_DECL_PROTECT(x)
-#define SYS_ARCH_PROTECT(x)
-#define SYS_ARCH_UNPROTECT(x)
-
-#endif /* __ARCH_CC_H__ */
+#endif // __LWIP_ARCH_CC_H__
--- a/packages/net/lwip_tcpip/current/include/arch/perf.h
+++ b/packages/net/lwip_tcpip/current/include/arch/perf.h
@@ -1,74 +1,39 @@
 //==========================================================================
-// ####ECOSGPLCOPYRIGHTBEGIN####                                            
-// -------------------------------------------                              
-// This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2008 Free Software Foundation
 //
-// eCos is free software; you can redistribute it and/or modify it under    
-// the terms of the GNU General Public License as published by the Free     
-// Software Foundation; either version 2 or (at your option) any later      
-// version.                                                                 
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
 //
-// eCos is distributed in the hope that it will be useful, but WITHOUT      
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
-// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
-// for more details.                                                        
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
 //
-// You should have received a copy of the GNU General Public License        
-// along with eCos; if not, write to the Free Software Foundation, Inc.,    
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 //
-// As a special exception, if other files instantiate templates or use      
-// macros or inline functions from this file, or you compile this file      
-// and link it with other works to produce a work based on this file,       
-// this file does not by itself cause the resulting work to be covered by   
-// the GNU General Public License. However the source code for this file    
-// must still be made available in accordance with section (3) of the GNU   
-// General Public License v2.                                               
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
 //
-// This exception does not invalidate any other reasons why a work based    
-// on this file might be covered by the GNU General Public License.         
-// -------------------------------------------                              
-// ####ECOSGPLCOPYRIGHTEND####                                              
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
 //==========================================================================
 
-/*
- * Copyright (c) 2001, Swedish Institute of Computer Science.
- * 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, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
- * 3. Neither the name of the Institute nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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 <adam@sics.se>
- *
- */
-#ifndef __PERF_H__
-#define __PERF_H__
+#ifndef __LWIP_PERF_H__
+#define __LWIP_PERF_H__
 
 #define PERF_START    /* null definition */
 #define PERF_STOP(x)  /* null definition */
 
-#endif /* __PERF_H__ */
+#endif // __LWIP_PERF_H__
--- a/packages/net/lwip_tcpip/current/include/arch/sys_arch.h
+++ b/packages/net/lwip_tcpip/current/include/arch/sys_arch.h
@@ -1,47 +1,51 @@
 //==========================================================================
-// ####ECOSGPLCOPYRIGHTBEGIN####                                            
-// -------------------------------------------                              
-// This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2008 Free Software Foundation
 //
-// eCos is free software; you can redistribute it and/or modify it under    
-// the terms of the GNU General Public License as published by the Free     
-// Software Foundation; either version 2 or (at your option) any later      
-// version.                                                                 
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
 //
-// eCos is distributed in the hope that it will be useful, but WITHOUT      
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
-// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
-// for more details.                                                        
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
 //
-// You should have received a copy of the GNU General Public License        
-// along with eCos; if not, write to the Free Software Foundation, Inc.,    
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 //
-// As a special exception, if other files instantiate templates or use      
-// macros or inline functions from this file, or you compile this file      
-// and link it with other works to produce a work based on this file,       
-// this file does not by itself cause the resulting work to be covered by   
-// the GNU General Public License. However the source code for this file    
-// must still be made available in accordance with section (3) of the GNU   
-// General Public License v2.                                               
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
 //
-// This exception does not invalidate any other reasons why a work based    
-// on this file might be covered by the GNU General Public License.         
-// -------------------------------------------                              
-// ####ECOSGPLCOPYRIGHTEND####                                              
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
 //==========================================================================
 
-#ifndef __SYS_ECOS_H__
-#define __SYS_ECOS_H__
+#ifndef __LWIP_SYS_ARCH_H__
+#define __LWIP_SYS_ARCH_H__
 
 #include <cyg/kernel/kapi.h>
 
-#define SYS_MBOX_NULL (sys_mbox_t)NULL 
-#define SYS_SEM_NULL  (sys_sem_t)NULL
+#include <lwip/opt.h>
+
+#if !NO_SYS
 
-typedef cyg_sem_t*   sys_sem_t;
-typedef cyg_handle_t sys_mbox_t;
-typedef cyg_handle_t sys_thread_t;
-#endif /* __SYS_ECOS_H__ */
+typedef cyg_sem_t *     sys_sem_t;
+typedef cyg_handle_t    sys_mbox_t;
+typedef cyg_handle_t    sys_thread_t;
 
+#define SYS_SEM_NULL    ((sys_sem_t) NULL)
+#define SYS_MBOX_NULL   ((sys_mbox_t) NULL)
+
+#endif // !NO_SYS
+
+#endif // __LWIP_SYS_ARCH_H__
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip.h
@@ -0,0 +1,93 @@
+#ifndef CYGONCE_LWIP_H
+#define CYGONCE_LWIP_H
+//=============================================================================
+//
+//      lwip.h
+//
+//      lwIP networking stack.
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     Simon Kallweit
+// Date:          2008-12-09
+// Purpose:
+// Description:
+//
+//####DESCRIPTIONEND####
+//=============================================================================
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <lwip/opt.h>
+#include <lwip/debug.h>
+#include <lwip/stats.h>
+#include <lwip/tcp.h>
+#include "lwip/sys.h"
+#include "lwip/api.h"
+
+// Serial device id's
+#define SIO_DEV_SLIPIF  0
+#define SIO_DEV_PPPOS   1
+    
+#ifdef CYGFUN_LWIP_MODE_SIMPLE
+
+externC void cyg_lwip_simple_init(void);
+externC void cyg_lwip_simple_restart(void);
+externC void cyg_lwip_simple_poll(void);
+
+#endif // CYGFUN_LWIP_MODE_SIMPLE
+
+
+#ifdef CYGFUN_LWIP_MODE_SEQUENTIAL
+
+externC void cyg_lwip_sequential_init(void);
+
+externC sys_thread_t cyg_lwip_thread_new(char *name,
+                                         void (* thread)(void *arg), void *arg,
+                                         void *stack, int stacksize, int prio);
+
+#endif // CYGFUN_LWIP_MODE_SEQUENTIAL
+
+
+#ifdef __cplusplus
+}
+#endif
+
+//-----------------------------------------------------------------------------
+#endif // CYGONCE_LWIP_H
--- a/packages/net/lwip_tcpip/current/include/lwip/api.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/api.h
@@ -33,33 +33,50 @@
 #define __LWIP_API_H__
 
 #include "lwip/opt.h"
-#include "lwip/pbuf.h"
-#include "lwip/sys.h"
 
-#include "lwip/ip.h"
+#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
 
-#include "lwip/raw.h"
-#include "lwip/udp.h"
-#include "lwip/tcp.h"
+#include <stddef.h> /* for size_t */
 
+#include "lwip/netbuf.h"
+#include "lwip/sys.h"
+#include "lwip/ip_addr.h"
 #include "lwip/err.h"
 
-#define NETCONN_NOCOPY 0x00
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Throughout this file, IP addresses and port numbers are expected to be in
+ * the same byte order as in the corresponding pcb.
+ */
+
+/* Flags for netconn_write */
+#define NETCONN_NOFLAG 0x00
+#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */
 #define NETCONN_COPY   0x01
+#define NETCONN_MORE   0x02
+
+/* Helpers to process several netconn_types by the same code */
+#define NETCONNTYPE_GROUP(t)    (t&0xF0)
+#define NETCONNTYPE_DATAGRAM(t) (t&0xE0)
 
 enum netconn_type {
-  NETCONN_TCP,
-  NETCONN_UDP,
-  NETCONN_UDPLITE,
-  NETCONN_UDPNOCHKSUM,
-  NETCONN_RAW
+  NETCONN_INVALID    = 0,
+  /* NETCONN_TCP Group */
+  NETCONN_TCP        = 0x10,
+  /* NETCONN_UDP Group */
+  NETCONN_UDP        = 0x20,
+  NETCONN_UDPLITE    = 0x21,
+  NETCONN_UDPNOCHKSUM= 0x22,
+  /* NETCONN_RAW Group */
+  NETCONN_RAW        = 0x40
 };
 
 enum netconn_state {
   NETCONN_NONE,
   NETCONN_WRITE,
-  NETCONN_ACCEPT,
-  NETCONN_RECV,
+  NETCONN_LISTEN,
   NETCONN_CONNECT,
   NETCONN_CLOSE
 };
@@ -71,89 +88,135 @@ enum netconn_evt {
   NETCONN_EVT_SENDMINUS
 };
 
-struct netbuf {
-  struct pbuf *p, *ptr;
-  struct ip_addr *fromaddr;
-  u16_t fromport;
-  err_t err;
+#if LWIP_IGMP
+enum netconn_igmp {
+  NETCONN_JOIN,
+  NETCONN_LEAVE
 };
+#endif /* LWIP_IGMP */
 
+/* forward-declare some structs to avoid to include their headers */
+struct ip_pcb;
+struct tcp_pcb;
+struct udp_pcb;
+struct raw_pcb;
+struct netconn;
+
+/** A callback prototype to inform about events for a netconn */
+typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
+
+/** A netconn descriptor */
 struct netconn {
+  /** type of the netconn (TCP, UDP or RAW) */
   enum netconn_type type;
+  /** current state of the netconn */
   enum netconn_state state;
+  /** the lwIP internal protocol control block */
   union {
+    struct ip_pcb  *ip;
     struct tcp_pcb *tcp;
     struct udp_pcb *udp;
     struct raw_pcb *raw;
   } pcb;
+  /** the last error this netconn had */
   err_t err;
-  sys_mbox_t mbox;
+  /** sem that is used to synchroneously execute functions in the core context */
+  sys_sem_t op_completed;
+  /** mbox where received packets are stored until they are fetched
+      by the netconn application thread (can grow quite big) */
   sys_mbox_t recvmbox;
+  /** mbox where new connections are stored until processed
+      by the application thread */
   sys_mbox_t acceptmbox;
-  sys_sem_t sem;
+  /** only used for socket layer */
   int socket;
-  u16_t recv_avail;
-  void (* callback)(struct netconn *, enum netconn_evt, u16_t len);
+#if LWIP_SO_RCVTIMEO
+  /** timeout to wait for new data to be received
+      (or connections to arrive for listening netconns) */
+  int recv_timeout;
+#endif /* LWIP_SO_RCVTIMEO */
+#if LWIP_SO_RCVBUF
+  /** maximum amount of bytes queued in recvmbox */
+  int recv_bufsize;
+#endif /* LWIP_SO_RCVBUF */
+  s16_t recv_avail;
+#if LWIP_TCP
+  /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
+      this temporarily stores the message. */
+  struct api_msg_msg *write_msg;
+  /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
+      this temporarily stores how much is already sent. */
+  size_t write_offset;
+#if LWIP_TCPIP_CORE_LOCKING
+  /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
+      this temporarily stores whether to wake up the original application task
+      if data couldn't be sent in the first try. */
+  u8_t write_delayed;
+#endif /* LWIP_TCPIP_CORE_LOCKING */
+#endif /* LWIP_TCP */
+  /** A callback function that is informed about events for this netconn */
+  netconn_callback callback;
 };
 
-/* Network buffer functions: */
-struct netbuf *   netbuf_new      (void);
-void              netbuf_delete   (struct netbuf *buf);
-void *            netbuf_alloc    (struct netbuf *buf, u16_t size);
-void              netbuf_free     (struct netbuf *buf);
-void              netbuf_ref      (struct netbuf *buf,
-           void *dataptr, u16_t size);
-void              netbuf_chain    (struct netbuf *head,
-           struct netbuf *tail);
-
-u16_t             netbuf_len      (struct netbuf *buf);
-err_t             netbuf_data     (struct netbuf *buf,
-           void **dataptr, u16_t *len);
-s8_t              netbuf_next     (struct netbuf *buf);
-void              netbuf_first    (struct netbuf *buf);
-
-void              netbuf_copy     (struct netbuf *buf,
-           void *dataptr, u16_t len);
-void              netbuf_copy_partial(struct netbuf *buf, void *dataptr, 
-              u16_t len, u16_t offset);
-struct ip_addr *  netbuf_fromaddr (struct netbuf *buf);
-u16_t             netbuf_fromport (struct netbuf *buf);
+/* Register an Network connection event */
+#define API_EVENT(c,e,l) if (c->callback) {         \
+                           (*c->callback)(c, e, l); \
+                         }
 
 /* Network connection functions: */
-struct netconn *  netconn_new     (enum netconn_type type);
+#define netconn_new(t)                  netconn_new_with_proto_and_callback(t, 0, NULL)
+#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
 struct
-netconn *netconn_new_with_callback(enum netconn_type t,
-                                   void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
-struct
-netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u16_t proto,
-                                   void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
+netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
+                                   netconn_callback callback);
 err_t             netconn_delete  (struct netconn *conn);
-enum netconn_type netconn_type    (struct netconn *conn);
-err_t             netconn_peer    (struct netconn *conn,
-           struct ip_addr *addr,
-           u16_t *port);
-err_t             netconn_addr    (struct netconn *conn,
-           struct ip_addr **addr,
-           u16_t *port);
+/** Get the type of a netconn (as enum netconn_type). */
+#define netconn_type(conn) (conn->type)
+
+err_t             netconn_getaddr (struct netconn *conn,
+                                   struct ip_addr *addr,
+                                   u16_t *port,
+                                   u8_t local);
+#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
+#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
+
 err_t             netconn_bind    (struct netconn *conn,
-           struct ip_addr *addr,
-           u16_t port);
+                                   struct ip_addr *addr,
+                                   u16_t port);
 err_t             netconn_connect (struct netconn *conn,
-           struct ip_addr *addr,
-           u16_t port);
+                                   struct ip_addr *addr,
+                                   u16_t port);
 err_t             netconn_disconnect (struct netconn *conn);
-err_t             netconn_listen  (struct netconn *conn);
+err_t             netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
+#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
 struct netconn *  netconn_accept  (struct netconn *conn);
 struct netbuf *   netconn_recv    (struct netconn *conn);
+err_t             netconn_sendto  (struct netconn *conn,
+                                   struct netbuf *buf, struct ip_addr *addr, u16_t port);
 err_t             netconn_send    (struct netconn *conn,
-           struct netbuf *buf);
+                                   struct netbuf *buf);
 err_t             netconn_write   (struct netconn *conn,
-           void *dataptr, u16_t size,
-           u8_t copy);
+                                   const void *dataptr, size_t size,
+                                   u8_t apiflags);
 err_t             netconn_close   (struct netconn *conn);
 
-err_t             netconn_err     (struct netconn *conn);
+#if LWIP_IGMP
+err_t             netconn_join_leave_group (struct netconn *conn,
+                                            struct ip_addr *multiaddr,
+                                            struct ip_addr *interface,
+                                            enum netconn_igmp join_or_leave);
+#endif /* LWIP_IGMP */
+#if LWIP_DNS
+err_t             netconn_gethostbyname(const char *name, struct ip_addr *addr);
+#endif /* LWIP_DNS */
+
+#define netconn_err(conn)          ((conn)->err)
+#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_NETCONN */
 
 #endif /* __LWIP_API_H__ */
-
-
--- a/packages/net/lwip_tcpip/current/include/lwip/api_msg.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/api_msg.h
@@ -33,62 +33,130 @@
 #define __LWIP_API_MSG_H__
 
 #include "lwip/opt.h"
-#include "lwip/pbuf.h"
-#include "lwip/sys.h"
+
+#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
+
+#include <stddef.h> /* for size_t */
 
-#include "lwip/ip.h"
-
-#include "lwip/udp.h"
-#include "lwip/tcp.h"
-
+#include "lwip/ip_addr.h"
+#include "lwip/err.h"
+#include "lwip/sys.h"
+#include "lwip/igmp.h"
 #include "lwip/api.h"
 
-enum api_msg_type {
-  API_MSG_NEWCONN,
-  API_MSG_DELCONN,
-  
-  API_MSG_BIND,
-  API_MSG_CONNECT,
-  API_MSG_DISCONNECT,
-
-  API_MSG_LISTEN,
-  API_MSG_ACCEPT,
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-  API_MSG_SEND,
-  API_MSG_RECV,
-  API_MSG_WRITE,
-
-  API_MSG_CLOSE,
-  
-  API_MSG_MAX
-};
-
+/* IP addresses and port numbers are expected to be in
+ * the same byte order as in the corresponding pcb.
+ */
+/** This struct includes everything that is necessary to execute a function
+    for a netconn in another thread context (mainly used to process netconns
+    in the tcpip_thread context to be thread safe). */
 struct api_msg_msg {
+  /** The netconn which to process - always needed: it includes the semaphore
+      which is used to block the application thread until the function finished. */
   struct netconn *conn;
-  enum netconn_type conntype;
+  /** Depending on the executed function, one of these union members is used */
   union {
-    struct pbuf *p;   
-    struct  {
+    /** used for do_send */
+    struct netbuf *b;
+    /** used for do_newconn */
+    struct {
+      u8_t proto;
+    } n;
+    /** used for do_bind and do_connect */
+    struct {
       struct ip_addr *ipaddr;
       u16_t port;
     } bc;
+    /** used for do_getaddr */
     struct {
-      void *dataptr;
+      struct ip_addr *ipaddr;
+      u16_t *port;
+      u8_t local;
+    } ad;
+    /** used for do_write */
+    struct {
+      const void *dataptr;
+      size_t len;
+      u8_t apiflags;
+    } w;
+    /** used for do_recv */
+    struct {
       u16_t len;
-      u8_t copy;
-    } w;    
-    sys_mbox_t mbox;
-    u16_t len;
+    } r;
+#if LWIP_IGMP
+    /** used for do_join_leave_group */
+    struct {
+      struct ip_addr *multiaddr;
+      struct ip_addr *interface;
+      enum netconn_igmp join_or_leave;
+    } jl;
+#endif /* LWIP_IGMP */
+#if TCP_LISTEN_BACKLOG
+    struct {
+      u8_t backlog;
+    } lb;
+#endif /* TCP_LISTEN_BACKLOG */
   } msg;
 };
 
+/** This struct contains a function to execute in another thread context and
+    a struct api_msg_msg that serves as an argument for this function.
+    This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
 struct api_msg {
-  enum api_msg_type type;
+  /** function to execute in tcpip_thread context */
+  void (* function)(struct api_msg_msg *msg);
+  /** arguments for this function */
   struct api_msg_msg msg;
 };
 
-void api_msg_input(struct api_msg *msg);
-void api_msg_post(struct api_msg *msg);
+#if LWIP_DNS
+/** As do_gethostbyname requires more arguments but doesn't require a netconn,
+    it has its own struct (to avoid struct api_msg getting bigger than necessary).
+    do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
+    (see netconn_gethostbyname). */
+struct dns_api_msg {
+  /** Hostname to query or dotted IP address string */
+  const char *name;
+  /** Rhe resolved address is stored here */
+  struct ip_addr *addr;
+  /** This semaphore is posted when the name is resolved, the application thread
+      should wait on it. */
+  sys_sem_t sem;
+  /** Errors are given back here */
+  err_t *err;
+};
+#endif /* LWIP_DNS */
+
+void do_newconn         ( struct api_msg_msg *msg);
+void do_delconn         ( struct api_msg_msg *msg);
+void do_bind            ( struct api_msg_msg *msg);
+void do_connect         ( struct api_msg_msg *msg);
+void do_disconnect      ( struct api_msg_msg *msg);
+void do_listen          ( struct api_msg_msg *msg);
+void do_send            ( struct api_msg_msg *msg);
+void do_recv            ( struct api_msg_msg *msg);
+void do_write           ( struct api_msg_msg *msg);
+void do_getaddr         ( struct api_msg_msg *msg);
+void do_close           ( struct api_msg_msg *msg);
+#if LWIP_IGMP
+void do_join_leave_group( struct api_msg_msg *msg);
+#endif /* LWIP_IGMP */
+
+#if LWIP_DNS
+void do_gethostbyname(void *arg);
+#endif /* LWIP_DNS */
+
+struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
+void netconn_free(struct netconn *conn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_NETCONN */
 
 #endif /* __LWIP_API_MSG_H__ */
-
--- a/packages/net/lwip_tcpip/current/include/lwip/arch.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/arch.h
@@ -42,6 +42,15 @@
 
 #include "arch/cc.h"
 
+/** Temporary: define format string for size_t if not defined in cc.h */
+#ifndef SZT_F
+#define SZT_F U32_F
+#endif /* SZT_F */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef PACK_STRUCT_BEGIN
 #define PACK_STRUCT_BEGIN
 #endif /* PACK_STRUCT_BEGIN */
@@ -55,6 +64,10 @@
 #endif /* PACK_STRUCT_FIELD */
 
 
+#ifndef LWIP_UNUSED_ARG
+#define LWIP_UNUSED_ARG(x) (void)x
+#endif /* LWIP_UNUSED_ARG */ 
+
 
 #ifdef LWIP_PROVIDE_ERRNO
 
@@ -187,25 +200,25 @@
 #define  EMEDIUMTYPE  124  /* Wrong medium type */
 
 
-#define	ENSROK		0	/* DNS server returned answer with no data */
-#define	ENSRNODATA	160	/* DNS server returned answer with no data */
-#define	ENSRFORMERR	161	/* DNS server claims query was misformatted */
-#define	ENSRSERVFAIL 162	/* DNS server returned general failure */
-#define	ENSRNOTFOUND 163	/* Domain name not found */
-#define	ENSRNOTIMP	164	/* DNS server does not implement requested operation */
-#define	ENSRREFUSED	165	/* DNS server refused query */
-#define	ENSRBADQUERY 166	/* Misformatted DNS query */
-#define	ENSRBADNAME	167	/* Misformatted domain name */
-#define	ENSRBADFAMILY 168	/* Unsupported address family */
-#define	ENSRBADRESP	169	/* Misformatted DNS reply */
-#define	ENSRCONNREFUSED	170	/* Could not contact DNS servers */
-#define	ENSRTIMEOUT	171	/* Timeout while contacting DNS servers */
-#define	ENSROF		172	/* End of file */
-#define	ENSRFILE	173	/* Error reading file */
-#define	ENSRNOMEM	174	/* Out of memory */
-#define	ENSRDESTRUCTION	175	/* Application terminated lookup */
-#define	ENSRQUERYDOMAINTOOLONG	176	/* Domain name is too long */
-#define	ENSRCNAMELOOP	177	/* Domain name is too long */
+#define ENSROK    0 /* DNS server returned answer with no data */
+#define ENSRNODATA  160 /* DNS server returned answer with no data */
+#define ENSRFORMERR 161 /* DNS server claims query was misformatted */
+#define ENSRSERVFAIL 162  /* DNS server returned general failure */
+#define ENSRNOTFOUND 163  /* Domain name not found */
+#define ENSRNOTIMP  164 /* DNS server does not implement requested operation */
+#define ENSRREFUSED 165 /* DNS server refused query */
+#define ENSRBADQUERY 166  /* Misformatted DNS query */
+#define ENSRBADNAME 167 /* Misformatted domain name */
+#define ENSRBADFAMILY 168 /* Unsupported address family */
+#define ENSRBADRESP 169 /* Misformatted DNS reply */
+#define ENSRCONNREFUSED 170 /* Could not contact DNS servers */
+#define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */
+#define ENSROF    172 /* End of file */
+#define ENSRFILE  173 /* Error reading file */
+#define ENSRNOMEM 174 /* Out of memory */
+#define ENSRDESTRUCTION 175 /* Application terminated lookup */
+#define ENSRQUERYDOMAINTOOLONG  176 /* Domain name is too long */
+#define ENSRCNAMELOOP 177 /* Domain name is too long */
 
 #ifndef errno
 extern int errno;
@@ -213,4 +226,8 @@ extern int errno;
 
 #endif /* LWIP_PROVIDE_ERRNO */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __LWIP_ARCH_H__ */
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/autoip.h
@@ -0,0 +1,116 @@
+/**
+ * @file
+ *
+ * AutoIP Automatic LinkLocal IP Configuration
+ */
+
+/*
+ *
+ * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
+ * 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,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    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.
+ *
+ * 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.
+ *
+ * Author: Dominik Spies <kontakt@dspies.de>
+ *
+ * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
+ * with RFC 3927.
+ *
+ *
+ * Please coordinate changes and requests with Dominik Spies
+ * <kontakt@dspies.de>
+ */
+ 
+#ifndef __LWIP_AUTOIP_H__
+#define __LWIP_AUTOIP_H__
+
+#include "lwip/opt.h"
+
+#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
+
+#include "lwip/netif.h"
+#include "lwip/udp.h"
+#include "netif/etharp.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* AutoIP Timing */
+#define AUTOIP_TMR_INTERVAL      100
+#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
+
+/* RFC 3927 Constants */
+#define PROBE_WAIT               1   /* second   (initial random delay)                 */
+#define PROBE_MIN                1   /* second   (minimum delay till repeated probe)    */
+#define PROBE_MAX                2   /* seconds  (maximum delay till repeated probe)    */
+#define PROBE_NUM                3   /*          (number of probe packets)              */
+#define ANNOUNCE_NUM             2   /*          (number of announcement packets)       */
+#define ANNOUNCE_INTERVAL        2   /* seconds  (time between announcement packets)    */
+#define ANNOUNCE_WAIT            2   /* seconds  (delay before announcing)              */
+#define MAX_CONFLICTS            10  /*          (max conflicts before rate limiting)   */
+#define RATE_LIMIT_INTERVAL      60  /* seconds  (delay between successive attempts)    */
+#define DEFEND_INTERVAL          10  /* seconds  (min. wait between defensive ARPs)     */
+
+/* AutoIP client states */
+#define AUTOIP_STATE_OFF         0
+#define AUTOIP_STATE_PROBING     1
+#define AUTOIP_STATE_ANNOUNCING  2
+#define AUTOIP_STATE_BOUND       3
+
+struct autoip
+{
+  struct ip_addr llipaddr;  /* the currently selected, probed, announced or used LL IP-Address */
+  u8_t state;               /* current AutoIP state machine state */
+  u8_t sent_num;            /* sent number of probes or announces, dependent on state */
+  u16_t ttw;                /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
+  u8_t lastconflict;        /* ticks until a conflict can be solved by defending */
+  u8_t tried_llipaddr;      /* total number of probed/used Link Local IP-Addresses */
+};
+
+
+/** Init srand, has to be called before entering mainloop */
+void autoip_init(void);
+
+/** Start AutoIP client */
+err_t autoip_start(struct netif *netif);
+
+/** Stop AutoIP client */
+err_t autoip_stop(struct netif *netif);
+
+/** Handles every incoming ARP Packet, called by etharp_arp_input */
+void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
+
+/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
+void autoip_tmr(void);
+
+/** Handle a possible change in the network configuration */
+void autoip_network_changed(struct netif *netif);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_AUTOIP */
+
+#endif /* __LWIP_AUTOIP_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/debug.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/debug.h
@@ -32,56 +32,67 @@
 #ifndef __LWIP_DEBUG_H__
 #define __LWIP_DEBUG_H__
 
-#include "arch/cc.h"
+#include "lwip/arch.h"
 
 /** lower two bits indicate debug level
- * - 0 off
+ * - 0 all
  * - 1 warning
  * - 2 serious
  * - 3 severe
  */
-
-#define DBG_LEVEL_OFF     0
-#define DBG_LEVEL_WARNING 1  /* bad checksums, dropped packets, ... */
-#define DBG_LEVEL_SERIOUS 2  /* memory allocation failures, ... */
-#define DBG_LEVEL_SEVERE  3  /* */ 
-#define DBG_MASK_LEVEL    3
+#define LWIP_DBG_LEVEL_ALL     0x00
+#define LWIP_DBG_LEVEL_OFF     LWIP_DBG_LEVEL_ALL /* compatibility define only */
+#define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
+#define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
+#define LWIP_DBG_LEVEL_SEVERE  0x03
+#define LWIP_DBG_MASK_LEVEL    0x03
 
 /** flag for LWIP_DEBUGF to enable that debug message */
-#define DBG_ON  0x80U
+#define LWIP_DBG_ON            0x80U
 /** flag for LWIP_DEBUGF to disable that debug message */
-#define DBG_OFF 0x00U
+#define LWIP_DBG_OFF           0x00U
 
 /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
-#define DBG_TRACE   0x40U
+#define LWIP_DBG_TRACE         0x40U
 /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
-#define DBG_STATE   0x20U
+#define LWIP_DBG_STATE         0x20U
 /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
-#define DBG_FRESH   0x10U
+#define LWIP_DBG_FRESH         0x10U
 /** flag for LWIP_DEBUGF to halt after printing this debug message */
-#define DBG_HALT    0x08U
+#define LWIP_DBG_HALT          0x08U
 
 #ifndef LWIP_NOASSERT
-#  define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
-#else
-#  define LWIP_ASSERT(x,y) 
-#endif
+#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
+  LWIP_PLATFORM_ASSERT(message); } while(0)
+#else  /* LWIP_NOASSERT */
+#define LWIP_ASSERT(message, assertion) 
+#endif /* LWIP_NOASSERT */
+
+/** if "expression" isn't true, then print "message" and execute "handler" expression */
+#ifndef LWIP_ERROR
+#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
+  LWIP_PLATFORM_ASSERT(message); handler;}} while(0)
+#endif /* LWIP_ERROR */
 
 #ifdef LWIP_DEBUG
 /** print debug message only if debug message type is enabled...
- *  AND is of correct type AND is at least DBG_LEVEL
+ *  AND is of correct type AND is at least LWIP_DBG_LEVEL
  */
-#  define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((s16_t)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
-#  define LWIP_ERROR(x)   do { LWIP_PLATFORM_DIAG(x); } while(0)  
-#else /* LWIP_DEBUG */
-#  define LWIP_DEBUGF(debug,x) 
-#  define LWIP_ERROR(x)  
+#define LWIP_DEBUGF(debug, message) do { \
+                               if ( \
+                                   ((debug) & LWIP_DBG_ON) && \
+                                   ((debug) & LWIP_DBG_TYPES_ON) && \
+                                   ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
+                                 LWIP_PLATFORM_DIAG(message); \
+                                 if ((debug) & LWIP_DBG_HALT) { \
+                                   while(1); \
+                                 } \
+                               } \
+                             } while(0)
+
+#else  /* LWIP_DEBUG */
+#define LWIP_DEBUGF(debug, message) 
 #endif /* LWIP_DEBUG */
 
 #endif /* __LWIP_DEBUG_H__ */
 
-
-
-
-
-
--- a/packages/net/lwip_tcpip/current/include/lwip/def.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/def.h
@@ -33,10 +33,10 @@
 #define __LWIP_DEF_H__
 
 /* this might define NULL already */
-#include "arch/cc.h"
+#include "lwip/arch.h"
 
-#define LWIP_MAX(x , y)  (x) > (y) ? (x) : (y)
-#define LWIP_MIN(x , y)  (x) < (y) ? (x) : (y)
+#define LWIP_MAX(x , y)  (((x) > (y)) ? (x) : (y))
+#define LWIP_MIN(x , y)  (((x) < (y)) ? (x) : (y))
 
 #ifndef NULL
 #define NULL ((void *)0)
--- a/packages/net/lwip_tcpip/current/include/lwip/dhcp.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/dhcp.h
@@ -5,32 +5,39 @@
 #define __LWIP_DHCP_H__
 
 #include "lwip/opt.h"
+
+#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */
+
 #include "lwip/netif.h"
 #include "lwip/udp.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /** period (in seconds) of the application calling dhcp_coarse_tmr() */
 #define DHCP_COARSE_TIMER_SECS 60 
+/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */
+#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL)
 /** period (in milliseconds) of the application calling dhcp_fine_tmr() */
 #define DHCP_FINE_TIMER_MSECS 500 
 
 struct dhcp
 {
-  /** current DHCP state machine state */
-  u8_t state;
-  /** retries of current request */
-  u8_t tries;
   /** transaction identifier of last sent request */ 
   u32_t xid;
   /** our connection to the DHCP server */ 
   struct udp_pcb *pcb;
-  /** (first) pbuf of incoming msg */
-  struct pbuf *p;
   /** incoming msg */
   struct dhcp_msg *msg_in;
   /** incoming msg options */
-  struct dhcp_msg *options_in; 
+  void *options_in; 
   /** ingoing msg options length */
   u16_t options_in_len;
+  /** current DHCP state machine state */
+  u8_t state;
+  /** retries of current request */
+  u8_t tries;
 
   struct pbuf *p_out; /* pbuf of outcoming msg */
   struct dhcp_msg *msg_out; /* outgoing msg */
@@ -50,6 +57,9 @@ struct dhcp
   u32_t offered_t0_lease; /* lease period (in seconds) */
   u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
   u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period)  */
+#if LWIP_DHCP_AUTOIP_COOP
+  u8_t autoip_coop_state;
+#endif
 /** Patch #1308
  *  TODO: See dhcp.c "TODO"s
  */
@@ -112,6 +122,8 @@ err_t dhcp_release(struct netif *netif);
 void dhcp_stop(struct netif *netif);
 /** inform server of our manual IP address */
 void dhcp_inform(struct netif *netif);
+/** Handle a possible change in the network configuration */
+void dhcp_network_changed(struct netif *netif);
 
 /** if enabled, check whether the offered IP address is not in use, using ARP */
 #if DHCP_DOES_ARP_CHECK
@@ -161,6 +173,10 @@ void dhcp_fine_tmr(void);
 /** not yet implemented #define DHCP_RELEASING 11 */
 #define DHCP_BACKING_OFF 12
 #define DHCP_OFF 13
+
+/** AUTOIP cooperatation flags */
+#define DHCP_AUTOIP_COOP_STATE_OFF 0
+#define DHCP_AUTOIP_COOP_STATE_ON 1
  
 #define DHCP_BOOTREQUEST 1
 #define DHCP_BOOTREPLY 2
@@ -210,6 +226,7 @@ void dhcp_fine_tmr(void);
 
 #define DHCP_OPTION_T1 58 /* T1 renewal time */
 #define DHCP_OPTION_T2 59 /* T2 rebinding time */
+#define DHCP_OPTION_US 60
 #define DHCP_OPTION_CLIENT_ID 61
 #define DHCP_OPTION_TFTP_SERVERNAME 66
 #define DHCP_OPTION_BOOTFILE 67
@@ -220,4 +237,10 @@ void dhcp_fine_tmr(void);
 #define DHCP_OVERLOAD_SNAME  2
 #define DHCP_OVERLOAD_SNAME_FILE 3
 
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_DHCP */
+
 #endif /*__LWIP_DHCP_H__*/
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/dns.h
@@ -0,0 +1,97 @@
+/**
+ * lwip DNS resolver header file.
+
+ * Author: Jim Pettinato 
+ *   April 2007
+
+ * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels.
+ *
+ * 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, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, 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.
+ *
+ * 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.
+ */
+
+#ifndef __LWIP_DNS_H__
+#define __LWIP_DNS_H__
+
+#include "lwip/opt.h"
+
+#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
+
+/** DNS timer period */
+#define DNS_TMR_INTERVAL          1000
+
+/** DNS field TYPE used for "Resource Records" */
+#define DNS_RRTYPE_A              1     /* a host address */
+#define DNS_RRTYPE_NS             2     /* an authoritative name server */
+#define DNS_RRTYPE_MD             3     /* a mail destination (Obsolete - use MX) */
+#define DNS_RRTYPE_MF             4     /* a mail forwarder (Obsolete - use MX) */
+#define DNS_RRTYPE_CNAME          5     /* the canonical name for an alias */
+#define DNS_RRTYPE_SOA            6     /* marks the start of a zone of authority */
+#define DNS_RRTYPE_MB             7     /* a mailbox domain name (EXPERIMENTAL) */
+#define DNS_RRTYPE_MG             8     /* a mail group member (EXPERIMENTAL) */
+#define DNS_RRTYPE_MR             9     /* a mail rename domain name (EXPERIMENTAL) */
+#define DNS_RRTYPE_NULL           10    /* a null RR (EXPERIMENTAL) */
+#define DNS_RRTYPE_WKS            11    /* a well known service description */
+#define DNS_RRTYPE_PTR            12    /* a domain name pointer */
+#define DNS_RRTYPE_HINFO          13    /* host information */
+#define DNS_RRTYPE_MINFO          14    /* mailbox or mail list information */
+#define DNS_RRTYPE_MX             15    /* mail exchange */
+#define DNS_RRTYPE_TXT            16    /* text strings */
+
+/** DNS field CLASS used for "Resource Records" */
+#define DNS_RRCLASS_IN            1     /* the Internet */
+#define DNS_RRCLASS_CS            2     /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
+#define DNS_RRCLASS_CH            3     /* the CHAOS class */
+#define DNS_RRCLASS_HS            4     /* Hesiod [Dyer 87] */
+#define DNS_RRCLASS_FLUSH         0x800 /* Flush bit */
+
+/** Callback which is invoked when a hostname is found.
+ * A function of this type must be implemented by the application using the DNS resolver.
+ * @param name pointer to the name that was looked up.
+ * @param ipaddr pointer to a struct ip_addr containing the IP address of the hostname,
+ *        or NULL if the name could not be found (or on any other error).
+ * @param callback_arg a user-specified callback argument passed to dns_gethostbyname
+*/
+typedef void (*dns_found_callback)(const char *name, struct ip_addr *ipaddr, void *callback_arg);
+
+
+void           dns_init(void);
+
+void           dns_tmr(void);
+
+void           dns_setserver(u8_t numdns, struct ip_addr *dnsserver);
+
+struct ip_addr dns_getserver(u8_t numdns);
+
+err_t          dns_gethostbyname(const char *hostname, struct ip_addr *addr,
+                                 dns_found_callback found, void *callback_arg);
+
+#if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
+int            dns_local_removehost(const char *hostname, const struct ip_addr *addr);
+err_t          dns_local_addhost(const char *hostname, const struct ip_addr *addr);
+#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+
+#endif /* LWIP_DNS */
+
+#endif /* __LWIP_DNS_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/err.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/err.h
@@ -33,38 +33,55 @@
 #define __LWIP_ERR_H__
 
 #include "lwip/opt.h"
+#include "lwip/arch.h"
 
-#include "arch/cc.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-typedef s8_t err_t;
+/** Define LWIP_ERR_T in cc.h if you want to use
+ *  a different type for your platform (must be signed). */
+#ifdef LWIP_ERR_T
+typedef LWIP_ERR_T err_t;
+#else /* LWIP_ERR_T */
+ typedef s8_t err_t;
+#endif /* LWIP_ERR_T*/
 
 /* Definitions for error constants. */
 
-#define ERR_OK    0      /* No error, everything OK. */
-#define ERR_MEM  -1      /* Out of memory error.     */
-#define ERR_BUF  -2      /* Buffer error.            */
-
+#define ERR_OK          0    /* No error, everything OK. */
+#define ERR_MEM        -1    /* Out of memory error.     */
+#define ERR_BUF        -2    /* Buffer error.            */
+#define ERR_TIMEOUT    -3    /* Timeout.                 */
+#define ERR_RTE        -4    /* Routing problem.         */
 
-#define ERR_ABRT -3      /* Connection aborted.      */
-#define ERR_RST  -4      /* Connection reset.        */
-#define ERR_CLSD -5      /* Connection closed.       */
-#define ERR_CONN -6      /* Not connected.           */
+#define ERR_IS_FATAL(e) ((e) < ERR_RTE)
 
-#define ERR_VAL  -7      /* Illegal value.           */
+#define ERR_ABRT       -5    /* Connection aborted.      */
+#define ERR_RST        -6    /* Connection reset.        */
+#define ERR_CLSD       -7    /* Connection closed.       */
+#define ERR_CONN       -8    /* Not connected.           */
 
-#define ERR_ARG  -8      /* Illegal argument.        */
+#define ERR_VAL        -9    /* Illegal value.           */
 
-#define ERR_RTE  -9      /* Routing problem.         */
+#define ERR_ARG        -10   /* Illegal argument.        */
+
+#define ERR_USE        -11   /* Address in use.          */
 
-#define ERR_USE  -10     /* Address in use.          */
+#define ERR_IF         -12   /* Low-level netif error    */
+#define ERR_ISCONN     -13   /* Already connected.       */
 
-#define ERR_IF   -11     /* Low-level netif error    */
-#define ERR_ISCONN -12   /* Already connected.       */
+#define ERR_INPROGRESS -14   /* Operation in progress    */
 
 
 #ifdef LWIP_DEBUG
-extern char *lwip_strerr(err_t err);
+extern const char *lwip_strerr(err_t err);
 #else
 #define lwip_strerr(x) ""
 #endif /* LWIP_DEBUG */
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __LWIP_ERR_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/icmp.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/icmp.h
@@ -32,14 +32,15 @@
 #ifndef __LWIP_ICMP_H__
 #define __LWIP_ICMP_H__
 
-#include "lwip/arch.h"
-
 #include "lwip/opt.h"
 #include "lwip/pbuf.h"
-
 #include "lwip/ip_addr.h"
 #include "lwip/netif.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define ICMP_ER 0      /* echo reply */
 #define ICMP_DUR 3     /* destination unreachable */
 #define ICMP_SQ 4      /* source quench */
@@ -66,47 +67,45 @@ enum icmp_te_type {
   ICMP_TE_FRAG = 1     /* fragment reassembly time exceeded */
 };
 
-void icmp_input(struct pbuf *p, struct netif *inp);
-
-void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
-void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
-
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
 #endif
+/** This is the standard ICMP header only that the u32_t data
+ *  is splitted to two u16_t like ICMP echo needs it.
+ *  This header is also used for other ICMP types that do not
+ *  use the data part.
+ */
 PACK_STRUCT_BEGIN
 struct icmp_echo_hdr {
-  PACK_STRUCT_FIELD(u16_t _type_code);
+  PACK_STRUCT_FIELD(u8_t type);
+  PACK_STRUCT_FIELD(u8_t code);
   PACK_STRUCT_FIELD(u16_t chksum);
   PACK_STRUCT_FIELD(u16_t id);
   PACK_STRUCT_FIELD(u16_t seqno);
 } PACK_STRUCT_STRUCT;
 PACK_STRUCT_END
-
-PACK_STRUCT_BEGIN
-struct icmp_dur_hdr {
-  PACK_STRUCT_FIELD(u16_t _type_code);
-  PACK_STRUCT_FIELD(u16_t chksum);
-  PACK_STRUCT_FIELD(u32_t unused);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-
-PACK_STRUCT_BEGIN
-struct icmp_te_hdr {
-  PACK_STRUCT_FIELD(u16_t _type_code);
-  PACK_STRUCT_FIELD(u16_t chksum);
-  PACK_STRUCT_FIELD(u32_t unused);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/epstruct.h"
 #endif
 
-#define ICMPH_TYPE(hdr) (ntohs((hdr)->_type_code) >> 8)
-#define ICMPH_CODE(hdr) (ntohs((hdr)->_type_code) & 0xff)
+#define ICMPH_TYPE(hdr) ((hdr)->type)
+#define ICMPH_CODE(hdr) ((hdr)->code)
+
+/** Combines type and code to an u16_t */
+#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t))
+#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c))
+
+
+#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
 
-#define ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = htons(ICMPH_CODE(hdr) | ((type) << 8)))
-#define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8)))
+void icmp_input(struct pbuf *p, struct netif *inp);
+void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
+void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
+
+#endif /* LWIP_ICMP */
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* __LWIP_ICMP_H__ */
-    
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/igmp.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2002 CITEL Technologies Ltd.
+ * 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, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``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 CITEL TECHNOLOGIES OR CONTRIBUTORS 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 a contribution to the lwIP TCP/IP stack.
+ * The Swedish Institute of Computer Science and Adam Dunkels
+ * are specifically granted permission to redistribute this
+ * source code.
+*/
+
+#ifndef __LWIP_IGMP_H__
+#define __LWIP_IGMP_H__
+
+#include "lwip/opt.h"
+#include "lwip/ip_addr.h"
+#include "lwip/netif.h"
+#include "lwip/pbuf.h"
+
+#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* 
+ * IGMP constants
+ */
+#define IP_PROTO_IGMP                  2
+#define IGMP_TTL                       1
+#define IGMP_MINLEN                    8
+#define ROUTER_ALERT                   0x9404
+#define ROUTER_ALERTLEN                4
+
+/*
+ * IGMP message types, including version number.
+ */
+#define IGMP_MEMB_QUERY                0x11 /* Membership query         */
+#define IGMP_V1_MEMB_REPORT            0x12 /* Ver. 1 membership report */
+#define IGMP_V2_MEMB_REPORT            0x16 /* Ver. 2 membership report */
+#define IGMP_LEAVE_GROUP               0x17 /* Leave-group message      */
+
+/* IGMP timer */
+#define IGMP_TMR_INTERVAL              100 /* Milliseconds */
+#define IGMP_V1_DELAYING_MEMBER_TMR   (1000/IGMP_TMR_INTERVAL)
+#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
+
+/* MAC Filter Actions */
+#define IGMP_DEL_MAC_FILTER            0
+#define IGMP_ADD_MAC_FILTER            1
+
+/* Group  membership states */
+#define IGMP_GROUP_NON_MEMBER          0
+#define IGMP_GROUP_DELAYING_MEMBER     1
+#define IGMP_GROUP_IDLE_MEMBER         2
+
+/*
+ * IGMP packet format.
+ */
+#ifdef PACK_STRUCT_USE_INCLUDES
+#  include "arch/bpstruct.h"
+#endif
+PACK_STRUCT_BEGIN
+struct igmp_msg {
+ PACK_STRUCT_FIELD(u8_t           igmp_msgtype);
+ PACK_STRUCT_FIELD(u8_t           igmp_maxresp);
+ PACK_STRUCT_FIELD(u16_t          igmp_checksum);
+ PACK_STRUCT_FIELD(struct ip_addr igmp_group_address);
+} PACK_STRUCT_STRUCT;
+PACK_STRUCT_END
+#ifdef PACK_STRUCT_USE_INCLUDES
+#  include "arch/epstruct.h"
+#endif
+
+/* 
+ * now a group structure - there is
+ * a list of groups for each interface
+ * these should really be linked from the interface, but
+ * if we keep them separate we will not affect the lwip original code
+ * too much
+ * 
+ * There will be a group for the all systems group address but this 
+ * will not run the state machine as it is used to kick off reports
+ * from all the other groups
+ */
+
+struct igmp_group {
+  struct igmp_group *next;
+  struct netif      *interface;
+  struct ip_addr     group_address;
+  u8_t               last_reporter_flag; /* signifies we were the last person to report */
+  u8_t               group_state;
+  u16_t              timer;
+  u8_t               use; /* counter of simultaneous uses */
+};
+
+
+/*  Prototypes */
+void   igmp_init(void);
+
+err_t  igmp_start( struct netif *netif);
+
+err_t  igmp_stop( struct netif *netif);
+
+void   igmp_report_groups( struct netif *netif);
+
+struct igmp_group *igmp_lookfor_group( struct netif *ifp, struct ip_addr *addr);
+
+struct igmp_group *igmp_lookup_group( struct netif *ifp, struct ip_addr *addr);
+
+err_t  igmp_remove_group( struct igmp_group *group);
+
+void   igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);
+
+err_t  igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
+
+err_t  igmp_leavegroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
+
+void   igmp_tmr(void);
+
+void   igmp_timeout( struct igmp_group *group);
+
+void   igmp_start_timer( struct igmp_group *group, u8_t max_time);
+
+void   igmp_stop_timer( struct igmp_group *group);
+
+void   igmp_delaying_member( struct igmp_group *group, u8_t maxresp);
+
+err_t  igmp_ip_output_if( struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif);
+
+void   igmp_send( struct igmp_group *group, u8_t type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_IGMP */
+
+#endif /* __LWIP_IGMP_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/inet.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/inet.h
@@ -32,24 +32,25 @@
 #ifndef __LWIP_INET_H__
 #define __LWIP_INET_H__
 
-#include "lwip/arch.h"
+#include "lwip/opt.h"
 
-#include "lwip/opt.h"
-#include "lwip/pbuf.h"
-#include "lwip/ip_addr.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-u16_t inet_chksum(void *dataptr, u16_t len);
-#if 0 /* optimized routine */
-u16_t inet_chksum4(u8_t *dataptr, u16_t len);
-#endif
-u16_t inet_chksum_pbuf(struct pbuf *p);
-u16_t inet_chksum_pseudo(struct pbuf *p,
-       struct ip_addr *src, struct ip_addr *dest,
-       u8_t proto, u16_t proto_len);
+/* For compatibility with BSD code */
+struct in_addr {
+  u32_t s_addr;
+};
 
-externC u32_t inet_addr(const char *cp);
-externC s8_t inet_aton(const char *cp, struct in_addr *addr);
-externC char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
+#define INADDR_NONE         ((u32_t)0xffffffffUL)  /* 255.255.255.255 */
+#define INADDR_LOOPBACK     ((u32_t)0x7f000001UL)  /* 127.0.0.1 */
+#define INADDR_ANY          ((u32_t)0x00000000UL)  /* 0.0.0.0 */
+#define INADDR_BROADCAST    ((u32_t)0xffffffffUL)  /* 255.255.255.255 */
+
+u32_t inet_addr(const char *cp);
+int inet_aton(const char *cp, struct in_addr *addr);
+char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
 
 #ifdef htons
 #undef htons
@@ -64,24 +65,39 @@ externC char *inet_ntoa(struct in_addr a
 #undef ntohl
 #endif /* ntohl */
 
+#ifndef LWIP_PLATFORM_BYTESWAP
+#define LWIP_PLATFORM_BYTESWAP 0
+#endif
+
 #if BYTE_ORDER == BIG_ENDIAN
 #define htons(x) (x)
 #define ntohs(x) (x)
 #define htonl(x) (x)
 #define ntohl(x) (x)
-#else
+#else /* BYTE_ORDER != BIG_ENDIAN */
 #ifdef LWIP_PREFIX_BYTEORDER_FUNCS
 /* workaround for naming collisions on some platforms */
 #define htons lwip_htons
 #define ntohs lwip_ntohs
 #define htonl lwip_htonl
 #define ntohl lwip_ntohl
-#endif
-externC u16_t htons(u16_t x);
-externC u16_t ntohs(u16_t x);
-externC u32_t htonl(u32_t x);
-externC u32_t ntohl(u32_t x);
+#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
+#if LWIP_PLATFORM_BYTESWAP
+#define htons(x) LWIP_PLATFORM_HTONS(x)
+#define ntohs(x) LWIP_PLATFORM_HTONS(x)
+#define htonl(x) LWIP_PLATFORM_HTONL(x)
+#define ntohl(x) LWIP_PLATFORM_HTONL(x)
+#else /* LWIP_PLATFORM_BYTESWAP */
+u16_t htons(u16_t x);
+u16_t ntohs(u16_t x);
+u32_t htonl(u32_t x);
+u32_t ntohl(u32_t x);
+#endif /* LWIP_PLATFORM_BYTESWAP */
+
+#endif /* BYTE_ORDER == BIG_ENDIAN */
+
+#ifdef __cplusplus
+}
 #endif
 
 #endif /* __LWIP_INET_H__ */
-
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/inet_chksum.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * 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,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    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. 
+ *
+ * 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 <adam@sics.se>
+ *
+ */
+#ifndef __LWIP_INET_CHKSUM_H__
+#define __LWIP_INET_CHKSUM_H__
+
+#include "lwip/opt.h"
+
+#include "lwip/pbuf.h"
+#include "lwip/ip_addr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+u16_t inet_chksum(void *dataptr, u16_t len);
+u16_t inet_chksum_pbuf(struct pbuf *p);
+u16_t inet_chksum_pseudo(struct pbuf *p,
+       struct ip_addr *src, struct ip_addr *dest,
+       u8_t proto, u16_t proto_len);
+#if LWIP_UDPLITE
+u16_t inet_chksum_pseudo_partial(struct pbuf *p,
+       struct ip_addr *src, struct ip_addr *dest,
+       u8_t proto, u16_t proto_len, u16_t chksum_len);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LWIP_INET_H__ */
+
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/init.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * 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,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    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. 
+ *
+ * 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 <adam@sics.se>
+ *
+ */
+#ifndef __LWIP_INIT_H__
+#define __LWIP_INIT_H__
+
+#include "lwip/opt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** X.x.x: Major version of the stack */
+#define LWIP_VERSION_MAJOR      1U
+/** x.X.x: Minor version of the stack */
+#define LWIP_VERSION_MINOR      3U
+/** x.x.X: Revision of the stack */
+#define LWIP_VERSION_REVISION   2U
+/** For release candidates, this is set to 1..254
+  * For official releases, this is set to 255 (LWIP_RC_RELEASE)
+  * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */
+#define LWIP_VERSION_RC         255U
+
+/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
+#define LWIP_RC_RELEASE         255U
+/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */
+#define LWIP_RC_DEVELOPMENT     0U
+
+#define LWIP_VERSION_IS_RELEASE     (LWIP_VERSION_RC == LWIP_RC_RELEASE)
+#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT)
+#define LWIP_VERSION_IS_RC          ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT))
+
+/** Provides the version of the stack */
+#define LWIP_VERSION   (LWIP_VERSION_MAJOR << 24   | LWIP_VERSION_MINOR << 16 | \
+                        LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC)
+
+/* Modules initialization */
+void lwip_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LWIP_INIT_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/ip.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/ip.h
@@ -32,30 +32,27 @@
 #ifndef __LWIP_IP_H__
 #define __LWIP_IP_H__
 
-#include "lwip/arch.h"
+#include "lwip/opt.h"
 
 #include "lwip/def.h"
 #include "lwip/pbuf.h"
 #include "lwip/ip_addr.h"
-
 #include "lwip/err.h"
-
+#include "lwip/netif.h"
 
-void ip_init(void);
-struct netif *ip_route(struct ip_addr *dest);
-err_t ip_input(struct pbuf *p, struct netif *inp);
-err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
-		u8_t ttl, u8_t tos, u8_t proto);
-err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
-		   u8_t ttl, u8_t tos, u8_t proto,
-       struct netif *netif);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Currently, the function ip_output_if_opt() is only used with IGMP */
+#define IP_OPTIONS_SEND   LWIP_IGMP
 
 #define IP_HLEN 20
 
-#define IP_PROTO_ICMP 1
-#define IP_PROTO_UDP 17
-#define IP_PROTO_UDPLITE 170
-#define IP_PROTO_TCP 6
+#define IP_PROTO_ICMP    1
+#define IP_PROTO_UDP     17
+#define IP_PROTO_UDPLITE 136
+#define IP_PROTO_TCP     6
 
 /* This is passed as the destination address to ip_output_if (not
    to ip_output), meaning that an IP header already is constructed
@@ -65,34 +62,47 @@ err_t ip_output_if(struct pbuf *p, struc
 #endif /* IP_HDRINCL */
 #define IP_HDRINCL  NULL
 
+#if LWIP_NETIF_HWADDRHINT
+#define IP_PCB_ADDRHINT ;u8_t addr_hint
+#else
+#define IP_PCB_ADDRHINT
+#endif /* LWIP_NETIF_HWADDRHINT */
 
 /* This is the common part of all PCB types. It needs to be at the
    beginning of a PCB type definition. It is located here so that
    changes to this common part are made in one location instead of
    having to change all PCB structs. */
-#define IP_PCB struct ip_addr local_ip; \
+#define IP_PCB \
+  /* ip addresses in network byte order */ \
+  struct ip_addr local_ip; \
   struct ip_addr remote_ip; \
    /* Socket options */  \
   u16_t so_options;      \
    /* Type Of Service */ \
   u8_t tos;              \
   /* Time To Live */     \
-  u8_t ttl
+  u8_t ttl               \
+  /* link layer address resolution hint */ \
+  IP_PCB_ADDRHINT
+
+struct ip_pcb {
+/* Common members of all PCB types */
+  IP_PCB;
+};
 
 /*
  * Option flags per-socket. These are the same like SO_XXX.
  */
-#define	SOF_DEBUG	    (u16_t)0x0001U		/* turn on debugging info recording */
-#define	SOF_ACCEPTCONN	(u16_t)0x0002U		/* socket has had listen() */
-#define	SOF_REUSEADDR	(u16_t)0x0004U		/* allow local address reuse */
-#define	SOF_KEEPALIVE	(u16_t)0x0008U		/* keep connections alive */
-#define	SOF_DONTROUTE	(u16_t)0x0010U		/* just use interface addresses */
-#define	SOF_BROADCAST	(u16_t)0x0020U		/* permit sending of broadcast msgs */
-#define	SOF_USELOOPBACK	(u16_t)0x0040U		/* bypass hardware when possible */
-#define	SOF_LINGER	    (u16_t)0x0080U		/* linger on close if data present */
-#define	SOF_OOBINLINE	(u16_t)0x0100U		/* leave received OOB data in line */
-#define	SOF_REUSEPORT	(u16_t)0x0200U		/* allow local address & port reuse */
-
+#define SOF_DEBUG       (u16_t)0x0001U    /* turn on debugging info recording */
+#define SOF_ACCEPTCONN  (u16_t)0x0002U    /* socket has had listen() */
+#define SOF_REUSEADDR   (u16_t)0x0004U    /* allow local address reuse */
+#define SOF_KEEPALIVE   (u16_t)0x0008U    /* keep connections alive */
+#define SOF_DONTROUTE   (u16_t)0x0010U    /* just use interface addresses */
+#define SOF_BROADCAST   (u16_t)0x0020U    /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
+#define SOF_USELOOPBACK (u16_t)0x0040U    /* bypass hardware when possible */
+#define SOF_LINGER      (u16_t)0x0080U    /* linger on close if data present */
+#define SOF_OOBINLINE   (u16_t)0x0100U    /* leave received OOB data in line */
+#define SOF_REUSEPORT   (u16_t)0x0200U    /* allow local address & port reuse */
 
 
 #ifdef PACK_STRUCT_USE_INCLUDES
@@ -139,16 +149,50 @@ PACK_STRUCT_END
 #define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
 #define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
 #define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
-#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((ttl) << 8)))
+#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((u16_t)(ttl) << 8)))
 #define IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))
 #define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
 
+/** The interface that provided the packet for the current callback invocation. */
+extern struct netif *current_netif;
+/** Header of the input packet currently being processed. */
+extern const struct ip_hdr *current_header;
+
+#define ip_init() /* Compatibility define, not init needed. */
+struct netif *ip_route(struct ip_addr *dest);
+err_t ip_input(struct pbuf *p, struct netif *inp);
+err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
+       u8_t ttl, u8_t tos, u8_t proto);
+err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
+       u8_t ttl, u8_t tos, u8_t proto,
+       struct netif *netif);
+#if LWIP_NETIF_HWADDRHINT
+err_t ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
+       u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
+#endif /* LWIP_NETIF_HWADDRHINT */
+#if IP_OPTIONS_SEND
+err_t ip_output_if_opt(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
+       u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
+       u16_t optlen);
+#endif /* IP_OPTIONS_SEND */
+/** Get the interface that received the current packet.
+ * This function must only be called from a receive callback (udp_recv,
+ * raw_recv, tcp_accept). It will return NULL otherwise. */
+#define ip_current_netif()  (current_netif)
+/** Get the IP header of the current packet.
+ * This function must only be called from a receive callback (udp_recv,
+ * raw_recv, tcp_accept). It will return NULL otherwise. */
+#define ip_current_header() (current_header)
 #if IP_DEBUG
 void ip_debug_print(struct pbuf *p);
 #else
 #define ip_debug_print(p)
 #endif /* IP_DEBUG */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __LWIP_IP_H__ */
 
 
--- a/packages/net/lwip_tcpip/current/include/lwip/ip_addr.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/ip_addr.h
@@ -32,7 +32,13 @@
 #ifndef __LWIP_IP_ADDR_H__
 #define __LWIP_IP_ADDR_H__
 
-#include "lwip/arch.h"
+#include "lwip/opt.h"
+
+#include "lwip/inet.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
@@ -46,6 +52,10 @@ PACK_STRUCT_END
 #  include "arch/epstruct.h"
 #endif
 
+/*
+ * struct ipaddr2 is used in the definition of the ARP packet format in
+ * order to support compilers that don't have structure packing.
+ */
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
 #endif
@@ -58,11 +68,6 @@ PACK_STRUCT_END
 #  include "arch/epstruct.h"
 #endif
 
-/* For compatibility with BSD code */
-struct in_addr {
-  u32_t s_addr;
-};
-
 struct netif;
 
 extern const struct ip_addr ip_addr_any;
@@ -71,48 +76,47 @@ extern const struct ip_addr ip_addr_broa
 /** IP_ADDR_ can be used as a fixed IP address
  *  for the wildcard and the broadcast address
  */
-#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
-#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
-
-#define INADDR_NONE    ((u32_t) 0xffffffff)  /* 255.255.255.255 */
-#define INADDR_LOOPBACK    ((u32_t) 0x7f000001)  /* 127.0.0.1 */
+#define IP_ADDR_ANY         ((struct ip_addr *)&ip_addr_any)
+#define IP_ADDR_BROADCAST   ((struct ip_addr *)&ip_addr_broadcast)
 
 /* Definitions of the bits in an Internet address integer.
 
    On subnets, host and network parts are found according to
    the subnet mask, not these masks.  */
 
-#define  IN_CLASSA(a)    ((((u32_t)(a)) & 0x80000000) == 0)
-#define  IN_CLASSA_NET    0xff000000
-#define  IN_CLASSA_NSHIFT  24
-#define  IN_CLASSA_HOST    (0xffffffff & ~IN_CLASSA_NET)
-#define  IN_CLASSA_MAX    128
+#define IN_CLASSA(a)        ((((u32_t)(a)) & 0x80000000UL) == 0)
+#define IN_CLASSA_NET       0xff000000
+#define IN_CLASSA_NSHIFT    24
+#define IN_CLASSA_HOST      (0xffffffff & ~IN_CLASSA_NET)
+#define IN_CLASSA_MAX       128
 
-#define  IN_CLASSB(a)    ((((u32_t)(a)) & 0xc0000000) == 0x80000000)
-#define  IN_CLASSB_NET    0xffff0000
-#define  IN_CLASSB_NSHIFT  16
-#define  IN_CLASSB_HOST    (0xffffffff & ~IN_CLASSB_NET)
-#define  IN_CLASSB_MAX    65536
+#define IN_CLASSB(a)        ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL)
+#define IN_CLASSB_NET       0xffff0000
+#define IN_CLASSB_NSHIFT    16
+#define IN_CLASSB_HOST      (0xffffffff & ~IN_CLASSB_NET)
+#define IN_CLASSB_MAX       65536
 
-#define  IN_CLASSC(a)    ((((u32_t)(a)) & 0xe0000000) == 0xc0000000)
-#define  IN_CLASSC_NET    0xffffff00
-#define  IN_CLASSC_NSHIFT  8
-#define  IN_CLASSC_HOST    (0xffffffff & ~IN_CLASSC_NET)
+#define IN_CLASSC(a)        ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL)
+#define IN_CLASSC_NET       0xffffff00
+#define IN_CLASSC_NSHIFT    8
+#define IN_CLASSC_HOST      (0xffffffff & ~IN_CLASSC_NET)
 
-#define IN_CLASSD(a)        (((u32_t)(a) & 0xf0000000) == 0xe0000000)
-#define IN_CLASSD_NET       0xf0000000  /* These ones aren't really */
-#define IN_CLASSD_NSHIFT    28      /* net and host fields, but */
-#define IN_CLASSD_HOST      0x0fffffff  /* routing needn't know.    */
+#define IN_CLASSD(a)        (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL)
+#define IN_CLASSD_NET       0xf0000000          /* These ones aren't really */
+#define IN_CLASSD_NSHIFT    28                  /*   net and host fields, but */
+#define IN_CLASSD_HOST      0x0fffffff          /*   routing needn't know. */
 #define IN_MULTICAST(a)     IN_CLASSD(a)
 
-#define IN_EXPERIMENTAL(a)  (((u32_t)(a) & 0xf0000000) == 0xf0000000)
-#define IN_BADCLASS(a)      (((u32_t)(a) & 0xf0000000) == 0xf0000000)
+#define IN_EXPERIMENTAL(a)  (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
+#define IN_BADCLASS(a)      (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
+
+#define IN_LOOPBACKNET      127                 /* official! */
 
-#define IN_LOOPBACKNET      127         /* official! */
-
-
-#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = htonl(((u32_t)(a & 0xff) << 24) | ((u32_t)(b & 0xff) << 16) | \
-                                                         ((u32_t)(c & 0xff) << 8) | (u32_t)(d & 0xff))
+#define IP4_ADDR(ipaddr, a,b,c,d) \
+        (ipaddr)->addr = htonl(((u32_t)((a) & 0xff) << 24) | \
+                               ((u32_t)((b) & 0xff) << 16) | \
+                               ((u32_t)((c) & 0xff) << 8) | \
+                                (u32_t)((d) & 0xff))
 
 #define ip_addr_set(dest, src) (dest)->addr = \
                                ((src) == NULL? 0:\
@@ -135,25 +139,35 @@ extern const struct ip_addr ip_addr_broa
 
 u8_t ip_addr_isbroadcast(struct ip_addr *, struct netif *);
 
-#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
+#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL))
 
+#define ip_addr_islinklocal(addr1) (((addr1)->addr & ntohl(0xffff0000UL)) == ntohl(0xa9fe0000UL))
 
-#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
-        ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \
-        ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \
-        ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \
-        ipaddr?(u16_t)ntohl((ipaddr)->addr) & 0xff:0U))
+#define ip_addr_debug_print(debug, ipaddr) \
+  LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,              \
+                      ipaddr != NULL ?                                  \
+                      (u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff : 0,  \
+                      ipaddr != NULL ?                                  \
+                      (u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff : 0,  \
+                      ipaddr != NULL ?                                  \
+                      (u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff : 0,   \
+                      ipaddr != NULL ?                                  \
+                      (u16_t)ntohl((ipaddr)->addr) & 0xff : 0))
 
-/* cast to unsigned int, as it is used as argument to printf functions
- * which expect integer arguments. CSi: use cc.h formatters (conversion chars)! */
+/* These are cast to u16_t, with the intent that they are often arguments
+ * to printf using the U16_F format from cc.h. */
 #define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
 #define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
 #define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
 #define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff)
-#endif /* __LWIP_IP_ADDR_H__ */
 
-
+/**
+ * Same as inet_ntoa() but takes a struct ip_addr*
+ */
+#define ip_ntoa(addr)  ((addr != NULL) ? inet_ntoa(*((struct in_addr*)(addr))) : "NULL")
 
-
+#ifdef __cplusplus
+}
+#endif
 
-
+#endif /* __LWIP_IP_ADDR_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/ip_frag.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/ip_frag.h
@@ -33,15 +33,44 @@
 #ifndef __LWIP_IP_FRAG_H__
 #define __LWIP_IP_FRAG_H__
 
+#include "lwip/opt.h"
 #include "lwip/err.h"
 #include "lwip/pbuf.h"
 #include "lwip/netif.h"
 #include "lwip/ip_addr.h"
+#include "lwip/ip.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if IP_REASSEMBLY
+/* The IP reassembly timer interval in milliseconds. */
+#define IP_TMR_INTERVAL 1000
+
+/* IP reassembly helper struct.
+ * This is exported because memp needs to know the size.
+ */
+struct ip_reassdata {
+  struct ip_reassdata *next;
+  struct pbuf *p;
+  struct ip_hdr iphdr;
+  u16_t datagram_len;
+  u8_t flags;
+  u8_t timer;
+};
+
+void ip_reass_init(void);
 void ip_reass_tmr(void);
 struct pbuf * ip_reass(struct pbuf *p);
+#endif /* IP_REASSEMBLY */
+
+#if IP_FRAG
 err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest);
+#endif /* IP_FRAG */
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* __LWIP_IP_FRAG_H__ */
-
-
--- a/packages/net/lwip_tcpip/current/include/lwip/mem.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/mem.h
@@ -33,29 +33,75 @@
 #define __LWIP_MEM_H__
 
 #include "lwip/opt.h"
-#include "lwip/arch.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if MEM_LIBC_MALLOC
+
+#include <stddef.h> /* for size_t */
+
+typedef size_t mem_size_t;
 
+/* aliases for C library malloc() */
+#define mem_init()
+/* in case C library malloc() needs extra protection,
+ * allow these defines to be overridden.
+ */
+#ifndef mem_free
+#define mem_free free
+#endif
+#ifndef mem_malloc
+#define mem_malloc malloc
+#endif
+#ifndef mem_calloc
+#define mem_calloc calloc
+#endif
+#ifndef mem_realloc
+static void *mem_realloc(void *mem, mem_size_t size)
+{
+  LWIP_UNUSED_ARG(size);
+  return mem;
+}
+#endif
+#else /* MEM_LIBC_MALLOC */
+
+/* MEM_SIZE would have to be aligned, but using 64000 here instead of
+ * 65535 leaves some room for alignment...
+ */
 #if MEM_SIZE > 64000l
 typedef u32_t mem_size_t;
 #else
 typedef u16_t mem_size_t;
 #endif /* MEM_SIZE > 64000 */
 
-
-void mem_init(void);
-
+#if MEM_USE_POOLS
+/** mem_init is not used when using pools instead of a heap */
+#define mem_init()
+/** mem_realloc is not used when using pools instead of a heap:
+    we can't free part of a pool element and don't want to copy the rest */
+#define mem_realloc(mem, size) (mem)
+#else /* MEM_USE_POOLS */
+/* lwIP alternative malloc */
+void  mem_init(void);
+void *mem_realloc(void *mem, mem_size_t size);
+#endif /* MEM_USE_POOLS */
 void *mem_malloc(mem_size_t size);
-void mem_free(void *mem);
-void *mem_realloc(void *mem, mem_size_t size);
-void *mem_reallocm(void *mem, mem_size_t size);
+void *mem_calloc(mem_size_t count, mem_size_t size);
+void  mem_free(void *mem);
+#endif /* MEM_LIBC_MALLOC */
 
-#ifndef MEM_ALIGN_SIZE
-#define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
+#ifndef LWIP_MEM_ALIGN_SIZE
+#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
 #endif
 
-#ifndef MEM_ALIGN
-#define MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
+#ifndef LWIP_MEM_ALIGN
+#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
+#endif
+
+#ifdef __cplusplus
+}
 #endif
 
 #endif /* __LWIP_MEM_H__ */
-
--- a/packages/net/lwip_tcpip/current/include/lwip/memp.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/memp.h
@@ -35,29 +35,82 @@
 
 #include "lwip/opt.h"
 
-typedef enum {
-  MEMP_PBUF,
-  MEMP_RAW_PCB,
-  MEMP_UDP_PCB,
-  MEMP_TCP_PCB,
-  MEMP_TCP_PCB_LISTEN,
-  MEMP_TCP_SEG,
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-  MEMP_NETBUF,
-  MEMP_NETCONN,
-  MEMP_API_MSG,
-  MEMP_TCPIP_MSG,
-
-  MEMP_SYS_TIMEOUT,
-  
+/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
+typedef enum {
+#define LWIP_MEMPOOL(name,num,size,desc)  MEMP_##name,
+#include "lwip/memp_std.h"
   MEMP_MAX
 } memp_t;
 
-void memp_init(void);
+#if MEM_USE_POOLS
+/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
+typedef enum {
+    /* Get the first (via:
+       MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
+    MEMP_POOL_HELPER_FIRST = ((u8_t)
+#define LWIP_MEMPOOL(name,num,size,desc)
+#define LWIP_MALLOC_MEMPOOL_START 1
+#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
+#define LWIP_MALLOC_MEMPOOL_END
+#include "lwip/memp_std.h"
+    ) ,
+    /* Get the last (via:
+       MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
+    MEMP_POOL_HELPER_LAST = ((u8_t)
+#define LWIP_MEMPOOL(name,num,size,desc)
+#define LWIP_MALLOC_MEMPOOL_START
+#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
+#define LWIP_MALLOC_MEMPOOL_END 1
+#include "lwip/memp_std.h"
+    )
+} memp_pool_helper_t;
+
+/* The actual start and stop values are here (cast them over)
+   We use this helper type and these defines so we can avoid using const memp_t values */
+#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
+#define MEMP_POOL_LAST   ((memp_t) MEMP_POOL_HELPER_LAST)
+#endif /* MEM_USE_POOLS */
 
+#if MEMP_MEM_MALLOC || MEM_USE_POOLS
+extern const u16_t memp_sizes[MEMP_MAX];
+#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
+
+#if MEMP_MEM_MALLOC
+
+#include "mem.h"
+
+#define memp_init()
+#define memp_malloc(type)     mem_malloc(memp_sizes[type])
+#define memp_free(type, mem)  mem_free(mem)
+
+#else /* MEMP_MEM_MALLOC */
+
+#if MEM_USE_POOLS
+/** This structure is used to save the pool one element came from. */
+struct memp_malloc_helper
+{
+   memp_t poolnr;
+};
+#endif /* MEM_USE_POOLS */
+
+void  memp_init(void);
+
+#if MEMP_OVERFLOW_CHECK
+void *memp_malloc_fn(memp_t type, const char* file, const int line);
+#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
+#else
 void *memp_malloc(memp_t type);
-void *memp_realloc(memp_t fromtype, memp_t totype, void *mem);
-void memp_free(memp_t type, void *mem);
+#endif
+void  memp_free(memp_t type, void *mem);
+
+#endif /* MEMP_MEM_MALLOC */
 
-#endif /* __LWIP_MEMP_H__  */
-    
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LWIP_MEMP_H__ */
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/memp_std.h
@@ -0,0 +1,102 @@
+/*
+ * SETUP: Make sure we define everything we will need.
+ *
+ * We have create three types of pools:
+ *   1) MEMPOOL - standard pools
+ *   2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
+ *   3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
+ *
+ * If the include'r doesn't require any special treatment of each of the types
+ * above, then will declare #2 & #3 to be just standard mempools.
+ */
+#ifndef LWIP_MALLOC_MEMPOOL
+/* This treats "malloc pools" just like any other pool.
+   The pools are a little bigger to provide 'size' as the amount of user data. */
+#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size)
+#define LWIP_MALLOC_MEMPOOL_START
+#define LWIP_MALLOC_MEMPOOL_END
+#endif /* LWIP_MALLOC_MEMPOOL */ 
+
+#ifndef LWIP_PBUF_MEMPOOL
+/* This treats "pbuf pools" just like any other pool.
+ * Allocates buffers for a pbuf struct AND a payload size */
+#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
+#endif /* LWIP_PBUF_MEMPOOL */
+
+
+/*
+ * A list of internal pools used by LWIP.
+ *
+ * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
+ *     creates a pool name MEMP_pool_name. description is used in stats.c
+ */
+#if LWIP_RAW
+LWIP_MEMPOOL(RAW_PCB,        MEMP_NUM_RAW_PCB,         sizeof(struct raw_pcb),        "RAW_PCB")
+#endif /* LWIP_RAW */
+
+#if LWIP_UDP
+LWIP_MEMPOOL(UDP_PCB,        MEMP_NUM_UDP_PCB,         sizeof(struct udp_pcb),        "UDP_PCB")
+#endif /* LWIP_UDP */
+
+#if LWIP_TCP
+LWIP_MEMPOOL(TCP_PCB,        MEMP_NUM_TCP_PCB,         sizeof(struct tcp_pcb),        "TCP_PCB")
+LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN,  sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
+LWIP_MEMPOOL(TCP_SEG,        MEMP_NUM_TCP_SEG,         sizeof(struct tcp_seg),        "TCP_SEG")
+#endif /* LWIP_TCP */
+
+#if IP_REASSEMBLY
+LWIP_MEMPOOL(REASSDATA,      MEMP_NUM_REASSDATA,       sizeof(struct ip_reassdata),   "REASSDATA")
+#endif /* IP_REASSEMBLY */
+
+#if LWIP_NETCONN
+LWIP_MEMPOOL(NETBUF,         MEMP_NUM_NETBUF,          sizeof(struct netbuf),         "NETBUF")
+LWIP_MEMPOOL(NETCONN,        MEMP_NUM_NETCONN,         sizeof(struct netconn),        "NETCONN")
+#endif /* LWIP_NETCONN */
+
+#if NO_SYS==0
+LWIP_MEMPOOL(TCPIP_MSG_API,  MEMP_NUM_TCPIP_MSG_API,   sizeof(struct tcpip_msg),      "TCPIP_MSG_API")
+LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg),      "TCPIP_MSG_INPKT")
+#endif /* NO_SYS==0 */
+
+#if ARP_QUEUEING
+LWIP_MEMPOOL(ARP_QUEUE,      MEMP_NUM_ARP_QUEUE,       sizeof(struct etharp_q_entry), "ARP_QUEUE")
+#endif /* ARP_QUEUEING */
+
+#if LWIP_IGMP
+LWIP_MEMPOOL(IGMP_GROUP,     MEMP_NUM_IGMP_GROUP,      sizeof(struct igmp_group),     "IGMP_GROUP")
+#endif /* LWIP_IGMP */
+
+#if NO_SYS==0
+LWIP_MEMPOOL(SYS_TIMEOUT,    MEMP_NUM_SYS_TIMEOUT,     sizeof(struct sys_timeo),      "SYS_TIMEOUT")
+#endif /* NO_SYS==0 */
+
+
+/*
+ * A list of pools of pbuf's used by LWIP.
+ *
+ * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
+ *     creates a pool name MEMP_pool_name. description is used in stats.c
+ *     This allocates enough space for the pbuf struct and a payload.
+ *     (Example: pbuf_payload_size=0 allocates only size for the struct)
+ */
+LWIP_PBUF_MEMPOOL(PBUF,      MEMP_NUM_PBUF,            0,                             "PBUF_REF/ROM")
+LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE,           PBUF_POOL_BUFSIZE,             "PBUF_POOL")
+
+
+/*
+ * Allow for user-defined pools; this must be explicitly set in lwipopts.h
+ * since the default is to NOT look for lwippools.h
+ */
+#if MEMP_USE_CUSTOM_POOLS
+#include "lwippools.h"
+#endif /* MEMP_USE_CUSTOM_POOLS */
+
+/*
+ * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
+ * (#undef is ignored for something that is not defined)
+ */
+#undef LWIP_MEMPOOL
+#undef LWIP_MALLOC_MEMPOOL
+#undef LWIP_MALLOC_MEMPOOL_START
+#undef LWIP_MALLOC_MEMPOOL_END
+#undef LWIP_PBUF_MEMPOOL
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/netbuf.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * 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,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    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. 
+ *
+ * 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 <adam@sics.se>
+ *
+ */
+#ifndef __LWIP_NETBUF_H__
+#define __LWIP_NETBUF_H__
+
+#include "lwip/opt.h"
+#include "lwip/pbuf.h"
+#include "lwip/ip_addr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct netbuf {
+  struct pbuf *p, *ptr;
+  struct ip_addr *addr;
+  u16_t port;
+#if LWIP_NETBUF_RECVINFO
+  struct ip_addr *toaddr;
+  u16_t toport;
+#endif /* LWIP_NETBUF_RECVINFO */
+};
+
+/* Network buffer functions: */
+struct netbuf *   netbuf_new      (void);
+void              netbuf_delete   (struct netbuf *buf);
+void *            netbuf_alloc    (struct netbuf *buf, u16_t size);
+void              netbuf_free     (struct netbuf *buf);
+err_t             netbuf_ref      (struct netbuf *buf,
+           const void *dataptr, u16_t size);
+void              netbuf_chain    (struct netbuf *head,
+           struct netbuf *tail);
+
+u16_t             netbuf_len      (struct netbuf *buf);
+err_t             netbuf_data     (struct netbuf *buf,
+           void **dataptr, u16_t *len);
+s8_t              netbuf_next     (struct netbuf *buf);
+void              netbuf_first    (struct netbuf *buf);
+
+
+#define netbuf_copy_partial(buf, dataptr, len, offset) \
+  pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
+#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
+#define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
+#define netbuf_len(buf)              ((buf)->p->tot_len)
+#define netbuf_fromaddr(buf)         ((buf)->addr)
+#define netbuf_fromport(buf)         ((buf)->port)
+#if LWIP_NETBUF_RECVINFO
+#define netbuf_destaddr(buf)         ((buf)->toaddr)
+#define netbuf_destport(buf)         ((buf)->toport)
+#endif /* LWIP_NETBUF_RECVINFO */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LWIP_NETBUF_H__ */
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/netdb.h
@@ -0,0 +1,111 @@
+/*
+ * 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,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    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. 
+ *
+ * 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: Simon Goldschmidt
+ *
+ */
+
+#include "lwip/opt.h"
+
+#if LWIP_DNS && LWIP_SOCKET
+
+#include <stddef.h> /* for size_t */
+
+#include "lwip/sockets.h"
+
+/* some rarely used options */
+#ifndef LWIP_DNS_API_DECLARE_H_ERRNO
+#define LWIP_DNS_API_DECLARE_H_ERRNO 1
+#endif
+
+#ifndef LWIP_DNS_API_DEFINE_ERRORS
+#define LWIP_DNS_API_DEFINE_ERRORS 1
+#endif
+
+#ifndef LWIP_DNS_API_DECLARE_STRUCTS
+#define LWIP_DNS_API_DECLARE_STRUCTS 1
+#endif
+
+#if LWIP_DNS_API_DEFINE_ERRORS
+/** Errors used by the DNS API functions, h_errno can be one of them */
+#define EAI_NONAME      200
+#define EAI_SERVICE     201
+#define EAI_FAIL        202
+#define EAI_MEMORY      203
+
+#define HOST_NOT_FOUND  210
+#define NO_DATA         211
+#define NO_RECOVERY     212
+#define TRY_AGAIN       213
+#endif /* LWIP_DNS_API_DEFINE_ERRORS */
+
+#if LWIP_DNS_API_DECLARE_STRUCTS
+struct hostent {
+    char  *h_name;      /* Official name of the host. */
+    char **h_aliases;   /* A pointer to an array of pointers to alternative host names,
+                           terminated by a null pointer. */
+    int    h_addrtype;  /* Address type. */
+    int    h_length;    /* The length, in bytes, of the address. */
+    char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
+                           network byte order) for the host, terminated by a null pointer. */
+#define h_addr h_addr_list[0] /* for backward compatibility */
+};
+
+struct addrinfo {
+    int               ai_flags;      /* Input flags. */
+    int               ai_family;     /* Address family of socket. */
+    int               ai_socktype;   /* Socket type. */
+    int               ai_protocol;   /* Protocol of socket. */
+    socklen_t         ai_addrlen;    /* Length of socket address. */
+    struct sockaddr  *ai_addr;       /* Socket address of socket. */
+    char             *ai_canonname;  /* Canonical name of service location. */
+    struct addrinfo  *ai_next;       /* Pointer to next in list. */
+};
+#endif /* LWIP_DNS_API_DECLARE_STRUCTS */
+
+#if LWIP_DNS_API_DECLARE_H_ERRNO
+/* application accessable error code set by the DNS API functions */
+extern int h_errno;
+#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
+
+struct hostent *lwip_gethostbyname(const char *name);
+int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
+                size_t buflen, struct hostent **result, int *h_errnop);
+void lwip_freeaddrinfo(struct addrinfo *ai);
+int lwip_getaddrinfo(const char *nodename,
+       const char *servname,
+       const struct addrinfo *hints,
+       struct addrinfo **res);
+
+#if LWIP_COMPAT_SOCKETS
+#define gethostbyname(name) lwip_gethostbyname(name)
+#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
+       lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
+#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
+#define getaddrinfo(nodname, servname, hints, res) \
+       lwip_getaddrinfo(nodname, servname, hints, res)
+#endif /* LWIP_COMPAT_SOCKETS */
+
+#endif /* LWIP_DNS && LWIP_SOCKET */
--- a/packages/net/lwip_tcpip/current/include/lwip/netif.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/netif.h
@@ -34,6 +34,8 @@
 
 #include "lwip/opt.h"
 
+#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
+
 #include "lwip/err.h"
 
 #include "lwip/ip_addr.h"
@@ -41,9 +43,19 @@
 #include "lwip/inet.h"
 #include "lwip/pbuf.h"
 #if LWIP_DHCP
-#  include "lwip/dhcp.h"
+struct dhcp;
+#endif
+#if LWIP_AUTOIP
+struct autoip;
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Throughout this file, IP addresses are expected to be in
+ * the same byte order as in IP_PCB. */
+
 /** must be the maximum of all used hardware address lengths
     across all types of interfaces in use */
 #define NETIF_MAX_HWADDR_LEN 6U
@@ -54,16 +66,20 @@
  * a software flag used to control whether this network
  * interface is enabled and processes traffic.
  */
-#define NETIF_FLAG_UP 0x1U
+#define NETIF_FLAG_UP           0x01U
 /** if set, the netif has broadcast capability */
-#define NETIF_FLAG_BROADCAST 0x2U
+#define NETIF_FLAG_BROADCAST    0x02U
 /** if set, the netif is one end of a point-to-point connection */
-#define NETIF_FLAG_POINTTOPOINT 0x4U
+#define NETIF_FLAG_POINTTOPOINT 0x04U
 /** if set, the interface is configured using DHCP */
-#define NETIF_FLAG_DHCP 0x08U
+#define NETIF_FLAG_DHCP         0x08U
 /** if set, the interface has an active link
  *  (set by the network interface driver) */
-#define NETIF_FLAG_LINK_UP 0x10U
+#define NETIF_FLAG_LINK_UP      0x10U
+/** if set, the netif is an device using ARP */
+#define NETIF_FLAG_ETHARP       0x20U
+/** if set, the netif has IGMP capability */
+#define NETIF_FLAG_IGMP         0x40U
 
 /** Generic data structure used for all lwIP network interfaces.
  *  The following fields should be filled in by the initialization
@@ -90,61 +106,158 @@ struct netif {
    *  to send a packet on the interface. This function outputs
    *  the pbuf as-is on the link medium. */
   err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
+#if LWIP_NETIF_STATUS_CALLBACK
+  /** This function is called when the netif state is set to up or down
+   */
+  void (* status_callback)(struct netif *netif);
+#endif /* LWIP_NETIF_STATUS_CALLBACK */
+#if LWIP_NETIF_LINK_CALLBACK
+  /** This function is called when the netif link is set to up or down
+   */
+  void (* link_callback)(struct netif *netif);
+#endif /* LWIP_NETIF_LINK_CALLBACK */
   /** This field can be set by the device driver and could point
    *  to state information for the device. */
   void *state;
 #if LWIP_DHCP
   /** the DHCP client state information for this netif */
   struct dhcp *dhcp;
+#endif /* LWIP_DHCP */
+#if LWIP_AUTOIP
+  /** the AutoIP client state information for this netif */
+  struct autoip *autoip;
 #endif
+#if LWIP_NETIF_HOSTNAME
+  /* the hostname for this netif, NULL is a valid value */
+  char*  hostname;
+#endif /* LWIP_NETIF_HOSTNAME */
+  /** maximum transfer unit (in bytes) */
+  u16_t mtu;
   /** number of bytes used in hwaddr */
   u8_t hwaddr_len;
   /** link level hardware address of this interface */
   u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
-  /** maximum transfer unit (in bytes) */
-  u16_t mtu;
   /** flags (see NETIF_FLAG_ above) */
   u8_t flags;
-  /** link type */
-  u8_t link_type;
   /** descriptive abbreviation */
   char name[2];
   /** number of this interface */
   u8_t num;
+#if LWIP_SNMP
+  /** link type (from "snmp_ifType" enum from snmp.h) */
+  u8_t link_type;
+  /** (estimate) link speed */
+  u32_t link_speed;
+  /** timestamp at last change made (up/down) */
+  u32_t ts;
+  /** counters */
+  u32_t ifinoctets;
+  u32_t ifinucastpkts;
+  u32_t ifinnucastpkts;
+  u32_t ifindiscards;
+  u32_t ifoutoctets;
+  u32_t ifoutucastpkts;
+  u32_t ifoutnucastpkts;
+  u32_t ifoutdiscards;
+#endif /* LWIP_SNMP */
+#if LWIP_IGMP
+  /* This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/
+  err_t (*igmp_mac_filter)( struct netif *netif, struct ip_addr *group, u8_t action);
+#endif /* LWIP_IGMP */
+#if LWIP_NETIF_HWADDRHINT
+  u8_t *addr_hint;
+#endif /* LWIP_NETIF_HWADDRHINT */
+#if ENABLE_LOOPBACK
+  /* List of packets to be queued for ourselves. */
+  struct pbuf *loop_first;
+  struct pbuf *loop_last;
+#if LWIP_LOOPBACK_MAX_PBUFS
+  u16_t loop_cnt_current;
+#endif /* LWIP_LOOPBACK_MAX_PBUFS */
+#endif /* ENABLE_LOOPBACK */
 };
 
+#if LWIP_SNMP
+#define NETIF_INIT_SNMP(netif, type, speed) \
+  /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \
+  netif->link_type = type;    \
+  /* your link speed here (units: bits per second) */  \
+  netif->link_speed = speed;  \
+  netif->ts = 0;              \
+  netif->ifinoctets = 0;      \
+  netif->ifinucastpkts = 0;   \
+  netif->ifinnucastpkts = 0;  \
+  netif->ifindiscards = 0;    \
+  netif->ifoutoctets = 0;     \
+  netif->ifoutucastpkts = 0;  \
+  netif->ifoutnucastpkts = 0; \
+  netif->ifoutdiscards = 0
+#else /* LWIP_SNMP */
+#define NETIF_INIT_SNMP(netif, type, speed)
+#endif /* LWIP_SNMP */
+
+
 /** The list of network interfaces. */
 extern struct netif *netif_list;
 /** The default network interface. */
 extern struct netif *netif_default;
 
-/* netif_init() must be called first. */
-externC void netif_init(void);
+#define netif_init() /* Compatibility define, not init needed. */
 
-externC struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
+struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
       struct ip_addr *gw,
       void *state,
       err_t (* init)(struct netif *netif),
       err_t (* input)(struct pbuf *p, struct netif *netif));
 
-externC void
+void
 netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
     struct ip_addr *gw);
-externC void netif_remove(struct netif * netif);
+void netif_remove(struct netif * netif);
 
 /* Returns a network interface given its name. The name is of the form
    "et0", where the first two letters are the "name" field in the
    netif structure, and the digit is in the num field in the same
    structure. */
-externC struct netif *netif_find(char *name);
+struct netif *netif_find(char *name);
+
+void netif_set_default(struct netif *netif);
+
+void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
+void netif_set_netmask(struct netif *netif, struct ip_addr *netmask);
+void netif_set_gw(struct netif *netif, struct ip_addr *gw);
 
-externC void netif_set_default(struct netif *netif);
+void netif_set_up(struct netif *netif);
+void netif_set_down(struct netif *netif);
+u8_t netif_is_up(struct netif *netif);
+
+#if LWIP_NETIF_STATUS_CALLBACK
+/*
+ * Set callback to be called when interface is brought up/down
+ */
+void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif));
+#endif /* LWIP_NETIF_STATUS_CALLBACK */
 
-externC void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
-externC void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
-externC void netif_set_gw(struct netif *netif, struct ip_addr *gw);
-externC void netif_set_up(struct netif *netif);
-externC void netif_set_down(struct netif *netif);
-externC u8_t netif_is_up(struct netif *netif);
+#if LWIP_NETIF_LINK_CALLBACK
+void netif_set_link_up(struct netif *netif);
+void netif_set_link_down(struct netif *netif);
+u8_t netif_is_link_up(struct netif *netif);
+/*
+ * Set callback to be called when link is brought up/down
+ */
+void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif));
+#endif /* LWIP_NETIF_LINK_CALLBACK */
+
+#ifdef __cplusplus
+}
+#endif
+
+#if ENABLE_LOOPBACK
+err_t netif_loop_output(struct netif *netif, struct pbuf *p, struct ip_addr *dest_ip);
+void netif_poll(struct netif *netif);
+#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
+void netif_poll_all(void);
+#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
+#endif /* ENABLE_LOOPBACK */
 
 #endif /* __LWIP_NETIF_H__ */
new file mode 100644
--- /dev/null
+++ b/packages/net/lwip_tcpip/current/include/lwip/netifapi.h
@@ -0,0 +1,105 @@
+/*
+ * 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,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    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. 
+ *
+ * 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.
+ * 
+ */
+ 
+#ifndef __LWIP_NETIFAPI_H__
+#define __LWIP_NETIFAPI_H__
+
+#include "lwip/opt.h"
+
+#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
+
+#include "lwip/sys.h"
+#include "lwip/netif.h"
+#include "lwip/dhcp.h"
+#include "lwip/autoip.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct netifapi_msg_msg {
+#if !LWIP_TCPIP_CORE_LOCKING
+  sys_sem_t sem;
+#endif /* !LWIP_TCPIP_CORE_LOCKING */
+  err_t err;
+  struct netif *netif;
+  union {
+    struct {
+      struct ip_addr *ipaddr;
+      struct ip_addr *netmask;
+      struct ip_addr *gw;
+      void *state;
+      err_t (* init) (struct netif *netif);
+      err_t (* input)(struct pbuf *p, struct netif *netif);
+    } add;
+    struct {
+      void  (* voidfunc)(struct netif *netif);
+      err_t (* errtfunc)(struct netif *netif);
+    } common;
+  } msg;
+};
+
+struct netifapi_msg {
+  void (* function)(struct netifapi_msg_msg *msg);
+  struct netifapi_msg_msg msg;
+};
+
+
+/* API for application */
+err_t netifapi_netif_add       ( struct netif *netif,
+                                 struct ip_addr *ipaddr,
+                                 struct ip_addr *netmask,
+                                 struct ip_addr *gw,
+                                 void *state,
+                                 err_t (* init)(struct netif *netif),
+                                 err_t (* input)(struct pbuf *p, struct netif *netif) );
+
+err_t netifapi_netif_set_addr  ( struct netif *netif,
+                                 struct ip_addr *ipaddr,
+                                 struct ip_addr *netmask,
+                                 struct ip_addr *gw );
+
+err_t netifapi_netif_common    ( struct netif *netif,
+                                 void  (* voidfunc)(struct netif *netif),
+                                 err_t (* errtfunc)(struct netif *netif) );
+
+#define netifapi_netif_remove(n)      netifapi_netif_common(n, netif_remove, NULL)
+#define netifapi_netif_set_up(n)      netifapi_netif_common(n, netif_set_up, NULL)
+#define netifapi_netif_set_down(n)    netifapi_netif_common(n, netif_set_down, NULL)
+#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
+#define netifapi_dhcp_start(n)        netifapi_netif_common(n, NULL, dhcp_start)
+#define netifapi_dhcp_stop(n)         netifapi_netif_common(n, dhcp_stop, NULL)
+#define netifapi_autoip_start(n)      netifapi_netif_common(n, NULL, autoip_start)
+#define netifapi_autoip_stop(n)       netifapi_netif_common(n, NULL, autoip_stop)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_NETIF_API */
+
+#endif /* __LWIP_NETIFAPI_H__ */
--- a/packages/net/lwip_tcpip/current/include/lwip/opt.h
+++ b/packages/net/lwip_tcpip/current/include/lwip/opt.h
@@ -1,3 +1,9 @@
+/**
+ * @file
+ *
+ * lwIP Options Configuration
+ */
+
 /*
  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
  * All rights reserved. 
@@ -32,460 +38,1473 @@
 #ifndef __LWIP_OPT_H__
 #define __LWIP_OPT_H__
 
-/* Include user defined options first */
+/*
+ * Include user defined options first. Anything not defined in these files
+ * will be set to standard values. Override anything you dont like!
+ */
 #include "lwipopts.h"
 #include "lwip/debug.h"
 
-/* Define default values for unconfigured parameters. */
-
-/* Platform specific locking */
+/*
+   -----------------------------------------------
+   ---------- Platform specific locking ----------
+   -----------------------------------------------
+*/
 
-/*
- * enable SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
+/**
+ * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
+ * critical regions during buffer allocation, deallocation and memory
  * allocation and deallocation.
  */
 #ifndef SYS_LIGHTWEIGHT_PROT
 #define SYS_LIGHTWEIGHT_PROT            0
 #endif
 
+/** 
+ * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
+ * use lwIP facilities.
+ */
 #ifndef NO_SYS
 #define NO_SYS                          0
 #endif
-/* ---------- Memory options ---------- */
-/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
-   lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
-   byte alignment -> define MEM_ALIGNMENT to 2. */
+
+/**
+ * MEMCPY: override this if you have a faster implementation at hand than the
+ * one included in your C library
+ */
+#ifndef MEMCPY
+#define MEMCPY(dst,src,len)             memcpy(dst,src,len)
+#endif
+
+/**
+ * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a
+ * call to memcpy() if the length is known at compile time and is small.
+ */
+#ifndef SMEMCPY
+#define SMEMCPY(dst,src,len)            memcpy(dst,src,len)
+#endif
 
+/*
+   ------------------------------------
+   ---------- Memory options ----------
+   ------------------------------------
+*/
+/**
+ * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
+ * instead of the lwip internal allocator. Can save code size if you
+ * already use it.
+ */
+#ifndef MEM_LIBC_MALLOC
+#define MEM_LIBC_MALLOC                 0
+#endif
+
+/**
+* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
+* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
+* speed and usage from interrupts!
+*/
+#ifndef MEMP_MEM_MALLOC
+#define MEMP_MEM_MALLOC                 0
+#endif
+
+/**
+ * MEM_ALIGNMENT: should be set to the alignment of the CPU
+ *    4 byte alignment -> #define MEM_ALIGNMENT 4
+ *    2 byte alignment -> #define MEM_ALIGNMENT 2
+ */
 #ifndef MEM_ALIGNMENT
 #define MEM_ALIGNMENT                   1
 #endif
 
-/* MEM_SIZE: the size of the heap memory. If the application will send
-a lot of data that needs to be copied, this should be set high. */
+/**
+ * MEM_SIZE: the size of the heap memory. If the application will send
+ * a lot of data that needs to be copied, this should be set high.
+ */
 #ifndef MEM_SIZE
 #define MEM_SIZE                        1600
 #endif
 
+/**
+ * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable
+ * amount of bytes before and after each memp element in every pool and fills
+ * it with a prominent default value.
+ *    MEMP_OVERFLOW_CHECK == 0 no checking
+ *    MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed
+ *    MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time
+ *      memp_malloc() or memp_free() is called (useful but slow!)
+ */
+#ifndef MEMP_OVERFLOW_CHECK
+#define MEMP_OVERFLOW_CHECK             0
+#endif
+
+/**
+ * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make
+ * sure that there are no cycles in the linked lists.
+ */
 #ifndef MEMP_SANITY_CHECK
-#define MEMP_SANITY_CHECK       0
+#define MEMP_SANITY_CHECK               0
+#endif
+
+/**
+ * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set
+ * of memory pools of various sizes. When mem_malloc is called, an element of
+ * the smallest pool that can provide the length needed is returned.
+ * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled.
+ */
+#ifndef MEM_USE_POOLS
+#define MEM_USE_POOLS                   0
+#endif
+
+/**
+ * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next
+ * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more
+ * reliable. */
+#ifndef MEM_USE_POOLS_TRY_BIGGER_POOL
+#define MEM_USE_POOLS_TRY_BIGGER_POOL   0
 #endif
 
-/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
-   sends a lot of data out of ROM (or other static memory), this
-   should be set high. */
+/**
+ * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h
+ * that defines additional pools beyond the "standard" ones required
+ * by lwIP. If you set this to 1, you must have lwippools.h in your 
+ * inlude path somewhere. 
+ */
+#ifndef MEMP_USE_CUSTOM_POOLS
+#define MEMP_USE_CUSTOM_POOLS           0
+#endif
+
+/**
+ * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from
+ * interrupt context (or another context that doesn't allow waiting for a
+ * semaphore).
+ * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT,
+ * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs
+ * with each loop so that mem_free can run.
+ *
+ * ATTENTION: As you can see from the above description, this leads to dis-/
+ * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc
+ * can need longer.
+ *
+ * If you don't want that, at least for NO_SYS=0, you can still use the following
+ * functions to enqueue a deallocation call which then runs in the tcpip_thread
+ * context:
+ * - pbuf_free_callback(p);
+ * - mem_free_callback(m);
+ */
+#ifndef LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
+#endif
+
+/*
+   ------------------------------------------------
+   ---------- Internal Memory Pool Sizes ----------
+   ------------------------------------------------
+*/
+/**
+ * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
+ * If the application sends a lot of data out of ROM (or other static memory),
+ * this should be set high.
+ */
 #ifndef MEMP_NUM_PBUF
 #define MEMP_NUM_PBUF                   16
 #endif
 
-/* Number of raw connection PCBs */
+/**
+ * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
+ * (requires the LWIP_RAW option)
+ */
 #ifndef MEMP_NUM_RAW_PCB
 #define MEMP_NUM_RAW_PCB                4
 #endif
 
-/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
-   per active UDP "connection". */
+/**
+ * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+ * per active UDP "connection".
+ * (requires the LWIP_UDP option)
+ */
 #ifndef MEMP_NUM_UDP_PCB
 #define MEMP_NUM_UDP_PCB                4
 #endif
-/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
-   connections. */
+
+/**
+ * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
+ * (requires the LWIP_TCP option)
+ */
 #ifndef MEMP_NUM_TCP_PCB
 #define MEMP_NUM_TCP_PCB                5
 #endif
-/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
-   connections. */
+
+/**
+ * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
+ * (requires the LWIP_TCP option)
+ */
 #ifndef MEMP_NUM_TCP_PCB_LISTEN
 #define MEMP_NUM_TCP_PCB_LISTEN         8
 #endif
-/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
-   segments. */
+
+/**
+ * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
+ * (requires the LWIP_TCP option)
+ */
 #ifndef MEMP_NUM_TCP_SEG
 #define MEMP_NUM_TCP_SEG                16
 #endif
-/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
-   timeouts. */
+
+/**
+ * MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
+ * reassembly (whole packets, not fragments!)
+ */
+#ifndef MEMP_NUM_REASSDATA
+#define MEMP_NUM_REASSDATA              5
+#endif
+
+/**
+ * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing
+ * packets (pbufs) that are waiting for an ARP request (to resolve
+ * their destination address) to finish.
+ * (requires the ARP_QUEUEING option)
+ */
+#ifndef MEMP_NUM_ARP_QUEUE
+#define MEMP_NUM_ARP_QUEUE              30
+#endif
+
+/**
+ * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces
+ * can be members et the same time (one per netif - allsystems group -, plus one
+ * per netif membership).
+ * (requires the LWIP_IGMP option)
+ */
+#ifndef MEMP_NUM_IGMP_GROUP
+#define MEMP_NUM_IGMP_GROUP             8
+#endif
+
+/**
+ * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
+ * (requires NO_SYS==0)
+ */
 #ifndef MEMP_NUM_SYS_TIMEOUT
 #define MEMP_NUM_SYS_TIMEOUT            3
 #endif
 
-/* The following four are used only with the sequential API and can be
-   set to 0 if the application only will use the raw API. */
-/* MEMP_NUM_NETBUF: the number of struct netbufs. */
+/**
+ * MEMP_NUM_NETBUF: the number of struct netbufs.
+ * (only needed if you use the sequential API, like api_lib.c)
+ */
 #ifndef MEMP_NUM_NETBUF
 #define MEMP_NUM_NETBUF                 2
 #endif
-/* MEMP_NUM_NETCONN: the number of struct netconns. */
+
+/**
+ * MEMP_NUM_NETCONN: the number of struct netconns.
+ * (only needed if you use the sequential API, like api_lib.c)
+ */
 #ifndef MEMP_NUM_NETCONN
 #define MEMP_NUM_NETCONN                4
 #endif
-/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
-   communication between the TCP/IP stack and the sequential
-   programs. */
-#ifndef MEMP_NUM_API_MSG
-#define MEMP_NUM_API_MSG                8
-#endif
-/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
-   for sequential API communication and incoming packets. Used in
-   src/api/tcpip.c. */
-#ifndef MEMP_NUM_TCPIP_MSG
-#define MEMP_NUM_TCPIP_MSG              8
+
+/**
+ * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
+ * for callback/timeout API communication. 
+ * (only needed if you use tcpip.c)
+ */
+#ifndef MEMP_NUM_TCPIP_MSG_API
+#define MEMP_NUM_TCPIP_MSG_API          8
 #endif
 
-/* ---------- Pbuf options ---------- */
-/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+/**
+ * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
+ * for incoming packets. 
+ * (only needed if you use tcpip.c)
+ */
+#ifndef MEMP_NUM_TCPIP_MSG_INPKT
+#define MEMP_NUM_TCPIP_MSG_INPKT        8
+#endif
 
+/**
+ * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. 
+ */
 #ifndef PBUF_POOL_SIZE
 #define PBUF_POOL_SIZE                  16
 #endif
 
-/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
-
-#ifndef PBUF_POOL_BUFSIZE
-#define PBUF_POOL_BUFSIZE               128
+/*
+   ---------------------------------
+   ---------- ARP options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_ARP==1: Enable ARP functionality.
+ */
+#ifndef LWIP_ARP
+#define LWIP_ARP                        1
 #endif
 
-/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
-   link level header. Defaults to 14 for Ethernet. */
-
-#ifndef PBUF_LINK_HLEN
-#define PBUF_LINK_HLEN                  14
-#endif
-
-
-
-/* ---------- ARP options ---------- */
-
-/** Number of active hardware address, IP address pairs cached */
+/**
+ * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached.
+ */
 #ifndef ARP_TABLE_SIZE
 #define ARP_TABLE_SIZE                  10
 #endif
 
 /**
- * If enabled, outgoing packets are queued during hardware address
+ * ARP_QUEUEING==1: Outgoing packets are queued during hardware address
  * resolution.
- *
- * This feature has not stabilized yet. Single-packet queueing is
- * believed to be stable, multi-packet queueing is believed to
- * clash with the TCP segment queueing.
- * 
- * As multi-packet-queueing is currently disabled, enabling this
- * _should_ work, but we need your testing feedback on lwip-users.
- *
  */
 #ifndef ARP_QUEUEING
 #define ARP_QUEUEING                    1
 #endif
 
-/* This option is deprecated */
-#ifdef ETHARP_QUEUE_FIRST
-#error ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h.
+/**
+ * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be
+ * updated with the source MAC and IP addresses supplied in the packet.
+ * You may want to disable this if you do not trust LAN peers to have the
+ * correct addresses, or as a limited approach to attempt to handle
+ * spoofing. If disabled, lwIP will need to make a new ARP request if
+ * the peer is not already in the ARP table, adding a little latency.
+ */
+#ifndef ETHARP_TRUST_IP_MAC
+#define ETHARP_TRUST_IP_MAC             1
 #endif
 
-/* This option is removed to comply with the ARP standard */
-#ifdef ETHARP_ALWAYS_INSERT
-#error ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h.
+/**
+ * ETHARP_SUPPORT_VLAN==1: support receiving ethernet packets with VLAN header.
+ * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check.
+ * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted.
+ * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted.
+ */
+#ifndef ETHARP_SUPPORT_VLAN
+#define ETHARP_SUPPORT_VLAN             0
 #endif
 
-/* ---------- IP options ---------- */
-/* Define IP_FORWARD to 1 if you wish to have the ability to forward
-   IP packets across network interfaces. If you are going to run lwIP
-   on a device with only one network interface, define this to 0. */
+/*
+   --------------------------------
+   ---------- IP options ----------
+   --------------------------------
+*/
+/**
+ * IP_FORWARD==1: Enables the ability to forward IP packets across network
+ * interfaces. If you are going to run lwIP on a device with only one network
+ * interface, define this to 0.
+ */
 #ifndef IP_FORWARD
 #define IP_FORWARD                      0
 #endif
 
-/* If defined to 1, IP options are allowed (but not parsed). If
-   defined to 0, all packets with IP options are dropped. */
-#ifndef IP_OPTIONS
-#define IP_OPTIONS                      1
+/**
+ * IP_OPTIONS_ALLOWED: Defines the behavior for IP options.
+ *      IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped.
+ *      IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed).
+ */
+#ifndef IP_OPTIONS_ALLOWED
+#define IP_OPTIONS_ALLOWED              1
 #endif
 
-/** IP reassembly and segmentation. Even if they both deal with IP
- *  fragments, note that these are orthogonal, one dealing with incoming
- *  packets, the other with outgoing packets
+/**
+ * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that
+ * this option does not affect outgoing packet sizes, which can be controlled
+ * via IP_FRAG.
  */
-
-/** Reassemble incoming fragmented IP packets */
 #ifndef IP_REASSEMBLY
 #define IP_REASSEMBLY                   1
 #endif
 
-/** Fragment outgoing IP packets if their size exceeds MTU */
+/**
+ * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
+ * that this option does not affect incoming packet sizes, which can be
+ * controlled via IP_REASSEMBLY.
+ */
 #ifndef IP_FRAG
 #define IP_FRAG                         1
 #endif
 
-/* ---------- ICMP options ---------- */
+/**
+ * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
+ * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
+ * in this time, the whole packet is discarded.
+ */
+#ifndef IP_REASS_MAXAGE
+#define IP_REASS_MAXAGE                 3
+#endif
+
+/**
+ * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
+ * Since the received pbufs are enqueued, be sure to configure
+ * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
+ * packets even if the maximum amount of fragments is enqueued for reassembly!
+ */
+#ifndef IP_REASS_MAX_PBUFS
+#define IP_REASS_MAX_PBUFS              10
+#endif
 
-#ifndef ICMP_TTL
-#define ICMP_TTL                        255
+/**
+ * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP
+ * fragmentation. Otherwise pbufs are allocated and reference the original
+ * packet data to be fragmented.
+ */
+#ifndef IP_FRAG_USES_STATIC_BUF
+#define IP_FRAG_USES_STATIC_BUF         1
+#endif
+
+/**
+ * IP_FRAG_MAX_MTU: Assumed max MTU on any interface for IP frag buffer
+ * (requires IP_FRAG_USES_STATIC_BUF==1)
+ */
+#if IP_FRAG_USES_STATIC_BUF && !defined(IP_FRAG_MAX_MTU)
+#define IP_FRAG_MAX_MTU                 1500
+#endif
+
+/**
+ * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers.
+ */
+#ifndef IP_DEFAULT_TTL
+#define IP_DEFAULT_TTL                  255
 #endif
 
-/* ---------- RAW options ---------- */
+/**
+ * IP_SOF_BROADCAST=1: Use the SOF_BROADCAST field to enable broadcast
+ * filter per pcb on udp and raw send operations. To enable broadcast filter
+ * on recv operations, you also have to set IP_SOF_BROADCAST_RECV=1.
+ */
+#ifndef IP_SOF_BROADCAST
+#define IP_SOF_BROADCAST                0
+#endif
+
+/**
+ * IP_SOF_BROADCAST_RECV (requires IP_SOF_BROADCAST=1) enable the broadcast
+ * filter on recv operations.
+ */
+#ifndef IP_SOF_BROADCAST_RECV
+#define IP_SOF_BROADCAST_RECV           0
+#endif
+
+/*
+   ----------------------------------
+   ---------- ICMP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_ICMP==1: Enable ICMP module inside the IP stack.
+ * Be careful, disable that make your product non-compliant to RFC1122
+ */
+#ifndef LWIP_ICMP
+#define LWIP_ICMP                       1
+#endif
 
+/**
+ * ICMP_TTL: Default value for Time-To-Live used by ICMP packets.
+ */
+#ifndef ICMP_TTL
+#define ICMP_TTL                       (IP_DEFAULT_TTL)
+#endif
+
+/**
+ * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only)
+ */
+#ifndef LWIP_BROADCAST_PING
+#define LWIP_BROADCAST_PING             0
+#endif
+
+/**
+ * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only)
+ */
+#ifndef LWIP_MULTICAST_PING
+#define LWIP_MULTICAST_PING             0
+#endif
+
+/*
+   ---------------------------------
+   ---------- RAW options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
+ */
 #ifndef LWIP_RAW
 #define LWIP_RAW                        1
 #endif
 
+/**
+ * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
+ */
 #ifndef RAW_TTL
-#define RAW_TTL                        255
+#define RAW_TTL                        (IP_DEFAULT_TTL)
 #endif
 
-/* ---------- DHCP options ---------- */
-
+/*
+   ----------------------------------
+   ---------- DHCP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_DHCP==1: Enable DHCP module.
+ */
 #ifndef LWIP_DHCP
 #define LWIP_DHCP                       0
 #endif
 
-/* 1 if you want to do an ARP check on the offered address
-   (recommended). */
+/**
+ * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
+ */
 #ifndef DHCP_DOES_ARP_CHECK
-#define DHCP_DOES_ARP_CHECK             1
+#define DHCP_DOES_ARP_CHECK             ((LWIP_DHCP) && (LWIP_ARP))
+#endif
+
+/*
+   ------------------------------------
+   ---------- AUTOIP options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_AUTOIP==1: Enable AUTOIP module.
+ */
+#ifndef LWIP_AUTOIP
+#define LWIP_AUTOIP                     0
+#endif
+
+/**
+ * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on
+ * the same interface at the same time.
+ */
+#ifndef LWIP_DHCP_AUTOIP_COOP
+#define LWIP_DHCP_AUTOIP_COOP           0
+#endif
+
+/**
+ * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes
+ * that should be sent before falling back on AUTOIP. This can be set
+ * as low as 1 to get an AutoIP address very quickly, but you should
+ * be prepared to handle a changing IP address when DHCP overrides
+ * AutoIP.
+ */
+#ifndef LWIP_DHCP_AUTOIP_COOP_TRIES
+#define LWIP_DHCP_AUTOIP_COOP_TRIES     9
+#endif
+
+/*
+   ----------------------------------
+   ---------- SNMP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP
+ * transport.
+ */
+#ifndef LWIP_SNMP
+#define LWIP_SNMP                       0
+#endif
+
+/**
+ * SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will
+ * allow. At least one request buffer is required. 
+ */
+#ifndef SNMP_CONCURRENT_REQUESTS
+#define SNMP_CONCURRENT_REQUESTS        1
+#endif
+
+/**
+ * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
+ * destination is required
+ */
+#ifndef SNMP_TRAP_DESTINATIONS
+#define SNMP_TRAP_DESTINATIONS          1
+#endif
+
+/**
+ * SNMP_PRIVATE_MIB: 
+ */
+#ifndef SNMP_PRIVATE_MIB
+#define SNMP_PRIVATE_MIB                0
+#endif
+
+/**
+ * Only allow SNMP write actions that are 'safe' (e.g. disabeling netifs is not
+ * a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
+ * Unsafe requests are disabled by default!
+ */
+#ifndef SNMP_SAFE_REQUESTS
+#define SNMP_SAFE_REQUESTS              1
 #endif
 
-/* ---------- UDP options ---------- */
+/*
+   ----------------------------------
+   ---------- IGMP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_IGMP==1: Turn on IGMP module. 
+ */
+#ifndef LWIP_IGMP
+#define LWIP_IGMP                       0
+#endif
+
+/*
+   ----------------------------------
+   ---------- DNS options -----------
+   ----------------------------------
+*/
+/**
+ * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
+ * transport.
+ */
+#ifndef LWIP_DNS
+#define LWIP_DNS                        0
+#endif
+
+/** DNS maximum number of entries to maintain locally. */
+#ifndef DNS_TABLE_SIZE
+#define DNS_TABLE_SIZE                  4
+#endif
+
+/** DNS maximum host name length supported in the name table. */
+#ifndef DNS_MAX_NAME_LENGTH
+#define DNS_MAX_NAME_LENGTH             256
+#endif
+
+/** The maximum of DNS servers */
+#ifndef DNS_MAX_SERVERS
+#define DNS_MAX_SERVERS                 2
+#endif
+
+/** DNS do a name checking between the query and the response. */
+#ifndef DNS_DOES_NAME_CHECK
+#define DNS_DOES_NAME_CHECK             1
+#endif
+
+/** DNS use a local buffer if DNS_USES_STATIC_BUF=0, a static one if
+    DNS_USES_STATIC_BUF=1, or a dynamic one if DNS_USES_STATIC_BUF=2.
+    The buffer will be of size DNS_MSG_SIZE */
+#ifndef DNS_USES_STATIC_BUF
+#define DNS_USES_STATIC_BUF             1
+#endif
+
+/** DNS message max. size. Default value is RFC compliant. */
+#ifndef DNS_MSG_SIZE
+#define DNS_MSG_SIZE                    512
+#endif
+
+/** DNS_LOCAL_HOSTLIST: Implements a local host-to-address list. If enabled,
+ *  you have to define
+ *    #define DNS_LOCAL_HOSTLIST_INIT {{"host1", 0x123}, {"host2", 0x234}}
+ *  (an array of structs name/address, where address is an u32_t in network
+ *  byte order).
+ *
+ *  Instead, you can also use an external function:
+ *  #define DNS_LOOKUP_LOCAL_EXTERN(x) extern u32_t my_lookup_function(const char *name)
+ *  that returns the IP address or INADDR_NONE if not found.
+ */
+#ifndef DNS_LOCAL_HOSTLIST
+#define DNS_LOCAL_HOSTLIST              0
+#endif /* DNS_LOCAL_HOSTLIST */
+
+/** If this is turned on, the local host-list can be dynamically changed
+ *  at runtime. */
+#ifndef DNS_LOCAL_HOSTLIST_IS_DYNAMIC
+#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC   0
+#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+
+/*
+   ---------------------------------
+   ---------- UDP options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_UDP==1: Turn on UDP.
+ */
 #ifndef LWIP_UDP
 #define LWIP_UDP                        1
 #endif
 
+/**
+ * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP)
+ */
+#ifndef LWIP_UDPLITE
+#define LWIP_UDPLITE                    0
+#endif
+
+/**
+ * UDP_TTL: Default Time-To-Live value.
+ */
 #ifndef UDP_TTL
-#define UDP_TTL                         255
+#define UDP_TTL                         (IP_DEFAULT_TTL)
 #endif
 
-/* ---------- TCP options ---------- */
+/**
+ * LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf.
+ */
+#ifndef LWIP_NETBUF_RECVINFO
+#define LWIP_NETBUF_RECVINFO            0
+#endif
+
+/*
+   ---------------------------------
+   ---------- TCP options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_TCP==1: Turn on TCP.
+ */
 #ifndef LWIP_TCP
 #define LWIP_TCP                        1
 #endif
 
+/**
+ * TCP_TTL: Default Time-To-Live value.
+ */
 #ifndef TCP_TTL
-#define TCP_TTL                         255
+#define TCP_TTL                         (IP_DEFAULT_TTL)
 #endif
 
+/**
+ * TCP_WND: The size of a TCP window.  This must be at least 
+ * (2 * TCP_MSS) for things to work well
+ */
 #ifndef TCP_WND
-#define TCP_WND                         2048
+#define TCP_WND                         (4 * TCP_MSS)
 #endif 
 
+/**
+ * TCP_MAXRTX: Maximum number of retransmissions of data segments.
+ */
 #ifndef TCP_MAXRTX
 #define TCP_MAXRTX                      12
 #endif
 
+/**
+ * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments.
+ */
 #ifndef TCP_SYNMAXRTX
 #define TCP_SYNMAXRTX                   6
 #endif
 
-
-/* Controls if TCP should queue segments that arrive out of
-   order. Define to 0 if your device is low on memory. */
+/**
+ * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
+ * Define to 0 if your device is low on memory.
+ */
 #ifndef TCP_QUEUE_OOSEQ
-#define TCP_QUEUE_OOSEQ                 1
+#define TCP_QUEUE_OOSEQ                 (LWIP_TCP)
 #endif
 
-/* TCP Maximum segment size. */
+/**
+ * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default,
+ * you might want to increase this.)
+ * For the receive side, this MSS is advertised to the remote side
+ * when opening a connection. For the transmit size, this MSS sets
+ * an upper limit on the MSS advertised by the remote host.
+ */
 #ifndef TCP_MSS
-#define TCP_MSS                         128 /* A *very* conservative default. */
+#define TCP_MSS                         536
 #endif
 
-/* TCP sender buffer space (bytes). */
+/**
+ * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really
+ * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which
+ * reflects the available reassembly buffer size at the remote host) and the
+ * largest size permitted by the IP layer" (RFC 1122)
+ * Setting this to 1 enables code that checks TCP_MSS against the MTU of the
+ * netif used for a connection and limits the MSS if it would be too big otherwise.
+ */
+#ifndef TCP_CALCULATE_EFF_SEND_MSS
+#define TCP_CALCULATE_EFF_SEND_MSS      1
+#endif
+
+
+/**
+ * TCP_SND_BUF: TCP sender buffer space (bytes). 
+ */
 #ifndef TCP_SND_BUF
 #define TCP_SND_BUF                     256
 #endif
 
-/* TCP sender buffer space (pbufs). This must be at least = 2 *
-   TCP_SND_BUF/TCP_MSS for things to work. */
+/**
+ * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
+ * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work.
+ */
 #ifndef TCP_SND_QUEUELEN
-#define TCP_SND_QUEUELEN                4 * TCP_SND_BUF/TCP_MSS
+#define TCP_SND_QUEUELEN                (4 * (TCP_SND_BUF)/(TCP_MSS))
+#endif
+
+/**
+ * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than or equal
+ * to TCP_SND_BUF. It is the amount of space which must be available in the
+ * TCP snd_buf for select to return writable.
+ */
+#ifndef TCP_SNDLOWAT
+#define TCP_SNDLOWAT                    ((TCP_SND_BUF)/2)
+#endif
+
+/**
+ * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
+ */
+#ifndef TCP_LISTEN_BACKLOG
+#define TCP_LISTEN_BACKLOG              0
 #endif
 
-
-/* Maximum number of retransmissions of data segments. */
-
-/* Maximum number of retransmissions of SYN segments. */
+/**
+ * The maximum allowed backlog for TCP listen netconns.
+ * This backlog is used unless another is explicitly specified.
+ * 0xff is the maximum (u8_t).
+ */
+#ifndef TCP_DEFAULT_LISTEN_BACKLOG
+#define TCP_DEFAULT_LISTEN_BACKLOG      0xff
+#endif
 
-/* TCP writable space (bytes). This must be less than or equal
-   to TCP_SND_BUF. It is the amount of space which must be
-   available in the tcp snd_buf for select to return writable */
-#ifndef TCP_SNDLOWAT
-#define TCP_SNDLOWAT                    TCP_SND_BUF/2
+/**
+ * LWIP_TCP_TIMESTAMPS==1: support the TCP timestamp option.
+ */
+#ifndef LWIP_TCP_TIMESTAMPS
+#define LWIP_TCP_TIMESTAMPS             0
 #endif
 
-/* Support loop interface (127.0.0.1) */
-#ifndef LWIP_HAVE_LOOPIF
-#define LWIP_HAVE_LOOPIF                0
+/**
+ * TCP_WND_UPDATE_THRESHOLD: difference in window to trigger an
+ * explicit window update
+ */
+#ifndef TCP_WND_UPDATE_THRESHOLD
+#define TCP_WND_UPDATE_THRESHOLD   (TCP_WND / 4)
 #endif
 
+/**
+ * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1.
+ *     LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
+ *         events (accept, sent, etc) that happen in the system.
+ *     LWIP_CALLBACK_API==1: The PCB callback function is called directly
+ *         for the event.
+ */
 #ifndef LWIP_EVENT_API
 #define LWIP_EVENT_API                  0
 #define LWIP_CALLBACK_API               1
 #else 
 #define LWIP_EVENT_API                  1
 #define LWIP_CALLBACK_API               0
-#endif 
-
-#ifndef LWIP_COMPAT_SOCKETS
-#define LWIP_COMPAT_SOCKETS             1
 #endif
 
 
+/*
+   ----------------------------------
+   ---------- Pbuf options ----------
+   ----------------------------------
+*/
+/**
+ * PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+ * link level header. The default is 14, the standard value for
+ * Ethernet.
+ */
+#ifndef PBUF_LINK_HLEN
+#define PBUF_LINK_HLEN                  14
+#endif
+
+/**
+ * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
+ * designed to accomodate single full size TCP frame in one pbuf, including
+ * TCP_MSS, IP header, and link header.
+ */
+#ifndef PBUF_POOL_BUFSIZE
+#define PBUF_POOL_BUFSIZE               LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN)
+#endif
+
+/*
+   ------------------------------------------------
+   ---------- Network Interfaces options ----------
+   ------------------------------------------------
+*/
+/**
+ * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
+ * field.
+ */
+#ifndef LWIP_NETIF_HOSTNAME
+#define LWIP_NETIF_HOSTNAME             0
+#endif
+
+/**
+ * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
+ */
+#ifndef LWIP_NETIF_API
+#define LWIP_NETIF_API                  0
+#endif
+
+/**
+ * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface
+ * changes its up/down status (i.e., due to DHCP IP acquistion)
+ */
+#ifndef LWIP_NETIF_STATUS_CALLBACK
+#define LWIP_NETIF_STATUS_CALLBACK      0
+#endif
+
+/**
+ * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
+ * whenever the link changes (i.e., link down)
+ */
+#ifndef LWIP_NETIF_LINK_CALLBACK
+#define LWIP_NETIF_LINK_CALLBACK        0
+#endif
+
+/**
+ * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table
+ * indices) in struct netif. TCP and UDP can make use of this to prevent
+ * scanning the ARP table for every sent packet. While this is faster for big
+ * ARP tables or many concurrent connections, it might be counterproductive
+ * if you have a tiny ARP table or if there never are concurrent connections.
+ */
+#ifndef LWIP_NETIF_HWADDRHINT
+#define LWIP_NETIF_HWADDRHINT           0
+#endif
+
+/**
+ * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
+ * address equal to the netif IP address, looping them back up the stack.
+ */
+#ifndef LWIP_NETIF_LOOPBACK
+#define LWIP_NETIF_LOOPBACK             0
+#endif
+
+/**
+ * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback
+ * sending for each netif (0 = disabled)
+ */
+#ifndef LWIP_LOOPBACK_MAX_PBUFS
+#define LWIP_LOOPBACK_MAX_PBUFS         0
+#endif
+
+/**
+ * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in
+ * the system, as netifs must change how they behave depending on this setting
+ * for the LWIP_NETIF_LOOPBACK option to work.
+ * Setting this is needed to avoid reentering non-reentrant functions like
+ * tcp_input().
+ *    LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a
+ *       multithreaded environment like tcpip.c. In this case, netif->input()
+ *       is called directly.
+ *    LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup.
+ *       The packets are put on a list and netif_poll() must be called in
+ *       the main application loop.
+ */
+#ifndef LWIP_NETIF_LOOPBACK_MULTITHREADING
+#define LWIP_NETIF_LOOPBACK_MULTITHREADING    (!NO_SYS)
+#endif
+
+/**
+ * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data
+ * to be sent into one single pbuf. This is for compatibility with DMA-enabled
+ * MACs that do not support scatter-gather.
+ * Beware that this might involve CPU-memcpy before transmitting that would not
+ * be needed without this flag! Use this only if you need to!
+ *
+ * @todo: TCP and IP-frag do not work with this, yet:
+ */
+#ifndef LWIP_NETIF_TX_SINGLE_PBUF
+#define LWIP_NETIF_TX_SINGLE_PBUF             0
+#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
+
+/*
+   ------------------------------------
+   ---------- LOOPIF options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
+ */
+#ifndef LWIP_HAVE_LOOPIF
+#define LWIP_HAVE_LOOPIF                0
+#endif
+
+/*
+   ------------------------------------
+   ---------- SLIPIF options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_HAVE_SLIPIF==1: Support slip interface and slipif.c
+ */
+#ifndef LWIP_HAVE_SLIPIF
+#define LWIP_HAVE_SLIPIF                0
+#endif
+
+/*
+   ------------------------------------
+   ---------- Thread options ----------
+   ------------------------------------
+*/
+/**
+ * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
+ */
+#ifndef TCPIP_THREAD_NAME
+#define TCPIP_THREAD_NAME              "tcpip_thread"
+#endif
+
+/**
+ * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
+ * The stack size value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
+#ifndef TCPIP_THREAD_STACKSIZE
+#define TCPIP_THREAD_STACKSIZE          0
+#endif
+
+/**
+ * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
+ * The priority value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
 #ifndef TCPIP_THREAD_PRIO
 #define TCPIP_THREAD_PRIO               1
 #endif
 
+/**
+ * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
+ * The queue size value itself is platform-dependent, but is passed to
+ * sys_mbox_new() when tcpip_init is called.
+ */
+#ifndef TCPIP_MBOX_SIZE
+#define TCPIP_MBOX_SIZE                 0
+#endif
+
+/**
+ * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread.
+ */
+#ifndef SLIPIF_THREAD_NAME
+#define SLIPIF_THREAD_NAME             "slipif_loop"
+#endif
+
+/**
+ * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread.
+ * The stack size value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
+#ifndef SLIPIF_THREAD_STACKSIZE
+#define SLIPIF_THREAD_STACKSIZE         0
+#endif
+
+/**
+ * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread.
+ * The priority value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
 #ifndef SLIPIF_THREAD_PRIO
 #define SLIPIF_THREAD_PRIO              1
 #endif
 
+/**
+ * PPP_THREAD_NAME: The name assigned to the pppMain thread.
+ */
+#ifndef PPP_THREAD_NAME
+#define PPP_THREAD_NAME                "pppMain"
+#endif
+
+/**
+ * PPP_THREAD_STACKSIZE: The stack size used by the pppMain thread.
+ * The stack size value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
+#ifndef PPP_THREAD_STACKSIZE
+#define PPP_THREAD_STACKSIZE            0
+#endif
+
+/**
+ * PPP_THREAD_PRIO: The priority assigned to the pppMain thread.
+ * The priority value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
 #ifndef PPP_THREAD_PRIO
 #define PPP_THREAD_PRIO                 1
 #endif
 
+/**
+ * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread.
+ */
+#ifndef DEFAULT_THREAD_NAME
+#define DEFAULT_THREAD_NAME            "lwIP"
+#endif
+
+/**
+ * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
+ * The stack size value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
+#ifndef DEFAULT_THREAD_STACKSIZE
+#define DEFAULT_THREAD_STACKSIZE        0
+#endif
+
+/**
+ * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread.
+ * The priority value itself is platform-dependent, but is passed to
+ * sys_thread_new() when the thread is created.
+ */
 #ifndef DEFAULT_THREAD_PRIO
 #define DEFAULT_THREAD_PRIO             1
 #endif
 
+/**
+ * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
+ * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
+ * to sys_mbox_new() when the recvmbox is created.
+ */
+#ifndef DEFAULT_RAW_RECVMBOX_SIZE
+#define DEFAULT_RAW_RECVMBOX_SIZE       0
+#endif
 
-/* ---------- Socket Options ---------- */
-/* Enable SO_REUSEADDR and SO_REUSEPORT options */ 
-#define SO_REUSE 0
-#if SO_REUSE
-/* I removed the lot since this was an ugly hack. It broke the raw-API.
-   It also came with many ugly goto's, Christiaan Simons. */
-#error "SO_REUSE currently unavailable, this was a hack"
-#endif                                                                        
+/**
+ * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
+ * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
+ * to sys_mbox_new() when the recvmbox is created.
+ */
+#ifndef DEFAULT_UDP_RECVMBOX_SIZE
+#define DEFAULT_UDP_RECVMBOX_SIZE       0
+#endif
+
+/**
+ * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
+ * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
+ * to sys_mbox_new() when the recvmbox is created.
+ */
+#ifndef DEFAULT_TCP_RECVMBOX_SIZE
+#define DEFAULT_TCP_RECVMBOX_SIZE       0
+#endif
+
+/**
+ * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
+ * The queue size value itself is platform-dependent, but is passed to
+ * sys_mbox_new() when the acceptmbox is created.
+ */
+#ifndef DEFAULT_ACCEPTMBOX_SIZE
+#define DEFAULT_ACCEPTMBOX_SIZE         0
+#endif
+
+/*
+   ----------------------------------------------
+   ---------- Sequential layer options ----------
+   ----------------------------------------------
+*/
+/**
+ * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!)
+ * Don't use it if you're not an active lwIP project member
+ */
+#ifndef LWIP_TCPIP_CORE_LOCKING
+#define LWIP_TCPIP_CORE_LOCKING         0
+#endif
+
+/**
+ * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
+ */
+#ifndef LWIP_NETCONN
+#define LWIP_NETCONN                    1
+#endif
+
+/*
+   ------------------------------------
+   ---------- Socket options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
+ */
+#ifndef LWIP_SOCKET
+#define LWIP_SOCKET                     1
+#endif
 
+/**
+ * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.
+ * (only used if you use sockets.c)
+ */
+#ifndef LWIP_COMPAT_SOCKETS
+#define LWIP_COMPAT_SOCKETS             1
+#endif
 
-/* ---------- Statistics options ---------- */
+/**
+ * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names.
+ * Disable this option if you use a POSIX operating system that uses the same
+ * names (read, write & close). (only used if you use sockets.c)
+ */
+#ifndef LWIP_POSIX_SOCKETS_IO_NAMES
+#define LWIP_POSIX_SOCKETS_IO_NAMES     1
+#endif
+
+/**
+ * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
+ * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
+ * in seconds. (does not require sockets.c, and will affect tcp.c)
+ */
+#ifndef LWIP_TCP_KEEPALIVE
+#define LWIP_TCP_KEEPALIVE              0
+#endif
+
+/**
+ * LWIP_SO_RCVTIMEO==1: Enable SO_RCVTIMEO processing.
+ */
+#ifndef LWIP_SO_RCVTIMEO
+#define LWIP_SO_RCVTIMEO                0
+#endif
+
+/**
+ * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
+ */
+#ifndef LWIP_SO_RCVBUF
+#define LWIP_SO_RCVBUF                  0
+#endif
+
+/**
+ * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize.
+ */
+#ifndef RECV_BUFSIZE_DEFAULT
+#define RECV_BUFSIZE_DEFAULT            INT_MAX
+#endif
+
+/**
+ * SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!
+ */
+#ifndef SO_REUSE
+#define SO_REUSE                        0
+#endif
+
+/*
+   ----------------------------------------
+   ---------- Statistics options ----------
+   ----------------------------------------
+*/
+/**
+ * LWIP_STATS==1: Enable statistics collection in lwip_stats.
+ */
 #ifndef LWIP_STATS
 #define LWIP_STATS                      1
 #endif
 
 #if LWIP_STATS
 
+/**
+ * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
+ */
 #ifndef LWIP_STATS_DISPLAY
-#define LWIP_STATS_DISPLAY 0
+#define LWIP_STATS_DISPLAY              0
 #endif
 
+/**
+ * LINK_STATS==1: Enable link stats.
+ */
 #ifndef LINK_STATS
-#define LINK_STATS  1
+#define LINK_STATS                      1
+#endif
+
+/**
+ * ETHARP_STATS==1: Enable etharp stats.
+ */
+#ifndef ETHARP_STATS
+#define ETHARP_STATS                    (LWIP_ARP)
 #endif
 
+/**
+ * IP_STATS==1: Enable IP stats.
+ */
 #ifndef IP_STATS
-#define IP_STATS    1
+#define IP_STATS                        1
 #endif
 
+/**
+ * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is
+ * on if using either frag or reass.
+ */
 #ifndef IPFRAG_STATS
-#define IPFRAG_STATS    1
+#define IPFRAG_STATS                    (IP_REASSEMBLY || IP_FRAG)
 #endif
 
+/**
+ * ICMP_STATS==1: Enable ICMP stats.
+ */
 #ifndef ICMP_STATS
-#define ICMP_STATS  1
+#define ICMP_STATS                      1
 #endif
 
-#ifndef UDP_STATS
-#define UDP_STATS   1
+/**
+ * IGMP_STATS==1: Enable IGMP stats.
+ */
+#ifndef IGMP_STATS
+#define IGMP_STATS                      (LWIP_IGMP)
 #endif
 
-#ifndef TCP_STATS
-#define TCP_STATS   1
-#endif
-
-#ifndef MEM_STATS
-#define MEM_STATS   1
+/**
+ * UDP_STATS==1: Enable UDP stats. Default is on if
+ * UDP enabled, otherwise off.
+ */
+#ifndef UDP_STATS
+#define UDP_STATS                       (LWIP_UDP)
 #endif
 
-#ifndef MEMP_STATS
-#define MEMP_STATS  1
+/**
+ * TCP_STATS==1: Enable TCP stats. Default is on if TCP
+ * enabled, otherwise off.
+ */
+#ifndef TCP_STATS
+#define TCP_STATS                       (LWIP_TCP)
 #endif
 
-#ifndef PBUF_STATS
-#define PBUF_STATS  1
+/**
+ * MEM_STATS==1: Enable mem.c stats.
+ */
+#ifndef MEM_STATS
+#define MEM_STATS                       ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
 #endif
 
-#ifndef SYS_STATS
-#define SYS_STATS   1
+/**
+ * MEMP_STATS==1: Enable memp.c pool stats.
+ */
+#ifndef MEMP_STATS
+#define MEMP_STATS                      (MEMP_MEM_MALLOC == 0)
 #endif
 
-#ifndef RAW_STATS
-#define RAW_STATS   0
+/**
+ * SYS_STATS==1: Enable system stats (sem and mbox counts, etc).
+ */
+#ifndef SYS_STATS
+#define SYS_STATS                       (NO_SYS == 0)
 #endif
 
 #else
 
-#define LINK_STATS  0
-#define IP_STATS    0
-#define IPFRAG_STATS    0
-#define ICMP_STATS  0
-#define UDP_STATS   0
-#define TCP_STATS   0
-#define MEM_STATS   0
-#define MEMP_STATS  0
-#define PBUF_STATS  0
-#define SYS_STATS   0
-#define RAW_STATS   0
-#define LWIP_STATS_DISPLAY  0
+#define LINK_STATS                      0
+#define IP_STATS                        0
+#define IPFRAG_STATS                    0
+#define ICMP_STATS                      0
+#define IGMP_STATS                      0
+#define UDP_STATS                       0
+#define TCP_STATS                       0
+#define MEM_STATS                       0
+#define MEMP_STATS                      0
+#define SYS_STATS                       0
+#define LWIP_STATS_DISPLAY              0
 
 #endif /* LWIP_STATS */
 
-/* ---------- PPP options ---------- */
+/*
+   ---------------------------------
+   ---------- PPP options ----------
+   ---------------------------------
+*/
+/**
+ * PPP_SUPPORT==1: Enable PPP.
+ */
+#ifndef PPP_SUPPORT
+#define PPP_SUPPORT                     0
+#endif
 
-#ifndef PPP_SUPPORT
-#define PPP_SUPPORT                     0      /* Set for PPP */
+/**
+ * PPPOE_SUPPORT==1: Enable PPP Over Ethernet
+ */
+#ifndef PPPOE_SUPPORT
+#define PPPOE_SUPPORT                   0
+#endif
+
+/**
+ * PPPOS_SUPPORT==1: Enable PPP Over Serial
+ */
+#ifndef PPPOS_SUPPORT
+#define PPPOS_SUPPORT                   PPP_SUPPORT
 #endif
 
-#if PPP_SUPPORT 
-
-#define NUM_PPP                         1      /* Max PPP sessions. */
+#if PPP_SUPPORT
 
-
-
-#ifndef PAP_SUPPORT
-#define PAP_SUPPORT                     0      /* Set for PAP. */
+/**
+ * NUM_PPP: Max PPP sessions.
+ */
+#ifndef NUM_PPP
+#define NUM_PPP                         1
 #endif
 
+/**
+ * PAP_SUPPORT==1: Support PAP.
+ */
+#ifndef PAP_SUPPORT
+#define PAP_SUPPORT                     0
+#endif
+
+/**
+ * CHAP_SUPPORT==1: Support CHAP.
+ */
 #ifndef CHAP_SUPPORT
-#define CHAP_SUPPORT                    0      /* Set for CHAP. */
+#define CHAP_SUPPORT                    0
+#endif
+
+/**
+ * MSCHAP_SUPPORT==1: Support MSCHAP. CURRENTLY NOT SUPPORTED! DO NOT SET!
+ */
+#ifndef MSCHAP_SUPPORT
+#define MSCHAP_SUPPORT                  0
 #endif
 
-#define MSCHAP_SUPPORT                  0      /* Set for MSCHAP (NOT FUNCTIONAL!) */
-#define CBCP_SUPPORT                    0      /* Set for CBCP (NOT FUNCTIONAL!) */
-#define CCP_SUPPORT                     0      /* Set for CCP (NOT FUNCTIONAL!) */
+/**
+ * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
+ */
+#ifndef CBCP_SUPPORT
+#define CBCP_SUPPORT                    0
+#endif
 
-#ifndef VJ_SUPPORT
-#define VJ_SUPPORT                      0      /* Set for VJ header compression. */
+/**
+ * CCP_SUPPORT==1: Support CCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
+ */
+#ifndef CCP_SUPPORT
+#define CCP_SUPPORT                     0
 #endif
 
-#ifndef MD5_SUPPORT
-#define MD5_SUPPORT                     0      /* Set for MD5 (see also CHAP) */
+/**
+ * VJ_SUPPORT==1: Support VJ header compression.
+ */
+#ifndef VJ_SUPPORT
+#define VJ_SUPPORT                      0
 #endif
 
+/**
+ * MD5_SUPPORT==1: Support MD5 (see also CHAP).
+ */
+#ifndef MD5_SUPPORT
+#define MD5_SUPPORT                     0
+#endif
 
 /*
- * Timeouts.
+ * Timeouts
  */
+#ifndef FSM_DEFTIMEOUT
 #define FSM_DEFTIMEOUT                  6       /* Timeout time in seconds */
+#endif
+
+#ifndef FSM_DEFMAXTERMREQS
 #define FSM_DEFMAXTERMREQS              2       /* Maximum Terminate-Request transmissions */
+#endif
+
+#ifndef FSM_DEFMAXCONFREQS
 #define FSM_DEFMAXCONFREQS              10      /* Maximum Configure-Request transmissions */
-#define FSM_DEFMAXNAKLOOPS              5       /* Maximum number of nak loops */
+#endif
 
+#ifndef FSM_DEFMAXNAKLOOPS
+#define FSM_DEFMAXNAKLOOPS              5       /* Maximum number of nak loops */
+#endif
+
+#ifndef UPAP_DEFTIMEOUT
 #define UPAP_DEFTIMEOUT                 6       /* Timeout (seconds) for retransmitting req */
-#define UPAP_DEFREQTIME                 30      /* Time to wait for auth-req from peer */
+#endif
 
+#ifndef UPAP_DEFREQTIME
+#define UPAP_DEFREQTIME                 30      /* Time to wait for auth-req from peer */
+#endif
+
+#ifndef CHAP_DEFTIMEOUT
 #define CHAP_DEFTIMEOUT                 6       /* Timeout time in seconds */
+#endif
+
+#ifndef CHAP_DEFTRANSMITS
 #define CHAP_DEFTRANSMITS               10      /* max # times to send challenge */
-
+#endif
 
 /* Interval in seconds between keepalive echo requests, 0 to disable. */
-#if 1
+#ifndef LCP_ECHOINTERVAL
 #define LCP_ECHOINTERVAL                0
-#else
-#define LCP_ECHOINTERVAL                10
 #endif
 
 /* Number of unanswered echo requests before failure. */
+#ifndef LCP_MAXECHOFAILS
 #define LCP_MAXECHOFAILS                3
+#endif
 
 /* Max Xmit idle time (in jiffies) before resend flag char. */
+#ifndef PPP_MAXIDLEFLAG
 #define PPP_MAXIDLEFLAG                 100
+#endif
 
 /*
  * Packet sizes
@@ -496,177 +1515,326 @@ a lot of data that needs to be copied, t
  *    of living in lcp.h)
  */
 #define PPP_MTU                         1500     /* Default MTU (size of Info field) */
-#if 0
-#define PPP_MAXMTU  65535 - (PPP_HDRLEN + PPP_FCSLEN)
-#else
+#ifndef PPP_MAXMTU
+/* #define PPP_MAXMTU  65535 - (PPP_HDRLEN + PPP_FCSLEN) */
 #define PPP_MAXMTU                      1500 /* Largest MTU we allow */
 #endif
 #define PPP_MINMTU                      64
 #define PPP_MRU                         1500     /* default MRU = max length of info field */
 #define PPP_MAXMRU                      1500     /* Largest MRU we allow */
+#ifndef PPP_DEFMRU
 #define PPP_DEFMRU                      296             /* Try for this */
+#endif
 #define PPP_MINMRU                      128             /* No MRUs below this */
 
-
+#ifndef MAXNAMELEN
 #define MAXNAMELEN                      256     /* max length of hostname or name for auth */
+#endif
+#ifndef MAXSECRETLEN
 #define MAXSECRETLEN                    256     /* max length of password or secret */
+#endif
 
 #endif /* PPP_SUPPORT */
 
-/* checksum options - set to zero for hardware checksum support */
-
+/*
+   --------------------------------------
+   ---------- Checksum options ----------
+   --------------------------------------
+*/
+/**
+ * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.
+ */
 #ifndef CHECKSUM_GEN_IP
 #define CHECKSUM_GEN_IP                 1
 #endif
  
+/**
+ * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.
+ */
 #ifndef CHECKSUM_GEN_UDP
 #define CHECKSUM_GEN_UDP                1
 #endif
  
+/**
+ * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.
+ */
 #ifndef CHECKSUM_GEN_TCP
 #define CHECKSUM_GEN_TCP                1
 #endif
  
+/**
+ * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.
+ */
 #ifndef CHECKSUM_CHECK_IP
 #define CHECKSUM_CHECK_IP               1
 #endif
  
+/**
+ * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.
+ */
 #ifndef CHECKSUM_CHECK_UDP
 #define CHECKSUM_CHECK_UDP              1
 #endif
 
+/**
+ * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.
+ */
 #ifndef CHECKSUM_CHECK_TCP
 #define CHECKSUM_CHECK_TCP              1
 #endif
 
-/* Debugging options all default to off */
-
-#ifndef DBG_TYPES_ON
-#define DBG_TYPES_ON                    0
+/*
+   ---------------------------------------
+   ---------- Debugging options ----------
+   ---------------------------------------
+*/
+/**
+ * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is
+ * compared against this value. If it is smaller, then debugging
+ * messages are written.
+ */
+#ifndef LWIP_DBG_MIN_LEVEL
+#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_ALL
 #endif
 
-#ifndef ETHARP_DEBUG
-#define ETHARP_DEBUG                    DBG_OFF
-#endif
-
-#ifndef NETIF_DEBUG
-#define NETIF_DEBUG                     DBG_OFF
+/**
+ * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable
+ * debug messages of certain types.
+ */
+#ifndef LWIP_DBG_TYPES_ON
+#define LWIP_DBG_TYPES_ON               LWIP_DBG_ON
 #endif
 
-#ifndef PBUF_DEBUG
-#define PBUF_DEBUG                      DBG_OFF
+/**
+ * ETHARP_DEBUG: Enable debugging in etharp.c.
+ */
+#ifndef ETHARP_DEBUG
+#define ETHARP_DEBUG                    LWIP_DBG_OFF
+#endif
+