reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
resip::DnsUtil Class Reference

Provides a collection of utility functions for manipulating DNS names and IP addresses and discovering details about the local interfaces. More...

#include <DnsUtil.hxx>

Classes

class  Exception
 

Static Public Member Functions

static const Data & getLocalHostName ()
 
static Data getLocalDomainName ()
 
static Data getLocalIpAddress (const Data &defaultInterface=Data::Empty)
 Gets the IP address of "the" local interface.
 
static std::list< std::pair< Data, Data > > getInterfaces (const Data &matchingInterface=Data::Empty)
 
static Data inet_ntop (const struct in_addr &addr)
 Converts from the network format to presentation format.
 
static Data inet_ntop (const struct sockaddr &addr)
 Converts from the network format to presentation format.
 
static int inet_pton (const Data &printableIp, struct in_addr &dst)
 Convert from the presentation format of the IPv4 address to struct in_addr.
 
static bool isIpAddress (const Data &ipAddress)
 
static bool isIpV4Address (const Data &ipAddress)
 
static bool isIpV6Address (const Data &ipAddress)
 
static const char * inet_ntop (int af, const void *src, char *dst, size_t size)
 Converts from the network format to presentation format.
 
static int inet_pton (int af, const char *src, void *dst)
 Converts from the presentation format to network format.
 
static Data canonicalizeIpV6Address (const Data &ipV6Address)
 Converts the printable form of an IPv6 address into consistent format so that string comparisons will do what you expect.
 
static std::list< Data > lookupARecords (const Data &host)
 Used to synchronously query A records - only for test code usage.
 

Detailed Description

Provides a collection of utility functions for manipulating DNS names and IP addresses and discovering details about the local interfaces.

Definition at line 28 of file DnsUtil.hxx.

Member Function Documentation

◆ canonicalizeIpV6Address()

Data DnsUtil::canonicalizeIpV6Address ( const Data &  ipV6Address)
static

Converts the printable form of an IPv6 address into consistent format so that string comparisons will do what you expect.

For instance, XXXX:0:0:0:YYYY:192.168.2.233 will be converted to XXXX::::YYYY:192.168.2.233. Currently, this is realized by (inet_ntop(inet_pton(input)).

Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 427 of file DnsUtil.cxx.

◆ getInterfaces()

std::list< std::pair< Data, Data > > DnsUtil::getInterfaces ( const Data &  matchingInterface = Data::Empty)
static
Returns
a list of interface name, IP addresses pairs of all available interfaces (note that some of these may be v4 and others v6.
Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 460 of file DnsUtil.cxx.

◆ getLocalDomainName()

Data DnsUtil::getLocalDomainName ( )
static
Returns
the suffix after the first "." in whatever getLocalHostName returns
Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 187 of file DnsUtil.cxx.

◆ getLocalHostName()

const Data & DnsUtil::getLocalHostName ( )
static
Returns
the fully qualified local host name as the host currently knows it ala gethostname(3)
Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 118 of file DnsUtil.cxx.

◆ getLocalIpAddress()

Data DnsUtil::getLocalIpAddress ( const Data &  defaultInterface = Data::Empty)
static

Gets the IP address of "the" local interface.

Note that this will not work on systems with more than one ethernet interface.

Deprecated:
Very few real systems have only one interface (loopback plus physical, vpns, wireless and wired, etc.) Use getInterfaces instead.
Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 222 of file DnsUtil.cxx.

◆ inet_ntop() [1/3]

Data DnsUtil::inet_ntop ( const struct in_addr &  addr)
static

Converts from the network format to presentation format.

That is, it converts from struct in_addr to character representation of the IPv4 address.

Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 240 of file DnsUtil.cxx.

◆ inet_ntop() [2/3]

Data DnsUtil::inet_ntop ( const struct sockaddr &  addr)
static

Converts from the network format to presentation format.

Converts from struct sockaddr to character representation of the IPv4 address.

Definition at line 258 of file DnsUtil.cxx.

◆ inet_ntop() [3/3]

const char * DnsUtil::inet_ntop ( int  af,
const void *  src,
char *  dst,
size_t  size 
)
static

Converts from the network format to presentation format.

Parameters
afthe address family (AF_INET, AF_INET6)
srcthe address of the networking representation to be converted (often of type struct in_addr *)
dstthe address where presentation format will be stored

@size the size of the dst

Definition at line 637 of file DnsUtil.cxx.

◆ inet_pton() [1/2]

int DnsUtil::inet_pton ( const Data &  printableIp,
struct in_addr &  dst 
)
static

Convert from the presentation format of the IPv4 address to struct in_addr.

Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 275 of file DnsUtil.cxx.

◆ inet_pton() [2/2]

int DnsUtil::inet_pton ( int  af,
const char *  src,
void *  dst 
)
static

Converts from the presentation format to network format.

Parameters
afthe address family (AF_INET, AF_INET6)
srcthe address of the presentation representation to be converted
dstthe address where presentation format will be stored (struct in_addr *, or struct in_addr6 *)

Definition at line 663 of file DnsUtil.cxx.

◆ isIpAddress()

bool DnsUtil::isIpAddress ( const Data &  ipAddress)
static

◆ isIpV4Address()

bool DnsUtil::isIpV4Address ( const Data &  ipAddress)
static

◆ isIpV6Address()

bool DnsUtil::isIpV6Address ( const Data &  ipAddress)
static

◆ lookupARecords()

list< Data > DnsUtil::lookupARecords ( const Data &  host)
static

Used to synchronously query A records - only for test code usage.

Examples
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx.

Definition at line 42 of file DnsUtil.cxx.


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