Strophe  0.10
XMPP client library
Data Structures | Macros | Functions
resolver.c File Reference

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)
 
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. More...
 
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. More...
 
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(). More...
 
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; \
} \
} while (0)

Function Documentation

◆ resolver_raw_srv_lookup_buf()

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 
)
static

◆ resolver_initialize()

void resolver_initialize ( void  )

◆ resolver_shutdown()

void resolver_shutdown ( void  )

◆ resolver_srv_list_sort()

static 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
ctxa Strophe context object
bufmessage in RFC1035 format
lenlength of the message
srv_rr_listis 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
ctxa Strophe context object
serviceservice of the SRV record
protoprotocol of the SRV record
domainresolving domain
srv_rr_listis 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
ctxa Strophe context object
srv_rr_lista list allocated by lookup functions

◆ xmpp_ntohs_ptr()

static uint16_t xmpp_ntohs_ptr ( const void *  ptr)
static

◆ message_header_qr()

static uint8_t message_header_qr ( const struct message_header header)
static

◆ message_header_rcode()

static uint8_t message_header_rcode ( const struct message_header header)
static

◆ message_name_append_safe()

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

◆ message_name_get()

static 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()

static unsigned message_name_len ( const unsigned char *  buf,
size_t  buf_len,
unsigned  buf_offset 
)
static
XMPP_DOMAIN_NOT_FOUND
@ XMPP_DOMAIN_NOT_FOUND
Definition: resolver.h:23