From 91a5b98a48643e0bb3fdbeffdb017da61e01c495 Mon Sep 17 00:00:00 2001 From: gnhb Date: Wed, 28 Apr 2010 22:12:30 +0700 Subject: [PATCH] Implement PPP config numbering scheme. Deleting a PPPx config doesn't renumber the other config sections, but saving a new or existing config renumbers all config sections. Update interfaces_assign to work properly with new scheme. --- usr/local/www/interfaces_assign.php | 82 +-- usr/local/www/interfaces_mlppp.php | 2 +- usr/local/www/interfaces_mlppp_edit.php | 732 ++++++++++++------------ 3 files changed, 418 insertions(+), 398 deletions(-) diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index 6d4dfe1508..0d3c1183a6 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -128,10 +128,10 @@ if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry /* add PPP interfaces */ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - $portname = basename($ppp['port']); + $portname = $ppp['type'].$ppp['pppid']; $portlist[$portname] = $ppp; $portlist[$portname]['isppp'] = true; - $portlist[$portname]['descr'] = "PPP " . basename($ppp['port']); + $portlist[$portname]['descr'] = strtoupper($ppp['type']) . $ppp['pppid']." - ".$ppp['descr']; } } @@ -403,45 +403,45 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) diff --git a/usr/local/www/interfaces_mlppp.php b/usr/local/www/interfaces_mlppp.php index 2e75201ae2..1fd9cbff08 100644 --- a/usr/local/www/interfaces_mlppp.php +++ b/usr/local/www/interfaces_mlppp.php @@ -108,7 +108,7 @@ include("head.inc"); $ppp): ?> - + - diff --git a/usr/local/www/interfaces_mlppp_edit.php b/usr/local/www/interfaces_mlppp_edit.php index 22266d88a1..576fd3f461 100644 --- a/usr/local/www/interfaces_mlppp_edit.php +++ b/usr/local/www/interfaces_mlppp_edit.php @@ -92,7 +92,7 @@ if (isset($id) && $a_ppps[$id]) { $pconfig['type'] = $a_ppps[$id]['type']; $pconfig['interfaces'] = $a_ppps[$id]['ports']; $pconfig['username'] = $a_ppps[$id]['username']; - $pconfig['password'] = $a_ppps[$id]['password']; + $pconfig['password'] = base64_decode($a_ppps[$id]['password']); if (isset($a_ppps[$id]['defaultgw'])) $pconfig['defaultgw'] = true; if (isset($a_ppps[$id]['ondemand'])) @@ -262,10 +262,21 @@ if ($_POST) { if (!$input_errors) { $ppp = array(); + + + $j=0; + foreach ($a_ppps as $p){ + $a_ppps[$j]['pppid'] = $j; + $j++; + } + if (isset($id)) + $ppp['pppid'] = $id; + else + $ppp['pppid'] = $j; $ppp['type'] = $_POST['type']; $ppp['ports'] = implode(',', $_POST['interfaces']); $ppp['username'] = $_POST['username']; - $ppp['password'] = $_POST['password']; + $ppp['password'] = base64_encode($_POST['password']); $ppp['defaultgw'] = $_POST['defaultgw'] ? true : false; $ppp['ondemand'] = $_POST['ondemand'] ? true : false; if (!empty($_POST['idletimeout'])) @@ -480,7 +491,8 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" for(var j=0; j < option_array.length-1; j++){ var option = option_array[j].split(","); var selected = Boolean(parseInt(option[2])); - select_list.options[j] = new Option(" "+option[0]+" ", option[1], false, selected); + select_list.options[j] = new Option(option[0], option[1], false, selected); + //this line for debugging the javascript above //select_list.options[option_array.length-1+j] = new Option(option[2].toString() +" "+ selected.toString()); } } @@ -496,7 +508,7 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" var select_list = document.iform["interfaces[]"]; switch(t) { case "select": { - $('ppp','pppoe','pptp','ipfields').invoke('hide'); + $('ppp','pppoe','pptp','ipfields','prefil_ppp').invoke('hide'); select_list.options.length = 0; select_list.options[0] = new Option("Select Link Type First",""); break; @@ -504,18 +516,18 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" case "ppp": { update_select_list(serialports, select_list); $('select','pppoe','pptp','subnet').invoke('hide'); - $('ipfields').show(); + $('ipfields','prefil_ppp').invoke('show'); break; } case "pppoe": { update_select_list(ports, select_list); - $('select','ppp','pptp','ipfields').invoke('hide'); + $('select','ppp','pptp','ipfields','prefil_ppp').invoke('hide'); break; } case "pptp": { update_select_list(ports, select_list); - $('select','ppp','pppoe').invoke('hide'); + $('select','ppp','pppoe','prefil_ppp').invoke('hide'); $('ipfields','subnet').invoke('show'); break; } @@ -563,360 +575,368 @@ $types = array("select" => "Select", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" -
- - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MLPPP configuration
Link Type - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MLPPP configuration
Link Type + +
Link interface(s) + +
Interfaces or ports participating in the multilink connection. + +

Click a link to fill in defaults for these carriers:  + ATT + Sprint + Verizon + +

Username + +
Password + +
Gateway + >This link will be used as the default gateway. +
Dial On Demand + > Enable Dial-on-Demand mode +
This option causes the interface to operate in dial-on-demand mode, allowing you to have a virtual full time connection. + The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected. +
Idle Timeout + seconds +
Sets the idle timeout value for the bundle. If no incoming or outgoing packets are transmitted for the set number of seconds + the connection is brought down. An idle timeout of zero disables this feature. Default is 0. +
When the idle timeout occurs, if the dial-on-demand option is enabled, mpd goes back into dial-on-demand mode. Otherwise, the interface is brought down and all associated routes removed.
+
Uptime Logging + > Enable persistent logging of connection uptime. +
This option causes cumulative uptime to be recorded and displayed on the Status Interfaces page. +
Description + +
You may enter a description here for your reference (not parsed). +
+
Advanced Options
Bandwidth + onclick="show_more_settings(this,bandwidth_input);" /> + Set bandwidths for links in multilink connections. + +
Link MTU + +
Set MTU for each link if links have different bandwidths, otherwise, leave blank. +
Link MRU + +
Set MRU for each link separated by commas, otherwise, leave blank. +
Compression + > Enable vjcomp(compression). +
This option enables Van Jacobson TCP header compression, which saves several bytes per TCP data packet. + You almost always want this option. This compression ineffective for TCP connections with enabled modern extensions like time + stamping or SACK, which modify TCP options between sequential packets. +
TCPmssFix + > Enable tcpmssfix. +
This option causes mpd to adjust incoming and outgoing TCP SYN segments so that the requested maximum segment size is not greater than the amount + allowed by the interface MTU. This is necessary in many setups to avoid problems caused by routers that drop ICMP Datagram Too Big messages. Without these messages, + the originating machine sends data, it passes the rogue router then hits a machine that has an MTU that is not big enough for the data. Because the IP Don't Fragment option is set, + this machine sends an ICMP Datagram Too Big message back to the originator and drops the packet. The rogue router drops the ICMP message and the originator never + gets to discover that it must reduce the fragment size or drop the IP Don't Fragment option from its outgoing data. +
ShortSeq + > Enable shortseq. +
This option is only meaningful if multi-link PPP is negotiated. It proscribes shorter multi-link fragment headers, saving two bytes on every frame. +
ACFComp + > Enable acfcomp. +
Address and control field compression. This option only applies to asynchronous link types. It saves two bytes per frame. +
ProtoComp + > Enable protocomp(compression). +
Protocol field compression. This option saves one byte per frame for most frames. +
  + + + + + +