This library is deprecated.

Dependents:   HTTPClientStreamingExample HTTPClientExample HTTPServerExample HTTPServerHelloWorld ... more

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Thu Aug 05 15:09:22 2010 +0000
Parent:
4:9cec8b1dcf09
Commit message:

Changed in this revision

LPC1768/EthernetNetIf.ar Show annotated file Show diff for this revision Revisions of this file
LPC1768/api/DNSRequest.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/api/TCPSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/api/UDPSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/core/host.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/core/ipaddr.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/core/net.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/core/netservice.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/eth/EthernetNetIf.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/lwip/LwipNetIf.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/lwip/lwipNetTcpSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/lwip/lwipNetUdpSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/net/host.h Show diff for this revision Revisions of this file
LPC1768/if/net/ipaddr.h Show diff for this revision Revisions of this file
LPC1768/if/net/net.h Show diff for this revision Revisions of this file
LPC1768/if/net/netif.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/net/netservice.h Show diff for this revision Revisions of this file
LPC1768/lwip/arch/cc.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/ipv4/lwip/autoip.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/ipv4/lwip/icmp.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/ipv4/lwip/inet.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/ipv4/lwip/ip.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/ipv4/lwip/ip_addr.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/ipv4/lwip/ip_frag.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/api.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/api_msg.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/def.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/dhcp.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/dns.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/err.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/init.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/mem.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/memp_std.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/netbuf.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/netif.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/opt.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/pbuf.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/snmp_asn1.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/snmp_structs.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/sockets.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/stats.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/sys.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/tcp_impl.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/tcpip.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/timers.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/lwip/udp.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/netif/etharp.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/include/netif/ppp_oe.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/lwipopts.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/lwipopts2.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/lwip/lwipopts_light.h Show diff for this revision Revisions of this file
LPC1768/netCfg.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/EthernetNetIf.ar Show annotated file Show diff for this revision Revisions of this file
LPC2368/api/DNSRequest.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/api/TCPSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/api/UDPSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/core/host.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/core/ipaddr.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/core/net.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/core/netservice.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/dbg/dbg.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/eth/EthernetNetIf.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/lwip/LwipNetIf.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/lwip/lwipNetTcpSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/lwip/lwipNetUdpSocket.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/net/host.h Show diff for this revision Revisions of this file
LPC2368/if/net/ipaddr.h Show diff for this revision Revisions of this file
LPC2368/if/net/net.h Show diff for this revision Revisions of this file
LPC2368/if/net/netif.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/net/netservice.h Show diff for this revision Revisions of this file
LPC2368/lwip/arch/cc.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/ipv4/lwip/autoip.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/ipv4/lwip/icmp.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/ipv4/lwip/inet.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/ipv4/lwip/ip.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/ipv4/lwip/ip_addr.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/ipv4/lwip/ip_frag.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/api.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/api_msg.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/def.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/dhcp.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/dns.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/err.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/init.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/mem.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/memp_std.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/netbuf.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/netif.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/opt.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/pbuf.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/snmp_asn1.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/snmp_structs.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/sockets.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/stats.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/sys.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/tcp_impl.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/tcpip.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/timers.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/lwip/udp.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/netif/etharp.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/include/netif/ppp_oe.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/lwipopts.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/lwipopts2.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/lwip/lwipopts_light.h Show diff for this revision Revisions of this file
LPC2368/netCfg.h Show annotated file Show diff for this revision Revisions of this file
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/EthernetNetIf.ar
Binary file LPC1768/EthernetNetIf.ar has changed
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/api/DNSRequest.h
--- a/LPC1768/api/DNSRequest.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/api/DNSRequest.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,44 +21,83 @@
 THE SOFTWARE.
 */
 
+/** \file
+DNS Request header file
+*/
+
 #ifndef DNSREQUEST_H
 #define DNSREQUEST_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/ipaddr.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetDnsRequest
 
+///DNS Request error codes
 enum DNSRequestErr
 {
   __DNS_MIN = -0xFFFF,
-  DNS_SETUP, //NetDnsRequest not properly configured
-  DNS_IF, //If has problems, does not exist or is not initialized
-  DNS_MEM, //Not enough mem
-  DNS_INUSE, //If/Port is in use
-  DNS_PROCESSING, //Req has not completed
+  DNS_SETUP, ///<DNSRequest not properly configured
+  DNS_IF, ///<Interface has problems, does not exist or is not initialized
+  DNS_MEM, ///<Not enough mem
+  DNS_INUSE, ///<Interface / Port is in use
+  DNS_PROCESSING, ///<Request has not completed
 //...
-  DNS_OK = 0
+  DNS_OK = 0 ///<Success
 };
 
+///DNS Request Result Events
 enum DNSReply
 {
   DNS_PRTCL,
-  DNS_NOTFOUND, //Hostname is unknown
-  DNS_ERROR, //Problem with DNS Service
+  DNS_NOTFOUND, ///Hostname is unknown
+  DNS_ERROR, ///Problem with DNS Service
   //...
   DNS_FOUND,
 };
 
+class NetDnsRequest;
+enum NetDnsReply;
+
+///This is a simple DNS Request class
+/**
+  This class exposes an API to deal with DNS Requests
+*/
 class DNSRequest
 {
 public:
+  ///Creates a new request
   DNSRequest();
+  
+  ///Terminates and closes request
   ~DNSRequest();
   
+  ///Resolves an hostname
+  /**
+  @param hostname : hostname to resolve
+  */
   DNSRequestErr resolve(const char* hostname);
+  
+  ///Resolves an hostname
+  /**
+  @param host : hostname to resolve, the result will be stored in the IpAddr field of this object
+  */
   DNSRequestErr resolve(Host* pHost);
   
+  ///Setups callback
+  /**
+  The callback function will be called on result.
+  @param pMethod : callback function
+  */  
+  void setOnReply( void (*pMethod)(DNSReply) );
+  
   class CDummy;
-  void setOnReply( void (*pMethod)(DNSReply) );
+  ///Setups callback
+  /**
+  The callback function will be called on result.
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnReply( T* pItem, void (T::*pMethod)(DNSReply) )
   {
@@ -66,8 +105,13 @@
     m_pCbMeth = (void (CDummy::*)(DNSReply)) pMethod;
   }
   
+  ///Gets IP address once it has been resolved
+  /**
+  @param pIp : pointer to an IpAddr instance in which to store the resolved IP address
+  */
   DNSRequestErr getResult(IpAddr* pIp);
   
+  ///Closes DNS Request before completion
   DNSRequestErr close();
   
 protected:
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/api/TCPSocket.h
--- a/LPC1768/api/TCPSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/api/TCPSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,64 +21,106 @@
 THE SOFTWARE.
 */
 
+/** \file
+TCP Socket header file
+*/
+
 #ifndef TCPSOCKET_H
 #define TCPSOCKET_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetTcpSocket
 
+///TCP Socket error codes
 enum TCPSocketErr
 {
   __TCPSOCKET_MIN = -0xFFFF,
-  TCPSOCKET_SETUP, //NetTcpSocket not properly configured
-  TCPSOCKET_TIMEOUT,
-  TCPSOCKET_IF, //If has problems, does not exist or is not initialized
-  TCPSOCKET_MEM, //Not enough mem
-  TCPSOCKET_INUSE, //If/Port is in use
-  TCPSOCKET_EMPTY, //Connections queue is empty
-  TCPSOCKET_RST, // Connection was reset by remote host
+  TCPSOCKET_SETUP, ///<TCPSocket not properly configured
+  TCPSOCKET_TIMEOUT, ///<Connection timed out
+  TCPSOCKET_IF, ///<Interface has problems, does not exist or is not initialized
+  TCPSOCKET_MEM, ///<Not enough mem
+  TCPSOCKET_INUSE, ///<Interface / Port is in use
+  TCPSOCKET_EMPTY, ///<Connections queue is empty
+  TCPSOCKET_RST, ///<Connection was reset by remote host
 //...
-  TCPSOCKET_OK = 0
+  TCPSOCKET_OK = 0 ///<Success
 };
 
+///TCP Socket Events
 enum TCPSocketEvent
 {
-  TCPSOCKET_CONNECTED, //Connected to host, must call accept() if we were listening
-  TCPSOCKET_ACCEPT,  //Connected to client
-  TCPSOCKET_READABLE, //Data in buf
-  TCPSOCKET_WRITEABLE, //Can write data to buf
-  TCPSOCKET_CONTIMEOUT,
-  TCPSOCKET_CONRST,
-  TCPSOCKET_CONABRT,
-  TCPSOCKET_ERROR,
-  TCPSOCKET_DISCONNECTED
+  TCPSOCKET_CONNECTED, ///<Connected to host
+  TCPSOCKET_ACCEPT,  ///<Client is connected, must call accept() to get a new Socket
+  TCPSOCKET_READABLE, ///<Data in buf
+  TCPSOCKET_WRITEABLE, ///<Can write data to buf
+  TCPSOCKET_CONTIMEOUT, ///<Connection timed out
+  TCPSOCKET_CONRST, ///<Connection was reset by remote host
+  TCPSOCKET_CONABRT, ///<Connection was aborted
+  TCPSOCKET_ERROR, ///<Unknown error
+  TCPSOCKET_DISCONNECTED ///<Disconnected
 };
 
+class NetTcpSocket;
+enum NetTcpSocketEvent;
 
+///This is a simple TCP Socket class
+/**
+  This class exposes an API to deal with TCP Sockets
+*/
 class TCPSocket
 {
 public:
+  ///Creates a new socket
   TCPSocket();
 protected:
   TCPSocket(NetTcpSocket* pNetTcpSocket);
 public:
+  ///Closes if needed and destroys the socket
   ~TCPSocket(); //close()
   
+  ///Binds the socket to (local) host
   TCPSocketErr bind(const Host& me);
+  
+  ///Starts listening
   TCPSocketErr listen();
+  
+  ///Connects socket to host
   TCPSocketErr connect(const Host& host);
+  
+  ///Accepts connection from client and gets connected socket
   TCPSocketErr accept(Host* pClient, TCPSocket** ppNewTcpSocket);
   
+  ///Sends data
+  /*
+  @return a negative error code or the number of bytes transmitted
+  */
   int /*if < 0 : TCPSocketErr*/ send(const char* buf, int len);
+  
+  ///Receives data
+  /*
+  @return a negative error code or the number of bytes received
+  */
   int /*if < 0 : TCPSocketErr*/ recv(char* buf, int len);
 
   /* TODO NTH : printf / scanf helpers that call send/recv */
 
+  ///Closes socket
   TCPSocketErr close();
 
+  //Callbacks
+  ///Setups callback
+  /**
+  @param pMethod : callback function
+  */
+  void setOnEvent( void (*pMethod)(TCPSocketEvent) );
+  
   class CDummy;
-  //Callbacks
-  void setOnEvent( void (*pMethod)(TCPSocketEvent) );
+  ///Setups callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnEvent( T* pItem, void (T::*pMethod)(TCPSocketEvent) )
   {
@@ -86,7 +128,8 @@
     m_pCbMeth = (void (CDummy::*)(TCPSocketEvent)) pMethod;
   }
   
-  void resetOnEvent(); //Disable callback
+  ///Disables callback
+  void resetOnEvent(); 
   
 protected:
   void onNetTcpSocketEvent(NetTcpSocketEvent e);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/api/UDPSocket.h
--- a/LPC1768/api/UDPSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/api/UDPSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,47 +21,86 @@
 THE SOFTWARE.
 */
 
+/** \file
+UDP Socket header file
+*/
+
 #ifndef UDPSOCKET_H
 #define UDPSOCKET_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetUdpSocket
 
+///UDP Socket error codes
 enum UDPSocketErr
 {
   __UDPSOCKET_MIN = -0xFFFF,
-  UDPSOCKET_SETUP, //NetUdpSocket not properly configured
-  UDPSOCKET_IF, //If has problems, does not exist or is not initialized
-  UDPSOCKET_MEM, //Not enough mem
-  UDPSOCKET_INUSE, //If/Port is in use
+  UDPSOCKET_SETUP, ///<UDPSocket not properly configured
+  UDPSOCKET_IF, ///<Interface has problems, does not exist or is not initialized
+  UDPSOCKET_MEM, ///<Not enough mem
+  UDPSOCKET_INUSE, ///<Interface / Port is in use
 //...
-  UDPSOCKET_OK = 0
+  UDPSOCKET_OK = 0 ///<Success
 };
 
-enum UDPSocketEvent //Only one lonely event here... but who knows, maybe some day there'll be another one!
+///UDP Socket Event(s)
+enum UDPSocketEvent //Only one event here for now, but keeps that model in case we need to implement some others
 {
-  UDPSOCKET_READABLE, //Data in buf
+  UDPSOCKET_READABLE, ///<Data in buf
 };
 
+class NetUdpSocket;
+enum NetUdpSocketEvent;
 
+///This is a simple UDP Socket class
+/**
+  This class exposes an API to deal with UDP Sockets
+*/
 class UDPSocket
 {
 public:
+  ///Creates a new socket
   UDPSocket();
+  
+  ///Closes and destroys socket
   ~UDPSocket(); //close()
   
+  ///Binds the socket to local host or a multicast address
   UDPSocketErr bind(const Host& me);
   
+  ///Sends data
+  /*
+  @param pHost : host to send data to
+  @return a negative error code or the number of bytes transmitted
+  */
   int /*if < 0 : UDPSocketErr*/ sendto(const char* buf, int len, Host* pHost);
+  
+  ///Receives data
+  /*
+  @param pHost : host from which this piece of data comes from
+  @return a negative error code or the number of bytes received
+  */
   int /*if < 0 : UDPSocketErr*/ recvfrom(char* buf, int len, Host* pHost);
 
   /* TODO NTH : printf / scanf helpers that call send/recv */
 
+  ///Closes socket
   UDPSocketErr close();
 
+  //Callbacks
+  ///Setups callback
+  /**
+  @param pMethod : callback function
+  */  
+  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  
   class CDummy;
-  //Callbacks
-  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  ///Setups callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnEvent( T* pItem, void (T::*pMethod)(UDPSocketEvent) )
   {
@@ -69,7 +108,8 @@
     m_pCbMeth = (void (CDummy::*)(UDPSocketEvent)) pMethod;
   }
   
-  void resetOnEvent(); //Disable callback
+  ///Disables callback
+  void resetOnEvent();
 
 protected:
   void onNetUdpSocketEvent(NetUdpSocketEvent e);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/core/host.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/host.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,109 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef HOST_H
+#define HOST_H
+
+#include "ipaddr.h"
+#include <string.h>
+
+///Host information container
+/**
+This class is a container for data relative to a connection:
+- IP Address
+- Port number
+- Host Name
+*/
+class Host 
+{
+public:
+  ///Initiliazes host with null values
+  Host() : m_ip(0,0,0,0), m_port(0), m_name(NULL)
+  {
+    
+  }
+  
+  ///Initializes host
+  Host(const IpAddr& ip, const int& port, const char* name="" ) : m_ip(ip), m_port(port), m_name(NULL)
+  {
+    setName(name); 
+  }
+  
+  ~Host()
+  {
+    if(m_name)
+    {
+      delete[] m_name;
+    }
+  }
+  
+  ///Returns IP address
+  const IpAddr& getIp() const
+  {
+    return m_ip;
+  }
+  
+  ///Returns port number
+  const int& getPort() const
+  {
+    return m_port;
+  }
+  
+  ///Returns host name
+  const char* getName() const
+  {
+    return m_name;
+  }
+  
+  ///Sets IP address
+  void setIp(const IpAddr& ip)
+  {
+    m_ip = ip;
+  }
+  
+  ///Sets port number
+  void setPort(int port)
+  {
+    m_port = port;
+  }
+  
+  ///Sets host name
+  void setName(const char* name)
+  {
+    if(m_name)
+      delete[] m_name;
+    int len = strlen(name);
+    if(len)
+    {
+      m_name = new char[len+1];
+      strcpy(m_name, name);
+    }
+  }
+  
+private:
+  IpAddr m_ip;
+  int m_port;
+  char* m_name;
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/core/ipaddr.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/ipaddr.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,98 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef IPADDR_H
+#define IPADDR_H
+
+#include "netCfg.h"
+#if NET_LWIP_STACK
+typedef struct ip_addr ip_addr_t;
+#endif
+
+#include "stdint.h"
+
+///IP Address container
+/**
+This class is a container for an IPv4 address.
+*/
+class IpAddr //Basically a C++ frontend to ip_addr_t
+{
+public:
+  #if NET_LWIP_STACK
+  IpAddr(ip_addr_t* pIp);
+  #endif
+  
+  ///Initializes IP address with provided values
+  IpAddr(uint8_t ip0, uint8_t ip1, uint8_t ip2, uint8_t ip3);
+  
+  ///Initializes IP address with null values 
+  IpAddr();
+
+  #if NET_LWIP_STACK
+  ip_addr_t getStruct() const;
+  #endif
+  
+  ///Returns IP address byte #
+  uint8_t operator[](unsigned int i) const;
+  
+  ///Compares too addresses
+  /**
+  @return true if the two addresses are equal
+  */
+  bool isEq(const IpAddr& b) const;
+  
+  ///Compares too addresses
+  /**
+  @return true if the two addresses are equal
+  */
+  bool operator==(const IpAddr& b) const;
+ 
+  ///Compares too addresses
+  /**
+  @return true if the two addresses are different
+  */ 
+  bool operator!=(const IpAddr& b) const;
+  
+  ///Checks whether the address is null
+  /**
+  @return true if the address is null
+  */
+  bool isNull() const;
+  
+  ///Checks whether the address is a broadcast address
+  /**
+  @return true if the address is a broadcast address
+  */
+  bool isBroadcast() const;
+
+  ///Checks whether the address is a multicast address
+  /**
+  @return true if the address is a multicast address
+  */
+  bool isMulticast() const;
+  
+private:
+  uint8_t m_ip[4];
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/core/net.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/net.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,101 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef NET_H
+#define NET_H
+
+class NetIf;
+class NetTcpSocket;
+class NetUdpSocket;
+class NetDnsRequest;
+
+#include <list>
+using std::list;
+
+/*
+#include "host.h"
+#include "ipaddr.h"
+#include "netservice.h"
+#include "if/net/netif.h"
+#include "if/net/nettcpsocket.h"
+#include "if/net/netudpsocket.h"
+#include "if/net/netdnsrequest.h"
+*/
+
+class Host;
+class NetIf;
+class NetTcpSocket;
+class NetUdpSocket;
+class NetDnsRequest;
+
+class Net
+{
+private:
+  Net();
+  ~Net();
+public:  
+  static void poll(); //Poll every if & socket
+  
+  static NetTcpSocket* tcpSocket(NetIf& netif);
+  static NetTcpSocket* tcpSocket(); //Socket on default if
+  static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
+  
+  static NetUdpSocket* udpSocket(NetIf& netif);
+  static NetUdpSocket* udpSocket(); //Socket on default if
+  static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
+  
+  static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
+  static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
+
+  static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
+  static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
+  
+  static void setDefaultIf(NetIf& netif); //Deprecated
+  static void setDefaultIf(NetIf* pIf);
+  static NetIf* getDefaultIf();
+  
+protected:
+  friend class NetIf;
+  friend class NetTcpSocket;
+  friend class NetUdpSocket;
+  
+  static void registerIf(NetIf* pIf);
+  static void unregisterIf(NetIf* pIf);
+  
+  static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
+  static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);  
+  
+  static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
+  static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);  
+  
+private:
+  static Net& net(); //Return inst of singleton
+
+  NetIf* m_defaultIf;
+  
+  list<NetIf*> m_lpIf;
+  list<NetTcpSocket*> m_lpNetTcpSocket;
+  list<NetUdpSocket*> m_lpNetUdpSocket;
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/core/netservice.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/netservice.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,67 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/**
+\file Net Service base class header file
+*/
+
+#ifndef NETSERVICE_H
+#define NETSERVICE_H
+
+#include <list>
+using std::list;
+
+///Net Service base class
+/**
+Each connection-oriented object can register as service (by inheriting this class), so that it is polled regularly.
+It notifies the pool when the connection is terminated so that it can be destroyed.
+*/
+class NetService
+{
+public:
+  ///Instantiates a new service
+  /**
+  @param owned If true the object is owned by the pool and will be destroyed on closure.
+  */
+  NetService(bool owned = true); //Is owned by the pool?
+  virtual ~NetService();
+
+  ///This method can be inherited so that it is called on each @a Net::poll() call.
+  virtual void poll();
+ 
+  static void servicesPoll(); //Poll all registered services & destroy closed ones
+
+protected:
+  ///This flags the service as to be destructed if owned by the pool.
+  void close();
+  
+private:
+  bool m_closed;
+  bool m_removed;
+  bool m_owned;
+  
+  static list<NetService*>& lpServices(); //Helper to prevent static initialization fiasco  
+
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/dbg/dbg.h
--- a/LPC1768/dbg/dbg.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/dbg/dbg.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,6 +21,10 @@
 THE SOFTWARE.
 */
 
+/** \file
+Debugging helpers header file
+*/
+
 //#ifdef DBG_H
 //#define DBG_H
 
@@ -28,6 +32,11 @@
 #define __DEBUG
 #endif
 
+/*!
+  \def __DEBUG
+  To define to enable debugging in one file
+*/
+
 #ifdef __DEBUG
 
 #ifndef __DEBUGSTREAM
@@ -47,8 +56,15 @@
 #undef DBG
 #undef DBG_END
 #undef BREAK
+
+///Debug output (if enabled), same syntax as printf, with heading info
 #define DBG(...) do{ DebugStream::debug("[%s:%s@%d] ", __FILE__, __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
+
+///Debug output (if enabled), same syntax as printf, no heading info
+#define DBGL(...) do{ DebugStream::debug(__VA_ARGS__); } while(0);
 #define DBG_END DebugStream::release
+
+///Break point usin serial debug interface (if debug enbaled)
 #define BREAK() DebugStream::breakPoint(__FILE__, __LINE__)
 #endif
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/eth/EthernetNetIf.h
--- a/LPC1768/if/eth/EthernetNetIf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/if/eth/EthernetNetIf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,6 +21,10 @@
 THE SOFTWARE.
 */
 
+/** \file
+Ethernet network interface header file
+*/
+
 #ifndef ETHERNETNETIF_H
 #define ETHERNETNETIF_H
 
@@ -28,23 +32,39 @@
 
 #include "mbed.h"
 
-#include "if/net/net.h"
 #include "if/lwip/LwipNetIf.h"
 
+///Ethernet network interface return codes
 enum EthernetErr
 {
   __ETH_MIN = -0xFFFF,
-  ETH_TIMEOUT, //Timeout during setup
-  ETH_OK = 0
+  ETH_TIMEOUT, ///<Timeout during setup
+  ETH_OK = 0 ///<Success
 };
 
+///Ethernet network interface
+/**
+This class provides Ethernet connectivity to the stack
+*/
 class EthernetNetIf : public LwipNetIf
 {
 public:
+  ///Instantiates the Interface and register it against the stack, DHCP will be used
   EthernetNetIf(); //W/ DHCP
+
+  ///Instantiates the Interface and register it against the stack, DHCP will not be used
+  /**
+  IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address.
+  */
   EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP
   virtual ~EthernetNetIf();
   
+  ///Brings the interface up
+  /**
+  Uses DHCP if necessary
+  @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
+  @return : ETH_OK on success or ETH_TIMEOUT on timeout
+  */
   EthernetErr setup(int timeout_ms = 15000);
 
   virtual void poll();
@@ -53,6 +73,7 @@
   Timer m_ethArpTimer;
   Timer m_dhcpCoarseTimer;
   Timer m_dhcpFineTimer;
+  Timer m_igmpTimer;
     
   bool m_useDhcp;
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/lwip/LwipNetIf.h
--- a/LPC1768/if/lwip/LwipNetIf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/if/lwip/LwipNetIf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -28,10 +28,13 @@
 #include "mbed.h"
 
 #define NET_LWIP_STACK 1
-#include "if/net/net.h"
+#include "core/net.h"
+#include "if/net/netif.h"
+/*
 #include "lwipNetTcpSocket.h"
 #include "lwipNetUdpSocket.h"
 #include "lwipNetDnsRequest.h"
+*/
 
 class LwipNetIf : public NetIf
 {
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/lwip/lwipNetTcpSocket.h
--- a/LPC1768/if/lwip/lwipNetTcpSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/if/lwip/lwipNetTcpSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -25,16 +25,18 @@
 #define LWIPNETTCPSOCKET_H
 
 #define NET_LWIP_STACK 1
-#include "lwip/ip_addr.h"
-#include "if/net/net.h"
+#include "if/net/nettcpsocket.h"
 #include "LwipNetIf.h"
 
+#include "stdint.h"
+
 //Implements NetTcpSockets over lwIP raw API
 
 struct tcp_pcb; //Represents a Tcp Connection, "Protocol Control Block", see rawapi.txt & tcp.h
 struct pbuf; //Lwip Buffer Container
 
 typedef signed char err_t;
+typedef uint16_t u16_t;
 
 class LwipNetTcpSocket: public NetTcpSocket
 {
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/lwip/lwipNetUdpSocket.h
--- a/LPC1768/if/lwip/lwipNetUdpSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/if/lwip/lwipNetUdpSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -25,10 +25,12 @@
 #define LWIPNETUDPSOCKET_H
 
 #define NET_LWIP_STACK 1
-#include "lwip/ip_addr.h"
-#include "if/net/net.h"
+//#include "lwip/ip_addr.h"
+#include "if/net/netudpsocket.h"
 #include "LwipNetIf.h"
 
+#include "stdint.h"
+
 #include <list>
 using std::list;
 
@@ -36,8 +38,10 @@
 
 struct udp_pcb; //Represents a Udp Connection, "Protocol Control Block", see rawapi.txt & udp.h
 struct pbuf; //Lwip Buffer Container
+typedef struct ip_addr ip_addr_t;
 
-typedef signed char err_t;
+//typedef signed char err_t;
+typedef uint16_t u16_t;
 
 class LwipNetUdpSocket: public NetUdpSocket
 {
@@ -70,6 +74,7 @@
   };
   
   list<InPacket> m_lInPkt;
+  IpAddr m_multicastGroup;
   
   //Static callback : Transforms into a C++ callback
   static void sRecvCb(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/net/host.h
--- a/LPC1768/if/net/host.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef HOST_H
-#define HOST_H
-
-class NetDnsRequest;
-
-#include "ipaddr.h"
-#include "netdnsrequest.h"
-#include <string.h>
-
-class Host 
-{
-public:
-  Host() : m_ip(0,0,0,0), m_port(0), m_name(NULL)
-  {
-    
-  }
-  Host(const IpAddr& ip, const int& port, const char* name="" ) : m_ip(ip), m_port(port), m_name(NULL)
-  {
-    setName(name); 
-  }
-  
-  ~Host()
-  {
-    if(m_name)
-    {
-      delete[] m_name;
-    }
-  }
-  
-  const IpAddr& getIp() const
-  {
-    return m_ip;
-  }
-  
-  const int& getPort() const
-  {
-    return m_port;
-  }
-  
-  const char* getName() const
-  {
-    return m_name;
-  }
-  
-  void setIp(const IpAddr& ip)
-  {
-    m_ip = ip;
-  }
-  
-  void setPort(int port)
-  {
-    m_port = port;
-  }
-  
-  void setName(const char* name)
-  {
-    if(m_name)
-      delete[] m_name;
-    int len = strlen(name);
-    if(len)
-    {
-      m_name = new char[len+1];
-      strcpy(m_name, name);
-    }
-  }
-  
-private:
-  friend class NetDnsRequest;
-  IpAddr m_ip;
-  int m_port;
-  char* m_name;
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/net/ipaddr.h
--- a/LPC1768/if/net/ipaddr.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef IPADDR_H
-#define IPADDR_H
-
-#include "mbed.h"
-
-#include "netCfg.h"
-#if NET_LWIP_STACK
-#include "lwip/ip_addr.h"
-#endif
-class IpAddr;
-
-class IpAddr //Basically a C++ frontend to ip_addr_t
-{
-public:
-  #if NET_LWIP_STACK
-  IpAddr(ip_addr_t* pIp)
-  {
-    *((uint32_t*)m_ip) = pIp->addr;
-  }
-  #endif
-  
-  IpAddr(uint8_t ip0, uint8_t ip1, uint8_t ip2, uint8_t ip3)
-  {
-    //We are in LE
-    m_ip[0] = ip0;
-    m_ip[1] = ip1;
-    m_ip[2] = ip2;
-    m_ip[3] = ip3;
-  }
-  
-  IpAddr()
-  {
-    m_ip[0] = 0;
-    m_ip[1] = 0;
-    m_ip[2] = 0;
-    m_ip[3] = 0;
-  }
-  
-  #if NET_LWIP_STACK
-  ip_addr_t getStruct() const
-  {
-    ip_addr_t ip_struct;
-    ip_struct.addr = *((uint32_t*)m_ip);
-    return ip_struct;
-  }
-  #endif
-  
-  uint8_t operator[](unsigned int i) const
-  {
-    uint8_t null = 0;
-    if( i > 3 )
-      return null;
-    return m_ip[i];
-  }
-  
-  bool isEq(const IpAddr& b) const
-  {
-    return (*((uint32_t*)m_ip) == *((uint32_t*)(b.m_ip)));
-  }
-  
-  bool operator==(const IpAddr& b) const
-  {
-    return isEq(b);
-  }
-  
-  bool operator!=(const IpAddr& b) const
-  {
-    return !(operator==(b));
-  }
-  
-  bool isNull() const
-  {
-    return (*((uint32_t*)m_ip) == 0);
-  }
-  
-private:
-  uint8_t m_ip[4];
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/net/net.h
--- a/LPC1768/if/net/net.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef NET_H
-#define NET_H
-
-class NetIf;
-class NetTcpSocket;
-class NetUdpSocket;
-class NetDnsRequest;
-
-#include <list>
-using std::list;
-
-#include "host.h"
-#include "ipaddr.h"
-#include "netif.h"
-#include "nettcpsocket.h"
-#include "netudpsocket.h"
-#include "netservice.h"
-#include "netdnsrequest.h"
-
-class Net
-{
-private:
-  Net();
-  ~Net();
-public:  
-  static void poll(); //Poll every if & socket
-  
-  static NetTcpSocket* tcpSocket(NetIf& netif);
-  static NetTcpSocket* tcpSocket(); //Socket on default if
-  static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
-  
-  static NetUdpSocket* udpSocket(NetIf& netif);
-  static NetUdpSocket* udpSocket(); //Socket on default if
-  static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
-  
-  static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
-  static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
-
-  static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
-  static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
-  
-  static void setDefaultIf(NetIf& netif); //Deprecated
-  static void setDefaultIf(NetIf* pIf);
-  static NetIf* getDefaultIf();
-  
-  //TODO: Factory functions like 'setupEthernet', 'setupPPP', 'setupTelit' ...
-  #if 0
-  enum NetErr //Generic errors
-  {
-    __NET_MIN = -0xFFFF;
-    NET_OPEN, //Could not open if
-    NET_CONNECT, //Could not connect
-    NET_AUTH, //Could not auth
-    NET_HW, //HW problem
-        
-    NET_OK = 0
-  };
-  
-  static NetErr Ethernet();
-  static NetErr PPPoverSerial(int Tx, int Rx, const char* apn, const char* user, const char* password);
-  static NetErr Telit(int pwrSetPin, int pwrMonPin, int Tx, int Rx);
-  #endif
-  
-protected:
-  friend class NetIf;
-  friend class NetTcpSocket;
-  friend class NetUdpSocket;
-  
-  static void registerIf(NetIf* pIf);
-  static void unregisterIf(NetIf* pIf);
-  
-  static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
-  static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);  
-  
-  static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
-  static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);  
-  
-private:
-  static Net& net(); //Return inst of singleton
-
-  NetIf* m_defaultIf;
-  
-  list<NetIf*> m_lpIf;
-  list<NetTcpSocket*> m_lpNetTcpSocket;
-  list<NetUdpSocket*> m_lpNetUdpSocket;
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/net/netif.h
--- a/LPC1768/if/net/netif.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/if/net/netif.h	Thu Aug 05 15:09:22 2010 +0000
@@ -24,10 +24,15 @@
 #ifndef NETIF_H
 #define NETIF_H
 
-#include "ipaddr.h"
+#include "core/ipaddr.h"
+/*
 #include "nettcpsocket.h"
 #include "netudpsocket.h"
 #include "netdnsrequest.h"
+*/
+class NetTcpSocket;
+class NetUdpSocket;
+class NetDnsRequest;
 
 #if 0
 enum NetifEvent
@@ -48,6 +53,8 @@
   virtual void poll() = 0;
   virtual NetDnsRequest* dnsRequest(const char* hostname) = 0; //Create a new NetDnsRequest object
   virtual NetDnsRequest* dnsRequest(Host* pHost) = 0; //Create a new NetDnsRequest object
+  
+  //!Returns the IP of the interface once it's connected
   IpAddr getIp() const;
   
 protected:
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/if/net/netservice.h
--- a/LPC1768/if/net/netservice.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef NETSERVICE_H
-#define NETSERVICE_H
-
-//class NetDnsRequest;
-//#include "net.h"
-
-//Each connection-oriented object can register as service (by inheriting this class), so that it is polled regularly
-//It notifies the pool when the connection is terminated so that it can be destroyed
-
-#include <list>
-using std::list;
-
-class NetService
-{
-public:
-  NetService(bool owned = true); //Is owned by the pool?
-  virtual ~NetService();
-
-  virtual void poll();
- 
-  static void servicesPoll(); //Poll all registered services & destroy closed ones
-
-protected:
-  void close();
-  
-private:
-  bool m_closed;
-  bool m_removed;
-  bool m_owned;
-  
-  static list<NetService*>& lpServices(); //Helper to prevent static initialization fiasco  
-
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/arch/cc.h
--- a/LPC1768/lwip/arch/cc.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/arch/cc.h	Thu Aug 05 15:09:22 2010 +0000
@@ -29,9 +29,8 @@
 #define FALSE 0
 #endif
 
-#ifndef DBG
-//#error
-#endif
+#include <stdlib.h>
+#define LWIP_RAND rand
 
 #define LWIP_PLATFORM_DIAG(x) DBG x
 #define LWIP_PLATFORM_ASSERT(x) DBG(x)
@@ -57,5 +56,7 @@
 #define PACK_STRUCT_BEGIN __packed
 #define PACK_STRUCT_END
 
+#define LWIP_CHKSUM_ALGORITHM 3
+
 
 #endif /* __LWIP_ARCH_CC_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/ipv4/lwip/autoip.h
--- a/LPC1768/lwip/include/ipv4/lwip/autoip.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/autoip.h	Thu Aug 05 15:09:22 2010 +0000
@@ -80,7 +80,7 @@
 
 struct autoip
 {
-  ip_addr_t llipaddr;  /* the currently selected, probed, announced or used LL IP-Address */
+  ip_addr_t 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 */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/ipv4/lwip/icmp.h
--- a/LPC1768/lwip/include/ipv4/lwip/icmp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/icmp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -70,7 +70,7 @@
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
 #endif
-/** This is the standard ICMP header only that the u32_t data
+/*  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.
@@ -91,7 +91,7 @@
 #define ICMPH_TYPE(hdr) ((hdr)->type)
 #define ICMPH_CODE(hdr) ((hdr)->code)
 
-/** Combines type and code to an u16_t */
+/*  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))
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/ipv4/lwip/inet.h
--- a/LPC1768/lwip/include/ipv4/lwip/inet.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/inet.h	Thu Aug 05 15:09:22 2010 +0000
@@ -40,7 +40,7 @@
 extern "C" {
 #endif
 
-/** For compatibility with BSD code */
+/*  For compatibility with BSD code */
 struct in_addr {
   u32_t s_addr;
 };
@@ -91,6 +91,8 @@
 
 #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
 #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr)   (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
+/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */
+#define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr)   ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr))
 
 /* directly map this to the lwip internal functions */
 #define inet_addr(cp)         ipaddr_addr(cp)
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/ipv4/lwip/ip.h
--- a/LPC1768/lwip/include/ipv4/lwip/ip.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/ip.h	Thu Aug 05 15:09:22 2010 +0000
@@ -78,7 +78,7 @@
   ip_addr_t local_ip; \
   ip_addr_t remote_ip; \
    /* Socket options */  \
-  u16_t so_options;      \
+  u8_t so_options;      \
    /* Type Of Service */ \
   u8_t tos;              \
   /* Time To Live */     \
@@ -94,16 +94,19 @@
 /*
  * 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 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 */
+/*#define SOF_DEBUG       (u8_t)0x01U     Unimplemented: turn on debugging info recording */
+#define SOF_ACCEPTCONN    (u8_t)0x02U  /* socket has had listen() */
+#define SOF_REUSEADDR     (u8_t)0x04U  /* allow local address reuse */
+#define SOF_KEEPALIVE     (u8_t)0x08U  /* keep connections alive */
+/*#define SOF_DONTROUTE   (u8_t)0x10U     Unimplemented: just use interface addresses */
+#define SOF_BROADCAST     (u8_t)0x20U  /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
+/*#define SOF_USELOOPBACK (u8_t)0x40U     Unimplemented: bypass hardware when possible */
+#define SOF_LINGER        (u8_t)0x80U  /* linger on close if data present */
+/*#define SOF_OOBINLINE   (u16_t)0x0100U     Unimplemented: leave received OOB data in line */
+/*#define SOF_REUSEPORT   (u16_t)0x0200U     Unimplemented: allow local address & port reuse */
+
+/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */
+#define SOF_INHERITED   (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/)
 
 
 #ifdef PACK_STRUCT_USE_INCLUDES
@@ -130,8 +133,8 @@
   /* checksum */
   PACK_STRUCT_FIELD(u16_t _chksum);
   /* source and destination IP addresses */
-  PACK_STRUCT_FIELD(ip_addr_t src);
-  PACK_STRUCT_FIELD(ip_addr_t dest); 
+  PACK_STRUCT_FIELD(ip_addr_p_t src);
+  PACK_STRUCT_FIELD(ip_addr_p_t dest); 
 } PACK_STRUCT_STRUCT;
 PACK_STRUCT_END
 #ifdef PACK_STRUCT_USE_INCLUDES
@@ -160,6 +163,10 @@
 extern struct netif *current_netif;
 /** Header of the input packet currently being processed. */
 extern const struct ip_hdr *current_header;
+/** Source IP address of current_header */
+extern ip_addr_t current_iphdr_src;
+/** Destination IP address of current_header */
+extern ip_addr_t current_iphdr_dest;
 
 #define ip_init() /* Compatibility define, not init needed. */
 struct netif *ip_route(ip_addr_t *dest);
@@ -186,6 +193,11 @@
  * 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)
+/** Source IP address of current_header */
+#define ip_current_src_addr()  (&current_iphdr_src)
+/** Destination IP address of current_header */
+#define ip_current_dest_addr() (&current_iphdr_dest)
+
 #if IP_DEBUG
 void ip_debug_print(struct pbuf *p);
 #else
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/ipv4/lwip/ip_addr.h
--- a/LPC1768/lwip/include/ipv4/lwip/ip_addr.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/ip_addr.h	Thu Aug 05 15:09:22 2010 +0000
@@ -39,11 +39,19 @@
 extern "C" {
 #endif
 
+/* This is the aligned version of ip_addr_t,
+   used as local variable, on the stack, etc. */
+struct ip_addr {
+  u32_t addr;
+};
+
+/* This is the packed version of ip_addr_t,
+   used in network headers that are itself packed */
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-struct _ip_addr {
+struct ip_addr_packed {
   PACK_STRUCT_FIELD(u32_t addr);
 } PACK_STRUCT_STRUCT;
 PACK_STRUCT_END
@@ -51,7 +59,10 @@
 #  include "arch/epstruct.h"
 #endif
 
-typedef struct _ip_addr ip_addr_t;
+/** ip_addr_t uses a struct for convenience only, so that the same defines can
+ * operate both on ip_addr_t as well as on ip_addr_p_t. */
+typedef struct ip_addr ip_addr_t;
+typedef struct ip_addr_packed ip_addr_p_t;
 
 /*
  * struct ipaddr2 is used in the definition of the ARP packet format in
@@ -140,6 +151,13 @@
                           (u32_t)((a) & 0xff)
 #endif
 
+/** MEMCPY-like copying of IP addresses where addresses are known to be
+ * 16-bit-aligned if the port is correctly configured (so a port could define
+ * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */
+#ifndef IPADDR2_COPY
+#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t))
+#endif
+
 /** Copy IP address - faster than ip_addr_set: no NULL check */
 #define ip_addr_copy(dest, src) ((dest).addr = (src).addr)
 /** Safely copy one IP address to another (src may be NULL) */
@@ -151,7 +169,7 @@
 /** Set address to IPADDR_ANY (no need for htonl()) */
 #define ip_addr_set_any(ipaddr)       ((ipaddr)->addr = IPADDR_ANY)
 /** Set address to loopback address */
-#define ip_addr_set_loopback(ipaddr)  ((ipaddr)->addr = htonl(IPADDR_LOOPBACK))
+#define ip_addr_set_loopback(ipaddr)  ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK))
 /** Safely copy one IP address to another and change byte order
  * from host- to network-order. */
 #define ip_addr_set_hton(dest, src) ((dest)->addr = \
@@ -181,11 +199,15 @@
 
 #define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY)
 
-u8_t ip_addr_isbroadcast(ip_addr_t *, struct netif *);
+#define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif))
+u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif);
 
-#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL))
+#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr)
+u8_t ip4_addr_netmask_valid(u32_t netmask);
 
-#define ip_addr_islinklocal(addr1) (((addr1)->addr & ntohl(0xffff0000UL)) == ntohl(0xa9fe0000UL))
+#define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL))
+
+#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
 
 #define ip_addr_debug_print(debug, ipaddr) \
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \
@@ -212,8 +234,8 @@
 u32_t ipaddr_addr(const char *cp);
 int ipaddr_aton(const char *cp, ip_addr_t *addr);
 /** returns ptr to static buffer; not reentrant! */
-char *ipaddr_ntoa(ip_addr_t *addr);
-char *ipaddr_ntoa_r(ip_addr_t *addr, char *buf, int buflen);
+char *ipaddr_ntoa(const ip_addr_t *addr);
+char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen);
 
 #ifdef __cplusplus
 }
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/ipv4/lwip/ip_frag.h
--- a/LPC1768/lwip/include/ipv4/lwip/ip_frag.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/ip_frag.h	Thu Aug 05 15:09:22 2010 +0000
@@ -66,6 +66,18 @@
 #endif /* IP_REASSEMBLY */
 
 #if IP_FRAG
+#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
+/** A custom pbuf that holds a reference to another pbuf, which is freed
+ * when this custom pbuf is freed. This is used to create a custom PBUF_REF
+ * that points into the original pbuf. */
+struct pbuf_custom_ref {
+  /** 'base class' */
+  struct pbuf_custom pc;
+  /** pointer to the original pbuf that is referenced */
+  struct pbuf *original;
+};
+#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
+
 err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest);
 #endif /* IP_FRAG */
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/api.h
--- a/LPC1768/lwip/include/lwip/api.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/api.h	Thu Aug 05 15:09:22 2010 +0000
@@ -150,9 +150,11 @@
   /** mbox where received packets are stored until they are fetched
       by the netconn application thread (can grow quite big) */
   sys_mbox_t recvmbox;
+#if LWIP_TCP
   /** mbox where new connections are stored until processed
       by the application thread */
   sys_mbox_t acceptmbox;
+#endif /* LWIP_TCP */
   /** only used for socket layer */
 #if LWIP_SOCKET
   int socket;
@@ -232,6 +234,7 @@
 err_t   netconn_write(struct netconn *conn, const void *dataptr, size_t size,
                       u8_t apiflags);
 err_t   netconn_close(struct netconn *conn);
+err_t   netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
 
 #if LWIP_IGMP
 err_t   netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr,
@@ -261,9 +264,9 @@
 #define netconn_get_noautorecved(conn)        (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)
 
 #if LWIP_SO_RCVTIMEO
-/** Set the receive timeout in miliseconds */
+/** Set the receive timeout in milliseconds */
 #define netconn_set_recvtimeout(conn, timeout)      ((conn)->recv_timeout = (timeout))
-/** Get the receive timeout in miliseconds */
+/** Get the receive timeout in milliseconds */
 #define netconn_get_recvtimeout(conn)               ((conn)->recv_timeout)
 #endif /* LWIP_SO_RCVTIMEO */
 #if LWIP_SO_RCVBUF
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/api_msg.h
--- a/LPC1768/lwip/include/lwip/api_msg.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/api_msg.h	Thu Aug 05 15:09:22 2010 +0000
@@ -48,6 +48,10 @@
 extern "C" {
 #endif
 
+#define NETCONN_SHUT_RD   1
+#define NETCONN_SHUT_WR   2
+#define NETCONN_SHUT_RDWR 3
+
 /* IP addresses and port numbers are expected to be in
  * the same byte order as in the corresponding pcb.
  */
@@ -89,6 +93,10 @@
     struct {
       u32_t len;
     } r;
+    /** used for do_close (/shutdown) */
+    struct {
+      u8_t shut;
+    } sd;
 #if LWIP_IGMP
     /** used for do_join_leave_group */
     struct {
@@ -144,6 +152,7 @@
 void do_write           ( struct api_msg_msg *msg);
 void do_getaddr         ( struct api_msg_msg *msg);
 void do_close           ( struct api_msg_msg *msg);
+void do_shutdown        ( struct api_msg_msg *msg);
 #if LWIP_IGMP
 void do_join_leave_group( struct api_msg_msg *msg);
 #endif /* LWIP_IGMP */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/def.h
--- a/LPC1768/lwip/include/lwip/def.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/def.h	Thu Aug 05 15:09:22 2010 +0000
@@ -39,6 +39,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 #define LWIP_MAX(x , y)  (((x) > (y)) ? (x) : (y))
 #define LWIP_MIN(x , y)  (((x) < (y)) ? (x) : (y))
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/dhcp.h
--- a/LPC1768/lwip/include/lwip/dhcp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/dhcp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -80,10 +80,10 @@
   PACK_STRUCT_FIELD(u32_t xid);
   PACK_STRUCT_FIELD(u16_t secs);
   PACK_STRUCT_FIELD(u16_t flags);
-  PACK_STRUCT_FIELD(ip_addr_t ciaddr);
-  PACK_STRUCT_FIELD(ip_addr_t yiaddr);
-  PACK_STRUCT_FIELD(ip_addr_t siaddr);
-  PACK_STRUCT_FIELD(ip_addr_t giaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t ciaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t yiaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t siaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t giaddr);
   PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
   PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
   PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/dns.h
--- a/LPC1768/lwip/include/lwip/dns.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/dns.h	Thu Aug 05 15:09:22 2010 +0000
@@ -1,116 +1,116 @@
-/**
- * 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 */
-
-/* The size used for the next line is rather a hack, but it prevents including socket.h in all files
-   that include memp.h, and that would possibly break portability (since socket.h defines some types
-   and constants possibly already define by the OS).
-   Calculation rule:
-   sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
-#define NETDB_ELEM_SIZE           (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
-
-#if DNS_LOCAL_HOSTLIST
-/** struct used for local host-list */
-struct local_hostlist_entry {
-  /** static hostname */
-  const char *name;
-  /** static host address in network byteorder */
-  ip_addr_t addr;
-  struct local_hostlist_entry *next;
-};
-#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
-#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
-#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN  DNS_MAX_NAME_LENGTH
-#endif
-#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
-#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
-#endif /* DNS_LOCAL_HOSTLIST */
-
-/** 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 an ip_addr_t 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, ip_addr_t *ipaddr, void *callback_arg);
-
-void           dns_init(void);
-void           dns_tmr(void);
-void           dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
-ip_addr_t      dns_getserver(u8_t numdns);
-err_t          dns_gethostbyname(const char *hostname, ip_addr_t *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 ip_addr_t *addr);
-err_t          dns_local_addhost(const char *hostname, const ip_addr_t *addr);
-#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
-
-#endif /* LWIP_DNS */
-
-#endif /* __LWIP_DNS_H__ */
+/**
+ * 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 */
+
+/* The size used for the next line is rather a hack, but it prevents including socket.h in all files
+   that include memp.h, and that would possibly break portability (since socket.h defines some types
+   and constants possibly already define by the OS).
+   Calculation rule:
+   sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
+#define NETDB_ELEM_SIZE           (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
+
+#if DNS_LOCAL_HOSTLIST
+/** struct used for local host-list */
+struct local_hostlist_entry {
+  /** static hostname */
+  const char *name;
+  /** static host address in network byteorder */
+  ip_addr_t addr;
+  struct local_hostlist_entry *next;
+};
+#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
+#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
+#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN  DNS_MAX_NAME_LENGTH
+#endif
+#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
+#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+#endif /* DNS_LOCAL_HOSTLIST */
+
+/** 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 an ip_addr_t 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, ip_addr_t *ipaddr, void *callback_arg);
+
+void           dns_init(void);
+void           dns_tmr(void);
+void           dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
+ip_addr_t      dns_getserver(u8_t numdns);
+err_t          dns_gethostbyname(const char *hostname, ip_addr_t *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 ip_addr_t *addr);
+err_t          dns_local_addhost(const char *hostname, const ip_addr_t *addr);
+#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+
+#endif /* LWIP_DNS */
+
+#endif /* __LWIP_DNS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/err.h
--- a/LPC1768/lwip/include/lwip/err.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/err.h	Thu Aug 05 15:09:22 2010 +0000
@@ -56,7 +56,7 @@
 #define ERR_RTE        -4    /* Routing problem.         */
 #define ERR_INPROGRESS -5    /* Operation in progress    */
 #define ERR_VAL        -6    /* Illegal value.           */
-#define ERR_WOULBLOCK  -7    /* Operation would block.   */
+#define ERR_WOULDBLOCK -7    /* Operation would block.   */
 
 #define ERR_IS_FATAL(e) ((e) < ERR_VAL)
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/init.h
--- a/LPC1768/lwip/include/lwip/init.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/init.h	Thu Aug 05 15:09:22 2010 +0000
@@ -47,7 +47,7 @@
 /** 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         0U
+#define LWIP_VERSION_RC         1U
 
 /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
 #define LWIP_RC_RELEASE         255U
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/mem.h
--- a/LPC1768/lwip/include/lwip/mem.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/mem.h	Thu Aug 05 15:09:22 2010 +0000
@@ -70,8 +70,10 @@
  */
 #if MEM_SIZE > 64000l
 typedef u32_t mem_size_t;
+#define MEM_SIZE_F U32_F
 #else
 typedef u16_t mem_size_t;
+#define MEM_SIZE_F U16_F
 #endif /* MEM_SIZE > 64000 */
 
 #if MEM_USE_POOLS
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/memp_std.h
--- a/LPC1768/lwip/include/lwip/memp_std.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/memp_std.h	Thu Aug 05 15:09:22 2010 +0000
@@ -47,6 +47,9 @@
 #if IP_REASSEMBLY
 LWIP_MEMPOOL(REASSDATA,      MEMP_NUM_REASSDATA,       sizeof(struct ip_reassdata),   "REASSDATA")
 #endif /* IP_REASSEMBLY */
+#if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
+LWIP_MEMPOOL(FRAG_PBUF,      MEMP_NUM_FRAG_PBUF,       sizeof(struct pbuf_custom_ref),"FRAG_PBUF")
+#endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
 
 #if LWIP_NETCONN
 LWIP_MEMPOOL(NETBUF,         MEMP_NUM_NETBUF,          sizeof(struct netbuf),         "NETBUF")
@@ -55,7 +58,9 @@
 
 #if NO_SYS==0
 LWIP_MEMPOOL(TCPIP_MSG_API,  MEMP_NUM_TCPIP_MSG_API,   sizeof(struct tcpip_msg),      "TCPIP_MSG_API")
+#if !LWIP_TCPIP_CORE_LOCKING_INPUT
 LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg),      "TCPIP_MSG_INPKT")
+#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
 #endif /* NO_SYS==0 */
 
 #if ARP_QUEUEING
@@ -66,7 +71,9 @@
 LWIP_MEMPOOL(IGMP_GROUP,     MEMP_NUM_IGMP_GROUP,      sizeof(struct igmp_group),     "IGMP_GROUP")
 #endif /* LWIP_IGMP */
 
+#if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */
 LWIP_MEMPOOL(SYS_TIMEOUT,    MEMP_NUM_SYS_TIMEOUT,     sizeof(struct sys_timeo),      "SYS_TIMEOUT")
+#endif /* LWIP_TIMERS */
 
 #if LWIP_SNMP
 LWIP_MEMPOOL(SNMP_ROOTNODE,  MEMP_NUM_SNMP_ROOTNODE,   sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE")
@@ -77,6 +84,12 @@
 #if LWIP_DNS && LWIP_SOCKET
 LWIP_MEMPOOL(NETDB,          MEMP_NUM_NETDB,           NETDB_ELEM_SIZE,               "NETDB")
 #endif /* LWIP_DNS && LWIP_SOCKET */
+#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
+LWIP_MEMPOOL(LOCALHOSTLIST,  MEMP_NUM_LOCALHOSTLIST,   LOCALHOSTLIST_ELEM_SIZE,       "LOCALHOSTLIST")
+#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+#if PPP_SUPPORT && PPPOE_SUPPORT
+LWIP_MEMPOOL(PPPOE_IF,      MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc),    "PPPOE_IF")
+#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
 
 /*
  * A list of pools of pbuf's used by LWIP.
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/netbuf.h
--- a/LPC1768/lwip/include/lwip/netbuf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/netbuf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -40,14 +40,24 @@
 extern "C" {
 #endif
 
+/** This netbuf has dest-addr/port set */
+#define NETBUF_FLAG_DESTADDR    0x01
+/** This netbuf includes a checksum */
+#define NETBUF_FLAG_CHKSUM      0x02
+
 struct netbuf {
   struct pbuf *p, *ptr;
-  ip_addr_t *addr;
+  ip_addr_t addr;
   u16_t port;
+#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
+#if LWIP_CHECKSUM_ON_COPY
+  u8_t flags;
+#endif /* LWIP_CHECKSUM_ON_COPY */
+  u16_t toport_chksum;
 #if LWIP_NETBUF_RECVINFO
-  ip_addr_t *toaddr;
-  u16_t toport;
+  ip_addr_t toaddr;
 #endif /* LWIP_NETBUF_RECVINFO */
+#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
 };
 
 /* Network buffer functions: */
@@ -56,12 +66,12 @@
 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);
+                                   const void *dataptr, u16_t size);
 void              netbuf_chain    (struct netbuf *head,
            struct netbuf *tail);
 
 err_t             netbuf_data     (struct netbuf *buf,
-           void **dataptr, u16_t *len);
+                                   void **dataptr, u16_t *len);
 s8_t              netbuf_next     (struct netbuf *buf);
 void              netbuf_first    (struct netbuf *buf);
 
@@ -71,12 +81,18 @@
 #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_fromaddr(buf)         (&((buf)->addr))
+#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr)
 #define netbuf_fromport(buf)         ((buf)->port)
 #if LWIP_NETBUF_RECVINFO
-#define netbuf_destaddr(buf)         ((buf)->toaddr)
-#define netbuf_destport(buf)         ((buf)->toport)
+#define netbuf_destaddr(buf)         (&((buf)->toaddr))
+#define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr)
+#define netbuf_destport(buf)         (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
 #endif /* LWIP_NETBUF_RECVINFO */
+#if LWIP_CHECKSUM_ON_COPY
+#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
+                                            (buf)->toport_chksum = chksum; } while(0)
+#endif /* LWIP_CHECKSUM_ON_COPY */
 
 #ifdef __cplusplus
 }
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/netif.h
--- a/LPC1768/lwip/include/lwip/netif.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/netif.h	Thu Aug 05 15:09:22 2010 +0000
@@ -56,58 +56,58 @@
 /* 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
+/*  must be the maximum of all used hardware address lengths
     across all types of interfaces in use */
 #define NETIF_MAX_HWADDR_LEN 6U
 
-/** Whether the network interface is 'up'. This is
+/*  Whether the network interface is 'up'. This is
  * a software flag used to control whether this network
  * interface is enabled and processes traffic.
  * It is set by the startup code (for static IP configuration) or
  * by dhcp/autoip when an address has been assigned.
  */
 #define NETIF_FLAG_UP           0x01U
-/** If set, the netif has broadcast capability.
+/*  If set, the netif has broadcast capability.
  * Set by the netif driver in its init function. */
 #define NETIF_FLAG_BROADCAST    0x02U
-/** If set, the netif is one end of a point-to-point connection.
+/*  If set, the netif is one end of a point-to-point connection.
  * Set by the netif driver in its init function. */
 #define NETIF_FLAG_POINTTOPOINT 0x04U
-/** If set, the interface is configured using DHCP.
+/*  If set, the interface is configured using DHCP.
  * Set by the DHCP code when starting or stopping DHCP. */
 #define NETIF_FLAG_DHCP         0x08U
-/** If set, the interface has an active link
+/*  If set, the interface has an active link
  *  (set by the network interface driver).
  * Either set by the netif driver in its init function (if the link
  * is up at that time) or at a later point once the link comes up
  * (if link detection is supported by the hardware). */
 #define NETIF_FLAG_LINK_UP      0x10U
-/** If set, the netif is an ethernet device using ARP.
+/*  If set, the netif is an ethernet device using ARP.
  * Set by the netif driver in its init function.
  * Used to check input packet types and use of DHCP. */
 #define NETIF_FLAG_ETHARP       0x20U
-/** If set, the netif is an ethernet device. It might not use
+/*  If set, the netif is an ethernet device. It might not use
  * ARP or TCP/IP if it is used for PPPoE only.
  */
 #define NETIF_FLAG_ETHERNET     0x40U
-/** If set, the netif has IGMP capability.
+/*  If set, the netif has IGMP capability.
  * Set by the netif driver in its init function. */
 #define NETIF_FLAG_IGMP         0x80U
 
-/** Function prototype for netif init functions. Set up flags and output/linkoutput
+/*  Function prototype for netif init functions. Set up flags and output/linkoutput
  * callback functions in this function.
  *
  * @param netif The netif to initialize
  */
 typedef err_t (*netif_init_fn)(struct netif *netif);
-/** Function prototype for netif->input functions. This function is saved as 'input'
+/*  Function prototype for netif->input functions. This function is saved as 'input'
  * callback function in the netif struct. Call it when a packet has been received.
  *
  * @param p The received packet, copied into a pbuf
  * @param inp The netif which received the packet
  */
 typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp);
-/** Function prototype for netif->output functions. Called by lwIP when a packet
+/*  Function prototype for netif->output functions. Called by lwIP when a packet
  * shall be sent. For ethernet netif, set this to 'etharp_output' and set
  * 'linkoutput'.
  *
@@ -117,87 +117,87 @@
  */
 typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p,
        ip_addr_t *ipaddr);
-/** Function prototype for netif->linkoutput functions. Only used for ethernet
+/*  Function prototype for netif->linkoutput functions. Only used for ethernet
  * netifs. This function is called by ARP when a packet shall be sent.
  *
  * @param netif The netif which shall send a packet
  * @param p The packet to send (raw ethernet packet)
  */
 typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p);
-/** Function prototype for netif status- or link-callback functions. */
+/*  Function prototype for netif status- or link-callback functions. */
 typedef void (*netif_status_callback_fn)(struct netif *netif);
-/** Function prototype for netif igmp_mac_filter functions */
+/*  Function prototype for netif igmp_mac_filter functions */
 typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
        ip_addr_t *group, u8_t action);
 
-/** Generic data structure used for all lwIP network interfaces.
+/*  Generic data structure used for all lwIP network interfaces.
  *  The following fields should be filled in by the initialization
  *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
 struct netif {
-  /** pointer to next in linked list */
+  /*  pointer to next in linked list */
   struct netif *next;
 
-  /** IP address configuration in network byte order */
+  /*  IP address configuration in network byte order */
   ip_addr_t ip_addr;
   ip_addr_t netmask;
   ip_addr_t gw;
 
-  /** This function is called by the network device driver
+  /*  This function is called by the network device driver
    *  to pass a packet up the TCP/IP stack. */
   netif_input_fn input;
-  /** This function is called by the IP module when it wants
+  /*  This function is called by the IP module when it wants
    *  to send a packet on the interface. This function typically
    *  first resolves the hardware address, then sends the packet. */
   netif_output_fn output;
-  /** This function is called by the ARP module when it wants
+  /*  This function is called by the ARP module when it wants
    *  to send a packet on the interface. This function outputs
    *  the pbuf as-is on the link medium. */
   netif_linkoutput_fn linkoutput;
 #if LWIP_NETIF_STATUS_CALLBACK
-  /** This function is called when the netif state is set to up or down
+  /*  This function is called when the netif state is set to up or down
    */
   netif_status_callback_fn status_callback;
 #endif /* LWIP_NETIF_STATUS_CALLBACK */
 #if LWIP_NETIF_LINK_CALLBACK
-  /** This function is called when the netif link is set to up or down
+  /*  This function is called when the netif link is set to up or down
    */
   netif_status_callback_fn link_callback;
 #endif /* LWIP_NETIF_LINK_CALLBACK */
-  /** This field can be set by the device driver and could point
+  /*  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 */
+  /*  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 */
+  /*  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) */
+  /*  maximum transfer unit (in bytes) */
   u16_t mtu;
-  /** number of bytes used in hwaddr */
+  /*  number of bytes used in hwaddr */
   u8_t hwaddr_len;
-  /** link level hardware address of this interface */
+  /*  link level hardware address of this interface */
   u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
-  /** flags (see NETIF_FLAG_ above) */
+  /*  flags (see NETIF_FLAG_ above) */
   u8_t flags;
-  /** descriptive abbreviation */
+  /*  descriptive abbreviation */
   char name[2];
-  /** number of this interface */
+  /*  number of this interface */
   u8_t num;
 #if LWIP_SNMP
-  /** link type (from "snmp_ifType" enum from snmp.h) */
+  /*  link type (from "snmp_ifType" enum from snmp.h) */
   u8_t link_type;
-  /** (estimate) link speed */
+  /*  (estimate) link speed */
   u32_t link_speed;
-  /** timestamp at last change made (up/down) */
+  /*  timestamp at last change made (up/down) */
   u32_t ts;
-  /** counters */
+  /*  counters */
   u32_t ifinoctets;
   u32_t ifinucastpkts;
   u32_t ifinnucastpkts;
@@ -208,7 +208,7 @@
   u32_t ifoutdiscards;
 #endif /* LWIP_SNMP */
 #if LWIP_IGMP
-  /** This function could be called to add or delete a entry in the multicast
+  /*  This function could be called to add or delete a entry in the multicast
       filter table of the ethernet MAC.*/
   netif_igmp_mac_filter_fn igmp_mac_filter;
 #endif /* LWIP_IGMP */
@@ -245,9 +245,9 @@
 #endif /* LWIP_SNMP */
 
 
-/** The list of network interfaces. */
+/*  The list of network interfaces. */
 extern struct netif *netif_list;
-/** The default network interface. */
+/*  The default network interface. */
 extern struct netif *netif_default;
 
 void netif_init(void);
@@ -274,7 +274,7 @@
 
 void netif_set_up(struct netif *netif);
 void netif_set_down(struct netif *netif);
-/** Ask if an interface is up */
+/*  Ask if an interface is up */
 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
 
 #if LWIP_NETIF_STATUS_CALLBACK
@@ -283,7 +283,7 @@
 
 void netif_set_link_up(struct netif *netif);
 void netif_set_link_down(struct netif *netif);
-/** Ask if a link is up */ 
+/*  Ask if a link is up */ 
 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
 
 #if LWIP_NETIF_LINK_CALLBACK
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/opt.h
--- a/LPC1768/lwip/include/lwip/opt.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/opt.h	Thu Aug 05 15:09:22 2010 +0000
@@ -69,6 +69,14 @@
 #endif
 
 /**
+ * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1
+ * Mainly for compatibility to old versions.
+ */
+#ifndef NO_SYS_NO_TIMERS
+#define NO_SYS_NO_TIMERS                0
+#endif
+
+/**
  * MEMCPY: override this if you have a faster implementation at hand than the
  * one included in your C library
  */
@@ -260,7 +268,7 @@
 #endif
 
 /**
- * MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
+ * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
  * reassembly (whole packets, not fragments!)
  */
 #ifndef MEMP_NUM_REASSDATA
@@ -268,6 +276,17 @@
 #endif
 
 /**
+ * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent
+ * (fragments, not whole packets!).
+ * This is only used with IP_FRAG_USES_STATIC_BUF==0 and
+ * LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 with DMA-enabled MACs
+ * where the packet is not yet sent when netif->output returns.
+ */
+#ifndef MEMP_NUM_FRAG_PBUF
+#define MEMP_NUM_FRAG_PBUF              15
+#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.
@@ -371,6 +390,22 @@
 #endif
 
 /**
+ * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list
+ * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1.
+ */
+#ifndef MEMP_NUM_LOCALHOSTLIST
+#define MEMP_NUM_LOCALHOSTLIST          1
+#endif
+
+/**
+ * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
+ * interfaces (only used with PPPOE_SUPPORT==1)
+ */
+#ifndef MEMP_NUM_PPPOE_INTERFACES
+#define MEMP_NUM_PPPOE_INTERFACES       1
+#endif
+
+/**
  * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. 
  */
 #ifndef PBUF_POOL_SIZE
@@ -444,6 +479,14 @@
 #define ETH_PAD_SIZE                    0
 #endif
 
+/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table
+ * entries (using etharp_add_static_entry/etharp_remove_static_entry).
+ */
+#ifndef ETHARP_SUPPORT_STATIC_ENTRIES
+#define ETHARP_SUPPORT_STATIC_ENTRIES   0
+#endif
+
+
 /*
    --------------------------------
    ---------- IP options ----------
@@ -507,10 +550,12 @@
 /**
  * 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.
+ * packet data to be fragmented (or with LWIP_NETIF_TX_SINGLE_PBUF==1,
+ * new PBUF_RAM pbufs are used for fragments).
+ * ATTENTION: IP_FRAG_USES_STATIC_BUF==1 may not be used for DMA-enabled MACs!
  */
 #ifndef IP_FRAG_USES_STATIC_BUF
-#define IP_FRAG_USES_STATIC_BUF         1
+#define IP_FRAG_USES_STATIC_BUF         0
 #endif
 
 /**
@@ -1313,6 +1358,13 @@
 #define LWIP_NETCONN                    1
 #endif
 
+/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout tod create
+ * timers running in tcpip_thread from another thread.
+ */
+#ifndef LWIP_TCPIP_TIMEOUT
+#define LWIP_TCPIP_TIMEOUT              1
+#endif
+
 /*
    ------------------------------------
    ---------- Socket options ----------
@@ -1373,12 +1425,21 @@
 #endif
 
 /**
- * SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!
+ * SO_REUSE==1: Enable SO_REUSEADDR option.
  */
 #ifndef SO_REUSE
 #define SO_REUSE                        0
 #endif
 
+/**
+ * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets
+ * to all local matches if SO_REUSEADDR is turned on.
+ * WARNING: Adds a memcpy for every packet if passing to more than one pcb!
+ */
+#ifndef SO_REUSE_RXTOALL
+#define SO_REUSE_RXTOALL                0
+#endif
+
 /*
    ----------------------------------------
    ---------- Statistics options ----------
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/pbuf.h
--- a/LPC1768/lwip/include/lwip/pbuf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/pbuf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -40,6 +40,10 @@
 extern "C" {
 #endif
 
+/* Currently, the pbuf_custom code is only needed for one specific configuration
+ * of IP_FRAG */
+#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
+
 #define PBUF_TRANSPORT_HLEN 20
 #define PBUF_IP_HLEN        20
 
@@ -58,16 +62,21 @@
 } pbuf_type;
 
 
-/** indicates this packet's data should be immediately passed to the application */
-#define PBUF_FLAG_PUSH 0x01U
+/* indicates this packet's data should be immediately passed to the application */
+#define PBUF_FLAG_PUSH      0x01U
+/* indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a
+    a pbuf differently */
+#define PBUF_FLAG_IS_CUSTOM 0x02U
+/* indicates this pbuf is UDP multicast to be looped back */
+#define PBUF_FLAG_MCASTLOOP 0x04U
 
 struct pbuf {
-  /** next pbuf in singly linked pbuf chain */
+  /* next pbuf in singly linked pbuf chain */
   struct pbuf *next;
 
-  /** pointer to the actual data in the buffer */
+  /* pointer to the actual data in the buffer */
   void *payload;
-  
+
   /**
    * total length of this buffer and all next buffers in chain
    * belonging to the same packet.
@@ -76,14 +85,14 @@
    * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
    */
   u16_t tot_len;
-  
-  /** length of this buffer */
-  u16_t len;  
 
-  /** pbuf_type as u8_t instead of enum to save space */
+  /* length of this buffer */
+  u16_t len;
+
+  /* pbuf_type as u8_t instead of enum to save space */
   u8_t /*pbuf_type*/ type;
 
-  /** misc flags */
+  /* misc flags */
   u8_t flags;
 
   /**
@@ -92,17 +101,33 @@
    * the stack itself, or pbuf->next pointers from a chain.
    */
   u16_t ref;
-  
 };
 
+#if LWIP_SUPPORT_CUSTOM_PBUF
+/* Prototype for a function to free a custom pbuf */
+typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
+
+/* A custom pbuf: like a pbuf, but following a function pointer to free it. */
+struct pbuf_custom {
+  /* The actual pbuf */
+  struct pbuf pbuf;
+  /* This function is called when pbuf_free deallocates this pbuf(_custom) */
+  pbuf_free_custom_fn custom_free_function;
+};
+#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
+
 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
 #define pbuf_init()
 
-struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type);
+struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
+#if LWIP_SUPPORT_CUSTOM_PBUF
+struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
+                                 struct pbuf_custom *p, void *payload_mem,
+                                 u16_t payload_mem_len);
+#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
 void pbuf_realloc(struct pbuf *p, u16_t size); 
 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
 void pbuf_ref(struct pbuf *p);
-void pbuf_ref_chain(struct pbuf *p);
 u8_t pbuf_free(struct pbuf *p);
 u8_t pbuf_clen(struct pbuf *p);  
 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
@@ -112,6 +137,15 @@
 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
+#if LWIP_CHECKSUM_ON_COPY
+err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
+                       u16_t len, u16_t *chksum);
+#endif /* LWIP_CHECKSUM_ON_COPY */
+
+u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
+u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
+u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
+u16_t pbuf_strstr(struct pbuf* p, const char* substr);
 
 #ifdef __cplusplus
 }
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/snmp_asn1.h
--- a/LPC1768/lwip/include/lwip/snmp_asn1.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/snmp_asn1.h	Thu Aug 05 15:09:22 2010 +0000
@@ -46,12 +46,12 @@
 extern "C" {
 #endif
 
-#define SNMP_ASN1_UNIV   (!0x80 | !0x40)
-#define SNMP_ASN1_APPLIC (!0x80 |  0x40)
-#define SNMP_ASN1_CONTXT ( 0x80 | !0x40)
+#define SNMP_ASN1_UNIV   (0)    /* (!0x80 | !0x40) */
+#define SNMP_ASN1_APPLIC (0x40) /* (!0x80 |  0x40) */
+#define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */
 
-#define SNMP_ASN1_CONSTR (0x20)
-#define SNMP_ASN1_PRIMIT (!0x20)
+#define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */
+#define SNMP_ASN1_PRIMIT (0)    /* (!0x20) */
 
 /* universal tags */
 #define SNMP_ASN1_INTEG  2
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/snmp_structs.h
--- a/LPC1768/lwip/include/lwip/snmp_structs.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/snmp_structs.h	Thu Aug 05 15:09:22 2010 +0000
@@ -136,7 +136,7 @@
   u8_t node_type;
   u16_t maxlength;
 
-  /* aditional struct members */
+  /* additional struct members */
   const s32_t *objid;
   struct mib_node* const *nptr;
 };
@@ -180,7 +180,7 @@
   u8_t node_type;
   u16_t maxlength;
 
-  /* aditional struct members */
+  /* additional struct members */
   struct mib_list_node *head;
   struct mib_list_node *tail;
   /* counts list nodes in list  */
@@ -200,8 +200,8 @@
   u8_t node_type;
   u16_t maxlength;
 
-  /* aditional struct members */
-  /** points to an extenal (in memory) record of some sort of addressing
+  /* additional struct members */
+  /** points to an external (in memory) record of some sort of addressing
       information, passed to and interpreted by the funtions below */
   void* addr_inf;
   /** tree levels under this node */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/sockets.h
--- a/LPC1768/lwip/include/lwip/sockets.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/sockets.h	Thu Aug 05 15:09:22 2010 +0000
@@ -72,11 +72,11 @@
 #define SOCK_RAW        3
 
 /*
- * Option flags per-socket. These must match the SOF_ flags in ip.h!
+ * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
  */
 #define  SO_DEBUG       0x0001 /* Unimplemented: turn on debugging info recording */
 #define  SO_ACCEPTCONN  0x0002 /* socket has had listen() */
-#define  SO_REUSEADDR   0x0004 /* Unimplemented: allow local address reuse */
+#define  SO_REUSEADDR   0x0004 /* Allow local address reuse */
 #define  SO_KEEPALIVE   0x0008 /* keep connections alive */
 #define  SO_DONTROUTE   0x0010 /* Unimplemented: just use interface addresses */
 #define  SO_BROADCAST   0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
@@ -279,6 +279,12 @@
 #define O_NDELAY    1 /* same as O_NONBLOCK, for compatibility */
 #endif
 
+#ifndef SHUT_RD
+  #define SHUT_RD   1
+  #define SHUT_WR   2
+  #define SHUT_RDWR 3
+#endif
+
 /* FD_SET used for lwip_select */
 #ifndef FD_SET
   #undef  FD_SETSIZE
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/stats.h
--- a/LPC1768/lwip/include/lwip/stats.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/stats.h	Thu Aug 05 15:09:22 2010 +0000
@@ -148,7 +148,7 @@
 
 extern struct stats_ lwip_stats;
 
-void stats_init();
+void stats_init(void);
 
 #define STATS_INC(x) ++lwip_stats.x
 #define STATS_DEC(x) --lwip_stats.x
@@ -157,7 +157,7 @@
                                     lwip_stats.x.max = lwip_stats.x.used; \
                                 } \
                              } while(0)
-#else
+#else /* LWIP_STATS */
 #define stats_init()
 #define STATS_INC(x)
 #define STATS_DEC(x)
@@ -276,7 +276,7 @@
 void stats_display_mem(struct stats_mem *mem, char *name);
 void stats_display_memp(struct stats_mem *mem, int index);
 void stats_display_sys(struct stats_sys *sys);
-#else
+#else /* LWIP_STATS_DISPLAY */
 #define stats_display()
 #define stats_display_proto(proto, name)
 #define stats_display_igmp(igmp)
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/sys.h
--- a/LPC1768/lwip/include/lwip/sys.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/sys.h	Thu Aug 05 15:09:22 2010 +0000
@@ -136,8 +136,8 @@
 void sys_sem_signal(sys_sem_t *sem);
 /** Wait for a semaphore for the specified timeout
  * @param sem the semaphore to wait for
- * @param timeout timeout in miliseconds to wait (0 = wait forever)
- * @return time (in miliseconds) waited for the semaphore
+ * @param timeout timeout in milliseconds to wait (0 = wait forever)
+ * @return time (in milliseconds) waited for the semaphore
  *         or SYS_ARCH_TIMEOUT on timeout */
 u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout);
 /** Delete a semaphore
@@ -178,8 +178,8 @@
 /** Wait for a new message to arrive in the mbox
  * @param mbox mbox to get a message from
  * @param msg pointer where the message is stored
- * @param timeout maximum time (in miliseconds) to wait for a message
- * @return time (in miliseconds) waited for a message, may be 0 if not waited
+ * @param timeout maximum time (in milliseconds) to wait for a message
+ * @return time (in milliseconds) waited for a message, may be 0 if not waited
            or SYS_ARCH_TIMEOUT on timeout
  *         The returned time has to be accurate to prevent timer jitter! */
 u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout);
@@ -188,8 +188,8 @@
 /** Wait for a new message to arrive in the mbox
  * @param mbox mbox to get a message from
  * @param msg pointer where the message is stored
- * @param timeout maximum time (in miliseconds) to wait for a message
- * @return 0 (miliseconds) if a message has been received
+ * @param timeout maximum time (in milliseconds) to wait for a message
+ * @return 0 (milliseconds) if a message has been received
  *         or SYS_MBOX_EMPTY if the mailbox is empty */
 u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg);
 #endif
@@ -215,7 +215,7 @@
  * @param arg parameter passed to 'thread'
  * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
  * @param prio priority of the new thread (may be ignored by ports) */
-sys_thread_t sys_thread_new(char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
+sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
 
 #endif /* NO_SYS */
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/tcp_impl.h
--- a/LPC1768/lwip/include/lwip/tcp_impl.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/tcp_impl.h	Thu Aug 05 15:09:22 2010 +0000
@@ -176,7 +176,7 @@
 
 #define TCPH_OFFSET_SET(phdr, offset) (phdr)->_hdrlen_rsvd_flags = htons(((offset) << 8) | TCPH_FLAGS(phdr))
 #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
-#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & htons((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags))
+#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags))
 #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags))
 
 #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags))
@@ -199,6 +199,8 @@
                    LWIP_EVENT_SENT, NULL, space, ERR_OK)
 #define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
                 LWIP_EVENT_RECV, (p), 0, (err))
+#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
+                LWIP_EVENT_RECV, NULL, 0, ERR_OK)
 #define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
                 LWIP_EVENT_CONNECTED, NULL, 0, (err))
 #define TCP_EVENT_POLL(pcb,ret)       ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
@@ -222,13 +224,22 @@
     else (ret) = ERR_OK;                                       \
   } while (0)
 
-#define TCP_EVENT_RECV(pcb,p,err,ret)                              \
-  do {                                                             \
-    if(((pcb)->recv != NULL) && (!((pcb)->flags & TF_RXCLOSED))) { \
-      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));    \
-    } else {                                                       \
-      (ret) = tcp_recv_null(NULL, (pcb), (p), (err));              \
-    }                                                              \
+#define TCP_EVENT_RECV(pcb,p,err,ret)                          \
+  do {                                                         \
+    if((pcb)->recv != NULL) {                                  \
+      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\
+    } else {                                                   \
+      (ret) = tcp_recv_null(NULL, (pcb), (p), (err));          \
+    }                                                          \
+  } while (0)
+
+#define TCP_EVENT_CLOSED(pcb,ret)                                \
+  do {                                                           \
+    if(((pcb)->recv != NULL)) {                                  \
+      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\
+    } else {                                                     \
+      (ret) = ERR_OK;                                            \
+    }                                                            \
   } while (0)
 
 #define TCP_EVENT_CONNECTED(pcb,err,ret)                         \
@@ -260,7 +271,7 @@
 #define TCP_OVERSIZE_DBGCHECK 0
 #endif
 
-/** Don't generate chceksum on copy if CHECKSUM_GEN_TCP is disabled */
+/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */
 #define TCP_CHECKSUM_ON_COPY  (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)
 
 /* This structure represents a TCP segment on the unsent, unacked and ooseq queues */
@@ -291,10 +302,10 @@
   (flags & TF_SEG_OPTS_TS  ? 12 : 0)
 
 /** This returns a TCP header option for MSS in an u32_t */
-#define TCP_BUILD_MSS_OPTION(x) (x) = htonl(((u32_t)2 << 24) |          \
-                                            ((u32_t)4 << 16) |          \
-                                            (((u32_t)TCP_MSS / 256) << 8) | \
-                                            (TCP_MSS & 255))
+#define TCP_BUILD_MSS_OPTION(x) (x) = PP_HTONL(((u32_t)2 << 24) |          \
+                                               ((u32_t)4 << 16) |          \
+                                               (((u32_t)TCP_MSS / 256) << 8) | \
+                                               (TCP_MSS & 255))
 
 /* Global variables: */
 extern struct tcp_pcb *tcp_input_pcb;
@@ -305,6 +316,7 @@
   struct tcp_pcb_listen *listen_pcbs; 
   struct tcp_pcb *pcbs;
 };
+extern struct tcp_pcb *tcp_bound_pcbs;
 extern union tcp_listen_pcbs_t tcp_listen_pcbs;
 extern struct tcp_pcb *tcp_active_pcbs;  /* List of all TCP PCBs that are in a
               state in which they accept or send
@@ -321,62 +333,65 @@
 */
 /* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
    with a PCB list or removes a PCB from a list, respectively. */
-#if 0
+#ifndef TCP_DEBUG_PCB_LISTS
+#define TCP_DEBUG_PCB_LISTS 0
+#endif
+#if TCP_DEBUG_PCB_LISTS
 #define TCP_REG(pcbs, npcb) do {\
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
-                            for(tcp_tmp_pcb = *pcbs; \
+                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \
+                            for(tcp_tmp_pcb = *(pcbs); \
           tcp_tmp_pcb != NULL; \
         tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
+                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \
                             } \
-                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
-                            npcb->next = *pcbs; \
-                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
-                            *(pcbs) = npcb; \
+                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \
+                            (npcb)->next = *(pcbs); \
+                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \
+                            *(pcbs) = (npcb); \
                             LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
               tcp_timer_needed(); \
                             } while(0)
 #define TCP_RMV(pcbs, npcb) do { \
-                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
-                            if(*pcbs == npcb) { \
-                               *pcbs = (*pcbs)->next; \
-                            } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                               if(tcp_tmp_pcb->next == npcb) { \
-                                  tcp_tmp_pcb->next = npcb->next; \
+                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
+                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
+                            if(*(pcbs) == (npcb)) { \
+                               *(pcbs) = (*pcbs)->next; \
+                            } else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
+                               if(tcp_tmp_pcb->next == (npcb)) { \
+                                  tcp_tmp_pcb->next = (npcb)->next; \
                                   break; \
                                } \
                             } \
-                            npcb->next = NULL; \
+                            (npcb)->next = NULL; \
                             LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
+                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \
                             } while(0)
 
 #else /* LWIP_DEBUG */
 
 #define TCP_REG(pcbs, npcb)                        \
   do {                                             \
-    npcb->next = *pcbs;                            \
-    *(pcbs) = npcb;                                \
+    (npcb)->next = *pcbs;                          \
+    *(pcbs) = (npcb);                              \
     tcp_timer_needed();                            \
   } while (0)
 
 #define TCP_RMV(pcbs, npcb)                        \
   do {                                             \
-    if(*(pcbs) == npcb) {                          \
+    if(*(pcbs) == (npcb)) {                        \
       (*(pcbs)) = (*pcbs)->next;                   \
     }                                              \
     else {                                         \
-      for(tcp_tmp_pcb = *pcbs;                                         \
-          tcp_tmp_pcb != NULL;                                         \
-          tcp_tmp_pcb = tcp_tmp_pcb->next) {                           \
-        if(tcp_tmp_pcb->next == npcb) {   \
-          tcp_tmp_pcb->next = npcb->next;          \
+      for(tcp_tmp_pcb = *pcbs;                     \
+          tcp_tmp_pcb != NULL;                     \
+          tcp_tmp_pcb = tcp_tmp_pcb->next) {       \
+        if(tcp_tmp_pcb->next == (npcb)) {          \
+          tcp_tmp_pcb->next = (npcb)->next;        \
           break;                                   \
         }                                          \
       }                                            \
     }                                              \
-    npcb->next = NULL;                             \
+    (npcb)->next = NULL;                           \
   } while(0)
 
 #endif /* LWIP_DEBUG */
@@ -448,68 +463,6 @@
 void tcp_timer_needed(void);
 
 
-/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
-   with a PCB list or removes a PCB from a list, respectively. */
-#if 0
-#define TCP_REG(pcbs, npcb) do {\
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
-                            for(tcp_tmp_pcb = *pcbs; \
-          tcp_tmp_pcb != NULL; \
-        tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
-                            } \
-                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
-                            npcb->next = *pcbs; \
-                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
-                            *(pcbs) = npcb; \
-                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-              tcp_timer_needed(); \
-                            } while(0)
-#define TCP_RMV(pcbs, npcb) do { \
-                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
-                            if(*pcbs == npcb) { \
-                               *pcbs = (*pcbs)->next; \
-                            } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                               if(tcp_tmp_pcb->next == npcb) { \
-                                  tcp_tmp_pcb->next = npcb->next; \
-                                  break; \
-                               } \
-                            } \
-                            npcb->next = NULL; \
-                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
-                            } while(0)
-
-#else /* LWIP_DEBUG */
-
-#define TCP_REG(pcbs, npcb)                        \
-  do {                                             \
-    npcb->next = *pcbs;                            \
-    *(pcbs) = npcb;                                \
-    tcp_timer_needed();                            \
-  } while (0)
-
-#define TCP_RMV(pcbs, npcb)                        \
-  do {                                             \
-    if(*(pcbs) == npcb) {                          \
-      (*(pcbs)) = (*pcbs)->next;                   \
-    }                                              \
-    else {                                         \
-      for(tcp_tmp_pcb = *pcbs;                                         \
-          tcp_tmp_pcb != NULL;                                         \
-          tcp_tmp_pcb = tcp_tmp_pcb->next) {                           \
-        if(tcp_tmp_pcb->next == npcb) {   \
-          tcp_tmp_pcb->next = npcb->next;          \
-          break;                                   \
-        }                                          \
-      }                                            \
-    }                                              \
-    npcb->next = NULL;                             \
-  } while(0)
-
-#endif /* LWIP_DEBUG */
-
 #ifdef __cplusplus
 }
 #endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/tcpip.h
--- a/LPC1768/lwip/include/lwip/tcpip.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/tcpip.h	Thu Aug 05 15:09:22 2010 +0000
@@ -48,6 +48,12 @@
 extern "C" {
 #endif
 
+/** Define this to something that triggers a watchdog. This is called from
+ * tcpip_thread after processing a message. */
+#ifndef LWIP_TCPIP_THREAD_ALIVE
+#define LWIP_TCPIP_THREAD_ALIVE()
+#endif
+
 #if LWIP_TCPIP_CORE_LOCKING
 /** The global semaphore to lock the stack. */
 extern sys_mutex_t lock_tcpip_core;
@@ -96,8 +102,10 @@
 err_t pbuf_free_callback(struct pbuf *p);
 err_t mem_free_callback(void *m);
 
+#if LWIP_TCPIP_TIMEOUT
 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
+#endif /* LWIP_TCPIP_TIMEOUT */
 
 enum tcpip_msg_type {
 #if LWIP_NETCONN
@@ -107,9 +115,11 @@
 #if LWIP_NETIF_API
   TCPIP_MSG_NETIFAPI,
 #endif /* LWIP_NETIF_API */
-  TCPIP_MSG_CALLBACK,
+#if LWIP_TCPIP_TIMEOUT
   TCPIP_MSG_TIMEOUT,
-  TCPIP_MSG_UNTIMEOUT
+  TCPIP_MSG_UNTIMEOUT,
+#endif /* LWIP_TCPIP_TIMEOUT */
+  TCPIP_MSG_CALLBACK
 };
 
 struct tcpip_msg {
@@ -130,11 +140,13 @@
       tcpip_callback_fn function;
       void *ctx;
     } cb;
+#if LWIP_TCPIP_TIMEOUT
     struct {
       u32_t msecs;
       sys_timeout_handler h;
       void *arg;
     } tmo;
+#endif /* LWIP_TCPIP_TIMEOUT */
   } msg;
 };
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/timers.h
--- a/LPC1768/lwip/include/lwip/timers.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/timers.h	Thu Aug 05 15:09:22 2010 +0000
@@ -35,6 +35,11 @@
 
 #include "lwip/opt.h"
 
+/* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */
+#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS))
+
+#if LWIP_TIMERS
+
 #include "lwip/err.h"
 #include "lwip/sys.h"
 
@@ -70,13 +75,13 @@
 void sys_timeouts_init(void);
 
 #if LWIP_DEBUG_TIMERNAMES
-void sys_timeout_debug(u32_t msecs, sys_timeout_handler h, void *arg, const char* handler_name);
+void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name);
 #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler)
 #else /* LWIP_DEBUG_TIMERNAMES */
-void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
+void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg);
 #endif /* LWIP_DEBUG_TIMERNAMES */
 
-void sys_untimeout(sys_timeout_handler h, void *arg);
+void sys_untimeout(sys_timeout_handler handler, void *arg);
 #if NO_SYS
 void sys_check_timeouts(void);
 void sys_restart_timeouts(void);
@@ -89,4 +94,5 @@
 }
 #endif
 
+#endif /* LWIP_TIMERS */
 #endif /* __LWIP_TIMERS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/lwip/udp.h
--- a/LPC1768/lwip/include/lwip/udp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/lwip/udp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -63,9 +63,10 @@
 #  include "arch/epstruct.h"
 #endif
 
-#define UDP_FLAGS_NOCHKSUM 0x01U
-#define UDP_FLAGS_UDPLITE  0x02U
-#define UDP_FLAGS_CONNECTED  0x04U
+#define UDP_FLAGS_NOCHKSUM       0x01U
+#define UDP_FLAGS_UDPLITE        0x02U
+#define UDP_FLAGS_CONNECTED      0x04U
+#define UDP_FLAGS_MULTICAST_LOOP 0x08U
 
 struct udp_pcb;
 
@@ -135,6 +136,18 @@
                                  ip_addr_t *dst_ip, u16_t dst_port);
 err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);
 
+#if LWIP_CHECKSUM_ON_COPY
+err_t            udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p,
+                                 ip_addr_t *dst_ip, u16_t dst_port,
+                                 struct netif *netif, u8_t have_chksum,
+                                 u16_t chksum);
+err_t            udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p,
+                                 ip_addr_t *dst_ip, u16_t dst_port,
+                                 u8_t have_chksum, u16_t chksum);
+err_t            udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
+                                 u8_t have_chksum, u16_t chksum);
+#endif /* LWIP_CHECKSUM_ON_COPY */
+
 #define          udp_flags(pcb) ((pcb)->flags)
 #define          udp_setflags(pcb, f)  ((pcb)->flags = (f))
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/netif/etharp.h
--- a/LPC1768/lwip/include/netif/etharp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/netif/etharp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -68,7 +68,7 @@
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-/** Ethernet header */
+/* Ethernet header */
 struct eth_hdr {
 #if ETH_PAD_SIZE
   PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
@@ -90,7 +90,7 @@
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-/** VLAN header inserted between ethernet header and payload
+/* VLAN header inserted between ethernet header and payload
  * if 'type' in ethernet header is ETHTYPE_VLAN.
  * See IEEE802.Q */
 struct eth_vlan_hdr {
@@ -111,11 +111,12 @@
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-/** the ARP message, see RFC 826 ("Packet format") */
+/* the ARP message, see RFC 826 ("Packet format") */
 struct etharp_hdr {
   PACK_STRUCT_FIELD(u16_t hwtype);
   PACK_STRUCT_FIELD(u16_t proto);
-  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
+  PACK_STRUCT_FIELD(u8_t  hwlen);
+  PACK_STRUCT_FIELD(u8_t  protolen);
   PACK_STRUCT_FIELD(u16_t opcode);
   PACK_STRUCT_FIELD(struct eth_addr shwaddr);
   PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
@@ -130,7 +131,7 @@
 #define SIZEOF_ETHARP_HDR 28
 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
 
-/** 5 seconds period */
+/* 5 seconds period */
 #define ARP_TMR_INTERVAL 5000
 
 #define ETHTYPE_ARP       0x0806
@@ -139,14 +140,36 @@
 #define ETHTYPE_PPPOEDISC 0x8863  /* PPP Over Ethernet Discovery Stage */
 #define ETHTYPE_PPPOE     0x8864  /* PPP Over Ethernet Session Stage */
 
+/* MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
+ * or known to be 32-bit aligned within the protocol header. */
+#ifndef ETHADDR32_COPY
+#define ETHADDR32_COPY(src, dst)  SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
+#endif
+
+/* MEMCPY-like macro to copy to/from struct eth_addr's that are no local
+ * variables and known to be 16-bit aligned within the protocol header. */
+#ifndef ETHADDR16_COPY
+#define ETHADDR16_COPY(src, dst)  SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
+#endif
+
 #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
 
-/** ARP message types (opcodes) */
+/* ARP message types (opcodes) */
 #define ARP_REQUEST 1
 #define ARP_REPLY   2
 
+/* Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type)
+ * to a filter function that returns the correct netif when using multiple
+ * netifs on one hardware interface where the netif's low-level receive
+ * routine cannot decide for the correct netif (e.g. when mapping multiple
+ * IP addresses to one hardware interface).
+ */
+#ifndef LWIP_ARP_FILTER_NETIF
+#define LWIP_ARP_FILTER_NETIF 0
+#endif
+
 #if ARP_QUEUEING
-/** struct for queueing outgoing packets for unknown address
+/* struct for queueing outgoing packets for unknown address
   * defined here to be accessed by memp.h
   */
 struct etharp_q_entry {
@@ -162,12 +185,17 @@
 err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
 err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q);
 err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr);
-/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
+/* For Ethernet network interfaces, we might want to send "gratuitous ARP";
  *  this is an ARP packet sent by a node in order to spontaneously cause other
  *  nodes to update an entry in their ARP cache.
  *  From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
 #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
 
+#if ETHARP_SUPPORT_STATIC_ENTRIES
+err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr);
+err_t etharp_remove_static_entry(ip_addr_t *ipaddr);
+#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
+
 #if LWIP_AUTOIP
 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
                  const struct eth_addr *ethdst_addr,
@@ -176,7 +204,6 @@
                  const u16_t opcode);
 #endif /* LWIP_AUTOIP */
 
-
 #endif /* LWIP_ARP */
 
 err_t ethernet_input(struct pbuf *p, struct netif *netif);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/include/netif/ppp_oe.h
--- a/LPC1768/lwip/include/netif/ppp_oe.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/include/netif/ppp_oe.h	Thu Aug 05 15:09:22 2010 +0000
@@ -140,12 +140,38 @@
 /* two byte PPP protocol discriminator, then IP data */
 #define PPPOE_MAXMTU          (ETHERMTU-PPPOE_HEADERLEN-2)
 
-struct pppoe_softc;
+#ifndef PPPOE_MAX_AC_COOKIE_LEN
+#define PPPOE_MAX_AC_COOKIE_LEN   64
+#endif
+
+struct pppoe_softc {
+  struct pppoe_softc *next;
+  struct netif *sc_ethif;      /* ethernet interface we are using */
+  int sc_pd;                   /* ppp unit number */
+  void (*sc_linkStatusCB)(int pd, int up);
+
+  int sc_state;                /* discovery phase or session connected */
+  struct eth_addr sc_dest;     /* hardware address of concentrator */
+  u16_t sc_session;            /* PPPoE session id */
+
+#ifdef PPPOE_TODO
+  char *sc_service_name;       /* if != NULL: requested name of service */
+  char *sc_concentrator_name;  /* if != NULL: requested concentrator id */
+#endif /* PPPOE_TODO */
+  u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
+  size_t sc_ac_cookie_len;     /* length of cookie data */
+#ifdef PPPOE_SERVER
+  u8_t *sc_hunique;            /* content of host unique we must echo back */
+  size_t sc_hunique_len;       /* length of host unique */
+#endif
+  int sc_padi_retried;         /* number of PADI retries already done */
+  int sc_padr_retried;         /* number of PADR retries already done */
+};
 
 
-void pppoe_init(void);
+#define pppoe_init() /* compatibility define, no initialization needed */
 
-err_t pppoe_create(struct netif *ethernetnetif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
+err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
 err_t pppoe_destroy(struct netif *ifp);
 
 int pppoe_connect(struct pppoe_softc *sc);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/lwipopts.h
--- a/LPC1768/lwip/lwipopts.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/lwip/lwipopts.h	Thu Aug 05 15:09:22 2010 +0000
@@ -53,10 +53,10 @@
 #define TUNIF_DEBUG LWIP_DBG_OFF
 #define UNIXIF_DEBUG LWIP_DBG_OFF
 #define DELIF_DEBUG LWIP_DBG_OFF
-#define SIO_FIFO_DEBUG LWIP_DBG_OFF
-#define TCPDUMP_DEBUG LWIP_DBG_OFF
+#define SIO_FIFO_DEBUG LWIP_DBG_ON
+#define TCPDUMP_DEBUG LWIP_DBG_ON
 
-#define PPP_DEBUG        LWIP_DBG_ON
+#define PPP_DEBUG        LWIP_DBG_OFF
 #define MEM_DEBUG        LWIP_DBG_OFF
 #define MEMP_DEBUG       LWIP_DBG_OFF
 #define PBUF_DEBUG       LWIP_DBG_OFF
@@ -70,6 +70,7 @@
 #define IP_REASS_DEBUG   LWIP_DBG_OFF
 #define RAW_DEBUG        LWIP_DBG_OFF
 #define ICMP_DEBUG       LWIP_DBG_OFF
+#define IGMP_DEBUG       LWIP_DBG_OFF
 #define UDP_DEBUG        LWIP_DBG_OFF
 #define TCP_DEBUG        LWIP_DBG_OFF
 #define TCP_INPUT_DEBUG  LWIP_DBG_OFF
@@ -174,30 +175,34 @@
 
 /* ---------- TCP options ---------- */
 #define LWIP_TCP                1
-#define TCP_TTL                 255
+//#define TCP_TTL                 255
 
 /* Controls if TCP should queue segments that arrive out of
    order. Define to 0 if your device is low on memory. */
-#define TCP_QUEUE_OOSEQ         0
+#define TCP_QUEUE_OOSEQ         1
 
 /* TCP Maximum segment size. */
 //#define TCP_MSS                 1024
-#define TCP_MSS                   1024//536//0x276
+#define TCP_MSS                   536//1024//536//0x276
 
 /* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             2048
+#define TCP_SND_BUF             (3 * TCP_MSS) //2048
 
 /* TCP sender buffer space (pbufs). This must be at least = 2 *
    TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)
+#define TCP_SND_QUEUELEN        (4 * (TCP_SND_BUF)/(TCP_MSS))
 
 /* 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 */
-#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
+#define TCP_SNDLOWAT        ((TCP_SND_BUF)/2)
 
+/**
+ * TCP_WND: The size of a TCP window.  This must be at least 
+ * (2 * TCP_MSS) for things to work well
+ */
 /* TCP receive window. */
-#define TCP_WND        1024         //8096
+#define TCP_WND        (4 * TCP_MSS)         //8096
 
 /* Maximum number of retransmissions of data segments. */
 //#define TCP_MAXRTX              12
@@ -272,14 +277,14 @@
 
 /* TCP Maximum segment size. */
 //#define TCP_MSS                 1024
-#define TCP_MSS                   512//0x276//536//0x276
+#define TCP_MSS                   536//0x276//536//0x276
 
 /* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             1024//2048
+#define TCP_SND_BUF             (3 * TCP_MSS)
 
 /* TCP sender buffer space (pbufs). This must be at least = 2 *
    TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
+#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
 
 /* TCP writable space (bytes). This must be less than or equal
    to TCP_SND_BUF. It is the amount of space which must be
@@ -287,7 +292,7 @@
 #define TCP_SNDLOWAT        (TCP_SND_BUF/2)
 
 /* TCP receive window. */
-#define TCP_WND        512         //8096
+#define TCP_WND        (3 * TCP_MSS)         //8096
 
 /* Maximum number of retransmissions of data segments. */
 //#define TCP_MAXRTX              12
@@ -299,8 +304,8 @@
 
 /* ---------- ARP options ---------- */
 #define LWIP_ARP                (NET_ETH | NET_ZG2100)
-#define ARP_TABLE_SIZE          2//4//10
-#define ARP_QUEUEING            0//1
+#define ARP_TABLE_SIZE          4//10
+#define ARP_QUEUEING            0
 #define ETHARP_TRUST_IP_MAC     1
 
 /* ---------- IP options ---------- */
@@ -321,6 +326,9 @@
 /* ---------- ICMP options ---------- */
 #define ICMP_TTL                255
 
+/* ---------- IGMP options ---------- */
+#define LWIP_IGMP               (NET_ETH | NET_ZG2100)
+
 /* ---------- DHCP options ---------- */
 /* Define LWIP_DHCP to 1 if you want DHCP configuration of
    interfaces. */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/lwipopts2.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/lwip/lwipopts2.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,454 @@
+/*
+ * Copyright (c) 2001-2003 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 __LWIPOPTS_H__
+#define __LWIPOPTS_H__
+
+#include "netCfg.h"
+#if NET_LWIP_STACK
+
+//#include "arch/sys_arch.h"
+
+/* <sys/time.h> is included in cc.h! */
+#define LWIP_TIMEVAL_PRIVATE 0
+
+//#define __LWIP_DEBUG
+#include "dbg/dbg.h"
+
+#ifdef __LWIP_DEBUG
+
+#define LWIP_DEBUG 1
+
+#define LWIP_DBG_MIN_LEVEL 0
+//#define LWIP_COMPAT_SOCKETS 1
+#define TAPIF_DEBUG LWIP_DBG_OFF
+#define TUNIF_DEBUG LWIP_DBG_OFF
+#define UNIXIF_DEBUG LWIP_DBG_OFF
+#define DELIF_DEBUG LWIP_DBG_OFF
+#define SIO_FIFO_DEBUG LWIP_DBG_OFF
+#define TCPDUMP_DEBUG LWIP_DBG_OFF
+
+#define PPP_DEBUG        LWIP_DBG_OFF
+#define MEM_DEBUG        LWIP_DBG_ON
+#define MEMP_DEBUG       LWIP_DBG_ON
+#define PBUF_DEBUG       LWIP_DBG_ON
+#define API_LIB_DEBUG    LWIP_DBG_OFF
+#define API_MSG_DEBUG    LWIP_DBG_OFF
+#define TCPIP_DEBUG      LWIP_DBG_OFF
+#define NETIF_DEBUG      LWIP_DBG_OFF
+#define SOCKETS_DEBUG    LWIP_DBG_OFF
+#define DEMO_DEBUG       LWIP_DBG_OFF
+#define IP_DEBUG         LWIP_DBG_OFF
+#define IP_REASS_DEBUG   LWIP_DBG_OFF
+#define RAW_DEBUG        LWIP_DBG_OFF
+#define ICMP_DEBUG       LWIP_DBG_OFF
+#define UDP_DEBUG        LWIP_DBG_OFF
+#define TCP_DEBUG        LWIP_DBG_OFF
+#define TCP_INPUT_DEBUG  LWIP_DBG_OFF
+#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
+#define TCP_RTO_DEBUG    LWIP_DBG_OFF
+#define TCP_CWND_DEBUG   LWIP_DBG_OFF
+#define TCP_WND_DEBUG    LWIP_DBG_OFF
+#define TCP_FR_DEBUG     LWIP_DBG_OFF
+#define TCP_QLEN_DEBUG   LWIP_DBG_OFF
+#define TCP_RST_DEBUG    LWIP_DBG_OFF
+#define ETHARP_DEBUG     LWIP_DBG_OFF
+#define DNS_DEBUG        LWIP_DBG_OFF
+
+#endif
+
+/*
+extern unsigned char debug_flags;
+#define LWIP_DBG_TYPES_ON debug_flags
+*/
+#define NO_SYS                     1
+#define LWIP_SOCKET                (NO_SYS==0)
+#define LWIP_NETCONN               (NO_SYS==0)
+
+
+#define IP_FRAG_USES_STATIC_BUF         0
+
+
+
+/* ---------- 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. */
+/* MSVC port: intel processors don't need 4-byte alignment,
+   but are faster that way! */
+#define MEM_ALIGNMENT           4
+
+/* 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. */
+//#define MEM_SIZE               10240 
+
+#if TARGET_LPC1768
+
+
+#define MEM_SIZE               4000
+
+///
+
+#define MEM_POSITION __attribute((section("AHBSRAM0")))
+
+/* 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. */
+#define MEMP_NUM_PBUF           16
+/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
+   per active RAW "connection". */
+//#define MEMP_NUM_RAW_PCB        3
+/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+   per active UDP "connection". */
+#define MEMP_NUM_UDP_PCB        2
+/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB        2
+/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB_LISTEN 2//4
+/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
+   segments. */
+#define MEMP_NUM_TCP_SEG        16
+/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
+   timeouts. */
+#define MEMP_NUM_SYS_TIMEOUT    12
+
+/* 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. */
+#define MEMP_NUM_NETBUF         0
+/* MEMP_NUM_NETCONN: the number of struct netconns. */
+#define MEMP_NUM_NETCONN        0
+/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
+   for sequential API communication and incoming packets. Used in
+   src/api/tcpip.c. */
+#define MEMP_NUM_TCPIP_MSG_API   0
+#define MEMP_NUM_TCPIP_MSG_INPKT 0
+
+/* ---------- Pbuf options ---------- */
+/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+#define PBUF_POOL_SIZE          8//100
+
+/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
+#define PBUF_POOL_BUFSIZE       128
+
+/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+   link level header. */
+//#define PBUF_LINK_HLEN          16 
+
+/** SYS_LIGHTWEIGHT_PROT
+ * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
+ * for certain critical regions during buffer allocation, deallocation and memory
+ * allocation and deallocation.
+ */
+#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
+
+/* ---------- TCP options ---------- */
+#define LWIP_TCP                1
+#define TCP_TTL                 255
+
+/* Controls if TCP should queue segments that arrive out of
+   order. Define to 0 if your device is low on memory. */
+#define TCP_QUEUE_OOSEQ         0
+
+/* TCP Maximum segment size. */
+//#define TCP_MSS                 1024
+#define TCP_MSS                   0x276//536//0x276
+
+/* TCP sender buffer space (bytes). */
+#define TCP_SND_BUF             2048
+
+/* TCP sender buffer space (pbufs). This must be at least = 2 *
+   TCP_SND_BUF/TCP_MSS for things to work. */
+#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)
+
+/* 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 */
+#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
+
+/* TCP receive window. */
+#define TCP_WND        2048         //8096
+
+/* Maximum number of retransmissions of data segments. */
+//#define TCP_MAXRTX              12
+
+/* Maximum number of retransmissions of SYN segments. */
+//#define TCP_SYNMAXRTX           4
+
+#elif TARGET_LPC2368
+
+#define MEM_POSITION __attribute((section("AHBSRAM1")))
+
+/* 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. */
+#define MEMP_NUM_PBUF           8
+/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
+   per active RAW "connection". */
+//#define MEMP_NUM_RAW_PCB        3
+/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+   per active UDP "connection". */
+#define MEMP_NUM_UDP_PCB        2
+/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB        2
+/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB_LISTEN 2//4
+/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
+   segments. */
+#define MEMP_NUM_TCP_SEG        8
+/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
+   timeouts. */
+#define MEMP_NUM_SYS_TIMEOUT    12
+
+/* 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. */
+#define MEMP_NUM_NETBUF         0
+/* MEMP_NUM_NETCONN: the number of struct netconns. */
+#define MEMP_NUM_NETCONN        0
+/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
+   for sequential API communication and incoming packets. Used in
+   src/api/tcpip.c. */
+#define MEMP_NUM_TCPIP_MSG_API   0
+#define MEMP_NUM_TCPIP_MSG_INPKT 0
+
+/* ---------- Pbuf options ---------- */
+/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+#define PBUF_POOL_SIZE          8//16//100
+
+/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
+//#define PBUF_POOL_BUFSIZE       128
+
+/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+   link level header. */
+//#define PBUF_LINK_HLEN          16 
+
+/** SYS_LIGHTWEIGHT_PROT
+ * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
+ * for certain critical regions during buffer allocation, deallocation and memory
+ * allocation and deallocation.
+ */
+#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
+
+/* ---------- TCP options ---------- */
+#define LWIP_TCP                1
+#define TCP_TTL                 255
+
+/* Controls if TCP should queue segments that arrive out of
+   order. Define to 0 if your device is low on memory. */
+#define TCP_QUEUE_OOSEQ         0
+
+/* TCP Maximum segment size. */
+//#define TCP_MSS                 1024
+#define TCP_MSS                   512//0x276//536//0x276
+
+/* TCP sender buffer space (bytes). */
+#define TCP_SND_BUF             1024//2048
+
+/* TCP sender buffer space (pbufs). This must be at least = 2 *
+   TCP_SND_BUF/TCP_MSS for things to work. */
+#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
+
+/* 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 */
+#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
+
+/* TCP receive window. */
+#define TCP_WND        512         //8096
+
+/* Maximum number of retransmissions of data segments. */
+//#define TCP_MAXRTX              12
+
+/* Maximum number of retransmissions of SYN segments. */
+//#define TCP_SYNMAXRTX           4
+
+#endif
+
+/* ---------- ARP options ---------- */
+#define LWIP_ARP                (NET_ETH | NET_ZG2100)
+#define ARP_TABLE_SIZE          2//4//10
+#define ARP_QUEUEING            0//1
+#define ETHARP_TRUST_IP_MAC     1
+
+/* ---------- 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. */
+#define IP_FORWARD              0
+
+
+/* IP reassembly and segmentation.These are orthogonal even
+ * if they both deal with IP fragments */
+ /*
+#define IP_REASSEMBLY     1
+#define IP_REASS_MAX_PBUFS      10
+#define MEMP_NUM_REASSDATA      10
+#define IP_FRAG           1
+*/
+/* ---------- ICMP options ---------- */
+#define ICMP_TTL                255
+
+/* ---------- DHCP options ---------- */
+/* Define LWIP_DHCP to 1 if you want DHCP configuration of
+   interfaces. */
+#define LWIP_DHCP               (NET_ETH | NET_ZG2100)
+
+/* 1 if you want to do an ARP check on the offered address
+   (recommended if using DHCP). */
+#define DHCP_DOES_ARP_CHECK     (LWIP_DHCP)
+
+/* ---------- AUTOIP options ------- */
+#define LWIP_AUTOIP             0
+
+/* ---------- SNMP options ---------- */
+/** @todo SNMP is experimental for now
+    @note UDP must be available for SNMP transport */
+#ifndef LWIP_SNMP
+#define LWIP_SNMP               0
+#endif
+
+
+#ifndef SNMP_PRIVATE_MIB
+#define SNMP_PRIVATE_MIB        0
+#endif
+
+
+/* ---------- UDP options ---------- */
+#define LWIP_UDP                1
+#define UDP_TTL                 255
+
+/* ---------- DNS options ---------- */
+#define LWIP_DNS                1
+
+/* ---------- RAW options ---------- */
+#define LWIP_RAW                0
+#define RAW_TTL                 255
+
+/* ---------- Statistics options ---------- */
+/* individual STATS options can be turned off by defining them to 0 
+ * (e.g #define TCP_STATS 0). All of them are turned off if LWIP_STATS
+ * is 0
+ * */
+
+#define LWIP_STATS    0
+
+/* ---------- PPP options ---------- */
+
+#define PPP_SUPPORT      NET_PPP      /* Set > 0 for PPP */
+
+#if PPP_SUPPORT > 0
+
+#define NUM_PPP 1           /* Max PPP sessions. */
+
+
+/* Select modules to enable.  Ideally these would be set in the makefile but
+ * we're limited by the command line length so you need to modify the settings
+ * in this file.
+ */
+#define PAP_SUPPORT      1      /* Set > 0 for PAP. */
+#define CHAP_SUPPORT     1      /* Set > 0 for CHAP. */
+#define MSCHAP_SUPPORT   0      /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */
+#define CBCP_SUPPORT     0      /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
+#define CCP_SUPPORT      0      /* Set > 0 for CCP (NOT FUNCTIONAL!) */
+#define VJ_SUPPORT       1      /* Set > 0 for VJ header compression. */
+#define MD5_SUPPORT      1      /* Set > 0 for MD5 (see also CHAP) */
+
+
+/*
+ * Timeouts.
+ */
+#define FSM_DEFTIMEOUT        6    /* Timeout time in seconds */
+#define FSM_DEFMAXTERMREQS    2    /* Maximum Terminate-Request transmissions */
+#define FSM_DEFMAXCONFREQS    10    /* Maximum Configure-Request transmissions */
+#define FSM_DEFMAXNAKLOOPS    5    /* Maximum number of nak loops */
+
+#define UPAP_DEFTIMEOUT        6    /* Timeout (seconds) for retransmitting req */
+#define UPAP_DEFREQTIME        30    /* Time to wait for auth-req from peer */
+
+#define CHAP_DEFTIMEOUT        6    /* Timeout time in seconds */
+#define CHAP_DEFTRANSMITS    10    /* max # times to send challenge */
+
+
+/* Interval in seconds between keepalive echo requests, 0 to disable. */
+#if 1
+#define LCP_ECHOINTERVAL 0
+#else
+
+#define LCP_ECHOINTERVAL 10
+#endif
+
+
+/* Number of unanswered echo requests before failure. */
+#define LCP_MAXECHOFAILS 3
+
+/* Max Xmit idle time (in jiffies) before resend flag char. */
+#define PPP_MAXIDLEFLAG 0//Send it every time//100
+
+/*
+ * Packet sizes
+ *
+ * Note - lcp shouldn't be allowed to negotiate stuff outside these
+ *    limits.  See lcp.h in the pppd directory.
+ * (XXX - these constants should simply be shared by lcp.c instead
+ *    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
+
+#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 */
+#define PPP_DEFMRU    296        /* Try for this */
+#define PPP_MINMRU    128        /* No MRUs below this */
+
+
+#define MAXNAMELEN      64     /* max length of hostname or name for auth */
+#define MAXSECRETLEN    64     /* max length of password or secret */
+
+#endif /* PPP_SUPPORT > 0 */
+
+//C++ Compat
+#define try vTry
+
+#endif
+
+
+#endif /* __LWIPOPTS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/lwip/lwipopts_light.h
--- a/LPC1768/lwip/lwipopts_light.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,454 +0,0 @@
-/*
- * Copyright (c) 2001-2003 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 __LWIPOPTS_H__
-#define __LWIPOPTS_H__
-
-#include "netCfg.h"
-#if NET_LWIP_STACK
-
-//#include "arch/sys_arch.h"
-
-/* <sys/time.h> is included in cc.h! */
-#define LWIP_TIMEVAL_PRIVATE 0
-
-//#define __LWIP_DEBUG
-#include "dbg/dbg.h"
-
-#ifdef __LWIP_DEBUG
-
-#define LWIP_DEBUG 1
-
-#define LWIP_DBG_MIN_LEVEL 0
-//#define LWIP_COMPAT_SOCKETS 1
-#define TAPIF_DEBUG LWIP_DBG_OFF
-#define TUNIF_DEBUG LWIP_DBG_OFF
-#define UNIXIF_DEBUG LWIP_DBG_OFF
-#define DELIF_DEBUG LWIP_DBG_OFF
-#define SIO_FIFO_DEBUG LWIP_DBG_OFF
-#define TCPDUMP_DEBUG LWIP_DBG_OFF
-
-#define PPP_DEBUG        LWIP_DBG_OFF
-#define MEM_DEBUG        LWIP_DBG_ON
-#define MEMP_DEBUG       LWIP_DBG_ON
-#define PBUF_DEBUG       LWIP_DBG_ON
-#define API_LIB_DEBUG    LWIP_DBG_OFF
-#define API_MSG_DEBUG    LWIP_DBG_OFF
-#define TCPIP_DEBUG      LWIP_DBG_OFF
-#define NETIF_DEBUG      LWIP_DBG_OFF
-#define SOCKETS_DEBUG    LWIP_DBG_OFF
-#define DEMO_DEBUG       LWIP_DBG_OFF
-#define IP_DEBUG         LWIP_DBG_OFF
-#define IP_REASS_DEBUG   LWIP_DBG_OFF
-#define RAW_DEBUG        LWIP_DBG_OFF
-#define ICMP_DEBUG       LWIP_DBG_OFF
-#define UDP_DEBUG        LWIP_DBG_OFF
-#define TCP_DEBUG        LWIP_DBG_OFF
-#define TCP_INPUT_DEBUG  LWIP_DBG_OFF
-#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
-#define TCP_RTO_DEBUG    LWIP_DBG_OFF
-#define TCP_CWND_DEBUG   LWIP_DBG_OFF
-#define TCP_WND_DEBUG    LWIP_DBG_OFF
-#define TCP_FR_DEBUG     LWIP_DBG_OFF
-#define TCP_QLEN_DEBUG   LWIP_DBG_OFF
-#define TCP_RST_DEBUG    LWIP_DBG_OFF
-#define ETHARP_DEBUG     LWIP_DBG_OFF
-#define DNS_DEBUG        LWIP_DBG_OFF
-
-#endif
-
-/*
-extern unsigned char debug_flags;
-#define LWIP_DBG_TYPES_ON debug_flags
-*/
-#define NO_SYS                     1
-#define LWIP_SOCKET                (NO_SYS==0)
-#define LWIP_NETCONN               (NO_SYS==0)
-
-
-#define IP_FRAG_USES_STATIC_BUF         0
-
-
-
-/* ---------- 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. */
-/* MSVC port: intel processors don't need 4-byte alignment,
-   but are faster that way! */
-#define MEM_ALIGNMENT           4
-
-/* 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. */
-//#define MEM_SIZE               10240 
-
-#if TARGET_LPC1768
-
-
-#define MEM_SIZE               2000
-
-///
-
-#define MEM_POSITION __attribute((section("AHBSRAM0")))
-
-/* 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. */
-#define MEMP_NUM_PBUF           8
-/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
-   per active RAW "connection". */
-//#define MEMP_NUM_RAW_PCB        3
-/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
-   per active UDP "connection". */
-#define MEMP_NUM_UDP_PCB        2
-/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB        2
-/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB_LISTEN 2//4
-/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
-   segments. */
-#define MEMP_NUM_TCP_SEG        8
-/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
-   timeouts. */
-#define MEMP_NUM_SYS_TIMEOUT    12
-
-/* 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. */
-#define MEMP_NUM_NETBUF         0
-/* MEMP_NUM_NETCONN: the number of struct netconns. */
-#define MEMP_NUM_NETCONN        0
-/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
-   for sequential API communication and incoming packets. Used in
-   src/api/tcpip.c. */
-#define MEMP_NUM_TCPIP_MSG_API   0
-#define MEMP_NUM_TCPIP_MSG_INPKT 0
-
-/* ---------- Pbuf options ---------- */
-/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
-#define PBUF_POOL_SIZE          16//100
-
-/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
-#define PBUF_POOL_BUFSIZE       128
-
-/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
-   link level header. */
-//#define PBUF_LINK_HLEN          16 
-
-/** SYS_LIGHTWEIGHT_PROT
- * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
-
-/* ---------- TCP options ---------- */
-#define LWIP_TCP                1
-#define TCP_TTL                 255
-
-/* Controls if TCP should queue segments that arrive out of
-   order. Define to 0 if your device is low on memory. */
-#define TCP_QUEUE_OOSEQ         0
-
-/* TCP Maximum segment size. */
-//#define TCP_MSS                 1024
-#define TCP_MSS                   0x276//536//0x276
-
-/* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             1024
-
-/* TCP sender buffer space (pbufs). This must be at least = 2 *
-   TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)
-
-/* 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 */
-#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
-
-/* TCP receive window. */
-#define TCP_WND        1024         //8096
-
-/* Maximum number of retransmissions of data segments. */
-//#define TCP_MAXRTX              12
-
-/* Maximum number of retransmissions of SYN segments. */
-//#define TCP_SYNMAXRTX           4
-
-#elif TARGET_LPC2368
-
-#define MEM_POSITION __attribute((section("AHBSRAM1")))
-
-/* 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. */
-#define MEMP_NUM_PBUF           8
-/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
-   per active RAW "connection". */
-//#define MEMP_NUM_RAW_PCB        3
-/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
-   per active UDP "connection". */
-#define MEMP_NUM_UDP_PCB        2
-/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB        2
-/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB_LISTEN 2//4
-/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
-   segments. */
-#define MEMP_NUM_TCP_SEG        8
-/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
-   timeouts. */
-#define MEMP_NUM_SYS_TIMEOUT    12
-
-/* 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. */
-#define MEMP_NUM_NETBUF         0
-/* MEMP_NUM_NETCONN: the number of struct netconns. */
-#define MEMP_NUM_NETCONN        0
-/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
-   for sequential API communication and incoming packets. Used in
-   src/api/tcpip.c. */
-#define MEMP_NUM_TCPIP_MSG_API   0
-#define MEMP_NUM_TCPIP_MSG_INPKT 0
-
-/* ---------- Pbuf options ---------- */
-/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
-#define PBUF_POOL_SIZE          8//16//100
-
-/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
-//#define PBUF_POOL_BUFSIZE       128
-
-/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
-   link level header. */
-//#define PBUF_LINK_HLEN          16 
-
-/** SYS_LIGHTWEIGHT_PROT
- * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
-
-/* ---------- TCP options ---------- */
-#define LWIP_TCP                1
-#define TCP_TTL                 255
-
-/* Controls if TCP should queue segments that arrive out of
-   order. Define to 0 if your device is low on memory. */
-#define TCP_QUEUE_OOSEQ         0
-
-/* TCP Maximum segment size. */
-//#define TCP_MSS                 1024
-#define TCP_MSS                   512//0x276//536//0x276
-
-/* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             1024//2048
-
-/* TCP sender buffer space (pbufs). This must be at least = 2 *
-   TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
-
-/* 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 */
-#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
-
-/* TCP receive window. */
-#define TCP_WND        512         //8096
-
-/* Maximum number of retransmissions of data segments. */
-//#define TCP_MAXRTX              12
-
-/* Maximum number of retransmissions of SYN segments. */
-//#define TCP_SYNMAXRTX           4
-
-#endif
-
-/* ---------- ARP options ---------- */
-#define LWIP_ARP                (NET_ETH | NET_ZG2100)
-#define ARP_TABLE_SIZE          2//4//10
-#define ARP_QUEUEING            0//1
-#define ETHARP_TRUST_IP_MAC     1
-
-/* ---------- 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. */
-#define IP_FORWARD              0
-
-
-/* IP reassembly and segmentation.These are orthogonal even
- * if they both deal with IP fragments */
- /*
-#define IP_REASSEMBLY     1
-#define IP_REASS_MAX_PBUFS      10
-#define MEMP_NUM_REASSDATA      10
-#define IP_FRAG           1
-*/
-/* ---------- ICMP options ---------- */
-#define ICMP_TTL                255
-
-/* ---------- DHCP options ---------- */
-/* Define LWIP_DHCP to 1 if you want DHCP configuration of
-   interfaces. */
-#define LWIP_DHCP               (NET_ETH | NET_ZG2100)
-
-/* 1 if you want to do an ARP check on the offered address
-   (recommended if using DHCP). */
-#define DHCP_DOES_ARP_CHECK     (LWIP_DHCP)
-
-/* ---------- AUTOIP options ------- */
-#define LWIP_AUTOIP             0
-
-/* ---------- SNMP options ---------- */
-/** @todo SNMP is experimental for now
-    @note UDP must be available for SNMP transport */
-#ifndef LWIP_SNMP
-#define LWIP_SNMP               0
-#endif
-
-
-#ifndef SNMP_PRIVATE_MIB
-#define SNMP_PRIVATE_MIB        0
-#endif
-
-
-/* ---------- UDP options ---------- */
-#define LWIP_UDP                1
-#define UDP_TTL                 255
-
-/* ---------- DNS options ---------- */
-#define LWIP_DNS                1
-
-/* ---------- RAW options ---------- */
-#define LWIP_RAW                0
-#define RAW_TTL                 255
-
-/* ---------- Statistics options ---------- */
-/* individual STATS options can be turned off by defining them to 0 
- * (e.g #define TCP_STATS 0). All of them are turned off if LWIP_STATS
- * is 0
- * */
-
-#define LWIP_STATS    0
-
-/* ---------- PPP options ---------- */
-
-#define PPP_SUPPORT      NET_PPP      /* Set > 0 for PPP */
-
-#if PPP_SUPPORT > 0
-
-#define NUM_PPP 1           /* Max PPP sessions. */
-
-
-/* Select modules to enable.  Ideally these would be set in the makefile but
- * we're limited by the command line length so you need to modify the settings
- * in this file.
- */
-#define PAP_SUPPORT      1      /* Set > 0 for PAP. */
-#define CHAP_SUPPORT     1      /* Set > 0 for CHAP. */
-#define MSCHAP_SUPPORT   0      /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */
-#define CBCP_SUPPORT     0      /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
-#define CCP_SUPPORT      0      /* Set > 0 for CCP (NOT FUNCTIONAL!) */
-#define VJ_SUPPORT       1      /* Set > 0 for VJ header compression. */
-#define MD5_SUPPORT      1      /* Set > 0 for MD5 (see also CHAP) */
-
-
-/*
- * Timeouts.
- */
-#define FSM_DEFTIMEOUT        6    /* Timeout time in seconds */
-#define FSM_DEFMAXTERMREQS    2    /* Maximum Terminate-Request transmissions */
-#define FSM_DEFMAXCONFREQS    10    /* Maximum Configure-Request transmissions */
-#define FSM_DEFMAXNAKLOOPS    5    /* Maximum number of nak loops */
-
-#define UPAP_DEFTIMEOUT        6    /* Timeout (seconds) for retransmitting req */
-#define UPAP_DEFREQTIME        30    /* Time to wait for auth-req from peer */
-
-#define CHAP_DEFTIMEOUT        6    /* Timeout time in seconds */
-#define CHAP_DEFTRANSMITS    10    /* max # times to send challenge */
-
-
-/* Interval in seconds between keepalive echo requests, 0 to disable. */
-#if 1
-#define LCP_ECHOINTERVAL 0
-#else
-
-#define LCP_ECHOINTERVAL 10
-#endif
-
-
-/* Number of unanswered echo requests before failure. */
-#define LCP_MAXECHOFAILS 3
-
-/* Max Xmit idle time (in jiffies) before resend flag char. */
-#define PPP_MAXIDLEFLAG 0//Send it every time//100
-
-/*
- * Packet sizes
- *
- * Note - lcp shouldn't be allowed to negotiate stuff outside these
- *    limits.  See lcp.h in the pppd directory.
- * (XXX - these constants should simply be shared by lcp.c instead
- *    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
-
-#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 */
-#define PPP_DEFMRU    296        /* Try for this */
-#define PPP_MINMRU    128        /* No MRUs below this */
-
-
-#define MAXNAMELEN      64     /* max length of hostname or name for auth */
-#define MAXSECRETLEN    64     /* max length of password or secret */
-
-#endif /* PPP_SUPPORT > 0 */
-
-//C++ Compat
-#define try vTry
-
-#endif
-
-
-#endif /* __LWIPOPTS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC1768/netCfg.h
--- a/LPC1768/netCfg.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC1768/netCfg.h	Thu Aug 05 15:09:22 2010 +0000
@@ -5,9 +5,9 @@
 #define NET_PPP 0
 #define NET_ZG2100 0
 #define TARGET_LPC1768 1
+#define NET_GPRS_MODULE 0
 #define NET_ETH 1
 #define NET_USB_SERIAL 0
-#define NET_TELIT 0
 #define NET_CFG_H 1
 #define NET_USB 0
 #define NET_LWIP_STACK 1
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/EthernetNetIf.ar
Binary file LPC2368/EthernetNetIf.ar has changed
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/api/DNSRequest.h
--- a/LPC2368/api/DNSRequest.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/api/DNSRequest.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,44 +21,83 @@
 THE SOFTWARE.
 */
 
+/** \file
+DNS Request header file
+*/
+
 #ifndef DNSREQUEST_H
 #define DNSREQUEST_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/ipaddr.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetDnsRequest
 
+///DNS Request error codes
 enum DNSRequestErr
 {
   __DNS_MIN = -0xFFFF,
-  DNS_SETUP, //NetDnsRequest not properly configured
-  DNS_IF, //If has problems, does not exist or is not initialized
-  DNS_MEM, //Not enough mem
-  DNS_INUSE, //If/Port is in use
-  DNS_PROCESSING, //Req has not completed
+  DNS_SETUP, ///<DNSRequest not properly configured
+  DNS_IF, ///<Interface has problems, does not exist or is not initialized
+  DNS_MEM, ///<Not enough mem
+  DNS_INUSE, ///<Interface / Port is in use
+  DNS_PROCESSING, ///<Request has not completed
 //...
-  DNS_OK = 0
+  DNS_OK = 0 ///<Success
 };
 
+///DNS Request Result Events
 enum DNSReply
 {
   DNS_PRTCL,
-  DNS_NOTFOUND, //Hostname is unknown
-  DNS_ERROR, //Problem with DNS Service
+  DNS_NOTFOUND, ///Hostname is unknown
+  DNS_ERROR, ///Problem with DNS Service
   //...
   DNS_FOUND,
 };
 
+class NetDnsRequest;
+enum NetDnsReply;
+
+///This is a simple DNS Request class
+/**
+  This class exposes an API to deal with DNS Requests
+*/
 class DNSRequest
 {
 public:
+  ///Creates a new request
   DNSRequest();
+  
+  ///Terminates and closes request
   ~DNSRequest();
   
+  ///Resolves an hostname
+  /**
+  @param hostname : hostname to resolve
+  */
   DNSRequestErr resolve(const char* hostname);
+  
+  ///Resolves an hostname
+  /**
+  @param host : hostname to resolve, the result will be stored in the IpAddr field of this object
+  */
   DNSRequestErr resolve(Host* pHost);
   
+  ///Setups callback
+  /**
+  The callback function will be called on result.
+  @param pMethod : callback function
+  */  
+  void setOnReply( void (*pMethod)(DNSReply) );
+  
   class CDummy;
-  void setOnReply( void (*pMethod)(DNSReply) );
+  ///Setups callback
+  /**
+  The callback function will be called on result.
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnReply( T* pItem, void (T::*pMethod)(DNSReply) )
   {
@@ -66,8 +105,13 @@
     m_pCbMeth = (void (CDummy::*)(DNSReply)) pMethod;
   }
   
+  ///Gets IP address once it has been resolved
+  /**
+  @param pIp : pointer to an IpAddr instance in which to store the resolved IP address
+  */
   DNSRequestErr getResult(IpAddr* pIp);
   
+  ///Closes DNS Request before completion
   DNSRequestErr close();
   
 protected:
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/api/TCPSocket.h
--- a/LPC2368/api/TCPSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/api/TCPSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,64 +21,106 @@
 THE SOFTWARE.
 */
 
+/** \file
+TCP Socket header file
+*/
+
 #ifndef TCPSOCKET_H
 #define TCPSOCKET_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetTcpSocket
 
+///TCP Socket error codes
 enum TCPSocketErr
 {
   __TCPSOCKET_MIN = -0xFFFF,
-  TCPSOCKET_SETUP, //NetTcpSocket not properly configured
-  TCPSOCKET_TIMEOUT,
-  TCPSOCKET_IF, //If has problems, does not exist or is not initialized
-  TCPSOCKET_MEM, //Not enough mem
-  TCPSOCKET_INUSE, //If/Port is in use
-  TCPSOCKET_EMPTY, //Connections queue is empty
-  TCPSOCKET_RST, // Connection was reset by remote host
+  TCPSOCKET_SETUP, ///<TCPSocket not properly configured
+  TCPSOCKET_TIMEOUT, ///<Connection timed out
+  TCPSOCKET_IF, ///<Interface has problems, does not exist or is not initialized
+  TCPSOCKET_MEM, ///<Not enough mem
+  TCPSOCKET_INUSE, ///<Interface / Port is in use
+  TCPSOCKET_EMPTY, ///<Connections queue is empty
+  TCPSOCKET_RST, ///<Connection was reset by remote host
 //...
-  TCPSOCKET_OK = 0
+  TCPSOCKET_OK = 0 ///<Success
 };
 
+///TCP Socket Events
 enum TCPSocketEvent
 {
-  TCPSOCKET_CONNECTED, //Connected to host, must call accept() if we were listening
-  TCPSOCKET_ACCEPT,  //Connected to client
-  TCPSOCKET_READABLE, //Data in buf
-  TCPSOCKET_WRITEABLE, //Can write data to buf
-  TCPSOCKET_CONTIMEOUT,
-  TCPSOCKET_CONRST,
-  TCPSOCKET_CONABRT,
-  TCPSOCKET_ERROR,
-  TCPSOCKET_DISCONNECTED
+  TCPSOCKET_CONNECTED, ///<Connected to host
+  TCPSOCKET_ACCEPT,  ///<Client is connected, must call accept() to get a new Socket
+  TCPSOCKET_READABLE, ///<Data in buf
+  TCPSOCKET_WRITEABLE, ///<Can write data to buf
+  TCPSOCKET_CONTIMEOUT, ///<Connection timed out
+  TCPSOCKET_CONRST, ///<Connection was reset by remote host
+  TCPSOCKET_CONABRT, ///<Connection was aborted
+  TCPSOCKET_ERROR, ///<Unknown error
+  TCPSOCKET_DISCONNECTED ///<Disconnected
 };
 
+class NetTcpSocket;
+enum NetTcpSocketEvent;
 
+///This is a simple TCP Socket class
+/**
+  This class exposes an API to deal with TCP Sockets
+*/
 class TCPSocket
 {
 public:
+  ///Creates a new socket
   TCPSocket();
 protected:
   TCPSocket(NetTcpSocket* pNetTcpSocket);
 public:
+  ///Closes if needed and destroys the socket
   ~TCPSocket(); //close()
   
+  ///Binds the socket to (local) host
   TCPSocketErr bind(const Host& me);
+  
+  ///Starts listening
   TCPSocketErr listen();
+  
+  ///Connects socket to host
   TCPSocketErr connect(const Host& host);
+  
+  ///Accepts connection from client and gets connected socket
   TCPSocketErr accept(Host* pClient, TCPSocket** ppNewTcpSocket);
   
+  ///Sends data
+  /*
+  @return a negative error code or the number of bytes transmitted
+  */
   int /*if < 0 : TCPSocketErr*/ send(const char* buf, int len);
+  
+  ///Receives data
+  /*
+  @return a negative error code or the number of bytes received
+  */
   int /*if < 0 : TCPSocketErr*/ recv(char* buf, int len);
 
   /* TODO NTH : printf / scanf helpers that call send/recv */
 
+  ///Closes socket
   TCPSocketErr close();
 
+  //Callbacks
+  ///Setups callback
+  /**
+  @param pMethod : callback function
+  */
+  void setOnEvent( void (*pMethod)(TCPSocketEvent) );
+  
   class CDummy;
-  //Callbacks
-  void setOnEvent( void (*pMethod)(TCPSocketEvent) );
+  ///Setups callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnEvent( T* pItem, void (T::*pMethod)(TCPSocketEvent) )
   {
@@ -86,7 +128,8 @@
     m_pCbMeth = (void (CDummy::*)(TCPSocketEvent)) pMethod;
   }
   
-  void resetOnEvent(); //Disable callback
+  ///Disables callback
+  void resetOnEvent(); 
   
 protected:
   void onNetTcpSocketEvent(NetTcpSocketEvent e);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/api/UDPSocket.h
--- a/LPC2368/api/UDPSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/api/UDPSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,47 +21,86 @@
 THE SOFTWARE.
 */
 
+/** \file
+UDP Socket header file
+*/
+
 #ifndef UDPSOCKET_H
 #define UDPSOCKET_H
 
-#include "if/net/net.h"
+#include "core/net.h"
+#include "core/host.h"
 //Essentially it is a safe interface to NetUdpSocket
 
+///UDP Socket error codes
 enum UDPSocketErr
 {
   __UDPSOCKET_MIN = -0xFFFF,
-  UDPSOCKET_SETUP, //NetUdpSocket not properly configured
-  UDPSOCKET_IF, //If has problems, does not exist or is not initialized
-  UDPSOCKET_MEM, //Not enough mem
-  UDPSOCKET_INUSE, //If/Port is in use
+  UDPSOCKET_SETUP, ///<UDPSocket not properly configured
+  UDPSOCKET_IF, ///<Interface has problems, does not exist or is not initialized
+  UDPSOCKET_MEM, ///<Not enough mem
+  UDPSOCKET_INUSE, ///<Interface / Port is in use
 //...
-  UDPSOCKET_OK = 0
+  UDPSOCKET_OK = 0 ///<Success
 };
 
-enum UDPSocketEvent //Only one lonely event here... but who knows, maybe some day there'll be another one!
+///UDP Socket Event(s)
+enum UDPSocketEvent //Only one event here for now, but keeps that model in case we need to implement some others
 {
-  UDPSOCKET_READABLE, //Data in buf
+  UDPSOCKET_READABLE, ///<Data in buf
 };
 
+class NetUdpSocket;
+enum NetUdpSocketEvent;
 
+///This is a simple UDP Socket class
+/**
+  This class exposes an API to deal with UDP Sockets
+*/
 class UDPSocket
 {
 public:
+  ///Creates a new socket
   UDPSocket();
+  
+  ///Closes and destroys socket
   ~UDPSocket(); //close()
   
+  ///Binds the socket to local host or a multicast address
   UDPSocketErr bind(const Host& me);
   
+  ///Sends data
+  /*
+  @param pHost : host to send data to
+  @return a negative error code or the number of bytes transmitted
+  */
   int /*if < 0 : UDPSocketErr*/ sendto(const char* buf, int len, Host* pHost);
+  
+  ///Receives data
+  /*
+  @param pHost : host from which this piece of data comes from
+  @return a negative error code or the number of bytes received
+  */
   int /*if < 0 : UDPSocketErr*/ recvfrom(char* buf, int len, Host* pHost);
 
   /* TODO NTH : printf / scanf helpers that call send/recv */
 
+  ///Closes socket
   UDPSocketErr close();
 
+  //Callbacks
+  ///Setups callback
+  /**
+  @param pMethod : callback function
+  */  
+  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  
   class CDummy;
-  //Callbacks
-  void setOnEvent( void (*pMethod)(UDPSocketEvent) );
+  ///Setups callback
+  /**
+  @param pItem : instance of class on which to execute the callback method
+  @param pMethod : callback method
+  */
   template<class T> 
   void setOnEvent( T* pItem, void (T::*pMethod)(UDPSocketEvent) )
   {
@@ -69,7 +108,8 @@
     m_pCbMeth = (void (CDummy::*)(UDPSocketEvent)) pMethod;
   }
   
-  void resetOnEvent(); //Disable callback
+  ///Disables callback
+  void resetOnEvent();
 
 protected:
   void onNetUdpSocketEvent(NetUdpSocketEvent e);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/core/host.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/host.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,109 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef HOST_H
+#define HOST_H
+
+#include "ipaddr.h"
+#include <string.h>
+
+///Host information container
+/**
+This class is a container for data relative to a connection:
+- IP Address
+- Port number
+- Host Name
+*/
+class Host 
+{
+public:
+  ///Initiliazes host with null values
+  Host() : m_ip(0,0,0,0), m_port(0), m_name(NULL)
+  {
+    
+  }
+  
+  ///Initializes host
+  Host(const IpAddr& ip, const int& port, const char* name="" ) : m_ip(ip), m_port(port), m_name(NULL)
+  {
+    setName(name); 
+  }
+  
+  ~Host()
+  {
+    if(m_name)
+    {
+      delete[] m_name;
+    }
+  }
+  
+  ///Returns IP address
+  const IpAddr& getIp() const
+  {
+    return m_ip;
+  }
+  
+  ///Returns port number
+  const int& getPort() const
+  {
+    return m_port;
+  }
+  
+  ///Returns host name
+  const char* getName() const
+  {
+    return m_name;
+  }
+  
+  ///Sets IP address
+  void setIp(const IpAddr& ip)
+  {
+    m_ip = ip;
+  }
+  
+  ///Sets port number
+  void setPort(int port)
+  {
+    m_port = port;
+  }
+  
+  ///Sets host name
+  void setName(const char* name)
+  {
+    if(m_name)
+      delete[] m_name;
+    int len = strlen(name);
+    if(len)
+    {
+      m_name = new char[len+1];
+      strcpy(m_name, name);
+    }
+  }
+  
+private:
+  IpAddr m_ip;
+  int m_port;
+  char* m_name;
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/core/ipaddr.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/ipaddr.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,98 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef IPADDR_H
+#define IPADDR_H
+
+#include "netCfg.h"
+#if NET_LWIP_STACK
+typedef struct ip_addr ip_addr_t;
+#endif
+
+#include "stdint.h"
+
+///IP Address container
+/**
+This class is a container for an IPv4 address.
+*/
+class IpAddr //Basically a C++ frontend to ip_addr_t
+{
+public:
+  #if NET_LWIP_STACK
+  IpAddr(ip_addr_t* pIp);
+  #endif
+  
+  ///Initializes IP address with provided values
+  IpAddr(uint8_t ip0, uint8_t ip1, uint8_t ip2, uint8_t ip3);
+  
+  ///Initializes IP address with null values 
+  IpAddr();
+
+  #if NET_LWIP_STACK
+  ip_addr_t getStruct() const;
+  #endif
+  
+  ///Returns IP address byte #
+  uint8_t operator[](unsigned int i) const;
+  
+  ///Compares too addresses
+  /**
+  @return true if the two addresses are equal
+  */
+  bool isEq(const IpAddr& b) const;
+  
+  ///Compares too addresses
+  /**
+  @return true if the two addresses are equal
+  */
+  bool operator==(const IpAddr& b) const;
+ 
+  ///Compares too addresses
+  /**
+  @return true if the two addresses are different
+  */ 
+  bool operator!=(const IpAddr& b) const;
+  
+  ///Checks whether the address is null
+  /**
+  @return true if the address is null
+  */
+  bool isNull() const;
+  
+  ///Checks whether the address is a broadcast address
+  /**
+  @return true if the address is a broadcast address
+  */
+  bool isBroadcast() const;
+
+  ///Checks whether the address is a multicast address
+  /**
+  @return true if the address is a multicast address
+  */
+  bool isMulticast() const;
+  
+private:
+  uint8_t m_ip[4];
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/core/net.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/net.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,101 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef NET_H
+#define NET_H
+
+class NetIf;
+class NetTcpSocket;
+class NetUdpSocket;
+class NetDnsRequest;
+
+#include <list>
+using std::list;
+
+/*
+#include "host.h"
+#include "ipaddr.h"
+#include "netservice.h"
+#include "if/net/netif.h"
+#include "if/net/nettcpsocket.h"
+#include "if/net/netudpsocket.h"
+#include "if/net/netdnsrequest.h"
+*/
+
+class Host;
+class NetIf;
+class NetTcpSocket;
+class NetUdpSocket;
+class NetDnsRequest;
+
+class Net
+{
+private:
+  Net();
+  ~Net();
+public:  
+  static void poll(); //Poll every if & socket
+  
+  static NetTcpSocket* tcpSocket(NetIf& netif);
+  static NetTcpSocket* tcpSocket(); //Socket on default if
+  static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
+  
+  static NetUdpSocket* udpSocket(NetIf& netif);
+  static NetUdpSocket* udpSocket(); //Socket on default if
+  static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
+  
+  static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
+  static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
+
+  static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
+  static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
+  
+  static void setDefaultIf(NetIf& netif); //Deprecated
+  static void setDefaultIf(NetIf* pIf);
+  static NetIf* getDefaultIf();
+  
+protected:
+  friend class NetIf;
+  friend class NetTcpSocket;
+  friend class NetUdpSocket;
+  
+  static void registerIf(NetIf* pIf);
+  static void unregisterIf(NetIf* pIf);
+  
+  static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
+  static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);  
+  
+  static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
+  static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);  
+  
+private:
+  static Net& net(); //Return inst of singleton
+
+  NetIf* m_defaultIf;
+  
+  list<NetIf*> m_lpIf;
+  list<NetTcpSocket*> m_lpNetTcpSocket;
+  list<NetUdpSocket*> m_lpNetUdpSocket;
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/core/netservice.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/netservice.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,67 @@
+
+/*
+Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/**
+\file Net Service base class header file
+*/
+
+#ifndef NETSERVICE_H
+#define NETSERVICE_H
+
+#include <list>
+using std::list;
+
+///Net Service base class
+/**
+Each connection-oriented object can register as service (by inheriting this class), so that it is polled regularly.
+It notifies the pool when the connection is terminated so that it can be destroyed.
+*/
+class NetService
+{
+public:
+  ///Instantiates a new service
+  /**
+  @param owned If true the object is owned by the pool and will be destroyed on closure.
+  */
+  NetService(bool owned = true); //Is owned by the pool?
+  virtual ~NetService();
+
+  ///This method can be inherited so that it is called on each @a Net::poll() call.
+  virtual void poll();
+ 
+  static void servicesPoll(); //Poll all registered services & destroy closed ones
+
+protected:
+  ///This flags the service as to be destructed if owned by the pool.
+  void close();
+  
+private:
+  bool m_closed;
+  bool m_removed;
+  bool m_owned;
+  
+  static list<NetService*>& lpServices(); //Helper to prevent static initialization fiasco  
+
+};
+
+#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/dbg/dbg.h
--- a/LPC2368/dbg/dbg.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/dbg/dbg.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,6 +21,10 @@
 THE SOFTWARE.
 */
 
+/** \file
+Debugging helpers header file
+*/
+
 //#ifdef DBG_H
 //#define DBG_H
 
@@ -28,6 +32,11 @@
 #define __DEBUG
 #endif
 
+/*!
+  \def __DEBUG
+  To define to enable debugging in one file
+*/
+
 #ifdef __DEBUG
 
 #ifndef __DEBUGSTREAM
@@ -47,8 +56,15 @@
 #undef DBG
 #undef DBG_END
 #undef BREAK
+
+///Debug output (if enabled), same syntax as printf, with heading info
 #define DBG(...) do{ DebugStream::debug("[%s:%s@%d] ", __FILE__, __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
+
+///Debug output (if enabled), same syntax as printf, no heading info
+#define DBGL(...) do{ DebugStream::debug(__VA_ARGS__); } while(0);
 #define DBG_END DebugStream::release
+
+///Break point usin serial debug interface (if debug enbaled)
 #define BREAK() DebugStream::breakPoint(__FILE__, __LINE__)
 #endif
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/eth/EthernetNetIf.h
--- a/LPC2368/if/eth/EthernetNetIf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/if/eth/EthernetNetIf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -21,6 +21,10 @@
 THE SOFTWARE.
 */
 
+/** \file
+Ethernet network interface header file
+*/
+
 #ifndef ETHERNETNETIF_H
 #define ETHERNETNETIF_H
 
@@ -28,23 +32,39 @@
 
 #include "mbed.h"
 
-#include "if/net/net.h"
 #include "if/lwip/LwipNetIf.h"
 
+///Ethernet network interface return codes
 enum EthernetErr
 {
   __ETH_MIN = -0xFFFF,
-  ETH_TIMEOUT, //Timeout during setup
-  ETH_OK = 0
+  ETH_TIMEOUT, ///<Timeout during setup
+  ETH_OK = 0 ///<Success
 };
 
+///Ethernet network interface
+/**
+This class provides Ethernet connectivity to the stack
+*/
 class EthernetNetIf : public LwipNetIf
 {
 public:
+  ///Instantiates the Interface and register it against the stack, DHCP will be used
   EthernetNetIf(); //W/ DHCP
+
+  ///Instantiates the Interface and register it against the stack, DHCP will not be used
+  /**
+  IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address.
+  */
   EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP
   virtual ~EthernetNetIf();
   
+  ///Brings the interface up
+  /**
+  Uses DHCP if necessary
+  @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
+  @return : ETH_OK on success or ETH_TIMEOUT on timeout
+  */
   EthernetErr setup(int timeout_ms = 15000);
 
   virtual void poll();
@@ -53,6 +73,7 @@
   Timer m_ethArpTimer;
   Timer m_dhcpCoarseTimer;
   Timer m_dhcpFineTimer;
+  Timer m_igmpTimer;
     
   bool m_useDhcp;
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/lwip/LwipNetIf.h
--- a/LPC2368/if/lwip/LwipNetIf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/if/lwip/LwipNetIf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -28,10 +28,13 @@
 #include "mbed.h"
 
 #define NET_LWIP_STACK 1
-#include "if/net/net.h"
+#include "core/net.h"
+#include "if/net/netif.h"
+/*
 #include "lwipNetTcpSocket.h"
 #include "lwipNetUdpSocket.h"
 #include "lwipNetDnsRequest.h"
+*/
 
 class LwipNetIf : public NetIf
 {
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/lwip/lwipNetTcpSocket.h
--- a/LPC2368/if/lwip/lwipNetTcpSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/if/lwip/lwipNetTcpSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -25,16 +25,18 @@
 #define LWIPNETTCPSOCKET_H
 
 #define NET_LWIP_STACK 1
-#include "lwip/ip_addr.h"
-#include "if/net/net.h"
+#include "if/net/nettcpsocket.h"
 #include "LwipNetIf.h"
 
+#include "stdint.h"
+
 //Implements NetTcpSockets over lwIP raw API
 
 struct tcp_pcb; //Represents a Tcp Connection, "Protocol Control Block", see rawapi.txt & tcp.h
 struct pbuf; //Lwip Buffer Container
 
 typedef signed char err_t;
+typedef uint16_t u16_t;
 
 class LwipNetTcpSocket: public NetTcpSocket
 {
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/lwip/lwipNetUdpSocket.h
--- a/LPC2368/if/lwip/lwipNetUdpSocket.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/if/lwip/lwipNetUdpSocket.h	Thu Aug 05 15:09:22 2010 +0000
@@ -25,10 +25,12 @@
 #define LWIPNETUDPSOCKET_H
 
 #define NET_LWIP_STACK 1
-#include "lwip/ip_addr.h"
-#include "if/net/net.h"
+//#include "lwip/ip_addr.h"
+#include "if/net/netudpsocket.h"
 #include "LwipNetIf.h"
 
+#include "stdint.h"
+
 #include <list>
 using std::list;
 
@@ -36,8 +38,10 @@
 
 struct udp_pcb; //Represents a Udp Connection, "Protocol Control Block", see rawapi.txt & udp.h
 struct pbuf; //Lwip Buffer Container
+typedef struct ip_addr ip_addr_t;
 
-typedef signed char err_t;
+//typedef signed char err_t;
+typedef uint16_t u16_t;
 
 class LwipNetUdpSocket: public NetUdpSocket
 {
@@ -70,6 +74,7 @@
   };
   
   list<InPacket> m_lInPkt;
+  IpAddr m_multicastGroup;
   
   //Static callback : Transforms into a C++ callback
   static void sRecvCb(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/net/host.h
--- a/LPC2368/if/net/host.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef HOST_H
-#define HOST_H
-
-class NetDnsRequest;
-
-#include "ipaddr.h"
-#include "netdnsrequest.h"
-#include <string.h>
-
-class Host 
-{
-public:
-  Host() : m_ip(0,0,0,0), m_port(0), m_name(NULL)
-  {
-    
-  }
-  Host(const IpAddr& ip, const int& port, const char* name="" ) : m_ip(ip), m_port(port), m_name(NULL)
-  {
-    setName(name); 
-  }
-  
-  ~Host()
-  {
-    if(m_name)
-    {
-      delete[] m_name;
-    }
-  }
-  
-  const IpAddr& getIp() const
-  {
-    return m_ip;
-  }
-  
-  const int& getPort() const
-  {
-    return m_port;
-  }
-  
-  const char* getName() const
-  {
-    return m_name;
-  }
-  
-  void setIp(const IpAddr& ip)
-  {
-    m_ip = ip;
-  }
-  
-  void setPort(int port)
-  {
-    m_port = port;
-  }
-  
-  void setName(const char* name)
-  {
-    if(m_name)
-      delete[] m_name;
-    int len = strlen(name);
-    if(len)
-    {
-      m_name = new char[len+1];
-      strcpy(m_name, name);
-    }
-  }
-  
-private:
-  friend class NetDnsRequest;
-  IpAddr m_ip;
-  int m_port;
-  char* m_name;
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/net/ipaddr.h
--- a/LPC2368/if/net/ipaddr.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef IPADDR_H
-#define IPADDR_H
-
-#include "mbed.h"
-
-#include "netCfg.h"
-#if NET_LWIP_STACK
-#include "lwip/ip_addr.h"
-#endif
-class IpAddr;
-
-class IpAddr //Basically a C++ frontend to ip_addr_t
-{
-public:
-  #if NET_LWIP_STACK
-  IpAddr(ip_addr_t* pIp)
-  {
-    *((uint32_t*)m_ip) = pIp->addr;
-  }
-  #endif
-  
-  IpAddr(uint8_t ip0, uint8_t ip1, uint8_t ip2, uint8_t ip3)
-  {
-    //We are in LE
-    m_ip[0] = ip0;
-    m_ip[1] = ip1;
-    m_ip[2] = ip2;
-    m_ip[3] = ip3;
-  }
-  
-  IpAddr()
-  {
-    m_ip[0] = 0;
-    m_ip[1] = 0;
-    m_ip[2] = 0;
-    m_ip[3] = 0;
-  }
-  
-  #if NET_LWIP_STACK
-  ip_addr_t getStruct() const
-  {
-    ip_addr_t ip_struct;
-    ip_struct.addr = *((uint32_t*)m_ip);
-    return ip_struct;
-  }
-  #endif
-  
-  uint8_t operator[](unsigned int i) const
-  {
-    uint8_t null = 0;
-    if( i > 3 )
-      return null;
-    return m_ip[i];
-  }
-  
-  bool isEq(const IpAddr& b) const
-  {
-    return (*((uint32_t*)m_ip) == *((uint32_t*)(b.m_ip)));
-  }
-  
-  bool operator==(const IpAddr& b) const
-  {
-    return isEq(b);
-  }
-  
-  bool operator!=(const IpAddr& b) const
-  {
-    return !(operator==(b));
-  }
-  
-  bool isNull() const
-  {
-    return (*((uint32_t*)m_ip) == 0);
-  }
-  
-private:
-  uint8_t m_ip[4];
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/net/net.h
--- a/LPC2368/if/net/net.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef NET_H
-#define NET_H
-
-class NetIf;
-class NetTcpSocket;
-class NetUdpSocket;
-class NetDnsRequest;
-
-#include <list>
-using std::list;
-
-#include "host.h"
-#include "ipaddr.h"
-#include "netif.h"
-#include "nettcpsocket.h"
-#include "netudpsocket.h"
-#include "netservice.h"
-#include "netdnsrequest.h"
-
-class Net
-{
-private:
-  Net();
-  ~Net();
-public:  
-  static void poll(); //Poll every if & socket
-  
-  static NetTcpSocket* tcpSocket(NetIf& netif);
-  static NetTcpSocket* tcpSocket(); //Socket on default if
-  static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
-  
-  static NetUdpSocket* udpSocket(NetIf& netif);
-  static NetUdpSocket* udpSocket(); //Socket on default if
-  static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
-  
-  static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
-  static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
-
-  static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
-  static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
-  
-  static void setDefaultIf(NetIf& netif); //Deprecated
-  static void setDefaultIf(NetIf* pIf);
-  static NetIf* getDefaultIf();
-  
-  //TODO: Factory functions like 'setupEthernet', 'setupPPP', 'setupTelit' ...
-  #if 0
-  enum NetErr //Generic errors
-  {
-    __NET_MIN = -0xFFFF;
-    NET_OPEN, //Could not open if
-    NET_CONNECT, //Could not connect
-    NET_AUTH, //Could not auth
-    NET_HW, //HW problem
-        
-    NET_OK = 0
-  };
-  
-  static NetErr Ethernet();
-  static NetErr PPPoverSerial(int Tx, int Rx, const char* apn, const char* user, const char* password);
-  static NetErr Telit(int pwrSetPin, int pwrMonPin, int Tx, int Rx);
-  #endif
-  
-protected:
-  friend class NetIf;
-  friend class NetTcpSocket;
-  friend class NetUdpSocket;
-  
-  static void registerIf(NetIf* pIf);
-  static void unregisterIf(NetIf* pIf);
-  
-  static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
-  static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);  
-  
-  static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
-  static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);  
-  
-private:
-  static Net& net(); //Return inst of singleton
-
-  NetIf* m_defaultIf;
-  
-  list<NetIf*> m_lpIf;
-  list<NetTcpSocket*> m_lpNetTcpSocket;
-  list<NetUdpSocket*> m_lpNetUdpSocket;
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/net/netif.h
--- a/LPC2368/if/net/netif.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/if/net/netif.h	Thu Aug 05 15:09:22 2010 +0000
@@ -24,10 +24,15 @@
 #ifndef NETIF_H
 #define NETIF_H
 
-#include "ipaddr.h"
+#include "core/ipaddr.h"
+/*
 #include "nettcpsocket.h"
 #include "netudpsocket.h"
 #include "netdnsrequest.h"
+*/
+class NetTcpSocket;
+class NetUdpSocket;
+class NetDnsRequest;
 
 #if 0
 enum NetifEvent
@@ -48,6 +53,8 @@
   virtual void poll() = 0;
   virtual NetDnsRequest* dnsRequest(const char* hostname) = 0; //Create a new NetDnsRequest object
   virtual NetDnsRequest* dnsRequest(Host* pHost) = 0; //Create a new NetDnsRequest object
+  
+  //!Returns the IP of the interface once it's connected
   IpAddr getIp() const;
   
 protected:
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/if/net/netservice.h
--- a/LPC2368/if/net/netservice.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-
-/*
-Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
- 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
- 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef NETSERVICE_H
-#define NETSERVICE_H
-
-//class NetDnsRequest;
-//#include "net.h"
-
-//Each connection-oriented object can register as service (by inheriting this class), so that it is polled regularly
-//It notifies the pool when the connection is terminated so that it can be destroyed
-
-#include <list>
-using std::list;
-
-class NetService
-{
-public:
-  NetService(bool owned = true); //Is owned by the pool?
-  virtual ~NetService();
-
-  virtual void poll();
- 
-  static void servicesPoll(); //Poll all registered services & destroy closed ones
-
-protected:
-  void close();
-  
-private:
-  bool m_closed;
-  bool m_removed;
-  bool m_owned;
-  
-  static list<NetService*>& lpServices(); //Helper to prevent static initialization fiasco  
-
-};
-
-#endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/arch/cc.h
--- a/LPC2368/lwip/arch/cc.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/arch/cc.h	Thu Aug 05 15:09:22 2010 +0000
@@ -29,9 +29,8 @@
 #define FALSE 0
 #endif
 
-#ifndef DBG
-//#error
-#endif
+#include <stdlib.h>
+#define LWIP_RAND rand
 
 #define LWIP_PLATFORM_DIAG(x) DBG x
 #define LWIP_PLATFORM_ASSERT(x) DBG(x)
@@ -57,5 +56,7 @@
 #define PACK_STRUCT_BEGIN __packed
 #define PACK_STRUCT_END
 
+#define LWIP_CHKSUM_ALGORITHM 3
+
 
 #endif /* __LWIP_ARCH_CC_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/ipv4/lwip/autoip.h
--- a/LPC2368/lwip/include/ipv4/lwip/autoip.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/autoip.h	Thu Aug 05 15:09:22 2010 +0000
@@ -80,7 +80,7 @@
 
 struct autoip
 {
-  ip_addr_t llipaddr;  /* the currently selected, probed, announced or used LL IP-Address */
+  ip_addr_t 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 */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/ipv4/lwip/icmp.h
--- a/LPC2368/lwip/include/ipv4/lwip/icmp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/icmp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -70,7 +70,7 @@
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
 #endif
-/** This is the standard ICMP header only that the u32_t data
+/*  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.
@@ -91,7 +91,7 @@
 #define ICMPH_TYPE(hdr) ((hdr)->type)
 #define ICMPH_CODE(hdr) ((hdr)->code)
 
-/** Combines type and code to an u16_t */
+/*  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))
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/ipv4/lwip/inet.h
--- a/LPC2368/lwip/include/ipv4/lwip/inet.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/inet.h	Thu Aug 05 15:09:22 2010 +0000
@@ -40,7 +40,7 @@
 extern "C" {
 #endif
 
-/** For compatibility with BSD code */
+/*  For compatibility with BSD code */
 struct in_addr {
   u32_t s_addr;
 };
@@ -91,6 +91,8 @@
 
 #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
 #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr)   (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
+/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */
+#define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr)   ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr))
 
 /* directly map this to the lwip internal functions */
 #define inet_addr(cp)         ipaddr_addr(cp)
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/ipv4/lwip/ip.h
--- a/LPC2368/lwip/include/ipv4/lwip/ip.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/ip.h	Thu Aug 05 15:09:22 2010 +0000
@@ -78,7 +78,7 @@
   ip_addr_t local_ip; \
   ip_addr_t remote_ip; \
    /* Socket options */  \
-  u16_t so_options;      \
+  u8_t so_options;      \
    /* Type Of Service */ \
   u8_t tos;              \
   /* Time To Live */     \
@@ -94,16 +94,19 @@
 /*
  * 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 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 */
+/*#define SOF_DEBUG       (u8_t)0x01U     Unimplemented: turn on debugging info recording */
+#define SOF_ACCEPTCONN    (u8_t)0x02U  /* socket has had listen() */
+#define SOF_REUSEADDR     (u8_t)0x04U  /* allow local address reuse */
+#define SOF_KEEPALIVE     (u8_t)0x08U  /* keep connections alive */
+/*#define SOF_DONTROUTE   (u8_t)0x10U     Unimplemented: just use interface addresses */
+#define SOF_BROADCAST     (u8_t)0x20U  /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
+/*#define SOF_USELOOPBACK (u8_t)0x40U     Unimplemented: bypass hardware when possible */
+#define SOF_LINGER        (u8_t)0x80U  /* linger on close if data present */
+/*#define SOF_OOBINLINE   (u16_t)0x0100U     Unimplemented: leave received OOB data in line */
+/*#define SOF_REUSEPORT   (u16_t)0x0200U     Unimplemented: allow local address & port reuse */
+
+/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */
+#define SOF_INHERITED   (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/)
 
 
 #ifdef PACK_STRUCT_USE_INCLUDES
@@ -130,8 +133,8 @@
   /* checksum */
   PACK_STRUCT_FIELD(u16_t _chksum);
   /* source and destination IP addresses */
-  PACK_STRUCT_FIELD(ip_addr_t src);
-  PACK_STRUCT_FIELD(ip_addr_t dest); 
+  PACK_STRUCT_FIELD(ip_addr_p_t src);
+  PACK_STRUCT_FIELD(ip_addr_p_t dest); 
 } PACK_STRUCT_STRUCT;
 PACK_STRUCT_END
 #ifdef PACK_STRUCT_USE_INCLUDES
@@ -160,6 +163,10 @@
 extern struct netif *current_netif;
 /** Header of the input packet currently being processed. */
 extern const struct ip_hdr *current_header;
+/** Source IP address of current_header */
+extern ip_addr_t current_iphdr_src;
+/** Destination IP address of current_header */
+extern ip_addr_t current_iphdr_dest;
 
 #define ip_init() /* Compatibility define, not init needed. */
 struct netif *ip_route(ip_addr_t *dest);
@@ -186,6 +193,11 @@
  * 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)
+/** Source IP address of current_header */
+#define ip_current_src_addr()  (&current_iphdr_src)
+/** Destination IP address of current_header */
+#define ip_current_dest_addr() (&current_iphdr_dest)
+
 #if IP_DEBUG
 void ip_debug_print(struct pbuf *p);
 #else
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/ipv4/lwip/ip_addr.h
--- a/LPC2368/lwip/include/ipv4/lwip/ip_addr.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/ip_addr.h	Thu Aug 05 15:09:22 2010 +0000
@@ -39,11 +39,19 @@
 extern "C" {
 #endif
 
+/* This is the aligned version of ip_addr_t,
+   used as local variable, on the stack, etc. */
+struct ip_addr {
+  u32_t addr;
+};
+
+/* This is the packed version of ip_addr_t,
+   used in network headers that are itself packed */
 #ifdef PACK_STRUCT_USE_INCLUDES
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-struct _ip_addr {
+struct ip_addr_packed {
   PACK_STRUCT_FIELD(u32_t addr);
 } PACK_STRUCT_STRUCT;
 PACK_STRUCT_END
@@ -51,7 +59,10 @@
 #  include "arch/epstruct.h"
 #endif
 
-typedef struct _ip_addr ip_addr_t;
+/** ip_addr_t uses a struct for convenience only, so that the same defines can
+ * operate both on ip_addr_t as well as on ip_addr_p_t. */
+typedef struct ip_addr ip_addr_t;
+typedef struct ip_addr_packed ip_addr_p_t;
 
 /*
  * struct ipaddr2 is used in the definition of the ARP packet format in
@@ -140,6 +151,13 @@
                           (u32_t)((a) & 0xff)
 #endif
 
+/** MEMCPY-like copying of IP addresses where addresses are known to be
+ * 16-bit-aligned if the port is correctly configured (so a port could define
+ * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */
+#ifndef IPADDR2_COPY
+#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t))
+#endif
+
 /** Copy IP address - faster than ip_addr_set: no NULL check */
 #define ip_addr_copy(dest, src) ((dest).addr = (src).addr)
 /** Safely copy one IP address to another (src may be NULL) */
@@ -151,7 +169,7 @@
 /** Set address to IPADDR_ANY (no need for htonl()) */
 #define ip_addr_set_any(ipaddr)       ((ipaddr)->addr = IPADDR_ANY)
 /** Set address to loopback address */
-#define ip_addr_set_loopback(ipaddr)  ((ipaddr)->addr = htonl(IPADDR_LOOPBACK))
+#define ip_addr_set_loopback(ipaddr)  ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK))
 /** Safely copy one IP address to another and change byte order
  * from host- to network-order. */
 #define ip_addr_set_hton(dest, src) ((dest)->addr = \
@@ -181,11 +199,15 @@
 
 #define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY)
 
-u8_t ip_addr_isbroadcast(ip_addr_t *, struct netif *);
+#define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif))
+u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif);
 
-#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL))
+#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr)
+u8_t ip4_addr_netmask_valid(u32_t netmask);
 
-#define ip_addr_islinklocal(addr1) (((addr1)->addr & ntohl(0xffff0000UL)) == ntohl(0xa9fe0000UL))
+#define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL))
+
+#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
 
 #define ip_addr_debug_print(debug, ipaddr) \
   LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F,             \
@@ -212,8 +234,8 @@
 u32_t ipaddr_addr(const char *cp);
 int ipaddr_aton(const char *cp, ip_addr_t *addr);
 /** returns ptr to static buffer; not reentrant! */
-char *ipaddr_ntoa(ip_addr_t *addr);
-char *ipaddr_ntoa_r(ip_addr_t *addr, char *buf, int buflen);
+char *ipaddr_ntoa(const ip_addr_t *addr);
+char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen);
 
 #ifdef __cplusplus
 }
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/ipv4/lwip/ip_frag.h
--- a/LPC2368/lwip/include/ipv4/lwip/ip_frag.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/ip_frag.h	Thu Aug 05 15:09:22 2010 +0000
@@ -66,6 +66,18 @@
 #endif /* IP_REASSEMBLY */
 
 #if IP_FRAG
+#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
+/** A custom pbuf that holds a reference to another pbuf, which is freed
+ * when this custom pbuf is freed. This is used to create a custom PBUF_REF
+ * that points into the original pbuf. */
+struct pbuf_custom_ref {
+  /** 'base class' */
+  struct pbuf_custom pc;
+  /** pointer to the original pbuf that is referenced */
+  struct pbuf *original;
+};
+#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
+
 err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest);
 #endif /* IP_FRAG */
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/api.h
--- a/LPC2368/lwip/include/lwip/api.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/api.h	Thu Aug 05 15:09:22 2010 +0000
@@ -150,9 +150,11 @@
   /** mbox where received packets are stored until they are fetched
       by the netconn application thread (can grow quite big) */
   sys_mbox_t recvmbox;
+#if LWIP_TCP
   /** mbox where new connections are stored until processed
       by the application thread */
   sys_mbox_t acceptmbox;
+#endif /* LWIP_TCP */
   /** only used for socket layer */
 #if LWIP_SOCKET
   int socket;
@@ -232,6 +234,7 @@
 err_t   netconn_write(struct netconn *conn, const void *dataptr, size_t size,
                       u8_t apiflags);
 err_t   netconn_close(struct netconn *conn);
+err_t   netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
 
 #if LWIP_IGMP
 err_t   netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr,
@@ -261,9 +264,9 @@
 #define netconn_get_noautorecved(conn)        (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)
 
 #if LWIP_SO_RCVTIMEO
-/** Set the receive timeout in miliseconds */
+/** Set the receive timeout in milliseconds */
 #define netconn_set_recvtimeout(conn, timeout)      ((conn)->recv_timeout = (timeout))
-/** Get the receive timeout in miliseconds */
+/** Get the receive timeout in milliseconds */
 #define netconn_get_recvtimeout(conn)               ((conn)->recv_timeout)
 #endif /* LWIP_SO_RCVTIMEO */
 #if LWIP_SO_RCVBUF
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/api_msg.h
--- a/LPC2368/lwip/include/lwip/api_msg.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/api_msg.h	Thu Aug 05 15:09:22 2010 +0000
@@ -48,6 +48,10 @@
 extern "C" {
 #endif
 
+#define NETCONN_SHUT_RD   1
+#define NETCONN_SHUT_WR   2
+#define NETCONN_SHUT_RDWR 3
+
 /* IP addresses and port numbers are expected to be in
  * the same byte order as in the corresponding pcb.
  */
@@ -89,6 +93,10 @@
     struct {
       u32_t len;
     } r;
+    /** used for do_close (/shutdown) */
+    struct {
+      u8_t shut;
+    } sd;
 #if LWIP_IGMP
     /** used for do_join_leave_group */
     struct {
@@ -144,6 +152,7 @@
 void do_write           ( struct api_msg_msg *msg);
 void do_getaddr         ( struct api_msg_msg *msg);
 void do_close           ( struct api_msg_msg *msg);
+void do_shutdown        ( struct api_msg_msg *msg);
 #if LWIP_IGMP
 void do_join_leave_group( struct api_msg_msg *msg);
 #endif /* LWIP_IGMP */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/def.h
--- a/LPC2368/lwip/include/lwip/def.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/def.h	Thu Aug 05 15:09:22 2010 +0000
@@ -39,6 +39,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 #define LWIP_MAX(x , y)  (((x) > (y)) ? (x) : (y))
 #define LWIP_MIN(x , y)  (((x) < (y)) ? (x) : (y))
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/dhcp.h
--- a/LPC2368/lwip/include/lwip/dhcp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/dhcp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -80,10 +80,10 @@
   PACK_STRUCT_FIELD(u32_t xid);
   PACK_STRUCT_FIELD(u16_t secs);
   PACK_STRUCT_FIELD(u16_t flags);
-  PACK_STRUCT_FIELD(ip_addr_t ciaddr);
-  PACK_STRUCT_FIELD(ip_addr_t yiaddr);
-  PACK_STRUCT_FIELD(ip_addr_t siaddr);
-  PACK_STRUCT_FIELD(ip_addr_t giaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t ciaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t yiaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t siaddr);
+  PACK_STRUCT_FIELD(ip_addr_p_t giaddr);
   PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
   PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
   PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/dns.h
--- a/LPC2368/lwip/include/lwip/dns.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/dns.h	Thu Aug 05 15:09:22 2010 +0000
@@ -1,116 +1,116 @@
-/**
- * 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 */
-
-/* The size used for the next line is rather a hack, but it prevents including socket.h in all files
-   that include memp.h, and that would possibly break portability (since socket.h defines some types
-   and constants possibly already define by the OS).
-   Calculation rule:
-   sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
-#define NETDB_ELEM_SIZE           (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
-
-#if DNS_LOCAL_HOSTLIST
-/** struct used for local host-list */
-struct local_hostlist_entry {
-  /** static hostname */
-  const char *name;
-  /** static host address in network byteorder */
-  ip_addr_t addr;
-  struct local_hostlist_entry *next;
-};
-#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
-#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
-#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN  DNS_MAX_NAME_LENGTH
-#endif
-#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
-#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
-#endif /* DNS_LOCAL_HOSTLIST */
-
-/** 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 an ip_addr_t 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, ip_addr_t *ipaddr, void *callback_arg);
-
-void           dns_init(void);
-void           dns_tmr(void);
-void           dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
-ip_addr_t      dns_getserver(u8_t numdns);
-err_t          dns_gethostbyname(const char *hostname, ip_addr_t *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 ip_addr_t *addr);
-err_t          dns_local_addhost(const char *hostname, const ip_addr_t *addr);
-#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
-
-#endif /* LWIP_DNS */
-
-#endif /* __LWIP_DNS_H__ */
+/**
+ * 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 */
+
+/* The size used for the next line is rather a hack, but it prevents including socket.h in all files
+   that include memp.h, and that would possibly break portability (since socket.h defines some types
+   and constants possibly already define by the OS).
+   Calculation rule:
+   sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
+#define NETDB_ELEM_SIZE           (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
+
+#if DNS_LOCAL_HOSTLIST
+/** struct used for local host-list */
+struct local_hostlist_entry {
+  /** static hostname */
+  const char *name;
+  /** static host address in network byteorder */
+  ip_addr_t addr;
+  struct local_hostlist_entry *next;
+};
+#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
+#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
+#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN  DNS_MAX_NAME_LENGTH
+#endif
+#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
+#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+#endif /* DNS_LOCAL_HOSTLIST */
+
+/** 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 an ip_addr_t 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, ip_addr_t *ipaddr, void *callback_arg);
+
+void           dns_init(void);
+void           dns_tmr(void);
+void           dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
+ip_addr_t      dns_getserver(u8_t numdns);
+err_t          dns_gethostbyname(const char *hostname, ip_addr_t *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 ip_addr_t *addr);
+err_t          dns_local_addhost(const char *hostname, const ip_addr_t *addr);
+#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+
+#endif /* LWIP_DNS */
+
+#endif /* __LWIP_DNS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/err.h
--- a/LPC2368/lwip/include/lwip/err.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/err.h	Thu Aug 05 15:09:22 2010 +0000
@@ -56,7 +56,7 @@
 #define ERR_RTE        -4    /* Routing problem.         */
 #define ERR_INPROGRESS -5    /* Operation in progress    */
 #define ERR_VAL        -6    /* Illegal value.           */
-#define ERR_WOULBLOCK  -7    /* Operation would block.   */
+#define ERR_WOULDBLOCK -7    /* Operation would block.   */
 
 #define ERR_IS_FATAL(e) ((e) < ERR_VAL)
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/init.h
--- a/LPC2368/lwip/include/lwip/init.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/init.h	Thu Aug 05 15:09:22 2010 +0000
@@ -47,7 +47,7 @@
 /** 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         0U
+#define LWIP_VERSION_RC         1U
 
 /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
 #define LWIP_RC_RELEASE         255U
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/mem.h
--- a/LPC2368/lwip/include/lwip/mem.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/mem.h	Thu Aug 05 15:09:22 2010 +0000
@@ -70,8 +70,10 @@
  */
 #if MEM_SIZE > 64000l
 typedef u32_t mem_size_t;
+#define MEM_SIZE_F U32_F
 #else
 typedef u16_t mem_size_t;
+#define MEM_SIZE_F U16_F
 #endif /* MEM_SIZE > 64000 */
 
 #if MEM_USE_POOLS
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/memp_std.h
--- a/LPC2368/lwip/include/lwip/memp_std.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/memp_std.h	Thu Aug 05 15:09:22 2010 +0000
@@ -47,6 +47,9 @@
 #if IP_REASSEMBLY
 LWIP_MEMPOOL(REASSDATA,      MEMP_NUM_REASSDATA,       sizeof(struct ip_reassdata),   "REASSDATA")
 #endif /* IP_REASSEMBLY */
+#if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
+LWIP_MEMPOOL(FRAG_PBUF,      MEMP_NUM_FRAG_PBUF,       sizeof(struct pbuf_custom_ref),"FRAG_PBUF")
+#endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
 
 #if LWIP_NETCONN
 LWIP_MEMPOOL(NETBUF,         MEMP_NUM_NETBUF,          sizeof(struct netbuf),         "NETBUF")
@@ -55,7 +58,9 @@
 
 #if NO_SYS==0
 LWIP_MEMPOOL(TCPIP_MSG_API,  MEMP_NUM_TCPIP_MSG_API,   sizeof(struct tcpip_msg),      "TCPIP_MSG_API")
+#if !LWIP_TCPIP_CORE_LOCKING_INPUT
 LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg),      "TCPIP_MSG_INPKT")
+#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
 #endif /* NO_SYS==0 */
 
 #if ARP_QUEUEING
@@ -66,7 +71,9 @@
 LWIP_MEMPOOL(IGMP_GROUP,     MEMP_NUM_IGMP_GROUP,      sizeof(struct igmp_group),     "IGMP_GROUP")
 #endif /* LWIP_IGMP */
 
+#if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */
 LWIP_MEMPOOL(SYS_TIMEOUT,    MEMP_NUM_SYS_TIMEOUT,     sizeof(struct sys_timeo),      "SYS_TIMEOUT")
+#endif /* LWIP_TIMERS */
 
 #if LWIP_SNMP
 LWIP_MEMPOOL(SNMP_ROOTNODE,  MEMP_NUM_SNMP_ROOTNODE,   sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE")
@@ -77,6 +84,12 @@
 #if LWIP_DNS && LWIP_SOCKET
 LWIP_MEMPOOL(NETDB,          MEMP_NUM_NETDB,           NETDB_ELEM_SIZE,               "NETDB")
 #endif /* LWIP_DNS && LWIP_SOCKET */
+#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
+LWIP_MEMPOOL(LOCALHOSTLIST,  MEMP_NUM_LOCALHOSTLIST,   LOCALHOSTLIST_ELEM_SIZE,       "LOCALHOSTLIST")
+#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
+#if PPP_SUPPORT && PPPOE_SUPPORT
+LWIP_MEMPOOL(PPPOE_IF,      MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc),    "PPPOE_IF")
+#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
 
 /*
  * A list of pools of pbuf's used by LWIP.
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/netbuf.h
--- a/LPC2368/lwip/include/lwip/netbuf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/netbuf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -40,14 +40,24 @@
 extern "C" {
 #endif
 
+/** This netbuf has dest-addr/port set */
+#define NETBUF_FLAG_DESTADDR    0x01
+/** This netbuf includes a checksum */
+#define NETBUF_FLAG_CHKSUM      0x02
+
 struct netbuf {
   struct pbuf *p, *ptr;
-  ip_addr_t *addr;
+  ip_addr_t addr;
   u16_t port;
+#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
+#if LWIP_CHECKSUM_ON_COPY
+  u8_t flags;
+#endif /* LWIP_CHECKSUM_ON_COPY */
+  u16_t toport_chksum;
 #if LWIP_NETBUF_RECVINFO
-  ip_addr_t *toaddr;
-  u16_t toport;
+  ip_addr_t toaddr;
 #endif /* LWIP_NETBUF_RECVINFO */
+#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
 };
 
 /* Network buffer functions: */
@@ -56,12 +66,12 @@
 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);
+                                   const void *dataptr, u16_t size);
 void              netbuf_chain    (struct netbuf *head,
            struct netbuf *tail);
 
 err_t             netbuf_data     (struct netbuf *buf,
-           void **dataptr, u16_t *len);
+                                   void **dataptr, u16_t *len);
 s8_t              netbuf_next     (struct netbuf *buf);
 void              netbuf_first    (struct netbuf *buf);
 
@@ -71,12 +81,18 @@
 #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_fromaddr(buf)         (&((buf)->addr))
+#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr)
 #define netbuf_fromport(buf)         ((buf)->port)
 #if LWIP_NETBUF_RECVINFO
-#define netbuf_destaddr(buf)         ((buf)->toaddr)
-#define netbuf_destport(buf)         ((buf)->toport)
+#define netbuf_destaddr(buf)         (&((buf)->toaddr))
+#define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr)
+#define netbuf_destport(buf)         (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
 #endif /* LWIP_NETBUF_RECVINFO */
+#if LWIP_CHECKSUM_ON_COPY
+#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
+                                            (buf)->toport_chksum = chksum; } while(0)
+#endif /* LWIP_CHECKSUM_ON_COPY */
 
 #ifdef __cplusplus
 }
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/netif.h
--- a/LPC2368/lwip/include/lwip/netif.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/netif.h	Thu Aug 05 15:09:22 2010 +0000
@@ -56,58 +56,58 @@
 /* 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
+/*  must be the maximum of all used hardware address lengths
     across all types of interfaces in use */
 #define NETIF_MAX_HWADDR_LEN 6U
 
-/** Whether the network interface is 'up'. This is
+/*  Whether the network interface is 'up'. This is
  * a software flag used to control whether this network
  * interface is enabled and processes traffic.
  * It is set by the startup code (for static IP configuration) or
  * by dhcp/autoip when an address has been assigned.
  */
 #define NETIF_FLAG_UP           0x01U
-/** If set, the netif has broadcast capability.
+/*  If set, the netif has broadcast capability.
  * Set by the netif driver in its init function. */
 #define NETIF_FLAG_BROADCAST    0x02U
-/** If set, the netif is one end of a point-to-point connection.
+/*  If set, the netif is one end of a point-to-point connection.
  * Set by the netif driver in its init function. */
 #define NETIF_FLAG_POINTTOPOINT 0x04U
-/** If set, the interface is configured using DHCP.
+/*  If set, the interface is configured using DHCP.
  * Set by the DHCP code when starting or stopping DHCP. */
 #define NETIF_FLAG_DHCP         0x08U
-/** If set, the interface has an active link
+/*  If set, the interface has an active link
  *  (set by the network interface driver).
  * Either set by the netif driver in its init function (if the link
  * is up at that time) or at a later point once the link comes up
  * (if link detection is supported by the hardware). */
 #define NETIF_FLAG_LINK_UP      0x10U
-/** If set, the netif is an ethernet device using ARP.
+/*  If set, the netif is an ethernet device using ARP.
  * Set by the netif driver in its init function.
  * Used to check input packet types and use of DHCP. */
 #define NETIF_FLAG_ETHARP       0x20U
-/** If set, the netif is an ethernet device. It might not use
+/*  If set, the netif is an ethernet device. It might not use
  * ARP or TCP/IP if it is used for PPPoE only.
  */
 #define NETIF_FLAG_ETHERNET     0x40U
-/** If set, the netif has IGMP capability.
+/*  If set, the netif has IGMP capability.
  * Set by the netif driver in its init function. */
 #define NETIF_FLAG_IGMP         0x80U
 
-/** Function prototype for netif init functions. Set up flags and output/linkoutput
+/*  Function prototype for netif init functions. Set up flags and output/linkoutput
  * callback functions in this function.
  *
  * @param netif The netif to initialize
  */
 typedef err_t (*netif_init_fn)(struct netif *netif);
-/** Function prototype for netif->input functions. This function is saved as 'input'
+/*  Function prototype for netif->input functions. This function is saved as 'input'
  * callback function in the netif struct. Call it when a packet has been received.
  *
  * @param p The received packet, copied into a pbuf
  * @param inp The netif which received the packet
  */
 typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp);
-/** Function prototype for netif->output functions. Called by lwIP when a packet
+/*  Function prototype for netif->output functions. Called by lwIP when a packet
  * shall be sent. For ethernet netif, set this to 'etharp_output' and set
  * 'linkoutput'.
  *
@@ -117,87 +117,87 @@
  */
 typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p,
        ip_addr_t *ipaddr);
-/** Function prototype for netif->linkoutput functions. Only used for ethernet
+/*  Function prototype for netif->linkoutput functions. Only used for ethernet
  * netifs. This function is called by ARP when a packet shall be sent.
  *
  * @param netif The netif which shall send a packet
  * @param p The packet to send (raw ethernet packet)
  */
 typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p);
-/** Function prototype for netif status- or link-callback functions. */
+/*  Function prototype for netif status- or link-callback functions. */
 typedef void (*netif_status_callback_fn)(struct netif *netif);
-/** Function prototype for netif igmp_mac_filter functions */
+/*  Function prototype for netif igmp_mac_filter functions */
 typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
        ip_addr_t *group, u8_t action);
 
-/** Generic data structure used for all lwIP network interfaces.
+/*  Generic data structure used for all lwIP network interfaces.
  *  The following fields should be filled in by the initialization
  *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
 struct netif {
-  /** pointer to next in linked list */
+  /*  pointer to next in linked list */
   struct netif *next;
 
-  /** IP address configuration in network byte order */
+  /*  IP address configuration in network byte order */
   ip_addr_t ip_addr;
   ip_addr_t netmask;
   ip_addr_t gw;
 
-  /** This function is called by the network device driver
+  /*  This function is called by the network device driver
    *  to pass a packet up the TCP/IP stack. */
   netif_input_fn input;
-  /** This function is called by the IP module when it wants
+  /*  This function is called by the IP module when it wants
    *  to send a packet on the interface. This function typically
    *  first resolves the hardware address, then sends the packet. */
   netif_output_fn output;
-  /** This function is called by the ARP module when it wants
+  /*  This function is called by the ARP module when it wants
    *  to send a packet on the interface. This function outputs
    *  the pbuf as-is on the link medium. */
   netif_linkoutput_fn linkoutput;
 #if LWIP_NETIF_STATUS_CALLBACK
-  /** This function is called when the netif state is set to up or down
+  /*  This function is called when the netif state is set to up or down
    */
   netif_status_callback_fn status_callback;
 #endif /* LWIP_NETIF_STATUS_CALLBACK */
 #if LWIP_NETIF_LINK_CALLBACK
-  /** This function is called when the netif link is set to up or down
+  /*  This function is called when the netif link is set to up or down
    */
   netif_status_callback_fn link_callback;
 #endif /* LWIP_NETIF_LINK_CALLBACK */
-  /** This field can be set by the device driver and could point
+  /*  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 */
+  /*  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 */
+  /*  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) */
+  /*  maximum transfer unit (in bytes) */
   u16_t mtu;
-  /** number of bytes used in hwaddr */
+  /*  number of bytes used in hwaddr */
   u8_t hwaddr_len;
-  /** link level hardware address of this interface */
+  /*  link level hardware address of this interface */
   u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
-  /** flags (see NETIF_FLAG_ above) */
+  /*  flags (see NETIF_FLAG_ above) */
   u8_t flags;
-  /** descriptive abbreviation */
+  /*  descriptive abbreviation */
   char name[2];
-  /** number of this interface */
+  /*  number of this interface */
   u8_t num;
 #if LWIP_SNMP
-  /** link type (from "snmp_ifType" enum from snmp.h) */
+  /*  link type (from "snmp_ifType" enum from snmp.h) */
   u8_t link_type;
-  /** (estimate) link speed */
+  /*  (estimate) link speed */
   u32_t link_speed;
-  /** timestamp at last change made (up/down) */
+  /*  timestamp at last change made (up/down) */
   u32_t ts;
-  /** counters */
+  /*  counters */
   u32_t ifinoctets;
   u32_t ifinucastpkts;
   u32_t ifinnucastpkts;
@@ -208,7 +208,7 @@
   u32_t ifoutdiscards;
 #endif /* LWIP_SNMP */
 #if LWIP_IGMP
-  /** This function could be called to add or delete a entry in the multicast
+  /*  This function could be called to add or delete a entry in the multicast
       filter table of the ethernet MAC.*/
   netif_igmp_mac_filter_fn igmp_mac_filter;
 #endif /* LWIP_IGMP */
@@ -245,9 +245,9 @@
 #endif /* LWIP_SNMP */
 
 
-/** The list of network interfaces. */
+/*  The list of network interfaces. */
 extern struct netif *netif_list;
-/** The default network interface. */
+/*  The default network interface. */
 extern struct netif *netif_default;
 
 void netif_init(void);
@@ -274,7 +274,7 @@
 
 void netif_set_up(struct netif *netif);
 void netif_set_down(struct netif *netif);
-/** Ask if an interface is up */
+/*  Ask if an interface is up */
 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
 
 #if LWIP_NETIF_STATUS_CALLBACK
@@ -283,7 +283,7 @@
 
 void netif_set_link_up(struct netif *netif);
 void netif_set_link_down(struct netif *netif);
-/** Ask if a link is up */ 
+/*  Ask if a link is up */ 
 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
 
 #if LWIP_NETIF_LINK_CALLBACK
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/opt.h
--- a/LPC2368/lwip/include/lwip/opt.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/opt.h	Thu Aug 05 15:09:22 2010 +0000
@@ -69,6 +69,14 @@
 #endif
 
 /**
+ * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1
+ * Mainly for compatibility to old versions.
+ */
+#ifndef NO_SYS_NO_TIMERS
+#define NO_SYS_NO_TIMERS                0
+#endif
+
+/**
  * MEMCPY: override this if you have a faster implementation at hand than the
  * one included in your C library
  */
@@ -260,7 +268,7 @@
 #endif
 
 /**
- * MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
+ * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
  * reassembly (whole packets, not fragments!)
  */
 #ifndef MEMP_NUM_REASSDATA
@@ -268,6 +276,17 @@
 #endif
 
 /**
+ * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent
+ * (fragments, not whole packets!).
+ * This is only used with IP_FRAG_USES_STATIC_BUF==0 and
+ * LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 with DMA-enabled MACs
+ * where the packet is not yet sent when netif->output returns.
+ */
+#ifndef MEMP_NUM_FRAG_PBUF
+#define MEMP_NUM_FRAG_PBUF              15
+#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.
@@ -371,6 +390,22 @@
 #endif
 
 /**
+ * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list
+ * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1.
+ */
+#ifndef MEMP_NUM_LOCALHOSTLIST
+#define MEMP_NUM_LOCALHOSTLIST          1
+#endif
+
+/**
+ * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
+ * interfaces (only used with PPPOE_SUPPORT==1)
+ */
+#ifndef MEMP_NUM_PPPOE_INTERFACES
+#define MEMP_NUM_PPPOE_INTERFACES       1
+#endif
+
+/**
  * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. 
  */
 #ifndef PBUF_POOL_SIZE
@@ -444,6 +479,14 @@
 #define ETH_PAD_SIZE                    0
 #endif
 
+/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table
+ * entries (using etharp_add_static_entry/etharp_remove_static_entry).
+ */
+#ifndef ETHARP_SUPPORT_STATIC_ENTRIES
+#define ETHARP_SUPPORT_STATIC_ENTRIES   0
+#endif
+
+
 /*
    --------------------------------
    ---------- IP options ----------
@@ -507,10 +550,12 @@
 /**
  * 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.
+ * packet data to be fragmented (or with LWIP_NETIF_TX_SINGLE_PBUF==1,
+ * new PBUF_RAM pbufs are used for fragments).
+ * ATTENTION: IP_FRAG_USES_STATIC_BUF==1 may not be used for DMA-enabled MACs!
  */
 #ifndef IP_FRAG_USES_STATIC_BUF
-#define IP_FRAG_USES_STATIC_BUF         1
+#define IP_FRAG_USES_STATIC_BUF         0
 #endif
 
 /**
@@ -1313,6 +1358,13 @@
 #define LWIP_NETCONN                    1
 #endif
 
+/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout tod create
+ * timers running in tcpip_thread from another thread.
+ */
+#ifndef LWIP_TCPIP_TIMEOUT
+#define LWIP_TCPIP_TIMEOUT              1
+#endif
+
 /*
    ------------------------------------
    ---------- Socket options ----------
@@ -1373,12 +1425,21 @@
 #endif
 
 /**
- * SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!
+ * SO_REUSE==1: Enable SO_REUSEADDR option.
  */
 #ifndef SO_REUSE
 #define SO_REUSE                        0
 #endif
 
+/**
+ * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets
+ * to all local matches if SO_REUSEADDR is turned on.
+ * WARNING: Adds a memcpy for every packet if passing to more than one pcb!
+ */
+#ifndef SO_REUSE_RXTOALL
+#define SO_REUSE_RXTOALL                0
+#endif
+
 /*
    ----------------------------------------
    ---------- Statistics options ----------
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/pbuf.h
--- a/LPC2368/lwip/include/lwip/pbuf.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/pbuf.h	Thu Aug 05 15:09:22 2010 +0000
@@ -40,6 +40,10 @@
 extern "C" {
 #endif
 
+/* Currently, the pbuf_custom code is only needed for one specific configuration
+ * of IP_FRAG */
+#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
+
 #define PBUF_TRANSPORT_HLEN 20
 #define PBUF_IP_HLEN        20
 
@@ -58,16 +62,21 @@
 } pbuf_type;
 
 
-/** indicates this packet's data should be immediately passed to the application */
-#define PBUF_FLAG_PUSH 0x01U
+/* indicates this packet's data should be immediately passed to the application */
+#define PBUF_FLAG_PUSH      0x01U
+/* indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a
+    a pbuf differently */
+#define PBUF_FLAG_IS_CUSTOM 0x02U
+/* indicates this pbuf is UDP multicast to be looped back */
+#define PBUF_FLAG_MCASTLOOP 0x04U
 
 struct pbuf {
-  /** next pbuf in singly linked pbuf chain */
+  /* next pbuf in singly linked pbuf chain */
   struct pbuf *next;
 
-  /** pointer to the actual data in the buffer */
+  /* pointer to the actual data in the buffer */
   void *payload;
-  
+
   /**
    * total length of this buffer and all next buffers in chain
    * belonging to the same packet.
@@ -76,14 +85,14 @@
    * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
    */
   u16_t tot_len;
-  
-  /** length of this buffer */
-  u16_t len;  
 
-  /** pbuf_type as u8_t instead of enum to save space */
+  /* length of this buffer */
+  u16_t len;
+
+  /* pbuf_type as u8_t instead of enum to save space */
   u8_t /*pbuf_type*/ type;
 
-  /** misc flags */
+  /* misc flags */
   u8_t flags;
 
   /**
@@ -92,17 +101,33 @@
    * the stack itself, or pbuf->next pointers from a chain.
    */
   u16_t ref;
-  
 };
 
+#if LWIP_SUPPORT_CUSTOM_PBUF
+/* Prototype for a function to free a custom pbuf */
+typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
+
+/* A custom pbuf: like a pbuf, but following a function pointer to free it. */
+struct pbuf_custom {
+  /* The actual pbuf */
+  struct pbuf pbuf;
+  /* This function is called when pbuf_free deallocates this pbuf(_custom) */
+  pbuf_free_custom_fn custom_free_function;
+};
+#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
+
 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
 #define pbuf_init()
 
-struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type);
+struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
+#if LWIP_SUPPORT_CUSTOM_PBUF
+struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
+                                 struct pbuf_custom *p, void *payload_mem,
+                                 u16_t payload_mem_len);
+#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
 void pbuf_realloc(struct pbuf *p, u16_t size); 
 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
 void pbuf_ref(struct pbuf *p);
-void pbuf_ref_chain(struct pbuf *p);
 u8_t pbuf_free(struct pbuf *p);
 u8_t pbuf_clen(struct pbuf *p);  
 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
@@ -112,6 +137,15 @@
 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
+#if LWIP_CHECKSUM_ON_COPY
+err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
+                       u16_t len, u16_t *chksum);
+#endif /* LWIP_CHECKSUM_ON_COPY */
+
+u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
+u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
+u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
+u16_t pbuf_strstr(struct pbuf* p, const char* substr);
 
 #ifdef __cplusplus
 }
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/snmp_asn1.h
--- a/LPC2368/lwip/include/lwip/snmp_asn1.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/snmp_asn1.h	Thu Aug 05 15:09:22 2010 +0000
@@ -46,12 +46,12 @@
 extern "C" {
 #endif
 
-#define SNMP_ASN1_UNIV   (!0x80 | !0x40)
-#define SNMP_ASN1_APPLIC (!0x80 |  0x40)
-#define SNMP_ASN1_CONTXT ( 0x80 | !0x40)
+#define SNMP_ASN1_UNIV   (0)    /* (!0x80 | !0x40) */
+#define SNMP_ASN1_APPLIC (0x40) /* (!0x80 |  0x40) */
+#define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */
 
-#define SNMP_ASN1_CONSTR (0x20)
-#define SNMP_ASN1_PRIMIT (!0x20)
+#define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */
+#define SNMP_ASN1_PRIMIT (0)    /* (!0x20) */
 
 /* universal tags */
 #define SNMP_ASN1_INTEG  2
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/snmp_structs.h
--- a/LPC2368/lwip/include/lwip/snmp_structs.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/snmp_structs.h	Thu Aug 05 15:09:22 2010 +0000
@@ -136,7 +136,7 @@
   u8_t node_type;
   u16_t maxlength;
 
-  /* aditional struct members */
+  /* additional struct members */
   const s32_t *objid;
   struct mib_node* const *nptr;
 };
@@ -180,7 +180,7 @@
   u8_t node_type;
   u16_t maxlength;
 
-  /* aditional struct members */
+  /* additional struct members */
   struct mib_list_node *head;
   struct mib_list_node *tail;
   /* counts list nodes in list  */
@@ -200,8 +200,8 @@
   u8_t node_type;
   u16_t maxlength;
 
-  /* aditional struct members */
-  /** points to an extenal (in memory) record of some sort of addressing
+  /* additional struct members */
+  /** points to an external (in memory) record of some sort of addressing
       information, passed to and interpreted by the funtions below */
   void* addr_inf;
   /** tree levels under this node */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/sockets.h
--- a/LPC2368/lwip/include/lwip/sockets.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/sockets.h	Thu Aug 05 15:09:22 2010 +0000
@@ -72,11 +72,11 @@
 #define SOCK_RAW        3
 
 /*
- * Option flags per-socket. These must match the SOF_ flags in ip.h!
+ * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
  */
 #define  SO_DEBUG       0x0001 /* Unimplemented: turn on debugging info recording */
 #define  SO_ACCEPTCONN  0x0002 /* socket has had listen() */
-#define  SO_REUSEADDR   0x0004 /* Unimplemented: allow local address reuse */
+#define  SO_REUSEADDR   0x0004 /* Allow local address reuse */
 #define  SO_KEEPALIVE   0x0008 /* keep connections alive */
 #define  SO_DONTROUTE   0x0010 /* Unimplemented: just use interface addresses */
 #define  SO_BROADCAST   0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
@@ -279,6 +279,12 @@
 #define O_NDELAY    1 /* same as O_NONBLOCK, for compatibility */
 #endif
 
+#ifndef SHUT_RD
+  #define SHUT_RD   1
+  #define SHUT_WR   2
+  #define SHUT_RDWR 3
+#endif
+
 /* FD_SET used for lwip_select */
 #ifndef FD_SET
   #undef  FD_SETSIZE
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/stats.h
--- a/LPC2368/lwip/include/lwip/stats.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/stats.h	Thu Aug 05 15:09:22 2010 +0000
@@ -148,7 +148,7 @@
 
 extern struct stats_ lwip_stats;
 
-void stats_init();
+void stats_init(void);
 
 #define STATS_INC(x) ++lwip_stats.x
 #define STATS_DEC(x) --lwip_stats.x
@@ -157,7 +157,7 @@
                                     lwip_stats.x.max = lwip_stats.x.used; \
                                 } \
                              } while(0)
-#else
+#else /* LWIP_STATS */
 #define stats_init()
 #define STATS_INC(x)
 #define STATS_DEC(x)
@@ -276,7 +276,7 @@
 void stats_display_mem(struct stats_mem *mem, char *name);
 void stats_display_memp(struct stats_mem *mem, int index);
 void stats_display_sys(struct stats_sys *sys);
-#else
+#else /* LWIP_STATS_DISPLAY */
 #define stats_display()
 #define stats_display_proto(proto, name)
 #define stats_display_igmp(igmp)
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/sys.h
--- a/LPC2368/lwip/include/lwip/sys.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/sys.h	Thu Aug 05 15:09:22 2010 +0000
@@ -136,8 +136,8 @@
 void sys_sem_signal(sys_sem_t *sem);
 /** Wait for a semaphore for the specified timeout
  * @param sem the semaphore to wait for
- * @param timeout timeout in miliseconds to wait (0 = wait forever)
- * @return time (in miliseconds) waited for the semaphore
+ * @param timeout timeout in milliseconds to wait (0 = wait forever)
+ * @return time (in milliseconds) waited for the semaphore
  *         or SYS_ARCH_TIMEOUT on timeout */
 u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout);
 /** Delete a semaphore
@@ -178,8 +178,8 @@
 /** Wait for a new message to arrive in the mbox
  * @param mbox mbox to get a message from
  * @param msg pointer where the message is stored
- * @param timeout maximum time (in miliseconds) to wait for a message
- * @return time (in miliseconds) waited for a message, may be 0 if not waited
+ * @param timeout maximum time (in milliseconds) to wait for a message
+ * @return time (in milliseconds) waited for a message, may be 0 if not waited
            or SYS_ARCH_TIMEOUT on timeout
  *         The returned time has to be accurate to prevent timer jitter! */
 u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout);
@@ -188,8 +188,8 @@
 /** Wait for a new message to arrive in the mbox
  * @param mbox mbox to get a message from
  * @param msg pointer where the message is stored
- * @param timeout maximum time (in miliseconds) to wait for a message
- * @return 0 (miliseconds) if a message has been received
+ * @param timeout maximum time (in milliseconds) to wait for a message
+ * @return 0 (milliseconds) if a message has been received
  *         or SYS_MBOX_EMPTY if the mailbox is empty */
 u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg);
 #endif
@@ -215,7 +215,7 @@
  * @param arg parameter passed to 'thread'
  * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
  * @param prio priority of the new thread (may be ignored by ports) */
-sys_thread_t sys_thread_new(char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
+sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
 
 #endif /* NO_SYS */
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/tcp_impl.h
--- a/LPC2368/lwip/include/lwip/tcp_impl.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/tcp_impl.h	Thu Aug 05 15:09:22 2010 +0000
@@ -176,7 +176,7 @@
 
 #define TCPH_OFFSET_SET(phdr, offset) (phdr)->_hdrlen_rsvd_flags = htons(((offset) << 8) | TCPH_FLAGS(phdr))
 #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
-#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & htons((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags))
+#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags))
 #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags))
 
 #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags))
@@ -199,6 +199,8 @@
                    LWIP_EVENT_SENT, NULL, space, ERR_OK)
 #define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
                 LWIP_EVENT_RECV, (p), 0, (err))
+#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
+                LWIP_EVENT_RECV, NULL, 0, ERR_OK)
 #define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
                 LWIP_EVENT_CONNECTED, NULL, 0, (err))
 #define TCP_EVENT_POLL(pcb,ret)       ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
@@ -222,13 +224,22 @@
     else (ret) = ERR_OK;                                       \
   } while (0)
 
-#define TCP_EVENT_RECV(pcb,p,err,ret)                              \
-  do {                                                             \
-    if(((pcb)->recv != NULL) && (!((pcb)->flags & TF_RXCLOSED))) { \
-      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));    \
-    } else {                                                       \
-      (ret) = tcp_recv_null(NULL, (pcb), (p), (err));              \
-    }                                                              \
+#define TCP_EVENT_RECV(pcb,p,err,ret)                          \
+  do {                                                         \
+    if((pcb)->recv != NULL) {                                  \
+      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\
+    } else {                                                   \
+      (ret) = tcp_recv_null(NULL, (pcb), (p), (err));          \
+    }                                                          \
+  } while (0)
+
+#define TCP_EVENT_CLOSED(pcb,ret)                                \
+  do {                                                           \
+    if(((pcb)->recv != NULL)) {                                  \
+      (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\
+    } else {                                                     \
+      (ret) = ERR_OK;                                            \
+    }                                                            \
   } while (0)
 
 #define TCP_EVENT_CONNECTED(pcb,err,ret)                         \
@@ -260,7 +271,7 @@
 #define TCP_OVERSIZE_DBGCHECK 0
 #endif
 
-/** Don't generate chceksum on copy if CHECKSUM_GEN_TCP is disabled */
+/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */
 #define TCP_CHECKSUM_ON_COPY  (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)
 
 /* This structure represents a TCP segment on the unsent, unacked and ooseq queues */
@@ -291,10 +302,10 @@
   (flags & TF_SEG_OPTS_TS  ? 12 : 0)
 
 /** This returns a TCP header option for MSS in an u32_t */
-#define TCP_BUILD_MSS_OPTION(x) (x) = htonl(((u32_t)2 << 24) |          \
-                                            ((u32_t)4 << 16) |          \
-                                            (((u32_t)TCP_MSS / 256) << 8) | \
-                                            (TCP_MSS & 255))
+#define TCP_BUILD_MSS_OPTION(x) (x) = PP_HTONL(((u32_t)2 << 24) |          \
+                                               ((u32_t)4 << 16) |          \
+                                               (((u32_t)TCP_MSS / 256) << 8) | \
+                                               (TCP_MSS & 255))
 
 /* Global variables: */
 extern struct tcp_pcb *tcp_input_pcb;
@@ -305,6 +316,7 @@
   struct tcp_pcb_listen *listen_pcbs; 
   struct tcp_pcb *pcbs;
 };
+extern struct tcp_pcb *tcp_bound_pcbs;
 extern union tcp_listen_pcbs_t tcp_listen_pcbs;
 extern struct tcp_pcb *tcp_active_pcbs;  /* List of all TCP PCBs that are in a
               state in which they accept or send
@@ -321,62 +333,65 @@
 */
 /* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
    with a PCB list or removes a PCB from a list, respectively. */
-#if 0
+#ifndef TCP_DEBUG_PCB_LISTS
+#define TCP_DEBUG_PCB_LISTS 0
+#endif
+#if TCP_DEBUG_PCB_LISTS
 #define TCP_REG(pcbs, npcb) do {\
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
-                            for(tcp_tmp_pcb = *pcbs; \
+                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \
+                            for(tcp_tmp_pcb = *(pcbs); \
           tcp_tmp_pcb != NULL; \
         tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
+                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \
                             } \
-                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
-                            npcb->next = *pcbs; \
-                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
-                            *(pcbs) = npcb; \
+                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \
+                            (npcb)->next = *(pcbs); \
+                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \
+                            *(pcbs) = (npcb); \
                             LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
               tcp_timer_needed(); \
                             } while(0)
 #define TCP_RMV(pcbs, npcb) do { \
-                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
-                            if(*pcbs == npcb) { \
-                               *pcbs = (*pcbs)->next; \
-                            } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                               if(tcp_tmp_pcb->next == npcb) { \
-                                  tcp_tmp_pcb->next = npcb->next; \
+                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
+                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
+                            if(*(pcbs) == (npcb)) { \
+                               *(pcbs) = (*pcbs)->next; \
+                            } else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
+                               if(tcp_tmp_pcb->next == (npcb)) { \
+                                  tcp_tmp_pcb->next = (npcb)->next; \
                                   break; \
                                } \
                             } \
-                            npcb->next = NULL; \
+                            (npcb)->next = NULL; \
                             LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
+                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \
                             } while(0)
 
 #else /* LWIP_DEBUG */
 
 #define TCP_REG(pcbs, npcb)                        \
   do {                                             \
-    npcb->next = *pcbs;                            \
-    *(pcbs) = npcb;                                \
+    (npcb)->next = *pcbs;                          \
+    *(pcbs) = (npcb);                              \
     tcp_timer_needed();                            \
   } while (0)
 
 #define TCP_RMV(pcbs, npcb)                        \
   do {                                             \
-    if(*(pcbs) == npcb) {                          \
+    if(*(pcbs) == (npcb)) {                        \
       (*(pcbs)) = (*pcbs)->next;                   \
     }                                              \
     else {                                         \
-      for(tcp_tmp_pcb = *pcbs;                                         \
-          tcp_tmp_pcb != NULL;                                         \
-          tcp_tmp_pcb = tcp_tmp_pcb->next) {                           \
-        if(tcp_tmp_pcb->next == npcb) {   \
-          tcp_tmp_pcb->next = npcb->next;          \
+      for(tcp_tmp_pcb = *pcbs;                     \
+          tcp_tmp_pcb != NULL;                     \
+          tcp_tmp_pcb = tcp_tmp_pcb->next) {       \
+        if(tcp_tmp_pcb->next == (npcb)) {          \
+          tcp_tmp_pcb->next = (npcb)->next;        \
           break;                                   \
         }                                          \
       }                                            \
     }                                              \
-    npcb->next = NULL;                             \
+    (npcb)->next = NULL;                           \
   } while(0)
 
 #endif /* LWIP_DEBUG */
@@ -448,68 +463,6 @@
 void tcp_timer_needed(void);
 
 
-/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
-   with a PCB list or removes a PCB from a list, respectively. */
-#if 0
-#define TCP_REG(pcbs, npcb) do {\
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
-                            for(tcp_tmp_pcb = *pcbs; \
-          tcp_tmp_pcb != NULL; \
-        tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
-                            } \
-                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
-                            npcb->next = *pcbs; \
-                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
-                            *(pcbs) = npcb; \
-                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-              tcp_timer_needed(); \
-                            } while(0)
-#define TCP_RMV(pcbs, npcb) do { \
-                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
-                            if(*pcbs == npcb) { \
-                               *pcbs = (*pcbs)->next; \
-                            } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                               if(tcp_tmp_pcb->next == npcb) { \
-                                  tcp_tmp_pcb->next = npcb->next; \
-                                  break; \
-                               } \
-                            } \
-                            npcb->next = NULL; \
-                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
-                            } while(0)
-
-#else /* LWIP_DEBUG */
-
-#define TCP_REG(pcbs, npcb)                        \
-  do {                                             \
-    npcb->next = *pcbs;                            \
-    *(pcbs) = npcb;                                \
-    tcp_timer_needed();                            \
-  } while (0)
-
-#define TCP_RMV(pcbs, npcb)                        \
-  do {                                             \
-    if(*(pcbs) == npcb) {                          \
-      (*(pcbs)) = (*pcbs)->next;                   \
-    }                                              \
-    else {                                         \
-      for(tcp_tmp_pcb = *pcbs;                                         \
-          tcp_tmp_pcb != NULL;                                         \
-          tcp_tmp_pcb = tcp_tmp_pcb->next) {                           \
-        if(tcp_tmp_pcb->next == npcb) {   \
-          tcp_tmp_pcb->next = npcb->next;          \
-          break;                                   \
-        }                                          \
-      }                                            \
-    }                                              \
-    npcb->next = NULL;                             \
-  } while(0)
-
-#endif /* LWIP_DEBUG */
-
 #ifdef __cplusplus
 }
 #endif
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/tcpip.h
--- a/LPC2368/lwip/include/lwip/tcpip.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/tcpip.h	Thu Aug 05 15:09:22 2010 +0000
@@ -48,6 +48,12 @@
 extern "C" {
 #endif
 
+/** Define this to something that triggers a watchdog. This is called from
+ * tcpip_thread after processing a message. */
+#ifndef LWIP_TCPIP_THREAD_ALIVE
+#define LWIP_TCPIP_THREAD_ALIVE()
+#endif
+
 #if LWIP_TCPIP_CORE_LOCKING
 /** The global semaphore to lock the stack. */
 extern sys_mutex_t lock_tcpip_core;
@@ -96,8 +102,10 @@
 err_t pbuf_free_callback(struct pbuf *p);
 err_t mem_free_callback(void *m);
 
+#if LWIP_TCPIP_TIMEOUT
 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
+#endif /* LWIP_TCPIP_TIMEOUT */
 
 enum tcpip_msg_type {
 #if LWIP_NETCONN
@@ -107,9 +115,11 @@
 #if LWIP_NETIF_API
   TCPIP_MSG_NETIFAPI,
 #endif /* LWIP_NETIF_API */
-  TCPIP_MSG_CALLBACK,
+#if LWIP_TCPIP_TIMEOUT
   TCPIP_MSG_TIMEOUT,
-  TCPIP_MSG_UNTIMEOUT
+  TCPIP_MSG_UNTIMEOUT,
+#endif /* LWIP_TCPIP_TIMEOUT */
+  TCPIP_MSG_CALLBACK
 };
 
 struct tcpip_msg {
@@ -130,11 +140,13 @@
       tcpip_callback_fn function;
       void *ctx;
     } cb;
+#if LWIP_TCPIP_TIMEOUT
     struct {
       u32_t msecs;
       sys_timeout_handler h;
       void *arg;
     } tmo;
+#endif /* LWIP_TCPIP_TIMEOUT */
   } msg;
 };
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/timers.h
--- a/LPC2368/lwip/include/lwip/timers.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/timers.h	Thu Aug 05 15:09:22 2010 +0000
@@ -35,6 +35,11 @@
 
 #include "lwip/opt.h"
 
+/* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */
+#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS))
+
+#if LWIP_TIMERS
+
 #include "lwip/err.h"
 #include "lwip/sys.h"
 
@@ -70,13 +75,13 @@
 void sys_timeouts_init(void);
 
 #if LWIP_DEBUG_TIMERNAMES
-void sys_timeout_debug(u32_t msecs, sys_timeout_handler h, void *arg, const char* handler_name);
+void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name);
 #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler)
 #else /* LWIP_DEBUG_TIMERNAMES */
-void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
+void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg);
 #endif /* LWIP_DEBUG_TIMERNAMES */
 
-void sys_untimeout(sys_timeout_handler h, void *arg);
+void sys_untimeout(sys_timeout_handler handler, void *arg);
 #if NO_SYS
 void sys_check_timeouts(void);
 void sys_restart_timeouts(void);
@@ -89,4 +94,5 @@
 }
 #endif
 
+#endif /* LWIP_TIMERS */
 #endif /* __LWIP_TIMERS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/lwip/udp.h
--- a/LPC2368/lwip/include/lwip/udp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/lwip/udp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -63,9 +63,10 @@
 #  include "arch/epstruct.h"
 #endif
 
-#define UDP_FLAGS_NOCHKSUM 0x01U
-#define UDP_FLAGS_UDPLITE  0x02U
-#define UDP_FLAGS_CONNECTED  0x04U
+#define UDP_FLAGS_NOCHKSUM       0x01U
+#define UDP_FLAGS_UDPLITE        0x02U
+#define UDP_FLAGS_CONNECTED      0x04U
+#define UDP_FLAGS_MULTICAST_LOOP 0x08U
 
 struct udp_pcb;
 
@@ -135,6 +136,18 @@
                                  ip_addr_t *dst_ip, u16_t dst_port);
 err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);
 
+#if LWIP_CHECKSUM_ON_COPY
+err_t            udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p,
+                                 ip_addr_t *dst_ip, u16_t dst_port,
+                                 struct netif *netif, u8_t have_chksum,
+                                 u16_t chksum);
+err_t            udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p,
+                                 ip_addr_t *dst_ip, u16_t dst_port,
+                                 u8_t have_chksum, u16_t chksum);
+err_t            udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
+                                 u8_t have_chksum, u16_t chksum);
+#endif /* LWIP_CHECKSUM_ON_COPY */
+
 #define          udp_flags(pcb) ((pcb)->flags)
 #define          udp_setflags(pcb, f)  ((pcb)->flags = (f))
 
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/netif/etharp.h
--- a/LPC2368/lwip/include/netif/etharp.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/netif/etharp.h	Thu Aug 05 15:09:22 2010 +0000
@@ -68,7 +68,7 @@
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-/** Ethernet header */
+/* Ethernet header */
 struct eth_hdr {
 #if ETH_PAD_SIZE
   PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
@@ -90,7 +90,7 @@
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-/** VLAN header inserted between ethernet header and payload
+/* VLAN header inserted between ethernet header and payload
  * if 'type' in ethernet header is ETHTYPE_VLAN.
  * See IEEE802.Q */
 struct eth_vlan_hdr {
@@ -111,11 +111,12 @@
 #  include "arch/bpstruct.h"
 #endif
 PACK_STRUCT_BEGIN
-/** the ARP message, see RFC 826 ("Packet format") */
+/* the ARP message, see RFC 826 ("Packet format") */
 struct etharp_hdr {
   PACK_STRUCT_FIELD(u16_t hwtype);
   PACK_STRUCT_FIELD(u16_t proto);
-  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
+  PACK_STRUCT_FIELD(u8_t  hwlen);
+  PACK_STRUCT_FIELD(u8_t  protolen);
   PACK_STRUCT_FIELD(u16_t opcode);
   PACK_STRUCT_FIELD(struct eth_addr shwaddr);
   PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
@@ -130,7 +131,7 @@
 #define SIZEOF_ETHARP_HDR 28
 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
 
-/** 5 seconds period */
+/* 5 seconds period */
 #define ARP_TMR_INTERVAL 5000
 
 #define ETHTYPE_ARP       0x0806
@@ -139,14 +140,36 @@
 #define ETHTYPE_PPPOEDISC 0x8863  /* PPP Over Ethernet Discovery Stage */
 #define ETHTYPE_PPPOE     0x8864  /* PPP Over Ethernet Session Stage */
 
+/* MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
+ * or known to be 32-bit aligned within the protocol header. */
+#ifndef ETHADDR32_COPY
+#define ETHADDR32_COPY(src, dst)  SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
+#endif
+
+/* MEMCPY-like macro to copy to/from struct eth_addr's that are no local
+ * variables and known to be 16-bit aligned within the protocol header. */
+#ifndef ETHADDR16_COPY
+#define ETHADDR16_COPY(src, dst)  SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
+#endif
+
 #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
 
-/** ARP message types (opcodes) */
+/* ARP message types (opcodes) */
 #define ARP_REQUEST 1
 #define ARP_REPLY   2
 
+/* Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type)
+ * to a filter function that returns the correct netif when using multiple
+ * netifs on one hardware interface where the netif's low-level receive
+ * routine cannot decide for the correct netif (e.g. when mapping multiple
+ * IP addresses to one hardware interface).
+ */
+#ifndef LWIP_ARP_FILTER_NETIF
+#define LWIP_ARP_FILTER_NETIF 0
+#endif
+
 #if ARP_QUEUEING
-/** struct for queueing outgoing packets for unknown address
+/* struct for queueing outgoing packets for unknown address
   * defined here to be accessed by memp.h
   */
 struct etharp_q_entry {
@@ -162,12 +185,17 @@
 err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
 err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q);
 err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr);
-/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
+/* For Ethernet network interfaces, we might want to send "gratuitous ARP";
  *  this is an ARP packet sent by a node in order to spontaneously cause other
  *  nodes to update an entry in their ARP cache.
  *  From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
 #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
 
+#if ETHARP_SUPPORT_STATIC_ENTRIES
+err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr);
+err_t etharp_remove_static_entry(ip_addr_t *ipaddr);
+#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
+
 #if LWIP_AUTOIP
 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
                  const struct eth_addr *ethdst_addr,
@@ -176,7 +204,6 @@
                  const u16_t opcode);
 #endif /* LWIP_AUTOIP */
 
-
 #endif /* LWIP_ARP */
 
 err_t ethernet_input(struct pbuf *p, struct netif *netif);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/include/netif/ppp_oe.h
--- a/LPC2368/lwip/include/netif/ppp_oe.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/include/netif/ppp_oe.h	Thu Aug 05 15:09:22 2010 +0000
@@ -140,12 +140,38 @@
 /* two byte PPP protocol discriminator, then IP data */
 #define PPPOE_MAXMTU          (ETHERMTU-PPPOE_HEADERLEN-2)
 
-struct pppoe_softc;
+#ifndef PPPOE_MAX_AC_COOKIE_LEN
+#define PPPOE_MAX_AC_COOKIE_LEN   64
+#endif
+
+struct pppoe_softc {
+  struct pppoe_softc *next;
+  struct netif *sc_ethif;      /* ethernet interface we are using */
+  int sc_pd;                   /* ppp unit number */
+  void (*sc_linkStatusCB)(int pd, int up);
+
+  int sc_state;                /* discovery phase or session connected */
+  struct eth_addr sc_dest;     /* hardware address of concentrator */
+  u16_t sc_session;            /* PPPoE session id */
+
+#ifdef PPPOE_TODO
+  char *sc_service_name;       /* if != NULL: requested name of service */
+  char *sc_concentrator_name;  /* if != NULL: requested concentrator id */
+#endif /* PPPOE_TODO */
+  u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
+  size_t sc_ac_cookie_len;     /* length of cookie data */
+#ifdef PPPOE_SERVER
+  u8_t *sc_hunique;            /* content of host unique we must echo back */
+  size_t sc_hunique_len;       /* length of host unique */
+#endif
+  int sc_padi_retried;         /* number of PADI retries already done */
+  int sc_padr_retried;         /* number of PADR retries already done */
+};
 
 
-void pppoe_init(void);
+#define pppoe_init() /* compatibility define, no initialization needed */
 
-err_t pppoe_create(struct netif *ethernetnetif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
+err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
 err_t pppoe_destroy(struct netif *ifp);
 
 int pppoe_connect(struct pppoe_softc *sc);
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/lwipopts.h
--- a/LPC2368/lwip/lwipopts.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/lwip/lwipopts.h	Thu Aug 05 15:09:22 2010 +0000
@@ -53,10 +53,10 @@
 #define TUNIF_DEBUG LWIP_DBG_OFF
 #define UNIXIF_DEBUG LWIP_DBG_OFF
 #define DELIF_DEBUG LWIP_DBG_OFF
-#define SIO_FIFO_DEBUG LWIP_DBG_OFF
-#define TCPDUMP_DEBUG LWIP_DBG_OFF
+#define SIO_FIFO_DEBUG LWIP_DBG_ON
+#define TCPDUMP_DEBUG LWIP_DBG_ON
 
-#define PPP_DEBUG        LWIP_DBG_ON
+#define PPP_DEBUG        LWIP_DBG_OFF
 #define MEM_DEBUG        LWIP_DBG_OFF
 #define MEMP_DEBUG       LWIP_DBG_OFF
 #define PBUF_DEBUG       LWIP_DBG_OFF
@@ -70,6 +70,7 @@
 #define IP_REASS_DEBUG   LWIP_DBG_OFF
 #define RAW_DEBUG        LWIP_DBG_OFF
 #define ICMP_DEBUG       LWIP_DBG_OFF
+#define IGMP_DEBUG       LWIP_DBG_OFF
 #define UDP_DEBUG        LWIP_DBG_OFF
 #define TCP_DEBUG        LWIP_DBG_OFF
 #define TCP_INPUT_DEBUG  LWIP_DBG_OFF
@@ -174,30 +175,34 @@
 
 /* ---------- TCP options ---------- */
 #define LWIP_TCP                1
-#define TCP_TTL                 255
+//#define TCP_TTL                 255
 
 /* Controls if TCP should queue segments that arrive out of
    order. Define to 0 if your device is low on memory. */
-#define TCP_QUEUE_OOSEQ         0
+#define TCP_QUEUE_OOSEQ         1
 
 /* TCP Maximum segment size. */
 //#define TCP_MSS                 1024
-#define TCP_MSS                   1024//536//0x276
+#define TCP_MSS                   536//1024//536//0x276
 
 /* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             2048
+#define TCP_SND_BUF             (3 * TCP_MSS) //2048
 
 /* TCP sender buffer space (pbufs). This must be at least = 2 *
    TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)
+#define TCP_SND_QUEUELEN        (4 * (TCP_SND_BUF)/(TCP_MSS))
 
 /* 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 */
-#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
+#define TCP_SNDLOWAT        ((TCP_SND_BUF)/2)
 
+/**
+ * TCP_WND: The size of a TCP window.  This must be at least 
+ * (2 * TCP_MSS) for things to work well
+ */
 /* TCP receive window. */
-#define TCP_WND        1024         //8096
+#define TCP_WND        (4 * TCP_MSS)         //8096
 
 /* Maximum number of retransmissions of data segments. */
 //#define TCP_MAXRTX              12
@@ -272,14 +277,14 @@
 
 /* TCP Maximum segment size. */
 //#define TCP_MSS                 1024
-#define TCP_MSS                   512//0x276//536//0x276
+#define TCP_MSS                   536//0x276//536//0x276
 
 /* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             1024//2048
+#define TCP_SND_BUF             (3 * TCP_MSS)
 
 /* TCP sender buffer space (pbufs). This must be at least = 2 *
    TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
+#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
 
 /* TCP writable space (bytes). This must be less than or equal
    to TCP_SND_BUF. It is the amount of space which must be
@@ -287,7 +292,7 @@
 #define TCP_SNDLOWAT        (TCP_SND_BUF/2)
 
 /* TCP receive window. */
-#define TCP_WND        512         //8096
+#define TCP_WND        (3 * TCP_MSS)         //8096
 
 /* Maximum number of retransmissions of data segments. */
 //#define TCP_MAXRTX              12
@@ -299,8 +304,8 @@
 
 /* ---------- ARP options ---------- */
 #define LWIP_ARP                (NET_ETH | NET_ZG2100)
-#define ARP_TABLE_SIZE          2//4//10
-#define ARP_QUEUEING            0//1
+#define ARP_TABLE_SIZE          4//10
+#define ARP_QUEUEING            0
 #define ETHARP_TRUST_IP_MAC     1
 
 /* ---------- IP options ---------- */
@@ -321,6 +326,9 @@
 /* ---------- ICMP options ---------- */
 #define ICMP_TTL                255
 
+/* ---------- IGMP options ---------- */
+#define LWIP_IGMP               (NET_ETH | NET_ZG2100)
+
 /* ---------- DHCP options ---------- */
 /* Define LWIP_DHCP to 1 if you want DHCP configuration of
    interfaces. */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/lwipopts2.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/lwip/lwipopts2.h	Thu Aug 05 15:09:22 2010 +0000
@@ -0,0 +1,454 @@
+/*
+ * Copyright (c) 2001-2003 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 __LWIPOPTS_H__
+#define __LWIPOPTS_H__
+
+#include "netCfg.h"
+#if NET_LWIP_STACK
+
+//#include "arch/sys_arch.h"
+
+/* <sys/time.h> is included in cc.h! */
+#define LWIP_TIMEVAL_PRIVATE 0
+
+//#define __LWIP_DEBUG
+#include "dbg/dbg.h"
+
+#ifdef __LWIP_DEBUG
+
+#define LWIP_DEBUG 1
+
+#define LWIP_DBG_MIN_LEVEL 0
+//#define LWIP_COMPAT_SOCKETS 1
+#define TAPIF_DEBUG LWIP_DBG_OFF
+#define TUNIF_DEBUG LWIP_DBG_OFF
+#define UNIXIF_DEBUG LWIP_DBG_OFF
+#define DELIF_DEBUG LWIP_DBG_OFF
+#define SIO_FIFO_DEBUG LWIP_DBG_OFF
+#define TCPDUMP_DEBUG LWIP_DBG_OFF
+
+#define PPP_DEBUG        LWIP_DBG_OFF
+#define MEM_DEBUG        LWIP_DBG_ON
+#define MEMP_DEBUG       LWIP_DBG_ON
+#define PBUF_DEBUG       LWIP_DBG_ON
+#define API_LIB_DEBUG    LWIP_DBG_OFF
+#define API_MSG_DEBUG    LWIP_DBG_OFF
+#define TCPIP_DEBUG      LWIP_DBG_OFF
+#define NETIF_DEBUG      LWIP_DBG_OFF
+#define SOCKETS_DEBUG    LWIP_DBG_OFF
+#define DEMO_DEBUG       LWIP_DBG_OFF
+#define IP_DEBUG         LWIP_DBG_OFF
+#define IP_REASS_DEBUG   LWIP_DBG_OFF
+#define RAW_DEBUG        LWIP_DBG_OFF
+#define ICMP_DEBUG       LWIP_DBG_OFF
+#define UDP_DEBUG        LWIP_DBG_OFF
+#define TCP_DEBUG        LWIP_DBG_OFF
+#define TCP_INPUT_DEBUG  LWIP_DBG_OFF
+#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
+#define TCP_RTO_DEBUG    LWIP_DBG_OFF
+#define TCP_CWND_DEBUG   LWIP_DBG_OFF
+#define TCP_WND_DEBUG    LWIP_DBG_OFF
+#define TCP_FR_DEBUG     LWIP_DBG_OFF
+#define TCP_QLEN_DEBUG   LWIP_DBG_OFF
+#define TCP_RST_DEBUG    LWIP_DBG_OFF
+#define ETHARP_DEBUG     LWIP_DBG_OFF
+#define DNS_DEBUG        LWIP_DBG_OFF
+
+#endif
+
+/*
+extern unsigned char debug_flags;
+#define LWIP_DBG_TYPES_ON debug_flags
+*/
+#define NO_SYS                     1
+#define LWIP_SOCKET                (NO_SYS==0)
+#define LWIP_NETCONN               (NO_SYS==0)
+
+
+#define IP_FRAG_USES_STATIC_BUF         0
+
+
+
+/* ---------- 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. */
+/* MSVC port: intel processors don't need 4-byte alignment,
+   but are faster that way! */
+#define MEM_ALIGNMENT           4
+
+/* 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. */
+//#define MEM_SIZE               10240 
+
+#if TARGET_LPC1768
+
+
+#define MEM_SIZE               4000
+
+///
+
+#define MEM_POSITION __attribute((section("AHBSRAM0")))
+
+/* 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. */
+#define MEMP_NUM_PBUF           16
+/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
+   per active RAW "connection". */
+//#define MEMP_NUM_RAW_PCB        3
+/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+   per active UDP "connection". */
+#define MEMP_NUM_UDP_PCB        2
+/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB        2
+/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB_LISTEN 2//4
+/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
+   segments. */
+#define MEMP_NUM_TCP_SEG        16
+/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
+   timeouts. */
+#define MEMP_NUM_SYS_TIMEOUT    12
+
+/* 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. */
+#define MEMP_NUM_NETBUF         0
+/* MEMP_NUM_NETCONN: the number of struct netconns. */
+#define MEMP_NUM_NETCONN        0
+/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
+   for sequential API communication and incoming packets. Used in
+   src/api/tcpip.c. */
+#define MEMP_NUM_TCPIP_MSG_API   0
+#define MEMP_NUM_TCPIP_MSG_INPKT 0
+
+/* ---------- Pbuf options ---------- */
+/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+#define PBUF_POOL_SIZE          8//100
+
+/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
+#define PBUF_POOL_BUFSIZE       128
+
+/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+   link level header. */
+//#define PBUF_LINK_HLEN          16 
+
+/** SYS_LIGHTWEIGHT_PROT
+ * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
+ * for certain critical regions during buffer allocation, deallocation and memory
+ * allocation and deallocation.
+ */
+#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
+
+/* ---------- TCP options ---------- */
+#define LWIP_TCP                1
+#define TCP_TTL                 255
+
+/* Controls if TCP should queue segments that arrive out of
+   order. Define to 0 if your device is low on memory. */
+#define TCP_QUEUE_OOSEQ         0
+
+/* TCP Maximum segment size. */
+//#define TCP_MSS                 1024
+#define TCP_MSS                   0x276//536//0x276
+
+/* TCP sender buffer space (bytes). */
+#define TCP_SND_BUF             2048
+
+/* TCP sender buffer space (pbufs). This must be at least = 2 *
+   TCP_SND_BUF/TCP_MSS for things to work. */
+#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)
+
+/* 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 */
+#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
+
+/* TCP receive window. */
+#define TCP_WND        2048         //8096
+
+/* Maximum number of retransmissions of data segments. */
+//#define TCP_MAXRTX              12
+
+/* Maximum number of retransmissions of SYN segments. */
+//#define TCP_SYNMAXRTX           4
+
+#elif TARGET_LPC2368
+
+#define MEM_POSITION __attribute((section("AHBSRAM1")))
+
+/* 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. */
+#define MEMP_NUM_PBUF           8
+/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
+   per active RAW "connection". */
+//#define MEMP_NUM_RAW_PCB        3
+/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+   per active UDP "connection". */
+#define MEMP_NUM_UDP_PCB        2
+/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB        2
+/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB_LISTEN 2//4
+/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
+   segments. */
+#define MEMP_NUM_TCP_SEG        8
+/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
+   timeouts. */
+#define MEMP_NUM_SYS_TIMEOUT    12
+
+/* 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. */
+#define MEMP_NUM_NETBUF         0
+/* MEMP_NUM_NETCONN: the number of struct netconns. */
+#define MEMP_NUM_NETCONN        0
+/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
+   for sequential API communication and incoming packets. Used in
+   src/api/tcpip.c. */
+#define MEMP_NUM_TCPIP_MSG_API   0
+#define MEMP_NUM_TCPIP_MSG_INPKT 0
+
+/* ---------- Pbuf options ---------- */
+/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+#define PBUF_POOL_SIZE          8//16//100
+
+/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
+//#define PBUF_POOL_BUFSIZE       128
+
+/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+   link level header. */
+//#define PBUF_LINK_HLEN          16 
+
+/** SYS_LIGHTWEIGHT_PROT
+ * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
+ * for certain critical regions during buffer allocation, deallocation and memory
+ * allocation and deallocation.
+ */
+#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
+
+/* ---------- TCP options ---------- */
+#define LWIP_TCP                1
+#define TCP_TTL                 255
+
+/* Controls if TCP should queue segments that arrive out of
+   order. Define to 0 if your device is low on memory. */
+#define TCP_QUEUE_OOSEQ         0
+
+/* TCP Maximum segment size. */
+//#define TCP_MSS                 1024
+#define TCP_MSS                   512//0x276//536//0x276
+
+/* TCP sender buffer space (bytes). */
+#define TCP_SND_BUF             1024//2048
+
+/* TCP sender buffer space (pbufs). This must be at least = 2 *
+   TCP_SND_BUF/TCP_MSS for things to work. */
+#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
+
+/* 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 */
+#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
+
+/* TCP receive window. */
+#define TCP_WND        512         //8096
+
+/* Maximum number of retransmissions of data segments. */
+//#define TCP_MAXRTX              12
+
+/* Maximum number of retransmissions of SYN segments. */
+//#define TCP_SYNMAXRTX           4
+
+#endif
+
+/* ---------- ARP options ---------- */
+#define LWIP_ARP                (NET_ETH | NET_ZG2100)
+#define ARP_TABLE_SIZE          2//4//10
+#define ARP_QUEUEING            0//1
+#define ETHARP_TRUST_IP_MAC     1
+
+/* ---------- 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. */
+#define IP_FORWARD              0
+
+
+/* IP reassembly and segmentation.These are orthogonal even
+ * if they both deal with IP fragments */
+ /*
+#define IP_REASSEMBLY     1
+#define IP_REASS_MAX_PBUFS      10
+#define MEMP_NUM_REASSDATA      10
+#define IP_FRAG           1
+*/
+/* ---------- ICMP options ---------- */
+#define ICMP_TTL                255
+
+/* ---------- DHCP options ---------- */
+/* Define LWIP_DHCP to 1 if you want DHCP configuration of
+   interfaces. */
+#define LWIP_DHCP               (NET_ETH | NET_ZG2100)
+
+/* 1 if you want to do an ARP check on the offered address
+   (recommended if using DHCP). */
+#define DHCP_DOES_ARP_CHECK     (LWIP_DHCP)
+
+/* ---------- AUTOIP options ------- */
+#define LWIP_AUTOIP             0
+
+/* ---------- SNMP options ---------- */
+/** @todo SNMP is experimental for now
+    @note UDP must be available for SNMP transport */
+#ifndef LWIP_SNMP
+#define LWIP_SNMP               0
+#endif
+
+
+#ifndef SNMP_PRIVATE_MIB
+#define SNMP_PRIVATE_MIB        0
+#endif
+
+
+/* ---------- UDP options ---------- */
+#define LWIP_UDP                1
+#define UDP_TTL                 255
+
+/* ---------- DNS options ---------- */
+#define LWIP_DNS                1
+
+/* ---------- RAW options ---------- */
+#define LWIP_RAW                0
+#define RAW_TTL                 255
+
+/* ---------- Statistics options ---------- */
+/* individual STATS options can be turned off by defining them to 0 
+ * (e.g #define TCP_STATS 0). All of them are turned off if LWIP_STATS
+ * is 0
+ * */
+
+#define LWIP_STATS    0
+
+/* ---------- PPP options ---------- */
+
+#define PPP_SUPPORT      NET_PPP      /* Set > 0 for PPP */
+
+#if PPP_SUPPORT > 0
+
+#define NUM_PPP 1           /* Max PPP sessions. */
+
+
+/* Select modules to enable.  Ideally these would be set in the makefile but
+ * we're limited by the command line length so you need to modify the settings
+ * in this file.
+ */
+#define PAP_SUPPORT      1      /* Set > 0 for PAP. */
+#define CHAP_SUPPORT     1      /* Set > 0 for CHAP. */
+#define MSCHAP_SUPPORT   0      /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */
+#define CBCP_SUPPORT     0      /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
+#define CCP_SUPPORT      0      /* Set > 0 for CCP (NOT FUNCTIONAL!) */
+#define VJ_SUPPORT       1      /* Set > 0 for VJ header compression. */
+#define MD5_SUPPORT      1      /* Set > 0 for MD5 (see also CHAP) */
+
+
+/*
+ * Timeouts.
+ */
+#define FSM_DEFTIMEOUT        6    /* Timeout time in seconds */
+#define FSM_DEFMAXTERMREQS    2    /* Maximum Terminate-Request transmissions */
+#define FSM_DEFMAXCONFREQS    10    /* Maximum Configure-Request transmissions */
+#define FSM_DEFMAXNAKLOOPS    5    /* Maximum number of nak loops */
+
+#define UPAP_DEFTIMEOUT        6    /* Timeout (seconds) for retransmitting req */
+#define UPAP_DEFREQTIME        30    /* Time to wait for auth-req from peer */
+
+#define CHAP_DEFTIMEOUT        6    /* Timeout time in seconds */
+#define CHAP_DEFTRANSMITS    10    /* max # times to send challenge */
+
+
+/* Interval in seconds between keepalive echo requests, 0 to disable. */
+#if 1
+#define LCP_ECHOINTERVAL 0
+#else
+
+#define LCP_ECHOINTERVAL 10
+#endif
+
+
+/* Number of unanswered echo requests before failure. */
+#define LCP_MAXECHOFAILS 3
+
+/* Max Xmit idle time (in jiffies) before resend flag char. */
+#define PPP_MAXIDLEFLAG 0//Send it every time//100
+
+/*
+ * Packet sizes
+ *
+ * Note - lcp shouldn't be allowed to negotiate stuff outside these
+ *    limits.  See lcp.h in the pppd directory.
+ * (XXX - these constants should simply be shared by lcp.c instead
+ *    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
+
+#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 */
+#define PPP_DEFMRU    296        /* Try for this */
+#define PPP_MINMRU    128        /* No MRUs below this */
+
+
+#define MAXNAMELEN      64     /* max length of hostname or name for auth */
+#define MAXSECRETLEN    64     /* max length of password or secret */
+
+#endif /* PPP_SUPPORT > 0 */
+
+//C++ Compat
+#define try vTry
+
+#endif
+
+
+#endif /* __LWIPOPTS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/lwip/lwipopts_light.h
--- a/LPC2368/lwip/lwipopts_light.h	Fri Jul 09 14:34:26 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,454 +0,0 @@
-/*
- * Copyright (c) 2001-2003 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 __LWIPOPTS_H__
-#define __LWIPOPTS_H__
-
-#include "netCfg.h"
-#if NET_LWIP_STACK
-
-//#include "arch/sys_arch.h"
-
-/* <sys/time.h> is included in cc.h! */
-#define LWIP_TIMEVAL_PRIVATE 0
-
-//#define __LWIP_DEBUG
-#include "dbg/dbg.h"
-
-#ifdef __LWIP_DEBUG
-
-#define LWIP_DEBUG 1
-
-#define LWIP_DBG_MIN_LEVEL 0
-//#define LWIP_COMPAT_SOCKETS 1
-#define TAPIF_DEBUG LWIP_DBG_OFF
-#define TUNIF_DEBUG LWIP_DBG_OFF
-#define UNIXIF_DEBUG LWIP_DBG_OFF
-#define DELIF_DEBUG LWIP_DBG_OFF
-#define SIO_FIFO_DEBUG LWIP_DBG_OFF
-#define TCPDUMP_DEBUG LWIP_DBG_OFF
-
-#define PPP_DEBUG        LWIP_DBG_OFF
-#define MEM_DEBUG        LWIP_DBG_ON
-#define MEMP_DEBUG       LWIP_DBG_ON
-#define PBUF_DEBUG       LWIP_DBG_ON
-#define API_LIB_DEBUG    LWIP_DBG_OFF
-#define API_MSG_DEBUG    LWIP_DBG_OFF
-#define TCPIP_DEBUG      LWIP_DBG_OFF
-#define NETIF_DEBUG      LWIP_DBG_OFF
-#define SOCKETS_DEBUG    LWIP_DBG_OFF
-#define DEMO_DEBUG       LWIP_DBG_OFF
-#define IP_DEBUG         LWIP_DBG_OFF
-#define IP_REASS_DEBUG   LWIP_DBG_OFF
-#define RAW_DEBUG        LWIP_DBG_OFF
-#define ICMP_DEBUG       LWIP_DBG_OFF
-#define UDP_DEBUG        LWIP_DBG_OFF
-#define TCP_DEBUG        LWIP_DBG_OFF
-#define TCP_INPUT_DEBUG  LWIP_DBG_OFF
-#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
-#define TCP_RTO_DEBUG    LWIP_DBG_OFF
-#define TCP_CWND_DEBUG   LWIP_DBG_OFF
-#define TCP_WND_DEBUG    LWIP_DBG_OFF
-#define TCP_FR_DEBUG     LWIP_DBG_OFF
-#define TCP_QLEN_DEBUG   LWIP_DBG_OFF
-#define TCP_RST_DEBUG    LWIP_DBG_OFF
-#define ETHARP_DEBUG     LWIP_DBG_OFF
-#define DNS_DEBUG        LWIP_DBG_OFF
-
-#endif
-
-/*
-extern unsigned char debug_flags;
-#define LWIP_DBG_TYPES_ON debug_flags
-*/
-#define NO_SYS                     1
-#define LWIP_SOCKET                (NO_SYS==0)
-#define LWIP_NETCONN               (NO_SYS==0)
-
-
-#define IP_FRAG_USES_STATIC_BUF         0
-
-
-
-/* ---------- 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. */
-/* MSVC port: intel processors don't need 4-byte alignment,
-   but are faster that way! */
-#define MEM_ALIGNMENT           4
-
-/* 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. */
-//#define MEM_SIZE               10240 
-
-#if TARGET_LPC1768
-
-
-#define MEM_SIZE               2000
-
-///
-
-#define MEM_POSITION __attribute((section("AHBSRAM0")))
-
-/* 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. */
-#define MEMP_NUM_PBUF           8
-/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
-   per active RAW "connection". */
-//#define MEMP_NUM_RAW_PCB        3
-/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
-   per active UDP "connection". */
-#define MEMP_NUM_UDP_PCB        2
-/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB        2
-/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB_LISTEN 2//4
-/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
-   segments. */
-#define MEMP_NUM_TCP_SEG        8
-/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
-   timeouts. */
-#define MEMP_NUM_SYS_TIMEOUT    12
-
-/* 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. */
-#define MEMP_NUM_NETBUF         0
-/* MEMP_NUM_NETCONN: the number of struct netconns. */
-#define MEMP_NUM_NETCONN        0
-/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
-   for sequential API communication and incoming packets. Used in
-   src/api/tcpip.c. */
-#define MEMP_NUM_TCPIP_MSG_API   0
-#define MEMP_NUM_TCPIP_MSG_INPKT 0
-
-/* ---------- Pbuf options ---------- */
-/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
-#define PBUF_POOL_SIZE          16//100
-
-/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
-#define PBUF_POOL_BUFSIZE       128
-
-/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
-   link level header. */
-//#define PBUF_LINK_HLEN          16 
-
-/** SYS_LIGHTWEIGHT_PROT
- * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
-
-/* ---------- TCP options ---------- */
-#define LWIP_TCP                1
-#define TCP_TTL                 255
-
-/* Controls if TCP should queue segments that arrive out of
-   order. Define to 0 if your device is low on memory. */
-#define TCP_QUEUE_OOSEQ         0
-
-/* TCP Maximum segment size. */
-//#define TCP_MSS                 1024
-#define TCP_MSS                   0x276//536//0x276
-
-/* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             1024
-
-/* TCP sender buffer space (pbufs). This must be at least = 2 *
-   TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (2 * TCP_SND_BUF/TCP_MSS)
-
-/* 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 */
-#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
-
-/* TCP receive window. */
-#define TCP_WND        1024         //8096
-
-/* Maximum number of retransmissions of data segments. */
-//#define TCP_MAXRTX              12
-
-/* Maximum number of retransmissions of SYN segments. */
-//#define TCP_SYNMAXRTX           4
-
-#elif TARGET_LPC2368
-
-#define MEM_POSITION __attribute((section("AHBSRAM1")))
-
-/* 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. */
-#define MEMP_NUM_PBUF           8
-/* MEMP_NUM_RAW_PCB: the number of UDP protocol control blocks. One
-   per active RAW "connection". */
-//#define MEMP_NUM_RAW_PCB        3
-/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
-   per active UDP "connection". */
-#define MEMP_NUM_UDP_PCB        2
-/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB        2
-/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
-   connections. */
-#define MEMP_NUM_TCP_PCB_LISTEN 2//4
-/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
-   segments. */
-#define MEMP_NUM_TCP_SEG        8
-/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
-   timeouts. */
-#define MEMP_NUM_SYS_TIMEOUT    12
-
-/* 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. */
-#define MEMP_NUM_NETBUF         0
-/* MEMP_NUM_NETCONN: the number of struct netconns. */
-#define MEMP_NUM_NETCONN        0
-/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
-   for sequential API communication and incoming packets. Used in
-   src/api/tcpip.c. */
-#define MEMP_NUM_TCPIP_MSG_API   0
-#define MEMP_NUM_TCPIP_MSG_INPKT 0
-
-/* ---------- Pbuf options ---------- */
-/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
-#define PBUF_POOL_SIZE          8//16//100
-
-/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
-//#define PBUF_POOL_BUFSIZE       128
-
-/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
-   link level header. */
-//#define PBUF_LINK_HLEN          16 
-
-/** SYS_LIGHTWEIGHT_PROT
- * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#define SYS_LIGHTWEIGHT_PROT           0 //No sys here
-
-/* ---------- TCP options ---------- */
-#define LWIP_TCP                1
-#define TCP_TTL                 255
-
-/* Controls if TCP should queue segments that arrive out of
-   order. Define to 0 if your device is low on memory. */
-#define TCP_QUEUE_OOSEQ         0
-
-/* TCP Maximum segment size. */
-//#define TCP_MSS                 1024
-#define TCP_MSS                   512//0x276//536//0x276
-
-/* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             1024//2048
-
-/* TCP sender buffer space (pbufs). This must be at least = 2 *
-   TCP_SND_BUF/TCP_MSS for things to work. */
-#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)//(4 * TCP_SND_BUF/TCP_MSS)
-
-/* 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 */
-#define TCP_SNDLOWAT        (TCP_SND_BUF/2)
-
-/* TCP receive window. */
-#define TCP_WND        512         //8096
-
-/* Maximum number of retransmissions of data segments. */
-//#define TCP_MAXRTX              12
-
-/* Maximum number of retransmissions of SYN segments. */
-//#define TCP_SYNMAXRTX           4
-
-#endif
-
-/* ---------- ARP options ---------- */
-#define LWIP_ARP                (NET_ETH | NET_ZG2100)
-#define ARP_TABLE_SIZE          2//4//10
-#define ARP_QUEUEING            0//1
-#define ETHARP_TRUST_IP_MAC     1
-
-/* ---------- 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. */
-#define IP_FORWARD              0
-
-
-/* IP reassembly and segmentation.These are orthogonal even
- * if they both deal with IP fragments */
- /*
-#define IP_REASSEMBLY     1
-#define IP_REASS_MAX_PBUFS      10
-#define MEMP_NUM_REASSDATA      10
-#define IP_FRAG           1
-*/
-/* ---------- ICMP options ---------- */
-#define ICMP_TTL                255
-
-/* ---------- DHCP options ---------- */
-/* Define LWIP_DHCP to 1 if you want DHCP configuration of
-   interfaces. */
-#define LWIP_DHCP               (NET_ETH | NET_ZG2100)
-
-/* 1 if you want to do an ARP check on the offered address
-   (recommended if using DHCP). */
-#define DHCP_DOES_ARP_CHECK     (LWIP_DHCP)
-
-/* ---------- AUTOIP options ------- */
-#define LWIP_AUTOIP             0
-
-/* ---------- SNMP options ---------- */
-/** @todo SNMP is experimental for now
-    @note UDP must be available for SNMP transport */
-#ifndef LWIP_SNMP
-#define LWIP_SNMP               0
-#endif
-
-
-#ifndef SNMP_PRIVATE_MIB
-#define SNMP_PRIVATE_MIB        0
-#endif
-
-
-/* ---------- UDP options ---------- */
-#define LWIP_UDP                1
-#define UDP_TTL                 255
-
-/* ---------- DNS options ---------- */
-#define LWIP_DNS                1
-
-/* ---------- RAW options ---------- */
-#define LWIP_RAW                0
-#define RAW_TTL                 255
-
-/* ---------- Statistics options ---------- */
-/* individual STATS options can be turned off by defining them to 0 
- * (e.g #define TCP_STATS 0). All of them are turned off if LWIP_STATS
- * is 0
- * */
-
-#define LWIP_STATS    0
-
-/* ---------- PPP options ---------- */
-
-#define PPP_SUPPORT      NET_PPP      /* Set > 0 for PPP */
-
-#if PPP_SUPPORT > 0
-
-#define NUM_PPP 1           /* Max PPP sessions. */
-
-
-/* Select modules to enable.  Ideally these would be set in the makefile but
- * we're limited by the command line length so you need to modify the settings
- * in this file.
- */
-#define PAP_SUPPORT      1      /* Set > 0 for PAP. */
-#define CHAP_SUPPORT     1      /* Set > 0 for CHAP. */
-#define MSCHAP_SUPPORT   0      /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */
-#define CBCP_SUPPORT     0      /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
-#define CCP_SUPPORT      0      /* Set > 0 for CCP (NOT FUNCTIONAL!) */
-#define VJ_SUPPORT       1      /* Set > 0 for VJ header compression. */
-#define MD5_SUPPORT      1      /* Set > 0 for MD5 (see also CHAP) */
-
-
-/*
- * Timeouts.
- */
-#define FSM_DEFTIMEOUT        6    /* Timeout time in seconds */
-#define FSM_DEFMAXTERMREQS    2    /* Maximum Terminate-Request transmissions */
-#define FSM_DEFMAXCONFREQS    10    /* Maximum Configure-Request transmissions */
-#define FSM_DEFMAXNAKLOOPS    5    /* Maximum number of nak loops */
-
-#define UPAP_DEFTIMEOUT        6    /* Timeout (seconds) for retransmitting req */
-#define UPAP_DEFREQTIME        30    /* Time to wait for auth-req from peer */
-
-#define CHAP_DEFTIMEOUT        6    /* Timeout time in seconds */
-#define CHAP_DEFTRANSMITS    10    /* max # times to send challenge */
-
-
-/* Interval in seconds between keepalive echo requests, 0 to disable. */
-#if 1
-#define LCP_ECHOINTERVAL 0
-#else
-
-#define LCP_ECHOINTERVAL 10
-#endif
-
-
-/* Number of unanswered echo requests before failure. */
-#define LCP_MAXECHOFAILS 3
-
-/* Max Xmit idle time (in jiffies) before resend flag char. */
-#define PPP_MAXIDLEFLAG 0//Send it every time//100
-
-/*
- * Packet sizes
- *
- * Note - lcp shouldn't be allowed to negotiate stuff outside these
- *    limits.  See lcp.h in the pppd directory.
- * (XXX - these constants should simply be shared by lcp.c instead
- *    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
-
-#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 */
-#define PPP_DEFMRU    296        /* Try for this */
-#define PPP_MINMRU    128        /* No MRUs below this */
-
-
-#define MAXNAMELEN      64     /* max length of hostname or name for auth */
-#define MAXSECRETLEN    64     /* max length of password or secret */
-
-#endif /* PPP_SUPPORT > 0 */
-
-//C++ Compat
-#define try vTry
-
-#endif
-
-
-#endif /* __LWIPOPTS_H__ */
diff -r 9cec8b1dcf09 -r bc7df6da7589 LPC2368/netCfg.h
--- a/LPC2368/netCfg.h	Fri Jul 09 14:34:26 2010 +0000
+++ b/LPC2368/netCfg.h	Thu Aug 05 15:09:22 2010 +0000
@@ -5,9 +5,9 @@
 #define NET_GPRS 0
 #define NET_PPP 0
 #define NET_ZG2100 0
+#define NET_GPRS_MODULE 0
 #define NET_ETH 1
 #define NET_USB_SERIAL 0
-#define NET_TELIT 0
 #define NET_CFG_H 1
 #define NET_USB 0
 #define NET_LWIP_STACK 1