tasklwIP - A Lightweight TCP/IP stack - Tasks: task #7507, Add static host table to...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #7507: Add static host table to dns_gethostbyname

Submitter:  Jonathan Larmour <jifl>
Submitted:  Wed 05 Dec 2007 12:20:23 AM UTC
   
 
Category:  None Should Start On:  Fri 05 Jan 2007 12:00:00 AM UTC
Should be Finished on:  Mon 05 Feb 2007 12:00:00 AM UTC Priority:  3 - Low
Status:  Done Privacy:  Public
Assigned to:  goldsimon Percent Complete:  100%
Open/Closed:  Closed Planned Release:  1.4.0
Effort:  0.00

Thu 07 May 2009 03:30:08 PM UTC, comment #4: 

See patch #6786: "Hook to support static hosts file in DNS lookup" for more info.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 23 Apr 2009 04:54:59 PM UTC, comment #3: 

Thanks for the info. It should work now.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 23 Apr 2009 04:17:46 PM UTC, comment #2: 

Some breaks in the last dns.c changes (win32 port doesn't build):

Index: dns.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/dns.c,v
retrieving revision 1.24
diff -u -3 -p -r1.24 dns.c
--- dns.c 21 Apr 2009 18:35:18 -0000 1.24
+++ dns.c 23 Apr 2009 15:50:46 -0000
@@ -193,7 +193,7 @@ struct dns_table_entry {
   void *arg;
 };
 
-#ifdef DNS_LOCAL_HOSTLIST
+#if DNS_LOCAL_HOSTLIST
 /** struct used for local host-list */
 struct local_hostlist_entry {
   /** static hostname */
@@ -319,7 +319,7 @@ dns_tmr(void)
 static void
 dns_init_local()
 {
-#ifdef DNS_LOCAL_HOSTLIST_INIT
+#if DNS_LOCAL_HOSTLIST_INIT
   int i;
   struct local_hostlist_entry *entry;
 #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC


There is also a warning if DNS_LOCAL_HOSTLIST==0


@@ -455,9 +455,9 @@ static u32_t
 dns_lookup(const char *name)
 {
   u8_t i;
+#if DNS_LOCAL_HOSTLIST
   u32_t addr;
 
-#if DNS_LOCAL_HOSTLIST
   if ((addr = dns_lookup_static(name)) != INADDR_NONE) {
     return addr;
   }

Last, in dns_gethostbyname, :

"((addr->addr = dns_lookup(hostname)) != 0)"

is replaced by

"((addr->addr = dns_lookup(hostname)) != INADDR_NONE)"

It doesn't work when you call "dns_gethostbyname("www.3com.com"...)" because dns_lookup return 0 when no found in cache, so, dns_gethostbyname returns ERR_OK.

I also see that "inet_addr("3com.com") returns now 0.0.0.3,  I note that on patch #6765 (but I'm not sure the problem is recent).






Frédéric Bernon <fbernon>
Group Member
Tue 21 Apr 2009 06:40:12 PM UTC, comment #1: 

Just felt like working on this:

This is now implemented in 2 stages:

a) Configuration option DNS_LOCAL_HOSTLIST turns on a statically allocated linked list of host-to-address. It is initialized by a define DNS_LOCAL_HOSTLIST_INIT like
#define DNS_LOCAL_HOSTLIST_INIT {{"host1", 0x123}, {"host2", 0x234}}

b) Configuration option DNS_LOCAL_HOSTLIST_IS_DYNAMIC makes the whole thing dynamic: mem_malloc is used to allocate the linked list items, the items in DNS_LOCAL_HOSTLIST_INIT are initially copied into that list, 3 functions can manipulate the list:

int dns_local_removehostname(const char *hostname);
int  dns_local_removehostaddr(const struct ip_addr *addr);
err_t dns_local_addhost(const char *hostname, const struct ip_addr *addr);

Jifl, I hope you don't mind me taking this over, I just felt the dns part was really missing this...

I regard this done now, please feel free to reopen it if you think different.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 05 Dec 2007 12:20:23 AM UTC, original submission:  

This was discussed in comments 82 to 89 in task #7017. A static host table would be a good idea, although perhaps not hard-coded into the image like originally suggested. Instead just have a pre-initialised array of a user-configured max size, along with simple functions to add/delete entries. It's pretty simple, but not worth worrying about for 1.3.0.

Jonathan Larmour <jifl>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by kieranm (Updated the item)
  • -email is unavailable- added by jifl (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-05-07 goldsimon Open/ClosedOpen Closed
    2009-04-23 fbernon Open/ClosedClosed Open
    2009-04-21 goldsimon StatusNone Done
        Percent Complete0% 100%
        Assigned tojifl goldsimon
        Open/ClosedOpen Closed
    2008-03-25 kieranm Planned ReleaseNone 1.4.0

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code