LLAres Class Reference

Asynchronous address resolver. More...

#include <llares.h>

List of all members.

Public Member Functions

 LLAres ()
 ~LLAres ()
void cancel ()
void getHostByName (const std::string &name, HostResponder *resp, int family=AF_INET)
void getHostByName (const char *name, HostResponder *resp, int family=PF_INET)
void getNameInfo (const struct sockaddr &sa, socklen_t salen, int flags, NameInfoResponder *resp)
void getSrvRecords (const std::string &name, SrvResponder *resp)
void rewriteURI (const std::string &uri, UriRewriteResponder *resp)
void search (const std::string &query, LLResType type, QueryResponder *resp)
bool process (U64 timeoutUsecs=0)
bool processAll ()

Static Public Member Functions

static int expandName (const char *encoded, const char *abuf, size_t alen, std::string &s)
static int expandName (const char *encoded, const char *abuf, size_t alen, std::string &s, size_t &enclen)
static const char * strerror (int code)

Protected Attributes

ares_channel chan_

Classes

class  HostResponder
 Base class for responding to hostname lookups. More...
class  NameInfoResponder
 Base class for responding to address lookups. More...
class  QueryResponder
 Base class for responding to custom searches. More...
class  SrvResponder
 Class for handling SRV query responses. More...
class  UriRewriteResponder
 Class for handling URI rewrites based on SRV records. More...


Detailed Description

Asynchronous address resolver.

Definition at line 277 of file llares.h.


Constructor & Destructor Documentation

LLAres::LLAres (  ) 

Definition at line 105 of file llares.cpp.

References chan_.

Referenced by ll_init_ares().

Here is the caller graph for this function:

LLAres::~LLAres (  ) 

Definition at line 111 of file llares.cpp.

References chan_.


Member Function Documentation

void LLAres::cancel (  ) 

Cancel all outstanding requests. The error methods of the corresponding responders will be called, with ARES_ETIMEOUT.

Definition at line 117 of file llares.cpp.

References chan_.

void LLAres::getHostByName ( const std::string &  name,
HostResponder resp,
int  family = AF_INET 
) [inline]

Look up the address of a host.

Parameters:
name name of host to look up
resp responder to call with result
family AF_INET for IPv4 addresses, AF_INET6 for IPv6

Definition at line 342 of file llares.h.

void LLAres::getHostByName ( const char *  name,
HostResponder resp,
int  family = PF_INET 
)

Look up the address of a host.

Parameters:
name name of host to look up
resp responder to call with result
family AF_INET for IPv4 addresses, AF_INET6 for IPv6

Definition at line 138 of file llares.cpp.

References chan_, host_callback(), and LLAres::HostResponder::hostError().

Here is the call graph for this function:

void LLAres::getNameInfo ( const struct sockaddr &  sa,
socklen_t  salen,
int  flags,
NameInfoResponder resp 
)

Look up the name associated with a socket address.

Parameters:
sa socket address to look up
salen size of socket address
flags flags to use
resp responder to call with result

Definition at line 407 of file llares.cpp.

References chan_, nameinfo_callback(), and LLAres::NameInfoResponder::nameInfoError().

Here is the call graph for this function:

void LLAres::getSrvRecords ( const std::string &  name,
SrvResponder resp 
)

Look up SRV (service location) records for a service name.

Parameters:
name service name (e.g. "_https._tcp.login.agni.lindenlab.com")
resp responder to call with result

Definition at line 150 of file llares.cpp.

References RES_SRV, and search().

Here is the call graph for this function:

void LLAres::rewriteURI ( const std::string &  uri,
UriRewriteResponder resp 
)

Rewrite a URI, using SRV (service location) records for its protocol if available. If no SRV records are published, the existing URI is handed to the responder.

Parameters:
uri URI to rewrite
resp responder to call with result

Definition at line 155 of file llares.cpp.

References LLURI::hostName(), LL_DEBUGS2, LL_ENDL, LLAres::UriRewriteResponder::mUri, RES_SRV, LLURI::scheme(), and search().

Referenced by LLSRV::rewriteURI().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLAres::search ( const std::string &  query,
LLResType  type,
QueryResponder resp 
)

Start a custom search.

Parameters:
query query to make
type type of query to perform
resp responder to call with result

Definition at line 435 of file llares.cpp.

References chan_, LLAres::QueryResponder::queryError(), and search_callback().

Referenced by getSrvRecords(), and rewriteURI().

Here is the call graph for this function:

Here is the caller graph for this function:

bool LLAres::process ( U64  timeoutUsecs = 0  ) 

Process any outstanding queries. This method takes an optional timeout parameter (specified in microseconds). If provided, it will block the calling thread for that length of time to await possible responses. A timeout of zero will return immediately if there are no responses or timeouts to process.

Parameters:
timeoutUsecs number of microseconds to block before timing out
Returns:
whether any responses were processed

Definition at line 447 of file llares.cpp.

References chan_, gAPRPoolp, i, ll_apr_assert_status(), ll_apr_warn_status(), ll_init_apr(), NULL, and indra::ipc::saranwrap::status().

Referenced by LLAppViewer::mainLoop(), and processAll().

Here is the call graph for this function:

Here is the caller graph for this function:

bool LLAres::processAll (  ) 

Process all outstanding queries, blocking the calling thread until all have either been responded to or timed out.

Returns:
whether any responses were processed

Definition at line 536 of file llares.cpp.

References chan_, NULL, and process().

Referenced by LLSRV::rewriteURI().

Here is the call graph for this function:

Here is the caller graph for this function:

static int LLAres::expandName ( const char *  encoded,
const char *  abuf,
size_t  alen,
std::string &  s 
) [inline, static]

Expand a DNS-encoded compressed string into a normal string.

Parameters:
encoded the encoded name (null-terminated)
abuf the response buffer in which the string is embedded
alen the length of the response buffer
s the string into which to place the result
Returns:
ARES_SUCCESS on success, otherwise an error indicator

Definition at line 426 of file llares.h.

Referenced by LLHostRecord::parse(), LLQueryResponder::parseRR(), and LLQueryResponder::queryResult().

Here is the caller graph for this function:

int LLAres::expandName ( const char *  encoded,
const char *  abuf,
size_t  alen,
std::string &  s,
size_t &  enclen 
) [static]

Definition at line 560 of file llares.cpp.

const char * LLAres::strerror ( int  code  )  [static]

Return a string describing an error code.

Definition at line 578 of file llares.cpp.

Referenced by LLAres::HostResponder::hostError(), LLAres::NameInfoResponder::nameInfoError(), LLAres::QueryResponder::queryError(), and LLAres::SrvResponder::srvError().

Here is the caller graph for this function:


Member Data Documentation

ares_channel LLAres::chan_ [protected]

Definition at line 441 of file llares.h.

Referenced by cancel(), getHostByName(), getNameInfo(), LLAres(), process(), processAll(), search(), and ~LLAres().


The documentation for this class was generated from the following files:

Generated on Fri May 16 08:39:07 2008 for SecondLife by  doxygen 1.5.5