mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[2094] added a new subdirectory for in-memory backend implementation details
This commit is contained in:
@@ -1101,6 +1101,7 @@ AC_CONFIG_FILES([Makefile
|
||||
src/lib/exceptions/Makefile
|
||||
src/lib/exceptions/tests/Makefile
|
||||
src/lib/datasrc/Makefile
|
||||
src/lib/datasrc/memory/Makefile
|
||||
src/lib/datasrc/tests/Makefile
|
||||
src/lib/datasrc/tests/testdata/Makefile
|
||||
src/lib/xfr/Makefile
|
||||
|
@@ -1,4 +1,4 @@
|
||||
SUBDIRS = . tests
|
||||
SUBDIRS = memory . tests
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
|
||||
@@ -64,6 +64,7 @@ libdatasrc_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
|
||||
libdatasrc_la_LIBADD += $(top_builddir)/src/lib/dns/libdns++.la
|
||||
libdatasrc_la_LIBADD += $(top_builddir)/src/lib/log/liblog.la
|
||||
libdatasrc_la_LIBADD += $(top_builddir)/src/lib/cc/libcc.la
|
||||
libdatasrc_la_LIBADD += memory/libdatasrc_memory.la
|
||||
libdatasrc_la_LIBADD += $(SQLITE_LIBS)
|
||||
|
||||
BUILT_SOURCES = datasrc_config.h datasrc_messages.h datasrc_messages.cc
|
||||
|
11
src/lib/datasrc/memory/Makefile.am
Normal file
11
src/lib/datasrc/memory/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
|
||||
AM_CPPFLAGS += $(BOOST_INCLUDES)
|
||||
AM_CPPFLAGS += $(SQLITE_CFLAGS)
|
||||
|
||||
AM_CXXFLAGS = $(B10_CXXFLAGS)
|
||||
|
||||
CLEANFILES = *.gcno *.gcda datasrc_messages.h datasrc_messages.cc
|
||||
|
||||
noinst_LTLIBRARIES = libdatasrc_memory.la
|
||||
libdatasrc_memory_la_SOURCES = rdata_encoder.h rdata_encoder.cc
|
110
src/lib/datasrc/memory/rdata_encoder.cc
Normal file
110
src/lib/datasrc/memory/rdata_encoder.cc
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include <dns/rrclass.h>
|
||||
#include <dns/rrtype.h>
|
||||
|
||||
#include "rdata_encoder.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace isc::dns;
|
||||
|
||||
namespace isc {
|
||||
namespace datasrc {
|
||||
namespace memory {
|
||||
|
||||
namespace {
|
||||
#ifdef notyet
|
||||
inline RdataNameAttributes
|
||||
operator&(RdataNameAttributes a1, RdataNameAttributes a2) {
|
||||
return (static_cast<RdataNameAttributes>(
|
||||
static_cast<unsigned int>(a1) &
|
||||
static_cast<unsigned int>(a2)));
|
||||
}
|
||||
#endif
|
||||
struct RdataFieldSpec {
|
||||
enum FieldType {
|
||||
FIXEDLEN_DATA = 0,
|
||||
VARLEN_DATA,
|
||||
DOMAIN_NAME
|
||||
};
|
||||
|
||||
FieldType type;
|
||||
union {
|
||||
uint16_t fixeddata_len;
|
||||
RdataNameAttributes name_attributes;
|
||||
};
|
||||
};
|
||||
|
||||
struct RdataEncodeSpec {
|
||||
uint16_t field_count;
|
||||
uint16_t name_count;
|
||||
uint16_t varlen_count;
|
||||
const RdataFieldSpec* fields;
|
||||
};
|
||||
|
||||
const uint16_t NAME_NOATTRIBUTE_INITIALIZER = static_cast<uint16_t>(0);
|
||||
const uint16_t NAME_COMPRESSIBLE_INITIALIZER =
|
||||
static_cast<uint16_t>(NAME_COMPRESSIBLE);
|
||||
const uint16_t NAME_ADDITIONAL_INITIALIZER =
|
||||
static_cast<uint16_t>(NAME_ADDITIONAL);
|
||||
const uint16_t NAME_COMPADDITIONAL_INITIALIZER =
|
||||
static_cast<uint16_t>(NAME_COMPRESSIBLE | NAME_ADDITIONAL);
|
||||
|
||||
const RdataFieldSpec generic_data_fields[] = {
|
||||
{RdataFieldSpec::VARLEN_DATA, {0}}
|
||||
};
|
||||
const uint16_t generic_data_fields_count =
|
||||
sizeof(generic_data_fields) / sizeof(RdataFieldSpec);
|
||||
|
||||
const RdataFieldSpec generic_single_name_fields[] = {
|
||||
{RdataFieldSpec::VARLEN_DATA, {NAME_COMPADDITIONAL_INITIALIZER}}
|
||||
};
|
||||
|
||||
// Class IN encode specs
|
||||
const RdataEncodeSpec encode_spec_list_in[] = {
|
||||
{generic_data_fields_count, 0, 0, generic_data_fields} // type #0
|
||||
};
|
||||
|
||||
#ifdef notyet
|
||||
inline
|
||||
const RdataEncodeSpec&
|
||||
getRdataEncodeSpec(RRClass rrclass, RRType rrtype) {
|
||||
if (rrclass == RRClass::IN()) {
|
||||
return (encode_spec_list_in[rrtype.getCode()]);
|
||||
}
|
||||
return (encode_spec_list_in[0]);
|
||||
}
|
||||
#endif
|
||||
} // end of unnamed namespace
|
||||
|
||||
#ifdef notyet
|
||||
void
|
||||
testRdataEncoder(const Rdata& rdata, RRClass rrclass, RRType rrtype,
|
||||
vector<uint8_t>& result)
|
||||
{
|
||||
const RdataEncodeSpec& encode_spec = getRdataEncodeSpec(rrclass, rrtype);
|
||||
for (size_t i = 0; i < encode_spec.field_count; ++i) {
|
||||
const RdataFieldSpec& field_spec = *encode_spec.fields[i];
|
||||
if (field_spec.type == RdataFieldSpec::FIXEDLEN_DATA)
|
||||
assert(encode_spec.fields[i] != NULL);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace memory
|
||||
} // namespace datasrc
|
||||
} // datasrc isc
|
35
src/lib/datasrc/memory/rdata_encoder.h
Normal file
35
src/lib/datasrc/memory/rdata_encoder.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#ifndef DATASRC_MEMORY_RDATA_ENCODER_H
|
||||
#define DATASRC_MEMORY_RDATA_ENCODER_H 1
|
||||
|
||||
namespace isc {
|
||||
namespace datasrc {
|
||||
namespace memory {
|
||||
|
||||
enum RdataNameAttributes {
|
||||
NAME_COMPRESSIBLE = 1,
|
||||
NAME_ADDITIONAL = (NAME_COMPRESSIBLE << 1)
|
||||
};
|
||||
|
||||
} // namespace memory
|
||||
} // namespace datasrc
|
||||
} // namespace isc
|
||||
|
||||
#endif // DATASRC_MEMORY_RDATA_ENCODER_H
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
Reference in New Issue
Block a user