src/resolve.h
changeset 173 1a7afcd2dd1a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/resolve.h	Thu May 07 02:12:06 2009 +0300
@@ -0,0 +1,59 @@
+#ifndef RESOLVE_H
+#define RESOLVE_H
+
+/**
+ * @file
+ *
+ * DNS resolver interface
+ */
+#include "error.h"
+#include <netdb.h>
+
+/**
+ * Lookup result state
+ */
+struct resolve_result {
+    /** Head of the addrinfo list */
+    struct addrinfo *list;
+    
+    /** Current addrinfo item */
+    struct addrinfo *item;
+};
+
+/**
+ * Resolve the given node/service tuple as a series of addrinfos for the given socktype.
+ *
+ * This will never return an empty result.
+ *
+ * XXX: blocking DNS stuff
+ *
+ * @param res where to store the result state
+ * @param node hostname/address to look up
+ * @param service service/port to look up
+ * @param socktype a SOCK_* value to return addrinfo's for that socktype
+ * @param ai_flags optional bitmask of AI_* flags to use
+ * @param err returned error info
+ */
+err_t resolve_addr (struct resolve_result *res, const char *node, const char *service, int socktype, int ai_flags, error_t *err);
+
+/**
+ * Initialize the given result to zero
+ */
+void resolve_result_init (struct resolve_result *res);
+
+/**
+ * Get the next address from a result, if any left
+ */
+struct addrinfo* resolve_result_next (struct resolve_result *res);
+
+/**
+ * Release the addrinfo resources associated with the given result
+ */
+void resolve_result_deinit (struct resolve_result *res);
+
+/**
+ * Returns a pointer to a static buffer containing a string description of the given addrinfo
+ */
+const char * resolve_addr_text (const struct addrinfo *addr);
+
+#endif /* RESOLVE_H */