Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qdnslookup_unix.cpp File Reference
#include "qdnslookup_p.h"
#include <qendian.h>
#include <qscopedpointer.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 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)
 

Variables

static constexpr qsizetype ReplyBufferSize = 1280 - 40 - 8
 
static constexpr unsigned char Edns0Record []
 
static constexpr qsizetype QueryBufferSize
 

Macro Definition Documentation

◆ T_OPT

#define T_OPT   ns_t_opt

Definition at line 29 of file qdnslookup_unix.cpp.

Typedef Documentation

◆ Cache

using Cache = QList<QDnsCachedName>

Definition at line 64 of file qdnslookup_unix.cpp.

◆ EnableIfIPv6

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

Definition at line 93 of file qdnslookup_unix.cpp.

◆ QueryBuffer

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

Definition at line 53 of file qdnslookup_unix.cpp.

Function Documentation

◆ applyNameServer()

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

Definition at line 124 of file qdnslookup_unix.cpp.

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

+ Here is the call graph for this function:

◆ prepareQueryBuffer()

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

Definition at line 139 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  )

◆ setIpv6NameServer() [1/2]

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

Definition at line 118 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 96 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 87 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 79 of file qdnslookup_unix.cpp.

References ext.

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 ReplyBufferSize
#define T_OPT

Definition at line 40 of file qdnslookup_unix.cpp.

Referenced by prepareQueryBuffer().

◆ QueryBufferSize

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

Definition at line 51 of file qdnslookup_unix.cpp.

◆ ReplyBufferSize

constexpr qsizetype ReplyBufferSize = 1280 - 40 - 8
staticconstexpr

Definition at line 37 of file qdnslookup_unix.cpp.