|
@@ -14,17 +14,61 @@ class BaseKea implements KeaConfigInterface
|
|
|
private $subnet4 = [];
|
|
|
|
|
|
/**
|
|
|
- * @var array
|
|
|
- */
|
|
|
- private $hooks_libraries = [[
|
|
|
- 'library' => '/opt/hooks/amqp/kea-hook-flowdat3.so',
|
|
|
- 'parameters' => '',
|
|
|
- ]];
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ private $hooks_libraries = [
|
|
|
+ [
|
|
|
+ 'library' => '/opt/hooks/mysql/kea-hook-flowdat3-mysql.so',
|
|
|
+ 'parameters' => '',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'library' => '/opt/hooks/amqp/kea-hook-flowdat3.so',
|
|
|
+ 'parameters' => '',
|
|
|
+ ],
|
|
|
+ ];
|
|
|
|
|
|
/**
|
|
|
- * @var array
|
|
|
- */
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
private $interfaces_config = [];
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var boolean
|
|
|
+ */
|
|
|
+ private $echo_client_id = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ private $option_def = [
|
|
|
+ [
|
|
|
+ "name" => "subopt1",
|
|
|
+ "code" => 3,
|
|
|
+ "space" => "pcc",
|
|
|
+ "type" => "binary",
|
|
|
+ "record-types" => "",
|
|
|
+ "array" => false,
|
|
|
+ "encapsulate" => "",
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "name" => "subopt2",
|
|
|
+ "code" => 6,
|
|
|
+ "space" => "pcc",
|
|
|
+ "type" => "binary",
|
|
|
+ "record-types" => "",
|
|
|
+ "array" => false,
|
|
|
+ "encapsulate" => "",
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "name" =>"clabs",
|
|
|
+ "code" => 122,
|
|
|
+ "space" => "dhcp4",
|
|
|
+ "type" => "empty",
|
|
|
+ "array" => false,
|
|
|
+ "record-types" => "",
|
|
|
+ "encapsulate" => "pcc",
|
|
|
+ ],
|
|
|
+ ];
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -47,6 +91,8 @@ class BaseKea implements KeaConfigInterface
|
|
|
array(
|
|
|
'arguments' => array(
|
|
|
'Dhcp4' => [
|
|
|
+ 'echo-client-id' => $this->echo_client_id,
|
|
|
+ 'option-def' => $this->option_def,
|
|
|
'control-socket' => $this->controlSocketConfig(),
|
|
|
'lease-database' => $this->leaseDatabaseConfig($data),
|
|
|
'hosts-database' => $this->leaseDatabaseConfig($data),
|
|
@@ -93,9 +139,28 @@ class BaseKea implements KeaConfigInterface
|
|
|
$subnetConf['next-server'] = $nextServer;
|
|
|
}
|
|
|
|
|
|
+ $filename = $subnet->getFilename();
|
|
|
+ if ($filename != '') {
|
|
|
+ $subnetConf['boot-file-name'] = $filename;
|
|
|
+ }
|
|
|
+
|
|
|
if ($client_class != '') {
|
|
|
$subnetConf['client-class'] = $client_class;
|
|
|
}
|
|
|
+
|
|
|
+ $netgroup = $subnet->getNetGroup();
|
|
|
+ if ($netgroup && count($netgroup->getRelay())) {
|
|
|
+ $relay = [];
|
|
|
+ foreach ($netgroup->getRelay() as $ip) {
|
|
|
+ $relay[] = $ip;
|
|
|
+ }
|
|
|
+ $subnetConf['relay'] = [
|
|
|
+ 'ip-addresses' => $relay,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->setOptionData($subnet, $subnetConf);
|
|
|
+
|
|
|
$this->subnet4[] = $subnetConf;
|
|
|
}
|
|
|
}
|
|
@@ -215,5 +280,75 @@ class BaseKea implements KeaConfigInterface
|
|
|
{
|
|
|
return ['interfaces' => ['*']];
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param Subnet $subnet
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ private function setOptionData($subnet, &$subnetConf)
|
|
|
+ {
|
|
|
+ $option_data = [];
|
|
|
+ $fields = [
|
|
|
+ "routers",
|
|
|
+ "time-servers" => ["always-send" => true],
|
|
|
+ "log-servers",
|
|
|
+ "time-offset",
|
|
|
+ "broadcast-address" => ["always-send" => true],
|
|
|
+ "domain-name-servers",
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach ($fields as $key => $options) {
|
|
|
+ $name = is_array($options) ? $key : $options;
|
|
|
+ $field = implode('', array_map(function ($piece) {
|
|
|
+ return ucfirst($piece);
|
|
|
+ }, explode('-', $name)));
|
|
|
+ $method = "get{$field}";
|
|
|
+ $value = $subnet->$method();
|
|
|
+ if ($value) {
|
|
|
+ $data = [
|
|
|
+ 'name' => $name,
|
|
|
+ 'data' => $subnet->$method(),
|
|
|
+ ];
|
|
|
+ if (is_array($options)) {
|
|
|
+ $data = array_merge($data, $options);
|
|
|
+ }
|
|
|
+ $option_data[] = $data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $option_122_data = [];
|
|
|
+ if ($subnet->getOption122ProvisioningServer() && $subnet->getOption122ProvisioningType()) {
|
|
|
+ $option_122_data = [
|
|
|
+ [
|
|
|
+ "name" => "subopt1",
|
|
|
+ "space" => "pcc",
|
|
|
+ "code" => 3,
|
|
|
+ "csv-format" => true,
|
|
|
+ "data" => bin2hex($subnet->getOption122ProvisioningServer()),
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "name" => "subopt2",
|
|
|
+ "space" => "pcc",
|
|
|
+ "code" => 6,
|
|
|
+ "csv-format" => true,
|
|
|
+ "data" => bin2hex($subnet->getOption122ProvisioningType()),
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "name" => "clabs",
|
|
|
+ "space" => "dhcp4",
|
|
|
+ "code" => 122,
|
|
|
+ "csv-format" => false,
|
|
|
+ "data" => "",
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $option_data = array_merge($option_data, $option_122_data);
|
|
|
+
|
|
|
+ $subnetConf['option-data'] = $option_data;
|
|
|
+
|
|
|
+ return $option_data;
|
|
|
+ }
|
|
|
|
|
|
}
|