dns_internal.cc File Reference
#include "squid.h"
#include "base/InstanceId.h"
#include "base/RunnersRegistry.h"
#include "comm.h"
#include "comm/Connection.h"
#include "comm/ConnOpener.h"
#include "comm/Loops.h"
#include "comm/Read.h"
#include "comm/Write.h"
#include "dlink.h"
#include "dns/forward.h"
#include "dns/rfc3596.h"
#include "event.h"
#include "fd.h"
#include "fde.h"
#include "ip/tools.h"
#include "MemBuf.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "util.h"
#include "wordlist.h"
#include "snmp_core.h"
#include <cerrno>
#include <random>
Include dependency graph for dns_internal.cc:

Go to the source code of this file.

Classes

class  idns_query
 
class  nsvc
 
class  ns
 
class  Dns::ConfigRr
 manage DNS internal component More...
 
struct  _sp
 

Namespaces

 Dns
 generic DNS API
 

Macros

#define _PATH_RESCONF   "/etc/resolv.conf"
 
#define NS_DEFAULTPORT   53
 
#define NS_MAXDNAME   1025
 
#define MAXDNSRCH   6
 
#define RESOLV_BUFSZ   NS_MAXDNAME * MAXDNSRCH + sizeof("search ") + 1
 
#define IDNS_MAX_TRIES   20
 
#define MAX_RCODE   17
 
#define MAX_ATTEMPT   3
 

Typedefs

typedef struct _sp sp
 

Functions

 InstanceIdDefinitions (idns_query,"dns")
 
 Dns::RunnerRegistrationEntry (ConfigRr)
 
static void idnsAddNameserver (const char *buf)
 
static void idnsAddMDNSNameservers ()
 
static void idnsAddPathComponent (const char *buf)
 
static void idnsFreeSearchpath (void)
 
static bool idnsParseNameservers (void)
 
static bool idnsParseResolvConf (void)
 
static void idnsStartQuery (idns_query *q, IDNSCB *callback, void *data)
 
static void idnsSendQuery (idns_query *q)
 
static void idnsDoSendQueryVC (nsvc *vc)
 
static int idnsFromKnownNameserver (Ip::Address const &from)
 
static idns_queryidnsFindQuery (unsigned short id)
 
static void idnsGrokReply (const char *buf, size_t sz, int from_ns)
 
static void idnsTickleQueue (void)
 
static void idnsRcodeCount (int, int)
 
static unsigned short idnsQueryID (void)
 
static void idnsSendSlaveAAAAQuery (idns_query *q)
 
static void idnsCallbackOnEarlyError (IDNSCB *callback, void *cbdata, const char *error)
 
static void idnsCheckMDNS (idns_query *q)
 
static void idnsStats (StoreEntry *sentry)
 
static void idnsSentQueryVC (const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int, void *data)
 
static void idnsInitVCConnected (const Comm::ConnectionPointer &conn, Comm::Flag status, int, void *data)
 
static void idnsVCClosed (const CommCloseCbParams &params)
 
static void idnsInitVC (size_t nsv)
 
static void idnsSendQueryVC (idns_query *q, size_t nsn)
 
static bool idnsStillPending (const idns_query *master)
 
static std::ostream & operator<< (std::ostream &os, const idns_query &answered)
 
static bool idnsCallbackOneWithAnswer (IDNSCB *callback, void *cbdata, const idns_query &answered, const bool lastAnswer)
 safely sends one set of DNS records (or an error) to the caller More...
 
static void idnsCallbackNewCallerWithOldAnswers (IDNSCB *callback, void *cbdata, const idns_query *const master)
 
static void idnsCallbackAllCallersWithNewAnswer (const idns_query *const answered, const bool lastAnswer)
 
static void idnsCallback (idns_query *q, const char *error)
 
static void idnsRead (int fd, void *)
 
static void idnsCheckQueue (void *)
 
static void idnsReadVC (const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int, void *data)
 
static void idnsReadVCHeader (const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int, void *data)
 
static void idnsShutdownAndFreeState (const char *reason)
 
static int idnsCachedLookup (const char *key, IDNSCB *callback, void *data)
 
void idnsALookup (const char *name, IDNSCB *callback, void *data)
 
void idnsPTRLookup (const Ip::Address &addr, IDNSCB *callback, void *data)
 
variable_listsnmp_netDnsFn (variable_list *Var, snint *ErrP)
 

Variables

static int RcodeMatrix [MAX_RCODE][MAX_ATTEMPT]
 
static const char * Rcodes []
 
static std::vector< nsnameservers
 
static spsearchpath = NULL
 
static int nns_mdns_count = 0
 
static int npc = 0
 
static int npc_alloc = 0
 
static int ndots = 1
 
static dlink_list lru_list
 
static int event_queued = 0
 
static hash_tableidns_lookup_hash = NULL
 
static OBJH idnsStats
 
static IOCB idnsReadVCHeader
 
static CNCB idnsInitVCConnected
 
static IOCB idnsReadVC
 
static IOCB idnsSentQueryVC
 
static PF idnsRead
 
static EVH idnsCheckQueue
 
static CLCB idnsVCClosed
 

Macro Definition Documentation

#define _PATH_RESCONF   "/etc/resolv.conf"

Definition at line 55 of file dns_internal.cc.

Referenced by idnsParseResolvConf().

#define IDNS_MAX_TRIES   20

Definition at line 74 of file dns_internal.cc.

#define MAX_ATTEMPT   3

Definition at line 76 of file dns_internal.cc.

Referenced by idnsGrokReply(), idnsRcodeCount(), and idnsStats().

#define MAX_RCODE   17

Definition at line 75 of file dns_internal.cc.

Referenced by idnsRcodeCount(), and idnsStats().

#define MAXDNSRCH   6

Definition at line 66 of file dns_internal.cc.

#define NS_DEFAULTPORT   53

Definition at line 58 of file dns_internal.cc.

Referenced by idnsAddNameserver().

#define NS_MAXDNAME   1025

Definition at line 62 of file dns_internal.cc.

Referenced by idnsALookup().

#define RESOLV_BUFSZ   NS_MAXDNAME * MAXDNSRCH + sizeof("search ") + 1

Definition at line 71 of file dns_internal.cc.

Referenced by idnsParseResolvConf().

Typedef Documentation

typedef struct _sp sp

Definition at line 99 of file dns_internal.cc.

Function Documentation

static void idnsAddMDNSNameservers ( )
static
static void idnsAddPathComponent ( const char *  buf)
static

Definition at line 352 of file dns_internal.cc.

References assert, debugs, _sp::domain, npc, npc_alloc, safe_free, searchpath, Tolower(), and xcalloc.

Referenced by idnsParseResolvConf().

static int idnsCachedLookup ( const char *  key,
IDNSCB callback,
void *  data 
)
static
static void idnsCallback ( idns_query q,
const char *  error 
)
static
static void idnsCallbackAllCallersWithNewAnswer ( const idns_query *const  answered,
const bool  lastAnswer 
)
static

Definition at line 1113 of file dns_internal.cc.

References debugs, idnsCallbackOneWithAnswer(), and idns_query::master.

Referenced by idnsCallback().

static void idnsCallbackNewCallerWithOldAnswers ( IDNSCB callback,
void *  cbdata,
const idns_query *const  master 
)
static

Definition at line 1100 of file dns_internal.cc.

References idnsCallbackOneWithAnswer(), and idns_query::slave.

Referenced by idnsCachedLookup().

static void idnsCallbackOnEarlyError ( IDNSCB callback,
void *  cbdata,
const char *  error 
)
static

Definition at line 1079 of file dns_internal.cc.

References callback, and debugs.

Referenced by idnsALookup(), and idnsPTRLookup().

static bool idnsCallbackOneWithAnswer ( IDNSCB callback,
void *  cbdata,
const idns_query answered,
const bool  lastAnswer 
)
static
static void idnsCheckMDNS ( idns_query q)
static
static idns_query * idnsFindQuery ( unsigned short  id)
static
static void idnsFreeSearchpath ( void  )
static

Definition at line 381 of file dns_internal.cc.

References npc, npc_alloc, and safe_free.

Referenced by idnsParseResolvConf(), and idnsShutdownAndFreeState().

static int idnsFromKnownNameserver ( Ip::Address const &  from)
static

Definition at line 1004 of file dns_internal.cc.

References i, and Ip::Address::port().

Referenced by idnsRead().

static void idnsInitVCConnected ( const Comm::ConnectionPointer conn,
Comm::Flag  status,
int  ,
void *  data 
)
static
static bool idnsParseNameservers ( void  )
static

Definition at line 388 of file dns_internal.cc.

References Config, DBG_IMPORTANT, debugs, SquidConfig::dns, i, and idnsAddNameserver().

Referenced by Dns::Init().

static bool idnsParseResolvConf ( void  )
static
static unsigned short idnsQueryID ( void  )
static
static void idnsRcodeCount ( int  rcode,
int  attempt 
)
static

Definition at line 1514 of file dns_internal.cc.

References MAX_ATTEMPT, MAX_RCODE, and RcodeMatrix.

Referenced by idnsGrokReply().

static void idnsReadVCHeader ( const Comm::ConnectionPointer conn,
char *  buf,
size_t  len,
Comm::Flag  flag,
int  ,
void *  data 
)
static
static void idnsSendQueryVC ( idns_query q,
size_t  nsn 
)
static
static void idnsSentQueryVC ( const Comm::ConnectionPointer conn,
char *  ,
size_t  size,
Comm::Flag  flag,
int  ,
void *  data 
)
static
static void idnsShutdownAndFreeState ( const char *  reason)
static
static void idnsStartQuery ( idns_query q,
IDNSCB callback,
void *  data 
)
static
static bool idnsStillPending ( const idns_query master)
static
Returns
whether master or associated queries are still waiting for replies

Definition at line 1058 of file dns_internal.cc.

References assert, idns_query::master, and idns_query::slave.

Referenced by idnsCachedLookup(), and idnsCallback().

static void idnsTickleQueue ( void  )
static
static void idnsVCClosed ( const CommCloseCbParams params)
static

Definition at line 866 of file dns_internal.cc.

References CommCommonCbParams::data.

InstanceIdDefinitions ( idns_query  ,
"dns"   
)
static std::ostream& operator<< ( std::ostream &  os,
const idns_query answered 
)
static

Definition at line 1069 of file dns_internal.cc.

References idns_query::ancount, and idns_query::error.

Variable Documentation

int event_queued = 0
static

Definition at line 222 of file dns_internal.cc.

Referenced by idnsCheckQueue(), and idnsTickleQueue().

hash_table* idns_lookup_hash = NULL
static

Definition at line 223 of file dns_internal.cc.

EVH idnsCheckQueue
static

Definition at line 276 of file dns_internal.cc.

Referenced by idnsTickleQueue().

CNCB idnsInitVCConnected
static

Definition at line 268 of file dns_internal.cc.

Referenced by idnsInitVC().

PF idnsRead
static

Definition at line 275 of file dns_internal.cc.

Referenced by idnsRead(), and Dns::Init().

IOCB idnsReadVC
static

Definition at line 269 of file dns_internal.cc.

Referenced by idnsReadVC(), and idnsReadVCHeader().

IOCB idnsReadVCHeader
static

Definition at line 266 of file dns_internal.cc.

Referenced by idnsInitVCConnected(), idnsReadVC(), and idnsReadVCHeader().

IOCB idnsSentQueryVC
static

Definition at line 270 of file dns_internal.cc.

Referenced by idnsDoSendQueryVC().

OBJH idnsStats
static

Definition at line 253 of file dns_internal.cc.

Referenced by Dns::Init().

CLCB idnsVCClosed
static

Definition at line 279 of file dns_internal.cc.

Referenced by idnsInitVCConnected().

dlink_list lru_list
static

Definition at line 221 of file dns_internal.cc.

std::vector<ns> nameservers
static

Definition at line 215 of file dns_internal.cc.

int ndots = 1
static

Definition at line 220 of file dns_internal.cc.

Referenced by idnsALookup(), and idnsParseResolvConf().

int nns_mdns_count = 0
static

Definition at line 217 of file dns_internal.cc.

Referenced by idnsAddMDNSNameservers(), and idnsSendQuery().

int npc_alloc = 0
static

Definition at line 219 of file dns_internal.cc.

Referenced by idnsAddPathComponent(), and idnsFreeSearchpath().

int RcodeMatrix[MAX_RCODE][MAX_ATTEMPT]
static

Definition at line 77 of file dns_internal.cc.

Referenced by idnsRcodeCount(), idnsStats(), and Dns::Init().

const char* Rcodes[]
static
Initial value:
= {
"Success",
"Packet Format Error",
"DNS Server Failure",
"Non-Existent Domain",
"Not Implemented",
"Query Refused",
"Name Exists when it should not",
"RR Set Exists when it should not",
"RR Set that should exist does not",
"Server Not Authoritative for zone",
"Name not contained in zone",
"","","","","",
"Bad OPT Version or TSIG Signature Failure"
}

Definition at line 79 of file dns_internal.cc.

Referenced by idnsStats().

sp* searchpath = NULL
static

Definition at line 216 of file dns_internal.cc.

Referenced by idnsAddPathComponent().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors