Kea  2.1.7-git
isc::dns Namespace Reference

Namespaces

 master_lexer_internal
 
 name
 
 rdata
 

Classes

class  AbstractMessageRenderer
 The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rendering a DNS message into a buffer in wire format. More...
 
class  AbstractRRset
 The AbstractRRset class is an abstract base class that models a DNS RRset. More...
 
class  BadEscape
 A standard DNS module exception that is thrown if the name parser fails to decode a back-slash escaped sequence. More...
 
class  BadLabelType
 A standard DNS module exception that is thrown if the name parser encounters an obsolete or incomplete label type. More...
 
class  BasicRRset
 The BasicRRset class is a concrete derived class of AbstractRRset that defines a straightforward RRset implementation. More...
 
class  BasicRRsetImpl
 This encapsulates the actual implementation of the BasicRRset class. More...
 
class  DefaultNSEC3HashCreator
 The default NSEC3Hash creator. More...
 
class  DNSMessageBADVERS
 
class  DNSMessageFORMERR
 
class  DNSProtocolError
 
class  DNSTextError
 Base class for all sorts of text parse errors. More...
 
class  EDNS
 The EDNS class represents the EDNS OPT RR defined in RFC2671. More...
 
class  EmptyLabel
 A standard DNS module exception that is thrown if the name parser encounters an empty label in the middle of a name. More...
 
class  EmptyRRset
 A standard DNS module exception that is thrown if an RRset object does not contain any RDATA where required. More...
 
class  Exception
 
class  IncompleteName
 A standard DNS module exception that is thrown if the name parser finds the input (string or wire-format data) is incomplete. More...
 
class  IncompleteRRClass
 A standard DNS module exception that is thrown if an RRClass object is being constructed from a incomplete (too short) wire-format data. More...
 
class  IncompleteRRTTL
 A standard DNS module exception that is thrown if an RRTTL object is being constructed from a incomplete (too short) wire-format data. More...
 
class  IncompleteRRType
 A standard DNS module exception that is thrown if an RRType object is being constructed from a incomplete (too short) wire-format data. More...
 
class  InvalidMessageOperation
 A standard DNS module exception that is thrown if a Message class method is called that is prohibited for the current mode of the message. More...
 
class  InvalidMessageSection
 A standard DNS module exception that is thrown if a section iterator is being constructed for an incompatible section. More...
 
class  InvalidMessageUDPSize
 A standard DNS module exception that is thrown if a UDP buffer size smaller than the standard default maximum (DEFAULT_MAX_UDPSIZE) is being specified for the message. More...
 
class  InvalidRRClass
 A standard DNS module exception that is thrown if an RRClass object is being constructed from an unrecognized string. More...
 
class  InvalidRRTTL
 A standard DNS module exception that is thrown if an RRTTL object is being constructed from an unrecognized string. More...
 
class  InvalidRRType
 A standard DNS module exception that is thrown if an RRType object is being constructed from an unrecognized string. More...
 
class  LabelSequence
 Light-weight Accessor to Name data. More...
 
class  MasterLexer
 Tokenizer for parsing DNS master files. More...
 
class  MasterLoader
 A class able to load DNS master files. More...
 
class  MasterLoaderCallbacks
 Set of issue callbacks for a loader. More...
 
class  MasterLoaderError
 Error while loading by MasterLoader without specifying the MANY_ERRORS option. More...
 
class  MasterLoadError
 An exception that is thrown if an error occurs while loading a master zone data. More...
 
class  MasterToken
 Tokens for MasterLexer. More...
 
class  Message
 The Message class encapsulates a standard DNS message. More...
 
class  MessageImpl
 
class  MessageRenderer
 The MessageRenderer is a concrete derived class of AbstractMessageRenderer as a general purpose implementation of the renderer interfaces. More...
 
class  MessageTooShort
 A standard DNS module exception that is thrown if a wire format message parser encounters a short length of data that don't even contain the full header section. More...
 
class  MissingNameOrigin
 Thrown when origin is NULL and is needed. More...
 
class  Name
 The Name class encapsulates DNS names. More...
 
class  NameComparisonResult
 This is a supplemental class used only as a return value of Name::compare() and LabelSequence::compare(). More...
 
class  NameParserException
 Base class for name parser exceptions. More...
 
class  NSEC3Hash
 A calculator of NSEC3 hashes. More...
 
class  NSEC3HashCreator
 Factory class of NSEC3Hash. More...
 
class  Opcode
 The Opcode class objects represent standard OPCODEs of the header section of DNS messages as defined in RFC1035. More...
 
class  QidGenerator
 This class generates Qids for outgoing queries. More...
 
class  Question
 The Question class encapsulates the common search key of DNS lookup, consisting of owner name, RR type and RR class. More...
 
class  Rcode
 DNS Response Codes (RCODEs) class. More...
 
class  RdataFactory
 
class  RdataIterator
 The RdataIterator class is an abstract base class that provides an interface for accessing RDATA objects stored in an RRset. More...
 
class  RRClass
 The RRClass class encapsulates DNS resource record classes. More...
 
class  RRClassExists
 A standard DNS module exception that is thrown if a new RR class is being registered with a different type string. More...
 
class  RRCollator
 A converter from a stream of RRs to a stream of collated RRsets. More...
 
class  RRParamRegistry
 The RRParamRegistry class represents a registry of parameters to manipulate DNS resource records (RRs). More...
 
struct  RRParamRegistryImpl
 The RRParamRegistryImpl class is the actual implementation of RRParamRegistry. More...
 
class  RRset
 The RRset class is a concrete derived class of BasicRRset which contains a pointer to an additional RRset containing associated RRSIG records. More...
 
class  RRsetCollection
 libdns++ implementation of RRsetCollectionBase using an STL container. More...
 
class  RRsetCollectionBase
 Generic class to represent a set of RRsets. More...
 
class  RRsetCollectionError
 Error during RRsetCollectionBase find() operation. More...
 
class  RRTTL
 The RRTTL class encapsulates TTLs used in DNS resource records. More...
 
class  RRType
 The RRType class encapsulates DNS resource record types. More...
 
class  RRTypeExists
 A standard DNS module exception that is thrown if a new RR type is being registered with a different type string. More...
 
class  SectionIterator
 SectionIterator is a templated class to provide standard-compatible iterators for Questions and RRsets for a given DNS message section. More...
 
struct  SectionIteratorImpl
 Template version of Section Iterator. More...
 
class  Serial
 This class defines DNS serial numbers and serial arithmetic. More...
 
class  TooLongLabel
 A standard DNS module exception that is thrown if the name parser encounters too long a label. More...
 
class  TooLongName
 A standard DNS module exception that is thrown if the name parser encounters too long a name. More...
 
class  TSIGContext
 TSIG session context. More...
 
class  TSIGContextError
 An exception that is thrown for logic errors identified in TSIG sign/verify operations. More...
 
class  TSIGError
 TSIG errors. More...
 
class  TSIGKey
 TSIG key. More...
 
class  TSIGKeyRing
 A simple repository of a set of TSIGKey objects. More...
 
class  TSIGRecord
 TSIG resource record. More...
 
class  UnknownNSEC3HashAlgorithm
 An exception that is thrown for when an NSEC3Hash object is constructed with an unknown hash algorithm. More...
 
class  ZoneCheckerCallbacks
 Set of callbacks used in zone checks. More...
 

Typedefs

typedef std::function< void(const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &rrttl, const rdata::RdataPtr &rdata)> AddRRCallback
 Type of callback to add a RR. More...
 
typedef boost::shared_ptr< const EDNSConstEDNSPtr
 A pointer-like type pointing to an immutable EDNS object. More...
 
typedef boost::shared_ptr< const MessageConstMessagePtr
 
typedef boost::shared_ptr< const QuestionConstQuestionPtr
 A pointer-like type pointing to an (immutable) Question object. More...
 
typedef boost::shared_ptr< const AbstractRRsetConstRRsetPtr
 A pointer-like type pointing to an (immutable) RRset object. More...
 
typedef boost::shared_ptr< const TSIGRecordConstTSIGRecordPtr
 A pointer-like type pointing to an immutable TSIGRecord object. More...
 
typedef boost::shared_ptr< EDNSEDNSPtr
 A pointer-like type pointing to an EDNS object. More...
 
typedef map< RRType, RdataFactoryPtrGenericRdataFactoryMap
 
typedef std::function< void(RRsetPtr)> MasterLoadCallback
 The type of the callback parameter of masterLoad(). More...
 
typedef boost::shared_ptr< MessageMessagePtr
 Pointer-like type pointing to a Message. More...
 
typedef uint16_t qid_t
 
typedef SectionIterator< QuestionPtrQuestionIterator
 
typedef boost::shared_ptr< QuestionQuestionPtr
 A pointer-like type pointing to an Question object. More...
 
typedef map< RRTypeClass, RdataFactoryPtrRdataFactoryMap
 
typedef boost::shared_ptr< RdataIteratorRdataIteratorPtr
 A pointer-like type point to an RdataIterator object. More...
 
typedef boost::shared_ptr< RRsetCollectionBaseRRsetCollectionPtr
 
typedef SectionIterator< RRsetPtrRRsetIterator
 
typedef boost::shared_ptr< AbstractRRsetRRsetPtr
 A pointer-like type pointing to an RRset object. More...
 
typedef pair< RRType, RRClassRRTypeClass
 Note: the element ordering in the type/class pair is intentional. More...
 
typedef boost::shared_ptr< TSIGContextTSIGContextPtr
 
typedef boost::shared_ptr< TSIGKeyTSIGKeyPtr
 
typedef boost::shared_ptr< TSIGRecordTSIGRecordPtr
 A pointer-like type pointing to a TSIGRecord object. More...
 

Functions

bool checkZone (const Name &zone_name, const RRClass &zone_class, const RRsetCollectionBase &zone_rrsets, const ZoneCheckerCallbacks &callbacks)
 Perform basic integrity checks on zone RRsets. More...
 
EDNScreateEDNSFromRR (const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &ttl, const rdata::Rdata &rdata, uint8_t &extended_rcode)
 Create a new EDNS object from a set of RR parameters, also providing the extended RCODE value. More...
 
ostream & operator<< (std::ostream &os, const Opcode &opcode)
 Insert the Opcode as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const RRType &rrtype)
 Insert the RRType as a string into stream. More...
 
std::ostream & operator<< (std::ostream &os, const TSIGError &tsig_error)
 Insert the TSIGError as a string into stream. More...
 
std::ostream & operator<< (std::ostream &os, const Serial &serial)
 Helper operator for output streams, writes the value to the stream. More...
 
ostream & operator<< (std::ostream &os, const RRClass &rrclass)
 Insert the RRClass as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const Question &question)
 Insert the Question as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const Rcode &rcode)
 Insert the Rcode as a string into stream. More...
 
std::ostream & operator<< (std::ostream &os, const TSIGRecord &record)
 Insert the TSIGRecord as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const AbstractRRset &rrset)
 Insert the RRset as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const EDNS &edns)
 Insert the EDNS as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const RRTTL &rrttl)
 Insert the RRTTL as a string into stream. More...
 
std::ostream & operator<< (std::ostream &os, const LabelSequence &label_sequence)
 Insert the label sequence as a string into stream. More...
 
std::ostream & operator<< (std::ostream &os, const Name &name)
 Insert the name as a string into stream. More...
 
ostream & operator<< (std::ostream &os, const Message &message)
 Insert the Message as a string into stream. More...
 
MasterLexer::Options operator| (MasterLexer::Options o1, MasterLexer::Options o2)
 Operator to combine MasterLexer options. More...
 
void setNSEC3HashCreator (const NSEC3HashCreator *new_creator)
 The registrar of NSEC3HashCreator. More...
 
Master zone file loader functions.
void masterLoad (const char *const filename, const Name &origin, const RRClass &zone_class, MasterLoadCallback callback)
 Master zone file loader from a file. More...
 
void masterLoad (std::istream &input, const Name &origin, const RRClass &zone_class, MasterLoadCallback callback, const char *source=NULL)
 Master zone file loader from input stream. More...
 

Variables

const uint32_t MAX_SERIAL_INCREMENT = 2147483647
 The maximum difference between two serial numbers. More...
 
const uint64_t MAX_SERIAL_VALUE = 4294967296ull
 Maximum value a serial can have, used in + operator. More...
 
QidGenerator qid_generator_instance
 

Typedef Documentation

◆ AddRRCallback

typedef std::function<void(const Name& name, const RRClass& rrclass, const RRType& rrtype, const RRTTL& rrttl, const rdata::RdataPtr& rdata)> isc::dns::AddRRCallback

Type of callback to add a RR.

This type of callback is used by the loader to report another loaded RR. The Rdata is no longer preserved by the loader and is fully owned by the callback.

Parameters
nameThe domain name where the RR belongs.
rrclassThe class of the RR.
rrtypeType of the RR.
rrttlTime to live of the RR.
rdataThe actual carried data of the RR.

Definition at line 41 of file master_loader_callbacks.h.

◆ ConstEDNSPtr

typedef boost::shared_ptr<const EDNS> isc::dns::ConstEDNSPtr

A pointer-like type pointing to an immutable EDNS object.

Definition at line 37 of file edns.h.

◆ ConstMessagePtr

typedef boost::shared_ptr<const Message> isc::dns::ConstMessagePtr

Definition at line 663 of file message.h.

◆ ConstQuestionPtr

typedef boost::shared_ptr<const Question> isc::dns::ConstQuestionPtr

A pointer-like type pointing to an (immutable) Question object.

Definition at line 34 of file question.h.

◆ ConstRRsetPtr

typedef boost::shared_ptr<const AbstractRRset> isc::dns::ConstRRsetPtr

A pointer-like type pointing to an (immutable) RRset object.

This type is commonly used as an argument of various functions defined in this library in order to handle RRsets in a polymorphic manner.

Definition at line 60 of file rrset.h.

◆ ConstTSIGRecordPtr

typedef boost::shared_ptr<const TSIGRecord> isc::dns::ConstTSIGRecordPtr

A pointer-like type pointing to an immutable TSIGRecord object.

Definition at line 280 of file tsigrecord.h.

◆ EDNSPtr

typedef boost::shared_ptr<EDNS> isc::dns::EDNSPtr

A pointer-like type pointing to an EDNS object.

Definition at line 31 of file edns.h.

◆ GenericRdataFactoryMap

◆ MasterLoadCallback

typedef std::function<void(RRsetPtr)> isc::dns::MasterLoadCallback

The type of the callback parameter of masterLoad().

This represents a functor object or a function that takes one parameter of type RRsetPtr and returns nothing.

Definition at line 33 of file masterload.h.

◆ MessagePtr

typedef boost::shared_ptr<Message> isc::dns::MessagePtr

Pointer-like type pointing to a Message.

This type is expected to be used as an argument in asynchronous callback functions. The internal reference-counting will ensure that that ongoing state information will not be lost if the object that originated the asynchronous call falls out of scope.

Definition at line 662 of file message.h.

◆ qid_t

typedef uint16_t isc::dns::qid_t

Definition at line 75 of file message.h.

◆ QuestionIterator

Definition at line 108 of file message.h.

◆ QuestionPtr

typedef boost::shared_ptr<Question> isc::dns::QuestionPtr

A pointer-like type pointing to an Question object.

Definition at line 28 of file question.h.

◆ RdataFactoryMap

Definition at line 161 of file rrparamregistry.cc.

◆ RdataIteratorPtr

typedef boost::shared_ptr<RdataIterator> isc::dns::RdataIteratorPtr

A pointer-like type point to an RdataIterator object.

Definition at line 63 of file rrset.h.

◆ RRsetCollectionPtr

Definition at line 204 of file rrset_collection_base.h.

◆ RRsetIterator

Definition at line 109 of file message.h.

◆ RRsetPtr

typedef boost::shared_ptr<AbstractRRset> isc::dns::RRsetPtr

A pointer-like type pointing to an RRset object.

This type is commonly used as an argument of various functions defined in this library in order to handle RRsets in a polymorphic manner.

Definition at line 47 of file rrset.h.

◆ RRTypeClass

Note: the element ordering in the type/class pair is intentional.

The standard library will perform inequality comparison (i.e, '<') in the way that the second elements (RRClass) are compared only when the first elements are equivalent. In practice, when we compare two pairs of RRType and RRClass, RRClass would be the same (and, in particular, be class IN) in the majority of cases. So this comparison ordering should be more efficient in common cases.

Definition at line 160 of file rrparamregistry.cc.

◆ TSIGContextPtr

typedef boost::shared_ptr<TSIGContext> isc::dns::TSIGContextPtr

Definition at line 435 of file tsig.h.

◆ TSIGKeyPtr

typedef boost::shared_ptr<TSIGKey> isc::dns::TSIGKeyPtr

Definition at line 436 of file tsig.h.

◆ TSIGRecordPtr

typedef boost::shared_ptr<TSIGRecord> isc::dns::TSIGRecordPtr

A pointer-like type pointing to a TSIGRecord object.

Definition at line 277 of file tsigrecord.h.

Function Documentation

◆ checkZone()

bool isc::dns::checkZone ( const Name zone_name,
const RRClass zone_class,
const RRsetCollectionBase zone_rrsets,
const ZoneCheckerCallbacks callbacks 
)

Perform basic integrity checks on zone RRsets.

This function performs some lightweight checks on zone's SOA and (apex) NS records. Here, lightweight means it doesn't require traversing the entire zone, and should be expected to complete reasonably quickly regardless of the size of the zone.

It distinguishes "critical" errors and other undesirable issues: the former should be interpreted as the resulting zone shouldn't be used further, e.g, by an authoritative server implementation; the latter means the issues are better to be addressed but are not necessarily considered to make the zone invalid. Critical errors are reported via the error() method of callbacks, and non critical issues are reported via its warn() method.

Specific checks performed by this function is as follows. Failure of a check is considered a critical error unless noted otherwise:

  • There is exactly one SOA RR at the zone apex.
  • There is at least one NS RR at the zone apex.
  • For each apex NS record, if the NS name (the RDATA of the record) is in the zone (i.e., it's a subdomain of the zone origin and above any zone cut due to delegation), check the following:
    • the NS name should have an address record (AAAA or A). Failure of this check is considered a non critical issue.
    • the NS name does not have a CNAME. This is prohibited by Section 10.3 of RFC 2181.
    • the NS name is not subject to DNAME substitution. This is prohibited by Section 4 of RFC 6672.
    In addition, when the check is completed without any critical error, this function guarantees that RRsets for the SOA and (apex) NS stored in the passed RRset collection have the expected type of Rdata objects, i.e., generic::SOA and generic::NS, respectively. (This is normally expected to be the case, but not guaranteed by the API).

As for the check on the existence of AAAA or A records for NS names, it should be noted that BIND 9 treats this as a critical error. It's not clear whether it's an implementation dependent behavior or based on the protocol standard (it looks like the former), but to make it sure we need to confirm there is even no wildcard match for the names. This should be a very rare configuration, and more expensive to detect, so we do not check this condition, and treat this case as a non critical issue.

This function indicates the result of the checks (whether there is a critical error) via the return value: It returns true if there is no critical error and returns false otherwise. It doesn't throw an exception on encountering an error so that it can report as many errors as possible in a single call. If an exception is a better way to signal the error, the caller can pass a callback object that throws from its error() method.

This function can still throw an exception if it finds a really bogus condition that is most likely to be an implementation bug of the caller. Such cases include when an RRset contained in the RRset collection is empty.

Exceptions
UnexpectedConditions that suggest a caller's bug (see the description)
Parameters
zone_nameThe name of the zone to be checked
zone_classThe RR class of the zone to be checked
zone_rrsetsThe collection of RRsets of the zone
callbacksCallback object used to report errors and issues
Returns
true if no critical errors are found; false otherwise.

Definition at line 176 of file zone_checker.cc.

References isc::dns::ZoneCheckerCallbacks::warn().

Referenced by isc::dns::ZoneCheckerCallbacks::warn().

+ Here is the call graph for this function:

◆ createEDNSFromRR()

EDNS * isc::dns::createEDNSFromRR ( const Name name,
const RRClass rrclass,
const RRType rrtype,
const RRTTL ttl,
const rdata::Rdata rdata,
uint8_t &  extended_rcode 
)

Create a new EDNS object from a set of RR parameters, also providing the extended RCODE value.

This function is similar to the EDNS class constructor EDNS::EDNS(const Name&, const RRClass&, const RRType&, const RRTTL&, const rdata::Rdata&) but is different in that

  • It dynamically creates a new object
  • It returns (via a reference argument) the topmost 8 bits of the extended RCODE encoded in the ttl.

On success, extended_rcode will be updated with the 8-bit part of the extended RCODE encoded in the TTL of the OPT RR.

The intended usage of this function is to parse an OPT RR of an incoming DNS message, while updating the RCODE of the message. One common usage pattern is as follows:

Message msg;
...
uint8_t extended_rcode;
ConstEDNSPtr edns = ConstEDNSPtr(createEDNSFromRR(..., extended_rcode));
rcode = Rcode(msg.getRcode().getCode(), extended_rcode);

(although, like the EDNS constructor, normal applications wouldn't have to use this function directly).

This function provides the strong exception guarantee: Unless an exception is thrown extended_code won't be modified.

This function validates the given parameters and throws exceptions on failure in the same way as the EDNS class constructor. In addition, if memory allocation for the new object fails it throws the corresponding standard exception.

Note that this function returns a bare pointer to the newly allocated object, not a shared pointer object enclosing the pointer. The caller is responsible for deleting the object after the use of it (typically, the caller would immediately encapsulate the returned pointer in a shared pointer object, EDNSPtr or ConstEDNSPtr). It returns a bare pointer so that it can be used where the use of a shared pointer is impossible or not desirable.

Note to developers: there is no strong technical reason why this function cannot be a constructor of the EDNS class or even integrated into the constructor. But we decided to make it a separate free function so that constructors will be free from side effects (which is in itself a matter of preference).

Parameters
nameThe owner name of the OPT RR. This must be the root name.
rrclassThe RR class of the OPT RR.
rrtypeThis must specify the OPT RR type.
ttlThe TTL of the OPT RR.
rdataThe RDATA of the OPT RR.
extended_rcodeA placeholder to store the topmost 8 bits of the extended Rcode.
Returns
A pointer to the created EDNS object.

Definition at line 157 of file edns.cc.

References isc::dns::EDNS::EDNS(), and isc::dns::RRTTL::getValue().

Referenced by isc::dns::MessageImpl::addEDNS().

+ Here is the call graph for this function:

◆ masterLoad() [1/2]

void isc::dns::masterLoad ( const char *const  filename,
const Name origin,
const RRClass zone_class,
MasterLoadCallback  callback 
)

Master zone file loader from a file.

This function parses a given file as a master DNS zone file for the given origin name and RR class, constructs a sequence of RRset from the RRs containing in the file, and calls the given callback functor object or function with each RRset.

The callback parameter is a functor object or a function that takes one parameter of type RRsetPtr and returns nothing, i.e. void (see below for specific examples). More precisely, it can be anything that this form of std::function can represent, but the caller normally doesn't have to care about that level of details.

The ownership of constructed RRsets is transferred to the callback and this function never uses it once it is called. The callback can freely modify the passed RRset.

This function internally uses the MasterLoader class, and basically accepts and rejects input that MasterLoader accepts and rejects, accordingly. In addition, this function performs the following validation: if an SOA RR is included, its owner name must be the origin name.

It does not perform other semantical checks, however. For example, it doesn't check if an NS RR of the origin name is included or if there is more than one SOA RR. Such further checks are the caller's (or the callback's) responsibility.

Exceptions

This function throws an exception of class MasterLoadError in the following cases:

  • Any of the validation checks fails (see above).
  • The input data has a syntax error.
  • The specified file cannot be opened for loading.
  • An I/O error occurs during the loading.

In addition, this function requires resource allocation for parsing and constructing RRsets. If it fails, the corresponding standard exception will be thrown.

The callback may throw its own function. This function doesn't catch it and will simply propagate it towards the caller.

Usage Examples

A simplest example usage of this function would be to parse a zone file and (after validation) dump the content to the standard output. This is an example functor object and a call to masterLoad that implements this scenario:

struct ZoneDumper {
void operator()(ConstRRsetPtr rrset) const {
std::cout << *rrset;
}
};
...
masterLoad(zone_file, Name("example.com"), RRClass::IN(), ZoneDumper());

Alternatively, you can use a normal function instead of a functor:

void zoneDumper(ConstRRsetPtr rrset) {
std::cout << *rrset;
}
...
masterLoad(zone_file, Name("example.com"), RRClass::IN(), zoneDumper);

Or, if you want to use it with a member function of some other class, wrapping things with std::bind would be handy:

class ZoneDumper {
public:
void dump(ConstRRsetPtr rrset) const {
std::cout << *rrset;
}
};
...
ZoneDumper dumper;
masterLoad(rr_stream, Name("example.com"), RRClass::IN(),
std::bind(&ZoneDumper::dump, &dumper, _1));

You can find a bit more complicated examples in the unit tests code for this function.

Implementation Notes

The current implementation is in a preliminary level and needs further extensions. Some design decisions may also have to be reconsidered as we gain experiences. Those include:

  • We may want to allow optional conditions. For example, we may want to be generous about some validation failures and be able to continue parsing.
  • Especially if we allow to be generous, we may also want to support returning an error code instead of throwing an exception when we encounter validation failure.
  • RRSIGs are handled as separate RRsets, i.e. they are not included in the RRset they cover.
Parameters
filenameA path to a master zone file to be loaded.
originThe origin name of the zone.
zone_classThe RR class of the zone.
callbackA callback functor or function that is to be called for each RRset.

Definition at line 82 of file masterload.cc.

References isc_throw.

◆ masterLoad() [2/2]

void isc::dns::masterLoad ( std::istream &  input,
const Name origin,
const RRClass zone_class,
MasterLoadCallback  callback,
const char *  source = NULL 
)

Master zone file loader from input stream.

This function is same as the other version (masterLoad(const char* const, const Name&, const RRClass&, MasterLoadCallback)) except that it takes a std::istream instead of a file. It extracts lines from the stream and handles each line just as a line of a file for the other version of function. All descriptions of the other version apply to this version except those specific to file I/O.

Note: The 'source' parameter is now ignored, but it was only used in exception messages on some error. So the compatibility effect should be minimal.

Parameters
inputAn input stream object that is to emit zone's RRs.
originThe origin name of the zone.
zone_classThe RR class of the zone.
callbackA callback functor or function that is to be called for each RRset.
sourceThis parameter is now ignored but left for compatibility.

Definition at line 93 of file masterload.cc.

◆ operator<<() [1/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const Opcode opcode 
)

Insert the Opcode as a string into stream.

This method convert opcode into a string and inserts it into the output stream os.

Parameters
osA std::ostream object on which the insertion operation is performed.
opcodeA reference to an Opcode object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 58 of file opcode.cc.

References isc::dns::Opcode::toText().

+ Here is the call graph for this function:

◆ operator<<() [2/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const RRType rrtype 
)

Insert the RRType as a string into stream.

This method convert the rrtype into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to RRType objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
rrtypeThe RRType object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 60 of file rrtype.cc.

References isc::dns::RRType::toText().

+ Here is the call graph for this function:

◆ operator<<() [3/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const TSIGError tsig_error 
)

Insert the TSIGError as a string into stream.

This method convert tsig_error into a string and inserts it into the output stream os.

Parameters
osA std::ostream object on which the insertion operation is performed.
tsig_errorAn TSIGError object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 62 of file tsigerror.cc.

References isc::dns::TSIGError::toText().

+ Here is the call graph for this function:

◆ operator<<() [4/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const Serial serial 
)

Helper operator for output streams, writes the value to the stream.

Parameters
osThe ostream to write to
serialThe Serial to write
Returns
the output stream

Definition at line 64 of file serial.cc.

References isc::dns::Serial::getValue().

+ Here is the call graph for this function:

◆ operator<<() [5/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const RRClass rrclass 
)

Insert the RRClass as a string into stream.

This method convert the rrclass into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to RRClass objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
rrclassThe RRClass object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 69 of file rrclass.cc.

References isc::dns::RRClass::toText().

+ Here is the call graph for this function:

◆ operator<<() [6/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const Question question 
)

Insert the Question as a string into stream.

This method convert the question into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to Question objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
questionA reference to a Question object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 76 of file question.cc.

References isc::dns::Question::toText().

+ Here is the call graph for this function:

◆ operator<<() [7/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const Rcode rcode 
)

Insert the Rcode as a string into stream.

This method convert rcode into a string and inserts it into the output stream os.

Parameters
osA std::ostream object on which the insertion operation is performed.
rcodeA reference to an Rcode object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 91 of file rcode.cc.

References isc::dns::Rcode::toText().

+ Here is the call graph for this function:

◆ operator<<() [8/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const TSIGRecord record 
)

Insert the TSIGRecord as a string into stream.

This method convert record into a string and inserts it into the output stream os.

Parameters
osA std::ostream object on which the insertion operation is performed.
recordA TSIGRecord object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 138 of file tsigrecord.cc.

References isc::dns::TSIGRecord::toText().

+ Here is the call graph for this function:

◆ operator<<() [9/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const AbstractRRset rrset 
)

Insert the RRset as a string into stream.

This method convert the rrset into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to RRset objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
rrsetA reference to a (derived class of) AbstractRRset object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 154 of file rrset.cc.

References isc::dns::AbstractRRset::toText().

+ Here is the call graph for this function:

◆ operator<<() [10/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const EDNS edns 
)

Insert the EDNS as a string into stream.

This method convert edns into a string and inserts it into the output stream os.

Parameters
osA std::ostream object on which the insertion operation is performed.
ednsA reference to an EDNS object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 172 of file edns.cc.

References isc::dns::EDNS::toText().

Referenced by isc::dns::TSIGError::BAD_TRUNC(), isc::dns::Rcode::BADVERS(), isc::dns::LabelSequence::getLabelCount(), isc::dns::Serial::getValue(), and isc::dns::Opcode::RESERVED15().

+ Here is the call graph for this function:

◆ operator<<() [11/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const RRTTL rrttl 
)

Insert the RRTTL as a string into stream.

This method convert the rrttl into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to RRTTL objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
rrttlThe RRTTL object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 209 of file rrttl.cc.

References isc::dns::RRTTL::toText().

+ Here is the call graph for this function:

◆ operator<<() [12/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const LabelSequence label_sequence 
)

Insert the label sequence as a string into stream.

This method convert the label_sequence into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to LabelSequence objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
label_sequenceThe LabelSequence object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 466 of file labelsequence.cc.

References isc::dns::LabelSequence::toText().

+ Here is the call graph for this function:

◆ operator<<() [13/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const Name name 
)

Insert the name as a string into stream.

This method convert the name into a string and inserts it into the output stream os.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to Name objects.

Parameters
osA std::ostream object on which the insertion operation is performed.
nameThe Name object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 718 of file name.cc.

References isc::dns::Name::toText().

+ Here is the call graph for this function:

◆ operator<<() [14/14]

std::ostream & isc::dns::operator<< ( std::ostream &  os,
const Message message 
)

Insert the Message as a string into stream.

This method convert message into a string and inserts it into the output stream os.

Parameters
osA std::ostream object on which the insertion operation is performed.
messageA Message object output by the operation.
Returns
A reference to the same std::ostream object referenced by parameter os after the insertion operation.

Definition at line 1159 of file dns/message.cc.

References isc::dns::Message::toText().

+ Here is the call graph for this function:

◆ operator|()

MasterLexer::Options isc::dns::operator| ( MasterLexer::Options  o1,
MasterLexer::Options  o2 
)
inline

Operator to combine MasterLexer options.

This is a trivial shortcut so that compound options can be specified in an intuitive way.

Definition at line 667 of file master_lexer.h.

◆ setNSEC3HashCreator()

void isc::dns::setNSEC3HashCreator ( const NSEC3HashCreator new_creator)

The registrar of NSEC3HashCreator.

This function sets or resets the system-wide NSEC3HashCreator that is used by NSEC3Hash::create().

If new_creator is non NULL, the given creator object will replace any existing creator. If it's NULL, the default builtin creator will be used again from that point.

When new_creator is non NULL, the caller is responsible for keeping the referenced object valid as long as it can be used via NSEC3Hash::create().

Exceptions
None
Parameters
new_creatorA pointer to the new creator object or NULL.

Definition at line 263 of file nsec3hash.cc.

Variable Documentation

◆ MAX_SERIAL_INCREMENT

const uint32_t isc::dns::MAX_SERIAL_INCREMENT = 2147483647

The maximum difference between two serial numbers.

If the (plain uint32_t) difference between two serials is greater than this number, the smaller one is considered greater.

Definition at line 19 of file serial.h.

Referenced by isc::dns::Serial::operator<().

◆ MAX_SERIAL_VALUE

const uint64_t isc::dns::MAX_SERIAL_VALUE = 4294967296ull

Maximum value a serial can have, used in + operator.

Definition at line 22 of file serial.h.

Referenced by isc::dns::Serial::operator+().

◆ qid_generator_instance

QidGenerator isc::dns::qid_generator_instance

Definition at line 22 of file qid_gen.cc.