summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-03-30 00:37:45 +0000
committerErmal Luçi <eri@pfsense.org>2009-03-30 00:38:36 +0000
commita55e9c701c2fc8914e0aebf12e37038f59b07cf8 (patch)
tree05b5a1bc85f8742706649429ec164f576d240975 /usr/local/www
parentcc460ee980e427bf4acdb8a4903e3278df59ea94 (diff)
downloadpfsense-a55e9c701c2fc8914e0aebf12e37038f59b07cf8.zip
pfsense-a55e9c701c2fc8914e0aebf12e37038f59b07cf8.tar.gz
* Hide interfaces internals to other code and use the propper interfaces.
Basically use get_interface*() functions instead of accessing fields like 'ipaddr'/'descr' etc... * Make get_interfaces_with_gateway less heavyweight by getting information from the configuration stored in config.xml * Some other missed custom interface list building and substituing with propper get_configured_interface*() NOTE: This should give indipendce on dynamic interfaces on some services that before could not be used on top of this type of interfaces.
Diffstat (limited to 'usr/local/www')
-rwxr-xr-xusr/local/www/firewall_nat_1to1_edit.php2
-rwxr-xr-xusr/local/www/firewall_nat_out.php13
-rwxr-xr-xusr/local/www/firewall_nat_server_edit.php2
-rwxr-xr-xusr/local/www/firewall_virtual_ip_edit.php9
-rwxr-xr-xusr/local/www/services_dhcp.php15
-rwxr-xr-xusr/local/www/services_dhcp_edit.php10
-rwxr-xr-xusr/local/www/services_wol.php8
-rw-r--r--usr/local/www/vpn_l2tp.php2
-rwxr-xr-xusr/local/www/vpn_pppoe.php2
-rwxr-xr-xusr/local/www/vpn_pptp.php2
-rwxr-xr-xusr/local/www/wizard.php6
11 files changed, 38 insertions, 33 deletions
diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php
index 116ca79..7ef2fab 100755
--- a/usr/local/www/firewall_nat_1to1_edit.php
+++ b/usr/local/www/firewall_nat_1to1_edit.php
@@ -85,7 +85,7 @@ if ($_POST) {
if (is_ipaddr($config['interfaces']['wan']['ipaddr'])) {
if (check_subnets_overlap($_POST['external'], $_POST['subnet'],
- $config['interfaces']['wan']['ipaddr'], 32))
+ get_interface_ip("wan"), 32))
$input_errors[] = "The WAN IP address may not be used in a 1:1 rule.";
}
diff --git a/usr/local/www/firewall_nat_out.php b/usr/local/www/firewall_nat_out.php
index d9886e2..03eb8bd 100755
--- a/usr/local/www/firewall_nat_out.php
+++ b/usr/local/www/firewall_nat_out.php
@@ -91,14 +91,17 @@ if (isset($_POST['save']) && $_POST['save'] == "Save") {
$ifdescrs = get_configured_interface_with_descr();
foreach($ifdescrs as $if => $ifdesc) {
- if (interface_has_gateway())
+ if (interface_has_gateway($if))
continue;
- if($ifdesc == "WAN")
+ if($ifdesc == "wan")
continue;
$natent = array();
- $osn = gen_subnet($config['interfaces'][$if]['ipaddr'],
- $config['interfaces'][$if]['subnet']);
- $natent['source']['network'] = $osn . "/" . $config['interfaces'][$if]['subnet'];
+ $osipaddr = get_interface_ip($if);
+ $ossubnet = get_interface_subnet($if);
+ if (!is_ipaddr($osipaddr) || empty($ossubnet))
+ continue;
+ $osn = gen_subnet($osipaddr, $ossubnet);
+ $natent['source']['network'] = "{$osn}/{$ossubnet}";
$natent['sourceport'] = "";
$natent['descr'] = "Auto created rule for {$ifdesc}";
$natent['target'] = "";
diff --git a/usr/local/www/firewall_nat_server_edit.php b/usr/local/www/firewall_nat_server_edit.php
index 4558526..7cee424 100755
--- a/usr/local/www/firewall_nat_server_edit.php
+++ b/usr/local/www/firewall_nat_server_edit.php
@@ -71,7 +71,7 @@ if ($_POST) {
$input_errors[] = "A valid external IP address must be specified.";
}
- if ($_POST['ipaddr'] == $config['interfaces']['wan']['ipaddr'])
+ if ($_POST['ipaddr'] == get_interface_ip("wan"))
$input_errors[] = "The WAN IP address may not be used in a NAT Address entry.";
/* check for overlaps with other server NAT */
diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php
index 52029b5..d6d82b8 100755
--- a/usr/local/www/firewall_virtual_ip_edit.php
+++ b/usr/local/www/firewall_virtual_ip_edit.php
@@ -88,11 +88,10 @@ if ($_POST) {
if (($_POST['subnet'] && !is_ipaddr($_POST['subnet'])))
$input_errors[] = "A valid IP address must be specified.";
- if ($_POST['ipaddr'] == $config['interfaces']['wan']['ipaddr'])
- $input_errors[] = "The WAN IP address may not be used in a virtual entry.";
-
- if ($_POST['ipaddr'] == $config['interfaces']['lan']['ipaddr'])
- $input_errors[] = "The LAN IP address may not be used in a virtual entry.";
+ $natiflist = get_configured_interface_with_descr();
+ foreach ($natiflist as $natif => $natdescr)
+ if ($_POST['ipaddr'] == get_interface_ip($natif))
+ $input_errors[] = "The {$natdescr} IP address may not be used in a virtual entry.";
if($_POST['subnet_bits'] == "32" and $_POST['type'] == "carp")
$input_errors[] = "The /32 subnet mask is invalid for CARP IPs.";
diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php
index 6ddced7..59b3415 100755
--- a/usr/local/www/services_dhcp.php
+++ b/usr/local/www/services_dhcp.php
@@ -101,7 +101,8 @@ if (is_array($config['dhcpd'][$if])){
$a_maps = &$config['dhcpd'][$if]['staticmap'];
}
-$ifcfg = $config['interfaces'][$if];
+$ifcfgip = get_interface_ip($if);
+$ifcfgsn = get_interface_subnet($if);
/* set the enabled flag which will tell us if DHCP relay is enabled
@@ -181,8 +182,8 @@ if ($_POST) {
if (!$input_errors) {
/* make sure the range lies within the current subnet */
- $subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
- $subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
+ $subnet_start = (ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));
+ $subnet_end = (ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)));
if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
(ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
@@ -431,23 +432,23 @@ function show_netboot_config() {
<tr>
<td width="22%" valign="top" class="vncellreq">Subnet</td>
<td width="78%" class="vtable">
- <?=gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);?>
+ <?=gen_subnet($ifcfgip, $ifcfgsn);?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Subnet
mask</td>
<td width="78%" class="vtable">
- <?=gen_subnet_mask($ifcfg['subnet']);?>
+ <?=gen_subnet_mask($ifcfgsn);?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Available
range</td>
<td width="78%" class="vtable">
- <?=long2ip(ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));?>
+ <?=long2ip(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));?>
-
- <?=long2ip(ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet']))); ?>
+ <?=long2ip(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))); ?>
</td>
</tr>
<?php if($is_olsr_enabled): ?>
diff --git a/usr/local/www/services_dhcp_edit.php b/usr/local/www/services_dhcp_edit.php
index fb9718d..3239d05 100755
--- a/usr/local/www/services_dhcp_edit.php
+++ b/usr/local/www/services_dhcp_edit.php
@@ -62,7 +62,9 @@ $static_map_enabled=isset($config['dhcpd'][$if]['staticarp']);
staticmaps_sort($if);
$a_maps = &$config['dhcpd'][$if]['staticmap'];
-$ifcfg = &$config['interfaces'][$if];
+$ifcfgip = get_interface_ip($if);
+$ifcfgsn = get_interface_subnet($if);
+$ifcfgdescr = convert_friendly_interface_to_friendly_descr($if);
$id = $_GET['id'];
if (isset($_POST['id']))
@@ -121,11 +123,11 @@ if ($_POST) {
if ($_POST['ipaddr']) {
$dynsubnet_start = ip2long($config['dhcpd'][$if]['range']['from']);
$dynsubnet_end = ip2long($config['dhcpd'][$if]['range']['to']);
- $lansubnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
- $lansubnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
+ $lansubnet_start = (ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));
+ $lansubnet_end = (ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)));
if ((ip2long($_POST['ipaddr']) < $lansubnet_start) ||
(ip2long($_POST['ipaddr']) > $lansubnet_end)) {
- $input_errors[] = "The IP address must lie in the {$ifcfg['descr']} subnet.";
+ $input_errors[] = "The IP address must lie in the {$ifcfgdescr} subnet.";
}
}
diff --git a/usr/local/www/services_wol.php b/usr/local/www/services_wol.php
index f6a87d9..a04920b 100755
--- a/usr/local/www/services_wol.php
+++ b/usr/local/www/services_wol.php
@@ -51,8 +51,8 @@ if($_GET['wakeall'] <> "") {
foreach ($a_wol as $wolent) {
$mac = $wolent['mac'];
$if = $wolent['interface'];
- $bcip = gen_subnet_max($config['interfaces'][$if]['ipaddr'],
- $config['interfaces'][$if]['subnet']);
+ $bcip = gen_subnet_max($get_interface_ip($if),
+ get_interface_subnet($if));
mwexec("/usr/local/bin/wol -i {$bcip} {$mac}");
$savemsg .= "Sent magic packet to {$mac}.<br>";
}
@@ -81,8 +81,8 @@ if ($_POST || $_GET['mac']) {
if (!$input_errors) {
/* determine broadcast address */
- $bcip = gen_subnet_max($config['interfaces'][$if]['ipaddr'],
- $config['interfaces'][$if]['subnet']);
+ $bcip = gen_subnet_max(get_interface_ip($if),
+ get_interface_subnet($if));
mwexec("/usr/local/bin/wol -i {$bcip} {$mac}");
$savemsg = "Sent magic packet to {$mac}.";
diff --git a/usr/local/www/vpn_l2tp.php b/usr/local/www/vpn_l2tp.php
index 2dc487a..2e6829a 100644
--- a/usr/local/www/vpn_l2tp.php
+++ b/usr/local/www/vpn_l2tp.php
@@ -94,7 +94,7 @@ if ($_POST) {
(ip2long($_POST['localip']) <= $subnet_end)) {
$input_errors[] = gettext("The specified server address lies in the remote subnet.");
}
- if ($_POST['localip'] == $config['interfaces']['lan']['ipaddr']) {
+ if ($_POST['localip'] == get_interface_ip("lan")) {
$input_errors[] = gettext("The specified server address is equal to the LAN interface address.");
}
}
diff --git a/usr/local/www/vpn_pppoe.php b/usr/local/www/vpn_pppoe.php
index 12c6cd8..192bb61 100755
--- a/usr/local/www/vpn_pppoe.php
+++ b/usr/local/www/vpn_pppoe.php
@@ -105,7 +105,7 @@ if ($_POST) {
(ip2long($_POST['localip']) <= $subnet_end)) {
$input_errors[] = "The specified server address lies in the remote subnet.";
}
- if ($_POST['localip'] == $config['interfaces']['lan']['ipaddr']) {
+ if ($_POST['localip'] == get_interface_ip("lan")) {
$input_errors[] = "The specified server address is equal to the LAN interface address.";
}
}
diff --git a/usr/local/www/vpn_pptp.php b/usr/local/www/vpn_pptp.php
index 0ffff02..036a1c6 100755
--- a/usr/local/www/vpn_pptp.php
+++ b/usr/local/www/vpn_pptp.php
@@ -105,7 +105,7 @@ if ($_POST) {
(ip2long($_POST['localip']) <= $subnet_end)) {
$input_errors[] = "The specified server address lies in the remote subnet.";
}
- if ($_POST['localip'] == $config['interfaces']['lan']['ipaddr']) {
+ if ($_POST['localip'] == get_interface_ip("lan")) {
$input_errors[] = "The specified server address is equal to the LAN interface address.";
}
}
diff --git a/usr/local/www/wizard.php b/usr/local/www/wizard.php
index 346a4c0..7dee0a4 100755
--- a/usr/local/www/wizard.php
+++ b/usr/local/www/wizard.php
@@ -228,7 +228,7 @@ function enablechange() {
<?php
if($title == "Reload in progress") {
- $ip = "http://{$config['interfaces']['lan']['ipaddr']}";
+ $ip = "http://" . get_interface_ip("lan");
} else {
$ip = "/";
}
@@ -619,13 +619,13 @@ function fixup_string($string) {
$urlport = "";
}
}
- $myurl = $proto . "://" . $config['interfaces']['lan']['ipaddr'] . $urlport . "/";
+ $myurl = $proto . "://" . get_interface_ip("lan") . $urlport . "/";
$newstring = str_replace("\$myurl", $myurl, $newstring);
// fixup #2: $wanip
$curwanip = get_interface_ip();
$newstring = str_replace("\$wanip", $curwanip, $newstring);
// fixup #3: $lanip
- $lanip = $config['interfaces']['lan']['ipaddr'];
+ $lanip = get_interface_ip("lan");
$newstring = str_replace("\$lanip", $lanip, $newstring);
// fixup #4: fix'r'up here.
return $newstring;
OpenPOWER on IntegriCloud