From c90f247117ace2af4e072e7004e1750875e568ff Mon Sep 17 00:00:00 2001 From: gnhb Date: Mon, 29 Mar 2010 20:03:55 +0700 Subject: Changes to make PPP work again. mpd5 fails to establish a ppp link without *some* username and password, so defaults are set if user enters nothing. Removed interface_ppp_configure call from interfaces_ppp_edit.php. It was useless there with the new structure, and it caused all PPP links to attempt to connect when user presses "Save" even before they are assigned to LAN/WAN, etc. Also, fix up pfsense-utils.inc and status_interfaces.php to display more info on status_interfaces.php. Changed util.inc to allow cua* interfaces to be recognized as real interfaces as pfSense got "interface mismatch" at boot and forced user to reassign. Maybe someone else has a better way to do this. --- etc/inc/interfaces.inc | 13 ++++++++----- etc/inc/pfsense-utils.inc | 31 +++++++++++++++++++------------ etc/inc/util.inc | 2 +- usr/local/www/interfaces_ppp_edit.php | 8 +++----- usr/local/www/status_interfaces.php | 6 +++--- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index f2ad8d4..65e3996 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -969,24 +969,27 @@ EOD; } $mpdconf .= << see if dhclient is up */ case "dhcp": @@ -1288,9 +1293,6 @@ function get_interface_info($ifdescr) { break; /* PPPoE interface? -> get status from virtual interface */ case "pppoe": - unset($linkinfo); - exec("/usr/bin/netstat -I " . $ifinfo['if'] . " -nWb -f link", $linkinfo); - $linkinfo = preg_split("/\s+/", $linkinfo[1]); if ("{$ifinfo['if']}*" == $linkinfo[0]) $ifinfo['pppoelink'] = "down"; else if ($ifinfo['if'] == $linkinfo[0] && !isset($link0)) @@ -1302,9 +1304,6 @@ function get_interface_info($ifdescr) { break; /* PPTP interface? -> get status from virtual interface */ case "pptp": - unset($linkinfo); - exec("/usr/bin/netstat -I " . $ifinfo['if'] . " -nWb -f link", $linkinfo); - $linkinfo = preg_split("/\s+/", $linkinfo[1]); if ("{$ifinfo['if']}*" == $linkinfo[0]) $ifinfo['pptplink'] = "down"; else if ($ifinfo['if'] == $linkinfo[0] && !isset($link0)) @@ -1315,20 +1314,28 @@ 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": + if ("{$ifinfo['if']}*" == $linkinfo[0]) + $ifinfo['ppplink'] = "down"; + else if ($ifinfo['if'] == $linkinfo[0]) + $ifinfo['ppplink'] = "up"; + else + $ifinfo['ppplink'] = "down" ; + if (empty($ifinfo['status'])) + $ifinfo['status'] = "down"; + $dev = $config['interfaces'][$if]['if']; if (empty($dev)) break; if (file_exists("/dev/{$dev}")) { - $ifinfo['ppplink'] = $ifinfo['if']; if (file_exists("{$g['varrun_path']}/ppp_{$if}.pid") && file_exists("{$g['varetc_path']}/mpd_{$if}.query")) { + $ifinfo['pppinfo'] = "{$ifinfo['if']}"; $pppid = substr($ifinfo['if'], 3); $sec = trim(`/usr/bin/nc 127.0.0.1 500{$pppid} < {$g['varetc_path']}/mpd_{$if}.query | grep 'Session time' | cut -f7 -d ' '`); - $ifinfo['ppp_uptime'] = convert_seconds_to_hms($sec); - } - $ifinfo['missing_device'] = 0; + $ifinfo['ppp_uptime'] = convert_seconds_to_hms($sec); + } } else { - $ifinfo['ppplink'] = $dev . " device not present! Is the modem attached to the system?"; - $ifinfo['missing_device'] = 1; + $ifinfo['nodevice'] = 1; + $ifinfo['pppinfo'] = $dev . " device not present! Is the modem attached to the system?"; } // 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); diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 584beb3..3c61b6c 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -1117,7 +1117,7 @@ function is_interface_mismatch() { $do_assign = false; $i = 0; foreach ($config['interfaces'] as $ifname => $ifcfg) { - if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) { + if (preg_match("/^enc|^cua|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) { $i++; } else if (does_interface_exist($ifcfg['if']) == false) { diff --git a/usr/local/www/interfaces_ppp_edit.php b/usr/local/www/interfaces_ppp_edit.php index 9657466..f3aae99 100644 --- a/usr/local/www/interfaces_ppp_edit.php +++ b/usr/local/www/interfaces_ppp_edit.php @@ -137,12 +137,10 @@ if ($_POST) { $ppp['descr'] = $_POST['descr']; - $iflist = get_configured_interface_list(); - foreach ($iflist as $if) { - if ($config['interfaces'][$if]['if'] == basename($a_ppps[$id]['port'])) { + $iflist = get_configured_interface_list(); + foreach ($iflist as $if) { + if ($config['interfaces'][$if]['if'] == basename($a_ppps[$id]['port'])) $config['interfaces'][$if]['if'] = basename($ppp['port']); - interface_ppp_configure($if); - } } if (isset($id) && $a_ppps[$id]) diff --git a/usr/local/www/status_interfaces.php b/usr/local/www/status_interfaces.php index 5ebde3d..eaa968b 100755 --- a/usr/local/www/status_interfaces.php +++ b/usr/local/www/status_interfaces.php @@ -138,12 +138,12 @@ include("head.inc"); PPP -    - + + - + -- cgit v1.1