CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dns Namespace Reference

Namespaces

 anonymous_namespace{dns.cc}
 

Classes

class  Host
 
class  Resolver
 
class  CaresResolver
 
class  HostfileResolver
 
class  NormalResolver
 

Enumerations

enum  Failures {
  kFailOk = 0, kFailInvalidResolvers, kFailTimeout, kFailInvalidHost,
  kFailUnknownHost, kFailMalformed, kFailNoAddress, kFailNotYetResolved,
  kFailOther, kFailNumEntries
}
 
enum  IpPreference { kIpPreferSystem = 0, kIpPreferV4, kIpPreferV6 }
 

Functions

static void PinpointHostSubstr (const std::string &url, unsigned *pos_begin, unsigned *pos_end)
 
std::string ExtractHost (const std::string &url)
 
std::string ExtractPort (const std::string &url)
 
string RewriteUrl (const string &url, const string &ip)
 
string StripIp (const string &decorated_ip)
 
std::string AddDefaultScheme (const std::string &proxy)
 
static Failures CaresExtractIpv4 (const unsigned char *abuf, int alen, vector< string > *addresses, unsigned *ttl, string *fqdn)
 
static Failures CaresExtractIpv6 (const unsigned char *abuf, int alen, vector< string > *addresses, unsigned *ttl, string *fqdn)
 
static void CallbackCares (void *arg, int status, int timeouts_ms, unsigned char *abuf, int alen)
 
static bool SortNameLength (const string &a, const string &b)
 
const char * Code2Ascii (const Failures error)
 
std::string RewriteUrl (const std::string &url, const std::string &ip)
 
std::string StripIp (const std::string &decorated_ip)
 

Detailed Description

This file is part of the CernVM File System.

Enumeration Type Documentation

Possible errors when trying to resolve a host name.

Enumerator
kFailOk 
kFailInvalidResolvers 
kFailTimeout 
kFailInvalidHost 
kFailUnknownHost 

Resolver returned a negative reply.

kFailMalformed 
kFailNoAddress 

Resolver returned a positive reply but without IPs.

kFailNotYetResolved 
kFailOther 
kFailNumEntries 

Definition at line 28 of file dns.h.

Steers IP protocol selection.

Enumerator
kIpPreferSystem 
kIpPreferV4 
kIpPreferV6 

Definition at line 46 of file dns.h.

Function Documentation

std::string dns::AddDefaultScheme ( const std::string &  proxy)

Adds http:// if it is missing from proxy

Definition at line 187 of file dns.cc.

Referenced by download::DownloadManager::SetProxyChain().

Here is the call graph for this function:

Here is the caller graph for this function:

static void dns::CallbackCares ( void *  arg,
int  status,
int  timeouts_ms,
unsigned char *  abuf,
int  alen 
)
static

Called when a DNS query returns or times out. Sets the return status and the IP addresses (if successful) in the QueryInfo object.

Definition at line 564 of file dns.cc.

Referenced by dns::CaresResolver::DoResolve().

Here is the call graph for this function:

Here is the caller graph for this function:

static Failures dns::CaresExtractIpv4 ( const unsigned char *  abuf,
int  alen,
vector< string > *  addresses,
unsigned *  ttl,
string *  fqdn 
)
static

Extracts IPv4 addresses from an A record return in c-ares. TTLs are merged to a single one, representing the minimum.

Definition at line 617 of file dns.cc.

Referenced by CallbackCares().

Here is the caller graph for this function:

static Failures dns::CaresExtractIpv6 ( const unsigned char *  abuf,
int  alen,
vector< string > *  addresses,
unsigned *  ttl,
string *  fqdn 
)
static

Definition at line 668 of file dns.cc.

Referenced by CallbackCares().

Here is the caller graph for this function:

const char* dns::Code2Ascii ( const Failures  error)
inline

Definition at line 53 of file dns.h.

Referenced by dns::Resolver::ResolveMany(), download::DownloadManager::SetProxyChain(), and download::DownloadManager::ValidateProxyIpsUnlocked().

Here is the caller graph for this function:

std::string dns::ExtractHost ( const std::string &  url)

Returns the host name from a string in the format http://<hostname>:<port>[/path] or an empty string if url doesn't match the format.

Definition at line 110 of file dns.cc.

Referenced by download::DownloadManager::GeoSortServers(), s3fanout::S3FanoutManager::InitializeDnsSettings(), download::DownloadManager::ProbeGeo(), and download::DownloadManager::SetProxyChain().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string dns::ExtractPort ( const std::string &  url)

Returns the port from a string in the format http://<hostname>:<port>/path or an empty string if url doesn't match the format.

Definition at line 125 of file dns.cc.

Referenced by s3fanout::S3FanoutManager::InitializeDnsSettings().

Here is the call graph for this function:

Here is the caller graph for this function:

static void dns::PinpointHostSubstr ( const std::string &  url,
unsigned *  pos_begin,
unsigned *  pos_end 
)
static

Sets pos_begin and pos_end to the first/last character of the host name in a string like http://<hostname>:<port>. Works also if the host name is an IPv4/6 address. Sets pos_begin and pos_end to 0 if url doesn't match the format.

Definition at line 53 of file dns.cc.

Referenced by ExtractHost(), ExtractPort(), and RewriteUrl().

Here is the caller graph for this function:

std::string dns::RewriteUrl ( const std::string &  url,
const std::string &  ip 
)
string dns::RewriteUrl ( const string &  url,
const string &  ip 
)

Replaces the host name in the url with the given IP address. If it is an IPv6 address, it has to be in brackets. If the input is not a valid URL, it is returned unmodified.

Definition at line 156 of file dns.cc.

Referenced by download::DownloadManager::SetProxyChain(), and download::DownloadManager::ValidateProxyIpsUnlocked().

Here is the call graph for this function:

Here is the caller graph for this function:

static bool dns::SortNameLength ( const string &  a,
const string &  b 
)
static

Used to process longer domain names before shorter ones, in order to get the correct fully qualified domain name. Reversed return value in order to sort in descending order.

Definition at line 1082 of file dns.cc.

Referenced by dns::HostfileResolver::DoResolve().

Here is the caller graph for this function:

std::string dns::StripIp ( const std::string &  decorated_ip)
string dns::StripIp ( const string &  decorated_ip)

Removes the brackets from IPv6 addresses. Leaves IPv4 addresses unchanged.

Definition at line 172 of file dns.cc.