srv_resolv.cc File Reference

implements SRV DNS resolving More...

#include "jabberd.h"
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include "srv_resolv.h"

Data Structures

struct  __srv_list
 representation of a SRV DNS record More...

Defines

#define BIND_8_COMPAT

Typedefs

typedef struct __srv_listsrv_list
 representation of a SRV DNS record
typedef struct __srv_list _srv_list

Functions

char * srv_inet_ntoa (pool p, unsigned char *addrptr)
char * srv_port2str (pool p, unsigned short port)
void srv_xhash_join (pool p, xht ht, const char *key, char *value)
char * srv_lookup (pool p, const char *service, const char *domain)

Detailed Description

implements SRV DNS resolving

This file implements resolving of services in the DNS using the protocol defined in RFC 2782.


Define Documentation

#define BIND_8_COMPAT

Typedef Documentation

typedef struct __srv_list _srv_list
typedef struct __srv_list * srv_list

representation of a SRV DNS record

This structure is used to build an ordered double linked list of SRV DNS records for a service on a domain


Function Documentation

char* srv_inet_ntoa ( pool  p,
unsigned char *  addrptr 
)

convert an IPv4 (AF_INET) address to its textual representation using memory pools

Parameters:
p the pool to be used
addrptr the address that should be printed
Returns:
the address as a string

References pstrdup().

Referenced by srv_lookup().

char* srv_lookup ( pool  p,
const char *  service,
const char *  domain 
)

do a DNS lookup

This function implements a SRV DNS lookup and falls back to normal AAAA/A resolution if no service has been given by the caller.

Parameters:
p memory pool to be used by this function
service which service should be looked up (e.g. "_xmpp-server._tcp")
domain which domain should be looked up
Returns:
comma separated list of results containing IPv4 and IPv6 addresses with or without ports
Todo:
The function honors the priority values of a SRV record but not the weight values. Implement handling of weights!

References __srv_list::host, j_strlen(), __srv_list::last, log_debug2, LOGT_IO, __srv_list::next, pmalloco(), __srv_list::port, __srv_list::priority, pstrdup(), srv_inet_ntoa(), srv_port2str(), srv_xhash_join(), xhash_get(), xhash_new(), and ZONE.

Referenced by dnsrv_child_process_xstream_io().

char* srv_port2str ( pool  p,
unsigned short  port 
)

convert a (numerical) port number to a string using memory pools

Parameters:
p the pool to be used
port the port that should be converted
Returns:
the port number as a string

References pmalloco().

Referenced by srv_lookup().

void srv_xhash_join ( pool  p,
xht  ht,
const char *  key,
char *  value 
)

put a value in an xhash and join it with the previous value if there has been already one in the hash

If there is no entry for this key, the function just enters the value. If there is already an entry for this key, the function will append a "," and the old value to the new value and insert it into the hash.

Parameters:
p memory pool to be used
ht the hash table
key the key in the hash
value the value that should be inserted

References pstrdup(), xhash_get(), and xhash_put().

Referenced by srv_lookup().

Generated on Fri Sep 3 06:00:05 2010 for jabberd14 by  doxygen 1.6.3