48 <<
" has neither hardware address or client id");
75 VersionedCSVFile::append(row);
76 }
catch (
const std::exception&) {
112 std::vector<uint8_t> client_id_vec;
114 client_id_vec = client_id->getClientId();
116 size_t client_id_len = client_id_vec.size();
120 HWAddr hwaddr = readHWAddr(row);
121 uint32_t state = readState(row);
123 if ((hwaddr.
hwaddr_.empty()) && (client_id_vec.empty()) &&
127 <<
" has neither hardware address or client id");
133 lease.reset(
new Lease4(addr,
135 client_id_vec.empty() ? NULL : &client_id_vec[0],
144 lease->state_ = state;
147 lease->setContext(ctx);
150 lease->pool_id_ = readPoolID(row);
151 }
catch (
const std::exception& ex) {
169CSVLeaseFile4::initColumns() {
188CSVLeaseFile4::readAddress(
const CSVRow& row) {
194CSVLeaseFile4::readHWAddr(
const CSVRow& row) {
200CSVLeaseFile4::readClientId(
const CSVRow& row) {
203 if (client_id.empty()) {
211CSVLeaseFile4::readValid(
const CSVRow& row) {
218CSVLeaseFile4::readCltt(
const CSVRow& row) {
226CSVLeaseFile4::readSubnetID(
const CSVRow& row) {
233CSVLeaseFile4::readPoolID(
const CSVRow& row) {
240CSVLeaseFile4::readFqdnFwd(
const CSVRow& row) {
246CSVLeaseFile4::readFqdnRev(
const CSVRow& row) {
252CSVLeaseFile4::readHostname(
const CSVRow& row) {
266 if (user_context.empty()) {
272 <<
"' 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.
std::string readAtEscaped(const size_t at) const
Retrieves a value from the internal container, free of escaped characters.
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.
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.
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
Defines unique IPv4 or IPv6 subnet identifier.
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-lfc.
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 pool_id_
The pool id.
uint32_t valid_lft_
Valid lifetime.
static std::string basicStatesToText(const uint32_t state)
Returns name(s) of the basic lease state(s).
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.