|
@@ -0,0 +1,25 @@
|
|
1
|
+#include "resolv.h"
|
|
2
|
+
|
|
3
|
+static struct resolver resolvers[0] __table_start(resolver);
|
|
4
|
+static struct resolver resolvers_end[0] __table_end(resolver);
|
|
5
|
+
|
|
6
|
+/*
|
|
7
|
+ * Resolve a name (which may be just a dotted quad IP address) to an
|
|
8
|
+ * IP address.
|
|
9
|
+ *
|
|
10
|
+ */
|
|
11
|
+int resolv ( struct in_addr *address, const char *name ) {
|
|
12
|
+ struct resolver *resolver;
|
|
13
|
+
|
|
14
|
+ /* Check for a dotted quad IP address first */
|
|
15
|
+ if ( inet_aton ( name, address ) )
|
|
16
|
+ return 1;
|
|
17
|
+
|
|
18
|
+ /* Try any compiled-in name resolution modules */
|
|
19
|
+ for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
|
|
20
|
+ if ( resolver->resolv ( address, name ) )
|
|
21
|
+ return 1;
|
|
22
|
+ }
|
|
23
|
+
|
|
24
|
+ return 0;
|
|
25
|
+}
|