|
@@ -100,6 +100,7 @@ class BaseKea implements KeaConfigInterface
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param array $subnets
|
|
* @param array $subnets
|
|
|
|
+ * @param array $reservations
|
|
*/
|
|
*/
|
|
private function subnetConfig($subnets, $reservations)
|
|
private function subnetConfig($subnets, $reservations)
|
|
{
|
|
{
|
|
@@ -112,10 +113,11 @@ class BaseKea implements KeaConfigInterface
|
|
}
|
|
}
|
|
|
|
|
|
$hostType = $subnet->getAllowedHostType();
|
|
$hostType = $subnet->getAllowedHostType();
|
|
- $client_class = '';
|
|
|
|
|
|
+ $client_class = 'cm';
|
|
if ($hostType != 'Cablemodem') {
|
|
if ($hostType != 'Cablemodem') {
|
|
$client_class = $hostType->getShortname();
|
|
$client_class = $hostType->getShortname();
|
|
}
|
|
}
|
|
|
|
+
|
|
if ($subnet->getStatus() != HostStatus::STATE_NONE && $subnet->getStatus() != '') {
|
|
if ($subnet->getStatus() != HostStatus::STATE_NONE && $subnet->getStatus() != '') {
|
|
if ($client_class != '') {
|
|
if ($client_class != '') {
|
|
$client_class .= '-';
|
|
$client_class .= '-';
|
|
@@ -231,29 +233,33 @@ class BaseKea implements KeaConfigInterface
|
|
// }
|
|
// }
|
|
// $hook['parameters']['remote-id-map'] = $hostConfig;
|
|
// $hook['parameters']['remote-id-map'] = $hostConfig;
|
|
// }
|
|
// }
|
|
-
|
|
|
|
|
|
+ //
|
|
// $this->hooks_libraries[] = $hook;
|
|
// $this->hooks_libraries[] = $hook;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * @param int $debugLevel
|
|
|
|
+ * @param string $severity
|
|
|
|
+ * @param string $output
|
|
|
|
+ *
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
- private function loggingConfig()
|
|
|
|
|
|
+ private function loggingConfig($debugLevel = 0, $severity = 'INFO', $output = '/usr/local/var/log/kea-dhcp4.log')
|
|
{
|
|
{
|
|
return array(
|
|
return array(
|
|
'loggers' => array(
|
|
'loggers' => array(
|
|
array(
|
|
array(
|
|
- 'debuglevel' => 0,
|
|
|
|
|
|
+ 'debuglevel' => $debugLevel,
|
|
'name' => 'kea-dhcp4',
|
|
'name' => 'kea-dhcp4',
|
|
'output_options' => array(
|
|
'output_options' => array(
|
|
array(
|
|
array(
|
|
'flush' => true,
|
|
'flush' => true,
|
|
'maxsize' => 10240000,
|
|
'maxsize' => 10240000,
|
|
'maxver' => 1,
|
|
'maxver' => 1,
|
|
- 'output' => '/usr/local/var/log/kea-dhcp4.log'
|
|
|
|
|
|
+ 'output' => $output
|
|
)
|
|
)
|
|
),
|
|
),
|
|
- 'severity' => 'INFO'
|
|
|
|
|
|
+ 'severity' => $severity
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
);
|
|
@@ -272,6 +278,9 @@ class BaseKea implements KeaConfigInterface
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @param string $type
|
|
|
|
+ *
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
private function leaseDatabaseConfig($data, $type = 'mysql')
|
|
private function leaseDatabaseConfig($data, $type = 'mysql')
|
|
@@ -304,6 +313,7 @@ class BaseKea implements KeaConfigInterface
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param Subnet $subnet
|
|
* @param Subnet $subnet
|
|
|
|
+ * @param array $subnetConf
|
|
*
|
|
*
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
@@ -317,6 +327,8 @@ class BaseKea implements KeaConfigInterface
|
|
"time-offset",
|
|
"time-offset",
|
|
"broadcast-address" => ["always-send" => true],
|
|
"broadcast-address" => ["always-send" => true],
|
|
"domain-name-servers",
|
|
"domain-name-servers",
|
|
|
|
+ "domain-name",
|
|
|
|
+ "tftp-server-name",
|
|
];
|
|
];
|
|
|
|
|
|
foreach ($fields as $key => $options) {
|
|
foreach ($fields as $key => $options) {
|
|
@@ -340,20 +352,32 @@ class BaseKea implements KeaConfigInterface
|
|
|
|
|
|
$option_122_data = [];
|
|
$option_122_data = [];
|
|
if ($subnet->getOption122ProvisioningServer() && $subnet->getOption122ProvisioningType()) {
|
|
if ($subnet->getOption122ProvisioningServer() && $subnet->getOption122ProvisioningType()) {
|
|
|
|
+ $provisioningServer = $subnet->getOption122ProvisioningServer();
|
|
|
|
+ $binary = array_map(function($piece) {
|
|
|
|
+ return self::int2hex(strlen($piece)) . self::string2hex($piece);
|
|
|
|
+ }, explode('.', $provisioningServer));
|
|
|
|
+ $provisioningServerBinary = self::int2hex(0) . implode('', $binary) . self::int2hex(0);
|
|
|
|
+
|
|
|
|
+ $provisioningType = $subnet->getOption122ProvisioningType();
|
|
|
|
+ $binary = array_map(function($piece) {
|
|
|
|
+ return self::int2hex(strlen($piece)) . self::string2hex($piece);
|
|
|
|
+ }, explode('.', $provisioningType));
|
|
|
|
+ $provisioningTypeBinary = '' . implode('', $binary) . self::int2hex(0);
|
|
|
|
+
|
|
$option_122_data = [
|
|
$option_122_data = [
|
|
[
|
|
[
|
|
"name" => "subopt1",
|
|
"name" => "subopt1",
|
|
"space" => "pcc",
|
|
"space" => "pcc",
|
|
"code" => 3,
|
|
"code" => 3,
|
|
- "csv-format" => true,
|
|
|
|
- "data" => bin2hex($subnet->getOption122ProvisioningServer()),
|
|
|
|
|
|
+ "csv-format" => false,
|
|
|
|
+ "data" => $provisioningServerBinary,
|
|
],
|
|
],
|
|
[
|
|
[
|
|
"name" => "subopt2",
|
|
"name" => "subopt2",
|
|
"space" => "pcc",
|
|
"space" => "pcc",
|
|
"code" => 6,
|
|
"code" => 6,
|
|
- "csv-format" => true,
|
|
|
|
- "data" => bin2hex($subnet->getOption122ProvisioningType()),
|
|
|
|
|
|
+ "csv-format" => false,
|
|
|
|
+ "data" => $provisioningTypeBinary,
|
|
],
|
|
],
|
|
[
|
|
[
|
|
"name" => "clabs",
|
|
"name" => "clabs",
|
|
@@ -372,4 +396,45 @@ class BaseKea implements KeaConfigInterface
|
|
return $option_data;
|
|
return $option_data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @param string $str
|
|
|
|
+ *
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
|
|
+ public static function string2hex($str)
|
|
|
|
+ {
|
|
|
|
+ $hex = '';
|
|
|
|
+ for ($iter = 0; $iter < strlen($str); $iter++) {
|
|
|
|
+ $hex .= dechex(ord($str[$iter]));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $hex;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param int $int
|
|
|
|
+ *
|
|
|
|
+ * @return string
|
|
|
|
+ */
|
|
|
|
+ public static function int2hex($int)
|
|
|
|
+ {
|
|
|
|
+ if ($int < 0) {
|
|
|
|
+ $hex = substr(dechex($int), -8);
|
|
|
|
+ } else {
|
|
|
|
+ $hex = base_convert($int, 10, 16);
|
|
|
|
+ // TODO: This is a quick hack. Fix this.
|
|
|
|
+ if (strlen($hex) == 1) {
|
|
|
|
+ $hex = '0' . $hex;
|
|
|
|
+ } else if (strlen($hex) == 3) {
|
|
|
|
+ $hex = '0' . $hex;
|
|
|
|
+ } else if (strlen($hex) == 5) {
|
|
|
|
+ $hex = '000' . $hex;
|
|
|
|
+ } else if (strlen($hex) == 7) {
|
|
|
|
+ $hex = '0' . $hex;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return '' . $hex;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|