BIND 10 #2096: Define and implement "RdataReader" class
BIND 10 Development
do-not-reply at isc.org
Mon Aug 27 07:33:19 UTC 2012
#2096: Define and implement "RdataReader" class
-------------------------------------+-------------------------------------
Reporter: | Owner: vorner
jinmei | Status: reviewing
Type: task | Milestone:
Priority: | Sprint-20120904
medium | Resolution:
Component: data | Sensitive: 0
source | Sub-Project: DNS
Keywords: | Estimated Difficulty: 5
Defect Severity: N/A | Total Hours: 14
Feature Depending on Ticket: |
scalable inmemory |
Add Hours to Ticket: 0 |
Internal?: 0 |
-------------------------------------+-------------------------------------
Comment (by jinmei):
...sorry, and just one more point. As I looked at #2098, I noticed
the current interface does not work well for implementing toWire.
Since we need to repeat the following for each RDATA:
- write name, type, class, TTL, (and skip space for RDATA len)
- write RDATA (from reader)
- write RDATA len
It cannot be a simple loop like this:
{{{#!cpp
while (reader.iterateRdata()) {
// do something, but what should we do?
}
}}}
and, if we implement it this way:
{{{#!cpp
for (size_t i = 0; i < rdata_count; ++i) {
// write name, type, class, TTL
// skip space for RDATA len
reader.iterateRdata(); // must return true
// write RDATA len
}
}}}
then at the end of the loop the reader still doesn't locate the
position of sigs, so if we do this for rendering SIGs:
{{{#!cpp
for (size_t i = 0; i < sig_count; ++i) {
// write name, type, class, TTL, skip RDATA len
reader.nextSig();
// write RDATA len
}
}}}
then at the first call to nextSig(), we need to do a bit of extra work
of saving current positions, call nextInternal() and restore the
positions:
{{{#!cpp
const size_t data_pos = data_pos_;
const size_t spec_pos = spec_pos_;
const size_t length_pos = length_pos_;
// When the next() gets to the last item, it sets the sigs_
while (nextInternal(emptyNameAction, emptyDataAction) !=
RRSET_BOUNDARY) {}
assert(sigs_ != NULL);
// Return the state
data_pos_ = data_pos;
spec_pos_ = spec_pos;
length_pos_ = length_pos;
}}}
So I suggest applying the attached diff.
Further, this makes me wonder whether we want to keep the behavior of
next(). At the moment, I don't see the need for it: we only need
iterate() (for additional section handling) and iterateRdata() (for
`RRset` rendering). And, since we implement these based on the next()
behavior, these need additional layer of function calls for each
single "data field". I wonder whether we could just expand the
`nextInternal` behavior so it examines all fields of each RDATA,
reducing the additional layer.
--
Ticket URL: <http://bind10.isc.org/ticket/2096#comment:26>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list