 |
Kea
1.5.0
|
Go to the documentation of this file.
19 CSVLeaseFile6::CSVLeaseFile6(
const std::string& filename)
27 VersionedCSVFile::open(seek_to_end);
62 VersionedCSVFile::append(row);
63 }
catch (
const std::exception&) {
85 VersionedCSVFile::next(row);
87 if (row == CSVFile::EMPTY_ROW()) {
92 lease.reset(
new Lease6(readType(row), readAddress(row), readDUID(row),
93 readIAID(row), readPreferred(row),
98 lease->cltt_ = readCltt(row);
99 lease->fqdn_fwd_ = readFqdnFwd(row);
100 lease->fqdn_rev_ = readFqdnRev(row);
101 lease->hostname_ = readHostname(row);
102 lease->state_ = readState(row);
106 "only valid for declined leases");
110 lease->setContext(ctx);
112 }
catch (std::exception& ex) {
130 CSVLeaseFile6::initColumns() {
151 CSVLeaseFile6::readType(
const CSVRow& row) {
157 CSVLeaseFile6::readAddress(
const CSVRow& row) {
163 CSVLeaseFile6::readDUID(
const util::CSVRow& row) {
169 CSVLeaseFile6::readIAID(
const CSVRow& row) {
175 CSVLeaseFile6::readPreferred(
const CSVRow& row) {
182 CSVLeaseFile6::readValid(
const CSVRow& row) {
189 CSVLeaseFile6::readCltt(
const CSVRow& row) {
197 CSVLeaseFile6::readSubnetID(
const CSVRow& row) {
204 CSVLeaseFile6::readPrefixLen(
const CSVRow& row) {
206 return (
static_cast<uint8_t
>(prefixlen));
210 CSVLeaseFile6::readFqdnFwd(
const CSVRow& row) {
216 CSVLeaseFile6::readFqdnRev(
const CSVRow& row) {
222 CSVLeaseFile6::readHostname(
const CSVRow& row) {
228 CSVLeaseFile6::readHWAddr(
const CSVRow& row) {
232 if (hwaddr.hwaddr_.empty()) {
242 }
catch (
const std::exception& ex) {
253 CSVLeaseFile6::readState(
const util::CSVRow& row) {
254 uint32_t state = row.readAndConvertAt<uint32_t>(
getColumnIndex(
"state"));
259 CSVLeaseFile6::readContext(
const util::CSVRow& row) {
260 std::string user_context = row.readAt(
getColumnIndex(
"user_context"));
261 if (user_context.empty()) {
265 if (!ctx || (ctx->getType() != Element::map)) {
267 <<
"' is not a JSON map");
uint8_t prefixlen_
IPv6 prefix length.
bool fqdn_fwd_
Forward zone updated?
uint32_t state_
Holds the lease state(s).
bool next(Lease6Ptr &lease)
Reads next lease from the CSV file.
uint32_t iaid_
Identity Association Identifier (IAID)
The IOAddress class represents an IP addresses (version agnostic)
boost::shared_ptr< DUID > DuidPtr
static const DUID & EMPTY()
Defines the constant "empty" DUID.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
static DUID fromText(const std::string &text)
Create DUID from the textual format.
static const uint32_t STATE_DECLINED
Declined lease.
Type
Type of lease or pool.
isc::asiolink::IOAddress addr_
IPv4 ot IPv6 address.
uint32_t writes_
Number of attempts to write a lease.
Lease::Type type_
Lease type.
uint32_t read_errs_
Number of errors when reading.
void setReadMsg(const std::string &read_msg)
Sets error message after row validation.
size_t getColumnCount() const
Returns the number of columns in the file.
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
void writeAt(const size_t at, const char *value)
Replaces the value at specified index.
uint32_t valid_lft_
Valid lifetime.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Structure that holds a lease for IPv6 address and/or prefix.
std::string readAt(const size_t at) const
Retrieves a value from the internal container.
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.
Represents a single row of the CSV file.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
uint32_t write_leases_
Number of lease written.
void append(const Lease6 &lease)
Appends the lease record to the CSV file.
T readAndConvertAt(const size_t at) const
Retrieves a value from the internal container.
uint32_t write_errs_
Number of errors when writing.
virtual void open(const bool seek_to_end=false)
Opens a lease file.
std::string toText() const
Convert the address to a string.
uint32_t read_leases_
Number of leases read.
Implements a CSV file that supports multiple versions of the file's "schema".
time_t cltt_
Client last transmission time.
bool fqdn_rev_
Reverse zone updated?
HWAddrPtr hwaddr_
Client's MAC/hardware address.
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.
void clearStatistics()
Clears the statistics.
uint32_t preferred_lft_
preferred lifetime
boost::shared_ptr< const Element > ConstElementPtr
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
size_t getColumnIndex(const std::string &col_name) const
Returns the index of the column having specified name.
uint32_t reads_
Number of attempts to read a lease.
std::string hostname_
Client hostname.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
SubnetID subnet_id_
Subnet identifier.
DuidPtr duid_
Client identifier.
static HWAddr fromText(const std::string &text, const uint16_t htype=HTYPE_ETHER)
Creates instance of the hardware address from textual format.