summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
Diffstat (limited to 'usr/local')
-rwxr-xr-xusr/local/captiveportal/index.php6
-rw-r--r--usr/local/pkg/carp_settings.xml9
-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
13 files changed, 43 insertions, 43 deletions
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php
index 011095a..9d21b8d 100755
--- a/usr/local/captiveportal/index.php
+++ b/usr/local/captiveportal/index.php
@@ -50,7 +50,7 @@ if (!$clientip) {
if (isset($config['captiveportal']['httpslogin']))
$ourhostname = $config['captiveportal']['httpsname'] . ":8001";
else
- $ourhostname = $config['interfaces'][$config['captiveportal']['interface']]['ipaddr'] . ":8000";
+ $ourhostname = get_interface_ip($config['captiveportal']['interface']) . ":8000";
if ($orig_host != $ourhostname) {
/* the client thinks it's connected to the desired web server, but instead
@@ -168,7 +168,7 @@ function portal_reply_page($redirurl, $type = null, $message = null, $clientmac
if (isset($config['captiveportal']['httpslogin']))
$htmltext = str_replace("\$PORTAL_ACTION\$", "https://{$config['captiveportal']['httpsname']}:8001/", $htmltext);
else
- $htmltext = str_replace("\$PORTAL_ACTION\$", "http://{$config['interfaces'][$config['captiveportal']['interface']]['ipaddr']}:8000/", $htmltext);
+ $htmltext = str_replace("\$PORTAL_ACTION\$", "http://" . get_interface_ip($config['captiveportal']['interface']) . ":8000/", $htmltext);
$htmltext = str_replace("\$PORTAL_REDIRURL\$", htmlspecialchars($redirurl), $htmltext);
$htmltext = str_replace("\$PORTAL_MESSAGE\$", htmlspecialchars($message), $htmltext);
@@ -316,7 +316,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut
if (isset($config['captiveportal']['httpslogin']))
$logouturl = "https://{$config['captiveportal']['httpsname']}:8001/";
else
- $logouturl = "http://{$config['interfaces'][$config['captiveportal']['interface']]['ipaddr']}:8000/";
+ $logouturl = "http://" . get_interface_ip($config['captiveportal']['interface']) . ":8000/";
echo <<<EOD
<HTML>
diff --git a/usr/local/pkg/carp_settings.xml b/usr/local/pkg/carp_settings.xml
index 29c1ba9..8b37e8c 100644
--- a/usr/local/pkg/carp_settings.xml
+++ b/usr/local/pkg/carp_settings.xml
@@ -169,11 +169,9 @@
if($_POST["synchronizetoip"]) {
if(!is_ipaddr($_POST["synchronizetoip"]))
$input_errors[] = "You must specify a valid IP address.";
- $ifdescrs = array('lan','wan');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
- $ifdescrs['opt' . $j] = "opt" . $j;
+ $ifdescrs = get_configured_interface_list();
foreach($ifdescrs as $descr)
- if($config['interfaces']['$descr']['ipaddr'] == $_POST["synchronizetoip"])
+ if(get_interface_ip($descr) == $_POST["synchronizetoip"])
$input_errors[] = "CARP sync IP must be the backup firewall IP! You cannot specify this firewalls IP in this location.";
if($config['virtualip']['vip']) {
foreach($config['virtualip']['vip'] as $vip) {
@@ -181,9 +179,6 @@
$input_errors[] = "CARP sync IP must be the backup firewall IP! You cannot specify this firewalls IP in this location.";
}
}
- $wanip = get_interface_ip();
- if($wanip == $_POST["synchronizetoip"])
- $input_errors[] = "CARP sync IP must be the backup firewall's IP! You cannot specify this firewall's IP in this location.";
}
</custom_php_validation_command>
<custom_add_php_command_late>
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