RULI Resolver API

This page documents the API for the asynchronous, stub, DNS resolver used internally by RULI.

The resolver interface operates asynchronously in an event-driven fashion. The application registers a callback function prior to submitting the desired query. Actually, the callback function is an argument for the query. When the answer arrives, the resolver asynchronously dispatches the registered callback passing the proper result.

This resolver API is not tied to SRV records. It's a general-purpose library aimed at querying recursive DNS servers. However, the resource records provided in the server answer are not interpreted; it's up to the application to handle them.

The asynchronous event management interface used here is provided by the excellent Liboop library.


Main Entry Points

int ruli_res_new(ruli_res_t *res_ctx);
void ruli_res_delete(ruli_res_t *res_ctx);
int ruli_res_query_submit(ruli_res_t *res_ctx, ruli_res_query_t *res_qry);
void ruli_res_query_delete(ruli_res_query_t *res_qry);

Auxiliary Functions

const char *ruli_res_errstr(int result);
int ruli_get_qtype_code(const char *qt_name);
int ruli_get_qclass_code(const char *qc_name);
const char *ruli_get_qtype_name(int qt_code);
const char *ruli_get_qclass_name(int qc_code);

Types

/* Opaque resolver context */

typedef struct {
  oop_source  *res_source;      /* event source */
  ruli_list_t *res_server_list; /* list of in_addr* */
  int         res_retry;        /* retry limit for each server */
  int         res_timeout;      /* query timeout for each server */
} ruli_res_t;


struct ruli_res_query_t;
typedef struct ruli_res_query_t ruli_res_query_t;


typedef void *(*ruli_res_query_call_t)(ruli_res_query_t *qry,
				       void *arg);

/* Opaque query context */

struct ruli_res_query_t {
  /* 
   * input
   */
  ruli_res_query_call_t q_on_answer;      /* query callback function */
  void                  *q_on_answer_arg; /* query callback opaque argument */
  char                  *q_domain;        /* query domain (encoded, uncompressed) */
  int                   q_domain_len;     /* domain length */
  int                   q_class;          /* query class (encoded, uncompressed) */
  int                   q_type;           /* query type */

  /* 
   * output
   */
  char              *answer_buf;
  int               answer_buf_size;
  int               answer_msg_len;
  int               answer_code;
  ruli_msg_header_t answer_header;
};

Functions


int ruli_res_new(ruli_res_t *res_ctx);

Input parameters
void ruli_res_delete(ruli_res_t *res_ctx);


int ruli_res_query_submit(ruli_res_t *res_ctx, ruli_res_query_t *res_qry);

Input parameters Output parameters
void ruli_res_query_delete(ruli_res_query_t *res_qry);


const char *ruli_res_errstr(int result);


int ruli_get_qtype_code(const char *qt_name);


int ruli_get_qclass_code(const char *qc_name);


const char *ruli_get_qtype_name(int qt_code);


const char *ruli_get_qclass_name(int qc_code);


$Id: resolver-api.html,v 1.6 2003/01/21 02:43:00 evertonm Exp $