Adding gui to choose media options for interfaces.

This commit is contained in:
Evgeny Yurchenko 2011-05-21 15:35:35 +00:00
parent abcdca835c
commit 509ca889c9

View File

@ -711,6 +711,15 @@ if ($_POST['apply']) {
} else {
$wancfg['mss'] = $_POST['mss'];
}
if (empty($_POST['mediaopt'])) {
unset($wancfg['media']);
unset($wancfg['mediaopt']);
} else {
$mediaopts = explode(' ', $_POST['mediaopt']);
if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
else { unset($wancfg['mediaopt']); }
}
if (isset($wancfg['wireless'])) {
handle_wireless_post();
}
@ -897,6 +906,21 @@ function check_wireless_mode() {
}
}
// Find all possible media options for the interface
$mediaopts_list = array();
$intrealname = $config['interfaces'][$if]['if'];
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
foreach ($mediaopts as $mediaopt){
preg_match("/media (.*)/", $mediaopt, $matches);
if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
}else{
// there is only media like "media 1000baseT"
array_push($mediaopts_list, $matches[1]);
}
}
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
$statusurl = "status_interfaces.php";
@ -1153,6 +1177,26 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp"
"header size) will be in effect."); ?>
</td>
</tr>
<?php
if (count($mediaopts_list) > 0){
$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
echo "<tr>";
echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
echo '<td class="vtable">';
echo '<select name="mediaopt" class="formselect" id="mediaopt">';
foreach($mediaopts_list as $mediaopt){
if ($mediaopt != rtrim($mediaopt_from_config)){
print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
} else {
print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
}
}
echo '</select><br>';
echo gettext("Here you can explicitely set up speed and duplex mode for the interface.");
echo '</td>';
echo '</tr>';
}
?>
<tr>
<td colspan="2" valign="top" height="16"></td>
</tr>