summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@sullrich-MacBookPro.local>2009-02-15 17:15:22 -0500
committerScott Ullrich <sullrich@sullrich-MacBookPro.local>2009-02-15 17:15:22 -0500
commit95f34842163cdfb1bdbcf4f022d51cdcdd4be10c (patch)
treec10cdca216a4b6f55562be5e193bc247d4e6c18d
parent0a029d0c98278a57eb9af2f43590265ba817fc9d (diff)
parenteff29d62c50803fe5eaf3b3d9089ac428c8811ad (diff)
downloadpfsense-95f34842163cdfb1bdbcf4f022d51cdcdd4be10c.zip
pfsense-95f34842163cdfb1bdbcf4f022d51cdcdd4be10c.tar.gz
Merge branch 'master' of http://gitweb.pfsense.org/pfsense/mainline
-rw-r--r--etc/inc/filter.inc9
-rw-r--r--etc/inc/globals.inc1
-rw-r--r--etc/inc/interfaces.inc8
-rw-r--r--etc/inc/pfsense-utils.inc3
-rw-r--r--etc/inc/shaper.inc20
-rw-r--r--etc/inc/util.inc64
-rw-r--r--etc/inc/vpn.inc13
-rwxr-xr-xusr/local/www/firewall_rules_edit.php123
-rwxr-xr-xusr/local/www/interfaces.php146
-rw-r--r--usr/local/www/javascript/firewall_rules_edit/firewall_rules_edit.js38
-rwxr-xr-xusr/local/www/services_usermanager.php2
-rwxr-xr-xusr/local/www/system.php18
-rwxr-xr-xusr/local/www/system_gateways.php20
-rwxr-xr-xusr/local/www/system_gateways_edit.php185
14 files changed, 174 insertions, 476 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index b0bb059..b4a2439 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -225,6 +225,10 @@ function filter_configure_sync() {
return;
}
}
+
+ update_filter_reload_status("Starting up layer7 daemon");
+ layer7_start_l7daemon();
+
unlink_if_exists("/usr/local/pkg/pf/carp_sync_client.php");
/* run items scheduled for after filter configure run */
$fda = fopen("/tmp/commands.txt", "w");
@@ -1314,7 +1318,10 @@ function generate_user_filter_rule($rule)
$gateway = $rule['gateway'];
if(!is_ipaddr($rule['gateway'])) {
$gwip = $GatewaysList[$rule['gateway']]['gateway'];
- $int = get_real_interface($GatewaysList[$gateway]['interface']);
+ if ($GatewaysList[$gateway]['interface'])
+ $int = $GatewaysList[$gateway]['interface'];
+ else
+ $int = "";
} else {
$gwip = $rule['gateway'];
$int = guess_interface_from_ip($rule['gateway']);
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc
index 8c1fdcc..a2207bf 100644
--- a/etc/inc/globals.inc
+++ b/etc/inc/globals.inc
@@ -62,6 +62,7 @@ $g = array(
"pptp_subnet" => 28, /* this value can be overriden in pptp->pptp_subnet */
"n_pppoe_units" => 16, /* this value can be overriden in pppoe->n_pppoe_units */
"pppoe_subnet" => 28, /* this value can be overriden in pppoe->pppoe_subnet */
+ "l2tp_subnet" => 28, /* this value can be overriden in l2tp->l2tp_subnet */
"debug" => false,
"latest_config" => "5.5",
"nopkg_platforms" => array("cdrom"),
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 652d527..3f96431 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -501,7 +501,7 @@ function interfaces_configure() {
$bridge_list = array();
foreach($iflist as $if => $ifname) {
- $realif = $config['interfaces'][$if];
+ $realif = $config['interfaces'][$if]['if'];
if(is_array($realif['pppoe']) && isset($realif['pppoe']['pppoe-reset-type']))
setup_pppoe_reset_file($if, true);
else
@@ -1799,7 +1799,7 @@ function get_current_wan_address($interface = "wan") {
function get_real_interface($interface = "wan") {
global $config;
- $wanif = $interface;
+ $wanif = NULL;
switch ($interface) {
case "l2tp":
@@ -1847,10 +1847,6 @@ function get_real_interface($interface = "wan") {
}
break;
case "pppoe":
- /*
- * XXX: mpd seems to use netgraph interfaces so ngX interfaces are created
- * instead of pppoeX. =) -simoncpu-
- */
if ($if == "wan")
$wanif = "pppoe0";
else
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 8b84fa9..8433bb7 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -1466,7 +1466,6 @@ function find_interface_subnet($interface, $flush = false, $type = "ipv4")
if (!isset($interface_sn_arr_cache[$interface]) or $flush) {
$interface_sn_arr_cache[$interface] = exec_command("/sbin/ifconfig {$interface} | /usr/bin/grep -w \"inet\" | /usr/bin/cut -d\" \" -f 4 | /usr/bin/head -1");
$interface_sn_arr_cache[$interface] = strlen(str_replace("0", "", base_convert(str_replace("\n", "", $interface_sn_arr_cache[$interface]),16, 2)));
- log_error("int:{$interface} - generated subnet mask {$interface_sn_arr_cache[$interface]}");
}
return $interface_sn_arr_cache[$interface];
@@ -1756,7 +1755,7 @@ function execute_command_return_output($command) {
function convert_friendly_interface_to_real_interface_name($interface) {
global $config;
- $wanif = $interface;
+ $wanif = NULL;
switch ($interface) {
case "l2tp":
$wanif = "l2tp";
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc
index 2c8a8ca..7d5b5b7 100644
--- a/etc/inc/shaper.inc
+++ b/etc/inc/shaper.inc
@@ -3379,8 +3379,24 @@ function generate_layer7_files() {
$fp = fopen($path,'w');
fwrite($fp,$rules);
fclose($fp);
-
- // XXX: Hardcoded number of packets to garbage collect.
+ }
+ }
+}
+
+function layer7_start_l7daemon() {
+ global $layer7_rules_list;
+
+ /*
+ * XXX: Needed ?!
+ * read_layer7_config();
+ */
+
+ foreach($layer7_rules_list as $l7rules) {
+ if($l7rules->GetREnabled()) {
+ $filename = $l7rules->GetRName() . ".l7";
+ $path = "/tmp/" . $filename;
+
+ // XXX: Hardcoded number of packets to garbage collect.
$ipfw_classifyd_init = "/usr/local/sbin/ipfw-classifyd -n 5 -c {$path} -p " . $l7rules->GetRPort() . " -P /usr/local/share/protocols";
mwexec_bg($ipfw_classifyd_init);
}
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 7b8ebe8..3ef01fc 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -27,8 +27,6 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-require_once 'IPv6.inc';
-
/* kill a process by pid file */
function killbypid($pidfile) {
sigkillbypid($pidfile, "TERM");
@@ -122,8 +120,9 @@ function is_ipaddr($ipaddr) {
return false;
}
-/* returns true if $ipaddr is a valid IPv4/IPv6 address or an alias thereof */
+/* returns true if $ipaddr is a valid dotted IPv4 address or an alias thereof */
function is_ipaddroralias($ipaddr) {
+
global $aliastable, $config;
if(is_array($config['aliases']['alias'])) {
@@ -133,22 +132,22 @@ function is_ipaddroralias($ipaddr) {
}
}
- if (isset($aliastable[$ipaddr]) && (is_ipaddr($aliastable[$ipaddr]) || Net_IPv6::checkIPv6($aliastable[$ipaddr]))) {
+ if (isset($aliastable[$ipaddr]) && is_ipaddr($aliastable[$ipaddr]))
return true;
- } else {
- return (is_ipaddr($ipaddr) || Net_IPv6::checkIPv6($ipaddr));
- }
+ else
+ return is_ipaddr($ipaddr);
+
}
/* returns true if $ipaddr is a valid dotted IPv4 address or any alias */
function is_ipaddroranyalias($ipaddr) {
+
global $aliastable;
- if (isset($aliastable[$ipaddr])) {
+ if (isset($aliastable[$ipaddr]))
return true;
- } else {
- return (is_ipaddr($ipaddr) || Net_IPv6::checkIPv6($ipaddr));
- }
+ else
+ return is_ipaddr($ipaddr);
}
/* returns true if $subnet is a valid subnet in CIDR format */
@@ -167,26 +166,6 @@ function is_subnet($subnet) {
return true;
}
-/* returns true if $subnet is a valid IPv6 network address */
-function is_subnet_ipv6($subnet, $max = 64) {
- if (!is_string($subnet)) {
- return false;
- }
-
- list ($hp, $np) = explode('/', $subnet);
-
- if (!Net_IPv6::checkIPv6($hp)) {
- return false;
- }
-
- if (!is_numeric($np) || ($np < 1) || ($np > $max)) {
- return false;
- }
-
- return true;
-}
-
-
/* returns true if $subnet is a valid subnet in CIDR format or an alias thereof */
function is_subnetoralias($subnet) {
@@ -524,15 +503,15 @@ function alias_expand_value($name) {
/* expand a host or network alias, if necessary */
function alias_expand($name) {
+
global $aliastable;
- if (isset($aliastable[$name])) {
+ if (isset($aliastable[$name]))
return "\${$name}";
- } else if (is_ipaddr($name) || is_subnet($name) || Net_IPv6::checkIPv6($name) || is_subnet_ipv6($name)) {
+ else if (is_ipaddr($name) || is_subnet($name))
return "{$name}";
- } else {
+ else
return null;
- }
}
/* expand a host alias, if necessary */
@@ -542,16 +521,14 @@ function alias_expand_host($name) {
if (isset($aliastable[$name])) {
$ip_arr = explode(" ", $aliastable[$name]);
foreach($ip_arr as $ip) {
- if (!is_ipaddr($ip) || Net_IPv6::checkIPv6($ip)) {
+ if (!is_ipaddr($ip))
return null;
- }
}
return $aliastable[$name];
- } else if (is_ipaddr($name) || Net_IPv6::checkIPv6($name)) {
+ } else if (is_ipaddr($name))
return $name;
- } else {
+ else
return null;
- }
}
/* expand a network alias, if necessary */
@@ -635,8 +612,8 @@ function arp_get_mac_by_ip($ip) {
/* return a fieldname that is safe for xml usage */
function xml_safe_fieldname($fieldname) {
- $replace = array('/', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
- '+', '=', '{', '}', '[', ']', '|', '/', '<', '>', '?',
+ $replace = array('/', '-', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
+ '_', '+', '=', '{', '}', '[', ']', '|', '/', '<', '>', '?',
':', ',', '.', '\'', '\\'
);
return strtolower(str_replace($replace, "", $fieldname));
@@ -670,9 +647,8 @@ function mac_format($clientmac) {
function resolve_retry($hostname, $retries = 5) {
- if (is_ipaddr($hostname) || Net_IPv6::checkIPv6($hostname)) {
+ if (is_ipaddr($hostname))
return $hostname;
- }
for ($i = 0; $i < $retries; $i++) {
$ip = gethostbyname($hostname);
diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc
index 50df908..232fdc9 100644
--- a/etc/inc/vpn.inc
+++ b/etc/inc/vpn.inc
@@ -936,7 +936,6 @@ EOD;
if(isset($pptpdcfg['radius']['radiusissueips']) && isset($pptpdcfg['radius']['enable'])) {
$isssue_ip_type = "set ipcp ranges {$pptpdcfg['localip']}/32 0.0.0.0/0";
- $isssue_ip_type .="\n\tset ipcp yes radius-ip";
} else {
$isssue_ip_type = "set ipcp ranges {$pptpdcfg['localip']}/32 {$clientip}/32";
}
@@ -1006,7 +1005,6 @@ EOD;
set radius retries 3
set radius timeout 10
set auth enable radius-auth
- set bundle disable radius-fallback
EOD;
@@ -1145,7 +1143,6 @@ EOD;
if (isset ($pppoecfg['radius']['radiusissueips']) && isset ($pppoecfg['radius']['enable'])) {
$isssue_ip_type = "set ipcp ranges {$pppoecfg['localip']}/32 0.0.0.0/0";
- $isssue_ip_type .= "\n\tset ipcp yes radius-ip";
} else {
$isssue_ip_type = "set ipcp ranges {$pppoecfg['localip']}/32 {$clientip}/32";
}
@@ -1203,11 +1200,9 @@ EOD;
if (isset ($pppoecfg['radius']['enable'])) {
$mpdconf .=<<<EOD
set radius server {$pppoecfg['radius']['server']} "{$pppoecfg['radius']['secret']}"
- set ipcp radius-ip
set radius retries 3
set radius timeout 10
set auth enable radius-auth
- set bundle disable radius-fallback
EOD;
@@ -1345,7 +1340,6 @@ EOD;
if (isset ($l2tpcfg['radius']['radiusissueips']) && isset ($l2tpcfg['radius']['enable'])) {
$isssue_ip_type = "set ipcp ranges {$l2tpcfg['localip']}/32 0.0.0.0/0";
- $isssue_ip_type .= "\n\tset ipcp yes radius-ip";
} else {
$isssue_ip_type = "set ipcp ranges {$l2tpcfg['localip']}/32 {$clientip}/32";
}
@@ -1393,11 +1387,9 @@ EOD;
if (isset ($l2tpcfg['radius']['enable'])) {
$mpdconf .=<<<EOD
set radius server {$l2tpcfg['radius']['server']} "{$l2tpcfg['radius']['secret']}"
- set ipcp radius-ip
set radius retries 3
set radius timeout 10
set auth enable radius-auth
- set bundle disable radius-fallback
EOD;
@@ -1424,9 +1416,10 @@ EOD;
for ($i = 0; $i < $l2tpcfg['n_l2tp_units']; $i++) {
$mpdlinks .=<<<EOD
-l2tp:
+l2tp{$i}:
set link type l2tp
- set l2tp iface {$l2tp_interface}
+ set l2tp enable incoming
+ set l2tp disable originate
EOD;
}
diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php
index cae0389..ecbb87e 100755
--- a/usr/local/www/firewall_rules_edit.php
+++ b/usr/local/www/firewall_rules_edit.php
@@ -40,7 +40,6 @@
require("guiconfig.inc");
-require_once("IPv6.inc");
$specialsrcdst = explode(" ", "any wanip lanip lan pptp pppoe");
@@ -92,9 +91,6 @@ if (isset($id) && $a_filter[$id]) {
if ($a_filter[$id]['protocol'] == "icmp")
$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
- if ($a_filter[$id]['protocol'] == "icmp6")
- $pconfig['icmp6type'] = $a_filter[$id]['icmp6type'];
-
address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
$pconfig['srcmask'], $pconfig['srcnot'],
$pconfig['srcbeginport'], $pconfig['srcendport']);
@@ -162,9 +158,9 @@ if (isset($_GET['dup']))
unset($id);
if ($_POST) {
- if ($_POST['type'] == "reject" && !($_POST['proto'] == "tcp" || $_POST['proto'] == "tcp6")) {
- $input_errors[] = "Reject type rules only works when the protocol is set to TCP or TCP6.";
- }
+
+ if ($_POST['type'] == "reject" && $_POST['proto'] <> "tcp")
+ $input_errors[] = "Reject type rules only works when the protocol is set to TCP.";
if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
$_POST['srcbeginport'] = 0;
@@ -288,7 +284,7 @@ if ($_POST) {
if (!is_specialnet($_POST['srctype'])) {
if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
- $input_errors[] = "A valid source IPv4/IPv6 address or alias must be specified.";
+ $input_errors[] = "A valid source IP address or alias must be specified.";
}
if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
$input_errors[] = "A valid source bit count must be specified.";
@@ -296,7 +292,7 @@ if ($_POST) {
}
if (!is_specialnet($_POST['dsttype'])) {
if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
- $input_errors[] = "A valid destination IPv4/IPv6 address or alias must be specified.";
+ $input_errors[] = "A valid destination IP address or alias must be specified.";
}
if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
$input_errors[] = "A valid destination bit count must be specified.";
@@ -396,11 +392,6 @@ if ($_POST) {
else
unset($filterent['icmptype']);
- if ($_POST['proto'] == "icmp6" && $_POST['icmp6type'])
- $filterent['icmp6type'] = $_POST['icmp6type'];
- else
- unset($filterent['icmp6type']);
-
pconfig_to_address($filterent['source'], $_POST['src'],
$_POST['srcmask'], $_POST['srcnot'],
$_POST['srcbeginport'], $_POST['srcendport']);
@@ -475,8 +466,6 @@ include("head.inc");
?>
-<script type="text/javascript" src="javascript/NetUtils.js"></script>
-
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
@@ -590,7 +579,7 @@ include("head.inc");
<td width="78%" class="vtable">
<select name="proto" class="formselect" onchange="proto_change()">
<?php
- $protocols = explode(" ", "TCP UDP TCP/UDP ICMP TCP6 UDP6 TCP6/UDP6 ICMP6 ESP AH GRE IGMP any carp pfsync");
+ $protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IGMP any carp pfsync");
foreach ($protocols as $proto): ?>
<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>><?=htmlspecialchars($proto);?></option>
<?php endforeach; ?>
@@ -632,50 +621,6 @@ include("head.inc");
<span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span>
</td>
</tr>
- <tr id="icmp6box" name="icmp6box">
- <td valign="top" class="vncell">ICMP6 type</td>
- <td class="vtable">
- <select name="icmp6type" class="formselect">
-<?php
- $icmp6types = array(
- "unreach" => "Destination unreachable",
- "toobig" => "Packet too big",
- "timex" => "Time exceeded",
- "parampro" => "Invalid IPv6 header",
- "echoreq" => "Echo service request",
- "echorep" => "Echo service reply",
- "groupqry" => "Group membership query",
- "listqry" => "Multicast listener query",
- "grouprep" => "Group membership report",
- "listenrep" => "Multicast listener report",
- "groupterm" => "Group membership termination",
- "listendone" => "Multicast listerner done",
- "routersol" => "Router solicitation",
- "routeradv" => "Router advertisement",
- "neighbrsol" => "Neighbor solicitation",
- "neighbradv" => "Neighbor advertisement",
- "redir" => "Shorter route exists",
- "routrrenum" => "Route renumbering",
- "fqdnreq" => "FQDN query",
- "niqry" => "Node information query",
- "wrureq" => "Who-are-you request",
- "fqdnrep" => "FQDN reply",
- "nirep" => "Node information reply",
- "wrurep" => "Who-are-you reply",
- "mtraceresp" => "mtrace response",
- "mtrace" => "mtrace messages"
- );
-?>
-
- <?php foreach ($icmp6types as $icmp6type => $descr): ?>
- <option value="<?=$icmp6type;?>" <?php if ($icmp6type == $pconfig['icmp6type']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
- <?php endforeach; ?>
-
- </select>
- <br />
- <span class="vexpl">If you selected ICMP6 for the protocol above, you may specify an ICMP6 type here.</span>
- </td>
- </tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Source</td>
<td width="78%" class="vtable">
@@ -690,31 +635,11 @@ include("head.inc");
<td>Type:&nbsp;&nbsp;</td>
<td>
<select name="srctype" class="formselect" onChange="typesel_change()">
- <?php
- $sel_host = false;
- $sel_v4 = false;
- $sel_v6 = false;
-
- $sel = is_specialnet($pconfig['src']);
-
- if (is_ipaddr($pconfig['src']) && !$sel) {
- if ($pconfig['srcmask'] == 32) {
- $sel_host = true;
- } else {
- $sel_v4 = true;
- }
- } else if (Net_IPv6::checkIPv6($pconfig['src']) && !$sel) {
- if ($pconfig['srcmask'] == 128) {
- $sel_host = true;
- } else {
- $sel_v6 = true;
- }
- }
- ?>
+<?php
+ $sel = is_specialnet($pconfig['src']); ?>
<option value="any" <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>any</option>
- <option value="single" <?php if ($sel_host) echo "selected"; ?>>Single host or alias</option>
- <option value="network" <?php if ($sel_v4) echo "selected"; ?>>IPv4 Network</option>
- <option value="network_ipv6" <?php if ($sel_v6) echo "selected"; ?>>IPv6 Network</option>
+ <option value="single" <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
+ <option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
<?php if(have_ruleint_access("wan")): ?>
<option value="wanip" <?php if ($pconfig['src'] == "wanip") { echo "selected"; } ?>>WAN address</option>
<?php endif; ?>
@@ -838,31 +763,11 @@ include("head.inc");
<td>Type:&nbsp;&nbsp;</td>
<td>
<select name="dsttype" class="formselect" onChange="typesel_change()">
- <?php
- $sel_host = false;
- $sel_v4 = false;
- $sel_v6 = false;
-
- $sel = is_specialnet($pconfig['src']);
-
- if (is_ipaddr($pconfig['src']) && !$sel) {
- if ($pconfig['dstmask'] == 32) {
- $sel_host = true;
- } else {
- $sel_v4 = true;
- }
- } else if (Net_IPv6::checkIPv6($pconfig['src']) && !$sel) {
- if ($pconfig['dstmask'] == 128) {
- $sel_host = true;
- } else {
- $sel_v6 = true;
- }
- }
- ?>
+<?php
+ $sel = is_specialnet($pconfig['dst']); ?>
<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>any</option>
- <option value="single" <?php if ($sel_host) echo "selected"; ?>>Single host or alias</option>
- <option value="network" <?php if ($sel_v4) echo "selected"; ?>>IPv4 Network</option>
- <option value="network_ipv6" <?php if ($sel_v6) echo "selected"; ?>>IPv6 Network</option>
+ <option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
+ <option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
<?php if(have_ruleint_access("wan")): ?>
<option value="wanip" <?php if ($pconfig['dst'] == "wanip") { echo "selected"; } ?>>WAN address</option>
<?php endif; ?>
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index c302232..c14e6be 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -40,8 +40,7 @@
##|*MATCH=interfaces.php*
##|-PRIV
-require_once("guiconfig.inc");
-require_once("IPv6.inc");
+require("guiconfig.inc");
if ($_REQUEST['if'])
$if = $_REQUEST['if'];
@@ -155,14 +154,10 @@ if ($if == "wan" || $if == "lan")
else
$pconfig['enable'] = isset($wancfg['enable']);
-if (is_array($config['aliases']['alias'])) {
- foreach($config['aliases']['alias'] as $alias) {
- if($alias['name'] == $wancfg['descr']) {
- $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
- }
- }
-}
-
+if (is_array($config['aliases']['alias']))
+foreach($config['aliases']['alias'] as $alias)
+ if($alias['name'] == $wancfg['descr'])
+ $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
if ($wancfg['ipaddr'] == "dhcp") {
$pconfig['type'] = "dhcp";
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
@@ -172,25 +167,14 @@ if ($wancfg['ipaddr'] == "dhcp") {
$pconfig['type'] = "pppoe";
} else if ($wancfg['ipaddr'] == "pptp") {
$pconfig['type'] = "pptp";
-} else if ($wancfg['ipaddr'] == "" && $wancfg['ipaddr_ipv6'] == "") {
+} else if ($wancfg['ipaddr'] != "") {
+ $pconfig['type'] = "static";
+ $pconfig['ipaddr'] = $wancfg['ipaddr'];
+ $pconfig['subnet'] = $wancfg['subnet'];
+ $pconfig['gateway'] = $wancfg['gateway'];
+ $pconfig['pointtopoint'] = $wancfg['pointtopoint'];
+} else
$pconfig['type'] = "none";
-} else {
- if ($wancfg['ipaddr'] != "") {
- $pconfig['type'] = "static";
- $pconfig['ipaddr'] = $wancfg['ipaddr'];
- $pconfig['subnet'] = $wancfg['subnet'];
- $pconfig['gateway'] = $wancfg['gateway'];
- $pconfig['pointtopoint'] = $wancfg['pointtopoint'];
- }
-
- if ($wancfg['ipaddr_ipv6'] != "") {
- $pconfig['type'] = "static";
- $pconfig['ipaddr_ipv6'] = $wancfg['ipaddr_ipv6'];
- $pconfig['subnet_ipv6'] = $wancfg['subnet_ipv6'];
- $pconfig['gateway_ipv6'] = $wancfg['gateway_ipv6'];
- $pconfig['pointtopoint_ipv6'] = $wancfg['pointtopoint_ipv6'];
- }
-}
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
@@ -312,16 +296,8 @@ if ($_POST) {
}
/* input validation */
if ($_POST['type'] == "static") {
- if ($_POST['ipaddr'] != "") {
- $reqdfields = explode(" ", "ipaddr subnet gateway");
- $reqdfieldsn = explode(",", "IPv4 Address,IPv4 Subnet Bit Count,IPv4 Gateway");
- } else if ($_POST['ipaddr_ipv6'] != "") {
- $reqdfields = explode(" ", "ipaddr_ipv6 subnet_ipv6 gateway_ipv6");
- $reqdfieldsn = explode(",", "IPv6 Address,IPv6 Subnet Bit Count,IPv6 Gateway");
- } else {
- $input_errors[] = "An IPv4 or IPv6 Address is required.";
- }
-
+ $reqdfields = explode(" ", "ipaddr subnet gateway");
+ $reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
} else if ($_POST['type'] == "PPPoE") {
if ($_POST['pppoe_dialondemand']) {
@@ -345,13 +321,9 @@ if ($_POST) {
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])))
- $input_errors[] = "A valid IPv4 address must be specified.";
+ $input_errors[] = "A valid IP address must be specified.";
if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
- $input_errors[] = "A valid IPv4 subnet bit count must be specified.";
- if ($_POST['ipaddr_ipv6'] && !Net_IPv6::checkIPv6($_POST['ipaddr_ipv6']))
- $input_errors[] = "A valid IPv6 address must be specified.";
- if ($_POST['subnet_ipv6'] && !is_numeric($_POST['subnet_ipv6']))
- $input_errors[] = "A valid IPv6 prefix length must be specified.";
+ $input_errors[] = "A valid subnet bit count must be specified.";
if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address'])))
$input_errors[] = "A valid alias IP address must be specified.";
if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
@@ -365,9 +337,7 @@ if ($_POST) {
$input_errors[] = "A valid gateway must be specified.";
}
if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint'])))
- $input_errors[] = "A valid IPv4 point-to-point address must be specified.";
- if (($_POST['pointtopoint_ipv6'] && !is_ipaddr($_POST['pointtopoint_ipv6'])))
- $input_errors[] = "A valid IPv6 point-to-point address must be specified.";
+ $input_errors[] = "A valid point-to-point IP address must be specified.";
if (($_POST['provider'] && !is_domain($_POST['provider'])))
$input_errors[] = "The service name contains invalid characters.";
if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
@@ -438,10 +408,6 @@ if ($_POST) {
unset($wancfg['subnet']);
unset($wancfg['gateway']);
unset($wancfg['pointtopoint']);
- unset($wancfg['ipaddr_ipv6']);
- unset($wancfg['subnet_ipv6']);
- unset($wancfg['gateway_ipv6']);
- unset($wancfg['pointtopoint_ipv6']);
unset($wancfg['dhcphostname']);
unset($wancfg['pppoe_username']);
unset($wancfg['pppoe_password']);
@@ -467,17 +433,10 @@ if ($_POST) {
if ($_POST['type'] == "static") {
$wancfg['ipaddr'] = $_POST['ipaddr'];
$wancfg['subnet'] = $_POST['subnet'];
- $wancfg['ipaddr_ipv6'] = $_POST['ipaddr_ipv6'];
- $wancfg['subnet_ipv6'] = $_POST['subnet_ipv6'];
-
- if ($_POST['gateway'] != "none") {
+ if ($_POST['gateway'] != "none")
$wancfg['gateway'] = $_POST['gateway'];
- $wancfg['gateway_ipv6'] = $_POST['gateway_ipv6'];
- }
- if (isset($wancfg['ispointtopoint'])) {
+ if (isset($wancfg['ispointtopoint']))
$wancfg['pointtopoint'] = $_POST['pointtopoint'];
- $wancfg['pointtopoint_ipv6'] = $_POST['pointtopoint_ipv6'];
- }
} else if ($_POST['type'] == "dhcp") {
$wancfg['ipaddr'] = "dhcp";
$wancfg['dhcphostname'] = $_POST['dhcphostname'];
@@ -753,7 +712,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
else
$('allcfg').hide();
}
-
+
function show_periodic_reset(obj) {
if (obj.checked)
$('presetwrap').show();
@@ -863,7 +822,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
<td colspan="2" style="padding:0px;">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td colspan="2" valign="top" class="listtopic">Static IPv4 configuration</td>
+ <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">IP address</td>
@@ -885,7 +844,7 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
</tr>
<?php if (isset($wancfg['ispointtopoint'])): ?>
<tr>
- <td width="22%" valign="top" class="vncellreq">Point-to-point IPv4 address </td>
+ <td width="22%" valign="top" class="vncellreq">Point-to-point IP address </td>
<td width"78%" class="vtable">
<input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
</td>
@@ -899,10 +858,10 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
<?php
if(count($a_gateways) > 0) {
foreach ($a_gateways as $gateway) {
- if($gateway['interface'] == $if && $gateway['type'] == 'IPv4') {
+ if($gateway['interface'] == $if) {
?>
<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
- <?=htmlspecialchars($gateway['name']);?>
+ <?=htmlspecialchars($gateway['name']);?>
</option>
<?php
}
@@ -959,63 +918,10 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
</table>
</td></tr></table>
<p/>
- </div> </td>
+ </div>
+ </td>
</tr>
</table>
-
- <!-- IPv6 begin -->
- <tr>
- <td colspan="2" valign="top" class="listtopic">Static IPv6 configuration</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">IP address</td>
- <td width="78%" class="vtable"> <input name="ipaddr_ipv6" type="text" class="formfld unknown" id="ipaddr_ipv6" size="20" value="<?=htmlspecialchars($pconfig['ipaddr_ipv6']);?>">
- /
- <select name="subnet_ipv6" class="formselect" id="subnet_ipv6">
- <?php
- for ($i = 64; $i > 0; $i -= 4) {
- if ($i == $pconfig['subnet_ipv6']) {
- echo "<option value=\"$i\" selected=\"selected\">$i</option>";
- } else {
- echo "<option value=\"$i\">$i</option>";
- }
- }
- ?>
- </select>
- </td>
- </tr>
- <?php if (isset($wancfg['ispointtopoint'])): ?>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Point-to-point IPv6 address </td>
- <td width"78%" class="vtable">
- <input name="pointtopoint_ipv6" type="text" class="formfld unknown" id="pointtopoint_ipv6" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint_ipv6']);?>">
- </td>
- </tr><?php endif; ?>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Gateway</td>
- <td width="78%" class="vtable"><select name="gateway_ipv6" class="formselect" id="gateway_ipv6">
- <option value="none" selected>None</option>
- <?php
- if(count($a_gateways) > 0) {
- foreach ($a_gateways as $gateway) {
- if($gateway['interface'] == $if && $gateway['type'] == 'IPv6') {
- ?>
- <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway_ipv6']) echo "selected"; ?>>
- <?=htmlspecialchars($gateway['name']);?>
- </option>
- <?php
- }
- }
- }
- ?>
- </select>
- <br />
- Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br />
- TODO: use Ajax, similar to IPv4
- </td>
- </tr>
- <!-- IPv6 end -->
-
</td>
</tr>
<tr style="display:none;" name="dhcp" id="dhcp">
diff --git a/usr/local/www/javascript/firewall_rules_edit/firewall_rules_edit.js b/usr/local/www/javascript/firewall_rules_edit/firewall_rules_edit.js
index 873bd87..8ac037f 100644
--- a/usr/local/www/javascript/firewall_rules_edit/firewall_rules_edit.js
+++ b/usr/local/www/javascript/firewall_rules_edit/firewall_rules_edit.js
@@ -52,19 +52,7 @@ function typesel_change() {
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
- case 2: /* IPv4 network */
- var obj = document.getElementById('srcmask');
- NetUtils_clearOptions(obj);
- NetUtils_loadMaskIPv4(obj, 31, 1, 31);
-
- document.iform.src.disabled = 0;
- document.iform.srcmask.disabled = 0;
- break;
- case 3: /* IPv6 network */
- var obj = document.getElementById('srcmask');
- NetUtils_clearOptions(obj);
- NetUtils_loadMaskIPv6(obj, 127, 1, 127);
-
+ case 2: /* network */
document.iform.src.disabled = 0;
document.iform.srcmask.disabled = 0;
break;
@@ -81,19 +69,7 @@ function typesel_change() {
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
- case 2: /* IPv4 network */
- var obj = document.getElementById('dstmask');
- NetUtils_clearOptions(obj);
- NetUtils_loadMaskIPv4(obj, 31, 1, 31);
-
- document.iform.dst.disabled = 0;
- document.iform.dstmask.disabled = 0;
- break;
- case 3: /* IPv6 network */
- var obj = document.getElementById('dstmask');
- NetUtils_clearOptions(obj);
- NetUtils_loadMaskIPv6(obj, 63, 1, 63);
-
+ case 2: /* network */
document.iform.dst.disabled = 0;
document.iform.dstmask.disabled = 0;
break;
@@ -128,18 +104,12 @@ function proto_change() {
ext_change();
- if(document.iform.proto.selectedIndex == 3 || document.iform.proto.selectedIndex == 8) {
+ if(document.iform.proto.selectedIndex == 3 || document.iform.proto.selectedIndex == 4) {
document.getElementById("icmpbox").style.display = '';
} else {
document.getElementById("icmpbox").style.display = 'none';
}
- if(document.iform.proto.selectedIndex == 7) {
- document.getElementById("icmp6box").style.display = '';
- } else {
- document.getElementById("icmp6box").style.display = 'none';
- }
-
if(document.iform.proto.selectedIndex >= 0 && document.iform.proto.selectedIndex <= 2) {
document.getElementById("dprtr").style.display = '';
document.getElementById("showadvancedboxspr").innerHTML='<p><input type="button" onClick="show_source_port_range()" value="Advanced"></input> - Show source port range</a>';
@@ -176,4 +146,4 @@ window.onload = function () {
var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
}
-//-->
+//--> \ No newline at end of file
diff --git a/usr/local/www/services_usermanager.php b/usr/local/www/services_usermanager.php
index 18ea9d2..33a1538 100755
--- a/usr/local/www/services_usermanager.php
+++ b/usr/local/www/services_usermanager.php
@@ -193,7 +193,7 @@ END;
echo <<<END
<tr>
<td class="list" colspan="3"></td>
- <td class="list"> <a href="services_usermanager.php?act=new"><img src="./themes/".{$g['theme']}."/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ <td class="list"> <a href="services_usermanager.php?act=new"><img src="./themes/".$g['theme']."/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
END;
diff --git a/usr/local/www/system.php b/usr/local/www/system.php
index 650c797..fe466da 100755
--- a/usr/local/www/system.php
+++ b/usr/local/www/system.php
@@ -38,7 +38,6 @@
require("guiconfig.inc");
-require_once("IPv6.inc");
$pconfig['hostname'] = $config['system']['hostname'];
$pconfig['domain'] = $config['system']['domain'];
@@ -111,25 +110,12 @@ if ($_POST) {
if ($_POST['domain'] && !is_domain($_POST['domain'])) {
$input_errors[] = "The domain may only contain the characters a-z, 0-9, '-' and '.'.";
}
- /*
if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server.";
}
if (($_POST['dns3'] && !is_ipaddr($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddr($_POST['dns4']))) {
$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server.";
}
- */
-
- if (
- $_POST['dns1'] && !is_ipaddr($_POST['dns1']) && !Net_IPv6::checkIPv6($_POST['dns1']) ||
- $_POST['dns2'] && !is_ipaddr($_POST['dns2']) && !Net_IPv6::checkIPv6($_POST['dns2']) ||
- $_POST['dns3'] && !is_ipaddr($_POST['dns3']) && !Net_IPv6::checkIPv6($_POST['dns3']) ||
- $_POST['dns4'] && !is_ipaddr($_POST['dns4']) && !Net_IPv6::checkIPv6($_POST['dns4'])
- ) {
- $input_errors[] = "A valid IPv4/IPv6 address must be specified for the primary/secondary DNS server.";
- }
-
-
if ($_POST['webguiport'] && (!is_numericint($_POST['webguiport']) ||
($_POST['webguiport'] < 1) || ($_POST['webguiport'] > 65535))) {
$input_errors[] = "A valid TCP/IP port must be specified for the webConfigurator port.";
@@ -267,7 +253,7 @@ include("head.inc");
<td width="78%" class="vtable"> <input name="domain" type="text" class="formfld unknown" id="domain" size="40" value="<?=htmlspecialchars($pconfig['domain']);?>">
<br/>
<span class="vexpl">
- e.g. <em>example.com</em>
+ e.g. <em>mycorp.com</em>
</span>
</td>
</tr>
@@ -321,7 +307,7 @@ include("head.inc");
</table>
<br>
<span class="vexpl">
- IPv4/IPv6 addresses; these are also used for the DHCP
+ IP addresses; these are also used for the DHCP
service, DNS forwarder and for PPTP VPN clients.
<br/>
<?php if($multiwan): ?>
diff --git a/usr/local/www/system_gateways.php b/usr/local/www/system_gateways.php
index 17a0751..3b0cd6c 100755
--- a/usr/local/www/system_gateways.php
+++ b/usr/local/www/system_gateways.php
@@ -1,5 +1,5 @@
<?php
-/* $Id: system_gateways.php,v 1.1 2008/11/06 16:46:42 sumacob Exp $ */
+/* $Id$ */
/*
system_gateways.php
part of pfSense (http://pfsense.com)
@@ -39,10 +39,7 @@
require("guiconfig.inc");
-if (!is_array($config['gateways']['gateway_item']))
- $config['gateways']['gateway_item'] = array();
-
-$a_gateways = &$config['gateways']['gateway_item'];
+$a_gateways = return_gateways_array();
$changedesc = "Gateways: ";
if ($_POST) {
@@ -71,8 +68,12 @@ if ($_POST) {
if ($_GET['act'] == "del") {
if ($a_gateways[$_GET['id']]) {
- $changedesc .= "removed gateway {$_GET['id']}";
- unset($a_gateways[$_GET['id']]);
+ /* remove the real entry */
+ $realid = $a_gateways[$_GET['id']]['attribute'];
+ $a_gateways = &$config['gateways']['gateway_item'];
+
+ $changedesc .= "removed gateway {$realid}";
+ unset($a_gateways[$realid]);
write_config($changedesc);
touch($d_staticroutesdirty_path);
header("Location: system_gateways.php");
@@ -80,6 +81,7 @@ if ($_GET['act'] == "del") {
}
}
+
$pgtitle = array("System","Gateways");
include("head.inc");
@@ -128,9 +130,9 @@ effect.");?><br>
<tr>
<td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
- echo $gateway['name'];
+ echo strtoupper($gateway['name']);
if(isset($gateway['defaultgw'])) {
- echo " <br /><strong>({$gateway['type']} default)<strong>";
+ echo " <strong>(default)<strong>";
}
?>
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
index 15b60e1..a8aa571 100755
--- a/usr/local/www/system_gateways_edit.php
+++ b/usr/local/www/system_gateways_edit.php
@@ -1,5 +1,5 @@
<?php
-/* $Id: system_gateways_edit.php,v 1.3 2008/11/24 05:48:02 sumacob Exp $ */
+/* $Id$ */
/*
system_gateways_edit.php
part of pfSense (http://pfsense.com)
@@ -37,21 +37,18 @@
##|-PRIV
-require_once("guiconfig.inc");
-require_once("IPv6.inc");
+require("guiconfig.inc");
-if (!is_array($config['gateways']['gateway_item']))
- $config['gateways']['gateway_item'] = array();
-
-$a_gateways = &$config['gateways']['gateway_item'];
+$a_gateways = return_gateways_array();
+$a_gateways_arr = array();
+foreach($a_gateways as $gw) {
+ $a_gateways_arr[] = $gw;
+}
+$a_gateways = $a_gateways_arr;
-if (isset($_GET['id'])) {
- $id = $_GET['id'];
-} else if (isset($_POST['id'])) {
+$id = $_GET['id'];
+if (isset($_POST['id']))
$id = $_POST['id'];
-} else {
- $id = -1;
-}
if (isset($_GET['dup'])) {
$id = $_GET['dup'];
@@ -64,11 +61,13 @@ if (isset($id) && $a_gateways[$id]) {
$pconfig['defaultgw'] = $a_gateways[$id]['defaultgw'];
$pconfig['monitor'] = $a_gateways[$id]['monitor'];
$pconfig['descr'] = $a_gateways[$id]['descr'];
- $pconfig['type'] = $a_gateways[$id]['type'];
+ $pconfig['attribute'] = $a_gateways[$id]['attribute'];
}
-if (isset($_GET['dup']))
+if (isset($_GET['dup'])) {
unset($id);
+ unset($pconfig['attribute']);
+}
if ($_POST) {
@@ -84,37 +83,12 @@ if ($_POST) {
if (! isset($_POST['name'])) {
$input_errors[] = "A valid gateway name must be specified.";
}
-
- if ($_POST['type'] == 'IPv4') {
- if (!is_ipaddr($_POST['gateway'])) {
- $input_errors[] = "A valid IPv4 gateway address must be specified.";
- }
-
- if ($_POST['monitor'] && !is_ipaddr($_POST['monitor'])) {
- $input_errors[] = "A valid IPv4 monitor address must be specified.";
- }
- } else if ($_POST['type'] == 'IPv6') {
- if (!Net_IPv6::checkIPv6($_POST['gateway'])) {
- $input_errors[] = "A valid IPv6 gateway address must be specified.";
- }
-
- if ($_POST['monitor'] && !Net_IPv6::checkIPv6($_POST['monitor'])) {
- $input_errors[] = "A valid IPv6 monitor address must be specified.";
- }
- } else {
- $input_errors[] = "A network type must be specified.";
+ /* skip system gateways which have been automatically added */
+ if ($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($pconfig['attribute'] != "system")) {
+ $input_errors[] = "A valid gateway IP address must be specified.";
}
-
- if ($_POST['defaultgw'] == "yes") {
- $i=0;
- foreach ($a_gateways as $gateway) {
- if($id != $i && $config['gateways']['gateway_item'][$i]['type'] == $_POST['type']) {
- unset($config['gateways']['gateway_item'][$i]['defaultgw']);
- } else if ($config['gateways']['gateway_item'][$i]['type'] == $_POST['type']) {
- $config['gateways']['gateway_item'][$i]['defaultgw'] = true;
- }
- $i++;
- }
+ if ((($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']))) {
+ $input_errors[] = "A valid monitor IP address must be specified.";
}
/* check for overlaps */
@@ -137,22 +111,44 @@ if ($_POST) {
}
if (!$input_errors) {
- $gateway = array();
- $gateway['interface'] = $_POST['interface'];
- $gateway['name'] = $_POST['name'];
- $gateway['gateway'] = $_POST['gateway'];
- $gateway['monitor'] = $_POST['monitor'];
- $gateway['descr'] = $_POST['descr'];
- $gateway['type'] = $_POST['type'];
-
- if($_POST['defaultgw'] == "yes") {
- $gateway['defaultgw'] = true;
+ /* if we are processing a system gateway only save the monitorip */
+ if($pconfig['attribute'] == "system") {
+ $config['interfaces'][$_POST['interface']]['monitorip'] = $_POST['monitor'];
}
- if (isset($id) && $a_gateways[$id])
- $a_gateways[$id] = $gateway;
- else
- $a_gateways[] = $gateway;
+ /* Manual gateways are handled differently */
+ /* rebuild the array with the manual entries only */
+ if (!is_array($config['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+
+ $a_gateways = &$config['gateways']['gateway_item'];
+
+ if ($pconfig['attribute'] != "system") {
+ $gateway = array();
+ $gateway['interface'] = $_POST['interface'];
+ $gateway['name'] = $_POST['name'];
+ $gateway['gateway'] = $_POST['gateway'];
+ $gateway['descr'] = $_POST['descr'];
+
+ if ($_POST['defaultgw'] == "yes") {
+ $i = 0;
+ foreach($a_gateways as $gw) {
+ unset($config['gateways'][$i]['defaultgw']);
+ $i++;
+ }
+ $gateway['defaultgw'] = true;
+ } else {
+ unset($gateway['defaultgw']);
+ }
+
+ /* when saving the manual gateway we use the attribute which has the corresponding id */
+ $id = $pconfig['attribute'];
+ if (isset($id) && $a_gateways[$id]) {
+ $a_gateways[$id] = $gateway;
+ } else {
+ $a_gateways[] = $gateway;
+ }
+ }
touch($d_staticroutesdirty_path);
@@ -177,6 +173,12 @@ include("head.inc");
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="system_gateways_edit.php" method="post" name="iform" id="iform">
+ <?php
+ /* If this is a automatically added system gateway we need this var */
+ if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
+ echo "<input type='hidden' name='attribute' id='attribute' value='{$pconfig['attribute']}' >\n";
+ }
+ ?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic">Edit gateway</td>
@@ -209,71 +211,10 @@ include("head.inc");
<br> <span class="vexpl">Gateway name</span></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncellreq">Type</td>
- <td width="78%" class="vtable">
- <!-- XXX -->
- <? /*
- <?php if (isset($_GET['id']) || $_POST): ?>
- <select class="formselect" disabled="true">
- <?php
- if ($pconfig['type'] == 'IPv6') {
- $str = <<<EOD
- <option value="IPv6" selected>IPv6</option>
-EOD;
- } else {
- $str = <<<EOD
- <option value="IPv4" selected>IPv4</option>
-EOD;
- }
-
- echo $str;
- ?>
- </select>
- <input type="hidden" name="type" id="type" value="<?php htmlspecialchars($pconfig['type']); ?>" />
- <? else: ?>
- <select name="type" class="formselect">
- <?php
- if ($pconfig['type'] == 'IPv6') {
- $str = <<<EOD
- <option value="IPv4">IPv4</option>
- <option value="IPv6" selected>IPv6</option>
-EOD;
- } else {
- $str = <<<EOD
- <option value="IPv4" selected>IPv4</option>
- <option value="IPv6">IPv6</option>
-EOD;
- }
-
- echo $str;
- ?>
- </select>
- <? endif; ?>
- */ ?>
- <select name="type" class="formselect">
- <?php
- if ($pconfig['type'] == 'IPv6') {
- $str = <<<EOD
- <option value="IPv4">IPv4</option>
- <option value="IPv6" selected>IPv6</option>
-EOD;
- } else {
- $str = <<<EOD
- <option value="IPv4" selected>IPv4</option>
- <option value="IPv6">IPv6</option>
-EOD;
- }
-
- echo $str;
- ?>
- </select>
- </td>
- </tr>
- <tr>
<td width="22%" valign="top" class="vncellreq">Gateway</td>
<td width="78%" class="vtable">
<input name="gateway" type="text" class="formfld host" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
- <br> <span class="vexpl">Gateway IPv4/IPv6 address</span></td>
+ <br> <span class="vexpl">Gateway IP address</span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Default Gateway</td>
@@ -288,7 +229,7 @@ EOD;
<td width="78%" class="vtable">
<input name="monitor" type="text" id="monitor" value="<?php echo ($pconfig['monitor']) ; ?>" />
<strong>Alternative monitor IP</strong> <br />
- Enter an alternative address here to be used to monitor the link. This is used for the
+ Enter a alternative address here to be used to monitor the link. This is used for the
quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond
to icmp requests.</strong>
<br />
OpenPOWER on IntegriCloud