Code

Check for pool range if possible. Elseways ignore range settings.
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Aug 2007 12:20:27 +0000 (12:20 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Aug 2007 12:20:27 +0000 (12:20 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7031 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_dhcpPool.inc

index 1083a7872283d6bf57124b9c974e72ed073ca6f1..5137dae9ba39064fb4fa9b2be27e20789719448b 100644 (file)
@@ -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);
+  }
+
   
 }