|
@@ -52,6 +52,7 @@ CommandOptions::reset() {
|
|
|
// will need to reset all members many times to perform unit tests
|
|
|
ipversion_ = 0;
|
|
|
exchange_mode_ = DORA_SARR;
|
|
|
+ lease_type_ = ADDRESS_ONLY;
|
|
|
rate_ = 0;
|
|
|
report_delay_ = 0;
|
|
|
clients_num_ = 0;
|
|
@@ -150,7 +151,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
|
|
|
// In this section we collect argument values from command line
|
|
|
// they will be tuned and validated elsewhere
|
|
|
while((opt = getopt(argc, argv, "hv46r:t:R:b:n:p:d:D:l:P:a:L:"
|
|
|
- "s:iBc1T:X:O:E:S:I:x:w:")) != -1) {
|
|
|
+ "s:iBc1T:X:O:E:S:I:x:w:e:")) != -1) {
|
|
|
stream << " -" << static_cast<char>(opt);
|
|
|
if (optarg) {
|
|
|
stream << " " << optarg;
|
|
@@ -232,6 +233,10 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
+ case 'e':
|
|
|
+ initLeaseType();
|
|
|
+ break;
|
|
|
+
|
|
|
case 'E':
|
|
|
elp_offset_ = nonNegativeInteger("value of time-offset: -E<value>"
|
|
|
" must not be a negative integer");
|
|
@@ -620,6 +625,11 @@ CommandOptions::validate() const {
|
|
|
"-6 (IPv6) must be set to use -c");
|
|
|
check((getExchangeMode() == DO_SA) && (getNumRequests().size() > 1),
|
|
|
"second -n<num-request> is not compatible with -i");
|
|
|
+ check((getIpVersion() == 4) && (getLeaseType() != ADDRESS_ONLY),
|
|
|
+ "-6 option must be used if lease type other than '-e address-only'"
|
|
|
+ " is specified");
|
|
|
+ check(!getTemplateFiles().empty() && (getLeaseType() != ADDRESS_ONLY),
|
|
|
+ "template files may be only used with '-e address-only'");
|
|
|
check((getExchangeMode() == DO_SA) && (getDropTime()[1] != 1.),
|
|
|
"second -d<drop-time> is not compatible with -i");
|
|
|
check((getExchangeMode() == DO_SA) &&
|
|
@@ -706,6 +716,22 @@ CommandOptions::nonEmptyString(const std::string& errmsg) const {
|
|
|
}
|
|
|
|
|
|
void
|
|
|
+CommandOptions::initLeaseType() {
|
|
|
+ std::string lease_type_arg = optarg;
|
|
|
+ if (lease_type_arg == "address-only") {
|
|
|
+ lease_type_ = ADDRESS_ONLY;
|
|
|
+
|
|
|
+ } else if (lease_type_arg == "prefix-only") {
|
|
|
+ lease_type_ = PREFIX_ONLY;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ isc_throw(isc::InvalidParameter, "value of lease-type: -e<lease-type>,"
|
|
|
+ " must be one of the following: 'address-only' or"
|
|
|
+ " 'prefix-only'");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
CommandOptions::printCommandLine() const {
|
|
|
std::cout << "IPv" << static_cast<int>(ipversion_) << std::endl;
|
|
|
if (exchange_mode_ == DO_SA) {
|
|
@@ -800,13 +826,13 @@ CommandOptions::printCommandLine() const {
|
|
|
void
|
|
|
CommandOptions::usage() const {
|
|
|
std::cout <<
|
|
|
- "perfdhcp [-hv] [-4|-6] [-r<rate>] [-t<report>] [-R<range>] [-b<base>]\n"
|
|
|
- " [-n<num-request>] [-p<test-period>] [-d<drop-time>] [-D<max-drop>]\n"
|
|
|
- " [-l<local-addr|interface>] [-P<preload>] [-a<aggressivity>]\n"
|
|
|
- " [-L<local-port>] [-s<seed>] [-i] [-B] [-c] [-1]\n"
|
|
|
- " [-T<template-file>] [-X<xid-offset>] [-O<random-offset]\n"
|
|
|
- " [-E<time-offset>] [-S<srvid-offset>] [-I<ip-offset>]\n"
|
|
|
- " [-x<diagnostic-selector>] [-w<wrapped>] [server]\n"
|
|
|
+ "perfdhcp [-hv] [-4|-6] [-e<lease-type>] [-r<rate>] [-t<report>]\n"
|
|
|
+ " [-R<range>] [-b<base>] [-n<num-request>] [-p<test-period>]\n"
|
|
|
+ " [-d<drop-time>] [-D<max-drop>] [-l<local-addr|interface>]\n"
|
|
|
+ " [-P<preload>] [-a<aggressivity>] [-L<local-port>] [-s<seed>]\n"
|
|
|
+ " [-i] [-B] [-c] [-1] [-T<template-file>] [-X<xid-offset>]\n"
|
|
|
+ " [-O<random-offset] [-E<time-offset>] [-S<srvid-offset>]\n"
|
|
|
+ " [-I<ip-offset>] [-x<diagnostic-selector>] [-w<wrapped>] [server]\n"
|
|
|
"\n"
|
|
|
"The [server] argument is the name/address of the DHCP server to\n"
|
|
|
"contact. For DHCPv4 operation, exchanges are initiated by\n"
|
|
@@ -838,6 +864,11 @@ CommandOptions::usage() const {
|
|
|
"-d<drop-time>: Specify the time after which a requeqst is treated as\n"
|
|
|
" having been lost. The value is given in seconds and may contain a\n"
|
|
|
" fractional component. The default is 1 second.\n"
|
|
|
+ "-e<lease-type>: A type of lease being requested from the server. It\n"
|
|
|
+ " may be one of the following: address-only or prefix-only. The\n"
|
|
|
+ " former indicates that the regular IP (v4 or v6) will be requested,\n"
|
|
|
+ " the latter indicates that the IPv6 prefixes will be requested. The\n"
|
|
|
+ " '-e prefix-only' must not be used with -4.\n"
|
|
|
"-E<time-offset>: Offset of the (DHCPv4) secs field / (DHCPv6)\n"
|
|
|
" elapsed-time option in the (second/request) template.\n"
|
|
|
" The value 0 disables it.\n"
|