isc_throw(Unexpected, "pointer to parsed lease is null");
}
- bool is_v6 = static_cast<bool>(boost::dynamic_pointer_cast<Lease6>(lease));
-
// IP address.
ConstElementPtr ip_address = element->get("ip-address");
if (!ip_address || (ip_address->getType() != Element::string)) {
<< " in the parsed lease");
}
- if (!is_v6 && !io_address->isV4()) {
- isc_throw(BadValue, "address " << *io_address << " it not an IPv4 address");
-
- } else if (is_v6 && !io_address->isV6()) {
- isc_throw(BadValue, "address " << *io_address << " it not an IPv6 address");
- }
-
lease->addr_ = *io_address;
// Subnet identifier.
isc_throw(BadValue, "invalid hardware address "
<< hw_address->stringValue() << " in the parsed lease");
}
-
- } else if (!is_v6) {
- isc_throw(BadValue, "hw-address not present in the parsed lease");
}
// cltt
// Extract common lease properties into the lease.
fromElementCommon(boost::dynamic_pointer_cast<Lease>(lease), element);
+ // Validate ip-address, which must be an IPv4 address.
+ if (!lease->addr_.isV4()) {
+ isc_throw(BadValue, "address " << lease->addr_ << " it not an IPv4 address");
+ }
+
+ // Make sure the hw-addres is present.
+ if (!lease->hwaddr_) {
+ isc_throw(BadValue, "hw-address not present in the parsed lease");
+ }
+
+
// Client identifier is IPv4 specific.
ConstElementPtr client_id = element->get("client-id");
if (client_id) {
// Extract common lease properties into the lease.
fromElementCommon(boost::dynamic_pointer_cast<Lease>(lease), element);
+ // Validate ip-address, which must be an IPv6 address.
+ if (!lease->addr_.isV6()) {
+ isc_throw(BadValue, "address " << lease->addr_ << " it not an IPv6 address");
+ }
+
// lease type
ConstElementPtr lease_type = element->get("type");
if (!lease_type || (lease_type->getType() != Element::string)) {