123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- // Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
- //
- // Permission to use, copy, modify, and/or distribute this software for any
- // purpose with or without fee is hereby granted, provided that the above
- // copyright notice and this permission notice appear in all copies.
- //
- // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- #ifndef CSV_LEASE_FILE6_H
- #define CSV_LEASE_FILE6_H
- #include <asiolink/io_address.h>
- #include <dhcp/duid.h>
- #include <dhcpsrv/lease.h>
- #include <dhcpsrv/subnet.h>
- #include <util/csv_file.h>
- #include <boost/shared_ptr.hpp>
- #include <stdint.h>
- #include <string>
- namespace isc {
- namespace dhcp {
- /// @brief Provides methods to access CSV file with DHCPv6 leases.
- class CSVLeaseFile6 : public isc::util::CSVFile {
- public:
- /// @brief Constructor.
- ///
- /// Initializes columns of the lease file.
- ///
- /// @param filename Name of the lease file.
- CSVLeaseFile6(const std::string& filename);
- /// @brief Appends the lease record to the CSV file.
- ///
- /// @param lease Structure representing a DHCPv6 lease.
- void append(const Lease6& lease) const;
- /// @brief Reads next lease from the CSV file.
- ///
- /// If this function hits an error during lease read, it sets the error
- /// message using @c CSVFile::setReadMsg and returns false. The error
- /// string may be read using @c CSVFile::getReadMsg.
- ///
- /// @param [out] lease Pointer to the lease read from CSV file or
- /// NULL pointer if lease hasn't been read.
- ///
- /// @return Boolean value indicating that the new lease has been
- /// read from the CSV file (if true), or that the error has occurred
- /// (false).
- bool next(Lease6Ptr& lease);
- private:
- /// @brief Initializes columns of the CSV file holding leases.
- ///
- /// This function initializes the following columns:
- /// - address
- /// - duid
- /// - valid_lifetime
- /// - expire
- /// - subnet_id
- /// - pref_lifetime
- /// - lease_type
- /// - iaid
- /// - prefix_len
- /// - fqdn_fwd
- /// - fqdn_rev
- /// - hostname
- void initColumns();
- ///
- /// @name Methods which read specific lease fields from the CSV row.
- ///
- //@{
- ///
- /// @brief Reads lease type from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- Lease::Type readType(const util::CSVRow& row);
- /// @brief Reads lease address from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- asiolink::IOAddress readAddress(const util::CSVRow& row);
- /// @brief Reads DUID from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- DuidPtr readDUID(const util::CSVRow& row);
- /// @brief Reads IAID from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- uint32_t readIAID(const util::CSVRow& row);
- /// @brief Reads preferred lifetime from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- uint32_t readPreferred(const util::CSVRow& row);
- /// @brief Reads valid lifetime from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- uint32_t readValid(const util::CSVRow& row);
- /// @brief Reads cltt value from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- uint32_t readCltt(const util::CSVRow& row);
- /// @brief Reads subnet id from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- SubnetID readSubnetID(const util::CSVRow& row);
- /// @brief Reads prefix length from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- uint8_t readPrefixLen(const util::CSVRow& row);
- /// @brief Reads the FQDN forward flag from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- bool readFqdnFwd(const util::CSVRow& row);
- /// @brief Reads the FQDN reverse flag from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- bool readFqdnRev(const util::CSVRow& row);
- /// @brief Reads hostname from the CSV file row.
- ///
- /// @param row CSV file holding lease values.
- std::string readHostname(const util::CSVRow& row);
- //@}
- };
- } // namespace isc::dhcp
- } // namespace isc
- #endif // CSV_LEASE_FILE6_H
|