First step: AutoIP compiled in and working

Dependencies:   mbed

Revision:
1:4218cacaf696
Parent:
0:55a05330f8cc
--- a/if/lwip/lwipNetDnsRequest.cpp	Fri Jun 18 09:11:35 2010 +0000
+++ b/if/lwip/lwipNetDnsRequest.cpp	Fri Jun 18 15:54:21 2010 +0000
@@ -31,12 +31,12 @@
 //#define __DEBUG
 #include "dbg/dbg.h"
 
-LwipNetDnsRequest::LwipNetDnsRequest(const char* hostname) : NetDnsRequest(hostname), m_state(LWIPNETDNS_START), m_cbFired(false)
+LwipNetDnsRequest::LwipNetDnsRequest(const char* hostname) : NetDnsRequest(hostname), m_state(LWIPNETDNS_START), m_cbFired(false), m_closing(false)
 {
   DBG("New LwipNetDnsRequest %p\n", this);
 }
 
-LwipNetDnsRequest::LwipNetDnsRequest(Host* pHost) : NetDnsRequest(pHost), m_state(LWIPNETDNS_START), m_cbFired(false)
+LwipNetDnsRequest::LwipNetDnsRequest(Host* pHost) : NetDnsRequest(pHost), m_state(LWIPNETDNS_START), m_cbFired(false), m_closing(false)
 {
   DBG("New LwipNetDnsRequest %p\n", this);
 }
@@ -106,16 +106,36 @@
     }  
     break; 
   }
-//  return m_state;
+  if(m_closing && (m_state!=LWIPNETDNS_PROCESSING)) //Check wether the closure has been reqd
+  {
+    DBG("LwipNetDnsRequest: Closing in poll()\n");
+    NetDnsRequest::close();
+  }
+}
+
+void LwipNetDnsRequest::close()
+{
+  DBG("LwipNetDnsRequest: Close req\n");
+  if(m_state!=LWIPNETDNS_PROCESSING)
+  {
+    DBG("LwipNetDnsRequest: Closing in close()\n");
+    NetDnsRequest::close();
+  }
+  else //Cannot close rightaway, waiting for callback from underlying layer
+  {
+    m_closing = true;
+  }
 }
 
 void LwipNetDnsRequest::foundCb(const char *name, ip_addr_t *ipaddr)
 {
   if( ipaddr == NULL )
   {
+    DBG("LwipNetDnsRequest: Callback: Name not found\n");
     m_state = LWIPNETDNS_NOTFOUND;
     return;
   }
+  DBG("LwipNetDnsRequest: Callback: Resolved\n");
   m_ip = IpAddr(ipaddr);
   m_state = LWIPNETDNS_OK;
 }
@@ -123,6 +143,7 @@
 
 void LwipNetDnsRequest::sFoundCb(const char *name, ip_addr_t *ipaddr, void *arg)
 {
+  DBG("LwipNetDnsRequest: Static callback\n");
   LwipNetDnsRequest* pMe = (LwipNetDnsRequest*) arg;
   return pMe->foundCb( name, ipaddr );
 }