david/ipxe
Archived
1
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
Michael Brown 88e38fa148 We don't actually have a stdio.h header file. Our printf() functions are
defined in vsprintf.h.  (This may change, since vsprintf.h is a
non-standard name, but for now it's the one to use.)

There should be no need to include vsprintf.h just for DBG() statements,
since include/compiler.h forces it in for a debug build anyway.
2006-09-27 10:58:14 +00:00

32 lines
835 B
C

#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 */
if ( inet_aton ( name, address ) ) {
DBG ( "RESOLV saw valid IP address %s\n", name );
return 1;
}
/* Try any compiled-in name resolution modules */
for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
if ( resolver->resolv ( address, name ) ) {
DBG ( "RESOLV resolved \"%s\" to %@ using %s\n",
name, address->s_addr, resolver->name );
return 1;
}
}
DBG ( "RESOLV failed to resolve %s\n", name );
return 0;
}