1 |
860c4e80
|
Chris Buechler
|
<?php
|
2 |
|
|
/*
|
3 |
0e1add13
|
Ermal Lu?i
|
interfaces_ppp_edit.php
|
4 |
860c4e80
|
Chris Buechler
|
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 |
9ebe7028
|
gnhb
|
$pconfig['initstr'] = base64_decode($a_ppps[$id]['initstr']);
|
60 |
|
|
$pconfig['simpin'] = $a_ppps[$id]['simpin'];
|
61 |
|
|
$pconfig['pin-wait'] = $a_ppps[$id]['pin-wait'];
|
62 |
|
|
$pconfig['apn'] = $a_ppps[$id]['apn'];
|
63 |
|
|
$pconfig['apnum'] = $a_ppps[$id]['apnum'];
|
64 |
|
|
$pconfig['phone'] = $a_ppps[$id]['phone'];
|
65 |
f4758c47
|
Ermal Luçi
|
$pconfig['username'] = $a_ppps[$id]['username'];
|
66 |
|
|
$pconfig['password'] = $a_ppps[$id]['password'];
|
67 |
|
|
$pconfig['localip'] = $a_ppps[$id]['localip'];
|
68 |
9ebe7028
|
gnhb
|
$pconfig['gateway'] = $a_ppps[$id]['gateway'];
|
69 |
daf8594a
|
Ermal Lu?i
|
if (isset($a_ppps[$id]['defaultgw']))
|
70 |
|
|
$pconfig['defaultgw'] = true;
|
71 |
9ebe7028
|
gnhb
|
$pconfig['connect-timeout'] = $a_ppps[$id]['connect-timeout'];
|
72 |
860c4e80
|
Chris Buechler
|
$pconfig['descr'] = $a_ppps[$id]['descr'];
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
if ($_POST) {
|
76 |
|
|
|
77 |
|
|
unset($input_errors);
|
78 |
|
|
$pconfig = $_POST;
|
79 |
|
|
|
80 |
|
|
/* input validation */
|
81 |
|
|
$reqdfields = explode(" ", "port");
|
82 |
|
|
$reqdfieldsn = explode(",", "Serial Port");
|
83 |
|
|
|
84 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
85 |
|
|
|
86 |
|
|
foreach ($a_ppps as $ppp) {
|
87 |
|
|
if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
|
88 |
|
|
continue;
|
89 |
|
|
|
90 |
|
|
if ($ppp['port'] == $_POST['port']) {
|
91 |
|
|
$input_errors[] = "Port is in use";
|
92 |
|
|
break;
|
93 |
|
|
}
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
if (!$input_errors) {
|
97 |
|
|
$ppp = array();
|
98 |
611ae852
|
Ermal
|
|
99 |
860c4e80
|
Chris Buechler
|
$ppp['port'] = $_POST['port'];
|
100 |
9ebe7028
|
gnhb
|
if ($_POST['initstr'] <> "")
|
101 |
|
|
$ppp['initstr'] = base64_encode($_POST['initstr']);
|
102 |
|
|
else
|
103 |
|
|
unset($ppp['initstr']);
|
104 |
|
|
|
105 |
|
|
if ($_POST['simpin'] <> "") {
|
106 |
|
|
$ppp['simpin'] = $_POST['simpin'];
|
107 |
|
|
$ppp['pin-wait'] = $_POST['pin-wait'];
|
108 |
|
|
} else {
|
109 |
|
|
unset($ppp['simpin']);
|
110 |
|
|
unset($ppp['pin-wait']);
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
$ppp['apn'] = $_POST['apn'];
|
114 |
|
|
if ($ppp['apn'] <> ""){
|
115 |
|
|
if ($_POST['apnum'] <> "")
|
116 |
|
|
$ppp['apnum'] = $_POST['apnum'];
|
117 |
|
|
else
|
118 |
|
|
$ppp['apnum'] = "1";
|
119 |
|
|
} else {
|
120 |
|
|
unset($ppp['apn']);
|
121 |
|
|
unset($ppp['apnum']);
|
122 |
|
|
}
|
123 |
|
|
|
124 |
860c4e80
|
Chris Buechler
|
$ppp['phone'] = $_POST['phone'];
|
125 |
f4758c47
|
Ermal Luçi
|
$ppp['username'] = $_POST['username'];
|
126 |
|
|
$ppp['password'] = $_POST['password'];
|
127 |
|
|
$ppp['localip'] = $_POST['localip'];
|
128 |
|
|
$ppp['gateway'] = $_POST['gateway'];
|
129 |
daf8594a
|
Ermal Lu?i
|
if ($_POST['defaultgw'] == "on")
|
130 |
|
|
$ppp['defaultgw'] = true;
|
131 |
|
|
else
|
132 |
|
|
unset($ppp['defaultgw']);
|
133 |
9ebe7028
|
gnhb
|
if ($_POST['connect-timeout'] <> "")
|
134 |
|
|
$ppp['connect-timeout'] = $_POST['connect-timeout'];
|
135 |
|
|
else
|
136 |
|
|
unset($ppp['connect-timeout']);
|
137 |
860c4e80
|
Chris Buechler
|
$ppp['descr'] = $_POST['descr'];
|
138 |
4aca19b3
|
Scott Ullrich
|
|
139 |
|
|
|
140 |
c90f2471
|
gnhb
|
$iflist = get_configured_interface_list();
|
141 |
|
|
foreach ($iflist as $if) {
|
142 |
|
|
if ($config['interfaces'][$if]['if'] == basename($a_ppps[$id]['port']))
|
143 |
c107a2ac
|
Ermal
|
$config['interfaces'][$if]['if'] = basename($ppp['port']);
|
144 |
|
|
}
|
145 |
|
|
|
146 |
4aca19b3
|
Scott Ullrich
|
if (isset($id) && $a_ppps[$id])
|
147 |
|
|
$a_ppps[$id] = $ppp;
|
148 |
|
|
else
|
149 |
|
|
$a_ppps[] = $ppp;
|
150 |
|
|
|
151 |
|
|
write_config();
|
152 |
|
|
|
153 |
|
|
header("Location: interfaces_ppp.php");
|
154 |
|
|
exit;
|
155 |
860c4e80
|
Chris Buechler
|
}
|
156 |
|
|
}
|
157 |
|
|
|
158 |
06a22f6d
|
Chris Buechler
|
$pgtitle = "Interfaces: PPP: Edit";
|
159 |
860c4e80
|
Chris Buechler
|
include("head.inc");
|
160 |
|
|
|
161 |
|
|
?>
|
162 |
|
|
|
163 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
164 |
|
|
<?php include("fbegin.inc"); ?>
|
165 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
166 |
4aca19b3
|
Scott Ullrich
|
<form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
|
167 |
46c3f09a
|
Scott Ullrich
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript">
|
168 |
|
|
</script>
|
169 |
|
|
<script type="text/javascript">
|
170 |
|
|
function prefill_att() {
|
171 |
9ebe7028
|
gnhb
|
$('initstr').value = "Q0V1E1S0=0&C1&D2+FCLASS=0";
|
172 |
|
|
$('apn').value = "ISP.CINGULAR";
|
173 |
|
|
$('apnum').value = "1";
|
174 |
46c3f09a
|
Scott Ullrich
|
$('phone').value = "*99#";
|
175 |
|
|
$('username').value = "att";
|
176 |
|
|
$('password').value = "att";
|
177 |
|
|
}
|
178 |
|
|
function prefill_sprint() {
|
179 |
9ebe7028
|
gnhb
|
$('initstr').value = "E1Q0";
|
180 |
|
|
$('apn').value = "";
|
181 |
|
|
$('apnum').value = "";
|
182 |
46c3f09a
|
Scott Ullrich
|
$('phone').value = "#777";
|
183 |
|
|
$('username').value = "sprint";
|
184 |
9694e102
|
Scott Ullrich
|
$('password').value = "sprint";
|
185 |
46c3f09a
|
Scott Ullrich
|
}
|
186 |
7c8dcff2
|
Chris Buechler
|
function prefill_vzw() {
|
187 |
9ebe7028
|
gnhb
|
$('initstr').value = "E1Q0s7=60";
|
188 |
|
|
$('apn').value = "";
|
189 |
|
|
$('apnum').value = "";
|
190 |
7c8dcff2
|
Chris Buechler
|
$('phone').value = "#777";
|
191 |
|
|
$('username').value = "123@vzw3g.com";
|
192 |
|
|
$('password').value = "vzw";
|
193 |
|
|
}
|
194 |
46c3f09a
|
Scott Ullrich
|
</script>
|
195 |
4aca19b3
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
196 |
|
|
<tr>
|
197 |
|
|
<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
|
198 |
|
|
</tr>
|
199 |
|
|
<tr>
|
200 |
|
|
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
|
201 |
|
|
<td width="78%" class="vtable">
|
202 |
|
|
<select name="port" id="port" class="formselect">
|
203 |
|
|
<?php
|
204 |
|
|
$portlist = glob("/dev/cua*");
|
205 |
1de43d91
|
Ermal Lu?i
|
$modems = glob("/dev/modem*");
|
206 |
|
|
$portlist = array_merge($portlist, $modems);
|
207 |
4aca19b3
|
Scott Ullrich
|
foreach ($portlist as $port) {
|
208 |
|
|
if(preg_match("/\.(lock|init)$/", $port))
|
209 |
|
|
continue;
|
210 |
|
|
echo "<option value=\"".trim($port)."\"";
|
211 |
|
|
if ($pconfig['port'] == $port)
|
212 |
|
|
echo "selected";
|
213 |
|
|
echo ">{$port}</option>";
|
214 |
|
|
}
|
215 |
|
|
?>
|
216 |
|
|
</select>
|
217 |
46c3f09a
|
Scott Ullrich
|
<p/>
|
218 |
|
|
Pre-fill connection information:
|
219 |
|
|
<a href='#' onClick='javascript:prefill_att();'>ATT</A>
|
220 |
|
|
<a href='#' onClick='javascript:prefill_sprint();'>Sprint</A>
|
221 |
7c8dcff2
|
Chris Buechler
|
<a href='#' onClick='javascript:prefill_vzw();'>Verizon</A>
|
222 |
4aca19b3
|
Scott Ullrich
|
</td>
|
223 |
|
|
</tr>
|
224 |
daf8594a
|
Ermal Lu?i
|
<tr>
|
225 |
|
|
<td width="22%" valign="top" class="vncell">Link Type</td>
|
226 |
|
|
<td width="78%" class="vtable">
|
227 |
9ebe7028
|
gnhb
|
<input type="checkbox" value="on" id="defaultgw" name="defaultgw" <?php if (isset($pconfig['defaultgw'])) echo "checked"; ?>>This link will be used as the default gateway.
|
228 |
daf8594a
|
Ermal Lu?i
|
</td>
|
229 |
|
|
</tr>
|
230 |
4aca19b3
|
Scott Ullrich
|
<tr>
|
231 |
|
|
<td width="22%" valign="top" class="vncell">Init String</td>
|
232 |
|
|
<td width="78%" class="vtable">
|
233 |
611ae852
|
Ermal
|
<input type="text" size="40" class="formfld unknown" id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
|
234 |
9ebe7028
|
gnhb
|
<br><span class="vexpl">Note: Enter the modem initialization string here. Do NOT include the "AT" string at the beginning of the command.</span>
|
235 |
4aca19b3
|
Scott Ullrich
|
</td>
|
236 |
|
|
</tr>
|
237 |
f4758c47
|
Ermal Luçi
|
<tr>
|
238 |
9ebe7028
|
gnhb
|
<td width="22%" valign="top" class="vncell">Sim PIN</td>
|
239 |
f4758c47
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
240 |
9ebe7028
|
gnhb
|
<input name="simpin" type="text" class="formfld unknown" id="simpin" size="12" value="<?=htmlspecialchars($pconfig['simpin']);?>">
|
241 |
|
|
</td>
|
242 |
|
|
</tr>
|
243 |
|
|
<tr>
|
244 |
|
|
<td width="22%" valign="top" class="vncell">Sim PIN wait</td>
|
245 |
|
|
<td width="78%" class="vtable">
|
246 |
|
|
<input name="pin-wait" type="text" class="formfld unknown" id="pin-wait" size="2" value="<?=htmlspecialchars($pconfig['pin-wait']);?>">
|
247 |
|
|
<br><span class="vexpl">Note: Time to wait for SIM to discover network after PIN is sent to SIM (seconds).</span>
|
248 |
f4758c47
|
Ermal Luçi
|
</td>
|
249 |
|
|
</tr>
|
250 |
4aca19b3
|
Scott Ullrich
|
<tr>
|
251 |
9ebe7028
|
gnhb
|
<td width="22%" valign="top" class="vncell">Access Point Name (APN)</td>
|
252 |
4aca19b3
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
253 |
9ebe7028
|
gnhb
|
<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
|
254 |
|
|
</td>
|
255 |
|
|
</tr>
|
256 |
|
|
<tr>
|
257 |
|
|
<td width="22%" valign="top" class="vncell">APN number (optional)</td>
|
258 |
|
|
<td width="78%" class="vtable">
|
259 |
|
|
<input name="apnum" type="text" class="formfld unknown" id="apnum" size="2" value="<?=htmlspecialchars($pconfig['apnum']);?>">
|
260 |
|
|
<br><span class="vexpl">Note: Defaults to 1 if you set APN above. Ignored if you set no APN above.</span>
|
261 |
|
|
</td>
|
262 |
4aca19b3
|
Scott Ullrich
|
</tr>
|
263 |
f4758c47
|
Ermal Luçi
|
<tr>
|
264 |
|
|
<td width="22%" valign="top" class="vncell">Phone Number</td>
|
265 |
|
|
<td width="78%" class="vtable">
|
266 |
|
|
<input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
|
267 |
9ebe7028
|
gnhb
|
<br><span class="vexpl">Note: Typically (*99# or *99***# or *99***1#) for GSM networks and *777 for CDMA networks</span>
|
268 |
f4758c47
|
Ermal Luçi
|
</td>
|
269 |
|
|
</tr>
|
270 |
4aca19b3
|
Scott Ullrich
|
<tr>
|
271 |
|
|
<td width="22%" valign="top" class="vncell">Username</td>
|
272 |
|
|
<td width="78%" class="vtable">
|
273 |
|
|
<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
|
274 |
|
|
</td>
|
275 |
|
|
</tr>
|
276 |
|
|
<tr>
|
277 |
|
|
<td width="22%" valign="top" class="vncell">Password</td>
|
278 |
|
|
<td width="78%" class="vtable">
|
279 |
|
|
<input name="password" type="password" class="formfld pwd" id="password" value="<?=htmlspecialchars($pconfig['password']);?>">
|
280 |
|
|
</td>
|
281 |
f4758c47
|
Ermal Luçi
|
</tr>
|
282 |
|
|
<tr>
|
283 |
|
|
<td width="22%" valign="top" class="vncell">Local IP</td>
|
284 |
|
|
<td width="78%" class="vtable">
|
285 |
ca010769
|
Chris Buechler
|
<input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
|
286 |
9ebe7028
|
gnhb
|
<br><span class="vexpl">Note: Enter your IP address here if it is not automatically assigned.</span>
|
287 |
f4758c47
|
Ermal Luçi
|
</td>
|
288 |
4aca19b3
|
Scott Ullrich
|
</tr>
|
289 |
860c4e80
|
Chris Buechler
|
<tr>
|
290 |
9ebe7028
|
gnhb
|
<td width="22%" valign="top" class="vncell">Remote IP (Gateway)</td>
|
291 |
4aca19b3
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
292 |
|
|
<input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
|
293 |
9ebe7028
|
gnhb
|
<br><span class="vexpl">Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed.</span>
|
294 |
4aca19b3
|
Scott Ullrich
|
</td>
|
295 |
|
|
</tr>
|
296 |
860c4e80
|
Chris Buechler
|
<tr>
|
297 |
4aca19b3
|
Scott Ullrich
|
<tr>
|
298 |
9ebe7028
|
gnhb
|
<td width="22%" valign="top" class="vncell">Connection Timeout</td>
|
299 |
4aca19b3
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
300 |
9ebe7028
|
gnhb
|
<input name="connect-timeout" type="text" class="formfld unknown" id="connect-timeout" size="2" value="<?=htmlspecialchars($pconfig['connect-timeout']);?>">
|
301 |
|
|
<br><span class="vexpl">Note: Enter timeout in seconds for connection to be established (sec.) Default is 45 sec.</span>
|
302 |
4aca19b3
|
Scott Ullrich
|
</td>
|
303 |
|
|
</tr>
|
304 |
|
|
<tr>
|
305 |
|
|
<td width="22%" valign="top" class="vncell">Description</td>
|
306 |
|
|
<td width="78%" class="vtable">
|
307 |
|
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
308 |
9ebe7028
|
gnhb
|
<br><span class="vexpl">You may enter a description here for your reference (not parsed).</span>
|
309 |
4aca19b3
|
Scott Ullrich
|
</td>
|
310 |
|
|
</tr>
|
311 |
|
|
<tr>
|
312 |
|
|
<td width="22%" valign="top"> </td>
|
313 |
|
|
<td width="78%">
|
314 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
315 |
|
|
<input type="button" value="Cancel" onclick="history.back()">
|
316 |
|
|
<?php if (isset($id) && $a_ppps[$id]): ?>
|
317 |
|
|
<input name="id" type="hidden" value="<?=$id;?>">
|
318 |
|
|
<?php endif; ?>
|
319 |
|
|
</td>
|
320 |
|
|
</tr>
|
321 |
|
|
</table>
|
322 |
860c4e80
|
Chris Buechler
|
</form>
|
323 |
|
|
<?php include("fend.inc"); ?>
|
324 |
|
|
</body>
|
325 |
|
|
</html>
|