Commit 7ddad1e7 authored by José Luis  Gutiérrez's avatar José Luis Gutiérrez Committed by Alessandro Rubini

/var/www Local Management Tool New Advance Menu (Tx/Rx calibration)

Adding new features to the Local Management Tool
- SFP calibration
- Endpoint Tx/Rx Calibration
- Terminal improved
- New advance menu

Fixes: Reboot after new configurations.
parent 97a6ca53
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<div class="main">
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
</div>
<div class="content">
<div class="leftpanel">
<h2>Main Menu</h2>
<?php include 'menu.php' ?>
</div>
<div class="rightpanel">
<div class="rightbody">
<h1 class="title">Switch Administration <a href='help.php?help_id=dashboard' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<FORM align="center" method="post">
<b>Download configuration files to PC: </b><INPUT type="submit" value="Download" class="btn">
<input type="hidden" name="download" value="hal">
</FORM>
<br>
<FORM align="center" action="endpointmode.php" method="post">
<b>Upload configuration files to PC: </b><INPUT type="submit" value="Upload" class="btn">
<input type="hidden" name="upload" value="hal">
</FORM>
<?php
if (!empty($_POST["download"])){
$filename = "configuration.tar";
$filepath = "/tmp/";
// http headers for zip downloads
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filepath.$filename));
ob_end_flush();
@readfile($filepath.$filename);
}
if (!empty($_POST["upload"])){
}
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<div class="main">
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
</div>
<div class="content">
<div class="leftpanel">
<h2>Main Menu</h2>
<?php include 'menu.php' ?>
</div>
<div class="rightpanel">
<div class="rightbody">
<h1 class="title">Switch Management <a href='help.php?help_id=management' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php
$_SESSION['advance']="yes";
header('Location: index.php');
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
......@@ -18,6 +18,7 @@
<div class="rightbody">
<h1 class="title">Contact</h1>
<?php $_SESSION['advance']=""; ?>
<p><strong>White-Rabbit switch Firmware v<?php $str = shell_exec("uname -v"); echo $str; ?> </strong></p><p>&nbsp;</p>
<p><strong>Open Hardware Repository <a href="http://www.ohwr.org/projects/white-rabbit/wiki">http://www.ohwr.org/projects/white-rabbit/wiki</a> </strong></p></strong></p><p>&nbsp;</p>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<div class="main">
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
</div>
<div class="content">
<div class="leftpanel">
<h2>Main Menu</h2>
<?php include 'menu.php' ?>
</div>
<div class="rightpanel">
<div class="rightbody">
<h1 class="title">Endpoint Calibration<a href='http://www.ohwr.org/projects/white-rabbit/wiki/Calibration' target='_blank'><img align=right src="./img/question.png"></a></h1>
<br>
<?php session_is_started() ?>
<div>
<?php
$file_init = 'global = {'."\n";
$file_init .= "\t".'sfp_database_path = "/wr/etc/sfp_database.conf";'."\n";
$file_init .= '};'."\n\n";
$file_init .= 'timing = {'."\n\n";
$file_end = '};'."\n";;
// Warning message
echo "<hr>
NOTE: This action will delete the previous wrsw_hal.conf file. <a href='showfile.php?help_id=file&name=wrsw_hal.conf'
onClick='showPopup(this.href);return(false);'> (see current configuration) </a>
<center>*If you do not know how to calibrate endpoints please click on <a href='http://www.ohwr.org/projects/white-rabbit/wiki/Calibration' target='_blank'> here </a>*";
echo '<br>**all fields are mandatory**</center></div><hr><br><br>';
//echo '<tr><td> <b><center> </center></b></td></tr>';
if (empty($_POST['newconf'])){
// Starting the form (timing + ports)
echo '<form method="post">';
echo "<table border='1' align='left' class='altrowstable' id='alternatecolor'>";
// Timing values:
echo '<tr><th>Switch Timing Values</th></tr>';
echo '<tr><th>PPS Width: </th><th><INPUT type="text" value = "100000" name="pps" > </th></tr>';
echo '<tr><th>Use NMEA: </th><th><INPUT type="text" value = "1" name="nmea" > </th></tr>';
echo '<tr><th>Switch Mode: [Master/GrandMaster] </th><th><INPUT type="text" value = "GrandMaster" name="switchmode" > </th></tr>';
// port values:
for($i=0; $i<18; $i++){
echo '<tr><th>Endpoint '.($i+1).'</th></tr>';
if($i<4){ echo '<tr><th>Rx min:</th><th><INPUT type="text" value = "160000" name="rx'.$i.'" > </th></tr>';
}else{ echo '<tr><th>Rx min:</th><th><INPUT type="text" value = "161200" name="rx'.$i.'" > </th></tr>';}
echo '<tr><th>Tx min:</th><th><INPUT type="text" value = "0" name="tx'.$i.'" > </th></tr>';
echo '<tr><th>Mac address:</th><th><INPUT type="text" value = "auto" name="mac'.$i.'" > </th></tr>';
if($i==0){ echo '<tr><th>Endpoint mode: [wr_slave/wr_master] </th><th><INPUT type="text" value = "wr_slave" name="mode'.$i.'" > </th></tr>';
}else{ echo '<tr><th>Endpoint mode: [wr_slave/wr_master] </th><th><INPUT type="text" value = "wr_master" name="mode'.$i.'" > </th></tr>';}
}
echo '<input type="hidden" name="newconf" value="newconf">';
echo '</table>';
echo '<input align="right" type="submit" value="Create new file & Reboot" class="btn">';
echo '</form>';
}
if (!empty($_POST['newconf'])){
$outputfile = $file_init;
$error = false;
if( empty($_POST['pps']) || empty($_POST['nmea']) || empty($_POST['switchmode'])){
$error = true;
}
// Switch mode must be Master or GrandMaster
if (!((!strcmp($_POST['switchmode'], "Master")) || !(strcmp($_POST['switchmode'], "GrandMaster")))){
$error = true;
}
if(!$error){
$outputfile .= "\t"."pps_width = ".$_POST['pps']."; -- PPS pulse width"."\n";
$outputfile .= "--"."\t"."use_nmea = ".$_POST['nmea']."; -- take UTC seconds from NMEA GPS clock connected to /dev/ttyS2"."\n";
$outputfile .= "--"."\t"."mode = ".'"'.$_POST['switchmode'].'"'."; -- grand-master with external reference"."\n";
$outputfile .= "};"."\n\n";
}
$outputfile .= "ports = {"."\n\n";
for($i=0; $i<18 && (!$error); $i++){
if( empty($_POST['mac'.$i]) || empty($_POST['mode'.$i]) /*|| empty($_POST['tx'.$i])*/ || empty($_POST['rx'.$i])){
$error = true;
echo '<br>ERROR!!'.$i."--".empty($_POST['mac'.$i])."--".empty($_POST['mode'.$i])."--".empty($_POST['tx'.$i])."--".empty($_POST['rx'.$i]);
}
// Switch mode must be Master or GrandMaster
if (!((!strcmp($_POST['mode'.$i], "wr_master")) || !(strcmp($_POST['mode'.$i], "wr_slave")))){
$error = true;
}
$outputfile .= "\t"."wr".$i." = {"."\n";
$outputfile .= "\t\t".'phy_rx_min = '.$_POST['rx'.$i].';'."\t"."-- minimal RX latency introduced by the PHY (in picoseconds)"."\n";
$outputfile .= "\t\t".'phy_tx_min = '.$_POST['tx'.$i].';'."\n\n";
$outputfile .= "\t\t".'mac_addr = '.'"'.$_POST['mac'.$i].'"'.';'."\n";
$outputfile .= "\t\t".'mode = '.'"'.$_POST['mode'.$i].'"'.';'."\n";
$outputfile .= "\t"."};"."\n\n";
}
$outputfile .= $file_end;
}
wrs_change_wrfs("rw");
if(!empty($_POST['newconf']) && !$error){
//We save the changes in a temporarely file in /tmp
$file = fopen("/tmp/wrsw_hal.conf","w+");
fwrite($file,$outputfile);
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/wrsw_hal.conf', '/wr/etc/wrsw_hal.conf');
echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>';
wrs_change_wrfs("ro");
shell_exec("reboot");
}else if(!empty($_POST['newconf']) && $error){
echo '<center><font color="red">WARNING: Conf. file not created. Please fill in all fields</font></center>';
echo '<center><font color="red">* Switch mode must be Master or GrandMaster </font></center>';
echo '<center><font color="red">** Endpoint mode must be wr_slave or wr_master </font></center>';
}
wrs_change_wrfs("ro");
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
......@@ -19,6 +19,7 @@
<h1 class="title">Endpoint Mode Configuration<a href='help.php?help_id=endpointmode' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<?php
//Load all
......@@ -42,7 +43,7 @@
echo '</table>';
echo '<br>';
wrs_check_writeable();
//wrs_check_writeable();
?>
......
......@@ -18,9 +18,21 @@ function wrs_header_ports(){
// Check whether $WRS_MANAGEMENT is set or we take the program
// by default.
$cmd = wrs_env_sh();
$str = shell_exec($cmd." ports");
$ports = explode(" ", $str);
if(!file_exists("/tmp/ports.conf")){
$cmd = wrs_env_sh();
shell_exec("killall wr_management");
$str = shell_exec($cmd." ports");
$fp = fopen('/tmp/ports.conf', 'w+');
fwrite($fp, $str);
fclose($fp);
$ports = $str;
}else{
$ports = shell_exec("cat /tmp/ports.conf");
}
$ports = explode(" ", $ports);
// We parse and show the information comming from each endpoint.
echo "<table border='0' align='center' vspace='1'>";
......@@ -29,17 +41,19 @@ function wrs_header_ports(){
echo "<table border='0' align='center' vspace='15'>";
echo '<tr>';
$cont = 0;
for($i=1; $i<18*4; $i=$i+4){
if (strstr($ports[($i-1)],"up")){
if (!strcmp($ports[($i)],"Master")){
echo '<th>'."<IMG SRC='img/master.png' align=left , width=40 , hight=40 , border=0 , alt='master'>".'</th>';
echo '<th>'."<IMG SRC='img/master.png' align=left , width=40 , hight=40 , border=0 , alt='master', title='wr".$cont."'>".'</th>';
}else{
echo '<th>'."<IMG SRC='img/slave.png' align=left , width=40 , hight=40 , border=0 , alt='slave'>".'</th>';
echo '<th>'."<IMG SRC='img/slave.png' align=left , width=40 , hight=40 , border=0 , alt='slave', title='wr".$cont."'>".'</th>';
}
}else{
echo '<th>'."<IMG SRC='img/linkdown.png' align=left , width=40 , hight=40 , border=0 , alt='down'>".'</th>';
echo '<th>'."<IMG SRC='img/linkdown.png' align=left , width=40 , hight=40 , border=0 , alt='down', title='wr".$cont."'>".'</th>';
}
$cont++;
}
echo '</tr>';
......@@ -48,14 +62,14 @@ function wrs_header_ports(){
for($i=1; $i<18*4; $i=$i+4){
if (!strstr($ports[($i+1)],"NoLock")){
echo '<th>'."<IMG SRC='img/locked.png' align=center , width=15 , hight=15 , border=0 , alt='locked'>";
echo '<th>'."<IMG SRC='img/locked.png' align=center , width=15 , hight=15 , border=0 , alt='locked', title = 'locked'>";
}else{
echo '<th>'."<IMG SRC='img/unlocked.png' align=center , width=15 , hight=15 , border=0 , alt='unlocked'>";
echo '<th>'."<IMG SRC='img/unlocked.png' align=center , width=15 , hight=15 , border=0 , alt='unlocked', title = 'unlocked'>";
}
if (!strstr($ports[($i+2)],"Uncalibrated")){
echo "<IMG SRC='img/check.png' align=center , width=15 , hight=15 , border=0 , alt='check'>".'</th>';
echo "<IMG SRC='img/check.png' align=center , width=15 , hight=15 , border=0 , alt='check', title = 'calibrated'>".'</th>';
}else{
echo "<IMG SRC='img/uncheck.png' align=center , width=15 , hight=15 , border=0 , alt='uncheck'>".'</th>';
echo "<IMG SRC='img/uncheck.png' align=center , width=15 , hight=15 , border=0 , alt='uncheck', title = 'uncalibrated'>".'</th>';
}
}
echo '</tr>';
......@@ -86,9 +100,15 @@ function wrs_main_info(){
echo '<tr><th><b>Hostname:</b></th><th><center>'; $str = shell_exec("uname -n"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>Switch Mode:</b> </th><th><center>'; $str = check_switch_mode(); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>IP Address:</b> </th><th><center>'; $ip = shell_exec("ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); echo $ip; echo '</center></th></tr>';
echo '<tr><th> <b>OS Release:</b> </th><th><center>'; $str = shell_exec("uname -r"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>OS name:</b> </th><th><center>'; $str = shell_exec("uname -s"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>OS Version:</b> </th><th><center>'; $str = shell_exec("uname -v"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>HW Address:</b> </th><th><center>'; $mac = shell_exec("ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'"); echo $mac; echo '</center></th></tr>';
//echo '<tr><th> <b>OS Release:</b> </th><th><center>'; $str = shell_exec("uname -r"); echo $str; echo '</center></th></tr>';
//echo '<tr><th> <b>OS name:</b> </th><th><center>'; $str = shell_exec("uname -s"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>OS Version:</b> </th><th><center>'; $str = shell_exec("uname -r"); echo $str; $str = shell_exec("uname -v"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>Gateware Version:</b> </th><th><center> '; $str = shell_exec("/wr/bin/shw_ver -g | grep version | awk '{ print $4}'");
echo '<a href="showfile.php?help_id=gateware&name=GateWare Info" onClick="showPopup(this.href);return(false);"</a>';
echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>PCB Version:</b> </th><th><center>'; $str = shell_exec("/wr/bin/shw_ver -p"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>FPGA:</b> </th><th><center>'; $str = shell_exec("/wr/bin/shw_ver -f"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>Compiling time:</b> </th><th><center>'; $str = shell_exec("/wr/bin/shw_ver -c"); echo $str; echo '</center></th></tr>';
......@@ -117,6 +137,20 @@ function wrs_check_writeable(){
}
/*
* It modifies filesystem to rw o ro
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* @param $m should be rw for writable and ro for read-only
*
*/
function wrs_change_wrfs($m){
$output = shell_exec('/wr/bin/wrfs_mnt.sh '.$m);
}
/*
* It checks whether the ptpd daemon is running or not.
*
......@@ -388,6 +422,8 @@ function wrs_load_files(){
echo '<center>Loading FPGA binary '.$_FILES['fpgafile']['name'].', please wait for the system to reboot</center>';
$str = shell_exec("/wr/bin/load-virtex ".$uploadfile);
echo $str;
echo '<br>System is rebooting, please wait for 30 seconds';
$str = shell_exec("reboot");
} else {
echo "<center>File is not valid, please upload a .bin file.</center>\n";
......@@ -408,6 +444,8 @@ function wrs_load_files(){
echo '<center>Loading lm32 binary '.$_FILES['lm32file']['name'].',, please wait for the system to reboot</center>';
$str = shell_exec("/wr/bin/load-lm32 ".$uploadfile);
echo $str;
echo '<br>System is rebooting, please wait for 30 seconds';
$str = shell_exec("reboot");
} else {
echo "<center>File is not valid, please upload a .bin file</center>\n";
......@@ -604,7 +642,7 @@ function wrs_vlan_display(){
}
function wrs_display_help($help_id){
function wrs_display_help($help_id, $name){
if(!strcmp($help_id, "dashboard")){
$message = "<p>
......@@ -667,9 +705,8 @@ function wrs_display_help($help_id){
} else if (!strcmp($help_id, "management")){
$message = "<p>
Options: <br>
- <b>Halt switch</b>: shut down switch. <br>
- <b>Change mode:</b> It changes switch mode to Master/GrandMaster <br>
- <b>Reboot switch</b>: it reboots the switch <br>
- <b>Mounting partitions</b>: Switch filefolders are read-only by default (except /tmp folder). If you want to make all directories writable use the remount function as writable. <br>
- <b>PHP Filesize</b>: It changes the max. size of the files that can be uploaded to the switch (2 MegaBytes by default)<br>
</p>";
} else if (!strcmp($help_id, "ptp")){
......@@ -679,8 +716,30 @@ function wrs_display_help($help_id){
$message = "<p>vlan</p>";
} else if (!strcmp($help_id, "console")){
$message = "<p>This is a switch console emulator windows. Use it as if you were using a ssh session.</p>";
} else if (!strcmp($help_id, "gateware")){
$msg = shell_exec("/wr/bin/shw_ver -g");
$msg = explode("\n", $msg);
for($i=0; $i<5; $i++){
$message .= "<p>".$msg[$i]."<br></p>";
}
} else if (!strcmp($help_id, "file")){
$msg = shell_exec("cat /wr/etc/".$name);
$msg = explode("\n", $msg);
for($i=0; $i<count($msg); $i++){
$message .= $i.": ".$msg[$i]."<br>";
}
} else if (!strcmp($help_id, "endpointmode")){
$message = "<b>Change endpoint mode to master/slave by clicking on one of the items</b>";
}
echo $message;
}
......
......@@ -8,7 +8,7 @@
<hr>
<?php
wrs_display_help($_GET['help_id']);
wrs_display_help($_GET['help_id'],"");
?>
</body>
......
......@@ -4,7 +4,7 @@
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="header-ports" ><?php shell_exec("rm /tmp/ports.conf"); wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
......@@ -18,6 +18,7 @@
<div class="rightbody">
<h1 class="title">Dashboard <a href='help.php?help_id=dashboard' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php
wrs_main_info();
echo '<br><br>';
......@@ -28,7 +29,7 @@
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
<?php include 'footer.php'; ?>
</div>
</div>
</div>
......
......@@ -19,6 +19,7 @@
<h1 class="title">Load LM32 & FPGA Files <a href='help.php?help_id=load' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<table border="0" align="center">
......@@ -47,18 +48,22 @@
<br><br><br><center>Max. filesize is now <?php echo shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'");
?></center>
<form method="post">
<form align="center" method="post">
Change PHP File Size Upload: <INPUT type="text" name="size" >
<input type="submit" value="Change" class="btn">
</form>
<br><br><br><hr>
*Note: After loading a FPGA or lm32 binary the switch will reboot.
<?
wrs_change_wrfs("rw");
wrs_load_files();
wrs_change_wrfs("ro");
echo '<center>';
wrs_check_writeable();
echo '</center>';
//echo '<center>';
//wrs_check_writeable();
//echo '</center>';
?>
......
......@@ -18,6 +18,8 @@
<div class="rightbody">
<h1 class="title">Dashboard <a href='help.php?help_id=logout' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php $_SESSION['advance']=""; ?>
<?php
//ob_start();
......
......@@ -18,7 +18,8 @@
<div class="rightbody">
<h1 class="title">Switch Management <a href='help.php?help_id=management' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<table border="0" align="center">
<tr>
......@@ -27,12 +28,12 @@
<th><input type="submit" value="Change Mode" class="btn"></th>
</form>
</tr>
<tr>
<!--<tr>
<form method="post">
<th><center>Halt system: </center><input type="hidden" name="cmd" value="halt"></th>
<th><input type="submit" value="Halt switch" class="btn"></th>
</form>
</tr>
</tr> -->
<tr>
<form method="post">
<th><center>Reboot system: </center><input type="hidden" name="cmd" value="reboot"></th>
......@@ -40,7 +41,7 @@
</form>
</tr>
</tr><th> </th><th> </th><tr></tr><th> </th><th> </th><tr>
<tr>
<!--<tr>
</form>
<form method="post">
<th><center>Mount partition as writable: </center><input type="hidden" name="cmd" value="rw"></th>
......@@ -53,7 +54,7 @@
<th><center>Mount partition as read-only: </center><input type="hidden" name="cmd" value="ro"></th>
<th><input type="submit" value="Remount" class="btn"></th>
</form>
</tr>
</tr>-->
</tr><th> </th><th> </th><tr></tr><th> </th><th> </th><tr>
<tr>
<form method="post">
......@@ -68,8 +69,10 @@
<?php
wrs_change_wrfs("rw");
wrs_management();
wrs_check_writeable();
//wrs_check_writeable();
wrs_change_wrfs("ro");
?>
......
......@@ -27,11 +27,16 @@ echo '<div class="login">
if(file_exists('/wr/bin/wrsw_rtud_new')) {echo '<li><a href="vlan.php"> VLAN Configuration </a></li>';}
echo '<li><a href="ptp.php"> PTP Configuration </a></li>';
echo '<li><a href="endpointmode.php"> Endpoint Mode</a></li>';
echo '<li><a href="endpoint.php"> Endpoint Tool </a></li>';
echo '<li><a href="load.php"> LM32 & FPGA </a></li>';
echo '<li><a href="management.php"> Switch Management </a></li>';
echo '<li><a href="advance.php"> Advance Mode </a></li>';
//echo '<li><a href="administration.php"> Switch Administration </a></li>';
echo '<li><a href="terminal.php"> Console </a></li>';
if(!empty($_SESSION['advance'])){
echo '<li>&nbsp;<a href="sfpcalibration.php"><font color="gray"> SFP Calibration </font></a></li>';
echo '<li>&nbsp;<a href="endpoint.php"><font color="gray"> Endpoint Tool</font> </a></li>';
echo '<li>&nbsp;<a href="endpointcalibration.php"><font color="gray"> Endpoint Calibration </font></a></li>';
echo '<li>&nbsp;<a href="terminal.php"> <font color="gray">Virtual Console </font></a></li>';
}
echo '</ul><br><hr>';
echo '<b>User: <font color="blue">'.$_SESSION["myusername"].' </font></b>';
......
......@@ -25,7 +25,9 @@
$endpoint = $_GET["wr"];
$mode = $_GET["mode"];
wrs_change_wrfs("rw");
wrs_modify_endpoint_mode($endpoint, $mode);
wrs_change_wrfs("ro");
?>
<hr>
......
......@@ -19,6 +19,7 @@
<h1 class="title">PTP Configuration <a href='help.php?help_id=ptp' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<FORM method="POST">
<table border="0" align="center">
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<div class="main">
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
</div>
<div class="content">
<div class="leftpanel">
<h2>Main Menu</h2>
<?php include 'menu.php' ?>
</div>
<div class="rightpanel">
<div class="rightbody">
<h1 class="title">SFP Database <a href='http://www.ohwr.org/projects/white-rabbit/wiki/Calibration' target='_blank'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<br>
<?php
$file_init = '-- The VENDOR_SERIAL field can be set to an empty string to provide class-level'."\n";
$file_init .= '-- information as opposed to device-level information.'."\n\n";
$file_init .= 'sfpdb = {'."\n";
$file_end = '}'."\n";;
if (empty($_POST['number'])){
echo '<div><form method="post">
Number of new SPFs to be added: <INPUT type="text" value="2" name="number" >
<input type="submit" value="Add" class="btn">
</form></div>';
echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><hr>
<div>
NOTE: This action will delete the previous sfp_database.conf file. <a href='showfile.php?help_id=file&name=sfp_database.conf'
onClick='showPopup(this.href);return(false);'> (see current configuration) </a>
<center>**If you do not know how to calibrate SFPs please click on <a href='http://www.ohwr.org/projects/white-rabbit/wiki/Calibration' target='_blank'> here </a>**</center>
</div>";
}else{
echo '*all fields are mandatory<br><br>';
echo "<div><table border='1' align='left' class='altrowstable' id='alternatecolor'>";
//echo '<tr><td> <b><center> </center></b></td></tr>';
echo '<form method="post">';
if (($_POST['number']!=2)){
for($i=0; $i<$_POST['number']; $i++){
echo '<tr><th>SFP '.($i+1).'</th></tr>';
echo '<tr><th>Part Number</th><th><INPUT type="text" name="sfpnumber'.$i.'" > </th></tr>';
echo '<tr><th>Alpha</th><th><INPUT type="text" name="alpha'.$i.'" > </th></tr>';
echo '<tr><th>Delta Tx</th><th><INPUT type="text" name="tx'.$i.'" > </th></tr>';
echo '<tr><th>Delta Rx</th><th><INPUT type="text" name="rx'.$i.'" > </th></tr>';
}
}else{
for($i=0; $i<$_POST['number']; $i++){
echo '<tr><th>SFP '.($i+1).'</th></tr>';
if($i==0){
echo '<tr><th>Part Number</th><th><INPUT type="text" value = "AXGE-1254-0531" name="sfpnumber'.$i.'" > </th></tr>';
echo '<tr><th>Alpha</th><th><INPUT type="text" value="2.67871791665542e-04" name="alpha'.$i.'" > </th></tr>';
echo '<tr><th>Delta Tx</th><th><INPUT type="text" value="10" name="tx'.$i.'" > </th></tr>';
echo '<tr><th>Delta Rx</th><th><INPUT type="text" value="10" name="rx'.$i.'" > </th></tr>';
}else{
echo '<tr><th>Part Number</th><th><INPUT type="text" value = "AXGE-3454-0531" name="sfpnumber'.$i.'" > </th></tr>';
echo '<tr><th>Alpha</th><th><INPUT type="text" value="-2.67800055584799e-04" name="alpha'.$i.'" > </th></tr>';
echo '<tr><th>Delta Tx</th><th><INPUT type="text" value="10" name="tx'.$i.'" > </th></tr>';
echo '<tr><th>Delta Rx</th><th><INPUT type="text" value="10" name="rx'.$i.'" > </th></tr>';
}
}
}
echo '<input type="hidden" name="newconf" value="newconf">';
echo '<input type="hidden" name="newnumber" value="'.$_POST['number'].'">';
echo '<input type="submit" value="Create new file & Reboot" class="btn">';
echo '</form>';
echo '</table>';
echo '</div>';
}
if (!empty($_POST['newconf'])){
$outputfile = $file_init;
$error = false;
for($i=0; $i<$_POST['newnumber'] && (!$error); $i++){
if(empty($_POST['sfpnumber'.$i]) || empty($_POST['alpha'.$i]) || empty($_POST['tx'.$i]) || empty($_POST['rx'.$i])){
$error = true;
}
$outputfile .= " {"."\n";
$outputfile .= "\t".'part_num = "'.$_POST['sfpnumber'.$i].'",'."\n";
$outputfile .= "\t"."alpha = ".$_POST['alpha'.$i].','."\n";
$outputfile .= "\t"."delta_tx = ".$_POST['tx'.$i].','."\n";
$outputfile .= "\t"."delta_rx = ".$_POST['rx'.$i]."\n";
$outputfile .= " },"."\n\n";
}
$outputfile .= $file_end;
}
wrs_change_wrfs("rw");
if(!empty($_POST['newconf']) && !$error){
//We save the changes in a temporarely file in /tmp
$file = fopen("/tmp/sfp_database.conf","w+");
fwrite($file,$outputfile);
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/sfp_database.conf', '/wr/etc/sfp_database.conf');
echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>';
wrs_change_wrfs("ro");
shell_exec("reboot");
}else if(!empty($_POST['newconf']) && $error){
echo '<center><font color="red">WARNING: Conf. file not created. Please fill in all fields</font></center>';
}
wrs_change_wrfs("ro");
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php include 'functions.php' ?>
<html>
<head>
<title></title>
</head>
<body >
<h1><center><?php echo $_GET['name'];?></center></h1>
<hr>
<?php
wrs_display_help($_GET['help_id'], $_GET['name']);
?>
</body>
</html>
......@@ -27,15 +27,88 @@
<?php
wrs_change_wrfs("rw");
/*$path = shell_exec("echo $PATH");
if(substr_count($path , "/wr/bin")==0){
//$new_path = shell_exec("export PATH=/wr/bin:$PATH");
$path = htmlspecialchars(shell_exec("echo $PATH"));
echo "PATH=".$path;
}*/
// If pwd is empty, we go to the root directory
if(empty($_SESSION["pwd"])){$_SESSION["pwd"]="/";}
shell_exec("cd ".$_SESSION["pwd"]);
$cmd = htmlspecialchars($_POST["cmd"]);
$output = shell_exec($cmd);
// user is moving to another directory
$cmd_aux = $cmd;
if(substr_count($cmd_aux , "cd")>0){
$cmd = " ls ";
// moving backwards
if(substr_count($cmd_aux , "cd ..")>0){
$back = explode("/", $_SESSION["pwd"]);
$size = count($back);
$_SESSION["pwd"] = str_replace("/".$back[$size-1],"",$_SESSION["pwd"]);
// moving forwards
}else{
$cmd_aux = explode(" ", $cmd_aux);
if(!strstr($cmd_aux[1][0],"/")){
if(file_exists($_SESSION["pwd"]."/".$cmd_aux[1])){
if (!strcmp($_SESSION["pwd"], "/")){
$_SESSION["pwd"].= $cmd_aux[1];
}else{
$_SESSION["pwd"].= "/".$cmd_aux[1];
}
}else{
$output = "folder not found";
}
}else{
if(file_exists($cmd_aux[1])){
$_SESSION["pwd"] = $cmd_aux[1];
}else{
$output = "folder not found";
}
}
}
}else{
}
$path = "PATH=/sbin:/usr/sbin:/bin:/usr/bin:/wr/bin";
if(strstr($output,"folder not found")){
$output = 'folder "'.$cmd_aux[1].'" not found';
$cmd = "";
}else{
$output = shell_exec( $path." ; cd ".$_SESSION["pwd"]." ; ".$cmd);
}
echo '<div align="center"> <div id="preview" style= "BORDER-RIGHT: #000 1px solid; PADDING-RIGHT: 0px;
BORDER-TOP: #000 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; WORD-SPACING: 1px; OVERFLOW: scroll;
BORDER-LEFT: #000 1px solid; WIDTH: 100%; PADDING-TOP: 1px;
BORDER-BOTTOM: #000 2px solid; HEIGHT: 350px; TEXT-ALIGN: left">
<p>$'.$cmd.':<br>'.$output.'</p> </div></div>';
<p>'.$_SESSION["pwd"].'$:'.$cmd.'<br>'.$output.'</p> </div></div>';
wrs_change_wrfs("ro");
?>
......
......@@ -12,13 +12,13 @@ echo '<ul>
echo '<ul>
<li><a href="index.php"> Dashboard </a></li>
<li><a href="ptp.php"> PTP Configuration </a></li>
<li><a href="endpoint.php"> Endpoint Configuration </a></li>
<li><a href="endpointmode.php"> Endpoint Mode</a></li>
<li><a href="management.php"> Switch Management </a></li>
<li><a href="contact.php"> Contact Us </a></li>
</ul>';
</ul>';
}
}
?>
......@@ -19,6 +19,7 @@
<h1 class="title">VLAN Configuration <a href='help.php?help_id=vlan' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<?php
echo '<table align=center border="1" class="altrowstable" id="alternatecolor">';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment