summaryrefslogtreecommitdiffstats
path: root/src/lib/dns/edns.cc
diff options
context:
space:
mode:
authorJINMEI Tatuya <jinmei@isc.org>2011-04-28 11:00:31 +0200
committerJINMEI Tatuya <jinmei@isc.org>2011-04-28 11:00:31 +0200
commit28143beb0e57bbd4d62432b81edc8e179b95959f (patch)
treecd04b8d647913c377468fb1ad22c972a31a310c7 /src/lib/dns/edns.cc
parent[trac812next] added document for the TSIG version of toWire() (diff)
downloadkea-28143beb0e57bbd4d62432b81edc8e179b95959f.tar.xz
kea-28143beb0e57bbd4d62432b81edc8e179b95959f.zip
[trac812next] made straightforward changes to toWire() methods so that
they use AbstractMessageRenderer. not related to the subject of this branch, but we'll need this change anyway, and touching some toWire()s is a good opportunity to make this happen.
Diffstat (limited to 'src/lib/dns/edns.cc')
-rw-r--r--src/lib/dns/edns.cc29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/lib/dns/edns.cc b/src/lib/dns/edns.cc
index 5405dab515..447b47986d 100644
--- a/src/lib/dns/edns.cc
+++ b/src/lib/dns/edns.cc
@@ -110,19 +110,25 @@ EDNS::toText() const {
return (ret);
}
+namespace {
+/// Helper function to define unified implementation for the public versions
+/// of toWire().
template <typename Output>
int
-EDNS::toWire(Output& output, const uint8_t extended_rcode) const {
+toWireCommon(Output& output, const uint8_t version,
+ const uint16_t udp_size, const bool dnssec_aware,
+ const uint8_t extended_rcode)
+{
// Render EDNS OPT RR
uint32_t extrcode_flags = extended_rcode << EXTRCODE_SHIFT;
- extrcode_flags |= (version_ << VERSION_SHIFT) & VERSION_MASK;
- if (dnssec_aware_) {
+ extrcode_flags |= (version << VERSION_SHIFT) & VERSION_MASK;
+ if (dnssec_aware) {
extrcode_flags |= EXTFLAG_DO;
}
// Construct an RRset corresponding to the EDNS.
// We don't support any options for now, so the OPT RR can be empty.
- RRsetPtr edns_rrset(new RRset(Name::ROOT_NAME(), RRClass(udp_size_),
+ RRsetPtr edns_rrset(new RRset(Name::ROOT_NAME(), RRClass(udp_size),
RRType::OPT(), RRTTL(extrcode_flags)));
edns_rrset->addRdata(ConstRdataPtr(new generic::OPT()));
@@ -130,9 +136,12 @@ EDNS::toWire(Output& output, const uint8_t extended_rcode) const {
return (1);
}
+}
unsigned int
-EDNS::toWire(MessageRenderer& renderer, const uint8_t extended_rcode) const {
+EDNS::toWire(AbstractMessageRenderer& renderer,
+ const uint8_t extended_rcode) const
+{
// If adding the OPT RR would exceed the size limit, don't do it.
// 11 = len(".") + type(2byte) + class(2byte) + TTL(4byte) + RDLEN(2byte)
// (RDATA is empty in this simple implementation)
@@ -140,12 +149,16 @@ EDNS::toWire(MessageRenderer& renderer, const uint8_t extended_rcode) const {
return (0);
}
- return (toWire<MessageRenderer>(renderer, extended_rcode));
+ return (toWireCommon(renderer, version_, udp_size_, dnssec_aware_,
+ extended_rcode));
}
unsigned int
-EDNS::toWire(isc::util::OutputBuffer& buffer, const uint8_t extended_rcode) const {
- return (toWire<isc::util::OutputBuffer>(buffer, extended_rcode));
+EDNS::toWire(isc::util::OutputBuffer& buffer,
+ const uint8_t extended_rcode) const
+{
+ return (toWireCommon(buffer, version_, udp_size_, dnssec_aware_,
+ extended_rcode));
}
EDNS*