[v2] BUG11278: enable creation from subnets of internal networks
Message ID | 1484057638-19086-1-git-send-email-alexander.marx@ipfire.org |
---|---|
State | Dropped |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 00A8161360 for <patchwork@ipfire.org>; Tue, 10 Jan 2017 15:14:02 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 66B459F3; Tue, 10 Jan 2017 15:14:02 +0100 (CET) Received: from EDV1.kappeln2011.lan (ip1f113c44.dynamic.kabel-deutschland.de [31.17.60.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 1FA8D2D9; Tue, 10 Jan 2017 15:14:00 +0100 (CET) From: Alexander Marx <alexander.marx@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH v2] BUG11278: enable creation from subnets of internal networks Date: Tue, 10 Jan 2017 15:13:58 +0100 Message-Id: <1484057638-19086-1-git-send-email-alexander.marx@ipfire.org> X-Mailer: git-send-email 2.7.4 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <http://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <http://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Message
Alexander Marx
Jan. 11, 2017, 1:13 a.m. UTC
In firewallgroups it was not possible to create new networks that are subnets of
IPFire internal networks. Now this is possible for all internal networks.
Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
---
config/cfgroot/general-functions.pl | 8 ++++----
config/cfgroot/network-functions.pl | 13 +++++++++++++
2 files changed, 17 insertions(+), 4 deletions(-)
Comments
Third time lucky, eh? On Tue, 2017-01-10 at 15:13 +0100, Alexander Marx wrote: > In firewallgroups it was not possible to create new networks that are > subnets of > IPFire internal networks. Now this is possible for all internal > networks. > > Signed-off-by: Alexander Marx <alexander.marx@ipfire.org> > --- > config/cfgroot/general-functions.pl | 8 ++++---- > config/cfgroot/network-functions.pl | 13 +++++++++++++ > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/config/cfgroot/general-functions.pl > b/config/cfgroot/general-functions.pl > index 188bb7f..081e4e3 100644 > --- a/config/cfgroot/general-functions.pl > +++ b/config/cfgroot/general-functions.pl > @@ -553,10 +553,10 @@ sub check_net_internal{ > $cidr=&iporsubtocidr($cidr); > #check if we use one of ipfire's networks > (green,orange,blue) > &readhash("${General::swroot}/ethernet/settings", \%ownnet); > - if (($ownnet{'GREEN_NETADDRESS'} ne '' && > $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && > &IpInSubnet($ip,$ownnet{'GREEN_NETADDRESS'},&iporsubtodec($ownnet{'GR > EEN_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err green'};return > $errormessage;} > - if (($ownnet{'ORANGE_NETADDRESS'} ne '' && > $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && > &IpInSubnet($ip,$ownnet{'ORANGE_NETADDRESS'},&iporsubtodec($ownnet{'O > RANGE_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err orange'};return > $errormessage;} > - if (($ownnet{'BLUE_NETADDRESS'} ne '' && > $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && > &IpInSubnet($ip,$ownnet{'BLUE_NETADDRESS'},&iporsubtodec($ownnet{'BLU > E_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err blue'};return > $errormessage;} > - if (($ownnet{'RED_NETADDRESS'} ne '' && > $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && > &IpInSubnet($ip,$ownnet{'RED_NETADDRESS'},&iporsubtodec($ownnet{'RED_ > NETMASK'}))){ $errormessage=$Lang::tr{'ccd err red'};return > $errormessage;} > + if (($ownnet{'GREEN_NETADDRESS'} ne '' && > $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && > &Network::network_equal("$ownnet{'GREEN_NETADDRESS'}/$ownnet{'GREEN_N > ETMASK'}",$network)){ $errormessage=$Lang::tr{'ccd err green'};return > $errormessage;} > + if (($ownnet{'ORANGE_NETADDRESS'} ne '' && > $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && > &Network::network_equal("$ownnet{'ORANGE_NETADDRESS'}/$ownnet{'ORANGE > _NETMASK'}",$network)){ $errormessage=$Lang::tr{'ccd err > orange'};return $errormessage;} > + if (($ownnet{'BLUE_NETADDRESS'} ne '' && > $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && > &Network::network_equal("$ownnet{'BLUE_NETADDRESS'}/$ownnet{'BLUE_NET > MASK'}",$network)){ $errormessage=$Lang::tr{'ccd err blue'};return > $errormessage;} > + if (($ownnet{'RED_NETADDRESS'} ne '' && > $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && > &Network::network_equal("$ownnet{'RED_NETADDRESS'}/$ownnet{'RED_NETMA > SK'}",$network)){ $errormessage=$Lang::tr{'ccd err red'};return > $errormessage;} > } > > sub validport > diff --git a/config/cfgroot/network-functions.pl > b/config/cfgroot/network-functions.pl > index 70fa5ed..5559be5 100644 > --- a/config/cfgroot/network-functions.pl > +++ b/config/cfgroot/network-functions.pl > @@ -102,6 +102,19 @@ sub bin2ip($) { > return $address; > } > > +#Takes two network addresses and compares them against each other > +#returns true if equal or false if not > +sub network_equal{ > + my $network1 = shift; > + my $network2 = shift; > + my $bin1 = &network2bin($network1); > + my $bin2 = &network2bin($network2); > + if ($bin1 eq $bin2){ > + return 1; > + } > + return 0; > +} > + > # Takes a network in either a.b.c.d/a.b.c.d or a.b.c.d/e notation > # and will return an 32 bit integer representing the start > # address and an other one representing the network mask.