1 |
860c4e80
|
Chris Buechler
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
interfaces_lan.php
|
4 |
|
|
part of pfSense(http://pfsense.org)
|
5 |
|
|
|
6 |
|
|
Originally written by Adam Lebsack <adam at holonyx dot com>
|
7 |
|
|
Changes by Chris Buechler <cmb at pfsense dot org>
|
8 |
4aca19b3
|
Scott Ullrich
|
Additions by Scott Ullrich <sullrich@pfsense.org>
|
9 |
860c4e80
|
Chris Buechler
|
|
10 |
4aca19b3
|
Scott Ullrich
|
Copyright (C) 2004-2009 BSD Perimeter LLC.
|
11 |
|
|
Copyright (C) 2009 Scott Ullrich
|
12 |
860c4e80
|
Chris Buechler
|
All rights reserved.
|
13 |
|
|
|
14 |
|
|
Redistribution and use in source and binary forms, with or without
|
15 |
|
|
modification, are permitted provided that the following conditions are met:
|
16 |
|
|
|
17 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
18 |
|
|
this list of conditions and the following disclaimer.
|
19 |
|
|
|
20 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
21 |
|
|
notice, this list of conditions and the following disclaimer in the
|
22 |
|
|
documentation and/or other materials provided with the distribution.
|
23 |
|
|
|
24 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
25 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
26 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
27 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
28 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
29 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
31 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
32 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
34 |
|
|
*/
|
35 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
36 |
|
|
pfSense_MODULE: interfaces
|
37 |
|
|
*/
|
38 |
860c4e80
|
Chris Buechler
|
|
39 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
40 |
|
|
##|*IDENT=page-interfaces-ppp-edit
|
41 |
|
|
##|*NAME=Interfaces: PPP: Edit page
|
42 |
|
|
##|*DESCR=Allow access to the 'Interfaces: PPP: Edit' page.
|
43 |
|
|
##|*MATCH=interfaces_ppp_edit.php*
|
44 |
|
|
##|-PRIV
|
45 |
|
|
|
46 |
860c4e80
|
Chris Buechler
|
require("guiconfig.inc");
|
47 |
|
|
|
48 |
|
|
if (!is_array($config['ppps']['ppp']))
|
49 |
|
|
$config['ppps']['ppp'] = array();
|
50 |
|
|
|
51 |
|
|
$a_ppps = &$config['ppps']['ppp'];
|
52 |
|
|
|
53 |
|
|
$id = $_GET['id'];
|
54 |
|
|
if (isset($_POST['id']))
|
55 |
|
|
$id = $_POST['id'];
|
56 |
|
|
|
57 |
|
|
if (isset($id) && $a_ppps[$id]) {
|
58 |
5d41713c
|
Ermal Luçi
|
$pconfig['port'] = $a_ppps[$id]['port'];
|
59 |
f4758c47
|
Ermal Luçi
|
$pconfig['ap'] = $a_ppps[$id]['ap'];
|
60 |
860c4e80
|
Chris Buechler
|
$pconfig['initstr'] = $a_ppps[$id]['initstr'];
|
61 |
f4758c47
|
Ermal Luçi
|
$pconfig['username'] = $a_ppps[$id]['username'];
|
62 |
|
|
$pconfig['password'] = $a_ppps[$id]['password'];
|
63 |
|
|
$pconfig['gateway'] = $a_ppps[$id]['gateway'];
|
64 |
|
|
$pconfig['localip'] = $a_ppps[$id]['localip'];
|
65 |
860c4e80
|
Chris Buechler
|
$pconfig['phone'] = $a_ppps[$id]['phone'];
|
66 |
4aca19b3
|
Scott Ullrich
|
$pconfig['dialcmd'] = $a_ppps[$id]['dialcmd'];
|
67 |
f4758c47
|
Ermal Luçi
|
$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
|
68 |
860c4e80
|
Chris Buechler
|
$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
|
69 |
|
|
$pconfig['descr'] = $a_ppps[$id]['descr'];
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
if ($_POST) {
|
73 |
|
|
|
74 |
|
|
unset($input_errors);
|
75 |
|
|
$pconfig = $_POST;
|
76 |
|
|
|
77 |
|
|
/* input validation */
|
78 |
|
|
$reqdfields = explode(" ", "port");
|
79 |
|
|
$reqdfieldsn = explode(",", "Serial Port");
|
80 |
|
|
|
81 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
82 |
|
|
|
83 |
|
|
foreach ($a_ppps as $ppp) {
|
84 |
|
|
if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
|
85 |
|
|
continue;
|
86 |
|
|
|
87 |
|
|
if ($ppp['port'] == $_POST['port']) {
|
88 |
|
|
$input_errors[] = "Port is in use";
|
89 |
|
|
break;
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
if (!$input_errors) {
|
94 |
|
|
$ppp = array();
|
95 |
|
|
$ppp['port'] = $_POST['port'];
|
96 |
|
|
$ppp['initstr'] = $_POST['initstr'];
|
97 |
f4758c47
|
Ermal Luçi
|
$ppp['ap'] = $_POST['ap'];
|
98 |
860c4e80
|
Chris Buechler
|
$ppp['phone'] = $_POST['phone'];
|
99 |
4aca19b3
|
Scott Ullrich
|
$ppp['dialcmd'] = $_POST['dialcmd'];
|
100 |
f4758c47
|
Ermal Luçi
|
$ppp['username'] = $_POST['username'];
|
101 |
|
|
$ppp['password'] = $_POST['password'];
|
102 |
|
|
$ppp['localip'] = $_POST['localip'];
|
103 |
|
|
$ppp['gateway'] = $_POST['gateway'];
|
104 |
860c4e80
|
Chris Buechler
|
$ppp['linespeed'] = $_POST['linespeed'];
|
105 |
f4758c47
|
Ermal Luçi
|
$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
|
106 |
860c4e80
|
Chris Buechler
|
$ppp['descr'] = $_POST['descr'];
|
107 |
4aca19b3
|
Scott Ullrich
|
|
108 |
|
|
interfaces_ppp_configure();
|
109 |
|
|
|
110 |
|
|
if (isset($id) && $a_ppps[$id])
|
111 |
|
|
$a_ppps[$id] = $ppp;
|
112 |
|
|
else
|
113 |
|
|
$a_ppps[] = $ppp;
|
114 |
|
|
|
115 |
|
|
write_config();
|
116 |
|
|
|
117 |
|
|
header("Location: interfaces_ppp.php");
|
118 |
|
|
exit;
|
119 |
860c4e80
|
Chris Buechler
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
06a22f6d
|
Chris Buechler
|
$pgtitle = "Interfaces: PPP: Edit";
|
123 |
860c4e80
|
Chris Buechler
|
include("head.inc");
|
124 |
|
|
|
125 |
|
|
?>
|
126 |
|
|
|
127 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
128 |
|
|
<?php include("fbegin.inc"); ?>
|
129 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
130 |
4aca19b3
|
Scott Ullrich
|
<form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
|
131 |
46c3f09a
|
Scott Ullrich
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript">
|
132 |
|
|
</script>
|
133 |
|
|
<script type="text/javascript">
|
134 |
|
|
function prefill_att() {
|
135 |
|
|
$('dialcmd').value = '"ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \\"\" AT OK-AT-OK ATQ0V1E1S0=0&C1&D2+FCLASS=0 OK \AT+CGDCONT=1,\\\"IP\\\",\\\"ISP.CINGULAR\\\" OK \\dATDT\\T \TIMEOUT 40 CONNECT"';
|
136 |
|
|
$('phone').value = "*99#";
|
137 |
|
|
$('username').value = "att";
|
138 |
|
|
$('password').value = "att";
|
139 |
9694e102
|
Scott Ullrich
|
$('linespeed').value = "921600";
|
140 |
46c3f09a
|
Scott Ullrich
|
}
|
141 |
|
|
function prefill_sprint() {
|
142 |
|
|
$('dialcmd').value = '"ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \\"\" AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT"';
|
143 |
|
|
$('phone').value = "#777";
|
144 |
|
|
$('username').value = "sprint";
|
145 |
9694e102
|
Scott Ullrich
|
$('password').value = "sprint";
|
146 |
|
|
$('linespeed').value = "921600";
|
147 |
46c3f09a
|
Scott Ullrich
|
}
|
148 |
|
|
</script>
|
149 |
4aca19b3
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
150 |
|
|
<tr>
|
151 |
|
|
<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
|
152 |
|
|
</tr>
|
153 |
|
|
<tr>
|
154 |
|
|
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
|
155 |
|
|
<td width="78%" class="vtable">
|
156 |
|
|
<select name="port" id="port" class="formselect">
|
157 |
|
|
<?php
|
158 |
|
|
$portlist = glob("/dev/cua*");
|
159 |
|
|
foreach ($portlist as $port) {
|
160 |
|
|
if(preg_match("/\.(lock|init)$/", $port))
|
161 |
|
|
continue;
|
162 |
|
|
echo "<option value=\"".trim($port)."\"";
|
163 |
|
|
if ($pconfig['port'] == $port)
|
164 |
|
|
echo "selected";
|
165 |
|
|
echo ">{$port}</option>";
|
166 |
|
|
}
|
167 |
|
|
?>
|
168 |
|
|
</select>
|
169 |
46c3f09a
|
Scott Ullrich
|
<p/>
|
170 |
|
|
Pre-fill connection information:
|
171 |
|
|
<a href='#' onClick='javascript:prefill_att();'>ATT</A>
|
172 |
|
|
<a href='#' onClick='javascript:prefill_sprint();'>Sprint</A>
|
173 |
4aca19b3
|
Scott Ullrich
|
</td>
|
174 |
|
|
</tr>
|
175 |
|
|
<tr>
|
176 |
|
|
<td width="22%" valign="top" class="vncell">Init String</td>
|
177 |
|
|
<td width="78%" class="vtable">
|
178 |
46c3f09a
|
Scott Ullrich
|
<textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
|
179 |
4aca19b3
|
Scott Ullrich
|
<br><span class="vexpl">Enter the modem initialization string here</span>
|
180 |
|
|
</td>
|
181 |
|
|
</tr>
|
182 |
f4758c47
|
Ermal Luçi
|
<tr>
|
183 |
|
|
<td width="22%" valign="top" class="vncell">AP Hostname</td>
|
184 |
|
|
<td width="78%" class="vtable">
|
185 |
|
|
<input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
|
186 |
|
|
</td>
|
187 |
|
|
</tr>
|
188 |
4aca19b3
|
Scott Ullrich
|
<tr>
|
189 |
|
|
<td width="22%" valign="top" class="vncell">Dial command</td>
|
190 |
|
|
<td width="78%" class="vtable">
|
191 |
|
|
<textarea rows="4" cols="65" name="dialcmd" id="dialcmd"><?=htmlspecialchars($pconfig['dialcmd']);?></textarea>
|
192 |
|
|
</td>
|
193 |
|
|
</tr>
|
194 |
f4758c47
|
Ermal Luçi
|
<tr>
|
195 |
|
|
<td width="22%" valign="top" class="vncell">Phone Number</td>
|
196 |
|
|
<td width="78%" class="vtable">
|
197 |
|
|
<input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
|
198 |
|
|
</td>
|
199 |
|
|
</tr>
|
200 |
4aca19b3
|
Scott Ullrich
|
<tr>
|
201 |
|
|
<td width="22%" valign="top" class="vncell">Username</td>
|
202 |
|
|
<td width="78%" class="vtable">
|
203 |
|
|
<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
|
204 |
|
|
</td>
|
205 |
|
|
</tr>
|
206 |
|
|
<tr>
|
207 |
|
|
<td width="22%" valign="top" class="vncell">Password</td>
|
208 |
|
|
<td width="78%" class="vtable">
|
209 |
|
|
<input name="password" type="password" class="formfld pwd" id="password" value="<?=htmlspecialchars($pconfig['password']);?>">
|
210 |
|
|
</td>
|
211 |
f4758c47
|
Ermal Luçi
|
</tr>
|
212 |
|
|
<tr>
|
213 |
|
|
<td width="22%" valign="top" class="vncell">Local IP</td>
|
214 |
|
|
<td width="78%" class="vtable">
|
215 |
ca010769
|
Chris Buechler
|
<input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
|
216 |
|
|
<span><p>Note: Enter your IP address here if it is not automatically assigned.</span>
|
217 |
f4758c47
|
Ermal Luçi
|
</td>
|
218 |
4aca19b3
|
Scott Ullrich
|
</tr>
|
219 |
860c4e80
|
Chris Buechler
|
<tr>
|
220 |
4aca19b3
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncell">Remote IP</td>
|
221 |
|
|
<td width="78%" class="vtable">
|
222 |
|
|
<input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
|
223 |
|
|
<span><p>Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed, equivalent to the gateway.</span>
|
224 |
|
|
</td>
|
225 |
|
|
</tr>
|
226 |
860c4e80
|
Chris Buechler
|
<tr>
|
227 |
4aca19b3
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncell">Line Speed</td>
|
228 |
|
|
<td width="78%" class="vtable">
|
229 |
|
|
<input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
|
230 |
|
|
</td>
|
231 |
|
|
</tr>
|
232 |
|
|
<tr>
|
233 |
|
|
<td width="22%" valign="top" class="vncell">Maximum connection retry</td>
|
234 |
|
|
<td width="78%" class="vtable">
|
235 |
|
|
<input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
|
236 |
|
|
</td>
|
237 |
|
|
</tr>
|
238 |
|
|
<tr>
|
239 |
|
|
<td width="22%" valign="top" class="vncell">Description</td>
|
240 |
|
|
<td width="78%" class="vtable">
|
241 |
|
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
242 |
|
|
<br> <span class="vexpl">You may enter a description here for your reference (not parsed).</span>
|
243 |
|
|
</td>
|
244 |
|
|
</tr>
|
245 |
|
|
<tr>
|
246 |
|
|
<td width="22%" valign="top"> </td>
|
247 |
|
|
<td width="78%">
|
248 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
249 |
|
|
<input type="button" value="Cancel" onclick="history.back()">
|
250 |
|
|
<?php if (isset($id) && $a_ppps[$id]): ?>
|
251 |
|
|
<input name="id" type="hidden" value="<?=$id;?>">
|
252 |
|
|
<?php endif; ?>
|
253 |
|
|
</td>
|
254 |
|
|
</tr>
|
255 |
|
|
</table>
|
256 |
860c4e80
|
Chris Buechler
|
</form>
|
257 |
|
|
<?php include("fend.inc"); ?>
|
258 |
|
|
</body>
|
259 |
|
|
</html>
|