Parcourir la source

First version

tags/v0.9.3
Michael Brown il y a 19 ans
Parent
révision
65dc273d78
2 fichiers modifiés avec 40 ajouts et 0 suppressions
  1. 25
    0
      src/core/resolv.c
  2. 15
    0
      src/include/resolv.h

+ 25
- 0
src/core/resolv.c Voir le fichier

@@ -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
+}

+ 15
- 0
src/include/resolv.h Voir le fichier

@@ -0,0 +1,15 @@
1
+#ifndef RESOLV_H
2
+#define RESOLV_H
3
+
4
+#include "in.h"
5
+#include "tables.h"
6
+
7
+struct resolver {
8
+	int ( * resolv ) ( struct in_addr *address, const char *name );
9
+};
10
+
11
+#define __resolver __table(resolver,01)
12
+
13
+extern int resolv ( struct in_addr *address, const char *name );
14
+
15
+#endif /* RESOLV_H */

Chargement…
Annuler
Enregistrer