david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/core/resolv.c

34 lines
877 B
C
Raw Normal View History

2005-04-29 15:26:31 +02:00
#include "resolv.h"
static struct resolver resolvers[0]
__table_start ( struct resolver, resolver );
static struct resolver resolvers_end[0]
__table_end ( struct resolver, resolver );
2005-04-29 15:26:31 +02:00
/*
* 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 16:41:37 +02:00
if ( inet_aton ( name, address ) ) {
DBG ( "RESOLV saw valid IP address %s\n", name );
2005-04-29 15:26:31 +02:00
return 1;
2005-04-30 16:41:37 +02:00
}
2005-04-29 15:26:31 +02:00
/* Try any compiled-in name resolution modules */
for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
2005-04-30 16:41:37 +02:00
if ( resolver->resolv ( address, name ) ) {
DBG ( "RESOLV resolved \"%s\" to %@ using %s\n",
name, address->s_addr, resolver->name );
2005-04-29 15:26:31 +02:00
return 1;
2005-04-30 16:41:37 +02:00
}
2005-04-29 15:26:31 +02:00
}
2005-04-30 16:41:37 +02:00
DBG ( "RESOLV failed to resolve %s\n", name );
2005-04-29 15:26:31 +02:00
return 0;
}