Commit 84cde10b authored by Alessandro Rubini's avatar Alessandro Rubini

Merge branch 'http-management'

parents f0f5ec8c 7ddad1e7
#
# Automatically generated make config: don't edit
# Buildroot 2011.11 Configuration
# Sat Feb 1 00:22:42 2014
# Fri Dec 13 14:36:03 2013
#
BR2_HAVE_DOT_CONFIG=y
BR2_arm=y
......@@ -76,7 +76,7 @@ BR2_SOURCEFORGE_MIRROR="kent"
BR2_KERNEL_MIRROR="http://www.kernel.org/pub/"
BR2_GNU_MIRROR="http://ftp.gnu.org/pub/gnu"
BR2_DEBIAN_MIRROR="http://ftp.debian.org"
BR2_JLEVEL=5
BR2_JLEVEL=9
# BR2_CCACHE is not set
# BR2_DEPRECATED is not set
# BR2_ENABLE_DEBUG is not set
......@@ -603,7 +603,47 @@ BR2_PACKAGE_LUA_SHARED_LIBRARY=y
# BR2_PACKAGE_WSAPI is not set
# BR2_PACKAGE_XAVANTE is not set
# BR2_PACKAGE_MICROPERL is not set
# BR2_PACKAGE_PHP is not set
BR2_PACKAGE_PHP=y
BR2_PACKAGE_PHP_CLI=y
BR2_PACKAGE_PHP_CGI=y
# BR2_PACKAGE_PHP_SAPI_CLI is not set
# BR2_PACKAGE_PHP_SAPI_CGI is not set
BR2_PACKAGE_PHP_SAPI_CLI_CGI=y
BR2_PACKAGE_PHP_FASTCGI=y
#
# PHP Extensions
#
BR2_PACKAGE_PHP_CONFIG="$(PHP_DIR)/php.ini-dist"
# BR2_PACKAGE_PHP_EXT_SOCKETS is not set
BR2_PACKAGE_PHP_EXT_POSIX=y
BR2_PACKAGE_PHP_EXT_SPL=y
BR2_PACKAGE_PHP_EXT_SESSION=y
# BR2_PACKAGE_PHP_EXT_OPENSSL is not set
# BR2_PACKAGE_PHP_EXT_LIBXML2 is not set
# BR2_PACKAGE_PHP_EXT_SIMPLEXML is not set
BR2_PACKAGE_PHP_EXT_ZLIB=y
# BR2_PACKAGE_PHP_EXT_EXIF is not set
# BR2_PACKAGE_PHP_EXT_FTP is not set
# BR2_PACKAGE_PHP_EXT_GETTEXT is not set
# BR2_PACKAGE_PHP_EXT_GMP is not set
# BR2_PACKAGE_PHP_EXT_JSON is not set
# BR2_PACKAGE_PHP_EXT_READLINE is not set
# BR2_PACKAGE_PHP_EXT_NCURSES is not set
# BR2_PACKAGE_PHP_EXT_PCRE is not set
# BR2_PACKAGE_PHP_EXT_PCNTL is not set
# BR2_PACKAGE_PHP_EXT_SYSVMSG is not set
# BR2_PACKAGE_PHP_EXT_SYSVSEM is not set
# BR2_PACKAGE_PHP_EXT_SYSVSHM is not set
# BR2_PACKAGE_PHP_EXT_ZIP is not set
# BR2_PACKAGE_PHP_EXT_FILTER is not set
# BR2_PACKAGE_PHP_EXT_CALENDAR is not set
#
# Database extensions
#
# BR2_PACKAGE_PHP_EXT_SQLITE is not set
# BR2_PACKAGE_PHP_EXT_PDO is not set
BR2_PACKAGE_PYTHON=y
# BR2_PACKAGE_PYTHON_PY_ONLY is not set
BR2_PACKAGE_PYTHON_PYC_ONLY=y
......@@ -886,7 +926,13 @@ BR2_PACKAGE_IPROUTE2=y
#
# Kismet requires a toolchain with C++ support enabled
#
# BR2_PACKAGE_LIGHTTPD is not set
BR2_PACKAGE_LIGHTTPD=y
# BR2_PACKAGE_LIGHTTPD_OPENSSL is not set
BR2_PACKAGE_LIGHTTPD_ZLIB=y
# BR2_PACKAGE_LIGHTTPD_BZIP2 is not set
BR2_PACKAGE_LIGHTTPD_PCRE=y
# BR2_PACKAGE_LIGHTTPD_WEBDAV is not set
# BR2_PACKAGE_LIGHTTPD_LUA is not set
# BR2_PACKAGE_LINKS is not set
# BR2_PACKAGE_LRZSZ is not set
# BR2_PACKAGE_MII_DIAG is not set
......@@ -1017,7 +1063,7 @@ BR2_PACKAGE_SCREEN=y
# BR2_PACKAGE_MODULE_INIT_TOOLS is not set
# BR2_PACKAGE_PROCPS is not set
# BR2_PACKAGE_PSMISC is not set
BR2_PACKAGE_RSYSLOG=y
# BR2_PACKAGE_RSYSLOG is not set
#
# syslogd requires a toolchain with LARGEFILE support
......
#!/bin/ash
#
# Starts lighttpd daemon.
#
start() {
echo -n "Starting lighttpd daemon: "
/usr/sbin/lighttpd -f /var/www/lighttpd.config
echo "OK"
}
stop() {
echo -n "Stopping lighttpd daemon: "
killall lighttpd
echo "OK"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
<?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>
<?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">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>
<p><strong>Built in <?php $str = shell_exec("/wr/bin/shw_ver -c"); echo $str; ?></strong></p><p>&nbsp;</p>
<a href='http://www.ugr.es'><IMG SRC='img/ugr.gif' align=right width=250 , hight=100 , border=0 , alt='UGR'></a><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
<p align=right><strong>Developed by Jos&eacute; Luis Guti&eacute;rrez <a href="mailto:jlgutierrez@ugr.es?subject=[White-Rabbit Switch Local Management Tool]">(jlgutierrez@ugr.es)</a> </strong></p>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #333333;
background-image: url(../img/bg.jpg);
background-repeat: repeat;
margin: 30px 0px 0px 0px;
}
h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, input, textarea {
padding: 0px;
margin: 0px;
}
.main {
width: 840px;
margin: 0px auto;
}
.page {
background-color: #FFFFFF;
width: 800px;
float: left;
padding: 0px 20px;
margin-bottom: 20px;
}
.header, .header-img {
width: 800px;
float: left;
}
.header-ports {
background-image: url(../img/header.jpg);
height: 140px;
margin-top: 15px;
}
.header h1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 30px;
font-weight: normal;
line-height: 80%;
color: #1C1C1C;
margin-top: 25px;
margin-left: 5px;
}
.topmenu {
background-color: #000000;
width: 800px;
height: 50px;
float: left;
}
.topmenu ul {
height: 15px;
margin: 18px 0px 0px 20px;
list-style-type: none;
}
.topmenu ul li {
background-image: url(../img/bullet.jpg);
background-repeat: no-repeat;
background-position: left top;
height: 15px;
float: left;
padding-left: 14px;
margin-right: 31px;
}
.topmenu ul li a {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
line-height: normal;
color: #FFFFFF;
text-decoration: none;
}
.topmenu ul li a:hover {
color: #23b14d;
}
.content {
width: 800px;
float: left;
}
.leftpanel {
background-color: #ededed;
width: 220px;
float: left;
padding: 25px 20px;
margin-right: -260px;
position: relative;
}
.leftpanel h2 {
font-size: 14px;
line-height: 100%;
text-transform: uppercase;
color: #000000;
padding-bottom: 5px;
margin-bottom: 17px;
border-bottom-width: 1px;
border-bottom-style: dashed;
border-bottom-color: #cccccc;
}
.leftpanel ul {
margin-bottom: 22px;
list-style-type: none;
}
.leftpanel ul li {
margin-bottom: 5px;
}
.leftpanel ul li a {
font-size: 11px;
font-weight: bold;
color: #000000;
text-decoration: none;
}
.leftpanel ul li a:hover {
color: #23b14d;
}
.rightpanel {
width: 540px;
float: left;
border-left: solid 260px #eaeff3;
}
.rightbody {
text-align: justify;
width: 480px;
float: left;
padding: 25px 0px 25px 40px;
}
.rightbody strong {
color: #000000;
}
.title {
font-size: 14px;
line-height: 100%;
text-transform: uppercase;
color: #000000;
padding-bottom: 5px;
margin-bottom: 17px;
border-bottom-width: 1px;
border-bottom-style: dashed;
border-bottom-color: #cccccc;
}
.copyright {
border: 0px;
height: 1px;
width: 1px;
}
.footer {
background-image: url(../img/footer.jpg);
background-repeat: no-repeat;
background-position: left top;
width: 800px;
height: 77px;
float: left;
}
.footer p {
font-size: 11px;
line-height: 57px;
color: #FFFFFF;
text-align: center;
}
.footer-link {
color:#ffffff;
text-decoration:none;
}
.btn {
background: #3498db;
background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
background-image: -moz-linear-gradient(top, #3498db, #2980b9);
background-image: -ms-linear-gradient(top, #3498db, #2980b9);
background-image: -o-linear-gradient(top, #3498db, #2980b9);
background-image: linear-gradient(to bottom, #3498db, #2980b9);
-webkit-border-radius: 60;
-moz-border-radius: 60;
border-radius: 60px;
font-family: Arial;
color: #ffffff;
font-size: 12px;
padding: 1px 5px 2px 7px;
text-decoration: none;
}
.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
.sec {
background: #9bcff2;
background-image: -webkit-linear-gradient(top, #9bcff2, #4fa2d6);
background-image: -moz-linear-gradient(top, #9bcff2, #4fa2d6);
background-image: -ms-linear-gradient(top, #9bcff2, #4fa2d6);
background-image: -o-linear-gradient(top, #9bcff2, #4fa2d6);
background-image: linear-gradient(to bottom, #9bcff2, #4fa2d6);
-webkit-border-radius: 5;
-moz-border-radius: 5;
border-radius: 5px;
font-family: Arial;
color: #ffffff;
font-size: 12px;
padding: 1px 5px 2px 7px;
text-decoration: none;
}
.sec:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
table.altrowstable {
font-family: verdana,arial,sans-serif;
font-size: 10px;
color: #333333;
border-width: 1px;
border-color: #a9c6c9;
border-collapse: collapse;
}
table.altrowstable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
.oddrowcolor{
background-color: #d4e3e5;
}
.evenrowcolor{
background-color: #c3dde0;
}
.tableheader {
background-color: #95BEE6;
color:white;
font-weight:bold;
}
.tablerow {
background-color: #A7D6F1;
color:white;
}
.message {
color: #FF0000;
font-weight: bold;
text-align: center;
width: 80%;
}
<?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 Tool <a href='help.php?help_id=endpoint' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php
echo '<form method=POST>
Select an Endpoint: <select name="endpoint" class="sec">';
for($op = 0; $op < 18; $op++){
echo '<option value="wr'.$op.'">wr'.$op.'</option>';
}
echo '</select>';
echo '<select name="option1" class="sec">';
echo '<option value="txcal1">Enable Calibration Transmission</option>';
echo '<option value="txcal0">Disable Calibration Transmission</option>';
echo '<option value="dump">See Registers</option>';
echo '<option value="wr">Modify Registers</option>';
//echo '<option value="rt">Show Flags</option>';
echo '<option value="lock">Lock Endpoint</option>';
//echo '<option value="master">Make Master</option>';
//echo '<option value="gm">Make GrandMaster</option>';
echo '</select>
<input type="submit" value="Go!" class="btn">
</form>';
//Second option levels:
$option1=htmlspecialchars($_POST['option1']);
$endpoint=htmlspecialchars($_POST['endpoint']);
//Calling phytool.
if(!empty($option1)){
wr_endpoint_phytool($option1, $endpoint);
}
echo '<br><hr><br>';
wr_show_endpoint_rt_show();
echo '<br><hr><br>';
?>
</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">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>
<?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 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
$modes = parse_wrsw_hal_file();
echo '<table align=center border="1" class="altrowstable" id="alternatecolor">';
//echo '<tr><th><center>Endpoint</center></th><th><center>Mode</center></th></tr>';
for($i = 0; $i < 9; $i++){
echo '<tr>';
echo '<td><center><b>wr'.($i+1).'</b></center></td>';
echo '<td><center><a href="modifymode.php?wr='.($i+1).'&mode='.$modes[$i+1].'">'.$modes[$i+1].'</a></center></td>';
echo '<td><center><b>wr'.($i+1+9).'</b></center></td>';
echo '<td><center><a href="modifymode.php?wr='.($i+1+9).'&mode='.$modes[$i+1+9].'">'.$modes[$i+1+9].'</a></center></td>';
echo '</tr>';
}
//echo '</tr>';
echo '</table>';
echo '<br>';
//wrs_check_writeable();
?>
<br>
<hr>
<FORM align="right" method="post">
<input type="hidden" name="hal" value="hal">
<INPUT type="submit" value="Reboot Hal daemon" class="btn">
</FORM>
<?php
if (!empty($_POST["hal"])){
//Relaunching wrsw_hal to commit endpoint changes
shell_exec("killall wrsw_hal");
shell_exec("/wr/bin/wrsw_hal -c /wr/etc/wrsw_hal.conf > /dev/null 2>&1 &");
//We must relaunch ptpd too. (by default)
shell_exec("killall ptpd");
$ptp_command = "/wr/bin/ptpd -A -c > /dev/null 2>&1 &";
$output = shell_exec($ptp_command);
}
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<img src="img/footnote.gif" class="copyright" alt="White-Rabbit OHR"></a>
<a href='index.php'><IMG SRC='img/wr_logo.png' align=left , vspace=7, hspace=5, width=50 , hight=100 , border=0 , alt='White Rabbit'></a>
<a href='http://www.ohwr.org/projects/wr-switch-sw' target="_blank"><IMG SRC='img/ohr.png' align=left , vspace=7, hspace=5, width=35 , hight=100 , border=0 , alt='OHR'></a>
<p>White Rabbit Project - Open Hardware and Source Project <a class="footer-link" target="_blank"
href="http://www.ohwr.org/projects/white-rabbit/wiki">White-Rabbit OHR</a>
<a href='sysinfo.php' target="_blank"><IMG SRC='img/light_php.png' align=right , vspace=7, hspace=5, width=100 , hight=100 , border=0 , alt='PHP Info'></a>
<img src="img/footnote.gif" alt="White-Rabbit OHR"></a>
</p>
<?php
/*
* Displays the current status of each enpoint.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* Displays the current status of each endpoint as wr_mon tool
* in the swich does. It retrieves the information from wr_mon
* and displays: master and slaves endpoints, calibration and locking
* status.
* If all endpoints looks disabled (but they are not) it means
* PTP is not running.
*
*/
function wrs_header_ports(){
// Check whether $WRS_MANAGEMENT is set or we take the program
// by default.
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'>";
echo '<tr><th><h1 align=center>White-Rabbit Switch Manager</h1></th></tr>';
echo '</table>';
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', title='wr".$cont."'>".'</th>';
}else{
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', title='wr".$cont."'>".'</th>';
}
$cont++;
}
echo '</tr>';
echo '<tr>';
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', title = 'locked'>";
}else{
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', title = 'calibrated'>".'</th>';
}else{
echo "<IMG SRC='img/uncheck.png' align=center , width=15 , hight=15 , border=0 , alt='uncheck', title = 'uncalibrated'>".'</th>';
}
}
echo '</tr>';
echo '<tr>';
echo '</tr>';
echo '</table>';
}
/*
* Displays OS, Hardware and protocols running on the switch
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* Displays the info comming from the following commands:
* uname, shw_ver, wr_date and php.ini
*
*/
function wrs_main_info(){
echo "<table border='1' align='left' class='altrowstable' id='alternatecolor'>";
echo '<tr><td> <b><center>Switch Info </center></b></td></tr>';
$str = shell_exec("uname -n");
if(strcmp($str,"(none)")) shell_exec("/bin/busybox hostname -F /etc/hostname");
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>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>';
echo '<tr><th> <b>White-Rabbit Date:</b></th><th><center>'; $str = shell_exec("/wr/bin/wr_date get"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>PTP:</b> </th><th><center>'; echo wrs_check_ptp_status() ? 'On' : 'Off'; echo '</center></th></tr>';
echo '<tr><th> <b>Max. Filesize Upload: </b></th><th><center>'; echo shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'"); echo '</center></th></tr>';
echo '</table>';
}
/*
* It checks whether the filesystem is writable or not.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* It checks whether the filesystem is writable or not and prints a
* warning message if so.
*
*/
function wrs_check_writeable(){
$output = shell_exec('mount | grep "(ro,"');
echo (!isset($output) || trim($output) == "") ? "" : "<br><font color='red'>WARNING: WRS is mounted as READ-ONLY, please contact the maintainer</font>";
}
/*
* 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.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* It checks whether the ptpd daemon is running or not by counting
* the number of entries in ps command.
*
* @return ptp is true or false
*
*/
function wrs_check_ptp_status(){
$output = intval(shell_exec("ps | grep -c ptpd"));
return ($output>2) ? 1 : 0;
}
/*
* It modifies filesize transfer value.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* It modifies filesize transfer value in php.ini. Two variables must be
* modified: upload_max_filesize and post_max_size
*
* @param string $size New PHP sent filename value.
*
*/
function php_file_transfer_size($size){
// We remove the blank space
$size=trim($size);
// We modify fist upload_max_filesize in php.ini
$prev_size = shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'");
$prev_size=trim($prev_size);
$cmd = "sed -i 's/upload_max_filesize = ".$prev_size."/upload_max_filesize = ".$size."M/g' /etc/php.ini";
shell_exec($cmd);
// We modify post_max_size in php.ini
$prev_size = shell_exec("cat /etc/php.ini | grep post_max_size | awk '{print $3}'");
$prev_size=trim($prev_size);
$cmd ="sed -i 's/post_max_size = ".$prev_size."/post_max_size = ".$size."M/g' /etc/php.ini";
shell_exec($cmd);
echo '<p align=center>File upload size changed to '.$size.'</p>';
}
/*
* It modifies each endpoint configuration
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* It modifies each endpoint configuration by using wrs_phytool program
* in switch.
* Operations: show registers, modify registers, enable/disable
* transmission, lock and master/grandmaster configuration.
*
* @param string $option1 New PHP sent filename value.
* @param string $endpoint Endpoint to apply new configuration.
*
*/
function wr_endpoint_phytool($option1, $endpoint){
$cont=0;
// User wants to display endpoint's registers
if(!strcmp($option1, "dump")){
$output=shell_exec("/wr/bin/wr_phytool ".$endpoint." dump");
$ports = explode(" ", $output);
echo "<table border='0' align='center'>";
echo '<tr>';
echo '<th>'.$endpoint.' Register</th>';
echo '<th>Value</th>';
echo '</tr>';
for($i=7; $i<20*2; $i=$i+2){
echo '<tr>';
echo '<th>R'.$cont.'</th>';
echo '<th>'.substr($ports[($i)],0,10).'</th>';
echo '</tr>';
$cont++;
}
echo '</tr>';
echo '</table>';
if (!strcmp($_POST['update'], "yes")){
echo 'aki stamos!';
}
// User wants to modify endpoint's registers
} else if(!strcmp($option1, "wr")){
$output=shell_exec("/wr/bin/wr_phytool ".$endpoint." dump");
$ports = explode(" ", $output);
echo '<br>';
echo '<center></center><form method=POST>';
echo "<table border='0' align='center'>";
echo '<tr>';
echo '<th>'.$endpoint.' Registers</th>';
echo '<th><center>Value</center></th>';
echo '</tr>';
for($i=0; $i<18; $i++){
echo '<tr>';
echo '<th>R'.$i.'</th>';
echo '<th><input type="text" name="r'.$i.'" value="'.$_POST['r'.$i].'"></th>';
echo '</tr>';
$cont++;
}
echo '</tr>';
echo '</table>';
echo '<input type="hidden" name="option1" value="wr">';
echo '<input type="hidden" name="wr" value="yes">';
echo '<input type="hidden" name="endpoint" value="'.$endpoint.'">';
echo '<center><input type="submit" value="Update" class="btn"></center></form><center>';
if(!empty($_POST['wr'])){
for($i=0; $i<18 ; $i++){
if (!empty($_POST['r'.$i])){
$cmd = '/wr/bin/wr_phytool '.$_POST['endpoint'].' wr '.dechex($i).' '.$_POST['r'.$i].'';
$output=shell_exec($cmd);
echo $endpoint.':R'.$i.' modified';
}
}
}
// User wants to enable transmission on endpoint
} else if (!strcmp($option1, "txcal1")){
$output=shell_exec('/wr/bin/wr_phytool '.$endpoint.' txcal 1');
echo $endpoint.' is now transmitting calibration';
// User wants to disable transmission on endpoint
} else if(!strcmp($option1, "txcal0")){
$output=shell_exec('/wr/bin/wr_phytool '.$endpoint.' txcal 0');
echo $endpoint.' stopped transmitting calibration';
// User wants to lock endpoint
} else if(!strcmp($option1, "lock")){
$output=shell_exec('/wr/bin/wr_phytool '.$endpoint.' rt lock');
echo 'Locking finished';
// User wants to make endpoint master
} else if(!strcmp($option1, "master")){
$output=shell_exec('/wr/bin/wr_phytool '.$endpoint.' rt master');
echo 'Mastering finished' ;
// User wants to make endpoint grandmaster
} else if(!strcmp($option1, "gm")){
$output=shell_exec('/wr/bin/wr_phytool '.$endpoint.' rt gm');
echo 'Grandmastering finished' ;
} else if(!strcmp($option1, "hal_conf")){
}
}
function wr_show_endpoint_rt_show(){
$output=shell_exec('/wr/bin/wr_phytool wr0 rt show');
$rts = nl2br($output);
echo $rts;
/*//Show RTS State Dump
$output=shell_exec('/wr/bin/wr_phytool wr0 rt show');
$rts = explode(" ", $output);
echo "<table border='1' align='center' vspace='1'>";
echo '<tr>';
echo '<th>Endpoint</th>';
echo '<th>Setpoint</th>';
echo '<th>PS Current</th>';
echo '<th>PS loopback</th>';
echo '<th>PS flags</th>';
echo '</tr>';
$cont = 0;
//First line
echo '<tr>';
echo '<th>wr'.$cont.'</th>';
echo '<th>'.$rts[14].'</th>';
echo '<th>'.$rts[14+7].'</th>';
echo '<th>'.$rts[14+16].'</th>';
echo '<th>'.$rts[14+22].'</th>';
echo '</tr>';
$cont++;
for($op = 39; $op < 300; $op=$op+30){
echo '<tr>';
echo '<th>wr'.$cont.'</th>';
echo '<th>'.$rts[$op].'</th>';
echo '<th>'.$rts[($op+9)].'</th>';
echo '<th>'.$rts[($op+18)].'</th>';
echo '<th>'.$rts[($op+27)].'</th>';
echo '</tr>';
$cont++;
}
for($op = 310; $op < 500; $op=$op+29){
echo '<tr>';
echo '<th>wr'.$cont.'</th>';
echo '<th>'.$rts[$op-2].'</th>';
echo '<th>'.$rts[($op+7)].'</th>';
echo '<th>'.$rts[($op+16)].'</th>';
echo '<th>'.$rts[($op+25)].'</th>';
echo '</tr>';
$cont++;
}
echo '</table>';*/
}
/*
* It returns the max. filesize that can be upload to the switch.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
*
*
*/
function wrs_php_filesize(){
$size=shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'");
$size=substr($size, 0, -2);
echo $size;
}
/*
* It loads binaries to the FPGA, LM32 and firmware folder.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* It runs:
* load-virtex for loading .bin to the FPGA
* load-lm32 for loading .bin to the lm32 professor
*
*
*
*/
function wrs_load_files(){
// Loading and executing binary file with load-virtex
if (!empty($_FILES['fpgafile']['name'])){
$uploaddir = '/tmp/';
$uploadfile = $uploaddir . basename($_FILES['fpgafile']['name']);
echo '<pre>';
if ((!strcmp(extension($_FILES['fpgafile']['name']), "bin")) && move_uploaded_file($_FILES['fpgafile']['tmp_name'], $uploadfile)) {
echo "<center>File is valid, and was successfully uploaded.</center>\n";
print "</pre>";
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";
}
// Loading and executing binary file with load-lm32
} else if (!empty($_FILES['lm32file']['name'])){
$uploaddir = '/tmp/';
$uploadfile = $uploaddir . basename($_FILES['lm32file']['name']);
echo '<pre>';
if ((!strcmp(extension($_FILES['lm32file']['name']), "bin")) && move_uploaded_file($_FILES['lm32file']['tmp_name'], $uploadfile)) {
echo "<center>File is valid, and was successfully uploaded.</center>\n";
print "</pre>";
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";
}
// Loading and copying binary file to /wr/lib/firmware folder on the switch.
} else if (!empty($_FILES['file']['name'])){
$uploaddir = '/wr/lib/firmware/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo '<pre>';
if ((!strcmp(extension($_FILES['file']['name']), "bin")) && move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "<center>File is valid, and was successfully uploaded to firmware folder\n";
} else {
echo "<center>File is not valid, please upload a .bin file</center>\n";
}
print "</pre>";
} else if (!empty($_POST["size"])){
php_file_transfer_size(htmlspecialchars($_POST["size"]));
}
}
/*
* Used for halting, rebooting and mounting partitions as read-only or
* writable on switch.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* Used for halting, rebooting and mounting partitions as read-only or
* writable on switch.
*
*
*/
function wrs_management(){
$cmd = htmlspecialchars($_POST["cmd"]);
if(!strcmp($cmd, "halt")){
echo '<br><br><br></be>System is halting';
$output = shell_exec($cmd);
}else if (!strcmp($cmd, "reboot")){
echo '<br><br><br>System is rebooting. Please wait 30 seconds.';
$output = shell_exec($cmd);
}else if (!strcmp($cmd, "rw")){
$output = shell_exec("/wr/bin/wrfs_mnt.sh rw");
echo '<br><br><br>Partition is now writable';
}else if (!strcmp($cmd, "ro")){
$output = shell_exec("/wr/bin/wrfs_mnt.sh ro");
echo '<br><br><br>Partition is now READ-ONLY';
}else if (!strcmp($cmd, "size")){
php_file_transfer_size(htmlspecialchars($_POST["size"]));
}else if (!strcmp($cmd, "change")){
modify_switch_mode();
$mode = check_switch_mode();
echo '<br><br><br>Switch is now '.$mode;
}
}
/*
* This function configures the PTP daemon.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* It configures PTP daemon:
* - By default (-A -c)
* - By changing the following values:
*
*
*/
function wrs_ptp_configuration(){
echo '<center>';
if(!empty($_POST["b"])){
$cmd .= " -b ".htmlspecialchars($_POST["b"]);
echo '<br>Network Interface binded to '.htmlspecialchars($_POST["b"]);
}
if (!empty($_POST["u"])){
$cmd .= " -u ".htmlspecialchars($_POST["u"]);
echo '<br>Unicast sent to '.htmlspecialchars($_POST["u"]);
}
if (!empty($_POST["i"])){
$cmd .= " -i ".htmlspecialchars($_POST["i"]);
echo '<br>PTP Domain number is now '.htmlspecialchars($_POST["i"]);
}
if (!empty($_POST["n"])){
$cmd .= " -n ".htmlspecialchars($_POST["n"]);
echo '<br>Announce Interval set to '.htmlspecialchars($_POST["n"]);
}
if (!empty($_POST["y"])){
$cmd .= " -y ".htmlspecialchars($_POST["y"]);
echo '<br>Sync Interval set to '.htmlspecialchars($_POST["y"]);
}
if (!empty($_POST["r"])){
$cmd .= " -r ".htmlspecialchars($_POST["r"]);
echo '<br>Clock accuracy set to '.htmlspecialchars($_POST["r"]);
}
if (!empty($_POST["v"])){
$cmd .= " -v ".htmlspecialchars($_POST["v"]);
echo '<br>Clock Class is now set to '.htmlspecialchars($_POST["v"]);
}
if (!empty($_POST["p"])){
$cmd .= " -p ".htmlspecialchars($_POST["p"]);
echo '<br>Priority changed to '.htmlspecialchars($_POST["p"]);
}
if ((!empty($_POST["daemongroup"])) && (!strcmp(htmlspecialchars($_POST["daemongroup"]),"On"))){
$cmd = shell_exec("/wr/bin/ptpd -A ");
echo '<center>PTPd enabled with default values!</center>';
}
if ((!empty($_POST["daemongroup"])) && (!strcmp(htmlspecialchars($_POST["daemongroup"]),"Off"))){
$cmd = shell_exec("killall ptpd");
echo '<center>PTPd stopped!</center>';
}
if(!empty($cmd)){
shell_exec("killall ptpd");
$ptp_command = "/wr/bin/ptpd -c ".$cmd. " > /dev/null 2>&1 &";
$output = shell_exec($ptp_command);
echo '<center>PTP initialized.</center>';
}
echo '</center>';
}
/*
* Checks whether $WRS_MANAGEMENT exists with the wr_management program
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* Checks whether $WRS_MANAGEMENT exists, if not, it points to the
* program by default (/wr/bin/wr_management)
*
*
*/
function wrs_env_sh(){
$output = shell_exec("echo $WRS_MANAGEMENT");
if(file_exists($output)){
$sh=$output;
}else{
$sh="/wr/bin/wr_management";
}
return $sh;
}
function wrs_vlan_configuration($input){
//Stop previous daemon and delete configuration file.
shell_exec('killall wrsw_rtud_new');
shell_exec('rm /tmp/vlan.conf');
$wrsw_rtud= '/wr/bin/wrsw_rtud_new -w 1 ';
for ($id=0; $id<18; $id++){
$wrsw_rtud .= $input[$id].' ';
//echo 'Endpoint '.$id.' added to VLAN'.$input[$id];
//echo '<br>';
shell_exec( 'echo '.$input[$id].' >>/tmp/vlan.conf');
}
$wrsw_rtud .= " > /dev/null 2>&1 &";
shell_exec($wrsw_rtud);
}
/*
* It gets the text that the help window should desplay.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
*
*/
function wrs_vlan_display(){
$rtu_running=shell_exec('ps aux | grep -c wrsw_rtud_new');
$rtu_running=(int)$rtu_running;
if($rtu_running >2){
$vlan_config = shell_exec('cat /tmp/vlan.conf');
echo "<br><table border='1' align='center' class='altrowstable' id='alternatecolor'>";
echo '<tr><td><b><center>Current Configuration </center></b></td></tr>';
echo '<tr><th><center>'.$vlan_config.'</center></th></tr>';
echo '</tr></table><br>';
}
}
function wrs_display_help($help_id, $name){
if(!strcmp($help_id, "dashboard")){
$message = "<p>
<table border=0 align=center>
<tr>
<td><img src='./img/master.png' width='20' ></td>
<td>The violet connector means that the endpoint is master</td>
</tr>
<tr>
<td><img src='./img/slave.png' width='20'></td>
<td>The blue connector means that the endpoint is slave</td>
</tr>
<tr>
<td><img src='./img/linkdown.png' width='20'></td>
<td>The gray connector means that the endpoint is not connected</td>
</tr>
<tr>
<td><img src='./img/unlocked.png' width='20'></td>
<td>The unlocked icon means that the endpoint is not locked.</td>
</tr>
<tr>
<td><img src='./img/locked.png' width='20'></td>
<td>The locked icon means that the endpoint is locked.</td>
</tr>
<tr>
<td><img src='./img/check.png' width='20'></td>
<td>The green check icon means that the endpoint is calibrated.</td>
</tr>
<tr>
<td><img src='./img/uncheck.png' width='20'></td>
<td>The red cross icon means that the endpoint is not calibrated.</td>
</tr>
</table>
</p>";
} else if (!strcmp($help_id, "load")){
$message = "<p>Loading files: <br>
- <b>Load FPGA File</b>: Loads a .bin file for the gateware on the FPGA.<br>
- <b>Load LM32 File</b>: Loads a .bin file into the lm32 processor.<br>
- <b>Load firmware</b>: It moves a binary file into the /wr/lib/firmware folder<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, "endpoint")){
$message = "<p>It is used to configure each point of the switch with different parameters as well as wrs_phytool program does. <br>
First <b>select an enpoint</b>. <br>
Then, select an option from the list: <br>
- <b>Enable Calibration Transmission</b>: enables calibration transmission on endpoint<br>
- <b>Disable Calibration Transmission</b>: disables calibration transmission on endpoint<br>
- <b>See registers</b>: displays each endpoint registers (R0-R16) <br>
- <b>Modify registers</b>: used to modify endpoint registers (R0-R16) <br>
- <b>Lock endpoint</b>: used to lock endpoint <br>
- <b>Make switch master</b>: Switch works as master <br>
- <b>Make switch grandmaster</b>: Switch works as grandmaster<br>
</p>";
} else if (!strcmp($help_id, "login")){
$message = "<p>login</p>";
} else if (!strcmp($help_id, "logout")){
$message = "<p>logout</p>";
} else if (!strcmp($help_id, "management")){
$message = "<p>
Options: <br>
- <b>Change mode:</b> It changes switch mode to Master/GrandMaster <br>
- <b>Reboot switch</b>: it reboots the switch <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")){
$message = "<p>The update button is used to stop or run the ptp daemon. It runs with the <b>default options (-A -c)</b> <br>
<b>If you want to run a ptp daemon with a specific configuration, use the text boxes and the 'Submit Configuration' button</b>. <br></p>";
} else if (!strcmp($help_id, "vlan")){
$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;
}
/*
* Obtains the file extension that will be loaded into the switch.
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
*
*/
function extension($filename){
return substr(strrchr($filename, '.'), 1);
}
/*
* Obtains the content of wrsw_hal_file
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* @return $file: string containing endpoints master/slave
*
*/
function parse_wrsw_hal_file(){
$file = shell_exec('cat /wr/etc/wrsw_hal.conf | grep wr_');
$file = str_replace("mode =", "", $file);
$file = str_replace('"', "", $file);
$file = str_replace(';', "", $file);
$file = str_replace('wr_', "", $file);
$file = explode(" ", $file);
return $file;
}
/*
* Obtains the content the switch mode from wrsw_hal.conf file
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* @return true for GrandMaster mode, false for Master mode.
*
*/
function check_switch_mode(){
$status = shell_exec("cat /wr/etc/wrsw_hal.conf | grep -c GrandMaster");
if($status>0){
return "GrandMaster";
} else {
return "Master";
}
}
/*
* Obtains the current mode of the switch from wrsw_hal.conf file
* and changes it from master to Grandmaster and vicecersa
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
*
*/
function modify_switch_mode(){
if (!strcmp(check_switch_mode(), "GrandMaster")){
$cmd = 'sed -i "s/mode = \"GrandMaster\"/mode = \"Master\"/g" /wr/etc/wrsw_hal.conf';
}else{
$cmd = 'sed -i "s/mode = \"Master\"/mode = \"GrandMaster\"/g" /wr/etc/wrsw_hal.conf';
}
shell_exec($cmd);
}
function wrs_modify_endpoint_mode($endpoint, $mode){
(!strcmp($mode, "master")) ? $new_mode = "wr_slave" : $new_mode = "wr_master";
if($endpoint>0 && $endpoint<19 && (((!strcmp($mode, "slave"))) || ((!strcmp($mode, "master"))))){
$file = "/wr/etc/wrsw_hal.conf";
$lines = file($file);
$output = "";
$count = 0;
$end_aux = $endpoint;
$endpoint = 'wr'.($endpoint-1).' =';
$found = false;
foreach($lines as $line_num => $line)
{
if(substr_count($line, $endpoint)>0){
$found = true;
}
if($found)$count++;
if($count==6){
$output.=' mode = "'.$new_mode.'";'."\n";
$count = 0;
$found = false;
}else{
$output.=$line;
}
}
//We save the changes in a temporarely file in /tmp
$file = fopen("/tmp/wrsw_hal.conf","w+");
fwrite($file,$output);
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/wrsw_hal.conf', '/wr/etc/wrsw_hal.conf');
echo '<br><br><br><br><br><br><br><br><center>Endpoint wr'.$end_aux.' is now '.$new_mode.'</center>';
}else{
echo '<br>Wrong parameters for endpoint-mode';
}
}
function session_is_started(){
ob_start();
$login_url = "./index.php";
if (!isset($_SESSION['myusername'])) {
echo '<br><br><br><center>Please <a href="' . $login_url . '">login.</center></a>';
exit;
}
}
?>
<?php ob_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>White-Rabbit Local Management Tool</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<link href="css/style.css" rel="stylesheet" type="text/css">
<!-- Javascript goes in the document HEAD -->
<script type="text/javascript">
function altRows(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
if(i % 2 == 0){
rows[i].className = "evenrowcolor";
}else{
rows[i].className = "oddrowcolor";
}
}
}
}
window.onload=function(){
altRows('alternatecolor');
}
</script>
<script type="text/javascript">
function showPopup(url) {
newwindow=window.open(url,'name','height=250,width=520,top=200,left=300,resizable');
if (window.focus) {newwindow.focus()}
}
</script>
</head>
<?php include 'functions.php' ?>
<html>
<head>
<title>Help Menu</title>
</head>
<body bgcolor="#FFFF99">
<h1><center>Help</center></h1>
<hr>
<?php
wrs_display_help($_GET['help_id'],"");
?>
</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 shell_exec("rm /tmp/ports.conf"); 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">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>';
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php'; ?>
</div>
</div>
</div>
</body>
</html>
server.document-root = "/var/www"
server.port = 80
#server.username = "root"
#server.groupname = "root"
## modules to load
# at least mod_access and mod_accesslog should be loaded
# all other module should only be loaded if really neccesary
# - saves some time
# - saves memory
server.modules = (
"mod_rewrite",
"mod_redirect",
# "mod_alias",
"mod_access",
# "mod_cml",
# "mod_trigger_b4_dl",
# "mod_auth",
# "mod_status",
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
# "mod_evhost",
# "mod_userdir",
"mod_cgi",
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
"mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png",
".css" => "text/css"
)
#### CGI module
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
"/admin" => "",
"/admindb" => "",
"/confirm" => "",
"/create" => "",
"/edithtml" => "",
"/listinfo" => "",
"/options" => "",
"/private" => "",
"/rmlist" => "",
"/roster" => "",
"/subscribe" => "" )
#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# (
# "socket" => "/tmp/php-fastcgi.socket",
# "bin-path" => "/usr/bin/php"
# )
# )
# )
#### url handling modules (rewrite, redirect, access)
#url.rewrite = ( "^/$" => "/server-status" )
#url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )
#### both rewrite/redirect support back reference to regex conditional using %n
#$HTTP["host"] =~ "^www\.(.*)" {
# url.redirect = ( "^/(.*)" => "http://%1/$1" )
#}
static-file.exclude-extensions = ( ".cgi", ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html", "index.php" )
$HTTP["host"] == "www2.example.org" {
server.document-root = "/var/www/"
$HTTP["url"] =~ "^/download/" {
dir-listing.activate = "enable"
}
}
#### accesslog module
accesslog.filename = "/var/log/access_lighttpd.log"
############# experimentos ##################
#url.rewrite = ( "^/([a-z]+)/([a-z]+)(\?*)(.*)" => "/index.html?url=$2&$4" )
url.rewrite = ("(css|files|img|js)/(.*)" => "/$1/$2")
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"broken-scriptfilename" => "enable"
# )),
# "/cgi-bin/" =>
# ((
# "socket" => "/tmp/php.socket1",
# "bin-path" => "/var/www/test.cgi",
# "check-local" => "disable",
# "max-procs" => 1
)))
#### compress module
#compress.cache-dir = "/tmp/lighttpd_tmp/"
#compress.filetype = ("text/plain", "text/html", "text/css", "image/png")
## where to upload files to, purged daily.
server.upload-dirs = ( "/tmp" )
<?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">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">
<tr>
<th><FORM method="POST" ENCTYPE="multipart/form-data" >
<INPUT type=file name="fpgafile" >
<INPUT type=submit Value="Load FPGA bin" class="btn" >
<INPUT type=hidden name=MAX_FILE_SIZE VALUE=<?php wrs_php_filesize();?>000>
</FORM></th>
</tr>
<tr>
<th ><FORM method="POST" ENCTYPE="multipart/form-data">
<INPUT type=file name="lm32file" >
<INPUT type=submit value="Load lm32 bin" class="btn">
<INPUT type=hidden name=MAX_FILE_SIZE VALUE=<?php wrs_php_filesize();?>000>
</FORM></th>
</tr>
<tr>
<th ><FORM method="POST" ENCTYPE="multipart/form-data">
<INPUT type=file name="file" >
<INPUT type=submit value="Load firmware" class="btn" >
<INPUT type=hidden name=MAX_FILE_SIZE VALUE= <?php wrs_php_filesize();?>000>
</FORM></th>
</tr>
</table>
<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 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>';
?>
</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">Login <a href='help.php?help_id=login' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php
ob_start();
$message="";
if(count($_POST)>0) {
$users = shell_exec('cat /etc/users');
$users = explode(" ", $users);
$username = $_POST["login"];
$password = $_POST["password"];
if ((!strcmp($username, "root")) && (!strcmp($password, ""))){
session_start();
$_SESSION["myusername"] = $username;
echo 'Logged in as '.$_SESSION["myusername"];
header('Location: index.php');
}else{
echo 'Invalid Username or Password';
}
}
//if(isset($_SESSION["user_id"])) {
//header("Location:index.php");
?>
</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">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();
unset($_SESSION["myusername"]);
unset($_SESSION["mypassword"]);
echo '<br><br><center><h3>Logged out</h3></center>';
header('Location: index.php');
?>
</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']=""; ?>
<table border="0" align="center">
<tr>
<form method="post">
<th><center>Switch Mode: (<?php $str = check_switch_mode(); echo $str; ?>) </center><input type="hidden" name="cmd" value="change"></th>
<th><input type="submit" value="Change Mode" class="btn"></th>
</form>
</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>
<form method="post">
<th><center>Reboot system: </center><input type="hidden" name="cmd" value="reboot"></th>
<th><input type="submit" value="Reboot switch" class="btn"></th>
</form>
</tr>
</tr><th> </th><th> </th><tr></tr><th> </th><th> </th><tr>
<!--<tr>
</form>
<form method="post">
<th><center>Mount partition as writable: </center><input type="hidden" name="cmd" value="rw"></th>
<th><input type="submit" value="Remount" class="btn"></th>
</form>
</tr>
<tr>
</form>
<form method="post">
<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><th> </th><th> </th><tr></tr><th> </th><th> </th><tr>
<tr>
<form method="post">
<th>Change PHP File Size Upload: <INPUT type="text" name="size" > </th>
<input type="hidden" name="cmd" value="size">
<th><input type="submit" value="Change" class="btn"></th>
</form>
</tr>
</table>
<?php
wrs_change_wrfs("rw");
wrs_management();
//wrs_check_writeable();
wrs_change_wrfs("ro");
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<ul>
<li><a href="index.php"> Dashboard </a></li>
<?php
//session_start();
if (!isset($_SESSION['myusername'])) {
echo '</ul><br><hr>';
echo '<div class="login">
<h3>Login</h3>
<form method="post" action="login.php">
<p><input type="text" name="login" value="" placeholder="Username"></p>
<p><input type="password" name="password" value="" placeholder="Password"></p>
<!--<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
Remember me on this computer
</label>
</p>-->
<p class="submit"><input type="submit" name="commit" value="Login" class="btn"></p>
</form>
</div>';
}else{
//The rest of the menu for logged users
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="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>';
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>';
echo '<a href="./logout.php">(logout)</a>';
}
?>
<hr>
<?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 Mode Configuration <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() ?>
<?php
$endpoint = $_GET["wr"];
$mode = $_GET["mode"];
wrs_change_wrfs("rw");
wrs_modify_endpoint_mode($endpoint, $mode);
wrs_change_wrfs("ro");
?>
<hr>
<FORM align="right" action="endpointmode.php" method="post">
<INPUT type="submit" value="Back" class="btn">
</FORM>
</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">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">
<tr>
<th align=left>PTP Daemon: </th>
<th><input type="radio" name="daemongroup" value="On" <?php echo (wrs_check_ptp_status()) ? 'checked' : ''; ?> > On <br>
<input type="radio" name="daemongroup" value="Off" <?php echo (wrs_check_ptp_status()) ? '' : 'checked'; ?> > Off <br>
<th><INPUT type="submit" value="Update" class="btn"></th>
</tr>
</table>
</FORM>
<FORM method="POST">
<table border="0" align="center">
<tr>
<th align=left>Network Interface Binding: </th>
<th><INPUT type="text" name="b" ></th>
</tr>
<tr>
<th align=left>Unicast to Address: </th>
<th><INPUT type="text" name="u" ></th>
</tr>
<tr>
<th align=left>PTP Domain Number: </th>
<th><INPUT type="text" name="i" ></th>
</tr>
<tr>
<th align=left>Announce Interval: </th>
<th><INPUT type="text" name="n" ></th>
</tr>
<tr>
<th align=left>Sync Interval: </th>
<th><INPUT type="text" name="y" ></th>
</tr>
<tr>
<th align=left>Clock Accuracy: </th>
<th><INPUT type="text" name="r" ></th>
</tr>
<tr>
<th align=left >Clock Class: </th>
<th><INPUT type="text" name="v" ></th>
</tr>
<tr>
<th align=left>Priority: </th>
<th><INPUT type="text" name="p" ></th>
<th><INPUT type="submit" value="Submit Configuration" class="btn"></th>
</tr>
</table>
</FORM>
<?php
wrs_ptp_configuration();
?>
</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">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>
<?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">White-Rabbit Switch Console <a href='help.php?help_id=console' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<FORM action="terminal.php" method="POST" accept-charset="UTF-8">
Unix Command: <input type="text" name="cmd">
<input type="submit" value="Enter" class="btn">
</FORM>
<?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"]);
// 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>'.$_SESSION["pwd"].'$:'.$cmd.'<br>'.$output.'</p> </div></div>';
wrs_change_wrfs("ro");
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php
session_start();
if (!isset($_SESSION['myusername'])) {
echo '<ul>
<li><a href="index.php"> Dashboard </a></li>
<li><a href="contact.php"> Contact Us </a></li>
</ul>';
}else{
echo '<ul>
<li><a href="index.php"> Dashboard </a></li>
<li><a href="ptp.php"> PTP 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>';
}
?>
<?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">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">';
echo '<tr><th>Endpoint</th><th>VLANs</th></tr>';
for($i = 0; $i < 18; $i++){
echo '<tr>';
echo '<td><center><b>wr'.($i+1).'</b></center></td>';
//Show the Vlan option button
echo '<td>';
echo '<form method=POST><div>
<select name='.($i).'>';
for($op = 0; $op < 18; $op++){
echo '<option class="btn" value="'.($op+1).'"><center>Vlan'.($op+1).'</center></option>';
}
echo '</select>';
echo '</td>';
}
echo '<input type="hidden" value=cmd name=cmd>';
echo '<p align="right"><input type="submit" value="Add VLANs" class="btn" ></p>
</form>';
echo '</tr>';
echo '</table>';
//Parse input and run the command
if (!empty($_POST['cmd'])){
$input = $_POST;
wrs_vlan_configuration($input);
}
wrs_vlan_display();
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
......@@ -10,3 +10,4 @@ wmapper
shw_ver
wr_date
fix_tai_offset
wr_management
\ No newline at end of file
TOOLS = rtu_stat wr_mon wr_phytool spll_dbg_proxy load-lm32 load-virtex com
TOOLS += mapper wmapper shw_ver wr_date
TOOLS += mapper wmapper shw_ver wr_date wr_management
# # Standard stanza for cross-compilation (courtesy of the linux makefile)
......@@ -41,6 +41,9 @@ rtu_stat: rtu_stat.o
wr_mon: wr_mon.o term.o
${CC} -o $@ $^ $(LDFLAGS)
wr_management: wr_management.o term.o
${CC} -o $@ $^ $(LDFLAGS)
wr_phytool: wr_phytool.o ../wrsw_hal/rt_client.o
${CC} -o $@ $^ $(LDFLAGS)
......
/*
* wr_management.c
*
* Obtains the information that is displayed by the local management tool
*
* Created on: Nov 11, 2013
* Authors:
* - José Luis Gutiérrez (jgutierrez@ugr.es)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License...
*/
#include <stdio.h>
#include <stdlib.h>
#include <minipc.h>
#include "term.h"
#define PTP_EXPORT_STRUCTURES
#include "ptpd_exports.h"
#include "hal_client.h"
hexp_port_list_t port_list;
static struct minipc_ch *ptp_ch;
void print_args(int argc, char *argv[])
{
printf("argc=%d: ",argc);
while(argc>0)
{
printf("%s, ",argv[0]);
argc--;
argv++;
}
printf("\n");
}
void init(int usecolor)
{
halexp_client_init();
ptp_ch = minipc_client_create("ptpd", 0);
if (!ptp_ch)
{
fprintf(stderr,"Can't establish WRIPC connection "
"to the PTP daemon!\n");
exit(-1);
}
term_init(usecolor);
halexp_query_ports(&port_list);
}
void show_ports()
{
int i, j;
time_t t;
struct tm *tm;
char datestr[32];
time(&t);
tm = localtime(&t);
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", tm);
for(i=0; i<18;i++)
{
char if_name[10], found = 0;
hexp_port_state_t state;
snprintf(if_name, 10, "wr%d", i);
for(j=0;j<port_list.num_ports;j++)
if(!strcmp(port_list.port_names[j], if_name)) { found = 1; break; }
if(!found) continue;
halexp_get_port_state(&state, if_name);
if(state.up)
term_cprintf(C_GREEN, "up ");
else
term_cprintf(C_RED, "down ");
switch(state.mode)
{
case HEXP_PORT_MODE_WR_MASTER:
term_cprintf(C_WHITE, "Master ");
break;
case HEXP_PORT_MODE_WR_SLAVE:
term_cprintf(C_WHITE, "Slave ");
break;
}
if(state.is_locked)
term_cprintf(C_GREEN, "Locked ");
else
term_cprintf(C_RED, "NoLock ");
if(state.rx_calibrated && state.tx_calibrated)
term_cprintf(C_GREEN, "Calibrated \n");
else
term_cprintf(C_RED, "Uncalibrated \n");
}
}
int track_onoff = 1;
void show_screen()
{
term_clear();
//term_pcprintf(1, 1, C_BLUE, "WR Switch Sync Monitor v 1.0 [q = quit]");
show_ports();
//show_servo();
fflush(stdout);
}
int main(int argc, char **argv)
{
int usecolor = 1;
if(argc > 1){
if(!strcmp(argv[1], "ports")){
usecolor = 0;
init(usecolor);
setvbuf(stdout, NULL, _IOFBF, 4096);
if(term_poll(500))
{
int rval;
track_onoff = 1-track_onoff;
minipc_call(ptp_ch, 200, &__rpcdef_cmd,
&rval, PTPDEXP_COMMAND_TRACKING,
track_onoff);
}
show_screen();
term_restore();
setlinebuf(stdout);
printf("\n");
}else if (!strcmp(argv[1], "fan")){
}else{
printf("\nParam required: ");
printf("\nProgram usage: %s [param]", argv[0]);
printf("\tports\t-->\tWRS ports state\n");
}
}else{
printf("\nParam required: ");
printf("\nProgram usage: %s [param]", argv[0]);
printf("\tports\t-->\tWRS ports state\n");
}
return 0;
}
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