|
@@ -12,18 +12,31 @@
|
|
|
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
+#include <dns/rrtype.h>
|
|
|
+#include <dns/rrset.h>
|
|
|
+
|
|
|
#include "rdataset.h"
|
|
|
+#include "rdata_encoder.h"
|
|
|
|
|
|
+#include <cstring>
|
|
|
#include <new> // for the placement new
|
|
|
|
|
|
+using namespace isc::dns;
|
|
|
+
|
|
|
namespace isc {
|
|
|
namespace datasrc {
|
|
|
namespace memory {
|
|
|
|
|
|
RdataSet*
|
|
|
-RdataSet::create(util::MemorySegment& mem_sgmt) {
|
|
|
+RdataSet::create(util::MemorySegment& mem_sgmt, RdataEncoder& /*encoder*/,
|
|
|
+ dns::ConstRRsetPtr rrset, dns::ConstRRsetPtr sig_rrset)
|
|
|
+{
|
|
|
void* p = mem_sgmt.allocate(sizeof(RdataSet));
|
|
|
- RdataSet* rdataset = new(p) RdataSet();
|
|
|
+ RdataSet* rdataset = new(p) RdataSet(rrset->getType(),
|
|
|
+ rrset->getRdataCount(),
|
|
|
+ sig_rrset ?
|
|
|
+ sig_rrset->getRdataCount() : 0,
|
|
|
+ rrset->getTTL());
|
|
|
return (rdataset);
|
|
|
}
|
|
|
|
|
@@ -33,6 +46,31 @@ RdataSet::destroy(util::MemorySegment& mem_sgmt, RdataSet* rdataset) {
|
|
|
mem_sgmt.deallocate(rdataset, sizeof(RdataSet));
|
|
|
}
|
|
|
|
|
|
+namespace {
|
|
|
+// Convert the given RRTTL into the corresponding 32-bit unsigned integer,
|
|
|
+// in the network byte order. We do not use htonl() to be as portable as
|
|
|
+// possible.
|
|
|
+uint32_t
|
|
|
+convertTTL(RRTTL ttl) {
|
|
|
+ const uint32_t ttl_val = ttl.getValue();
|
|
|
+ uint8_t buf[4];
|
|
|
+ buf[0] = (ttl_val & 0xff000000) >> 24;
|
|
|
+ buf[1] = (ttl_val & 0x00ff0000) >> 16;
|
|
|
+ buf[2] = (ttl_val & 0x0000ff00) >> 8;
|
|
|
+ buf[3] = (ttl_val & 0x000000ff);
|
|
|
+ uint32_t ret;
|
|
|
+ std::memcpy(&ret, buf, sizeof(ret));
|
|
|
+ return (ret);
|
|
|
+}
|
|
|
+}
|
|
|
+
|
|
|
+RdataSet::RdataSet(RRType type_param, size_t rdata_count_param,
|
|
|
+ size_t sig_rdata_count_param, RRTTL ttl_param) :
|
|
|
+ type(type_param), sig_rdata_count(sig_rdata_count_param),
|
|
|
+ rdata_count(rdata_count_param), ttl(convertTTL(ttl_param))
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
} // namespace memory
|
|
|
} // namespace datasrc
|
|
|
} // datasrc isc
|