Commit b5bfaf8c authored by Jelte Jansen's avatar Jelte Jansen

[1455] cleanup, documentation

and removed a method in rrset that turned out to be unneeded
parent 788dbb80
......@@ -260,7 +260,6 @@ public:
~BasicRdataIterator() {}
virtual void first() { it_ = datavector_->begin(); }
virtual void next() { ++it_; }
virtual bool currentEmpty() const { return (!(*it_)); }
virtual const rdata::Rdata& getCurrent() const { return (**it_); }
virtual bool isLast() const { return (it_ == datavector_->end()); }
private:
......
......@@ -267,6 +267,8 @@ public:
/// the resulting string with a trailing newline character.
/// (following the BIND9 convention)
///
/// If the class is not ANY or NONE, the RRset must contain some RDATA;
/// otherwise, an exception of class \c EmptyRRset will be thrown.
/// If resource allocation fails, a corresponding standard exception
/// will be thrown.
/// The default implementation may throw other exceptions if the
......@@ -297,6 +299,8 @@ public:
///
/// If resource allocation fails, a corresponding standard exception
/// will be thrown.
/// If the class is not ANY or NONE, the RRset must contain some RDATA;
/// otherwise, an exception of class \c EmptyRRset will be thrown.
/// The default implementation may throw other exceptions if the
/// \c toWire() method of the RDATA objects throws.
/// If a derived class of \c AbstractRRset overrides the default
......@@ -556,11 +560,6 @@ public:
/// This method should never throw an exception.
virtual void next() = 0;
/// \brief Check if 'current' is empty (in which case getCurrent() would
/// fail
/// \return True if the current Rdata field is NULL, false if not
virtual bool currentEmpty() const = 0;
/// \brief Return the current \c Rdata corresponding to the rdata cursor.
///
/// \return A reference to an \c rdata::Rdata object corresponding
......
......@@ -197,6 +197,7 @@ class UpdateSession:
'''Check whether an rrset with the given name and type exists. Class,
TTL, and Rdata (if any) of the given RRset are ignored.
RFC2136 Section 2.4.1.
Returns True if the prerequisite is satisfied, False otherwise.
'''
_, finder = datasrc_client.find_zone(rrset.get_name())
result, _, _ = finder.find(rrset.get_name(), rrset.get_type(),
......@@ -207,6 +208,7 @@ class UpdateSession:
'''Check whether an rrset that matches name, type, and rdata(s) of the
given rrset exists.
RFC2136 Section 2.4.2
Returns True if the prerequisite is satisfied, False otherwise.
'''
_, finder = datasrc_client.find_zone(rrset.get_name())
result, found_rrset, _ = finder.find(rrset.get_name(), rrset.get_type(),
......@@ -231,6 +233,7 @@ class UpdateSession:
'''Check whether no rrsets with the same name and type as the given
rrset exist.
RFC2136 Section 2.4.3.
Returns True if the prerequisite is satisfied, False otherwise.
'''
return not self.__prereq_rrset_exists(datasrc_client, rrset)
......@@ -238,6 +241,7 @@ class UpdateSession:
'''Check whether the name of the given RRset is in use (i.e. has
1 or more RRs).
RFC2136 Section 2.4.4
Returns True if the prerequisite is satisfied, False otherwise.
'''
_, finder = datasrc_client.find_zone(rrset.get_name())
result, rrsets, flags = finder.find_all(rrset.get_name(),
......@@ -252,12 +256,16 @@ class UpdateSession:
'''Check whether the name of the given RRset is not in use (i.e. does
not exist at all, or is an empty nonterminal.
RFC2136 Section 2.4.5.
Returns True if the prerequisite is satisfied, False otherwise.
'''
return not self.__prereq_name_in_use(datasrc_client, rrset)
def __check_prerequisites(self, datasrc_client, zname, zclass):
'''Check the prerequisites section of the UPDATE Message.
RFC2136 Section 2.4'''
RFC2136 Section 2.4.
Returns a dns Rcode signaling either no error (Rcode.NOERROR())
or that one of the prerequisites failed (any other Rcode).
'''
for rrset in self.__message.get_section(SECTION_PREREQUISITE):
# First check if the name is in the zone
relation = rrset.get_name().compare(zname).get_relation()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment