19 CSVLeaseFile6::CSVLeaseFile6(
const std::string& filename)
27 VersionedCSVFile::open(seek_to_end);
69 VersionedCSVFile::append(row);
70 }
catch (
const std::exception&) {
92 VersionedCSVFile::next(row);
94 if (row == CSVFile::EMPTY_ROW()) {
99 lease.reset(
new Lease6(readType(row), readAddress(row), readDUID(row),
100 readIAID(row), readPreferred(row),
104 readPrefixLen(row)));
105 lease->cltt_ = readCltt(row);
106 lease->fqdn_fwd_ = readFqdnFwd(row);
107 lease->fqdn_rev_ = readFqdnRev(row);
108 lease->hostname_ = readHostname(row);
109 lease->state_ = readState(row);
113 "only valid for declined leases");
117 lease->setContext(ctx);
119 }
catch (
const std::exception& ex) {
137 CSVLeaseFile6::initColumns() {
158 CSVLeaseFile6::readType(
const CSVRow& row) {
159 return (static_cast<Lease::Type>
164 CSVLeaseFile6::readAddress(
const CSVRow& row) {
170 CSVLeaseFile6::readDUID(
const util::CSVRow& row) {
176 CSVLeaseFile6::readIAID(
const CSVRow& row) {
182 CSVLeaseFile6::readPreferred(
const CSVRow& row) {
189 CSVLeaseFile6::readValid(
const CSVRow& row) {
196 CSVLeaseFile6::readCltt(
const CSVRow& row) {
204 CSVLeaseFile6::readSubnetID(
const CSVRow& row) {
211 CSVLeaseFile6::readPrefixLen(
const CSVRow& row) {
213 return (static_cast<uint8_t>(prefixlen));
217 CSVLeaseFile6::readFqdnFwd(
const CSVRow& row) {
223 CSVLeaseFile6::readFqdnRev(
const CSVRow& row) {
229 CSVLeaseFile6::readHostname(
const CSVRow& row) {
235 CSVLeaseFile6::readHWAddr(
const CSVRow& row) {
239 if (hwaddr.hwaddr_.empty()) {
249 }
catch (
const std::exception& ex) {
260 CSVLeaseFile6::readState(
const util::CSVRow& row) {
261 uint32_t state = row.readAndConvertAt<uint32_t>(
getColumnIndex(
"state"));
266 CSVLeaseFile6::readContext(
const util::CSVRow& row) {
267 std::string user_context = row.readAtEscaped(
getColumnIndex(
"user_context"));
268 if (user_context.empty()) {
272 if (!ctx || (ctx->getType() != Element::map)) {
274 <<
"' is not a JSON map");
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
uint32_t state_
Holds the lease state(s).
boost::shared_ptr< DUID > DuidPtr
HWAddrPtr hwaddr_
Client's MAC/hardware address.
size_t getColumnCount() const
Returns the number of columns in the file.
uint32_t iaid_
Identity Association Identifier (IAID)
bool fqdn_rev_
Reverse zone updated?
uint32_t reads_
Number of attempts to read a lease.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
void writeAtEscaped(const size_t at, const std::string &value)
Replaces the value at the specified index with a value that has had special characters escaped...
time_t cltt_
Client last transmission time.
bool next(Lease6Ptr &lease)
Reads next lease from the CSV file.
uint32_t preferred_lft_
Preferred lifetime.
static const DUID & EMPTY()
Defines the constant "empty" DUID.
bool fqdn_fwd_
Forward zone updated?
uint32_t writes_
Number of attempts to write a lease.
static DUID fromText(const std::string &text)
Create DUID from the textual format.
uint32_t write_leases_
Number of lease written.
std::string hostname_
Client hostname.
SubnetID subnet_id_
Subnet identifier.
std::string readAt(const size_t at) const
Retrieves a value from the internal container.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void setMinimumValidColumns(const std::string &column_name)
Sets the minimum number of valid columns based on a given column.
boost::shared_ptr< const Element > ConstElementPtr
DuidPtr duid_
Client identifier.
Structure that holds a lease for IPv6 address and/or prefix.
Represents a single row of the CSV file.
void setReadMsg(const std::string &read_msg)
Sets error message after row validation.
size_t getColumnIndex(const std::string &col_name) const
Returns the index of the column having specified name.
Lease::Type type_
Lease type.
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
uint8_t prefixlen_
IPv6 prefix length.
void clearStatistics()
Clears the statistics.
uint32_t write_errs_
Number of errors when writing.
virtual void open(const bool seek_to_end=false)
Opens a lease file.
void append(const Lease6 &lease)
Appends the lease record to the CSV file.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void addColumn(const std::string &col_name, const std::string &version, const std::string &default_value="")
Adds metadata for a single column to the schema.
Implements a CSV file that supports multiple versions of the file's "schema".
std::string readAtEscaped(const size_t at) const
Retrieves a value from the internal container, free of escaped characters.
static HWAddr fromText(const std::string &text, const uint16_t htype=HTYPE_ETHER)
Creates instance of the hardware address from textual format.
Type
Type of lease or pool.
static std::string basicStatesToText(const uint32_t state)
Returns name(s) of the basic lease state(s).
std::string toText() const
Convert the address to a string.
T readAndConvertAt(const size_t at) const
Retrieves a value from the internal container.
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.
void writeAt(const size_t at, const char *value)
Replaces the value at specified index.
const isc::log::MessageID DHCPSRV_MEMFILE_READ_HWADDR_FAIL
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
static const uint32_t STATE_DECLINED
Declined lease.
uint32_t read_leases_
Number of leases read.
uint32_t valid_lft_
Valid lifetime.
The IOAddress class represents an IP addresses (version agnostic)
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
uint32_t read_errs_
Number of errors when reading.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)