From 9344ac9c99c7a541fc16049d7e461ab11718849a Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 9 Aug 2007 12:20:27 +0000 Subject: [PATCH] Check for pool range if possible. Elseways ignore range settings. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7031 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_dhcpPool.inc | 43 ++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/plugins/admin/systems/class_dhcpPool.inc b/plugins/admin/systems/class_dhcpPool.inc index 1083a7872..5137dae9b 100644 --- a/plugins/admin/systems/class_dhcpPool.inc +++ b/plugins/admin/systems/class_dhcpPool.inc @@ -127,13 +127,26 @@ class dhcpPool extends dhcpPlugin } /* Check if range is in the network */ - #TODO: look for preceeding subnet entries in $cache and check if the - # range is valid. - #if (!is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) || - # !is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){ - # $message[] = _("'Range' is not inside the configured network."); - #} + $dn= $this->dn; + while (preg_match('/,/', $dn)){ + $type= $this->objectType($cache, $dn); + + /* Check for subnet */ + if ($type == 'dhcpSubnet'){ + $network= $cache[$dn]['cn'][0]; + $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]); + if (!is_in_network($network, $netmask, $this->range_start) || + !is_in_network($network, $netmask, $this->range_stop)){ + $message[] = _("'Range' is not inside the configured network."); + } + } + /* Stop if we've examined the service base object */ + if ($type == 'dhcpService'){ + break; + } + $dn= preg_replace('/^[^,]+,/', '', $dn); + } return $message; } @@ -145,6 +158,24 @@ class dhcpPool extends dhcpPlugin return ($this->attrs); } + + + function objectType($cache, $dn) + { + $type= ""; + $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost", + "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork"); + + foreach ($cache[$dn]['objectClass'] as $oc){ + if (in_array($oc, $types)){ + $type= $oc; + break; + } + } + + return ($type); + } + } -- 2.30.2