|
@@ -85,10 +85,12 @@ class KEAHostReservationSubscriber implements EventSubscriber
|
|
|
$query = "
|
|
|
INSERT INTO kea.hosts (dhcp_identifier,
|
|
|
dhcp_identifier_type,
|
|
|
- ipv4_address)
|
|
|
+ ipv4_address,
|
|
|
+ hostname)
|
|
|
VALUES (:mac,
|
|
|
(SELECT type FROM kea.host_identifier_type WHERE name=:type),
|
|
|
- INET_ATON(:ip));
|
|
|
+ INET_ATON(:ip),
|
|
|
+ :hostname);
|
|
|
";
|
|
|
} else {
|
|
|
$query = "
|
|
@@ -99,9 +101,29 @@ class KEAHostReservationSubscriber implements EventSubscriber
|
|
|
|
|
|
$databaseConnection = $this->serviceContainer->get('database_connection');
|
|
|
$stmt = $databaseConnection->prepare($query);
|
|
|
- $stmt->bindValue("mac", hex2bin(str_replace(':', '', $entity->getMac())));
|
|
|
+ $hostType = $entity->getHostType();
|
|
|
+ $shortname = $hostType->getShortname();
|
|
|
+ // calculo el campo dhcp_identifier_type de kea.hosts
|
|
|
+ if ($shortname == 'cablemodem' || $shortname == 'cm') {
|
|
|
+ $stmt->bindValue("mac", hex2bin(str_replace(':', '', $entity->getMac())));
|
|
|
+ } else {
|
|
|
+ // mta|cpe
|
|
|
+ $hex = '';
|
|
|
+ $prefix = $shortname . '-';
|
|
|
+ for ($i = 0; $i < strlen($prefix); $i++) {
|
|
|
+ $ord = ord($prefix[$i]);
|
|
|
+ $hexCode = dechex($ord);
|
|
|
+ $hex .= substr('0'.$hexCode, -2);
|
|
|
+ }
|
|
|
+ $stmt->bindValue("mac", hex2bin($hex . str_replace(':', '', $entity->getHost()->getMac())));
|
|
|
+ }
|
|
|
if ($entity->getFixedAddress() && $remove == false) {
|
|
|
- $stmt->bindValue("type", 'hw-address');
|
|
|
+ if ($shortname == 'cablemodem' || $shortname == 'cm') {
|
|
|
+ $stmt->bindValue("type", 'hw-address');
|
|
|
+ } else {
|
|
|
+ $stmt->bindValue("type", 'flex-id');
|
|
|
+ }
|
|
|
+ $stmt->bindValue("hostname", $entity->getHostName());
|
|
|
$stmt->bindValue("ip", $entity->getFixedAddress());
|
|
|
}
|
|
|
$stmt->execute();
|