Verified Commit 257091f6 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(ipam) Store subnet IP and netmask in CIDR notation

issue #6040
parent 696eb663
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2019-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*! \brief String LDAP attribute that contains an IP (v4 or v6) with netmask in CIDR notation
*
*/
class CIDRAttribute extends StringAttribute
{
protected $trim = TRUE;
function validate ()
{
list($ip,$bits) = explode('/', $this->getValue(), 2);
if (empty($ip) || empty($bits) || !tests::is_ip($ip) || !preg_match('/^[0-9]$/', $bits) || ($bits > 128)) {
return msgPool::invalid($this->getLabel(), $this->getValue(), $this->example);
}
}
}
...@@ -87,13 +87,9 @@ class ipamSubnet extends simplePlugin ...@@ -87,13 +87,9 @@ class ipamSubnet extends simplePlugin
'ip' => [ 'ip' => [
'name' => _('IP information'), 'name' => _('IP information'),
'attrs' => [ 'attrs' => [
new IPAttribute( new CIDRAttribute(
_('IP'), _('Subnet IP'), _('IP'), _('Subnet IP and mask size in CIDR notation'),
'ipHostNumber', TRUE 'fdIpamSubnetCIDR', TRUE
),
new IPAttribute(
_('Netmask'), _('Subnet netmask'),
'fdIpamNetmask', FALSE
), ),
] ]
] ]
......
...@@ -36,9 +36,10 @@ attributetype ( 1.3.6.1.4.1.38414.78.10.5 NAME 'fdIpamReleaseDate' ...@@ -36,9 +36,10 @@ attributetype ( 1.3.6.1.4.1.38414.78.10.5 NAME 'fdIpamReleaseDate'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SYNTAX 1.3.6.1.4.1.1466.115.121.1.24
SINGLE-VALUE ) SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.38414.78.10.6 NAME 'fdIpamNetmask' attributetype ( 1.3.6.1.4.1.38414.78.10.6 NAME 'fdIpamSubnetCIDR'
DESC 'FusionDirectory - IPAM Netmask' DESC 'FusionDirectory - IPAM IP and mask size in CIDR notation'
EQUALITY caseIgnoreIA5Match EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128} SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{128}
SINGLE-VALUE ) SINGLE-VALUE )
...@@ -86,7 +87,7 @@ objectclass ( 1.3.6.1.4.1.38414.78.2.1 NAME 'fdIpamSubnet' ...@@ -86,7 +87,7 @@ objectclass ( 1.3.6.1.4.1.38414.78.2.1 NAME 'fdIpamSubnet'
description $ o $ description $ o $
fdIpamActive $ fdIpamActive $
fdIpamType $ fdIpamApplicant $ fdIpamAllocationDate $ fdIpamReleaseDate $ fdIpamType $ fdIpamApplicant $ fdIpamAllocationDate $ fdIpamReleaseDate $
ipHostNumber $ fdIpamNetmask $ fdIpamSubnetCIDR $
fdIpamVlanDN fdIpamVlanDN
) ) ) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment