Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Fri Aug 06 10:42:05 2010 +0000
Parent:
2:1f10f8ab527b
Commit message:

Changed in this revision

LPC1768/ZG2100NetIf.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/drv/zg2100/zg_com.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/drv/zg2100/zg_defs.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/drv/zg2100/zg_drv.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/drv/zg2100/zg_err.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/drv/zg2100/zg_if.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/drv/zg2100/zg_net.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/if/zg2100/ZG2100NetIf.h Show annotated file Show diff for this revision Revisions of this file
LPC1768/if/zg2100/zg2100NetIf.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/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/lwip/netif.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/netif/etharp.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
LPC2368/ZG2100NetIf.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/drv/zg2100/zg_com.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/drv/zg2100/zg_defs.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/drv/zg2100/zg_drv.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/drv/zg2100/zg_err.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/drv/zg2100/zg_if.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/drv/zg2100/zg_net.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/if/zg2100/ZG2100NetIf.h Show annotated file Show diff for this revision Revisions of this file
LPC2368/if/zg2100/zg2100NetIf.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/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/lwip/netif.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/netif/etharp.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
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/ZG2100NetIf.ar
Binary file LPC1768/ZG2100NetIf.ar has changed
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/api/DNSRequest.h
--- a/LPC1768/api/DNSRequest.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/api/DNSRequest.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/api/TCPSocket.h
--- a/LPC1768/api/TCPSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/api/TCPSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/api/UDPSocket.h
--- a/LPC1768/api/UDPSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/api/UDPSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/core/host.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/host.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/core/ipaddr.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/ipaddr.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/core/net.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/net.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/core/netservice.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/core/netservice.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/dbg/dbg.h
--- a/LPC1768/dbg/dbg.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/dbg/dbg.h	Fri Aug 06 10:42:05 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,9 +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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/drv/zg2100/zg_com.h
--- a/LPC1768/drv/zg2100/zg_com.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/drv/zg2100/zg_com.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,7 +21,10 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level communication functions (SPI, CS, Interrupt)
+/**
+@file 
+ZG2100 Low-level communication functions (SPI, CS, Interrupt)
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_COM_H
@@ -44,41 +47,46 @@
 class DigitalOut;
 class InterruptIn;
 */
+///Opens SPI interface with pins
 void zg_com_init(SPI* pSpi, DigitalOut* pCs, /*InterruptIn*/ DigitalIn* pInt, DigitalOut* pNrst);
 
 //Registers Access
-
+///Reads register
 uint32_t zg_register_read(uint32_t addr);
 
+///Writes register
 void zg_register_write(uint32_t addr, uint32_t reg);
 
 //Indexed Registers Access
-
+///Reads indexed register
 uint32_t zg_indexed_register_read(uint32_t addr);
 
+///writes indexed register
 void zg_indexed_register_write(uint32_t addr, uint32_t reg);
 
 //Fifos
-
+///Reads FIFO
 void zg_fifo_read( byte fifo, byte* pType, byte* pSubtype, byte* buf, int len );
 
+///Writes FIFO (can be chunked)
 void zg_fifo_write( byte fifo, byte type, byte subtype, byte* buf, int len, bool start = true, bool stop = true ); //Write by chunks
 
 //Spi
 
+///SPI transfers directions
 typedef enum __ZG_SPI_DIR
 {
-  ZG_SPI_READ,
-  ZG_SPI_WRITE,
-  ZG_SPI_TRF //Read & Write
+  ZG_SPI_READ, ///Read
+  ZG_SPI_WRITE, ///Write
+  ZG_SPI_TRF ///Read & Write
 } ZG_SPI_DIR;
 
-
+///Transfers SPI frame
 void zg_spi_trf(byte* buf, int len, bool resetCs = true, ZG_SPI_DIR dir = ZG_SPI_TRF);
 
+///Is there an interrupt to serve?
 bool zg_is_int();
 
-
 //Callbacks, must be implemented in zg_drv.c
 
 void zg_on_int(); //On data available interrupt
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/drv/zg2100/zg_defs.h
--- a/LPC1768/drv/zg2100/zg_defs.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/drv/zg2100/zg_defs.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,14 +21,15 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level driver definitions
+/**
+@file
+ZG2100 Low-level driver definitions
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_DEFS_H
 #define ZG_DEFS_H
 
-#include "zg_err.h" //Error codes
-
 /* Parameters */
 
 #define ZG_HEAD_BUF_SIZE 64//16
@@ -188,6 +189,21 @@
 #define ZG_INT_MASK_F0 0x40
 #define ZG_INT_MASK_F1 0x80
 
+/* Internal Error Codes */
+
+typedef enum __ZG_INT_ERR 
+{
+  ZG_INT_OK = 1,
+  ZG_INT_RESOURCES = 12, //Not enough resources
+  ZG_INT_TIMEOUT,
+  ZG_INT_FRAME_ERROR,
+  ZG_INT_AUTH_REFUSED,
+  ZG_INT_ASSOC_REFUSED,
+  ZG_INT_IN_PROGRESS,
+  ZG_INT_SUPPLICANT_FAILED = 21
+
+} ZG_INT_ERR;
+
 /* F0 / F1 helpers */
 #define ZG_REG_F_CTRL0(n)   ((n==0)?ZG_REG_F0_CTRL0:ZG_REG_F1_CTRL0)
 #define ZG_REG_F_CTRL1(n)   ((n==0)?ZG_REG_F0_CTRL1:ZG_REG_F1_CTRL1)
@@ -236,11 +252,12 @@
   byte revision;
 } ZG_SYSV;
 
+///BSS types
 typedef enum __ZG_BSS_TYPE
 {
-  ZG_BSS_INFRA = 1,
-  ZG_BSS_ADHOC = 2,
-  ZG_BSS_ANY = 3
+  ZG_BSS_INFRA = 1, ///< Infrastructure
+  ZG_BSS_ADHOC = 2, ///< Ad-Hoc
+  ZG_BSS_ANY = 3 ///< Either
 } ZG_BSS_TYPE;
 
 typedef enum __ZG_PROBE_TYPE
@@ -333,13 +350,14 @@
   byte key[ZG_PMK_LEN]; //PSK key returned
 } ZG_PMK_REQ;
 
+///Security type
 typedef enum __ZG_SECURITY
 {
-  ZG_SECURITY_NONE = 0x00,
-  ZG_SECURITY_WEP  = 0x01,
-  ZG_SECURITY_WPA  = 0x02,
-  ZG_SECURITY_WPA2 = 0x03,
-  ZG_SECURITY_TRY  = 0xFF
+  ZG_SECURITY_NONE = 0x00, ///< None
+  ZG_SECURITY_WEP  = 0x01, ///< WEP
+  ZG_SECURITY_WPA  = 0x02, ///< WPA
+  ZG_SECURITY_WPA2 = 0x03, ///< WPA2
+  ZG_SECURITY_TRY  = 0xFF ///< Try all (not recommanded)
 } ZG_SECURITY;
 
 typedef __packed struct __ZG_CONNECT_REQ
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/drv/zg2100/zg_drv.h
--- a/LPC1768/drv/zg2100/zg_drv.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/drv/zg2100/zg_drv.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,21 +21,27 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level driver
+/**
+@file
+ZG2100 Low-level driver
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_DRV_H
 #define ZG_DRV_H
 
 #include "zg_defs.h"
+#include "zg_err.h"
 
+//Stores relevant data
 typedef struct _ZG_DATA
 {
   byte mac_addr[6];
   ZG_SYSV sys_version;
-
+  
 } ZG_DATA;
 
+//Stores which data is actually available
 typedef struct _ZG_DATA_MASK
 {
   bool mac_addr;
@@ -49,34 +55,53 @@
 extern ZG_DATA_MASK zg_data_mask; //Flags valid data
 
 //Spi intf, Chip Select pin, Interrupt pin
+///Initializes driver (zg_com_init must be called before).
 zg_err zg_drv_init();
 
+//FIXME: Not implemented, not used (to be deleted?)
 void zg_on_data_attach( void (*on_data)() );
 
+///Must be called regularly to process interrupts.
 void zg_process(); //Must be called regularly by user
 
+///Processes interrupt. (Called by zg_process if needed)
 void zg_int_process(); //Process interrupt
 
+///Can a management request be sent?
 bool zg_mgmt_is_busy();
 
+///Sends management request
 void zg_mgmt_req(byte subtype, byte* buf, int len, bool close = true);
+
+///Writes additional management data
 void zg_mgmt_data(byte* buf, int len, bool close = true);
 
+///Gets parameter
 void zg_mgmt_get_param(byte param);
+
+///Sets parameter
 void zg_mgmt_set_param(byte param, byte* buf, int len);
 
+///Called on management request result
 void zg_on_mgmt_avl(byte subtype, byte* buf, int len); //Data is available
+
+///Called on management event
 void zg_on_mgmt_evt(byte subtype, byte* buf, int len); //Management event
 
+///Called when get parameter request completes
 void zg_on_mgmt_get_param(byte* buf, int len); //Get param completed
 
 //uint32_t zg_fifo_room();
 
 //Useful to be split in several function because Lwip stores buffers in chunks
+///Sends Data (start)
 void zg_send_start();
+///Sends Data (main)
 void zg_send(byte* buf, int len);
+///Sends Data (end)
 void zg_send_end();
 
+///Can more data be sent?
 bool zg_send_is_busy();
 
 //Callbacks implemented in zg_if
@@ -85,6 +110,7 @@
 void zg_on_connect(zg_err result);
 
 //Handled by zg_net
+///Data received
 void zg_on_input(byte* buf, int len); 
 
 //Callbacks from zg_com
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/drv/zg2100/zg_err.h
--- a/LPC1768/drv/zg2100/zg_err.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/drv/zg2100/zg_err.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,23 +21,33 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level driver definitions
+/**
+@file
+ZG2100 driver errors
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_ERR_H
 #define ZG_ERR_H
 
+#include "zg_defs.h"
+
+///ZG2100 Wi-Fi Module driver error codes
 typedef enum __zg_err 
 {
-  ZG_OK = 1,
-  ZG_RESOURCES = 12, //Not enough resources
-  ZG_TIMEOUT,
-  ZG_FRAME_ERROR,
-  ZG_AUTH_REFUSED,
-  ZG_ASSOC_REFUSED,
-  ZG_IN_PROGRESS,
-  ZG_SUPPLICANT_FAILED = 21
+  __ZG_MIN = -0xFFFF,
+  ZG_RESOURCES, ///< Not enough resources
+  ZG_TIMEOUT, ///< Timeout
+  ZG_FRAME_ERROR, ///< Framing error
+  ZG_AUTH_REFUSED, ///< Authentication refused
+  ZG_ASSOC_REFUSED, ///< Association refused
+  ZG_IN_PROGRESS, ///< Command is being processed
+  ZG_SUPPLICANT_FAILED, ///< Error with WPA-handling
+  ZG_UNKNOWN, ///< Unknown error
+  ZG_OK = 0 ///< Success
 
 } zg_err;
 
+zg_err zg_errcode(ZG_INT_ERR int_err); //Errcodes conversion
+
 #endif
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/drv/zg2100/zg_if.h
--- a/LPC1768/drv/zg2100/zg_if.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/drv/zg2100/zg_if.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,7 +21,10 @@
 THE SOFTWARE.
 */
 
-//ZG2100 NetServices high-level interface : configuration & setup
+/**
+@file
+ZG2100 NetServices high-level interface : configuration & setup
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_IF_H
@@ -29,26 +32,37 @@
 
 #include "zg_defs.h"
 
+///Scans for available networks on given \a channel.
 void zg_scan(byte channel);
 
+///Will be called on scan completion, for now it is just a debug dump.
 void zg_on_scan_results(byte* buf, int len);
 
+///Sets the SSID of the network to be joined.
 void zg_set_ssid(const char* ssid);
 
+///Sets WEP key.
 void zg_set_wep_key(const byte* key, int len);
 
+///Sets WPA passphrase (will compute PSK key and set it).
 void zg_set_wpa_pass(const char* pass);
 
+///On completion of the passphrase computation.
 void zg_on_psk_key(byte* buf, int len);
 
+///Sets PSK key (preferred to be called directly than recomputing it every time using \a zg_set_wpa_pass).
 void zg_set_psk_key(const byte* key, int len);
 
+///Connects to network.
 void zg_connect(ZG_BSS_TYPE type, ZG_SECURITY security);
 
+///On connection result.
 void zg_on_connect(zg_err result);
 
+///Gets connection result.
 zg_err zg_get_connection_result();
 
+///Disconnects from network.
 void zg_disconnect();
 
 void hexdump(byte* buffer, int size);
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/drv/zg2100/zg_net.h
--- a/LPC1768/drv/zg2100/zg_net.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/drv/zg2100/zg_net.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,7 +21,10 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Lwip Driver
+/**
+@file
+ZG2100 LwIP Driver
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_NET_H
@@ -32,12 +35,14 @@
 typedef signed char err_t;
 
 //To be called by Lwip
-static err_t zg_output(struct netif *netif, struct pbuf *p); //Transfer an ethernet frame : convert into ZG frame & TX it
+///Transfers an ethernet frame: converts into ZG frame & TXs it
+static err_t zg_output(struct netif *netif, struct pbuf *p); 
 
 //Callback from zg_drv
-void zg_on_input(byte* buf, int len); //On reception of a ZG frame : convert into Eth frame & feed lwip
+///On reception of a ZG frame: converts into Eth frame & feeds lwip
+void zg_on_input(byte* buf, int len);
 
-
+///Initializes network interface
 err_t zg_net_init(struct netif *netif);
 
 #endif
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/lwip/LwipNetIf.h
--- a/LPC1768/if/lwip/LwipNetIf.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/if/lwip/LwipNetIf.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/lwip/lwipNetTcpSocket.h
--- a/LPC1768/if/lwip/lwipNetTcpSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/if/lwip/lwipNetTcpSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/lwip/lwipNetUdpSocket.h
--- a/LPC1768/if/lwip/lwipNetUdpSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/if/lwip/lwipNetUdpSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/net/host.h
--- a/LPC1768/if/net/host.h	Thu Jul 22 11:31:59 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/net/ipaddr.h
--- a/LPC1768/if/net/ipaddr.h	Thu Jul 22 11:31:59 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +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"
-
-#ifdef __LWIP_DEBUG
-#undef __LWIP_DEBUG
-#endif
-#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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/net/net.h
--- a/LPC1768/if/net/net.h	Thu Jul 22 11:31:59 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/net/netif.h
--- a/LPC1768/if/net/netif.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/if/net/netif.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/net/netservice.h
--- a/LPC1768/if/net/netservice.h	Thu Jul 22 11:31:59 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/zg2100/ZG2100NetIf.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC1768/if/zg2100/ZG2100NetIf.h	Fri Aug 06 10:42:05 2010 +0000
@@ -0,0 +1,117 @@
+
+/*
+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
+ZG2100 Wi-Fi Module network interface header file
+*/
+
+#ifndef ZG2100NETIF_H
+#define ZG2100NETIF_H
+
+struct netif;
+
+#include "mbed.h"
+
+#include "if/lwip/LwipNetIf.h"
+#include "core/net.h"
+
+#include "drv/zg2100/zg_defs.h"
+#include "drv/zg2100/zg_err.h"
+
+///ZG2100 Wi-Fi Module network interface error codes
+typedef zg_err ZG2100Err;
+
+///ZG2100 Wi-Fi Module network interface
+/**
+This class provides Wi-Fi connectivity to the stack
+*/
+class ZG2100NetIf : public LwipNetIf
+{
+public:
+  ///Instantiates the Interface and register it against the stack, DHCP will be used
+  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst ); //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.
+  */
+  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst,
+               IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns ); //W/o DHCP
+  virtual ~ZG2100NetIf();
+  
+  ///Initializes module
+  void init();
+  
+  ///Sets network's SSID
+  void setSsid(const char* ssid);
+
+  ///Sets network's WEP key
+  void setWepKey(const byte* key, int len);
+
+  ///Sets network's WPA passphrase (can last up to 30s)
+  void setWpaPass(const char* pass);
+
+  ///Sets network's PSK key (preferred when using WPA to avoid computing it each time)
+  void setPskKey(const byte* key, int len);
+
+  ///Connects to network
+  ZG2100Err connect(ZG_BSS_TYPE type, ZG_SECURITY security);
+
+  ///Disconnects from network
+  void disconnect();
+
+  ///Brings the interface up (must be connected to a network first)
+  /**
+  Uses DHCP if necessary
+  @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
+  @return : ZG_OK on success or ZG_TIMEOUT on timeout
+  */  
+  ZG2100Err setup(int timeout_ms = 15000);
+
+  virtual void poll();
+
+private:
+  void waitReady();
+
+  SPI m_spi;
+  DigitalOut m_cs;
+  /*InterruptIn*/ DigitalIn m_intp;
+  DigitalOut m_nrst;
+
+  Timer m_ethArpTimer;
+  Timer m_dhcpCoarseTimer;
+  Timer m_dhcpFineTimer;
+  Timer m_igmpTimer;
+    
+  bool m_useDhcp;
+
+  netif* m_pNetIf;
+  
+  IpAddr m_netmask;
+  IpAddr m_gateway;
+  
+  const char* m_hostname;
+  
+};
+
+#endif
+
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/if/zg2100/zg2100NetIf.h
--- a/LPC1768/if/zg2100/zg2100NetIf.h	Thu Jul 22 11:31:59 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +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 ZG2100NETIF_H
-#define ZG2100NETIF_H
-
-struct netif;
-
-#include "mbed.h"
-
-#include "if/lwip/LwipNetIf.h"
-#include "if/net/net.h"
-
-#include "drv/zg2100/zg_defs.h"
-
-typedef zg_err ZG2100Err;
-
-class ZG2100NetIf : public LwipNetIf
-{
-public:
-  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst ); //W/ DHCP
-  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst,
-               IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns ); //W/o DHCP
-  virtual ~ZG2100NetIf();
-  
-  void init();
-  
-  void setSsid(const char* ssid);
-
-  void setWepKey(const byte* key, int len);
-
-  void setWpaPass(const char* pass);
-
-  void setPskKey(const byte* key, int len);
-
-  ZG2100Err connect(ZG_BSS_TYPE type, ZG_SECURITY security);
-
-  void disconnect();
-  
-  ZG2100Err setup(int timeout_ms = 15000);
-
-  virtual void poll();
-
-private:
-  void waitReady();
-
-  SPI m_spi;
-  DigitalOut m_cs;
-  /*InterruptIn*/ DigitalIn m_intp;
-  DigitalOut m_nrst;
-
-  Timer m_ethArpTimer;
-  Timer m_dhcpCoarseTimer;
-  Timer m_dhcpFineTimer;
-    
-  bool m_useDhcp;
-
-  netif* m_pNetIf;
-  
-  IpAddr m_netmask;
-  IpAddr m_gateway;
-  
-  const char* m_hostname;
-  
-};
-
-#endif
-
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/arch/cc.h
--- a/LPC1768/lwip/arch/cc.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/arch/cc.h	Fri Aug 06 10:42:05 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)
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/include/ipv4/lwip/icmp.h
--- a/LPC1768/lwip/include/ipv4/lwip/icmp.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/icmp.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/include/ipv4/lwip/inet.h
--- a/LPC1768/lwip/include/ipv4/lwip/inet.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/include/ipv4/lwip/inet.h	Fri Aug 06 10:42:05 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;
 };
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/include/lwip/netif.h
--- a/LPC1768/lwip/include/lwip/netif.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/include/lwip/netif.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/include/lwip/pbuf.h
--- a/LPC1768/lwip/include/lwip/pbuf.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/include/lwip/pbuf.h	Fri Aug 06 10:42:05 2010 +0000
@@ -40,7 +40,7 @@
 extern "C" {
 #endif
 
-/** Currently, the pbuf_custom code is only needed for one specific configuration
+/* 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)
 
@@ -62,19 +62,19 @@
 } pbuf_type;
 
 
-/** indicates this packet's data should be immediately passed to the application */
+/* 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
+/* 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 */
+/* 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;
 
   /**
@@ -86,13 +86,13 @@
    */
   u16_t tot_len;
 
-  /** length of this buffer */
+  /* length of this buffer */
   u16_t len;
 
-  /** pbuf_type as u8_t instead of enum to save space */
+  /* pbuf_type as u8_t instead of enum to save space */
   u8_t /*pbuf_type*/ type;
 
-  /** misc flags */
+  /* misc flags */
   u8_t flags;
 
   /**
@@ -104,14 +104,14 @@
 };
 
 #if LWIP_SUPPORT_CUSTOM_PBUF
-/** Prototype for a function to free a 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. */
+/* A custom pbuf: like a pbuf, but following a function pointer to free it. */
 struct pbuf_custom {
-  /** The actual pbuf */
+  /* The actual pbuf */
   struct pbuf pbuf;
-  /** This function is called when pbuf_free deallocates this pbuf(_custom) */
+  /* This function is called when pbuf_free deallocates this pbuf(_custom) */
   pbuf_free_custom_fn custom_free_function;
 };
 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/include/netif/etharp.h
--- a/LPC1768/lwip/include/netif/etharp.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/include/netif/etharp.h	Fri Aug 06 10:42:05 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,7 +111,7 @@
 #  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);
@@ -131,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
@@ -140,13 +140,13 @@
 #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
+/* 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
+/* 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)
@@ -154,11 +154,11 @@
 
 #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)
+/* 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
@@ -169,7 +169,7 @@
 #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 {
@@ -185,7 +185,7 @@
 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. */
@@ -212,10 +212,10 @@
 
 extern const struct eth_addr ethbroadcast, ethzero;
 
-#endif /* LWIP_ARP || LWIP_ETHERNET */
-
 #ifdef __cplusplus
 }
 #endif
 
+#endif /* LWIP_ARP || LWIP_ETHERNET */
+
 #endif /* __NETIF_ARP_H__ */
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC1768/lwip/lwipopts.h
--- a/LPC1768/lwip/lwipopts.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC1768/lwip/lwipopts.h	Fri Aug 06 10:42:05 2010 +0000
@@ -53,7 +53,7 @@
 #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 SIO_FIFO_DEBUG LWIP_DBG_ON
 #define TCPDUMP_DEBUG LWIP_DBG_ON
 
 #define PPP_DEBUG        LWIP_DBG_OFF
@@ -62,26 +62,27 @@
 #define PBUF_DEBUG       LWIP_DBG_OFF
 #define API_LIB_DEBUG    LWIP_DBG_OFF
 #define API_MSG_DEBUG    LWIP_DBG_OFF
-#define TCPIP_DEBUG      LWIP_DBG_ON
-#define NETIF_DEBUG      LWIP_DBG_ON
+#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_ON
-#define IP_REASS_DEBUG   LWIP_DBG_ON
+#define IP_DEBUG         LWIP_DBG_OFF
+#define IP_REASS_DEBUG   LWIP_DBG_OFF
 #define RAW_DEBUG        LWIP_DBG_OFF
-#define ICMP_DEBUG       LWIP_DBG_ON
-#define UDP_DEBUG        LWIP_DBG_ON
-#define TCP_DEBUG        LWIP_DBG_ON
-#define TCP_INPUT_DEBUG  LWIP_DBG_ON
-#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
-#define TCP_RTO_DEBUG    LWIP_DBG_ON
-#define TCP_CWND_DEBUG   LWIP_DBG_ON
-#define TCP_WND_DEBUG    LWIP_DBG_ON
-#define TCP_FR_DEBUG     LWIP_DBG_ON
-#define TCP_QLEN_DEBUG   LWIP_DBG_ON
-#define TCP_RST_DEBUG    LWIP_DBG_ON
-#define ETHARP_DEBUG     LWIP_DBG_ON
-#define DNS_DEBUG        LWIP_DBG_ON
+#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
+#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
 
@@ -276,10 +277,10 @@
 
 /* TCP Maximum segment size. */
 //#define TCP_MSS                 1024
-#define TCP_MSS                   1024//0x276//536//0x276
+#define TCP_MSS                   536//0x276//536//0x276
 
 /* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             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. */
@@ -291,7 +292,7 @@
 #define TCP_SNDLOWAT        (TCP_SND_BUF/2)
 
 /* TCP receive window. */
-#define TCP_WND        1024         //8096
+#define TCP_WND        (3 * TCP_MSS)         //8096
 
 /* Maximum number of retransmissions of data segments. */
 //#define TCP_MAXRTX              12
@@ -325,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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/ZG2100NetIf.ar
Binary file LPC2368/ZG2100NetIf.ar has changed
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/api/DNSRequest.h
--- a/LPC2368/api/DNSRequest.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/api/DNSRequest.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/api/TCPSocket.h
--- a/LPC2368/api/TCPSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/api/TCPSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/api/UDPSocket.h
--- a/LPC2368/api/UDPSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/api/UDPSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/core/host.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/host.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/core/ipaddr.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/ipaddr.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/core/net.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/net.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/core/netservice.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/core/netservice.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/dbg/dbg.h
--- a/LPC2368/dbg/dbg.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/dbg/dbg.h	Fri Aug 06 10:42:05 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,9 +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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/drv/zg2100/zg_com.h
--- a/LPC2368/drv/zg2100/zg_com.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/drv/zg2100/zg_com.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,7 +21,10 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level communication functions (SPI, CS, Interrupt)
+/**
+@file 
+ZG2100 Low-level communication functions (SPI, CS, Interrupt)
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_COM_H
@@ -44,41 +47,46 @@
 class DigitalOut;
 class InterruptIn;
 */
+///Opens SPI interface with pins
 void zg_com_init(SPI* pSpi, DigitalOut* pCs, /*InterruptIn*/ DigitalIn* pInt, DigitalOut* pNrst);
 
 //Registers Access
-
+///Reads register
 uint32_t zg_register_read(uint32_t addr);
 
+///Writes register
 void zg_register_write(uint32_t addr, uint32_t reg);
 
 //Indexed Registers Access
-
+///Reads indexed register
 uint32_t zg_indexed_register_read(uint32_t addr);
 
+///writes indexed register
 void zg_indexed_register_write(uint32_t addr, uint32_t reg);
 
 //Fifos
-
+///Reads FIFO
 void zg_fifo_read( byte fifo, byte* pType, byte* pSubtype, byte* buf, int len );
 
+///Writes FIFO (can be chunked)
 void zg_fifo_write( byte fifo, byte type, byte subtype, byte* buf, int len, bool start = true, bool stop = true ); //Write by chunks
 
 //Spi
 
+///SPI transfers directions
 typedef enum __ZG_SPI_DIR
 {
-  ZG_SPI_READ,
-  ZG_SPI_WRITE,
-  ZG_SPI_TRF //Read & Write
+  ZG_SPI_READ, ///Read
+  ZG_SPI_WRITE, ///Write
+  ZG_SPI_TRF ///Read & Write
 } ZG_SPI_DIR;
 
-
+///Transfers SPI frame
 void zg_spi_trf(byte* buf, int len, bool resetCs = true, ZG_SPI_DIR dir = ZG_SPI_TRF);
 
+///Is there an interrupt to serve?
 bool zg_is_int();
 
-
 //Callbacks, must be implemented in zg_drv.c
 
 void zg_on_int(); //On data available interrupt
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/drv/zg2100/zg_defs.h
--- a/LPC2368/drv/zg2100/zg_defs.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/drv/zg2100/zg_defs.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,14 +21,15 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level driver definitions
+/**
+@file
+ZG2100 Low-level driver definitions
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_DEFS_H
 #define ZG_DEFS_H
 
-#include "zg_err.h" //Error codes
-
 /* Parameters */
 
 #define ZG_HEAD_BUF_SIZE 64//16
@@ -188,6 +189,21 @@
 #define ZG_INT_MASK_F0 0x40
 #define ZG_INT_MASK_F1 0x80
 
+/* Internal Error Codes */
+
+typedef enum __ZG_INT_ERR 
+{
+  ZG_INT_OK = 1,
+  ZG_INT_RESOURCES = 12, //Not enough resources
+  ZG_INT_TIMEOUT,
+  ZG_INT_FRAME_ERROR,
+  ZG_INT_AUTH_REFUSED,
+  ZG_INT_ASSOC_REFUSED,
+  ZG_INT_IN_PROGRESS,
+  ZG_INT_SUPPLICANT_FAILED = 21
+
+} ZG_INT_ERR;
+
 /* F0 / F1 helpers */
 #define ZG_REG_F_CTRL0(n)   ((n==0)?ZG_REG_F0_CTRL0:ZG_REG_F1_CTRL0)
 #define ZG_REG_F_CTRL1(n)   ((n==0)?ZG_REG_F0_CTRL1:ZG_REG_F1_CTRL1)
@@ -236,11 +252,12 @@
   byte revision;
 } ZG_SYSV;
 
+///BSS types
 typedef enum __ZG_BSS_TYPE
 {
-  ZG_BSS_INFRA = 1,
-  ZG_BSS_ADHOC = 2,
-  ZG_BSS_ANY = 3
+  ZG_BSS_INFRA = 1, ///< Infrastructure
+  ZG_BSS_ADHOC = 2, ///< Ad-Hoc
+  ZG_BSS_ANY = 3 ///< Either
 } ZG_BSS_TYPE;
 
 typedef enum __ZG_PROBE_TYPE
@@ -333,13 +350,14 @@
   byte key[ZG_PMK_LEN]; //PSK key returned
 } ZG_PMK_REQ;
 
+///Security type
 typedef enum __ZG_SECURITY
 {
-  ZG_SECURITY_NONE = 0x00,
-  ZG_SECURITY_WEP  = 0x01,
-  ZG_SECURITY_WPA  = 0x02,
-  ZG_SECURITY_WPA2 = 0x03,
-  ZG_SECURITY_TRY  = 0xFF
+  ZG_SECURITY_NONE = 0x00, ///< None
+  ZG_SECURITY_WEP  = 0x01, ///< WEP
+  ZG_SECURITY_WPA  = 0x02, ///< WPA
+  ZG_SECURITY_WPA2 = 0x03, ///< WPA2
+  ZG_SECURITY_TRY  = 0xFF ///< Try all (not recommanded)
 } ZG_SECURITY;
 
 typedef __packed struct __ZG_CONNECT_REQ
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/drv/zg2100/zg_drv.h
--- a/LPC2368/drv/zg2100/zg_drv.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/drv/zg2100/zg_drv.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,21 +21,27 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level driver
+/**
+@file
+ZG2100 Low-level driver
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_DRV_H
 #define ZG_DRV_H
 
 #include "zg_defs.h"
+#include "zg_err.h"
 
+//Stores relevant data
 typedef struct _ZG_DATA
 {
   byte mac_addr[6];
   ZG_SYSV sys_version;
-
+  
 } ZG_DATA;
 
+//Stores which data is actually available
 typedef struct _ZG_DATA_MASK
 {
   bool mac_addr;
@@ -49,34 +55,53 @@
 extern ZG_DATA_MASK zg_data_mask; //Flags valid data
 
 //Spi intf, Chip Select pin, Interrupt pin
+///Initializes driver (zg_com_init must be called before).
 zg_err zg_drv_init();
 
+//FIXME: Not implemented, not used (to be deleted?)
 void zg_on_data_attach( void (*on_data)() );
 
+///Must be called regularly to process interrupts.
 void zg_process(); //Must be called regularly by user
 
+///Processes interrupt. (Called by zg_process if needed)
 void zg_int_process(); //Process interrupt
 
+///Can a management request be sent?
 bool zg_mgmt_is_busy();
 
+///Sends management request
 void zg_mgmt_req(byte subtype, byte* buf, int len, bool close = true);
+
+///Writes additional management data
 void zg_mgmt_data(byte* buf, int len, bool close = true);
 
+///Gets parameter
 void zg_mgmt_get_param(byte param);
+
+///Sets parameter
 void zg_mgmt_set_param(byte param, byte* buf, int len);
 
+///Called on management request result
 void zg_on_mgmt_avl(byte subtype, byte* buf, int len); //Data is available
+
+///Called on management event
 void zg_on_mgmt_evt(byte subtype, byte* buf, int len); //Management event
 
+///Called when get parameter request completes
 void zg_on_mgmt_get_param(byte* buf, int len); //Get param completed
 
 //uint32_t zg_fifo_room();
 
 //Useful to be split in several function because Lwip stores buffers in chunks
+///Sends Data (start)
 void zg_send_start();
+///Sends Data (main)
 void zg_send(byte* buf, int len);
+///Sends Data (end)
 void zg_send_end();
 
+///Can more data be sent?
 bool zg_send_is_busy();
 
 //Callbacks implemented in zg_if
@@ -85,6 +110,7 @@
 void zg_on_connect(zg_err result);
 
 //Handled by zg_net
+///Data received
 void zg_on_input(byte* buf, int len); 
 
 //Callbacks from zg_com
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/drv/zg2100/zg_err.h
--- a/LPC2368/drv/zg2100/zg_err.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/drv/zg2100/zg_err.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,23 +21,33 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Low-level driver definitions
+/**
+@file
+ZG2100 driver errors
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_ERR_H
 #define ZG_ERR_H
 
+#include "zg_defs.h"
+
+///ZG2100 Wi-Fi Module driver error codes
 typedef enum __zg_err 
 {
-  ZG_OK = 1,
-  ZG_RESOURCES = 12, //Not enough resources
-  ZG_TIMEOUT,
-  ZG_FRAME_ERROR,
-  ZG_AUTH_REFUSED,
-  ZG_ASSOC_REFUSED,
-  ZG_IN_PROGRESS,
-  ZG_SUPPLICANT_FAILED = 21
+  __ZG_MIN = -0xFFFF,
+  ZG_RESOURCES, ///< Not enough resources
+  ZG_TIMEOUT, ///< Timeout
+  ZG_FRAME_ERROR, ///< Framing error
+  ZG_AUTH_REFUSED, ///< Authentication refused
+  ZG_ASSOC_REFUSED, ///< Association refused
+  ZG_IN_PROGRESS, ///< Command is being processed
+  ZG_SUPPLICANT_FAILED, ///< Error with WPA-handling
+  ZG_UNKNOWN, ///< Unknown error
+  ZG_OK = 0 ///< Success
 
 } zg_err;
 
+zg_err zg_errcode(ZG_INT_ERR int_err); //Errcodes conversion
+
 #endif
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/drv/zg2100/zg_if.h
--- a/LPC2368/drv/zg2100/zg_if.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/drv/zg2100/zg_if.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,7 +21,10 @@
 THE SOFTWARE.
 */
 
-//ZG2100 NetServices high-level interface : configuration & setup
+/**
+@file
+ZG2100 NetServices high-level interface : configuration & setup
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_IF_H
@@ -29,26 +32,37 @@
 
 #include "zg_defs.h"
 
+///Scans for available networks on given \a channel.
 void zg_scan(byte channel);
 
+///Will be called on scan completion, for now it is just a debug dump.
 void zg_on_scan_results(byte* buf, int len);
 
+///Sets the SSID of the network to be joined.
 void zg_set_ssid(const char* ssid);
 
+///Sets WEP key.
 void zg_set_wep_key(const byte* key, int len);
 
+///Sets WPA passphrase (will compute PSK key and set it).
 void zg_set_wpa_pass(const char* pass);
 
+///On completion of the passphrase computation.
 void zg_on_psk_key(byte* buf, int len);
 
+///Sets PSK key (preferred to be called directly than recomputing it every time using \a zg_set_wpa_pass).
 void zg_set_psk_key(const byte* key, int len);
 
+///Connects to network.
 void zg_connect(ZG_BSS_TYPE type, ZG_SECURITY security);
 
+///On connection result.
 void zg_on_connect(zg_err result);
 
+///Gets connection result.
 zg_err zg_get_connection_result();
 
+///Disconnects from network.
 void zg_disconnect();
 
 void hexdump(byte* buffer, int size);
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/drv/zg2100/zg_net.h
--- a/LPC2368/drv/zg2100/zg_net.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/drv/zg2100/zg_net.h	Fri Aug 06 10:42:05 2010 +0000
@@ -21,7 +21,10 @@
 THE SOFTWARE.
 */
 
-//ZG2100 Lwip Driver
+/**
+@file
+ZG2100 LwIP Driver
+*/
 //Donatien Garnier 2010
 
 #ifndef ZG_NET_H
@@ -32,12 +35,14 @@
 typedef signed char err_t;
 
 //To be called by Lwip
-static err_t zg_output(struct netif *netif, struct pbuf *p); //Transfer an ethernet frame : convert into ZG frame & TX it
+///Transfers an ethernet frame: converts into ZG frame & TXs it
+static err_t zg_output(struct netif *netif, struct pbuf *p); 
 
 //Callback from zg_drv
-void zg_on_input(byte* buf, int len); //On reception of a ZG frame : convert into Eth frame & feed lwip
+///On reception of a ZG frame: converts into Eth frame & feeds lwip
+void zg_on_input(byte* buf, int len);
 
-
+///Initializes network interface
 err_t zg_net_init(struct netif *netif);
 
 #endif
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/lwip/LwipNetIf.h
--- a/LPC2368/if/lwip/LwipNetIf.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/if/lwip/LwipNetIf.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/lwip/lwipNetTcpSocket.h
--- a/LPC2368/if/lwip/lwipNetTcpSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/if/lwip/lwipNetTcpSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/lwip/lwipNetUdpSocket.h
--- a/LPC2368/if/lwip/lwipNetUdpSocket.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/if/lwip/lwipNetUdpSocket.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/net/host.h
--- a/LPC2368/if/net/host.h	Thu Jul 22 11:31:59 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/net/ipaddr.h
--- a/LPC2368/if/net/ipaddr.h	Thu Jul 22 11:31:59 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +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"
-
-#ifdef __LWIP_DEBUG
-#undef __LWIP_DEBUG
-#endif
-#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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/net/net.h
--- a/LPC2368/if/net/net.h	Thu Jul 22 11:31:59 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/net/netif.h
--- a/LPC2368/if/net/netif.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/if/net/netif.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/net/netservice.h
--- a/LPC2368/if/net/netservice.h	Thu Jul 22 11:31:59 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/zg2100/ZG2100NetIf.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPC2368/if/zg2100/ZG2100NetIf.h	Fri Aug 06 10:42:05 2010 +0000
@@ -0,0 +1,117 @@
+
+/*
+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
+ZG2100 Wi-Fi Module network interface header file
+*/
+
+#ifndef ZG2100NETIF_H
+#define ZG2100NETIF_H
+
+struct netif;
+
+#include "mbed.h"
+
+#include "if/lwip/LwipNetIf.h"
+#include "core/net.h"
+
+#include "drv/zg2100/zg_defs.h"
+#include "drv/zg2100/zg_err.h"
+
+///ZG2100 Wi-Fi Module network interface error codes
+typedef zg_err ZG2100Err;
+
+///ZG2100 Wi-Fi Module network interface
+/**
+This class provides Wi-Fi connectivity to the stack
+*/
+class ZG2100NetIf : public LwipNetIf
+{
+public:
+  ///Instantiates the Interface and register it against the stack, DHCP will be used
+  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst ); //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.
+  */
+  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst,
+               IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns ); //W/o DHCP
+  virtual ~ZG2100NetIf();
+  
+  ///Initializes module
+  void init();
+  
+  ///Sets network's SSID
+  void setSsid(const char* ssid);
+
+  ///Sets network's WEP key
+  void setWepKey(const byte* key, int len);
+
+  ///Sets network's WPA passphrase (can last up to 30s)
+  void setWpaPass(const char* pass);
+
+  ///Sets network's PSK key (preferred when using WPA to avoid computing it each time)
+  void setPskKey(const byte* key, int len);
+
+  ///Connects to network
+  ZG2100Err connect(ZG_BSS_TYPE type, ZG_SECURITY security);
+
+  ///Disconnects from network
+  void disconnect();
+
+  ///Brings the interface up (must be connected to a network first)
+  /**
+  Uses DHCP if necessary
+  @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
+  @return : ZG_OK on success or ZG_TIMEOUT on timeout
+  */  
+  ZG2100Err setup(int timeout_ms = 15000);
+
+  virtual void poll();
+
+private:
+  void waitReady();
+
+  SPI m_spi;
+  DigitalOut m_cs;
+  /*InterruptIn*/ DigitalIn m_intp;
+  DigitalOut m_nrst;
+
+  Timer m_ethArpTimer;
+  Timer m_dhcpCoarseTimer;
+  Timer m_dhcpFineTimer;
+  Timer m_igmpTimer;
+    
+  bool m_useDhcp;
+
+  netif* m_pNetIf;
+  
+  IpAddr m_netmask;
+  IpAddr m_gateway;
+  
+  const char* m_hostname;
+  
+};
+
+#endif
+
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/if/zg2100/zg2100NetIf.h
--- a/LPC2368/if/zg2100/zg2100NetIf.h	Thu Jul 22 11:31:59 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +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 ZG2100NETIF_H
-#define ZG2100NETIF_H
-
-struct netif;
-
-#include "mbed.h"
-
-#include "if/lwip/LwipNetIf.h"
-#include "if/net/net.h"
-
-#include "drv/zg2100/zg_defs.h"
-
-typedef zg_err ZG2100Err;
-
-class ZG2100NetIf : public LwipNetIf
-{
-public:
-  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst ); //W/ DHCP
-  ZG2100NetIf( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName intp, PinName nrst,
-               IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns ); //W/o DHCP
-  virtual ~ZG2100NetIf();
-  
-  void init();
-  
-  void setSsid(const char* ssid);
-
-  void setWepKey(const byte* key, int len);
-
-  void setWpaPass(const char* pass);
-
-  void setPskKey(const byte* key, int len);
-
-  ZG2100Err connect(ZG_BSS_TYPE type, ZG_SECURITY security);
-
-  void disconnect();
-  
-  ZG2100Err setup(int timeout_ms = 15000);
-
-  virtual void poll();
-
-private:
-  void waitReady();
-
-  SPI m_spi;
-  DigitalOut m_cs;
-  /*InterruptIn*/ DigitalIn m_intp;
-  DigitalOut m_nrst;
-
-  Timer m_ethArpTimer;
-  Timer m_dhcpCoarseTimer;
-  Timer m_dhcpFineTimer;
-    
-  bool m_useDhcp;
-
-  netif* m_pNetIf;
-  
-  IpAddr m_netmask;
-  IpAddr m_gateway;
-  
-  const char* m_hostname;
-  
-};
-
-#endif
-
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/arch/cc.h
--- a/LPC2368/lwip/arch/cc.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/arch/cc.h	Fri Aug 06 10:42:05 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)
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/include/ipv4/lwip/icmp.h
--- a/LPC2368/lwip/include/ipv4/lwip/icmp.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/icmp.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/include/ipv4/lwip/inet.h
--- a/LPC2368/lwip/include/ipv4/lwip/inet.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/include/ipv4/lwip/inet.h	Fri Aug 06 10:42:05 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;
 };
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/include/lwip/netif.h
--- a/LPC2368/lwip/include/lwip/netif.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/include/lwip/netif.h	Fri Aug 06 10:42:05 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 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/include/lwip/pbuf.h
--- a/LPC2368/lwip/include/lwip/pbuf.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/include/lwip/pbuf.h	Fri Aug 06 10:42:05 2010 +0000
@@ -40,7 +40,7 @@
 extern "C" {
 #endif
 
-/** Currently, the pbuf_custom code is only needed for one specific configuration
+/* 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)
 
@@ -62,19 +62,19 @@
 } pbuf_type;
 
 
-/** indicates this packet's data should be immediately passed to the application */
+/* 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
+/* 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 */
+/* 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;
 
   /**
@@ -86,13 +86,13 @@
    */
   u16_t tot_len;
 
-  /** length of this buffer */
+  /* length of this buffer */
   u16_t len;
 
-  /** pbuf_type as u8_t instead of enum to save space */
+  /* pbuf_type as u8_t instead of enum to save space */
   u8_t /*pbuf_type*/ type;
 
-  /** misc flags */
+  /* misc flags */
   u8_t flags;
 
   /**
@@ -104,14 +104,14 @@
 };
 
 #if LWIP_SUPPORT_CUSTOM_PBUF
-/** Prototype for a function to free a 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. */
+/* A custom pbuf: like a pbuf, but following a function pointer to free it. */
 struct pbuf_custom {
-  /** The actual pbuf */
+  /* The actual pbuf */
   struct pbuf pbuf;
-  /** This function is called when pbuf_free deallocates this pbuf(_custom) */
+  /* This function is called when pbuf_free deallocates this pbuf(_custom) */
   pbuf_free_custom_fn custom_free_function;
 };
 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/include/netif/etharp.h
--- a/LPC2368/lwip/include/netif/etharp.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/include/netif/etharp.h	Fri Aug 06 10:42:05 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,7 +111,7 @@
 #  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);
@@ -131,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
@@ -140,13 +140,13 @@
 #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
+/* 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
+/* 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)
@@ -154,11 +154,11 @@
 
 #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)
+/* 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
@@ -169,7 +169,7 @@
 #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 {
@@ -185,7 +185,7 @@
 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. */
@@ -212,10 +212,10 @@
 
 extern const struct eth_addr ethbroadcast, ethzero;
 
-#endif /* LWIP_ARP || LWIP_ETHERNET */
-
 #ifdef __cplusplus
 }
 #endif
 
+#endif /* LWIP_ARP || LWIP_ETHERNET */
+
 #endif /* __NETIF_ARP_H__ */
diff -r 1f10f8ab527b -r e02ec42cf9c8 LPC2368/lwip/lwipopts.h
--- a/LPC2368/lwip/lwipopts.h	Thu Jul 22 11:31:59 2010 +0000
+++ b/LPC2368/lwip/lwipopts.h	Fri Aug 06 10:42:05 2010 +0000
@@ -53,7 +53,7 @@
 #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 SIO_FIFO_DEBUG LWIP_DBG_ON
 #define TCPDUMP_DEBUG LWIP_DBG_ON
 
 #define PPP_DEBUG        LWIP_DBG_OFF
@@ -62,26 +62,27 @@
 #define PBUF_DEBUG       LWIP_DBG_OFF
 #define API_LIB_DEBUG    LWIP_DBG_OFF
 #define API_MSG_DEBUG    LWIP_DBG_OFF
-#define TCPIP_DEBUG      LWIP_DBG_ON
-#define NETIF_DEBUG      LWIP_DBG_ON
+#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_ON
-#define IP_REASS_DEBUG   LWIP_DBG_ON
+#define IP_DEBUG         LWIP_DBG_OFF
+#define IP_REASS_DEBUG   LWIP_DBG_OFF
 #define RAW_DEBUG        LWIP_DBG_OFF
-#define ICMP_DEBUG       LWIP_DBG_ON
-#define UDP_DEBUG        LWIP_DBG_ON
-#define TCP_DEBUG        LWIP_DBG_ON
-#define TCP_INPUT_DEBUG  LWIP_DBG_ON
-#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
-#define TCP_RTO_DEBUG    LWIP_DBG_ON
-#define TCP_CWND_DEBUG   LWIP_DBG_ON
-#define TCP_WND_DEBUG    LWIP_DBG_ON
-#define TCP_FR_DEBUG     LWIP_DBG_ON
-#define TCP_QLEN_DEBUG   LWIP_DBG_ON
-#define TCP_RST_DEBUG    LWIP_DBG_ON
-#define ETHARP_DEBUG     LWIP_DBG_ON
-#define DNS_DEBUG        LWIP_DBG_ON
+#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
+#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
 
@@ -276,10 +277,10 @@
 
 /* TCP Maximum segment size. */
 //#define TCP_MSS                 1024
-#define TCP_MSS                   1024//0x276//536//0x276
+#define TCP_MSS                   536//0x276//536//0x276
 
 /* TCP sender buffer space (bytes). */
-#define TCP_SND_BUF             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. */
@@ -291,7 +292,7 @@
 #define TCP_SNDLOWAT        (TCP_SND_BUF/2)
 
 /* TCP receive window. */
-#define TCP_WND        1024         //8096
+#define TCP_WND        (3 * TCP_MSS)         //8096
 
 /* Maximum number of retransmissions of data segments. */
 //#define TCP_MAXRTX              12
@@ -325,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. */