pdns  4.5.1
About: PowerDNS daemon - a high performance authoritative nameserver.
  Fossies Dox: pdns-4.5.1.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

PacketHandler Class Reference

#include <packethandler.hh>

Collaboration diagram for PacketHandler:
[legend]

Public Member Functions

std::unique_ptr< DNSPacketdoQuestion (DNSPacket &)
 hand us a DNS packet with a question, we give you an answer More...
 
std::unique_ptr< DNSPacketquestion (DNSPacket &)
 hand us a DNS packet with a question, we give you an answer More...
 
 PacketHandler ()
  More...
 
 ~PacketHandler ()
  More...
 
UeberBackendgetBackend ()
 Returns the number of running PacketHandlers. Called by Distributor. More...
 
int trySuperMasterSynchronous (const DNSPacket &p, const DNSName &tsigkeyname)
  More...
 

Static Public Member Functions

static int numRunning ()
  More...
 

Static Public Attributes

static NetmaskGroup s_allowNotifyFrom
  More...
 
static set< string > s_forwardNotify
  More...
 
static bool s_SVCAutohints {false}
  More...
 
static const std::shared_ptr< CDNSKEYRecordContents_deleteCDNSKEYContent = std::make_shared<CDNSKEYRecordContent>("0 3 0 AA==")
  More...
 
static const std::shared_ptr< CDSRecordContents_deleteCDSContent = std::make_shared<CDSRecordContent>("0 0 0 00")
  More...
 

Private Member Functions

int trySuperMaster (const DNSPacket &p, const DNSName &tsigkeyname)
  More...
 
int processNotify (const DNSPacket &)
  More...
 
void addRootReferral (DNSPacket &r)
 
int doChaosRequest (const DNSPacket &p, std::unique_ptr< DNSPacket > &r, DNSName &target) const
  More...
 
bool addDNSKEY (DNSPacket &p, std::unique_ptr< DNSPacket > &r)
 This adds DNSKEY records to the answer packet. More...
 
bool addCDNSKEY (DNSPacket &p, std::unique_ptr< DNSPacket > &r)
 This adds CDNSKEY records to the answer packet. More...
 
bool addCDS (DNSPacket &p, std::unique_ptr< DNSPacket > &r)
 This adds CDS records to the answer packet r. More...
 
bool addNSEC3PARAM (const DNSPacket &p, std::unique_ptr< DNSPacket > &r)
 This adds NSEC3PARAM records. More...
 
void doAdditionalProcessing (DNSPacket &p, std::unique_ptr< DNSPacket > &r)
  More...
 
DNSName doAdditionalServiceProcessing (const DNSName &firstTarget, const uint16_t &qtype, std::unique_ptr< DNSPacket > &r, vector< DNSZoneRecord > &extraRecords)
  More...
 
vector< ComboAddressgetIPAddressFor (const DNSName &target, const uint16_t qtype)
 Get all IPv4 or IPv6 addresses (based on |qtype|) for |target|. More...
 
void addNSECX (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target, const DNSName &wildcard, int mode)
  More...
 
void addNSEC (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target, const DNSName &wildcard, int mode)
  More...
 
bool getNSEC3Hashes (bool narrow, const std::string &hashed, bool decrement, DNSName &unhashed, std::string &before, std::string &after, int mode=0)
  More...
 
void addNSEC3 (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target, const DNSName &wildcard, const NSEC3PARAMRecordContent &nsec3param, bool narrow, int mode)
  More...
 
void emitNSEC (std::unique_ptr< DNSPacket > &r, const DNSName &name, const DNSName &next, int mode)
  More...
 
void emitNSEC3 (std::unique_ptr< DNSPacket > &r, const NSEC3PARAMRecordContent &ns3rc, const DNSName &unhashed, const string &begin, const string &end, int mode)
  More...
 
int processUpdate (DNSPacket &p)
  More...
 
int forwardPacket (const string &msgPrefix, const DNSPacket &p, const DomainInfo &di)
  More...
 
uint performUpdate (const string &msgPrefix, const DNSRecord *rr, DomainInfo *di, bool isPresigned, bool *narrow, bool *haveNSEC3, NSEC3PARAMRecordContent *ns3pr, bool *updatedSerial)
  More...
 
int checkUpdatePrescan (const DNSRecord *rr)
  More...
 
int checkUpdatePrerequisites (const DNSRecord *rr, DomainInfo *di)
  More...
 
void increaseSerial (const string &msgPrefix, const DomainInfo *di, const string &soaEditSetting, bool haveNSEC3, bool narrow, const NSEC3PARAMRecordContent *ns3pr)
  More...
 
void makeNXDomain (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target, const DNSName &wildcard)
  More...
 
void makeNOError (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target, const DNSName &wildcard, int mode)
  More...
 
vector< DNSZoneRecordgetBestReferralNS (DNSPacket &p, const DNSName &target)
  More...
 
vector< DNSZoneRecordgetBestDNAMESynth (DNSPacket &p, DNSName &target)
  More...
 
bool tryDNAME (DNSPacket &p, std::unique_ptr< DNSPacket > &r, DNSName &target)
  More...
 
bool tryReferral (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target, bool retargeted)
  More...
 
bool getBestWildcard (DNSPacket &p, const DNSName &target, DNSName &wildcard, vector< DNSZoneRecord > *ret)
  More...
 
bool tryWildcard (DNSPacket &p, std::unique_ptr< DNSPacket > &r, DNSName &target, DNSName &wildcard, bool &retargeted, bool &nodata)
  More...
 
bool addDSforNS (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &dsname)
  More...
 
void completeANYRecords (DNSPacket &p, std::unique_ptr< DNSPacket > &r, const DNSName &target)
  More...
 
void tkeyHandler (const DNSPacket &p, std::unique_ptr< DNSPacket > &r)
  More...
 

Private Attributes

bool d_logDNSDetails
  More...
 
bool d_doDNAME
  More...
 
bool d_doExpandALIAS
  More...
 
bool d_dnssec
  More...
 
SOAData d_sd
  More...
 
std::unique_ptr< AuthLua4d_pdl
  More...
 
std::unique_ptr< AuthLua4d_update_policy_lua
  More...
 
UeberBackend B
  More...
 
DNSSECKeeper d_dk
  More...
 

Static Private Attributes

static AtomicCounter s_count
  More...
 
static std::mutex s_rfc2136lock
  More...
 

Detailed Description

Definition at line 52 of file packethandler.hh.

Member Function Documentation

◆ addCDNSKEY()

bool PacketHandler::addCDNSKEY ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r 
)
private

This adds CDNSKEY records to the answer packet.

Returns true if one was added.

Parameters
pPointer to the DNSPacket containing the original question
rPointer to the DNSPacket where the records should be inserted into
Returns
bool that shows if any records were added

Definition at line 112 of file packethandler.cc.

References arg(), DNSZoneRecord::auth, B, QType::CDNSKEY, DNSRecord::d_content, d_dk, DNSRecord::d_name, d_sd, DNSRecord::d_ttl, DNSRecord::d_type, SOAData::domain_id, DNSZoneRecord::dr, UeberBackend::get(), DNSSECKeeper::getEntryPoints(), DNSSECKeeper::getPublishCDNSKEY(), UeberBackend::lookup(), SOAData::minimum, DNSPacket::qdomain, and s_deleteCDNSKEYContent.

Referenced by completeANYRecords(), and doQuestion().

◆ addCDS()

bool PacketHandler::addCDS ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r 
)
private

This adds CDS records to the answer packet r.

Parameters
pPointer to the DNSPacket containing the original question.
rPointer to the DNSPacket where the records should be inserted into. used to determine record TTL.
Returns
bool that shows if any records were added.

Definition at line 201 of file packethandler.cc.

References arg(), DNSZoneRecord::auth, B, QType::CDS, DNSRecord::d_content, d_dk, DNSRecord::d_name, d_sd, DNSRecord::d_ttl, DNSRecord::d_type, SOAData::domain_id, DNSZoneRecord::dr, UeberBackend::get(), DNSSECKeeper::getEntryPoints(), DNSSECKeeper::getPublishCDS(), UeberBackend::lookup(), makeDSFromDNSKey(), SOAData::minimum, pdns_stou(), DNSPacket::qdomain, s_deleteCDSContent, and stringtok().

Referenced by completeANYRecords(), and doQuestion().

◆ addDNSKEY()

bool PacketHandler::addDNSKEY ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r 
)
private

This adds DNSKEY records to the answer packet.

Returns true if one was added.

Parameters
pPointer to the DNSPacket containing the original question
rPointer to the DNSPacket where the records should be inserted into
Returns
bool that shows if any records were added

Definition at line 161 of file packethandler.cc.

References arg(), DNSZoneRecord::auth, B, DNSRecord::d_content, d_dk, DNSRecord::d_name, d_sd, DNSRecord::d_ttl, DNSRecord::d_type, QType::DNSKEY, SOAData::domain_id, DNSZoneRecord::dr, UeberBackend::get(), DNSSECKeeper::getKeys(), UeberBackend::lookup(), SOAData::minimum, and DNSPacket::qdomain.

Referenced by completeANYRecords(), and doQuestion().

◆ addDSforNS()

bool PacketHandler::addDSforNS ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName dsname 
)
private

◆ addNSEC()

void PacketHandler::addNSEC ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target,
const DNSName wildcard,
int  mode 
)
private

◆ addNSEC3()

void PacketHandler::addNSEC3 ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target,
const DNSName wildcard,
const NSEC3PARAMRecordContent nsec3param,
bool  narrow,
int  mode 
)
private

◆ addNSEC3PARAM()

bool PacketHandler::addNSEC3PARAM ( const DNSPacket p,
std::unique_ptr< DNSPacket > &  r 
)
private

◆ addNSECX()

void PacketHandler::addNSECX ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target,
const DNSName wildcard,
int  mode 
)
private

◆ checkUpdatePrerequisites()

◆ checkUpdatePrescan()

◆ completeANYRecords()

void PacketHandler::completeANYRecords ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target 
)
private

◆ doAdditionalProcessing()

◆ doAdditionalServiceProcessing()

DNSName PacketHandler::doAdditionalServiceProcessing ( const DNSName firstTarget,
const uint16_t &  qtype,
std::unique_ptr< DNSPacket > &  r,
vector< DNSZoneRecord > &  extraRecords 
)
private

◆ doChaosRequest()

◆ doQuestion()

std::unique_ptr< DNSPacket > PacketHandler::doQuestion ( DNSPacket p)

hand us a DNS packet with a question, we give you an answer

Called by the Distributor to ask a question. Returns 0 in case of an error.

Definition at line 1255 of file packethandler.cc.

References QType::A, QType::AAAA, addCDNSKEY(), addCDS(), addDNSKEY(), addNSEC(), addNSEC3PARAM(), addRRSigs(), QType::ALIAS, QType::ANY, QClass::ANY, DNSZoneRecord::auth, B, ERCode::BADVERS, QType::CDNSKEY, QType::CDS, QClass::CHAOS, DNSPacket::checkForCorrectTSIG(), QType::CNAME, completeANYRecords(), DNSPacket::couldBeCached(), DNSPacket::d, TSIGRecordContent::d_algoName, DNSRecord::d_content, d_dk, d_dnssec, DNSPacket::d_dnssecOk, d_doExpandALIAS, DNSPacket::d_havetsig, d_logDNSDetails, TSIGRecordContent::d_mac, DNSRecord::d_name, DNSPacket::d_remote, d_sd, DNSPacket::d_tcp, DNSPacket::d_tsig_algo, DNSRecord::d_type, DLOG, QType::DNSKEY, doAdditionalProcessing(), doChaosRequest(), DNSSECKeeper::doesDNSSEC(), SOAData::domain_id, DP, DNSZoneRecord::dr, QType::DS, DNSName::empty(), AuthPacketCache::enabled(), Logger::Error, g_anyToTcp, g_log, UeberBackend::get(), UeberBackend::getAuth(), Netmask::getBits(), QType::getCode(), DNSPacket::getEDNSVersion(), DNSSECKeeper::getFromMeta(), DNSPacket::getMinTTL(), DNSSECKeeper::getNSEC3PARAM(), DNSPacket::getRealRemote(), DNSPacket::getRemote(), getTSIGHashEnum(), DNSPacket::hasEDNS(), QClass::IN, StatBag::inc(), Logger::Info, AuthPacketCache::insert(), DNSSECKeeper::isPresigned(), DNSSECKeeper::isSecuredZone(), QType::IXFR, UeberBackend::lookup(), QType::LUA, luaSynth(), makeEditedDNSZRFromSOAData(), makeNOError(), makeNXDomain(), RCode::NotAuth, Opcode::Notify, RCode::NotImp, QType::NS, QType::NSEC, QType::NSEC3PARAM, PC, processNotify(), processUpdate(), DNSPacket::qclass, DNSPacket::qdomain, SOAData::qname, DNSPacket::qtype, PDNSException::reason, RCode::Refused, DNSPacket::replyPacket(), StatBag::ringAccount(), QType::RRSIG, S, DNSZoneRecord::scopeMask, RCode::ServFail, DNSPacket::setTSIGDetails(), QType::SOA, QType::TKEY, tkeyHandler(), QType::toString(), DNSName::trimToLabels(), tryDNAME(), tryReferral(), tryWildcard(), Opcode::Update, validDNSName(), and Logger::Warning.

Referenced by question().

◆ emitNSEC()

◆ emitNSEC3()

◆ forwardPacket()

◆ getBackend()

UeberBackend * PacketHandler::getBackend ( )

Returns the number of running PacketHandlers. Called by Distributor.

Definition at line 94 of file packethandler.cc.

References B.

Referenced by CommunicatorClass::doNotifications(), CommunicatorClass::masterUpdateCheck(), and CommunicatorClass::slaveRefresh().

◆ getBestDNAMESynth()

◆ getBestReferralNS()

vector< DNSZoneRecord > PacketHandler::getBestReferralNS ( DNSPacket p,
const DNSName target 
)
private

◆ getBestWildcard()

◆ getIPAddressFor()

vector< ComboAddress > PacketHandler::getIPAddressFor ( const DNSName target,
const uint16_t  qtype 
)
private

Get all IPv4 or IPv6 addresses (based on |qtype|) for |target|.

Definition at line 584 of file packethandler.cc.

References QType::A, QType::AAAA, B, d_sd, SOAData::domain_id, DNSZoneRecord::dr, UeberBackend::get(), and UeberBackend::lookup().

Referenced by doAdditionalProcessing().

◆ getNSEC3Hashes()

bool PacketHandler::getNSEC3Hashes ( bool  narrow,
const std::string &  hashed,
bool  decrement,
DNSName unhashed,
std::string &  before,
std::string &  after,
int  mode = 0 
)
private

◆ increaseSerial()

◆ makeNOError()

void PacketHandler::makeNOError ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target,
const DNSName wildcard,
int  mode 
)
private

◆ makeNXDomain()

void PacketHandler::makeNXDomain ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target,
const DNSName wildcard 
)
private

◆ numRunning()

static int PacketHandler::numRunning ( )
inlinestatic

Definition at line 59 of file packethandler.hh.

References s_count.

◆ performUpdate()

uint PacketHandler::performUpdate ( const string &  msgPrefix,
const DNSRecord rr,
DomainInfo di,
bool  isPresigned,
bool *  narrow,
bool *  haveNSEC3,
NSEC3PARAMRecordContent ns3pr,
bool *  updatedSerial 
)
private

◆ processNotify()

◆ processUpdate()

int PacketHandler::processUpdate ( DNSPacket p)
private

Definition at line 643 of file rfc2136handler.cc.

References DNSBackend::abortTransaction(), NetmaskGroup::addMask(), DNSResourceRecord::ANSWER, QType::ANY, QClass::ANY, arg(), DNSResourceRecord::AUTHORITY, B, DomainInfo::backend, checkUpdatePrerequisites(), checkUpdatePrescan(), DNSSECKeeper::clearMetaCache(), QType::CNAME, DNSBackend::commitTransaction(), Communicator, DNSPacket::d, MOADNSParser::d_answers, DNSRecord::d_class, d_dk, DNSPacket::d_havetsig, MOADNSParser::d_header, DNSRecord::d_name, DNSRecord::d_place, DNSPacket::d_remote, DNSRecord::d_ttl, DNSRecord::d_type, d_update_policy_lua, Logger::Debug, StatBag::deposit(), QType::ENT, Logger::Error, RCode::FormErr, forwardPacket(), DNSResourceRecord::fromWire(), g_log, DNSBackend::get(), QType::getCode(), UeberBackend::getDomainInfo(), UeberBackend::getDomainMetadata(), DNSSECKeeper::getNSEC3PARAM(), DNSPacket::getRemote(), DNSSECKeeper::getSoaEdit(), DNSPacket::getString(), DNSPacket::getTSIGDetails(), dnsheader::id, DomainInfo::id, QClass::IN, increaseSerial(), Logger::Info, DNSName::isPartOf(), DNSSECKeeper::isPresigned(), itoa(), DomainInfo::kind, DNSBackend::lookup(), DomainInfo::Master, NetmaskGroup::match(), RCode::NoError, QClass::NONE, RCode::NotAuth, CommunicatorClass::notifyDomain(), RCode::NotImp, RCode::NotZone, QType::NS, RCode::NXRRSet, performUpdate(), purgeAuthCaches(), DNSPacket::qclass, dnsheader::qdcount, DNSPacket::qdomain, DNSResourceRecord::qtype, DNSPacket::qtype, RCode::Refused, QType::RRSIG, S, s_rfc2136lock, RCode::ServFail, DomainInfo::Slave, QType::SOA, DNSBackend::startTransaction(), stringtok(), RCode::to_s(), DNSName::toLogString(), ComboAddress::toString(), QType::toString(), DNSName::toString(), DNSResourceRecord::ttl, SSqlException::txtReason(), Logger::Warning, and DomainInfo::zone.

Referenced by doQuestion().

◆ question()

std::unique_ptr< DNSPacket > PacketHandler::question ( DNSPacket p)

hand us a DNS packet with a question, we give you an answer

Definition at line 1107 of file packethandler.cc.

References DNSPacket::d, d_pdl, doQuestion(), StatBag::getPointer(), and S.

◆ tkeyHandler()

◆ tryDNAME()

bool PacketHandler::tryDNAME ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
DNSName target 
)
private

Definition at line 1205 of file packethandler.cc.

References DNSResourceRecord::ANSWER, d_doDNAME, DLOG, g_log, getBestDNAMESynth(), and Logger::Warning.

Referenced by doQuestion().

◆ tryReferral()

bool PacketHandler::tryReferral ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
const DNSName target,
bool  retargeted 
)
private

◆ trySuperMaster()

int PacketHandler::trySuperMaster ( const DNSPacket p,
const DNSName tsigkeyname 
)
private

◆ trySuperMasterSynchronous()

◆ tryWildcard()

bool PacketHandler::tryWildcard ( DNSPacket p,
std::unique_ptr< DNSPacket > &  r,
DNSName target,
DNSName wildcard,
bool &  retargeted,
bool &  nodata 
)
private

Definition at line 1220 of file packethandler.cc.

References addNSECX(), DNSResourceRecord::ANSWER, QType::CNAME, d_dnssec, DLOG, g_log, and getBestWildcard().

Referenced by doQuestion().


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