summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotrek Zadroga <piotrek@isc.org>2024-01-15 12:03:39 +0100
committerPiotrek Zadroga <piotrek@isc.org>2024-01-15 12:03:39 +0100
commitcf22095d8ecca00c6ed2338123f34b0a30bd711b (patch)
tree14524ecc97308c06b1dd08d86bee32b755d526de
parent[#3074] internal opt type refactor (diff)
downloadkea-cf22095d8ecca00c6ed2338123f34b0a30bd711b.tar.xz
kea-cf22095d8ecca00c6ed2338123f34b0a30bd711b.zip
[#3074] addressed review comments
-rw-r--r--src/lib/dhcp/option_classless_static_route.cc8
-rw-r--r--src/lib/dhcp/tests/option_classless_static_route_unittest.cc3
2 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/dhcp/option_classless_static_route.cc b/src/lib/dhcp/option_classless_static_route.cc
index edabeda074..6b22b7ca2a 100644
--- a/src/lib/dhcp/option_classless_static_route.cc
+++ b/src/lib/dhcp/option_classless_static_route.cc
@@ -225,9 +225,9 @@ OptionClasslessStaticRoute::parseConfigData(const std::string& config_txt) {
try {
subnet_addr = IOAddress(txt_subnet_addr);
if (!subnet_addr.isV4()) {
- isc_throw(IOError, "This is not IPv4 address.");
+ isc_throw(BadValue, "This is not IPv4 address.");
}
- } catch (const IOError& e) {
+ } catch (const std::exception& e) {
isc_throw(BadValue, "DHCPv4 OptionClasslessStaticRoute "
<< type_ << " has invalid value, provided subnet_addr "
<< txt_subnet_addr << " is not a valid IPv4 address. "
@@ -255,9 +255,9 @@ OptionClasslessStaticRoute::parseConfigData(const std::string& config_txt) {
try {
router_addr = IOAddress(txt_router);
if (!router_addr.isV4()) {
- isc_throw(IOError, "This is not IPv4 address.");
+ isc_throw(BadValue, "This is not IPv4 address.");
}
- } catch (const IOError& e) {
+ } catch (const std::exception& e) {
isc_throw(BadValue, "DHCPv4 OptionClasslessStaticRoute "
<< type_ << " has invalid value, provided router address "
<< txt_router << " is not a valid IPv4 address. "
diff --git a/src/lib/dhcp/tests/option_classless_static_route_unittest.cc b/src/lib/dhcp/tests/option_classless_static_route_unittest.cc
index 329952dc90..caa12303e6 100644
--- a/src/lib/dhcp/tests/option_classless_static_route_unittest.cc
+++ b/src/lib/dhcp/tests/option_classless_static_route_unittest.cc
@@ -46,6 +46,9 @@ TEST(OptionClasslessStaticRouteTest, bufferFromStrCtorWithOneRoute) {
// 3 static routes are defined.
TEST(OptionClasslessStaticRouteTest, bufferFromStrCtorWithMoreRoutes) {
// Prepare data to decode - 3 static routes
+ // White space added/missing inconsistency is on purpose,
+ // it simulates real user typing inconsistent config.
+ // Trimming spaces in config is tested as well.
const std::string config = "0.0.0.0/0 - 10.17.0.1,10.229.0.128/25-10.229.0.1, "
"10.27.129.0/24 - 10.27.129.1";
OptionBuffer buf;