diff options
-rw-r--r-- | etc/inc/interfaces.inc | 24 | ||||
-rw-r--r-- | usr/local/www/interfaces_ppps_edit.php | 21 |
2 files changed, 22 insertions, 23 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index be118a8..a77218c 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1143,7 +1143,14 @@ function handle_pppoe_reset($post_array) { function interface_ppps_configure($interface) { global $config, $g; - + + /* Return for unassigned interfaces. This is a minimum requirement. */ + if (empty($config['interfaces'][$interface])) + return 0; + $ifcfg = $config['interfaces'][$interface]; + if (!isset($ifcfg['enable'])) + return 0; + // mpd5 requires a /var/spool/lock directory for PPP modem links. if(!is_dir("/var/spool/lock")) { exec("/bin/mkdir -p /var/spool/lock"); @@ -1152,10 +1159,7 @@ function interface_ppps_configure($interface) { // mpd5 modem chat script expected in the same directory as the mpd_xxx.conf files if (!file_exists("{$g['varetc_path']}/mpd.script")) mwexec("/bin/ln -s /usr/local/sbin/mpd.script {$g['varetc_path']}/."); - - $ifcfg = $config['interfaces'][$interface]; - if (!isset($ifcfg['enable'])) - return 0; + if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { foreach ($config['ppps']['ppp'] as $pppid => $ppp) { if ($ifcfg['if'] == $ppp['if']) @@ -1172,7 +1176,7 @@ function interface_ppps_configure($interface) { else $type = $ppp['type']; $upper_type = strtoupper($ppp['type']); - + if($g['booting']) { $descr = isset($ifcfg['descr']) ? $ifcfg['descr'] : strtoupper($interface); echo "starting {$pppif} link..."; @@ -1180,7 +1184,7 @@ function interface_ppps_configure($interface) { if(file_exists("{$g['varrun_path']}/{$ppp['type']}_{$interface}.pid")) return 0; } - + $ports = explode(',',$ppp['ports']); if ($type != "modem") { foreach ($ports as $pid => $port) @@ -1189,10 +1193,10 @@ function interface_ppps_configure($interface) { $localips = explode(',',$ppp['localip']); $gateways = explode(',',$ppp['gateway']); $subnets = explode(',',$ppp['subnet']); - + /* We bring up the parent interface first because if DHCP is configured on the parent we need - to obtain an address first so we can write it in the mpd .conf file for PPTP and L2TP configs - */ + * to obtain an address first so we can write it in the mpd .conf file for PPTP and L2TP configs + */ foreach($ports as $pid => $port){ switch ($ppp['type']) { case "pppoe": diff --git a/usr/local/www/interfaces_ppps_edit.php b/usr/local/www/interfaces_ppps_edit.php index 140b998..1f3c748 100644 --- a/usr/local/www/interfaces_ppps_edit.php +++ b/usr/local/www/interfaces_ppps_edit.php @@ -54,8 +54,9 @@ if (!is_array($config['ppps']['ppp'])) $a_ppps = &$config['ppps']['ppp']; +$iflist = get_configured_interface_with_descr(); $portlist = get_interface_list(); -$portlist = array_merge($portlist, get_configured_interface_with_descr()); +$portlist = array_merge($portlist, $iflist); $id = $_GET['id']; if (isset($_POST['id'])) @@ -355,24 +356,18 @@ if ($_POST) { must be able to clear the config data in the <cron> section of config.xml if it exists */ handle_pppoe_reset($_POST); - - $iflist = get_configured_interface_list(); - foreach ($iflist as $if) { - if ($config['interfaces'][$if]['if'] == $ppp['if']){ - $thisif = $if; - break; - } - } + if (isset($id) && $a_ppps[$id]) $a_ppps[$id] = $ppp; else $a_ppps[] = $ppp; - + write_config(); configure_cron(); - - if (isset($thisif)){ - interface_ppps_configure($thisif); + + foreach ($iflist as $pppif => $ifdescr) { + if ($config['interfaces'][$if]['if'] == $ppp['if']) + interface_ppps_configure($pppif); } header("Location: interfaces_ppps.php"); exit; |