diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-08-12 21:42:02 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-08-12 21:42:02 +0000 |
commit | 8c3e8725c163657625ba90fefc6ec13490ead13c (patch) | |
tree | d1350e1b2cafa0abfd5cfe4dd403196eb053b3fe | |
parent | 76b3f381b3b97ae1fc75a0bacee70b548273f53b (diff) | |
download | pfsense-8c3e8725c163657625ba90fefc6ec13490ead13c.zip pfsense-8c3e8725c163657625ba90fefc6ec13490ead13c.tar.gz |
Fixup Renew/Release
-rw-r--r-- | etc/inc/interfaces.inc | 48 | ||||
-rwxr-xr-x | usr/local/www/status_interfaces.php | 18 |
2 files changed, 58 insertions, 8 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index da1f4f0..bde5689 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -646,6 +646,49 @@ EOD; return 0; } +function interfaces_dhcp_configure($interface) { + global $config, $g; + + $optcfg = $config['interfaces'][$interface]; + + /* generate dhclient_$interface.conf */ + $fd = fopen("{$g['varetc_path']}/dhclient_{$interface}.conf", "w"); + if (!$fd) { + printf("Error: cannot open dhclient_{$interface}.conf in interfaces_dhcp_configure({$$interface}) for writing.\n"); + return 1; + } + + $dhclientconf = ""; + + if ($optcfg['dhcphostname']) { + $dhclientconf .= <<<EOD +interface "{$optcfg['if']}" { + send dhcp-client-identifier "{$optcfg['dhcphostname']}"; + send host-name "{$optcfg['dhcphostname']}"; + script "/sbin/dhclient-script"; +} + +EOD; + } + + fwrite($fd, $dhclientconf); + fclose($fd); + + $optif = $optcfg['if']; + + /* bring wan interface up before starting dhclient */ + mwexec("/sbin/ifconfig {$optif} up"); + + /* fire up dhclient */ + mwexec("/sbin/dhclient -b -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif} >/tmp/{$optif}_output >/tmp/{$optif}_error_output"); + + $fout = fopen("/tmp/ifconfig_{$optif}","w"); + fwrite($fout, "/sbin/dhclient -b -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif}"); + fclose($fout); + + return 0; +} + function interfaces_wan_dhcp_configure() { global $config, $g; @@ -708,6 +751,11 @@ function interfaces_dhcp_down($interface) { sleep(1); } +function interfaces_dhcp_up($interface) { + interfaces_dhcp_configure($interface); + sleep(1); +} + function interfaces_wan_dhcp_up() { interfaces_wan_dhcp_configure(); sleep(1); diff --git a/usr/local/www/status_interfaces.php b/usr/local/www/status_interfaces.php index 663420c..6126e93 100755 --- a/usr/local/www/status_interfaces.php +++ b/usr/local/www/status_interfaces.php @@ -2,8 +2,11 @@ <?php /* status_interfaces.php - part of m0n0wall (http://m0n0.ch/wall) + part of pfSense + Copyright (C) 2005 Scott Ullrich <sullrich@gmail.com>. + All rights reserved. + originally part of m0n0wall (http://m0n0.ch/wall) Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>. All rights reserved. @@ -36,14 +39,14 @@ $wancfg = &$config['interfaces']['wan']; if ($_POST) { if ($_POST['submit'] == "Disconnect" || $_POST['submit'] == "Release") { if ($wancfg['ipaddr'] == "dhcp") - interfaces_wan_dhcp_down(); + interfaces_dhcp_down($_POST['interface']); else if ($wancfg['ipaddr'] == "pppoe") interfaces_wan_pppoe_down(); else if ($wancfg['ipaddr'] == "pptp") interfaces_wan_pptp_down(); } else if ($_POST['submit'] == "Connect" || $_POST['submit'] == "Renew") { if ($wancfg['ipaddr'] == "dhcp") - interfaces_wan_dhcp_up(); + interfaces_dhcp_up($_POST['interface']); else if ($wancfg['ipaddr'] == "pppoe") interfaces_wan_pppoe_up(); else if ($wancfg['ipaddr'] == "pptp") @@ -104,7 +107,7 @@ function get_interface_info($ifdescr) { /* loop through optional interfaces looking to see if they are dhcp */ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; - if (($ifdescr == "opt$j") && ($config['interfaces']['opt' . $j]['ipaddr'] == "dhcp")) { + if (($ifdescr == "opt{$j}") && ($config['interfaces']['opt' . $j]['ipaddr'] == "dhcp")) { /* see if dhclient is up */ if (is_process_running("dhclient") == true) $ifinfo['dhcplink'] = "up"; @@ -227,11 +230,9 @@ include("head.inc"); <p class="pgtitle"><?=$pgtitle?></p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; } - foreach ($ifdescrs as $ifdescr => $ifname): $ifinfo = get_interface_info($ifdescr); $realint = filter_translate_type_to_real_interface($ifname); @@ -345,7 +346,7 @@ include("head.inc"); <td width="22%" class="vncellt">In/out packets</td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (" . - format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");?> + format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");?> </td> </tr><?php if (isset($ifinfo['inerrs'])): ?> <tr> @@ -370,7 +371,8 @@ include("head.inc"); </strong>Using dial-on-demand will bring the connection up again if any packet triggers it. To substantiate this point: disconnecting manually will <strong>not</strong> prevent dial-on-demand from making connections -to the outside! Don't use dial-on-demand if you want to make sure that the line is kept disconnected. +to the outside! Don't use dial-on-demand if you want to make sure that the line +is kept disconnected. <meta http-equiv="refresh" content="120;url=<?php print $_SERVER['PHP_SELF']; ?>"> |