BIND 10 #2096: Define and implement "RdataReader" class (was: Define and implement RdataIterator class)

BIND 10 Development do-not-reply at isc.org
Thu Jul 26 06:36:50 UTC 2012


#2096: Define and implement "RdataReader" class
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:
  jinmei                             |                Status:  new
                       Type:  task   |             Milestone:
                   Priority:         |  Sprint-20120731
  medium                             |            Resolution:
                  Component:  data   |             Sensitive:  0
  source                             |           Sub-Project:  DNS
                   Keywords:         |  Estimated Difficulty:  5
            Defect Severity:  N/A    |           Total Hours:  0
Feature Depending on Ticket:         |
  scalable inmemory                  |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------
Description changed by jinmei:

Old description:

> This is different from the generic iterator defined in libdns++.
> It provides lightweight (efficient) interface for the user to iterate
> over RDATA (and RRSIG RDATA) encoded in memory.  Like `RdataEncoder`
> class, it doesn't necessarily have to be this way, but for reference,
> this is what I'd do based on my experiment:
>
> {{{#!cpp
> class RdataIterator {
> public:
>     // functor called for each "Name" field.  the second parameter is
>     // its attributes (compresible or not, needing additional handling
>     // or not)
>     typedef boost::function<void(const LabelSequence&, unsigned int)>
> NameAction;
>     // functor called for each "Data" field.  Just wire-format data
>     // will be passed.
>     typedef boost::function<void(const uint8_t*, size_t)> DataAction;
>
>     // constructor.  caller specifies the RR type, # of RDATA, and
>     // the entry pointer to the encoded data.  It passes callback
>     // functors.  Note: we should probably also pass RRClass.
>     // Also, it would be nice if we can begin with an arbitrary
>     // count of RDATA (starting from the 2nd one instead of 1st, etc)
>     // so we can use it for RR rotation in the answer section.
>     // but that would be a future extension.
>     RdataIterator(dns::RRType type, uint16_t n_rdata,
>                   const uint8_t* encoded_data,
>                   NameAction name_action, DataAction data_action);
>
>     // iterate over RDATA fields of the "current" RDATA and call the
>     // callback functor for each field, then move to the next RDATA
>     void action();
>     bool isLast() const;
>
>    // We'll need RRSIG RDATA version of these, too.
> };
> }}}
>
> Note: For now, we'll encode names in the form of serialized
> `LabelSequence` (namelen, offsetlen, namedata, offset data) instead of
> pointers.  This is different from the ultimate proposed version in the
> wiki.
>
> Depend on #2094.

New description:

 (Revising the description based on the experience of other tasks
 and discussions in this ticket)

 The main purpose of the class is similar to the generic RDATA iterator
 defined in libdns++, but it provides lightweight (efficient) interface
 for the user to iterate over RDATA (and RRSIG RDATA) encoded in
 memory.

 A proposed interface is as follows (but details are ultimately up to
 the developer who works on this ticket):

 {{{#!cpp
 class RdataReader {
 public:
     // functor called for each "Name" field.  the second parameter is
     // its attributes (compresible or not, needing additional handling
     // or not)
     typedef boost::function<void(const LabelSequence&, unsigned int)>
 NameAction;
     // functor called for each "Data" field.  Just wire-format data
     // will be passed.
     typedef boost::function<void(const uint8_t*, size_t)> DataAction;

     // constructor.  caller specifies the RR type, # of RDATA, and
     // the entry pointer to the encoded data.  It takes callback
     // functors used for actionXXX (by passing them on construction
     // we can eliminate the need for constructing the functors for
     // every action() call).  It sets an internal "cursor" (current
 position
     // in the sequence of RDATA) to the first RDATA (there'd be two
     // types of cursor: one for RDATA and one for RRSIG RDATA).
     RdataReader(dns::RRClass rrclass, dns::RRType rrtype,
                 size_t n_rdata, size_t n_rrsig,
                 const void* encoded_data,
                 NameAction name_action, DataAction data_action);

     // Return the total size of the encoded data.  Necessary for
     // destroying RdataSet.
     size_t getDataLength() const;

     // (Optional) we might want to set the position of the "cursor" to
     // an arbitrary valid position.  Then we can use it for RR
     // rotation in the answer section.

     // iterate over RDATA fields of the "current" RDATA and call the
     // callback functor for each field, then move the cursor to the
     // next RDATA.
     void actionOnRdata();

     // Return true iff the cursor reaches the end of the RDATA
     // sequence.
     // Also consider recording the position of the end of RDATA (to a
     // mutable member variable) so if actionOnSIGRdata() is called
     // later we can skip iterating over all RDATAs again.
     bool isLastRdata() const;

     // call data_action for the current RRSIG RDATA and move the RRSIG
     // cursor to the next RRSIG RDATA.
     void actionOnSIGRdata();

     // Return true iff the cursor reaches the end of the RRSIG RDATA
 sequence.
     bool isLastSIGRdata() const;
 };
 }}}

 Note: For now, we'll encode names in the form of serialized
 `LabelSequence` (namelen, offsetlen, namedata, offset data) instead of
 pointers.  This is different from the ultimate proposed version in the
 wiki.

 Depend on #2094.

--

-- 
Ticket URL: <http://bind10.isc.org/ticket/2096#comment:7>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list