david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

First version

This commit is contained in:
Michael Brown 2005-04-29 13:26:31 +00:00
parent e4131ebb84
commit 65dc273d78
2 changed files with 40 additions and 0 deletions

25
src/core/resolv.c Normal file
View File

@ -0,0 +1,25 @@
#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 ) )
return 1;
/* Try any compiled-in name resolution modules */
for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
if ( resolver->resolv ( address, name ) )
return 1;
}
return 0;
}

15
src/include/resolv.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef RESOLV_H
#define RESOLV_H
#include "in.h"
#include "tables.h"
struct resolver {
int ( * resolv ) ( struct in_addr *address, const char *name );
};
#define __resolver __table(resolver,01)
extern int resolv ( struct in_addr *address, const char *name );
#endif /* RESOLV_H */