BIND 10 #2096: Define and implement `RdataIterator` class

BIND 10 Development do-not-reply at isc.org
Sat Jun 30 06:52:20 UTC 2012


#2096: Define and implement `RdataIterator` class
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:
  jinmei                             |                Status:  new
                       Type:  task   |             Milestone:  Next-Sprint-
                   Priority:         |  Proposed
  medium                             |            Resolution:
                  Component:  data   |             Sensitive:  0
  source                             |           Sub-Project:  DNS
                   Keywords:         |  Estimated Difficulty:  0
            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.
> };
> }}}
>
> Depend on #2094.

New 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.

--

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


More information about the bind10-tickets mailing list