7#ifndef COMMAND_OPTIONS_H
8#define COMMAND_OPTIONS_H
16#include <boost/noncopyable.hpp>
76 bool is(
const Type lease_type)
const;
98 void set(
const Type lease_type);
113 std::string
toText()
const;
143 bool parse(
int argc,
char**
const argv,
bool print_cmd_line =
false);
208 std::vector<std::string>
getBase()
const {
return base_; }
422 std::string
getRandRelayAddr() {
return relay_addr_list_[rand() % relay_addr_list_.size()]; }
434 if (
getDiags().find(diag) != std::string::npos) {
464 bool initialize(
int argc,
char** argv,
bool print_cmd_line);
482 inline void check(
bool condition,
const std::string& errmsg)
const;
488 int positiveInteger(
const std::string& errmsg)
const;
494 int nonNegativeInteger(
const std::string& errmsg)
const;
500 std::string nonEmptyString(
const std::string& errmsg)
const;
505 void initLeaseType();
513 void initClientsNum();
520 void initIsInterface();
537 void decodeBase(
const std::string& base);
548 void decodeMacBase(
const std::string& base);
559 void decodeDuid(
const std::string& base);
567 void generateDuidTemplate();
573 uint8_t convertHexString(
const std::string& hex_text)
const;
581 bool decodeMacString(
const std::string& line);
584 void loadRelayAddr();
590 bool validateIP(
const std::string& line);
600 LeaseType lease_type_;
606 unsigned int renew_rate_;
609 unsigned int release_rate_;
618 std::string clean_report_separator_;
621 uint32_t clients_num_;
625 std::vector<uint8_t> mac_template_;
629 std::vector<uint8_t> duid_template_;
636 std::vector<std::string> base_;
642 std::vector<int> num_request_;
649 int wait_for_elapsed_time_;
653 int increased_elapsed_time_;
657 uint8_t drop_time_set_;
662 std::vector<double> drop_time_;
668 std::vector<int> max_drop_;
673 std::vector<double> max_pdrop_;
676 std::string localname_;
711 std::vector<std::string> template_file_;
718 std::string mac_list_file_;
721 std::vector<std::vector<uint8_t> > mac_list_;
724 std::string relay_addr_list_file_;
727 std::vector<std::string> relay_addr_list_;
736 std::vector<int> xid_offset_;
741 std::vector<int> rnd_offset_;
758 std::string wrapped_;
761 std::string server_name_;
764 uint8_t v6_relay_encapsulation_level_;
770 std::map<uint8_t, isc::dhcp::OptionCollection> relay_opts_;
773 bool single_thread_mode_;
A class encapsulating the type of lease being requested from the server.
void set(const Type lease_type)
Sets the lease type code.
void fromCommandLine(const std::string &cmd_line_arg)
Sets the lease type from the command line argument.
bool is(const Type lease_type) const
Checks if lease type has the specified code.
std::string toText() const
Return textual representation of the lease type.
bool includes(const Type lease_type) const
Checks if lease type implies request for the address, prefix (or both) as specified by the function a...
bool testDiags(const char diag)
Find if diagnostic flag has been set.
std::string getRandRelayAddr()
Returns random relay address.
int getIncreaseElapsedTime() const
Returns increased elapsed time.
CommandOptions()
Default Constructor.
std::vector< std::string > getBase() const
Returns base values.
int getServerIdOffset() const
Returns template offset for server-ID.
std::string getWrapped() const
Returns wrapped command.
bool isSingleThreaded() const
Check if single-threaded mode is enabled.
int getRenewRate() const
Returns a rate at which DHCPv6 Renew messages are sent.
uint8_t getIpVersion() const
Returns IP version.
std::vector< uint8_t > getDuidTemplate() const
Returns DUID template.
bool getAddrUnique() const
Returns address uniqueness value.
int getRate() const
Returns exchange rate.
void version() const
Print program version.
std::string getCleanReportSeparator() const
Returns clean report separator.
bool isRapidCommit() const
Check if rapid commit option used.
std::string getLocalName() const
Returns local address or interface name.
bool checkMultiSubnet()
Check if multi subnet mode is enabled.
const isc::dhcp::OptionCollection & getExtraOpts() const
Returns extra options to be inserted.
bool isUseFirst() const
Check if server-ID to be taken from first package.
std::string getRelayAddrListFile() const
Returns file location with set of relay addresses.
int getLocalPort() const
Returns local port number.
void extendedVersion() const
Print extended program version.
std::string getMacListFile() const
Returns location of the file containing list of MAC addresses.
int getReportDelay() const
Returns delay between two performance reports.
std::vector< int > getRandomOffset() const
Returns template offsets for rnd.
std::vector< double > getMaxDropPercentage() const
Returns maximal percentage of drops.
int getRemotePort() const
Returns remote port number.
Scenario getScenario() const
Returns selected scenario.
std::vector< std::string > getRelayAddrList() const
Returns list of relay addresses.
static const uint8_t RELAY_OPTIONS_MAX_ENCAPSULATION
Maximum allowed level of encapsulation of added relay options.
int getWaitForElapsedTime() const
Returns time to wait for elapsed time increase.
const MacAddrsVector & getMacsFromFile() const
Returns reference to a vector of MAC addresses read from a file.
bool isBroadcast() const
Checks if broadcast address is to be used.
std::vector< std::string > getTemplateFiles() const
Returns template file names.
std::vector< int > getTransactionIdOffset() const
brief Returns template offsets for xid.
std::vector< std::vector< uint8_t > > MacAddrsVector
A vector holding MAC addresses.
ExchangeMode
2-way (cmd line param -i) or 4-way exchanges
int getElapsedTimeOffset() const
Returns template offset for elapsed time.
std::string getServerName() const
Returns server name.
const isc::dhcp::OptionCollection & getRelayOpts(uint8_t encapsulation_level=1) const
Returns relay options to be inserted at given level of encapsulation.
std::vector< int > getNumRequests() const
Returns maximum number of exchanges.
LeaseType getLeaseType() const
\ brief Returns the type of lease being requested.
bool isUseRelayedV6() const
Check if generated DHCPv6 messages should appear as relayed.
int getExitWaitTime() const
Returns the time in microseconds to delay the program by.
uint32_t getClientsNum() const
Returns number of simulated clients.
int getPreload() const
Returns number of preload exchanges.
bool isSeeded() const
Checks if seed provided.
void reset()
Reset to defaults.
std::vector< double > getDropTime() const
Returns drop time.
std::vector< int > getMaxDrop() const
Returns maximum drops number.
int getPeriod() const
Returns test period.
static void usage()
Print usage.
bool parse(int argc, char **const argv, bool print_cmd_line=false)
Parse command line.
std::string getDiags() const
Returns diagnostic selectors.
int getReleaseRate() const
Returns a rate at which DHCPv6 Release messages are sent.
uint32_t getSeed() const
Returns random seed.
ExchangeMode getExchangeMode() const
Returns packet exchange mode.
void printCommandLine() const
Print command line arguments.
int getCleanReport() const
Returns clean report mode.
bool isInterface() const
Checks if interface name was used.
std::vector< uint8_t > getMacTemplate() const
Returns MAC address template.
int getRequestedIpOffset() const
Returns template offset for requested IP.
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
Defines the logger used by the top-level component of kea-lfc.