2005-04-29 13:26:31 +00:00
|
|
|
#include "resolv.h"
|
|
|
|
|
|
|
|
static struct resolver resolvers[0] __table_start(resolver);
|
|
|
|
static struct resolver resolvers_end[0] __table_end(resolver);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resolve a name (which may be just a dotted quad IP address) to an
|
|
|
|
* IP address.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int resolv ( struct in_addr *address, const char *name ) {
|
|
|
|
struct resolver *resolver;
|
|
|
|
|
|
|
|
/* Check for a dotted quad IP address first */
|
2005-04-30 14:41:37 +00:00
|
|
|
if ( inet_aton ( name, address ) ) {
|
|
|
|
DBG ( "RESOLV saw valid IP address %s\n", name );
|
2005-04-29 13:26:31 +00:00
|
|
|
return 1;
|
2005-04-30 14:41:37 +00:00
|
|
|
}
|
2005-04-29 13:26:31 +00:00
|
|
|
|
|
|
|
/* Try any compiled-in name resolution modules */
|
|
|
|
for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
|
2005-04-30 14:41:37 +00:00
|
|
|
if ( resolver->resolv ( address, name ) ) {
|
|
|
|
DBG ( "RESOLV resolved \"%s\" to %@ using %s\n",
|
|
|
|
name, address->s_addr, resolver->name );
|
2005-04-29 13:26:31 +00:00
|
|
|
return 1;
|
2005-04-30 14:41:37 +00:00
|
|
|
}
|
2005-04-29 13:26:31 +00:00
|
|
|
}
|
|
|
|
|
2005-04-30 14:41:37 +00:00
|
|
|
DBG ( "RESOLV failed to resolve %s\n", name );
|
2005-04-29 13:26:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|