mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Initial import of PPP for 3G and dial up modem support.
Needs testing and likely some fixing, then porting to HEAD once verified working.
This commit is contained in:
parent
cc3087bd05
commit
860c4e80bb
@ -394,7 +394,15 @@ function filter_generate_aliases() {
|
||||
if($opt_carp_ints)
|
||||
$aliases .= $opt_carp_ints;
|
||||
}
|
||||
$aliases .= " }\"\n";
|
||||
$aliases .= " }\"\n";
|
||||
/* XXX TODO: below comment and subsequent two lines of code from
|
||||
Adam Lebsack <adam at holonyx dot com>
|
||||
I'm not sure what it means, marking this to look into. cmb@
|
||||
|
||||
add an alias, since much of the filter code is broken when it comes to
|
||||
finding out the real interface */
|
||||
if(preg_match("/^ppp_(.+)$/", $config['interfaces'][$ifname]['if'], $matches))
|
||||
$aliases .= "{$config['interfaces'][$ifname]['if']} = \"ppp0\"\n";
|
||||
}
|
||||
$aliases .= "# User Aliases \n";
|
||||
/* Setup pf groups */
|
||||
|
||||
@ -278,6 +278,10 @@ function interfaces_optional_configure_if($opti) {
|
||||
if (is_array($optcfg['wireless']))
|
||||
interfaces_wireless_configure($optcfg['if'], $optcfg['wireless']);
|
||||
|
||||
/* PPP configuration */
|
||||
if (isset($optcfg['pointtopoint']))
|
||||
interfaces_ppp_configure_if($optcfg);
|
||||
|
||||
/* MAC spoofing? */
|
||||
if ($optcfg['spoofmac']) {
|
||||
mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) .
|
||||
@ -368,6 +372,74 @@ function interfaces_optional_configure_if($opti) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function interfaces_ppp_configure_if($ifcfg) {
|
||||
global $config;
|
||||
|
||||
if(file_exists("/var/run/ppp0.pid")) {
|
||||
$pid = file_get_contents("/var/run/ppp0.pid");
|
||||
mwexec('kill $pid');
|
||||
}
|
||||
|
||||
mwexec("/sbin/ifconfig ppp0 down destroy");
|
||||
|
||||
$peerfile = "lcp-echo-failure 0\n";
|
||||
$peerfile .= "lcp-echo-interval 0\n";
|
||||
$peerfile .= "connect /etc/ppp/peers/ppp0-connect-chat\n";
|
||||
//$peerfile .= "disconnect /etc/ppp/peers/ppp0-disconnect-chat\n";
|
||||
$peerfile .= "/dev/{$ifcfg['serialport']}\n";
|
||||
$peerfile .= "crtscts\n";
|
||||
$peerfile .= "local\n";
|
||||
$peerfile .= ":{$ifcfg['gateway']}\n";
|
||||
$peerfile .= "noipdefault\n";
|
||||
$peerfile .= "ipcp-accept-local\n";
|
||||
$peerfile .= "novj\n";
|
||||
$peerfile .= "nobsdcomp\n";
|
||||
$peerfile .= "novjccomp\n";
|
||||
$peerfile .= "nopcomp\n";
|
||||
$peerfile .= "noaccomp\n";
|
||||
$peerfile .= "noauth\n";
|
||||
$peerfile .= "persist\n";
|
||||
$peerfile .= "debug\n";
|
||||
// KD - test
|
||||
//$peerfile .= "defaultroute\n";
|
||||
//$peerfile .= "nodetach\n";
|
||||
// KD - so I know where to look!
|
||||
$peerfile .= "# created by /etc/inc/interfaces.inc\n";
|
||||
file_put_contents("/etc/ppp/peers/ppp0", $peerfile);
|
||||
|
||||
// Added single quotes to some strings below:
|
||||
// the \rAT is *always* going to need it
|
||||
// and the phone number on a GSM connection ends in a # char
|
||||
// Kevin Dawson, 22 Jan 2008
|
||||
// Refer Andrew Curtis
|
||||
|
||||
$chatfile = "#!/bin/sh\n";
|
||||
$chatfile .= "exec chat \\\n";
|
||||
$chatfile .= "TIMEOUT 5 \\\n";
|
||||
$chatfile .= "ECHO ON \\\n";
|
||||
$chatfile .= "ABORT '\\nBUSY\\r' \\\n";
|
||||
$chatfile .= "ABORT '\\nERROR\\r' \\\n";
|
||||
$chatfile .= "ABORT '\\nNO ANSWER\\r' \\\n";
|
||||
$chatfile .= "ABORT '\\nNO CARRIER\\r' \\\n";
|
||||
$chatfile .= "ABORT '\\nNO DIALTONE\\r' \\\n";
|
||||
$chatfile .= "ABORT '\\nRINGING\\r\\n\\r\\nRINGING\\r' \\\n";
|
||||
// KD
|
||||
$chatfile .= "'' '\\rAT' \\\n";
|
||||
$chatfile .= "TIMEOUT 12 \\\n";
|
||||
$chatfile .= "OK ATH \\\n";
|
||||
$chatfile .= "OK ATE1 \\\n";
|
||||
$chatfile .= "OK 'AT+CGDCONT=1,\"IP\",\"{$ifcfg['ap']}\"' \\\n";
|
||||
// KD
|
||||
$chatfile .= "OK 'ATD{$ifcfg['phone']}' \\\n";
|
||||
$chatfile .= "TIMEOUT 22 \\\n";
|
||||
$chatfile .= "CONNECT \"\" \\\n";
|
||||
$chatfile .= "SAY \"\\nConnected.\"\n";
|
||||
file_put_contents("/etc/ppp/peers/ppp0-connect-chat", $chatfile);
|
||||
chmod("/etc/ppp/peers/ppp0-connect-chat", 0755);
|
||||
mwexec("/sbin/ifconfig ppp0 create");
|
||||
return 0;
|
||||
}
|
||||
|
||||
function interfaces_carp_configure() {
|
||||
global $g, $config, $debugging;
|
||||
$balanacing = "";
|
||||
@ -1637,6 +1709,20 @@ function get_number_of_vlan_interfaces() {
|
||||
return "{$vlans_total}";
|
||||
}
|
||||
|
||||
function get_number_of_ppp_interfaces() {
|
||||
$ppps_total = 0;
|
||||
$ppps = split("\n", `/sbin/ifconfig -a | /usr/bin/grep ppp | grep flags`);
|
||||
foreach($ppps as $bridge) {
|
||||
$match_array = "";
|
||||
preg_match_all("/ppp(.*):/",$bridge,$match_array);
|
||||
if($match_array[1][0] <> "") {
|
||||
if($match_array[1][0] > $ppps_total)
|
||||
$ppps_total = $match_array[1][0];
|
||||
}
|
||||
}
|
||||
return "{$ppps_total}";
|
||||
}
|
||||
|
||||
function get_next_available_bridge_interface() {
|
||||
$bridges_total = get_number_of_bridged_interfaces();
|
||||
$interfaces = `/sbin/ifconfig -l`;
|
||||
|
||||
@ -1464,6 +1464,8 @@ function guess_interface_from_ip($ipaddress) {
|
||||
|
||||
function filter_opt_interface_to_real($opt) {
|
||||
global $config;
|
||||
if(isset($config['interfaces'][$opt]['pointtopoint']))
|
||||
return "ppp0";
|
||||
return $config['interfaces'][$opt]['if'];
|
||||
}
|
||||
|
||||
@ -1509,6 +1511,8 @@ function find_ip_interface($ip) {
|
||||
*/
|
||||
function filter_translate_type_to_real_interface($interface) {
|
||||
global $config;
|
||||
if(isset($config['interfaces'][$interface]['pointtopoint']))
|
||||
return "ppp0";
|
||||
if($config['interfaces'][$interface]['if'] <> "") {
|
||||
return $config['interfaces'][$interface]['if'];
|
||||
} else {
|
||||
@ -1780,6 +1784,8 @@ function convert_friendly_interface_to_real_interface_name($interface) {
|
||||
global $config;
|
||||
if($config['interfaces'][$interface]['ipaddr'] == "pppoe")
|
||||
return "ng0";
|
||||
if(isset($config['interfaces'][$interface]['pointtopoint']))
|
||||
return "ppp0";
|
||||
$lc_interface = strtolower($interface);
|
||||
if($lc_interface == "lan")
|
||||
return $config['interfaces']['lan']['if'];
|
||||
|
||||
@ -50,6 +50,17 @@ if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
||||
}
|
||||
}
|
||||
|
||||
/* add PPP interfaces */
|
||||
if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
|
||||
$i = 0;
|
||||
foreach ($config['ppps']['ppp'] as $ppp) {
|
||||
$portname = 'ppp_' . basename($ppp['port']);
|
||||
$portlist[$portname] = $ppp;
|
||||
$portlist[$portname]['isppp'] = true;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
unset($input_errors);
|
||||
@ -92,7 +103,11 @@ if ($_POST) {
|
||||
|
||||
if (!is_array($ifport)) {
|
||||
$config['interfaces'][$ifname]['if'] = $ifport;
|
||||
|
||||
if (preg_match('/^ppp_(.+)$/', $ifport, $matches)) {
|
||||
$config['interfaces'][$ifname]['pointtopoint'] = true;
|
||||
$config['interfaces'][$ifname]['serialport'] = $matches[1];
|
||||
}
|
||||
|
||||
/* check for wireless interfaces, set or clear ['wireless'] */
|
||||
if (preg_match($g['wireless_regex'], $ifport)) {
|
||||
if (!is_array($config['interfaces'][$ifname]['wireless']))
|
||||
@ -235,6 +250,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
|
||||
$tab_array = array();
|
||||
$tab_array[0] = array("Interface assignments", true, "interfaces_assign.php");
|
||||
$tab_array[1] = array("VLANs", false, "interfaces_vlan.php");
|
||||
$tab_array[2] = array("PPP", false, "interfaces_ppp.php");
|
||||
display_top_tabs($tab_array);
|
||||
?>
|
||||
</td></tr>
|
||||
@ -264,6 +280,11 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
|
||||
if ($portinfo['descr'])
|
||||
$descr .= " (" . $portinfo['descr'] . ")";
|
||||
echo htmlspecialchars($descr);
|
||||
} elseif ($portinfo['isppp']) {
|
||||
$descr = "PPP {$portinfo['port']}";
|
||||
if ($portinfo['descr'])
|
||||
$descr .= " (" . $portinfo['descr'] . ")";
|
||||
echo htmlspecialchars($descr);
|
||||
} else
|
||||
echo htmlspecialchars($portname . " (" . $portinfo['mac'] . ")");
|
||||
?>
|
||||
|
||||
@ -84,6 +84,8 @@ if ($optcfg['ipaddr'] == "dhcp") {
|
||||
$pconfig['subnet'] = $optcfg['subnet'];
|
||||
$pconfig['gateway'] = $optcfg['gateway'];
|
||||
$pconfig['pointtopoint'] = $optcfg['pointtopoint'];
|
||||
$pconfig['ap'] = $optcfg['ap'];
|
||||
$pconfig['phone'] = $optcfg['phone'];
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
@ -231,8 +233,11 @@ if ($_POST) {
|
||||
$optcfg['ipaddr'] = $_POST['ipaddr'];
|
||||
$optcfg['subnet'] = $_POST['subnet'];
|
||||
$optcfg['gateway'] = $_POST['gateway'];
|
||||
if (isset($optcfg['ispointtopoint']))
|
||||
if (isset($optcfg['ispointtopoint'])) {
|
||||
$optcfg['pointtopoint'] = $_POST['pointtopoint'];
|
||||
$optcfg['ap'] = $_POST['ap'];
|
||||
$optcfg['phone'] = $_POST['phone'];
|
||||
}
|
||||
} else if ($_POST['type'] == "DHCP") {
|
||||
$optcfg['ipaddr'] = "dhcp";
|
||||
$optcfg['dhcphostname'] = $_POST['dhcphostname'];
|
||||
@ -324,6 +329,30 @@ function show_mon_config() {
|
||||
<tr>
|
||||
<td colspan="2" valign="top" class="listtopic">General configuration</td>
|
||||
</tr>
|
||||
<?php if (isset($optcfg['pointtopoint'])): ?>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">AP Hostname</td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="ap" type="text" class="formfld" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">Phone Number</td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="phone" type="text" class="formfld" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">Remote IP</td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="gateway" type="text" class="formfld" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<input name="type" type="hidden" value="Static">
|
||||
<input name="ipaddr" type="hidden" value="0.0.0.0">
|
||||
<input name="subnet" type="hidden" value="32">
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td valign="middle" class="vncell"><strong>Type</strong></td>
|
||||
<td class="vtable"> <select name="type" class="formselect" id="type" onchange="type_change()">
|
||||
@ -422,6 +451,7 @@ function show_mon_config() {
|
||||
</select>Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<tr>
|
||||
<td colspan="2" valign="top" height="16"></td>
|
||||
</tr>
|
||||
|
||||
148
usr/local/www/interfaces_ppp.php
Normal file
148
usr/local/www/interfaces_ppp.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/*
|
||||
interfaces_lan.php
|
||||
part of pfSense(http://pfsense.org)
|
||||
|
||||
Originally written by Adam Lebsack <adam at holonyx dot com>
|
||||
Changes by Chris Buechler <cmb at pfsense dot org>
|
||||
|
||||
Copyright (C) 2004-2008 BSD Perimeter LLC.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require("guiconfig.inc");
|
||||
|
||||
if (!is_array($config['ppps']['ppp']))
|
||||
$config['ppps']['ppp'] = array();
|
||||
|
||||
$a_ppps = &$config['ppps']['ppp'] ;
|
||||
|
||||
function ppp_inuse($num) {
|
||||
global $config, $g;
|
||||
|
||||
if ($config['interfaces']['lan']['if'] == "ppp{$num}")
|
||||
return true;
|
||||
if ($config['interfaces']['wan']['if'] == "ppp{$num}")
|
||||
return true;
|
||||
|
||||
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
||||
if ($config['interfaces']['opt' . $i]['if'] == "ppp{$num}")
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function renumber_ppp($if, $delppp) {
|
||||
if (!preg_match("/^ppp/", $if))
|
||||
return $if;
|
||||
|
||||
$ppp = substr($if, 4);
|
||||
if ($ppp > $delppp)
|
||||
return "ppp" . ($ppp - 1);
|
||||
else
|
||||
return $if;
|
||||
}
|
||||
|
||||
if ($_GET['act'] == "del") {
|
||||
/* check if still in use */
|
||||
if (ppp_inuse($_GET['id'])) {
|
||||
$input_errors[] = "This PPP interface cannot be deleted because it is still being used as an interface.";
|
||||
} else {
|
||||
unset($a_ppps[$_GET['id']]);
|
||||
|
||||
/* renumber all interfaces that use PPP */
|
||||
$config['interfaces']['lan']['if'] = renumber_ppp($config['interfaces']['lan']['if'], $_GET['id']);
|
||||
$config['interfaces']['wan']['if'] = renumber_ppp($config['interfaces']['wan']['if'], $_GET['id']);
|
||||
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
|
||||
$config['interfaces']['opt' . $i]['if'] = renumber_ppp($config['interfaces']['opt' . $i]['if'], $_GET['id']);
|
||||
|
||||
write_config();
|
||||
|
||||
interfaces_optional_configure();
|
||||
|
||||
header("Location: interfaces_ppp.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$pgtitle = "Interfaces: PPP";
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<p class="pgtitle"><?=$pgtitle?></p>
|
||||
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td>
|
||||
<?php
|
||||
$tab_array = array();
|
||||
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
|
||||
$tab_array[1] = array("VLANs", false, "interfaces_vlan.php");
|
||||
$tab_array[2] = array("PPP", true, "interfaces_ppp.php");
|
||||
display_top_tabs($tab_array);
|
||||
?>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div id="mainarea">
|
||||
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="20%" class="listhdrr">Interface</td>
|
||||
<td width="20%" class="listhdrr">Serial Port</td>
|
||||
<td width="50%" class="listhdr">Description</td>
|
||||
<td width="10%" class="list"></td>
|
||||
</tr>
|
||||
<?php $i = 0; foreach ($a_ppps as $id => $ppp): ?>
|
||||
<tr>
|
||||
<td class="listlr">
|
||||
ppp<?=htmlspecialchars($id);?>
|
||||
</td>
|
||||
<td class="listr">
|
||||
<?=htmlspecialchars($ppp['port']);?>
|
||||
</td>
|
||||
<td class="listbg">
|
||||
<font color="white">
|
||||
<?=htmlspecialchars($ppp['descr']);?>
|
||||
</font>
|
||||
</td>
|
||||
<td valign="middle" nowrap class="list"> <a href="interfaces_ppp_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
|
||||
<a href="interfaces_ppp.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this PPP interface?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<tr>
|
||||
<td class="list" colspan="3"> </td>
|
||||
<td class="list"> <a href="interfaces_ppp_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php include("fend.inc"); ?>
|
||||
</body>
|
||||
</html>
|
||||
166
usr/local/www/interfaces_ppp_edit.php
Normal file
166
usr/local/www/interfaces_ppp_edit.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/*
|
||||
interfaces_lan.php
|
||||
part of pfSense(http://pfsense.org)
|
||||
|
||||
Originally written by Adam Lebsack <adam at holonyx dot com>
|
||||
Changes by Chris Buechler <cmb at pfsense dot org>
|
||||
|
||||
Copyright (C) 2004-2008 BSD Perimeter LLC.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require("guiconfig.inc");
|
||||
|
||||
if (!is_array($config['ppps']['ppp']))
|
||||
$config['ppps']['ppp'] = array();
|
||||
|
||||
$a_ppps = &$config['ppps']['ppp'];
|
||||
|
||||
|
||||
$id = $_GET['id'];
|
||||
if (isset($_POST['id']))
|
||||
$id = $_POST['id'];
|
||||
|
||||
if (isset($id) && $a_ppps[$id]) {
|
||||
$pconfig['if'] = $a_ppps[$id]['if'];
|
||||
$pconfig['initstr'] = $a_ppps[$id]['initstr'];
|
||||
$pconfig['phone'] = $a_ppps[$id]['phone'];
|
||||
$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
|
||||
$pconfig['descr'] = $a_ppps[$id]['descr'];
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
unset($input_errors);
|
||||
$pconfig = $_POST;
|
||||
|
||||
/* input validation */
|
||||
$reqdfields = explode(" ", "port");
|
||||
$reqdfieldsn = explode(",", "Serial Port");
|
||||
|
||||
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
||||
|
||||
foreach ($a_ppps as $ppp) {
|
||||
if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
|
||||
continue;
|
||||
|
||||
if ($ppp['port'] == $_POST['port']) {
|
||||
$input_errors[] = "Port is in use";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$input_errors) {
|
||||
$ppp = array();
|
||||
$ppp['port'] = $_POST['port'];
|
||||
$ppp['initstr'] = $_POST['initstr'];
|
||||
$ppp['phone'] = $_POST['phone'];
|
||||
$ppp['linespeed'] = $_POST['linespeed'];
|
||||
$ppp['descr'] = $_POST['descr'];
|
||||
|
||||
if (isset($id) && $a_ppps[$id])
|
||||
$a_ppps[$id] = $ppp;
|
||||
else
|
||||
$a_ppps[] = $ppp;
|
||||
|
||||
write_config();
|
||||
|
||||
interfaces_optional_configure();
|
||||
|
||||
header("Location: interfaces_ppp.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$pgtitle = "Firewall: PPP: Edit";
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<p class="pgtitle"><?=$pgtitle?></p>
|
||||
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
||||
<form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
|
||||
<td width="78%" class="vtable">
|
||||
<select name="port" class="formfld">
|
||||
<?php
|
||||
$portlist = glob("/dev/cua*");
|
||||
foreach ($portlist as $port) {
|
||||
if(preg_match("/\.(lock|init)$/", $port))
|
||||
continue;
|
||||
echo "<option value=\"{$port}\"";
|
||||
if (false)
|
||||
echo "selected";
|
||||
echo ">";
|
||||
echo $port;
|
||||
echo "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">Init String</td>
|
||||
<td width="78%" class="vtable">
|
||||
<textarea name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
|
||||
<br> <span class="vexpl">Enter the modem initialization string here</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">Phone Number</td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="phone" type="text" class="formfld" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">Line Speed</td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="linespeed" type="text" class="formfld" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell">Description</td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
||||
<br> <span class="vexpl">You may enter a description here
|
||||
for your reference (not parsed).</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top"> </td>
|
||||
<td width="78%">
|
||||
<input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
|
||||
<?php if (isset($id) && $a_ppps[$id]): ?>
|
||||
<input name="id" type="hidden" value="<?=$id;?>">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include("fend.inc"); ?>
|
||||
</body>
|
||||
</html>
|
||||
@ -100,6 +100,7 @@ include("head.inc");
|
||||
$tab_array = array();
|
||||
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
|
||||
$tab_array[1] = array("VLANs", true, "interfaces_vlan.php");
|
||||
$tab_array[2] = array("PPP", false, "interfaces_ppp.php");
|
||||
display_top_tabs($tab_array);
|
||||
?>
|
||||
</td></tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user