resolver.c File Reference

DNS resolver. More...

## Data Structures

struct | message_header

## Macros

#define | MESSAGE_HEADER_LEN 12
#define | MESSAGE_RESPONSE 1
#define | MESSAGE_T_SRV 33
#define | MESSAGE_C_IN 1
#define | RESOLVER_BUF_MAX 65536
#define | BUF_OVERFLOW_CHECK(ptr, len)

## Functions

static int | resolver_raw_srv_lookup_buf (xmpp_ctx_t *ctx, const unsigned char *buf, size_t len, resolver_srv_rr_t **srv_rr_list)
void | resolver_initialize (void)
void | resolver_shutdown (void)
resolver_srv_rr_t * | resolver_srv_rr_new (xmpp_ctx_t *ctx, const char *host, unsigned short port, unsigned short prio, unsigned short weight)
static void | resolver_srv_list_sort (resolver_srv_rr_t **srv_rr_list)
int | resolver_srv_lookup_buf (xmpp_ctx_t *ctx, const unsigned char *buf, size_t len, resolver_srv_rr_t **srv_rr_list)
| Perform lookup for RFC1035 message format.
int | resolver_srv_lookup (xmpp_ctx_t *ctx, const char *service, const char *proto, const char *domain, resolver_srv_rr_t **srv_rr_list)
| Resolve SRV record.
void | resolver_srv_free (xmpp_ctx_t *ctx, resolver_srv_rr_t *srv_rr_list)
| Release a list returned by resolver_srv_lookup() or resolver_srv_lookup_buf().
static uint16_t | xmpp_ntohs_ptr (const void *ptr)
static uint8_t | message_header_qr (const struct message_header *header)
static uint8_t | message_header_rcode (const struct message_header *header)
static size_t | message_name_append_safe (char *name, size_t name_len, size_t name_max, const char *tail, size_t tail_len)
static unsigned | message_name_get (const unsigned char *buf, size_t buf_len, unsigned buf_offset, char *name, size_t name_max)
static unsigned | message_name_len (const unsigned char *buf, size_t buf_len, unsigned buf_offset)

## Detailed Description

DNS resolver.

## Macro Definition Documentation

## MESSAGE_HEADER_LEN

#define MESSAGE_HEADER_LEN 12

## MESSAGE_RESPONSE

#define MESSAGE_RESPONSE 1

## MESSAGE_T_SRV

#define MESSAGE_T_SRV 33

## MESSAGE_C_IN

#define MESSAGE_C_IN 1

## RESOLVER_BUF_MAX

#define RESOLVER_BUF_MAX 65536

## BUF_OVERFLOW_CHECK

#define BUF_OVERFLOW_CHECK | ( |  | ptr,
|  |  | len )

Value:
do { \
if ((ptr) >= (len)) { \
if (*srv_rr_list != NULL) \
resolver_srv_free(ctx, *srv_rr_list); \
*srv_rr_list = NULL; \
return XMPP_DOMAIN_NOT_FOUND; \
} \
} while (0)
XMPP_DOMAIN_NOT_FOUND
@ XMPP_DOMAIN_NOT_FOUND
Definition resolver.h:24

## Function Documentation

## resolver_raw_srv_lookup_buf()

int resolver_raw_srv_lookup_buf | ( | xmpp_ctx_t * | ctx,
|  | const unsigned char * | buf,
|  | size_t | len,
|  | resolver_srv_rr_t ** | srv_rr_list )

static

## resolver_initialize()

void resolver_initialize | ( | void |  | ) |

## resolver_shutdown()

void resolver_shutdown | ( | void |  | ) |

## resolver_srv_rr_new()

resolver_srv_rr_t * resolver_srv_rr_new | ( | xmpp_ctx_t * | ctx,
|  | const char * | host,
|  | unsigned short | port,
|  | unsigned short | prio,
|  | unsigned short | weight )

## resolver_srv_list_sort()

void resolver_srv_list_sort | ( | resolver_srv_rr_t ** | srv_rr_list | ) |

static

## resolver_srv_lookup_buf()

int resolver_srv_lookup_buf | ( | xmpp_ctx_t * | ctx,
|  | const unsigned char * | buf,
|  | size_t | len,
|  | resolver_srv_rr_t ** | srv_rr_list )

Perform lookup for RFC1035 message format.

This function allocates all elements.

Parameters

  ctx | a Strophe context object
  buf | message in RFC1035 format
  len | length of the message
  srv_rr_list | is the result

Returns
  XMPP_DOMAIN_FOUND on success or XMPP_DOMAIN_NOT_FOUND on fail

## resolver_srv_lookup()

int resolver_srv_lookup | ( | xmpp_ctx_t * | ctx,
|  | const char * | service,
|  | const char * | proto,
|  | const char * | domain,
|  | resolver_srv_rr_t ** | srv_rr_list )

Resolve SRV record.

Parameters

  ctx | a Strophe context object
  service | service of the SRV record
  proto | protocol of the SRV record
  domain | resolving domain
  srv_rr_list | is the result

Returns
  XMPP_DOMAIN_FOUND on success or XMPP_DOMAIN_NOT_FOUND on fail

## resolver_srv_free()

void resolver_srv_free | ( | xmpp_ctx_t * | ctx,
|  | resolver_srv_rr_t * | srv_rr_list )

Release a list returned by resolver_srv_lookup() or resolver_srv_lookup_buf().

Parameters

  ctx | a Strophe context object
  srv_rr_list | a list allocated by lookup functions

## xmpp_ntohs_ptr()

uint16_t xmpp_ntohs_ptr | ( | const void * | ptr | ) |

static

## message_header_qr()

uint8_t message_header_qr | ( | const struct message_header * | header | ) |

static

## message_header_rcode()

uint8_t message_header_rcode | ( | const struct message_header * | header | ) |

static

## message_name_append_safe()

size_t message_name_append_safe | ( | char * | name,
|  | size_t | name_len,
|  | size_t | name_max,
|  | const char * | tail,
|  | size_t | tail_len )

static

## message_name_get()

unsigned message_name_get | ( | const unsigned char * | buf,
|  | size_t | buf_len,
|  | unsigned | buf_offset,
|  | char * | name,
|  | size_t | name_max )

static

## message_name_len()

unsigned message_name_len | ( | const unsigned char * | buf,
|  | size_t | buf_len,
|  | unsigned | buf_offset )

static