namespace perfdhcp {
CommandOptions::LeaseType::LeaseType()
- : type_(ADDRESS_ONLY) {
+ : type_(ADDRESS) {
}
CommandOptions::LeaseType::LeaseType(const Type lease_type)
void
CommandOptions::LeaseType::fromCommandLine(const std::string& cmd_line_arg) {
if (cmd_line_arg == "address-only") {
- type_ = ADDRESS_ONLY;
+ type_ = ADDRESS;
} else if (cmd_line_arg == "prefix-only") {
- type_ = PREFIX_ONLY;
+ type_ = PREFIX;
} else if (cmd_line_arg == "address-and-prefix") {
type_ = ADDRESS_AND_PREFIX;
std::string
CommandOptions::LeaseType::toText() const {
switch (type_) {
- case ADDRESS_ONLY:
+ case ADDRESS:
return ("address-only (IA_NA option added to the client's request)");
- case PREFIX_ONLY:
+ case PREFIX:
return ("prefix-only (IA_PD option added to the client's request)");
case ADDRESS_AND_PREFIX:
return ("address-and-prefix (Both IA_NA and IA_PD options added to the"
// will need to reset all members many times to perform unit tests
ipversion_ = 0;
exchange_mode_ = DORA_SARR;
- lease_type_.set(LeaseType::ADDRESS_ONLY);
+ lease_type_.set(LeaseType::ADDRESS);
rate_ = 0;
report_delay_ = 0;
clients_num_ = 0;
"-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().is(LeaseType::ADDRESS_ONLY),
+ check((getIpVersion() == 4) && !getLeaseType().is(LeaseType::ADDRESS),
"-6 option must be used if lease type other than '-e address-only'"
" is specified");
check(!getTemplateFiles().empty() &&
- !getLeaseType().is(LeaseType::ADDRESS_ONLY),
+ !getLeaseType().is(LeaseType::ADDRESS),
"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");
TEST(LeaseTypeTest, defaultConstructor) {
CommandOptions::LeaseType lease_type;
- EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS));
}
TEST(LeaseTypeTest, constructor) {
CommandOptions::LeaseType
- lease_type1(CommandOptions::LeaseType::ADDRESS_ONLY);
- EXPECT_TRUE(lease_type1.is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ lease_type1(CommandOptions::LeaseType::ADDRESS);
+ EXPECT_TRUE(lease_type1.is(CommandOptions::LeaseType::ADDRESS));
CommandOptions::LeaseType
- lease_type2(CommandOptions::LeaseType::PREFIX_ONLY);
- EXPECT_TRUE(lease_type2.is(CommandOptions::LeaseType::PREFIX_ONLY));
+ lease_type2(CommandOptions::LeaseType::PREFIX);
+ EXPECT_TRUE(lease_type2.is(CommandOptions::LeaseType::PREFIX));
}
TEST(LeaseTypeTest, set) {
CommandOptions::LeaseType
- lease_type(CommandOptions::LeaseType::ADDRESS_ONLY);
- EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ lease_type(CommandOptions::LeaseType::ADDRESS);
+ EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS));
- lease_type.set(CommandOptions::LeaseType::PREFIX_ONLY);
- EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::PREFIX_ONLY));
+ lease_type.set(CommandOptions::LeaseType::PREFIX);
+ EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::PREFIX));
}
TEST(LeaseTypeTest, includes) {
CommandOptions::LeaseType
- lease_type(CommandOptions::LeaseType::ADDRESS_ONLY);
- ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS_ONLY));
- EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::ADDRESS_ONLY));
- EXPECT_FALSE(lease_type.includes(CommandOptions::LeaseType::PREFIX_ONLY));
+ lease_type(CommandOptions::LeaseType::ADDRESS);
+ ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS));
+ EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::ADDRESS));
+ EXPECT_FALSE(lease_type.includes(CommandOptions::LeaseType::PREFIX));
EXPECT_FALSE(
lease_type.includes(CommandOptions::LeaseType::ADDRESS_AND_PREFIX)
);
- lease_type.set(CommandOptions::LeaseType::PREFIX_ONLY);
- EXPECT_FALSE(lease_type.includes(CommandOptions::LeaseType::ADDRESS_ONLY));
- EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::PREFIX_ONLY));
+ lease_type.set(CommandOptions::LeaseType::PREFIX);
+ EXPECT_FALSE(lease_type.includes(CommandOptions::LeaseType::ADDRESS));
+ EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::PREFIX));
EXPECT_FALSE(
lease_type.includes(CommandOptions::LeaseType::ADDRESS_AND_PREFIX)
);
lease_type.set(CommandOptions::LeaseType::ADDRESS_AND_PREFIX);
- EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::ADDRESS_ONLY));
- EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::PREFIX_ONLY));
+ EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::ADDRESS));
+ EXPECT_TRUE(lease_type.includes(CommandOptions::LeaseType::PREFIX));
EXPECT_TRUE(
lease_type.includes(CommandOptions::LeaseType::ADDRESS_AND_PREFIX)
);
TEST(LeaseTypeTest, fromCommandLine) {
CommandOptions::LeaseType
- lease_type(CommandOptions::LeaseType::ADDRESS_ONLY);
- ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ lease_type(CommandOptions::LeaseType::ADDRESS);
+ ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS));
lease_type.fromCommandLine("prefix-only");
- ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::PREFIX_ONLY));
+ ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::PREFIX));
lease_type.fromCommandLine("address-only");
- EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ EXPECT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS));
EXPECT_THROW(lease_type.fromCommandLine("bogus-parameter"),
isc::InvalidParameter);
TEST(LeaseTypeTest, toText) {
CommandOptions::LeaseType lease_type;
- ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ ASSERT_TRUE(lease_type.is(CommandOptions::LeaseType::ADDRESS));
EXPECT_EQ("address-only (IA_NA option added to the client's request)",
lease_type.toText());
- lease_type.set(CommandOptions::LeaseType::PREFIX_ONLY);
+ lease_type.set(CommandOptions::LeaseType::PREFIX);
EXPECT_EQ("prefix-only (IA_PD option added to the client's request)",
lease_type.toText());
}
EXPECT_NO_THROW(process("perfdhcp 192.168.0.1"));
EXPECT_EQ(4, opt.getIpVersion());
EXPECT_EQ(CommandOptions::DORA_SARR, opt.getExchangeMode());
- EXPECT_TRUE(opt.getLeaseType()
- .is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::ADDRESS));
EXPECT_EQ(0, opt.getRate());
EXPECT_EQ(0, opt.getReportDelay());
EXPECT_EQ(0, opt.getClientsNum());
ASSERT_NO_THROW(process("perfdhcp -6 -l etx -e address-only all"));
EXPECT_EQ(6, opt.getIpVersion());
EXPECT_EQ("etx", opt.getLocalName());
- EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::ADDRESS));
// Check that the -e address-only works for IPv4.
ASSERT_NO_THROW(process("perfdhcp -4 -l etx -e address-only all"));
EXPECT_EQ(4, opt.getIpVersion());
EXPECT_EQ("etx", opt.getLocalName());
- EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::ADDRESS_ONLY));
+ EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::ADDRESS));
// Check that the -e prefix-only works.
ASSERT_NO_THROW(process("perfdhcp -6 -l etx -e prefix-only all"));
EXPECT_EQ(6, opt.getIpVersion());
EXPECT_EQ("etx", opt.getLocalName());
- EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::PREFIX_ONLY));
+ EXPECT_TRUE(opt.getLeaseType().is(CommandOptions::LeaseType::PREFIX));
// Check that -e prefix-only must not coexist with -4 option.
EXPECT_THROW(process("perfdhcp -4 -l ethx -e prefix-only all"),
InvalidParameter);