diff options
author | Ermal <eri@pfsense.org> | 2010-03-27 00:05:37 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2010-03-27 00:05:37 +0000 |
commit | 611ae8521469576569a8d9c0d306668fe1b20dfe (patch) | |
tree | f16b941d545194ba2db9a794dc66080cc5b4895f | |
parent | 3ad5fd63f0b5a7fa7b1f291b44ba37c0ccf88cd1 (diff) | |
download | pfsense-611ae8521469576569a8d9c0d306668fe1b20dfe.zip pfsense-611ae8521469576569a8d9c0d306668fe1b20dfe.tar.gz |
Redo most of the ppp interface handling to be consistent with the other mpd5 configurations. This way there is no more special handling for ppp around.
-rw-r--r-- | etc/inc/interfaces.inc | 324 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 38 | ||||
-rwxr-xr-x | usr/local/www/firewall_rules_edit.php | 10 | ||||
-rwxr-xr-x | usr/local/www/interfaces.php | 18 | ||||
-rwxr-xr-x | usr/local/www/interfaces_assign.php | 12 | ||||
-rw-r--r-- | usr/local/www/interfaces_ppp.php | 10 | ||||
-rw-r--r-- | usr/local/www/interfaces_ppp_edit.php | 14 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/interfaces.widget.php | 5 |
8 files changed, 164 insertions, 267 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 4d24665..35f728a 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -873,67 +873,46 @@ function interface_bring_down($interface = "wan", $destroy = false) { return; } -function interface_ppp_configure($ppp_int,$edit=false) { +function interface_ppp_configure($interface) { global $config, $g; - $serial_device = 0; - if ($ppp_int <> -1) - if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - foreach ($config['ppps']['ppp'] as $ppp) { - if ($ppp_int == "ppp".$ppp['pppid']) - $serial_device = $ppp['port']; - } + $wancfg =& $config['interfaces'][$interface]; + if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $ppp) { + if ($wancfg['if'] == basename($ppp['port'])) + break; } - + } + if (!$ppp || empty($ppp['port'])) + return; + + if ($ifname == "wan") + $pppid = "0"; + else + $pppid = substr($ifname, 3); + + $pppif = "ppp{$pppid}"; + // mpd5 requires a /var/spool/lock directory if(!is_dir("/var/spool/lock")) { exec("/bin/mkdir -p /var/spool/lock"); exec("/bin/chmod a+rw /var/spool/lock/."); } if (!file_exists("{$g['varetc_path']}/mpd.script")) - if($g['booting']) - mwexec("/bin/ln -s /usr/local/sbin/mpd.script {$g['varetc_path']}/."); + mwexec("/bin/ln -s /usr/local/sbin/mpd.script {$g['varetc_path']}/."); - if ($edit || $g['booting']){ - if($g['booting']) - echo " configuring PPP on {$ppp_int} interface...\n"; - /* generate mpd.conf */ - $fd = fopen("{$g['varetc_path']}/mpd-ppp.conf", "w"); - if (!$fd) { - printf("Error: cannot open mpd-ppp.conf in interface_ppp_configure().\n"); - return 1; - } - /* generate mpd.secret */ - $fds = fopen("{$g['varetc_path']}/mpd.secret", "w"); - if (!$fds) { - printf("Error: cannot open mpd.secret in interface_ppp_configure().\n"); - return 1; - } - - // Create mpd.secret file - - $secret = <<<EOD -################################################################# -# -# MPD secrets file -# Entries are for authentication in either or both directions, as well -# as telnet console login. Auto generated from /etc/inc/interfaces.inc -# {$g['varetc_path']}/mpd.secret -# -################################################################## -Mylogin "" + if($g['booting']) + echo " configuring PPP on {$pppif} interface...\n"; -EOD; - // Construct the mpd.conf file - $mpdconf = <<<EOD -################################################################# -# -# MPD Configuration file -# Auto generated by pfSense from /etc/inc/interfaces.inc -# {$g['varetc_path']}/mpd_ppp.conf -# -################################################################## + /* generate mpd.conf */ + $fd = fopen("{$g['varetc_path']}/mpd_{$interface}.conf", "w"); + if (!$fd) { + log_error("Error: cannot open mpd_{$interface}.conf in interface_ppp_configure().\n"); + return 1; + } + // Construct the mpd.conf file + $mpdconf = <<<EOD startup: # configure mpd users set user admin pfsense admin @@ -942,159 +921,137 @@ startup: set console self 127.0.0.1 5005 set console open # configure the web server + set web close #set web self 0.0.0.0 5006 #set web open -default: +EOD; + if (is_ipaddr($ppp['localip'])) + $localip = $ppp['localip']; + else + $localip = '0.0.0.0'; + if (is_ipaddr($ppp['gateway'])) + $localgw = $ppp['gateway']; + else + $localgw = "10.0.0.{$pppid}"; + + $mpdconf .= <<<EOD +default: +pppclient: + create bundle static {$interface} + set iface name {$pppif} + set iface up-script /usr/local/sbin/ppp-linkup + set iface down-script /usr/local/sbin/ppp-linkdown + set ipcp ranges {$localip}/0 {$localgw}/0 + EOD; - $ip = 1; - - if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - foreach ($config['ppps']['ppp'] as $ppp) { - //$dev = substr($ppp['port'], 5); //Device sans path - $id = $ppp['pppid']; - $ppp_port = "ppp{$id}"; - - $endingip = $ip+1; - if($ppp['localip'] && $ppp['gateway']) - $ranges = "set ipcp ranges {$ppp['localip']}/0 {$ppp['gateway']}/0"; - if(!$ppp['localip'] && $ppp['gateway']) - $ranges = "set ipcp ranges 10.0.0.{$ip}/0 {$ppp['gateway']}/0"; - if($ppp['localip'] and !$ppp['gateway']) - $ranges = "set ipcp ranges {$ppp['localip']}/0 10.0.0.{$endingip}/0"; - if(!$ppp['localip'] and !$ppp['gateway']) - $ranges = "set ipcp ranges 10.0.0.{$ip}/0 10.0.0.{$endingip}/0"; - $ip++; - if ($ppp['username'] <> ""){ - $user = "{$ppp['username']}"; - } else { - $user = "Mylogin"; - } - - $mpdconf .= <<<EOD -{$ppp_port}: - create bundle static B{$id} - {$ranges} + if (isset($config['system']['dnsallowoverride'])) { + $mpdconf .= <<<EOD set ipcp yes req-pri-dns set ipcp yes req-sec-dns - set iface name {$ppp_port} EOD; - if (isset($ppp['defaultgw'])){ - $mpdconf .= <<<EOD + } + + if (isset($ppp['defaultgw'])) { + $mpdconf .= <<<EOD set iface route default EOD; - } - $mpdconf .= <<<EOD - set iface up-script /usr/local/sbin/ppp-linkup - set iface down-script /usr/local/sbin/ppp-linkdown + } + + $mpdconf .= <<<EOD # Create link. - create link static lnk-{$ppp_port} modem + create link static lnk{$interface} modem +# We expect to be authenticated by peer using any protocol. + set link disable chap pap + set link accept chap pap eap + set link enable no-orig-auth +# To make Ringback work we should specify how to handle incoming calls originated by it. + #set link enable incoming + set link action bundle {$interface} + +EOD; + + if (!empty($ppp['username'])) { + $mpdconf .= <<<EOD +# Configure the account name. Password will be taken from mpd.secret. + set auth authname "{$ppp['username']}" + set auth password "{$ppp['password']}" + +EOD; + } + + $mpdconf .= <<<EOD set modem device {$ppp['port']} + set modem script DialPeer + set modem idle-script Ringback + set modem watch -cd set modem var \$DialPrefix "DT" set modem var \$Telephone "{$ppp['phone']}" EOD; - if (isset($ppp['connect-timeout'])){ - $mpdconf .= <<<EOD + if (isset($ppp['connect-timeout'])) { + $mpdconf .= <<<EOD set modem var \$ConnectTimeout "{$ppp['connect-timeout']}" EOD; - } - if (isset($ppp['initstr'])){ - $initstr = base64_decode($ppp['initstr']); - $mpdconf .= <<<EOD + } + if (isset($ppp['initstr'])) { + $initstr = base64_decode($ppp['initstr']); + $mpdconf .= <<<EOD set modem var \$InitString "{$initstr}" EOD; - } - if (isset($ppp['simpin'])){ - $mpdconf .= <<<EOD + } + if (isset($ppp['simpin'])) { + $mpdconf .= <<<EOD set modem var \$SimPin "{$ppp['simpin']}" set modem var \$PinWait "{$ppp['pin-wait']}" EOD; - } - if (isset($ppp['apn'])){ - $mpdconf .= <<<EOD + } + if (isset($ppp['apn'])) { + $mpdconf .= <<<EOD set modem var \$APN "{$ppp['apn']}" set modem var \$APNum "{$ppp['apnum']}" EOD; - } - $mpdconf .= <<<EOD - set modem script DialPeer - set modem idle-script Ringback - set modem watch -cd -# We expect to be authenticated by peer using any protocol. - set link disable chap pap - set link accept chap pap eap - set link enable no-orig-auth -# Configure the account name. Password will be taken from mpd.secret. - set auth authname {$user} -# To make Ringback work we should specify how to handle incoming calls originated by it. - #set link enable incoming - set link action bundle B{$id} - open + } -EOD; + $mpdconf .= "\topen"; - $fdlnkq = fopen("{$g['varetc_path']}/{$ppp_port}.query", "w"); - if (!$fdlnkq) { - printf("Error: cannot open {$ppp_port}.query in interface_ppp_configure().\n"); - return 1; - } - $linkquery = <<<EOD + // Write out configuration for mpd_ppp.conf and mpd.secret + fwrite($fd, $mpdconf); + fclose($fd); + + $fdlnkq = fopen("{$g['varetc_path']}/mpd_{$interface}.query", "w"); + if (!$fdlnkq) { + /* NOTE: It is not fatal if we cannot write the query."); + log_error("Error: cannot open mpd_{$interface}.query in interface_ppp_configure().\n"); + } else { + $linkquery = <<<EOD admin pfsense -link lnk-{$ppp_port} +link lnk{$interface} show iface exit EOD; - // Write out linkquery file for each configured PPP interface. - fwrite($fdlnkq, $linkquery); - fclose($fdlnkq); - - - if ($ppp['username'] <> ""){ - $secret .= <<<EOD -{$ppp['username']} "{$ppp['password']}" - -EOD; - - } - } - } - - // Write out configuration for mpd_ppp.conf and mpd.secret - fwrite($fd, $mpdconf); - fclose($fd); - fwrite($fds, $secret); - fclose($fds); - sleep(2); + // Write out linkquery file for each configured PPP interface. + fwrite($fdlnkq, $linkquery); + fclose($fdlnkq); } + // Launch specified ppp instance - if( (!$edit || $g['booting']) && file_exists("{$serial_device}")){ - $timeout = 15; - /* if mpd is active, lets take it down -> accomplished by starting mpd with the -k flag*/ + if( (file_exists("{$ppp['port']}")) { /* fire up mpd */ - if (file_exists("{$g['tmp_path']}/{$ppp_int}_router")) - mwexec("/bin/rm -r {$g['tmp_path']}/{$ppp_int}_router"); - mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd-ppp.conf -p {$g['varrun_path']}/{$ppp_int}.pid -s ppp {$ppp_int}"); - /* Wait for mpd5 to bring up connection, but don't wait longer than $timeout */ - for ($i=0; $i < $timeout; $i++){ - sleep(1); - if (file_exists("{$g['tmp_path']}/{$ppp_int}_router")) - break; - } - - - } + mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/ppp_{$interface}.pid -s {$interface} pppclient"); + } else + log_error("Device {$ppp['port']} has disappeared."); } function interfaces_carp_setup() { @@ -2002,20 +1959,14 @@ function interface_configure($interface = "wan", $reloadall = false) { interface_pptp_configure($interface); break; case 'ppp': - interface_ppp_configure($realif); + interface_ppp_configure($interface); break; default: if ($wancfg['ipaddr'] <> "" && $wancfg['subnet'] <> "") { - if (isset($wancfg['ispointtopoint']) && $wancfg['pointtopoint']) { - mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " " . - escapeshellarg($wancfg['ipaddr'] . "/" . $wancfg['subnet']) . - " " . escapeshellarg($wancfg['pointtopoint']) . " up"); - } else { - if($wancfg['ipaddr'] && $wancfg['subnet']) - mwexec("/sbin/ifconfig " . escapeshellarg($realif) . - " " . escapeshellarg($wancfg['ipaddr'] . "/" . - $wancfg['subnet'])); - } + if($wancfg['ipaddr'] && $wancfg['subnet']) + mwexec("/sbin/ifconfig " . escapeshellarg($realif) . + " " . escapeshellarg($wancfg['ipaddr'] . "/" . + $wancfg['subnet'])); } if (is_ipaddr($wancfg['gateway'])) @@ -2288,12 +2239,6 @@ EOD; if(file_exists("{$g['varrun_path']}/pppoe_{$interface}.pid") and $g['booting']) { /* if we are booting and mpd has already been started then don't start again. */ } else { - /* if mpd is active, lets take it down */ - if(file_exists("{$g['varrun_path']}/pppoe_{$interface}.pid")) { - killbypid("{$g['varrun_path']}/pppoe_{$interface}.pid"); - sleep(3); - } - /* Bring the parent interface up */ if($wancfg['if']) interfaces_bring_up($wancfg['if']); @@ -2301,7 +2246,7 @@ EOD; log_error("Could not bring wancfg['if'] up in interface_pppoe_configure()"); /* fire up mpd */ - mwexec("/usr/local/sbin/mpd5 -b -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/pppoe_{$interface}.pid pppoeclient"); + mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/pppoe_{$interface}.pid -s {$interface} pppoeclient"); } /* sleep until wan is up - or 30 seconds, whichever comes first */ @@ -2435,7 +2380,7 @@ EOD; else log_error("Could not bring interface wancfg['if'] up in interface_pptp_configure()"); /* fire up mpd */ - mwexec("/usr/local/sbin/mpd5 -b -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/pptp_{$interface}.pid pptp"); + mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/pptp_{$interface}.pid -s {$interface} pptp"); return 0; } @@ -2710,7 +2655,10 @@ function get_real_interface($interface = "wan") { $wanif = "pptp" . substr($if, 3); break; case "ppp": - $wanif = $cfg['if']; + if ($if == "wan") + $wanif = "ppp0"; + else + $wanif = "ppp" . substr($if, 3); break; default: $wanif = $cfg['if']; @@ -3021,10 +2969,8 @@ function get_interfaces_with_gateway() { $ints[] = $ifdescr; break; default: - if ($ifname['pointtopoint']) - $ints[] = $ifdescr; - else if (!empty($ifname['gateway'])) - $ints[] = $ifdescr; + if (!empty($ifname['gateway'])) + $ints[] = $ifdescr; break; } } @@ -3072,22 +3018,6 @@ function is_altq_capable($int) { return false; } -/****f* interfaces/is_interface_ppp - * NAME - * is_interface_ppp - Returns if an interface is ppp - * RESULT - * $tmp - Returns if an interface is ppp - ******/ -function is_interface_ppp($interface) { - global $config, $g; - - $friendly = convert_real_interface_to_friendly_interface_name($interface); - if(isset($config['interfaces'][$friendly]['serialport'])) - return true; - - return false; -} - /****f* interfaces/is_interface_wireless * NAME * is_interface_wireless - Returns if an interface is wireless diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 6333762..e8dad4d 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1207,10 +1207,8 @@ function get_interface_info($ifdescr) { $found = false; foreach ($iflist as $if => $ifname) { - if ($ifdescr == $if || $ifdescr == $ifname) { + if ($ifdescr == $if || $ifdescr == $ifname) { $ifinfo['hwif'] = $config['interfaces'][$if]['if']; - if($config['interfaces'][$if]['serialport']) - $ifinfo['hwif'] = get_real_interface($if); $ifinfo['if'] = get_real_interface($if); $found = true; break; @@ -1317,24 +1315,22 @@ function get_interface_info($ifdescr) { break; /* PPP interface? -> get uptime for this session and cumulative uptime from the persistant log file in conf */ case "ppp": - $ppp_int = $config['interfaces'][$if]['if']; - $dev = $config['interfaces'][$if]['serialport']; - if ($dev == "") - break; - if (file_exists("/dev/{$dev}")){ - $ifinfo['ppplink'] = $dev; - if (file_exists("{$g['varrun_path']}/{$ppp_int}.pid") && file_exists("{$g['varetc_path']}/{$ppp_int}.query")){ - $sec = trim(`/usr/bin/nc localhost 5005 < {$g['varetc_path']}/{$ppp_int}.query | grep 'Session time' | cut -f7 -d ' '`); + $dev = $config['interfaces'][$if]['if']; + if (empty($dev)) + break; + if (file_exists("/dev/{$dev}")) { + $ifinfo['ppplink'] = $dev; + if (file_exists("{$g['varrun_path']}/mpd_{$if}.pid") && file_exists("{$g['varetc_path']}/mpd_{$if}.query")) { + $sec = trim(`/usr/bin/nc localhost 5005 < {$g['varetc_path']}/mpd_{$if}.query | grep 'Session time' | cut -f7 -d ' '`); $ifinfo['ppp_uptime'] = convert_seconds_to_hms($sec); - } - $ifinfo['missing_device'] = 0; - } - else{ - $ifinfo['ppplink'] = $dev . " device not present! Is the modem attached to the system?"; - $ifinfo['missing_device'] = 1; - } - // Calculate cumulative uptime for PPP link. Useful for connections that have per minute/hour contracts so you don't go over! - $ifinfo['ppp_uptime_accumulated'] = get_ppp_uptime($dev); + } + $ifinfo['missing_device'] = 0; + } else { + $ifinfo['ppplink'] = $dev . " device not present! Is the modem attached to the system?"; + $ifinfo['missing_device'] = 1; + } + // Calculate cumulative uptime for PPP link. Useful for connections that have per minute/hour contracts so you don't go over! + $ifinfo['ppp_uptime_accumulated'] = get_ppp_uptime($dev); break; default: @@ -1808,4 +1804,4 @@ function process_alias_tgz($temp_filename) { fclose($fd); } -?>
\ No newline at end of file +?> diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php index 9be39b2..8493914 100755 --- a/usr/local/www/firewall_rules_edit.php +++ b/usr/local/www/firewall_rules_edit.php @@ -1116,7 +1116,7 @@ include("head.inc"); // add dynamic gateways to list $iflist = get_configured_interface_with_descr(); foreach ($iflist as $ifent => $ifdesc) { - if (in_array($config['interfaces'][$ifent]['ipaddr'], array("dhcp", "pppoe", "pptp"))) { + if (in_array($config['interfaces'][$ifent]['ipaddr'], array("dhcp", "pppoe", "pptp", "ppp"))) { if ($pconfig['gateway'] == $ifent) { $selected = " SELECTED"; } else { @@ -1124,14 +1124,6 @@ include("head.inc"); } if($ifdesc <> "") echo "<option value=\"{$ifent}\" {$selected}>".strtoupper($ifent)." - {$ifdesc}</option>\n"; - } else if ($config['interfaces'][$ifent]['serialport'] <> "") { - if ($pconfig['gateway'] == $ifent) { - $selected = " SELECTED"; - } else { - $selected = ""; - } - if($ifdesc <> "") - echo "<option value=\"{$ifent}\" {$selected}>".strtoupper($ifent)." - {$ifdesc}</option>\n"; } } /* add gateway groups to the list */ diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 28af188..11fab26 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -188,13 +188,15 @@ switch($wancfg['ipaddr']) { case "pptp": $pconfig['type'] = "pptp"; break; + case "ppp": + $pconfig['type'] = "none"; + break; default: if(is_ipaddr($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"; } @@ -398,8 +400,6 @@ if ($_POST) { $input_errors[] = "A valid gateway must be specified."; } } - if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) - $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'])) @@ -476,7 +476,6 @@ if ($_POST) { unset($wancfg['ipaddr']); unset($wancfg['subnet']); unset($wancfg['gateway']); - unset($wancfg['pointtopoint']); unset($wancfg['dhcphostname']); unset($wancfg['pppoe_username']); unset($wancfg['pppoe_password']); @@ -529,9 +528,6 @@ if ($_POST) { if ($_POST['gateway'] != "none") { $wancfg['gateway'] = $_POST['gateway']; } - if (isset($wancfg['ispointtopoint'])) { - $wancfg['pointtopoint'] = $_POST['pointtopoint']; - } break; case "dhcp": $wancfg['ipaddr'] = "dhcp"; @@ -1020,14 +1016,6 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" </select> </td> </tr> - <?php if (isset($wancfg['ispointtopoint'])): ?> - <tr> - <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> - </tr> - <?php endif; ?> <tr> <td width="22%" valign="top" class="vncellreq">Gateway</td> <td width="78%" class="vtable"> diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index 71b4a70..6d485a4 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -127,11 +127,11 @@ 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 $ppp) { - $portname = "ppp{$ppp['pppid']}"; - log_error("portname = " . $portname); + foreach ($config['ppps']['ppp'] as $pppid => $ppp) { + $portname = "ppp{$pppid}"; $portlist[$portname] = $ppp; $portlist[$portname]['isppp'] = true; + $portlist[$portname]['descr'] = "PPP {$ppp['port']}"; } } @@ -202,12 +202,8 @@ if ($_POST['apply']) { } $config['interfaces'][$ifname]['if'] = $ifport; if (preg_match('/^ppp[0-9]+/',$ifport)){ - $config['interfaces'][$ifname]['serialport'] = basename($portlist[$ifport]['port']); - $config['interfaces'][$ifname]['pointtopoint'] = true; + $config['interfaces'][$ifname]['if'] = basename($portlist[$ifport]['port']); $config['interfaces'][$ifname]['ipaddr'] = "ppp"; - } else { - unset($config['interfaces'][$ifname]['pointtopoint']); - unset($config['interfaces'][$ifname]['serialport']); } /* check for wireless interfaces, set or clear ['wireless'] */ diff --git a/usr/local/www/interfaces_ppp.php b/usr/local/www/interfaces_ppp.php index 3b5d339..41d36f9 100644 --- a/usr/local/www/interfaces_ppp.php +++ b/usr/local/www/interfaces_ppp.php @@ -51,10 +51,10 @@ if (!is_array($config['ppps']['ppp'])) $a_ppps = &$config['ppps']['ppp'] ; function ppp_inuse($num) { - global $config, $g; + global $config, $g, $a_ppps; $iflist = get_configured_interface_list(false, true); foreach ($iflist as $if) { - if ($config['interfaces'][$if]['if'] == "ppp{$num}") + if ($config['interfaces'][$if]['if'] == $a_ppps[$num]['port']) return true; } return false; @@ -67,7 +67,6 @@ if ($_GET['act'] == "del") { } else { unset($a_ppps[$_GET['id']]); write_config(); - interface_ppp_configure(-1); header("Location: interfaces_ppp.php"); exit; } @@ -103,15 +102,12 @@ include("head.inc"); <div id="mainarea"> <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> - <td width="10%" class="listhdrr">PPP Port</td> <td width="20%" class="listhdrr">Serial Port</td> <td width="40%" class="listhdr">Description</td> <td width="10%" class="list"></td> </tr> <?php $i = 0; foreach ($a_ppps as $id => $ppp): ?> <tr ondblclick="document.location='interfaces_ppp_edit.php?id=<?=$i;?>'"> - <td class="listr">ppp<?=htmlspecialchars($ppp['pppid']);?> - </td> <td class="listr"> <?=htmlspecialchars($ppp['port']);?> </td> @@ -123,7 +119,7 @@ include("head.inc"); </tr> <?php $i++; endforeach; ?> <tr> - <td class="list" colspan="3"> </td> + <td class="list" colspan="2"> </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> diff --git a/usr/local/www/interfaces_ppp_edit.php b/usr/local/www/interfaces_ppp_edit.php index 56146dd..47ed2ea 100644 --- a/usr/local/www/interfaces_ppp_edit.php +++ b/usr/local/www/interfaces_ppp_edit.php @@ -95,11 +95,7 @@ if ($_POST) { if (!$input_errors) { $ppp = array(); - if (isset($id)) - $ppp['pppid'] = $id; - else - $ppp['pppid'] = count($a_ppps); - + $ppp['port'] = $_POST['port']; if ($_POST['initstr'] <> "") $ppp['initstr'] = base64_encode($_POST['initstr']); @@ -148,7 +144,11 @@ if ($_POST) { write_config(); - interface_ppp_configure(-1,true); + $iflist = get_configured_interface_list(); + foreach ($iflist as $if) { + if ($config['interfaces'][$if]['if'] == $a_ppps[$num]['port']) + interface_ppp_configure($if); + } header("Location: interfaces_ppp.php"); exit; @@ -230,7 +230,7 @@ include("head.inc"); <tr> <td width="22%" valign="top" class="vncell">Init String</td> <td width="78%" class="vtable"> - <textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea> + <input type="text" size="40" class="formfld unknown" id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea> <br><span class="vexpl">Note: Enter the modem initialization string here. Do NOT include the "AT" string at the beginning of the command.</span> </td> </tr> diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php index 58a2c1c..d74f690 100644 --- a/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/usr/local/www/widgets/widgets/interfaces.widget.php @@ -44,13 +44,12 @@ require_once("/usr/local/www/widgets/include/interfaces.inc"); foreach ($ifdescrs as $ifdescr => $ifname) { $ifinfo = get_interface_info($ifdescr); $iswireless = is_interface_wireless($ifdescr); - $isserial = is_interface_ppp($ifdescr); ?> <tr> <td class="vncellt" width="40%"> <?php - if($isserial) { - echo "<img src='./themes/{$g['theme']}/images/icons/icon_3g.gif' />"; + if($ifinfo['ppplink']) { + echo "<img src='./themes/{$g['theme']}/images/icons/icon_3g.gif' />"; } else if($iswireless) { if($ifinfo['status'] == "associated") { ?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_wlan.gif" /> |