63 VersionedCSVFile::append(row);
64 }
catch (
const std::exception&) {
97 std::vector<uint8_t> client_id_vec;
99 client_id_vec = client_id->getClientId();
101 size_t client_id_len = client_id_vec.size();
105 HWAddr hwaddr = readHWAddr(row);
106 uint32_t state = readState(row);
109 " valid for declined leases");
115 lease.reset(
new Lease4(readAddress(row),
117 client_id_vec.empty() ? NULL : &client_id_vec[0],
126 lease->state_ = state;
129 lease->setContext(ctx);
132 }
catch (std::exception& ex) {
150CSVLeaseFile4::initColumns() {
167CSVLeaseFile4::readAddress(
const CSVRow& row) {
173CSVLeaseFile4::readHWAddr(
const CSVRow& row) {
179CSVLeaseFile4::readClientId(
const CSVRow& row) {
182 if (client_id.empty()) {
190CSVLeaseFile4::readValid(
const CSVRow& row) {
197CSVLeaseFile4::readCltt(
const CSVRow& row) {
205CSVLeaseFile4::readSubnetID(
const CSVRow& row) {
212CSVLeaseFile4::readFqdnFwd(
const CSVRow& row) {
218CSVLeaseFile4::readFqdnRev(
const CSVRow& row) {
224CSVLeaseFile4::readHostname(
const CSVRow& row) {
238 if (user_context.empty()) {
244 <<
"' is not a JSON map");
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
static ElementPtr fromJSON(const std::string &in, bool preproc=false)
These functions will parse the given string (JSON) representation of a compound element.
void append(const Lease4 &lease)
Appends the lease record to the CSV file.
CSVLeaseFile4(const std::string &filename)
Constructor.
virtual void open(const bool seek_to_end=false)
Opens a lease file.
bool next(Lease4Ptr &lease)
Reads next lease from the CSV file.
static ClientIdPtr fromText(const std::string &text)
Create client identifier from the textual format.
uint32_t write_leases_
Number of lease written.
uint32_t read_leases_
Number of leases read.
uint32_t reads_
Number of attempts to read a lease.
void clearStatistics()
Clears the statistics.
uint32_t writes_
Number of attempts to write a lease.
uint32_t write_errs_
Number of errors when writing.
uint32_t read_errs_
Number of errors when reading.
size_t getColumnCount() const
Returns the number of columns in the file.
static CSVRow EMPTY_ROW()
Represents empty row.
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.
Represents a single row of the CSV file.
T readAndConvertAt(const size_t at) const
Retrieves a value from the internal container.
void writeAt(const size_t at, const char *value)
Replaces the value at specified index.
std::string readAt(const size_t at) const
Retrieves a value from the internal container.
Implements a CSV file that supports multiple versions of the file's "schema".
virtual void open(const bool seek_to_end=false)
Opens existing file or creates a new one.
void setMinimumValidColumns(const std::string &column_name)
Sets the minimum number of valid columns based on a given column.
bool next(CSVRow &row)
Reads next row from the file file.
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.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Defines the logger used by the top-level component of kea-dhcp-ddns.
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
Hardware type that represents information from DHCPv4 packet.
static HWAddr fromText(const std::string &text, const uint16_t htype=HTYPE_ETHER)
Creates instance of the hardware address from textual format.
std::vector< uint8_t > hwaddr_
Structure that holds a lease for IPv4 address.
ClientIdPtr client_id_
Client identifier.
SubnetID subnet_id_
Subnet identifier.
uint32_t valid_lft_
Valid lifetime.
static const uint32_t STATE_DECLINED
Declined lease.
std::string hostname_
Client hostname.
uint32_t state_
Holds the lease state(s).
bool fqdn_fwd_
Forward zone updated?
time_t cltt_
Client last transmission time.
HWAddrPtr hwaddr_
Client's MAC/hardware address.
bool fqdn_rev_
Reverse zone updated?
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.