Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<id>reservation.ip_address</id>
<label>IP address</label>
<type>text</type>
<help>IP address to offer to the client</help>
<help>IP address to offer to the client. Leave empty for a hostname-only reservation (dynamic IP).</help>
</field>
<field>
<id>reservation.hw_address</id>
Expand All @@ -27,7 +27,7 @@
<id>reservation.hostname</id>
<label>Hostname</label>
<type>text</type>
<help>Offer a hostname to the client</help>
<help>Hostname to associate with this client. When set without an IP address, Kea assigns a dynamic address from the pool and stamps this hostname on the lease record.</help>
</field>
<field>
<id>reservation.description</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<id>reservation.ip_address</id>
<label>IP address</label>
<type>text</type>
<help>IP address to offer to the client</help>
<help>IP address to offer to the client. Leave empty for a hostname-only reservation (dynamic IP).</help>
</field>
<field>
<id>reservation.prefix</id>
Expand All @@ -33,7 +33,7 @@
<id>reservation.hostname</id>
<label>Hostname</label>
<type>text</type>
<help>Offer a hostname to the client</help>
<help>Hostname to associate with this client. When set without an IP address or prefix, Kea assigns a dynamic address from the pool and stamps this hostname on the lease record.</help>
</field>
<field>
<id>reservation.domain_search</id>
Expand Down
5 changes: 4 additions & 1 deletion src/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv4.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ public function performValidation($validateFullModel = false)
if ($subnet_node) {
$subnet = $subnet_node->subnet->getValue();
}
if (!Util::isIPInCIDR($reservation->ip_address->getValue(), $subnet)) {
if (!$reservation->ip_address->isEmpty() && !Util::isIPInCIDR($reservation->ip_address->getValue(), $subnet)) {
$messages->appendMessage(new Message(gettext("Address not in specified subnet"), $key . ".ip_address"));
}
if ($reservation->ip_address->isEmpty() && $reservation->hostname->isEmpty()) {
$messages->appendMessage(new Message(gettext("A hostname is required when no IP address is specified."), $key . ".hostname"));
}
if (!$reservation->client_id->isEmpty() && !$reservation->hw_address->isEmpty()) {
$messages->appendMessage(new Message(gettext("Either a client ID or a MAC address should be specified, but not both"), $key . ".hw_address"));
} elseif ($reservation->client_id->isEmpty() && $reservation->hw_address->isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv6.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function performValidation($validateFullModel = false)
if (!Util::isIPv6PrefixInPrefix($reservation->prefix->getValue(), $subnet) && !$reservation->prefix->isEmpty()) {
$messages->appendMessage(new Message(gettext("Prefix not in specified subnet"), $key . ".prefix"));
}
if ($reservation->ip_address->isEmpty() && $reservation->prefix->isEmpty()) {
$messages->appendMessage(new Message(gettext("Either an IP address or a Prefix should be specified."), $key . ".ip_address"));
if ($reservation->ip_address->isEmpty() && $reservation->prefix->isEmpty() && $reservation->hostname->isEmpty()) {
$messages->appendMessage(new Message(gettext("Either an IP address, a prefix, or a hostname must be specified."), $key . ".ip_address"));
}
if (!$reservation->duid->isEmpty() && !$reservation->hw_address->isEmpty()) {
$messages->appendMessage(new Message(gettext("Either a DUID or an MAC address should be specified, but not both"), $key . ".duid"));
Expand Down