Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdnslookup_unix.cpp File Reference

(e3f520e621a9ea631d8a1d2f9bfc7a5f20dc698a)

#include "qdnslookup_p.h"
#include <qendian.h>
#include <qscopedpointer.h>
#include <qspan.h>
#include <qurl.h>
#include <qvarlengtharray.h>
#include <private/qnativesocketengine_p.h>
#include <private/qtnetwork-config_p.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <resolv.h>
#include <array>
+ Include dependency graph for qdnslookup_unix.cpp:

Go to the source code of this file.

Macros

#define T_OPT   ns_t_opt
 

Typedefs

using ReplyBuffer = QDnsLookupRunnable::ReplyBuffer
 
using QueryBuffer = std::array<unsigned char, (QueryBufferSize + 15) / 16 * 16>
 
using Cache = QList<QDnsCachedName>
 
template<bool Condition>
using EnableIfIPv6 = std::enable_if_t<Condition, const QHostAddress *>
 

Functions

 QT_REQUIRE_CONFIG (libresolv)
 
 Q_DECLARE_TYPEINFO (QDnsCachedName, Q_RELOCATABLE_TYPE)
 
template<typename T >
void setNsMap (T &ext, std::enable_if_t< sizeof(T::nsmap) !=0, uint16_t > v)
 
template<typename T >
void setNsMap (T &,...)
 
template<typename State >
bool setIpv6NameServer (State *state, EnableIfIPv6< sizeof(std::declval< State >()._u._ext.nsaddrs) !=0 > addr, quint16 port)
 
template<typename State >
bool setIpv6NameServer (State *, const void *, quint16)
 
static bool applyNameServer (res_state state, const QHostAddress &nameserver, quint16 port)
 
static int prepareQueryBuffer (res_state state, QueryBuffer &buffer, const char *label, ns_rcode type)
 
static int sendStandardDns (QDnsLookupReply *reply, res_state state, QSpan< unsigned char > qbuffer, ReplyBuffer &buffer, const QHostAddress &nameserver, quint16 port)
 

Variables

static constexpr unsigned char Edns0Record []
 
static constexpr qsizetype QueryBufferSize
 

Macro Definition Documentation

◆ T_OPT

#define T_OPT   ns_t_opt

Definition at line 30 of file qdnslookup_unix.cpp.

Typedef Documentation

◆ Cache

using Cache = QList<QDnsCachedName>

Definition at line 63 of file qdnslookup_unix.cpp.

◆ EnableIfIPv6

template<bool Condition>
using EnableIfIPv6 = std::enable_if_t<Condition, const QHostAddress *>

Definition at line 90 of file qdnslookup_unix.cpp.

◆ QueryBuffer

using QueryBuffer = std::array<unsigned char, (QueryBufferSize + 15) / 16 * 16>

Definition at line 52 of file qdnslookup_unix.cpp.

◆ ReplyBuffer

Function Documentation

◆ applyNameServer()

static bool applyNameServer ( res_state state,
const QHostAddress & nameserver,
quint16 port )
static

Definition at line 121 of file qdnslookup_unix.cpp.

References QAbstractSocket::IPv6Protocol, QHostAddress::protocol(), setIpv6NameServer(), and state.

Referenced by sendStandardDns().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareQueryBuffer()

static int prepareQueryBuffer ( res_state state,
QueryBuffer & buffer,
const char * label,
ns_rcode type )
static

Definition at line 133 of file qdnslookup_unix.cpp.

References Edns0Record, Q_ASSERT, Q_UNLIKELY, and state.

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( QDnsCachedName ,
Q_RELOCATABLE_TYPE  )

◆ QT_REQUIRE_CONFIG()

QT_REQUIRE_CONFIG ( libresolv )

◆ sendStandardDns()

static int sendStandardDns ( QDnsLookupReply * reply,
res_state state,
QSpan< unsigned char > qbuffer,
ReplyBuffer & buffer,
const QHostAddress & nameserver,
quint16 port )
static

Definition at line 150 of file qdnslookup_unix.cpp.

References applyNameServer(), Edns0Record, header(), QHostAddress::isNull(), Q_UNLIKELY, qt_error_string(), reply, QDnsLookup::ResolverError, QDnsLookup::ServerRefusedError, QNetworkReply::setError(), and state.

+ Here is the call graph for this function:

◆ setIpv6NameServer() [1/2]

template<typename State >
bool setIpv6NameServer ( State * ,
const void * ,
quint16  )

Definition at line 115 of file qdnslookup_unix.cpp.

◆ setIpv6NameServer() [2/2]

template<typename State >
bool setIpv6NameServer ( State * state,
EnableIfIPv6< sizeof(std::declval< State >()._u._ext.nsaddrs) !=0 > addr,
quint16 port )

Definition at line 93 of file qdnslookup_unix.cpp.

References Q_CHECK_PTR(), setNsMap(), and state.

Referenced by applyNameServer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNsMap() [1/2]

template<typename T >
void setNsMap ( T & ,
... )

Definition at line 84 of file qdnslookup_unix.cpp.

◆ setNsMap() [2/2]

template<typename T >
void setNsMap ( T & ext,
std::enable_if_t< sizeof(T::nsmap) !=0, uint16_t > v )

Definition at line 76 of file qdnslookup_unix.cpp.

Referenced by setIpv6NameServer().

+ Here is the caller graph for this function:

Variable Documentation

◆ Edns0Record

constexpr unsigned char Edns0Record[]
staticconstexpr
Initial value:
= {
0x00,
T_OPT >> 8, T_OPT & 0xff,
NOERROR,
0,
0x00, 0x00,
0x00, 0x00,
}
static constexpr qsizetype PreallocatedSize
#define T_OPT

Definition at line 39 of file qdnslookup_unix.cpp.

Referenced by prepareQueryBuffer(), and sendStandardDns().

◆ QueryBufferSize

constexpr qsizetype QueryBufferSize
staticconstexpr
Initial value:
=
HFIXEDSZ + QFIXEDSZ + MAXCDNAME + 1 + sizeof(Edns0Record)
static constexpr unsigned char Edns0Record[]

Definition at line 50 of file qdnslookup_unix.cpp.