[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [task #7017] Implement DNS client
From: |
Jonathan Larmour |
Subject: |
[lwip-devel] [task #7017] Implement DNS client |
Date: |
Sun, 02 Dec 2007 22:35:19 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060513 Fedora/1.0.8-1.1.fc3.1.legacy Firefox/1.0.8 |
Follow-up Comment #82, task #7017 (project lwip):
Strictly it's incorrect: the name localhost is not special, and the
configured DNS server should map it to 127.0.0.1 anyway. In practice it makes
sense though :).
But once we consider this, it doesn't take much to take one little extra step
to provide a general hard-coded hosts lookup functionality, configured by the
user. For example in the following, the user can enable LWIP_HOSTS_LOOKUP in
lwipopts.h, and then define their own host mappings, e.g.:
#define LWIP_HOSTS_MAP
{ "server1", htonl((192<<24)|(168<<16)|(1<<8)|(1<<0)) },
{ "server2", htonl((192<<24)|(168<<16)|(1<<8)|(2<<0)) }
And here's the code for dns.c:
#if LWIP_HOSTS_LOOKUP
struct hosts_map_s {
const char *name;
u32_t addr;
};
struct hosts_map_s hosts_map[] = {
#if LWIP_HAVE_LOOPIF
{ "localhost", INADDR_LOOPBACK }
#endif
#ifdef LWIP_HOSTS_MAP
,
LWIP_HOSTS_MAP
#endif
};
In dns_gethostbyname:
#if LWIP_HOSTS_LOOKUP
{
u16_t i;
for (i=0;i<(sizeof(hosts_map)/sizeof(hosts_map[0]));i++) {
if (!strcmp(hostname, host_maps[i].name)) {
addr->addr=hosts_maps[i].addr;
return DNS_COMPLETE;
}
}
}
#endif
It's just a thought, take it or leave it.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/task/?7017>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [lwip-devel] [task #7017] Implement DNS client, Frédéric Bernon, 2007/12/01
- [lwip-devel] [task #7017] Implement DNS client, Simon Goldschmidt, 2007/12/01
- [lwip-devel] [task #7017] Implement DNS client,
Jonathan Larmour <=
- [lwip-devel] [task #7017] Implement DNS client, Simon Goldschmidt, 2007/12/03
- [lwip-devel] [task #7017] Implement DNS client, Frédéric Bernon, 2007/12/03
- [lwip-devel] [task #7017] Implement DNS client, David Empson, 2007/12/03
- [lwip-devel] [task #7017] Implement DNS client, Jonathan Larmour, 2007/12/04
- [lwip-devel] [task #7017] Implement DNS client, Frédéric Bernon, 2007/12/04
- [lwip-devel] [task #7017] Implement DNS client, Frédéric Bernon, 2007/12/04
- [lwip-devel] [task #7017] Implement DNS client, Jonathan Larmour, 2007/12/04
- [lwip-devel] [task #7017] Implement DNS client, Simon Goldschmidt, 2007/12/11
- [lwip-devel] [task #7017] Implement DNS client, Frédéric Bernon, 2007/12/11
- [lwip-devel] [task #7017] Implement DNS client, Simon Goldschmidt, 2007/12/11