reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
/home/runner/work/resiprocate/resiprocate/rutil/DnsUtil.hxx

based on RFC 1884

based on RFC 1884

Data addr("5f1b:df00:ce3e:e200:20:800:2b37:6426");
cerr << "!! "<< addr << endl;
resip_assert(DnsUtil::isIpV6Address(addr));
#define resip_assert(x)
This file needs to work for both C and C++ code.
#if !defined(RESIP_DNSUTIL_HXX)
#define RESIP_DNSUTIL_HXX
#include <list>
#include "rutil/Socket.hxx"
#include "rutil/Data.hxx"
#ifndef WIN32
#include <netinet/in.h>
#else
#include <Ws2tcpip.h>
#endif
struct in_addr;
struct in6_addr;
namespace resip
{
class Tuple;
class DnsUtil
{
public:
class Exception final : public BaseException
{
public:
Exception(const Data& msg,
const Data& file,
const int line)
: BaseException(msg, file, line) {}
protected:
const char* name() const noexcept override { return "DnsUtil::Exception"; }
};
static const Data& getLocalHostName();
static Data getLocalDomainName();
static Data getLocalIpAddress(const Data& defaultInterface=Data::Empty) ;
// returns pair of interface name, ip address
static std::list<std::pair<Data,Data> > getInterfaces(const Data& matchingInterface=Data::Empty);
// wrappers for the not so ubiquitous inet_pton, inet_ntop (e.g. WIN32)
static Data inet_ntop(const struct in_addr& addr);
static Data inet_ntop(const struct sockaddr& addr);
static int inet_pton(const Data& printableIp, struct in_addr& dst);
static bool isIpAddress(const Data& ipAddress);
static bool isIpV4Address(const Data& ipAddress);
static bool isIpV6Address(const Data& ipAddress);
#ifdef IPPROTO_IPV6
static Data inet_ntop(const struct in6_addr& addr);
static int inet_pton(const Data& printableIp, struct in6_addr& dst);
#endif
//pass-throughs when supported, actual implemenation in the WIN32 case
static const char * inet_ntop(int af, const void* src, char* dst, size_t size);
#ifdef __APPLE__
static const Data UInt8ToStr[256];
#endif // __APPLE__
static int inet_pton(int af, const char * src, void * dst);
// so string (case) comparison will work
// or something
static Data canonicalizeIpV6Address(const Data& ipV6Address);
static std::list<Data> lookupARecords(const Data& host);
private:
static Data lookupLocalHostName();
};
}
#endif
/* ====================================================================
* The Vovida Software License, Version 1.0
*
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
* and "Vovida Open Communication Application Library (VOCAL)" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact vocal@vovida.org.
*
* 4. Products derived from this software may not be called "VOCAL", nor
* may "VOCAL" appear in their name, without prior written
* permission of Vovida Networks, Inc.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* ====================================================================
*
* This software consists of voluntary contributions made by Vovida
* Networks, Inc. and many individuals on behalf of Vovida Networks,
* Inc. For more information on Vovida Networks, Inc., please see
* <http://www.vovida.org/>.
*
*/
Handles cross-platform sockets compatibility.
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
const char * name() const noexcept override
Definition DnsUtil.hxx:39
static bool isIpV6Address(const Data &ipAddress)
Definition DnsUtil.cxx:386
static Data canonicalizeIpV6Address(const Data &ipV6Address)
Converts the printable form of an IPv6 address into consistent format so that string comparisons will...
Definition DnsUtil.cxx:427
static Data getLocalDomainName()
Definition DnsUtil.cxx:187
static std::list< std::pair< Data, Data > > getInterfaces(const Data &matchingInterface=Data::Empty)
Definition DnsUtil.cxx:460
static bool isIpAddress(const Data &ipAddress)
Definition DnsUtil.cxx:453
static const Data & getLocalHostName()
Definition DnsUtil.cxx:118
static int inet_pton(const Data &printableIp, struct in_addr &dst)
Convert from the presentation format of the IPv4 address to struct in_addr.
Definition DnsUtil.cxx:275
static Data inet_ntop(const struct in_addr &addr)
Converts from the network format to presentation format.
Definition DnsUtil.cxx:240
static bool isIpV4Address(const Data &ipAddress)
Definition DnsUtil.cxx:290
static std::list< Data > lookupARecords(const Data &host)
Used to synchronously query A records - only for test code usage.
Definition DnsUtil.cxx:42
static Data getLocalIpAddress(const Data &defaultInterface=Data::Empty)
Gets the IP address of "the" local interface.
Definition DnsUtil.cxx:222
dcm! – add UnusedChecking(_enum) below;