21 CSVLeaseFile6::CSVLeaseFile6(
const std::string& filename)
29 VersionedCSVFile::open(seek_to_end);
73 VersionedCSVFile::append(row);
74 }
catch (
const std::exception&) {
96 VersionedCSVFile::next(row);
98 if (row == CSVFile::EMPTY_ROW()) {
103 lease.reset(
new Lease6(readType(row), readAddress(row), readDUID(row),
104 readIAID(row), readPreferred(row),
108 readPrefixLen(row)));
109 lease->cltt_ = readCltt(row);
110 lease->fqdn_fwd_ = readFqdnFwd(row);
111 lease->fqdn_rev_ = readFqdnRev(row);
112 lease->hostname_ = readHostname(row);
113 lease->state_ = readState(row);
117 "The Empty DUID is only valid for declined leases");
121 lease->setContext(ctx);
123 }
catch (
const std::exception& ex) {
141 CSVLeaseFile6::initColumns() {
170 CSVLeaseFile6::readType(
const CSVRow& row) {
171 return (static_cast<Lease::Type>
176 CSVLeaseFile6::readAddress(
const CSVRow& row) {
188 CSVLeaseFile6::readIAID(
const CSVRow& row) {
194 CSVLeaseFile6::readPreferred(
const CSVRow& row) {
201 CSVLeaseFile6::readValid(
const CSVRow& row) {
208 CSVLeaseFile6::readCltt(
const CSVRow& row) {
216 CSVLeaseFile6::readSubnetID(
const CSVRow& row) {
223 CSVLeaseFile6::readPrefixLen(
const CSVRow& row) {
225 return (static_cast<uint8_t>(prefixlen));
229 CSVLeaseFile6::readFqdnFwd(
const CSVRow& row) {
235 CSVLeaseFile6::readFqdnRev(
const CSVRow& row) {
241 CSVLeaseFile6::readHostname(
const CSVRow& row) {
247 CSVLeaseFile6::readHWAddr(
const CSVRow& row) {
250 uint16_t
const hwtype(readHWType(row).valueOr(
HTYPE_ETHER));
265 }
catch (
const std::exception& ex) {
284 if (user_context.empty()) {
290 <<
"' is not a JSON map");
296 CSVLeaseFile6::readHWType(
const CSVRow& row) {
298 if (row.
readAt(index).empty()) {
305 CSVLeaseFile6::readHWAddrSource(
const CSVRow& row) {
307 if (row.
readAt(index).empty()) {
T readAndConvertAt(const size_t at) const
Retrieves a value from the internal container.
#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.
uint32_t iaid_
Identity Association Identifier (IAID)
size_t getColumnCount() const
Returns the number of columns in the file.
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
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.
static const uint32_t HWADDR_SOURCE_UNKNOWN
Used when actual origin is not known, e.g.
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.
std::vector< uint8_t > hwaddr_
static ElementPtr fromJSON(const std::string &in, bool preproc=false)
These functions will parse the given string (JSON) representation of a compound element.
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.
Holds DUID (DHCPv6 Unique Identifier)
#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.
Lease::Type type_
Lease type.
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-lfc.
T valueOr(T const &or_value) const
Retrieves the encapsulated value if specified, or the given value otherwise.
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 toText() const
Convert the address to a string.
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.
size_t getColumnIndex(const std::string &col_name) const
Returns the index of the column having specified name.
std::string readAt(const size_t at) const
Retrieves a value from the internal container.
static std::string basicStatesToText(const uint32_t state)
Returns name(s) of the basic lease state(s).
Hardware type that represents information from DHCPv4 packet.
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.
const isc::log::MessageID DHCPSRV_MEMFILE_READ_HWADDR_FAIL
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
std::string readAtEscaped(const size_t at) const
Retrieves a value from the internal container, free of escaped characters.
static const uint32_t STATE_DECLINED
Declined lease.
uint32_t read_leases_
Number of leases read.
uint32_t source_
Hardware address source.
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
Defines unique IPv4 or IPv6 subnet identifier.