First version
authorMichael Brown <mcb30@etherboot.org>
Fri, 29 Apr 2005 13:26:31 +0000 (13:26 +0000)
committerMichael Brown <mcb30@etherboot.org>
Fri, 29 Apr 2005 13:26:31 +0000 (13:26 +0000)
src/core/resolv.c [new file with mode: 0644]
src/include/resolv.h [new file with mode: 0644]

diff --git a/src/core/resolv.c b/src/core/resolv.c
new file mode 100644 (file)
index 0000000..24483b8
--- /dev/null
@@ -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;
+}
diff --git a/src/include/resolv.h b/src/include/resolv.h
new file mode 100644 (file)
index 0000000..99e3b29
--- /dev/null
@@ -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 */