src/resolve.h
branchnew-lib-errors
changeset 219 cefec18b8268
parent 218 5229a5d098b2
equal deleted inserted replaced
218:5229a5d098b2 219:cefec18b8268
     1 #ifndef RESOLVE_H
       
     2 #define RESOLVE_H
       
     3 
       
     4 /**
       
     5  * @file
       
     6  *
       
     7  * DNS resolver interface
       
     8  */
       
     9 #include "error.h"
       
    10 #include <netdb.h>
       
    11 
       
    12 /**
       
    13  * Lookup result state
       
    14  */
       
    15 struct resolve_result {
       
    16     /** Head of the addrinfo list */
       
    17     struct addrinfo *list;
       
    18     
       
    19     /** Current addrinfo item */
       
    20     struct addrinfo *item;
       
    21 };
       
    22 
       
    23 /**
       
    24  * Resolve the given node/service tuple as a series of addrinfos for the given socktype.
       
    25  *
       
    26  * This will never return an empty result.
       
    27  *
       
    28  * XXX: blocking DNS stuff
       
    29  *
       
    30  * @param res where to store the result state
       
    31  * @param node hostname/address to look up
       
    32  * @param service service/port to look up
       
    33  * @param socktype a SOCK_* value to return addrinfo's for that socktype
       
    34  * @param ai_flags optional bitmask of AI_* flags to use
       
    35  * @param err returned error info
       
    36  */
       
    37 err_t resolve_addr (struct resolve_result *res, const char *node, const char *service, int socktype, int ai_flags, error_t *err);
       
    38 
       
    39 /**
       
    40  * Initialize the given result to zero
       
    41  */
       
    42 void resolve_result_init (struct resolve_result *res);
       
    43 
       
    44 /**
       
    45  * Get the next address from a result, if any left
       
    46  */
       
    47 struct addrinfo* resolve_result_next (struct resolve_result *res);
       
    48 
       
    49 /**
       
    50  * Release the addrinfo resources associated with the given result
       
    51  */
       
    52 void resolve_result_deinit (struct resolve_result *res);
       
    53 
       
    54 /**
       
    55  * Returns a pointer to a static buffer containing a string description of the given addrinfo
       
    56  */
       
    57 const char * resolve_addr_text (const struct addrinfo *addr);
       
    58 
       
    59 #endif /* RESOLVE_H */