|
@@ -17,7 +17,6 @@
|
|
#include <exceptions/exceptions.h>
|
|
#include <exceptions/exceptions.h>
|
|
#include <log/logger_support.h>
|
|
#include <log/logger_support.h>
|
|
#include <log/logger_manager.h>
|
|
#include <log/logger_manager.h>
|
|
-//#include <dhcpsrv/cfgmgr.h>
|
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
|
|
using namespace std;
|
|
using namespace std;
|
|
@@ -27,23 +26,23 @@ namespace lfc {
|
|
|
|
|
|
/// @brief Defines the application name, it may be used to locate
|
|
/// @brief Defines the application name, it may be used to locate
|
|
/// configuration data and appears in log statements.
|
|
/// configuration data and appears in log statements.
|
|
-const char* lfc::lfc_app_name_ = "DhcpLFC";
|
|
|
|
|
|
+const char* lfcController::lfc_app_name_ = "DhcpLFC";
|
|
|
|
|
|
/// @brief Defines the executable name.
|
|
/// @brief Defines the executable name.
|
|
-const char*lfc::lfc_bin_name_ = "kea-lfc";
|
|
|
|
|
|
+const char* lfcController::lfc_bin_name_ = "kea-lfc";
|
|
|
|
|
|
-lfc::lfc()
|
|
|
|
- : dhcp_version_(0), verbose_(false), config_file_(""),
|
|
|
|
- previous_file_(""), copy_file_(""), output_file_("") {
|
|
|
|
|
|
+lfcController::lfcController()
|
|
|
|
+ : protocol_version_(0), verbose_(false), config_file_(""), previous_file_(""),
|
|
|
|
+ copy_file_(""), output_file_(""), finish_file_(""), pid_file_("./test_pid") {
|
|
std::cerr << "created lfc" << std::endl;
|
|
std::cerr << "created lfc" << std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
-lfc::~lfc() {
|
|
|
|
|
|
+lfcController::~lfcController() {
|
|
std::cerr << "destroyed lfc" << std::endl;
|
|
std::cerr << "destroyed lfc" << std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-lfc::launch(int argc, char* argv[], const bool test_mode) {
|
|
|
|
|
|
+lfcController::launch(int argc, char* argv[], const bool test_mode) {
|
|
try {
|
|
try {
|
|
parseArgs(argc, argv);
|
|
parseArgs(argc, argv);
|
|
} catch (const InvalidUsage& ex) {
|
|
} catch (const InvalidUsage& ex) {
|
|
@@ -55,30 +54,30 @@ lfc::launch(int argc, char* argv[], const bool test_mode) {
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-lfc::parseArgs(int argc, char* argv[])
|
|
|
|
|
|
+lfcController::parseArgs(int argc, char* argv[])
|
|
{
|
|
{
|
|
int ch;
|
|
int ch;
|
|
|
|
|
|
- while ((ch = getopt(argc, argv, "46dvVp:i:o:c:")) != -1) {
|
|
|
|
|
|
+ while ((ch = getopt(argc, argv, "46dvVp:i:o:c:f:")) != -1) {
|
|
switch (ch) {
|
|
switch (ch) {
|
|
case '4':
|
|
case '4':
|
|
// Process DHCPv4 lease files.
|
|
// Process DHCPv4 lease files.
|
|
- dhcp_version_ = 4;
|
|
|
|
|
|
+ protocol_version_ = 4;
|
|
break;
|
|
break;
|
|
|
|
|
|
case '6':
|
|
case '6':
|
|
// Process DHCPv6 lease files.
|
|
// Process DHCPv6 lease files.
|
|
- dhcp_version_ = 6;
|
|
|
|
|
|
+ protocol_version_ = 6;
|
|
break;
|
|
break;
|
|
|
|
|
|
case 'v':
|
|
case 'v':
|
|
// Print just Kea vesion and exit.
|
|
// Print just Kea vesion and exit.
|
|
- // std::cout << getVersion(false) << std::endl;
|
|
|
|
|
|
+ std::cout << getVersion(false) << std::endl;
|
|
exit(EXIT_SUCCESS);
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
case 'V':
|
|
case 'V':
|
|
// Print extended Kea vesion and exit.
|
|
// Print extended Kea vesion and exit.
|
|
- //std::cout << getVersion(true) << std::endl;
|
|
|
|
|
|
+ std::cout << getVersion(true) << std::endl;
|
|
exit(EXIT_SUCCESS);
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
case 'd':
|
|
case 'd':
|
|
@@ -110,6 +109,14 @@ lfc::parseArgs(int argc, char* argv[])
|
|
output_file_ = optarg;
|
|
output_file_ = optarg;
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+ case 'f':
|
|
|
|
+ // Output file name.
|
|
|
|
+ if (optarg == NULL) {
|
|
|
|
+ isc_throw(InvalidUsage, "Finish file name missing");
|
|
|
|
+ }
|
|
|
|
+ finish_file_ = optarg;
|
|
|
|
+ break;
|
|
|
|
+
|
|
case 'c':
|
|
case 'c':
|
|
// Previous file name.
|
|
// Previous file name.
|
|
if (optarg == NULL) {
|
|
if (optarg == NULL) {
|
|
@@ -128,7 +135,7 @@ lfc::parseArgs(int argc, char* argv[])
|
|
isc_throw(InvalidUsage, "Extraneous parameters.");
|
|
isc_throw(InvalidUsage, "Extraneous parameters.");
|
|
}
|
|
}
|
|
|
|
|
|
- if (dhcp_version_ == 0) {
|
|
|
|
|
|
+ if (protocol_version_ == 0) {
|
|
isc_throw(InvalidUsage, "DHCP version required");
|
|
isc_throw(InvalidUsage, "DHCP version required");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -144,43 +151,57 @@ lfc::parseArgs(int argc, char* argv[])
|
|
isc_throw(InvalidUsage, "Output file not specified");
|
|
isc_throw(InvalidUsage, "Output file not specified");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (finish_file_.empty()) {
|
|
|
|
+ isc_throw(InvalidUsage, "Finish file not specified");
|
|
|
|
+ }
|
|
|
|
+
|
|
if (config_file_.empty()) {
|
|
if (config_file_.empty()) {
|
|
isc_throw(InvalidUsage, "Config file not specified");
|
|
isc_throw(InvalidUsage, "Config file not specified");
|
|
}
|
|
}
|
|
|
|
|
|
// If verbose is set echo the input information
|
|
// If verbose is set echo the input information
|
|
if (verbose_ == true) {
|
|
if (verbose_ == true) {
|
|
- std::cerr << "Protocol version: " << dhcp_version_ << std::endl
|
|
|
|
|
|
+ std::cerr << "Protocol version: " << protocol_version_ << std::endl
|
|
<< "Previous lease file: " << previous_file_ << std::endl
|
|
<< "Previous lease file: " << previous_file_ << std::endl
|
|
<< "Copy lease file: " << copy_file_ << std::endl
|
|
<< "Copy lease file: " << copy_file_ << std::endl
|
|
<< "Output lease file: " << output_file_ << std::endl
|
|
<< "Output lease file: " << output_file_ << std::endl
|
|
- << "Config file: " << config_file_ << std::endl;
|
|
|
|
|
|
+ << "Finishn file: " << finish_file_ << std::endl
|
|
|
|
+ << "Config file: " << config_file_ << std::endl
|
|
|
|
+ << "PID file: " << pid_file_ << std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void
|
|
|
|
-lfc::pidCheck()
|
|
|
|
|
|
+bool
|
|
|
|
+lfcController::pidCheck(const std::string & pid_file)
|
|
|
|
+{
|
|
|
|
+ return (false);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool
|
|
|
|
+lfcController::pidWrite(const std::string & pid_file)
|
|
{
|
|
{
|
|
|
|
+ return (true);
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-lfc::pidDelete()
|
|
|
|
|
|
+lfcController::pidDelete(const std::string & pid_file)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-lfc::usage(const std::string & text)
|
|
|
|
|
|
+lfcController::usage(const std::string & text)
|
|
{
|
|
{
|
|
if (text != "") {
|
|
if (text != "") {
|
|
std::cerr << "Usage error: " << text << std::endl;
|
|
std::cerr << "Usage error: " << text << std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
std::cerr << "Usage: " << lfc_bin_name_ << std::endl
|
|
std::cerr << "Usage: " << lfc_bin_name_ << std::endl
|
|
- << " [-4|-6] -p file -i file -o file -c file" << std::endl
|
|
|
|
|
|
+ << " [-4|-6] -p file -i file -o file -f file -c file" << std::endl
|
|
<< " -4 or -6 clean a set of v4 or v6 lease files" << std::endl
|
|
<< " -4 or -6 clean a set of v4 or v6 lease files" << std::endl
|
|
<< " -p <file>: previous lease file" << std::endl
|
|
<< " -p <file>: previous lease file" << std::endl
|
|
<< " -i <file>: copy of lease file" << std::endl
|
|
<< " -i <file>: copy of lease file" << std::endl
|
|
<< " -o <file>: output lease file" << std::endl
|
|
<< " -o <file>: output lease file" << std::endl
|
|
|
|
+ << " -f <file>: finish file" << std::endl
|
|
<< " -c <file>: configuration file" << std::endl
|
|
<< " -c <file>: configuration file" << std::endl
|
|
<< " -v: print version number and exit" << std::endl
|
|
<< " -v: print version number and exit" << std::endl
|
|
<< " -V: print extended version inforamtion and exit" << std::endl
|
|
<< " -V: print extended version inforamtion and exit" << std::endl
|
|
@@ -188,21 +209,17 @@ lfc::usage(const std::string & text)
|
|
<< std::endl;
|
|
<< std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+std::string
|
|
|
|
+lfcController::getVersion(bool extended) {
|
|
|
|
+ std::stringstream tmp;
|
|
|
|
+
|
|
|
|
+ tmp << VERSION;
|
|
|
|
+ if (extended) {
|
|
|
|
+ tmp << std::endl << EXTENDED_VERSION;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return (tmp.str());
|
|
|
|
+}
|
|
|
|
+
|
|
}; // namespace isc::lfc
|
|
}; // namespace isc::lfc
|
|
}; // namespace isc
|
|
}; // namespace isc
|
|
-
|
|
|
|
-//std::string
|
|
|
|
-//isc::dhcp::Daemon::getVersion(bool extended) {
|
|
|
|
-// std::stringstream tmp;
|
|
|
|
-//
|
|
|
|
-// tmp << VERSION;
|
|
|
|
-// if (extended) {
|
|
|
|
-// tmp << std::endl << EXTENDED_VERSION;
|
|
|
|
-//
|
|
|
|
- // @todo print more details (is it Botan or OpenSSL build,
|
|
|
|
- // with or without MySQL/Postgres? What compilation options were
|
|
|
|
- // used? etc)
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return (tmp.str());
|
|
|
|
-//}
|
|
|