Commit cfdbd93f authored by Alessandro Rubini's avatar Alessandro Rubini

Merge branch 'guti-140618-rebased'

parents c565a117 86634428
......@@ -109,6 +109,8 @@ WR
: White Rabbit.
WRS
: White Rabbit Switch.
WMI
: Web Management Interface
\clearpage
......@@ -206,6 +208,8 @@ The device is factory configured with the following default settings:
* SSH user: **root**
* SSH password: (empty/just press enter)
* Boot method: from Nandflash firmware
* Web Management Interface user: **admin**
* Web Management Interface password: (empty)
Quick Startup
......@@ -334,6 +338,26 @@ by the one in your subnetwork.
![Putty - SSH connection](putty-SSH.png)
Login using the Web Management Interface
-----------------------
If you want to access and manage the [WRS] using the web interface, it is necessary to connect the [WRS] manager ethernet port to your local network.
The access should be carried out by a network browser (Mozilla Firefox and Google Chrome supported) as it follows:
1. Open your browser and type the IP address (i.e. 192.168.1.50) of the [WRS]. By default, the network IP configuration
is provided by the DHCP server in the same network and can be retrieved from it.
![Web Management Interface - Login](wwwlogin.png)
2. After accessing the [WMI], you should enter the web interface user and password, which is not
same for the SSH connection, otherwise you will be only able to see the Dashboard info.
By default the user is **admin** with no password. For this reason it is strongly recommended to change the password.
In order to change the [WMI] password you just need to click on "**User: admin**" on the left side of the webpage.
You have to enter your username (**admin**), old password, new password and repeat the new password.
Once you submit the new password you will be redirected to the main screen and logged out.
After login:
-------------------
......@@ -354,6 +378,34 @@ The SFP ports are labeled from 1 to 18 on the front panel but their correspondin
network interface are named from `wr0` to `wr17`.
Web Management Interface Features:
-------------------
[WMI] is a web interface that allows the [WRS] management from a web browser. It displays the main configuration and status of the main services and programms that are available for the switch, such as endpoints' mode and calibration status, SFP calibration, PTP, SNMP, VLANs, etc. It acts as an abstraction layer between the back-end scritps and programs in */wr/bin/* folder, making the WR switch management easier for the user.
![Web Management Interface - Switch Management](wwwmanagement.png)
List of all the actions that can be performed by using the [WMI]:
- Display info: IP configuration, switch HW/SW/GW description, WR date, PPSi status, SNMP server status, NTP server status.
- Stop/run services: PPSi, WRSW_HAL, NTP.
- NTP server setup.
- Modify endpoint wr_master/wr_slave mode.
- VLAN setup.
- White-Rabbit timing.
- Modify maximum filesize of uploaded files to the switch.
- PPSi daemon configuration: clock class, clock accuracy, etc.
- Terminal simulation avoiding SSH connections.
- Login system.
- Modify login password.
- Load lm32 and FPGA binaries into the switch.
- Switch reboot.
- Backup and restore configuration files for services (PPSi, HAL, SNMP, etc).
- Restore configuration files from tarball.
- Flash firmware.
- Backup firmware.
Configurations
==================
......@@ -592,6 +644,7 @@ Features
* WRP daemon (node discovery, etc.)
* DHCP client
* SSH server
* Web Management Interface
* Python Support
* NTP Client/Relay/Server
* ARP/ DNS / EtherWake protocol
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="advance">
<div class="main">
<div class="page">
<div class="header" >
......
<?php include 'functions.php'; include 'head.php'; ?>
<body id="ptp">
<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">User Administration <a href='help.php?help_id=network' 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="left">
<form method="post">
<tr><th>Username: </th><th><INPUT type="text" name="user" value="admin" readonly></th></tr>
<tr><th>Old Password: </th><th><INPUT type="password" name="oldpasswd" > </th></tr>
<tr><th>New Password: </th><th> <INPUT type="password" name="newpasswd" > </th></tr>
<tr><th>Confirm Password: </th><th><INPUT type="password" name="confirmpasswd" > </th></tr>
<tr><th></th><th align="center"><input type="submit" value="Change Password" class="btn"></th></tr>
</form>
</table>
<?php
wrs_change_wrfs("rw");
//Change user password
$success=false;
if( empty($_POST['user'])){
echo '<br><br><br><p align=center>Please fill fields.<br></p>';
}else{
$saved_hash = shell_exec("cat ".$GLOBALS['phpusersfile']." | grep ".$_POST["user"]." | awk '{print $2}'");
$saved_hash = str_replace("\n","",$saved_hash);
$username = $_POST["user"];
$oldpassword = $_POST["oldpasswd"];
$newpasswd = $_POST["newpasswd"];
$confirmpasswd = $_POST["confirmpasswd"];
//First confirm old password
$salt="wrs4.0salt";
$pass = $oldpassword;
$hash = md5($pass); // md5 hash #1
$hash_md5 = md5($salt.$pass); // md5 hash with salt #2
$hash_md5_double = md5(sha1($salt.$pass)); // md5 hash with salt & sha1 #3
if (!strcmp($hash_md5_double, $saved_hash) && !strcmp($newpasswd, $confirmpasswd) && !strcmp($_POST["user"],$_SESSION['myusername'])){ //old password is correct && new and confirm are the same
//set the new one
$pass = $confirmpasswd;
$hash = md5($pass); // md5 hash #1
$hash_md5 = md5($salt.$pass); // md5 hash with salt #2
$hash_md5_double = md5(sha1($salt.$pass)); // md5 hash with salt & sha1 #3
//Save in file
//We save the changes in a temporarely file in /tmp
$old_value=$username." ".$saved_hash;
$new_value=$username." ".$hash_md5_double;
$output = shell_exec('cat '.$GLOBALS['phpusersfile'].' | sed -i "s/'.$old_value.'/'.$new_value.'/g" '.$GLOBALS['phpusersfile']); //replace password for the user
//$file = fopen("/etc/phpusers","w+");
//fwrite($file,$output);
//fclose($file);
$success=true;
echo '<br><br><br><p align=center>Password changed.<br></p>';
}else{
$success=false;
echo '<br><br><br><p align=center>Error changing password.<br></p>';
}
}
wrs_change_wrfs("ro");
if($success) header('Location: logout.php');
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="contact">
<div class="main">
<div class="page">
<div class="header" >
......@@ -16,16 +16,26 @@
</div>
<div class="rightpanel">
<div class="rightbody">
<h1 class="title">Contact</h1>
<h1 class="title">About</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>
<p><strong>WRSW OS: <?php $str = shell_exec("uname -r"); echo $str; ?> </strong></p>
<p><strong><?php $str = shell_exec("/wr/bin/shw_ver -g"); $str = str_replace("\n","<br>",$str);
$str=str_replace("Reading GW info","",$str); echo $str; ?></strong></p><p>&nbsp;</p>
<br>
<center><p align=right><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 align=right><strong>White-Rabbit Mailing List <a href="mailto:white-rabbit-dev@ohwr.org?subject=[White-Rabbit Switch Local Management Tool]">(white-rabbit-dev@ohwr.org)</a> </strong></p></center>
<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>
<br><br><br><br><br>
<center>
<IMG SRC="img/cern.jpg" WIDTH=80 ALT="CERN">
<IMG SRC="img/7s.png" WIDTH=80 ALT="Seven Solutions">
<IMG SRC="img/ugr.gif" WIDTH=140 ALT="University of Granada">
</center>
<br><br>
<p align=right><strong>Developers: </strong>Alessandro Rubini, Tomasz Wlostowski, Benoit Rat, Federico Vega, Grzegorz Daniluk, Maciej Lipinski, Jose Luis Gutierrez</p>
</div>
</div>
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2014 UGR (www.ugr.es)
* Copyright (C) 2014 7S (www.sevensols.com)
* Author: Jose Luis Gutierrez <jlgutierrez@ugr.es>
* Author: Benoit Rat <benoit@sevensols.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
}
hr {
border: none;
border-top: 1px dashed black;
height: 1px;
}
/*
* This work is part of the White Rabbit project
*
* Color scheme:
*
*
* Button:
*
* Light: #3A8AAF
* Dark: #002350
*
*
*
* Copyright (C) 2014 UGR (www.ugr.es)
* Copyright (C) 2014 7S (www.sevensols.com)
* Author: Jose Luis Gutierrez <jlgutierrez@ugr.es>
* Author: Benoit Rat <benoit@sevensols.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
......@@ -6,6 +26,8 @@ body {
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;
......@@ -28,7 +50,7 @@ h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, input, textarea {
}
.header-ports {
background-image: url(../img/header.jpg);
background-color:#ACD0DB;
height: 140px;
margin-top: 15px;
......@@ -83,6 +105,7 @@ h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, input, textarea {
padding: 25px 20px;
margin-right: -260px;
position: relative;
min-height:400px;
}
.leftpanel h2 {
font-size: 14px;
......@@ -108,9 +131,15 @@ h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, input, textarea {
color: #000000;
text-decoration: none;
}
.leftpanel ul li a:hover {
.leftpanel ul a:hover, .leftpanel ul.advance li a:hover {
color: #23b14d;
}
.leftpanel ul.advance li a {
color:grey;
margin-left:10px;
}
.rightpanel {
width: 540px;
float: left;
......@@ -136,19 +165,32 @@ h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, input, textarea {
border-bottom-style: dashed;
border-bottom-color: #cccccc;
}
.title a {
top: -20px;
position: relative;
width: 100%;
float: left;
}
.title a img {
width:20px;
}
.copyright {
border: 0px;
height: 1px;
width: 1px;
}
.footer {
background-image: url(../img/footer.jpg);
background-repeat: no-repeat;
background-position: left top;
/*background: #002350;*/
background:black;
width: 800px;
height: 77px;
float: left;
margin-bottom: 10px;
}
.footer p {
font-size: 11px;
line-height: 57px;
......@@ -159,63 +201,48 @@ h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, input, textarea {
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;
a, a:visited {
color: #002350;
}
.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;
a:hover {
color: #3A8AAF;
}
.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;
.btn {
background: #3A8AAF;
background-image: -webkit-linear-gradient(top, #3A8AAF, #002350);
background-image: -moz-linear-gradient(top, #3A8AAF, #002350);
background-image: -ms-linear-gradient(top, #3A8AAF, #002350);
background-image: -o-linear-gradient(top, #3A8AAF, #002350);
background-image: linear-gradient(to bottom, #3A8AAF, #002350);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
font-family: Arial;
color: #ffffff;
font-size: 12px;
padding: 1px 5px 2px 7px;
padding: 1px 6px;
text-decoration: none;
border:1px solid darkgrey;
min-height:20px;
}
.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);
.btn:hover {
background: #3A8AAF;
text-decoration: none;
}
/**
* Light: #3A8AAF
* Dark: #002350
**/
table.altrowstable {
font-family: verdana,arial,sans-serif;
font-size: 10px;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #a9c6c9;
......@@ -223,22 +250,47 @@ table.altrowstable {
}
table.altrowstable th {
border-width: 1px;
padding: 8px;
padding: 2px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstable td {
border-width: 1px;
padding: 8px;
padding: 4px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstabledash {
font-family: verdana,arial,sans-serif;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #a9c6c9;
border-collapse: collapse;
}
table.altrowstabledash th {
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstabledash td {
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: #a9c6c9;
}
table tr.sub{
color:white;
background-color:#3A8AAF;
}
.oddrowcolor{
background-color: #d4e3e5;
}
.evenrowcolor{
background-color: #c3dde0;
}
.tableheader {
background-color: #95BEE6;
color:white;
......@@ -254,3 +306,46 @@ font-weight: bold;
text-align: center;
width: 80%;
}
input {
padding:0px 1px;
}
form input.last {
min-height:22px;
margin: 20px auto;
margin-left: 30%; /**TODO: Bad Hack **/
}
#epcalib form {
width:90%;
margin: 0 auto;
}
#epcalib form table {
width:100%;
border:none;
}
#epcalib form table .empty, #epcalib form table .empty th{
background:none;
border:none;
height:2px;
}
#ptp #daemon {
width: 50%;
border-bottom: 1px dotted grey;
margin-bottom:10px;
padding-bottom:10px;
}
#ptp #daemon input.btn {
height: 22px;
width: 80px;
}
#management input.btn, #load input.btn {
width: 100px;
height: 22px;
}
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="management">
<div class="main">
<div class="page">
<div class="header" >
......@@ -16,46 +16,25 @@
</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>
<h1 class="title">VLAN Management <a href='help.php?help_id=firmware' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<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"])){
<?php
if(!strcmp($_GET['vlan'],"all")){ // Delete all vlans and free ports
shell_exec("/wr/bin/wrsw_vlans --clear");
}else{
shell_exec("/wr/bin/wrsw_vlans --rvid ".$_GET['vlan']." --del");
}
header('Location: vlan.php');
?>
......
download folder for system backups
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="endpoint">
<div class="main">
<div class="page">
<div class="header" >
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="epcalib">
<div class="main">
<div class="page">
<div class="header" >
......@@ -26,7 +26,7 @@
<?php
$file_init = 'global = {'."\n";
$file_init .= "\t".'sfp_database_path = "/wr/etc/sfp_database.conf";'."\n";
$file_init .= "\t".'sfp_database_path = "'.$GLOBALS['etcdir'].'sfp_database.conf";'."\n";
$file_init .= '};'."\n\n";
$file_init .= 'timing = {'."\n\n";
......@@ -54,7 +54,7 @@
// Timing values:
echo '<tr><th>Switch Timing Values</th></tr>';
echo '<tr class="sub"><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>';
......@@ -62,7 +62,8 @@
// port values:
for($i=0; $i<18; $i++){
echo '<tr><th>Endpoint '.($i+1).'</th></tr>';
echo '<tr class="empty"><th></th></tr>';
echo '<tr class="sub"><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>';
......@@ -73,9 +74,11 @@
}
echo '<input type="hidden" name="newconf" value="newconf">';
echo '</table>';
echo '<div>';
echo '<input type="hidden" name="newconf" value="newconf">';
echo '<input align="right" type="submit" value="Create new file & Reboot" class="btn">';
echo '</div>';
echo '</form>';
......@@ -138,7 +141,7 @@
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/wrsw_hal.conf', '/wr/etc/wrsw_hal.conf');
copy('/tmp/wrsw_hal.conf', $GLOBALS['etcdir'].'wrsw_hal.conf');
echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>';
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="epmode">
<div class="main">
<div class="page">
<div class="header" >
......@@ -23,9 +23,10 @@
<?php
//Load all
$modes = parse_wrsw_hal_file();
//$modes = parse_wrsw_hal_file();
$modes = parse_ppsi_conf_file();
echo '<table align=center border="1" class="altrowstable" id="alternatecolor">';
echo '<table align=center border="1" class="altrowstable" id="alternatecolor" width="50%">';
//echo '<tr><th><center>Endpoint</center></th><th><center>Mode</center></th></tr>';
for($i = 0; $i < 9; $i++){
echo '<tr>';
......@@ -47,24 +48,25 @@
?>
<br>
<br><br><br><br><br><br>
<hr>
<FORM align="right" method="post">
<input type="hidden" name="hal" value="hal">
<INPUT type="submit" value="Reboot Hal daemon" class="btn">
<INPUT type="submit" value="Restart PPSi" class="btn">
</FORM>
<?php
if (!empty($_POST["hal"])){
//We must relaunch ptpd too. (by default)
shell_exec("killall ppsi");
$ptp_command = "/wr/bin/ppsi > /dev/null 2>&1 &";
$output = shell_exec($ptp_command);
//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 &");
//shell_exec("killall wrsw_hal");
//shell_exec("/wr/bin/wrsw_hal -c ".$GLOBALS['etcdir']."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);
}
?>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body id="management">
<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">Firmware Management <a href='help.php?help_id=firmware' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<table border="0" align="center">
<tr>
<FORM method="POST" ENCTYPE="multipart/form-data" onsubmit="return confirm('Are you sure you want to upload and flash a new firmware?');">
<th ><INPUT type=file name="file" ></th>
<th><INPUT type=submit value="Flash Firmware" class="btn" ><INPUT type=hidden name=MAX_FILE_SIZE VALUE=<?php echo wrs_php_filesize();?>000></th>
</FORM>
</tr>
<!--
<tr></tr><tr></tr><tr>
<FORM method="POST" ENCTYPE="multipart/form-data" >
<th align=center>Download a backup of the entire Switch</th>
<th><INPUT type=submit value="Backup Firmware" class="btn"><input type="hidden" name="cmd" value="backup-wrs"></th>
</FORM>
</tr>
-->
<?php
//Include downloading and flashing from OHWR if file wr-switch-sw-v4.0-rc1-20140710_binaries.tar is available
//$ohwrlink="http://www.ohwr.org/attachments/download/3095/wr-switch-sw-v4.0-rc1-20140710_binaries.tar";
//echo '<tr></tr><tr></tr><tr><tr></tr><tr></tr><tr><tr></tr><tr></tr><tr>';
//echo ' <tr>
//<th >Download binaries from OHWR <FORM method="POST" onsubmit="return confirm("Are you sure you want to upload and flash a new firmware?");"></th>
//<th ><INPUT type=hidden name="cmd" value="remoteflash" >
//<INPUT type=submit value="Download&Flash Firmware from OHWR" class="btn" ></th>
//</FORM>
//</tr>';
?>
</table>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<hr>
<p align=center ><font color="red">NOTE: Flashing the switch with a wrong binary file might damage your device. <br>Please visit the
<A HREF="http://www.ohwr.org/projects/wr-switch-sw/files" TARGET="_new">OHR website</A> for more details.</font>
</p>
<hr>
<?php
wrs_change_wrfs("rw");
wrs_management();
wrs_change_wrfs("ro");
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php
//Global Variables
$etcdir="/usr/wr/etc/"; //configuration file folder for WRS
$snmpconf="snmpd.conf";
$ppsiconf="ppsi.conf";
$wrswhalconf="wrsw_hal.conf";
$sfpdatabaseconf="sfp_database.conf";
$wrdateconf="wr_date.conf";
$vlancolor = array("#27DE2A", "#B642A8", "#6E42B6", "#425DB6" , "#428DB6", "#4686B6", "#43B88B", "#42B65F", "#82B642", "#B6AE42", "#B67E42");
$MAX_PHP_FILESIZE = 40;
$phpusersfile="/usr/etc/phpusers";
$profilefile="/usr/etc/profile";
$phpinifile="/etc/php.ini";
$interfacesfile = "/usr/etc/network/interfaces";
/*
* Displays the current status of each enpoint.
......@@ -19,8 +32,16 @@ function wrs_header_ports(){
// Check whether $WRS_MANAGEMENT is set or we take the program
// by default.
if(!file_exists("/tmp/ports.conf")){
session_start();
if(empty($_SESSION['portsupdated'])){
$_SESSION['portsupdated'] = intval(shell_exec("date +%s"));
}
// Let's update endpoints info every 15 seconds.
$currenttime = intval(shell_exec("date +%s"));
$interval = $currenttime - $_SESSION['portsupdated'];
if(!file_exists("/tmp/ports.conf") || $interval>15){
$cmd = wrs_env_sh();
shell_exec("killall wr_management");
$str = shell_exec($cmd." ports");
......@@ -28,10 +49,11 @@ function wrs_header_ports(){
fwrite($fp, $str);
fclose($fp);
$ports = $str;
$_SESSION['portsupdated'] = intval(shell_exec("date +%s"));
}else{
$ports = shell_exec("cat /tmp/ports.conf");
}
$ports = explode(" ", $ports);
// We parse and show the information comming from each endpoint.
......@@ -41,7 +63,7 @@ function wrs_header_ports(){
echo "<table border='0' align='center' vspace='15'>";
echo '<tr>';
$cont = 0;
$cont = 1;
for($i=1; $i<18*4; $i=$i+4){
if (strstr($ports[($i-1)],"up")){
......@@ -92,33 +114,76 @@ function wrs_header_ports(){
*/
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>';
//Changing php filesize in case it is necessary
if(wrs_php_filesize()<$GLOBALS['MAX_PHP_FILESIZE']){php_file_transfer_size($GLOBALS['MAX_PHP_FILESIZE']);}
if(empty($_SESSION["utc"])){
$utc_exists = shell_exec("cat ".$GLOBALS['profilefile']." | grep -c TZ");
if($utc_exists){
$_SESSION["utc"]=shell_exec("cat ".$GLOBALS['profilefile']." | grep TZ | awk '{print $2}' | sed 's/TZ=//g'");
}else{
$_SESSION["utc"]="UTC";
}
}
echo "<table border='1' align='center' class='altrowstabledash' id='alternatecolor'>";
echo '<tr class="sub"><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 align=center><b><font color="darkblue">Hostname</font></b></th><th><center>'; $str = shell_exec("uname -n"); echo $str; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">Switch Mode</font></b> </th><th><center>'; $str = check_switch_mode(); echo $str; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">IP Address</font></b> </th><th><center>'; $ip = shell_exec("ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); echo $ip;
echo '(<a href="network.php">'; echo wrs_interface_setup(); echo '</a>)'; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">HW Address</font></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 align=center> <b><font color="darkblue">Kernel Version</font></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 '<tr><th align=center> <b><font color="darkblue">Firmware Version</font></b> </th><th><center> '; $str = shell_exec("/wr/bin/shw_ver | 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 '<tr><th align=center> <b><font color="darkblue">PCB Version</font></b> </th><th><center>'; $str = shell_exec("/wr/bin/shw_ver -p"); echo $str; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">FPGA</font></b> </th><th><center>'; $str = shell_exec("/wr/bin/shw_ver -f"); echo $str; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">Compiling Date</font></b> </th><th><center>'; $str = shell_exec("/wr/bin/shw_ver -c"); echo $str; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">White-Rabbit Date</font></b></th><th><center>'; $str = shell_exec("export TZ=".$_SESSION['utc']." /wr/bin/wr_date -n get"); echo str_replace("\n","<br>",$str); echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">PPSi</font></b> </th><th><center>'; echo wrs_check_ptp_status() ? '[<A HREF="ptp.php">on</A>]' : '[<A HREF="ptp.php">off</A>]'; echo '</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">Net-SNMP Server</font></b> </th><th><center>'; echo check_snmp_status() ? '[on] ' : '[off] '; echo '&nbsp;&nbsp;ver. '; echo shell_exec("snmpd -v | grep version | awk '{print $3}'");
echo '( port '; $str = shell_exec("cat ".$GLOBALS['etcdir']."snmpd.conf | grep agent | cut -d: -f3 | awk '{print $1}'"); echo $str; echo ')'; echo /*" <a href='help.php?help_id=snmp' onClick='showPopup(this.href);return(false);'> [OIDs]</a>*/"</center></th></tr>";
echo '<tr><th align=center> <b><font color="darkblue">NTP Server</font></b> </th><th><center> <A HREF="management.php">'; $str = check_ntp_server(); echo $str; echo '</A> '.$_SESSION['utc'].'</center></th></tr>';
echo '<tr><th align=center> <b><font color="darkblue">Max. Filesize Upload</font> </b></th><th><center>'; echo shell_exec("cat ".$GLOBALS['phpinifile']." | grep upload_max_filesize | awk '{print $3}'"); echo '</center></th></tr>';
echo '</table>';
}
function check_ntp_server(){
$output = "cat ".$GLOBALS['etcdir'].$GLOBALS['wrdateconf']. " | grep ntpserver | awk '{print $2}' ";
$output = shell_exec($output);
if(!strcmp($output, "")){
return "not set";
}else{
return $output;
}
}
function check_snmp_status(){
$output = intval(shell_exec("ps aux | grep -c snmpd"));
return ($output>2) ? 1 : 0;
}
function wrs_interface_setup(){
$interfaces = shell_exec('cat '.$GLOBALS['interfacesfile'].' | grep dhcp');
return (strcmp($interfaces[0],"#")) ? "dhcp" : "static";
}
/*
......@@ -163,7 +228,7 @@ function wrs_change_wrfs($m){
*
*/
function wrs_check_ptp_status(){
$output = intval(shell_exec("ps | grep -c ptpd"));
$output = intval(shell_exec("ps aux | grep -c ppsi"));
return ($output>2) ? 1 : 0;
}
......@@ -183,19 +248,24 @@ function php_file_transfer_size($size){
// We remove the blank space
$size=trim($size);
wrs_change_wrfs("rw");
// 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 = shell_exec("cat ".$GLOBALS['phpinifile']." | 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";
$cmd = "sed -i 's/upload_max_filesize = ".$prev_size."/upload_max_filesize = ".$size."M/g' ".$GLOBALS['phpinifile'];
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 = shell_exec("cat ".$GLOBALS['phpinifile']." | 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";
$cmd ="sed -i 's/post_max_size = ".$prev_size."/post_max_size = ".$size."M/g' ".$GLOBALS['phpinifile'];
shell_exec($cmd);
shell_exec("cat ".$GLOBALS['phpinifile']." >/usr/etc/php.ini"); //We store it in /usr/etc/php.ini copy. Just in case
wrs_change_wrfs("ro");
echo '<p align=center>File upload size changed to '.$size.'</p>';
//echo '<p align=center>File upload size changed to '.$size.'</p>';
}
/*
......@@ -239,9 +309,9 @@ function wr_endpoint_phytool($option1, $endpoint){
echo '</tr>';
echo '</table>';
if (!strcmp($_POST['update'], "yes")){
echo 'aki stamos!';
}
//if (!strcmp($_POST['update'], "yes")){
//echo 'aki stamos!';
//}
// User wants to modify endpoint's registers
} else if(!strcmp($option1, "wr")){
......@@ -388,9 +458,9 @@ function wr_show_endpoint_rt_show(){
*/
function wrs_php_filesize(){
$size=shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'");
$size=shell_exec("cat ".$GLOBALS['phpinifile']." | grep upload_max_filesize | awk '{print $3}'");
$size=substr($size, 0, -2);
echo $size;
return $size;
}
......@@ -452,21 +522,22 @@ function wrs_load_files(){
}
// Loading and copying binary file to /wr/lib/firmware folder on the switch.
// Loading and copying binary file to /tmp folder on the switch.
} else if (!empty($_FILES['file']['name'])){
$uploaddir = '/wr/lib/firmware/';
$uploaddir = '/tmp/';
$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";
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 tmp folder\n";
} else {
echo "<center>File is not valid, please upload a .bin file</center>\n";
}
print "</pre>";
echo "</pre>";
} else if (!empty($_POST["size"])){
php_file_transfer_size(htmlspecialchars($_POST["size"]));
header ('Location: load.php');
}
......@@ -503,13 +574,248 @@ function wrs_management(){
echo '<br><br><br>Partition is now READ-ONLY';
}else if (!strcmp($cmd, "size")){
php_file_transfer_size(htmlspecialchars($_POST["size"]));
header('Location: firmware.php');
}else if (!strcmp($cmd, "change")){
modify_switch_mode();
$mode = check_switch_mode();
echo '<br><br><br>Switch is now '.$mode;
header ('Location: management.php');
} else if (!empty($_FILES['file']['name'])){
$uploaddir = '/tmp/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo '<p align=center ><font color="red"><br>Upgrade procedure will take place after reboot.<br>Please do not switch off the device during flashing procedure.</font></p>';
rename($uploadfile, "/update/".($_FILES['file']['name']));
//Reboot switch
shell_exec("reboot");
} else {
echo "<center>Something went wrong. File was not uploaded.</center>\n";
}
echo "</pre>";
} else if (!strcmp($cmd, "remoteflash")){
echo '<p align=center>Downloading '.$ohwrlink.'</p>';
$filename="/tmp/wr-switch-sw-v4.0-rc1-20140710_binaries.tar";
$firmware="/update/wrs-firmware.tar";
$ohwrlink="http://www.ohwr.org/attachments/download/3095/wr-switch-sw-v4.0-rc1-20140710_binaries.tar";
file_put_contents($filename, file_get_contents($ohwrlink));
rename($filename, $firmware);
echo '<p align=center>File successfully downloaded. Rebooting.</p>';
shell_exec("reboot");
} else if (!empty($_FILES['ppsi_conf']['name'])){
$uploaddir = $GLOBALS['etcdir'];
$uploadfile = $uploaddir . basename($_FILES['ppsi_conf']['name']);
echo '<pre>';
if ((!strcmp($_FILES['ppsi_conf']['name'],$GLOBALS['ppsiconf']) && (!strcmp(extension($_FILES['ppsi_conf']['name']), "conf")) && move_uploaded_file($_FILES['ppsi_conf']['tmp_name'], $uploadfile))) {
echo "<center>File is valid, and was successfully uploaded to ".$GLOBALS['etcdir']." folder\n";
} else {
echo "<center>File is not valid, please upload a ".$GLOBALS['ppsiconf']." file</center>\n";
}
echo "</pre>";
} else if (!empty($_FILES['sfp_conf']['name'])){
$uploaddir = $GLOBALS['etcdir'];
$uploadfile = $uploaddir . basename($_FILES['sfp_conf']['name']);
echo '<pre>';
if ((!strcmp($_FILES['sfp_conf']['name'],$GLOBALS['sfpdatabaseconf'])) && (!strcmp(extension($_FILES['sfp_conf']['name']), "conf")) && move_uploaded_file($_FILES['sfp_conf']['tmp_name'], $uploadfile)) {
echo "<center>File is valid, and was successfully uploaded to ".$GLOBALS['etcdir']." folder\n";
} else {
echo "<center>File is not valid, please upload a ".$GLOBALS['sfpdatabaseconf']." file</center>\n";
}
echo "</pre>";
} else if (!empty($_FILES['snmp_conf']['name'])){
$uploaddir = $GLOBALS['etcdir'];
$uploadfile = $uploaddir . basename($_FILES['snmp_conf']['name']);
echo '<pre>';
if ((!strcmp($_FILES['snmp_conf']['name'],$GLOBALS['snmpconf'])) && (!strcmp(extension($_FILES['snmp_conf']['name']), "conf")) && move_uploaded_file($_FILES['snmp_conf']['tmp_name'], $uploadfile)) {
echo "<center>File is valid, and was successfully uploaded to ".$GLOBALS['etcdir']." folder\n";
} else {
echo "<center>File is not valid, please upload a ".$GLOBALS['snmpconf']." file</center>\n";
}
echo "</pre>";
} else if (!empty($_FILES['hal_conf']['name'])){
$uploaddir = $GLOBALS['etcdir'];
$uploadfile = $uploaddir . basename($_FILES['hal_conf']['name']);
echo '<pre>';
if ((!strcmp($_FILES['hal_conf']['name'],$GLOBALS['wrswhalconf'])) && (!strcmp(extension($_FILES['hal_conf']['name']), "conf")) && move_uploaded_file($_FILES['hal_conf']['tmp_name'], $uploadfile)) {
echo "<center>File is valid, and was successfully uploaded to ".$GLOBALS['etcdir']." folder\n";
} else {
echo "<center>File is not valid, please upload a ".$GLOBALS['wrswhalconf']." file</center>\n";
}
echo "</pre>";
} else if (!empty($_FILES['restore_conf']['name'])){
$uploaddir = $GLOBALS['etcdir'];
$uploadfile = $uploaddir . basename($_FILES['restore_conf']['name']);
echo '<pre>';
if ((!strcmp(extension($_FILES['restore_conf']['name']), "gz")) && move_uploaded_file($_FILES['restore_conf']['tmp_name'], $uploadfile)) {
shell_exec("tar -xvf ".$uploadfile. " -C ". $GLOBALS['etcdir'] ); //untar the file
echo "<center>Configuration restored sucessfully. Rebooting system.\n";
shell_exec("reboot");
} else {
echo "<center>File is not valid, please upload a .tar.gz file</center>\n";
}
shell_exec("rm $uploadfile");
echo "</pre>";
} else if (!strcmp($cmd, "Backup")){
//Prepare backup (tar)
$backupfile="backup".date("Y-m-d").".tar.gz";
shell_exec("cd ".$GLOBALS['etcdir']."; tar -cvf ".$backupfile." *; mv ".$backupfile." /var/www/download/".$backupfile);
$backupfile="/download/$backupfile";
//Download the file
header('Location: '.$backupfile);
} else if (!strcmp($cmd, "ntp")){
$output = "ntpserver ". htmlspecialchars($_POST["ntpip"])."\n\n";
if (file_exists($GLOBALS['etcdir'].$GLOBALS['wrdateconf'])) {
$current = file_get_contents($GLOBALS['etcdir'].$GLOBALS['wrdateconf']);
if(substr_count($current,"ntpserver")>0){
$current = shell_exec("sed '/ntpserver/d' ".$GLOBALS['etcdir'].$GLOBALS['wrdateconf']);
$current = str_replace("\n", "", $current);
}
$current .= $output;
$file=$GLOBALS['etcdir'].$GLOBALS['wrdateconf'];
unlink($GLOBALS['etcdir'].$GLOBALS['wrdateconf']);
$file = fopen($GLOBALS['etcdir'].$GLOBALS['wrdateconf'],"w+");
fwrite($file,$current);
fclose($file);
} else {
$file = fopen("/tmp/".$GLOBALS['wrdateconf'],"w+");
fwrite($file,$output);
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/'.$GLOBALS['wrdateconf'], $GLOBALS['etcdir'].$GLOBALS['wrdateconf']);
}
//Set UTC
$UTC=htmlspecialchars($_POST["utc"]);
$_SESSION['utc']=$UTC;
//Export to /etc/profile --> when /etc/profile remains saved...
$utc_exists = shell_exec("cat ".$GLOBALS['profilefile']." | grep -c TZ");
$utc_prev = shell_exec("cat ".$GLOBALS['profilefile']." | grep TZ");
$utc_prev=trim($utc_prev);
if($utc_exists>0){
$sed_cmd = 'sed -i "s/'.$utc_prev.'/export TZ='.$_SESSION['utc'].'/g" '.$GLOBALS['profilefile'];
shell_exec ($sed_cmd);
}else{ // Add TZ to profile file
shell_exec ('echo "export TZ='.$_SESSION['utc'].'" >>'.$GLOBALS['profilefile']);
}
echo '<br><p align=center>Rebooting...</p>';
//Reboot the switch after 1s
usleep(1000000);
shell_exec("reboot");
} else if (!strcmp($cmd, "backup-wrs")){
//Backup wrs firmware
} else if (!strcmp($cmd, "snmp")){
if(check_snmp_status()){ //It is running
//Stop SNMP
shell_exec("killall snmpd");
}else{ //Not running
shell_exec("/etc/init.d/S80snmp > /dev/null 2>&1 &");
}
header('Location: management.php');
}
}
/**
* Download file
*
* @param string $path
* @param string $type
* @param string $name
* @param bool $force_download
* @return bool
*/
function download($path, $name = '', $type = 'application/octet-stream', $force_download = true) {
if (!is_file($path) || connection_status() !== 0);
if($force_download) {
header("Cache-Control: public");
} else {
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Content-Type: $type");
header("Content-Length: ".(string)(filesize($path)));
$disposition = $force_download ? 'attachment' : 'inline';
if(trim($name) == '') {
header("Content-Disposition: $disposition; filename=" . basename($path));
} else {
header("Content-Disposition: $disposition; filename=\"" . trim($name)."\"");
}
header("Content-Transfer-Encoding: binary\n");
if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
print(fread($file, 1024*8));
flush();
}
fclose($file);
}
return((connection_status() == 0) && !connection_aborted());
}
/*
* This function configures the PTP daemon.
*
......@@ -527,7 +833,7 @@ function wrs_ptp_configuration(){
echo '<center>';
if(!empty($_POST["b"])){
$cmd .= " -b ".htmlspecialchars($_POST["b"]);
echo '<br>Network Interface binded to '.htmlspecialchars($_POST["b"]);
echo '<br>Network Interface bound to '.htmlspecialchars($_POST["b"]);
}
if (!empty($_POST["u"])){
$cmd .= " -u ".htmlspecialchars($_POST["u"]);
......@@ -557,23 +863,51 @@ function wrs_ptp_configuration(){
$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(!strcmp($_POST['cmd'],"ppsiupdate")){
if(wrs_check_ptp_status()){ //PPSi is enabled.
shell_exec("killall ppsi");
}else{ //PPSi is disabled.
$ptp_command = "/wr/bin/ppsi > /dev/null 2>&1 &";
$output = shell_exec($ptp_command);
}
header('Location: ptp.php');
}
if(!empty($cmd)){
shell_exec("killall ptpd");
$ptp_command = "/wr/bin/ptpd -c ".$cmd. " > /dev/null 2>&1 &";
if (!empty($_POST["clkclass"])){
$old_value= rtrim(shell_exec("cat ".$GLOBALS['etcdir'].$GLOBALS['ppsiconf']." | grep class "));
$new_value="clock-class ".htmlspecialchars($_POST["clkclass"]);
$sed = 'sed -i "s/'.$old_value.'/'.$new_value.'/g" '.$GLOBALS['etcdir'].$GLOBALS['ppsiconf'];echo $sed;
shell_exec($sed);
echo '<br>Clock Class changed to '.htmlspecialchars($_POST["clkclass"]);
}
if (!empty($_POST["clkacc"])){
$old_value= rtrim(shell_exec("cat ".$GLOBALS['etcdir'].$GLOBALS['ppsiconf']." | grep accuracy "));
$new_value="clock-accuracy ".htmlspecialchars($_POST["clkacc"]);
$sed ='sed -i "s/'.$old_value.'/'.$new_value.'/g" '.$GLOBALS['etcdir'].$GLOBALS['ppsiconf'];echo $sed;
shell_exec($sed);
echo '<br>Clock Accuracy changed to '.htmlspecialchars($_POST["clkacc"]);
}
if ((!empty($_POST["clkclass"])) || !empty($_POST["clkacc"])){
// Redirect & relaunch.
echo '<br>Clock values changed. Rebooting PPSi daemon.</br';
//We must relaunch ptpd too. (by default)
shell_exec("killall ppsi");
$ptp_command = "/wr/bin/ppsi > /dev/null 2>&1 &";
$output = shell_exec($ptp_command);
echo '<center>PTP initialized.</center>';
//Relaunching wrsw_hal to commit endpoint changes
//shell_exec("killall wrsw_hal");
//shell_exec("/wr/bin/wrsw_hal -c ".$GLOBALS['etcdir']."wrsw_hal.conf > /dev/null 2>&1 &");
header('Location: ptp.php');
exit;
}
echo '</center>';
}
/*
......@@ -683,8 +1017,6 @@ function wrs_display_help($help_id, $name){
$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>
......@@ -705,15 +1037,16 @@ function wrs_display_help($help_id, $name){
} 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>";
- <b>Change mode:</b> Changes switch mode to Master/GrandMaster <br>
- <b>Reboot switch</b>: Reboots the switch <br>
- <b>Net-SNMP Server</b>: Enables/Disables remote management using SNMP <br>
- <b>NTP Server</b>: Sets the IP address of an external NTP server. By default it is configured as UTC, please use the second box to change it. This change is done on the webserver, not in the switch command line environment.<br>
- <b>Load Configuration Files</b>: You can upload individual configuration files to the switch (ppsi.conf, wrsw_hal.conf, snmp.conf, sfp_database.conf or a .tar.gz file with all of them.<br>
- <b>Backup Configuration Files</b>: Downloads a tar.gz file with all configuration files of the switch.<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>";
$message = "<p><b>Enable or disable PPSi service. <br>
<b>Changing Clock CLass and Clock Accuracy fields modifies ppsi.conf file for those values and relanches the service again.</b>. <br></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")){
......@@ -726,7 +1059,7 @@ function wrs_display_help($help_id, $name){
}
} else if (!strcmp($help_id, "file")){
$msg = shell_exec("cat /wr/etc/".$name);
$msg = shell_exec("cat ".$GLOBALS['etcdir'].$name);
$msg = explode("\n", $msg);
for($i=0; $i<count($msg); $i++){
......@@ -734,7 +1067,50 @@ function wrs_display_help($help_id, $name){
}
} else if (!strcmp($help_id, "endpointmode")){
$message = "<b>Change endpoint mode to master/slave by clicking on one of the items</b>";
$message = "<br><b>Change endpoint mode to master/slave/auto by clicking on one of the items.</b><br>";
$message .= "<b>It modifies both wrsw_hal.conf and ppsi.conf files</b>";
} else if (!strcmp($help_id, "snmp")){
$message = "<p align=left>List of public SNMP OIDs</p><br>";
$message .= shell_exec("snmpwalk -v1 -c public localhost");
$message = str_replace("\n","<br>",$message);
} else if (!strcmp($help_id, "vlan")){
$message = "<br><b>Add new VLANs to the WRS</b>";
$message .= "<br><b>- VID --> VLAN ID in rtud</b>";
$message .= "<br><b>- FID --> Assign FID to configured VLAN</b>";
$message .= "<br><b>- DROP --> Enable/Disable drop frames on VLAN</b>";
$message .= "<br><b>- PRIO --> Sets Priority</b>";
$message .= "<br><b>- MASK --> Mask for ports belonging to configured VLAN</b>";
$message .= "<br><br>If you want to assign port to VLANs, please add VLANs first and then click on <strong>Assign Ports to VLANs</strong>. ";
} else if (!strcmp($help_id, "vlanassignment")){
$message = "<br><b>Assign ports to created VLANs</b>";
$message .= "<br><b>VLANs ID --> VLANs ID already created in rtud</b>";
$message .= "<br><b>Mode --> Sets mode for the endpoint:</b>";
$message .= "<br><b><ul><li>Access --> tags untagged frames, drops tagged frames not belinging to configured VLAN</b></li>";
$message .= "<br><b><li>Trunk --> passes only tagged frames, drops all untagged frames</b></li>";
$message .= "<br><b><li>Disable --> passess all frames as is</b></li>";
$message .= "<br><b><li>Unqualified Port --> passess all frames regardless VLAN config</b></li></ul>";
$message .= "<br><b>Priority --> sets priority for retagging</b>";
$message .= "<br><b>Mask --> sets untag mask for port</b>";
} else if (!strcmp($help_id, "network")){
$message = "<br><b>Set a DHCP network interface configuration or a static one.</b>";
$message = "<br><b>If you set a static configuration, you have to define: </b>";
$message .= "<br><b><ul><li>IP Address --> IP Address of your switch</b></li>";
$message .= "<br><b><li>Netmask --> Netmask</b></li>";
$message .= "<br><b><li>Network--> IP Address of your network</b></li>";
$message .= "<br><b><li>Broadcast --> Broadcast address</b></li>";
$message .= "<br><b><li>Gateway--> Gateway of the switch network</b></li></ul>";
$message .= "<br><br><b>NOTE: This network configuration only works for NAND-flashed switches. If you are using a NFS server, the configurtion is set by default in busybox and it is not possible to be changed.</b>";
} else if (!strcmp($help_id, "firmware")){
$message = "<p>Firmware features: <br>
- <b>Flash firmware</b>: It flashes a new firmware to the switch. Do it under your own risk.<br>
</p>";
}
......@@ -765,7 +1141,7 @@ function extension($filename){
*/
function parse_wrsw_hal_file(){
$file = shell_exec('cat /wr/etc/wrsw_hal.conf | grep wr_');
$file = shell_exec('cat '.$GLOBALS['etcdir'].'wrsw_hal.conf | grep wr_');
$file = str_replace("mode =", "", $file);
$file = str_replace('"', "", $file);
$file = str_replace(';', "", $file);
......@@ -774,6 +1150,15 @@ function parse_wrsw_hal_file(){
return $file;
}
function parse_ppsi_conf_file(){
$file = shell_exec('cat '.$GLOBALS['etcdir'].'ppsi.conf | grep role');
$file = str_replace("role", "", $file);
$file = explode(" ", $file);
return $file;
}
/*
* Obtains the content the switch mode from wrsw_hal.conf file
*
......@@ -783,7 +1168,7 @@ function parse_wrsw_hal_file(){
*
*/
function check_switch_mode(){
$status = shell_exec("cat /wr/etc/wrsw_hal.conf | grep -c GrandMaster");
$status = shell_exec("cat ".$GLOBALS['etcdir']."wrsw_hal.conf | grep -c GrandMaster");
if($status>0){
return "GrandMaster";
......@@ -804,22 +1189,101 @@ function check_switch_mode(){
function modify_switch_mode(){
if (!strcmp(check_switch_mode(), "GrandMaster")){
$cmd = 'sed -i "s/mode = \"GrandMaster\"/mode = \"Master\"/g" /wr/etc/wrsw_hal.conf';
$cmd = 'sed -i "s/mode = \"GrandMaster\"/mode = \"Master\"/g" '.$GLOBALS['etcdir'].'wrsw_hal.conf';
}else{
$cmd = 'sed -i "s/mode = \"Master\"/mode = \"GrandMaster\"/g" /wr/etc/wrsw_hal.conf';
$cmd = 'sed -i "s/mode = \"Master\"/mode = \"GrandMaster\"/g" '.$GLOBALS['etcdir'].'wrsw_hal.conf';
}
shell_exec($cmd);
}
function wrs_modify_endpoint_mode($endpoint, $mode){
switch ($mode) {
case "master":
$new_mode = "slave";
break;
case "slave":
$new_mode = "auto";
break;
case "auto":
$new_mode = "master";
break;
}
(!strcmp($mode, "master")) ? $new_mode = "wr_slave" : $new_mode = "wr_master";
if($endpoint>0 && $endpoint<19 && (((!strcmp($mode, "slave"))) || ((!strcmp($mode, "master"))))){
// ### Code for ppsi.conf ###
if($endpoint>0 && $endpoint<19 && (((!strcmp($mode, "slave"))) || ((!strcmp($mode, "master"))) || ((!strcmp($mode, "auto"))))){
$file = "/wr/etc/wrsw_hal.conf";
$file = $GLOBALS['etcdir'].$GLOBALS['ppsiconf'];
$lines = file($file);
$output = "";
$count = 0;
$end_aux = $endpoint;
if($endpoint == 1){ //Slave port
$endpoint= "port slave";
}else{ //Master ports
$endpoint= "port master".($end_aux-1)."\n";
}
$found = false;
foreach($lines as $line_num => $line)
{
if(substr_count($line, $endpoint)>0){
$found = true;
}
if($found)$count++;
if($count==3){
$output.='role '.$new_mode."\n";
$count = 0;
$found = false;
}else{
$output.=$line;
}
}
//We save the changes in a temporarely file in /tmp
$file = fopen("/tmp/".$GLOBALS['ppsiconf'],"w+");
fwrite($file,$output);
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/'.$GLOBALS['ppsiconf'], $GLOBALS['etcdir'].$GLOBALS['ppsiconf']);
//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';
}
// ##### old code for wrsw_hal.conf ######
switch ($mode) {
case "master":
$new_mode = "wr_slave";
break;
case "slave":
$new_mode = "wr_master";
break;
case "auto":
$new_mode = "wr_slave";
break;
}
echo $mode, "---", $new_mode;
if($endpoint>0 && $endpoint<19 && (((!strcmp($mode, "slave"))) || ((!strcmp($mode, "master"))) || ((!strcmp($mode, "auto"))))){
$file = $GLOBALS['etcdir'].$GLOBALS['wrswhalconf'];
$lines = file($file);
$output = "";
$count = 0;
......@@ -846,14 +1310,13 @@ function wrs_modify_endpoint_mode($endpoint, $mode){
}
//We save the changes in a temporarely file in /tmp
$file = fopen("/tmp/wrsw_hal.conf","w+");
$file = fopen("/tmp/".$GLOBALS['wrswhalconf'],"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>';
copy('/tmp/'.$GLOBALS['wrswhalconf'], $GLOBALS['etcdir'].$GLOBALS['wrswhalconf']);
}else{
echo '<br>Wrong parameters for endpoint-mode';
}
......@@ -872,6 +1335,31 @@ function session_is_started(){
}
}
function parse_mask2ports($vlanmask){
$vlanmask = str_replace("0x","", $vlanmask);
$bin = decbin(hexdec($vlanmask));
$bin = strrev($bin);
$size = strlen($bin);
$counter = 0;
$ports = "";
for($i=0; $i<18; $i++){
if($bin[$i]=="1"){
$ports .= "wr".($i+1)." ";
$counter++;
if($counter==4){
$ports .= "<br>";
$counter = 0;
}
}
}
return $ports;
}
?>
......@@ -12,15 +12,25 @@
<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";
rows[i].className += " evenrowcolor";
}else{
rows[i].className += " oddrowcolor";
}
}
var table = document.getElementById(id+1);
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";
rows[i].className += " oddrowcolor";
}
}
}
......
<?php include 'functions.php' ?>
<html>
<html id="help">
<head>
<title>Help Menu</title>
<link href="css/help.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFF99">
<h1><center>Help</center></h1>
......
userspace/rootfs_override/var/www/img/uncheck.png

10 KB | W: | H:

userspace/rootfs_override/var/www/img/uncheck.png

3.76 KB | W: | H:

userspace/rootfs_override/var/www/img/uncheck.png
userspace/rootfs_override/var/www/img/uncheck.png
userspace/rootfs_override/var/www/img/uncheck.png
userspace/rootfs_override/var/www/img/uncheck.png
  • 2-up
  • Swipe
  • Onion skin
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="dashboard">
<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="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="load">
<div class="main">
<div class="page">
<div class="header" >
......@@ -19,41 +19,41 @@
<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" >
<th><FORM method="POST" ENCTYPE="multipart/form-data" onsubmit="return confirm('Are you sure you want to upload a new FPGA binary file? \nThis could result in the malfunction of the switch.');">
<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">
<th ><FORM method="POST" ENCTYPE="multipart/form-data" onsubmit="return confirm('Are you sure you want to upload a new lm32 binary file? \nThis could result in the malfunction of the switch.');">
<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}'");
<!--
<br><br><br><center>Max. filesize is now <?php //echo shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'");
?></center>
<table border="0" align="center">
<tr>
<form align="center" method="post">
Change PHP File Size Upload: <INPUT type="text" name="size" >
<input type="submit" value="Change" class="btn">
<th>New PHP Filesize: </th><th><INPUT type="text" name="size" > </th>
<th><input type="submit" value="Change" class="btn"></th>
</tr>
</form>
<br><br><br><hr>
</table>
-->
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><hr>
*Note: After loading a FPGA or lm32 binary the switch will reboot.
<?
......@@ -61,9 +61,6 @@
wrs_load_files();
wrs_change_wrfs("ro");
//echo '<center>';
//wrs_check_writeable();
//echo '</center>';
?>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="login">
<div class="main">
<div class="page">
<div class="header" >
......@@ -23,24 +23,50 @@
$message="";
if(count($_POST)>0) {
$users = shell_exec('cat /etc/users');
$users = explode(" ", $users);
//If /etc/phpusers does not exist we create the file and "admin" "" user&pass
if (!file_exists($GLOBALS['phpusersfile'])) {
$username = "admin";
$password = "";
$salt="wrs4.0salt";
$pass = $password;
$hash = md5($pass); // md5 hash #1
$hash_md5 = md5($salt.$pass); // md5 hash with salt #2
$hash_md5_double = md5(sha1($salt.$pass)); // md5 hash with salt & sha1 #3
$output= $username." ".$hash_md5_double."\n";
wrs_change_wrfs("rw");
$file = fopen($GLOBALS['phpusersfile'],"w+");
fwrite($file,$output);
fclose($file);
wrs_change_wrfs("ro");
}
$username = $_POST["login"];
$password = $_POST["password"];
if ((!strcmp($username, "root")) && (!strcmp($password, ""))){
$saved_hash = shell_exec("cat ".$GLOBALS['phpusersfile']." | grep ".$username." | awk '{print $2}'");
$saved_hash = str_replace("\n","",$saved_hash);
$user_exists = shell_exec("cat ".$GLOBALS['phpusersfile']." | grep -c ".$username);
$salt="wrs4.0salt";
$pass = $password;
$hash = md5($pass); // md5 hash #1
$hash_md5 = md5($salt.$pass); // md5 hash with salt #2
$hash_md5_double = md5(sha1($salt.$pass)); // md5 hash with salt & sha1 #3
if (!strcmp($hash_md5_double,$saved_hash) && $user_exists>0){
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");
?>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="management">
<div class="main">
<div class="page">
<div class="header" >
......@@ -21,58 +21,135 @@
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<table border="0" align="center">
<tr>
<center>
<form method="post">
<th>Switch Mode: (<?php $str = check_switch_mode(); echo $str; ?>)</th>
<input type="hidden" name="cmd" value="change">
<th><input type="submit" value="Change Mode" class="btn"></th>
</form>
</tr>
<tr>
<form method="post">
<th>Reboot system: </th>
<input type="hidden" name="cmd" value="reboot">
<th><input type="submit" value="Reboot switch" class="btn"> </th>
</form>
</center>
</tr>
<tr>
<form method="post">
<th align=left>Net-SNMP Server: </th>
<input type="hidden" name="cmd" value="snmp">
<th><INPUT type="submit" STYLE="text-align:center;" value="<?php echo (check_snmp_status()) ? 'Disable SNMP' : 'Enable SNMP'; ?>" class="btn"></th>
</form>
</tr>
</table>
<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>
<th><center>NTP Server:</center></th><th><INPUT type="text" STYLE="text-align:center;" name="ntpip" value="<?php $str = check_ntp_server(); echo $str; ?>"> </th>
<th><input type="hidden" name="cmd" value="ntp">
<select name="utc" >
<?php
$selected_utc=$_SESSION['utc'];
$selected_utc=str_replace("UTC","",$selected_utc);
$selected_utc=trim($selected_utc);
for($op = -12; $op < 0; $op++){
if($selected_utc==$op && !empty($selected_utc)){
echo '<option selected="UTC'.$op.'" class="btn" value="UTC'.($op).'"><center>UTC'.($op).'</center></option>';
}else{
echo '<option class="btn" value="UTC'.($op).'"><center>UTC'.($op).'</center></option>';
}
}
if(!strcmp($selected_utc,"")){
echo '<option selected="UTC" class="btn" value="UTC"><center>UTC</center></option>';
}else{
echo '<option class="btn" value="UTC"><center>UTC</center></option>';
}
for($op = 1; $op < 15; $op++){
if($selected_utc==$op && !empty($selected_utc)){
echo '<option elected="UTC'.$op.'" class="btn" value="UTC+'.($op).'"><center>UTC+'.($op).'</center></option>';
}else{
echo '<option class="btn" value="UTC+'.($op).'"><center>UTC+'.($op).'</center></option>';
}
}
?>
</th>
<th><input type="submit" value="Add NTP Server" 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> -->
</table>
<hr>
<br><br>
<center><p><strong>Load configuration files</strong></p></center>
<table border="1" align="center" class='altrowstable' id='alternatecolor' width="80%">
<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>
<FORM method="POST" ENCTYPE="multipart/form-data">
<th>PPSi Config </th>
<th ><INPUT type=file name="ppsi_conf" ></th>
<th><INPUT type=submit value="Load" class="btn" ><INPUT type=hidden name=MAX_FILE_SIZE VALUE= <?php wrs_php_filesize();?>000></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>
<FORM method="POST" ENCTYPE="multipart/form-data">
<th>SFP Config </th>
<th ><INPUT type=file name="sfp_conf" ></th>
<th><INPUT type=submit value="Load" class="btn" ><INPUT type=hidden name=MAX_FILE_SIZE VALUE= <?php wrs_php_filesize();?>000></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>
<FORM method="POST" ENCTYPE="multipart/form-data">
<th>SNMP Config</th>
<th ><INPUT type=file name="snmp_conf" ></th>
<th><INPUT type=submit value="Load" class="btn" ><INPUT type=hidden name=MAX_FILE_SIZE VALUE= <?php wrs_php_filesize();?>000></th>
</form>
</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>
<FORM method="POST" ENCTYPE="multipart/form-data">
<th>HAL Config </th>
<th ><INPUT type=file name="hal_conf" ></th>
<th><INPUT type=submit value="Load" class="btn" ><INPUT type=hidden name=MAX_FILE_SIZE VALUE= <?php wrs_php_filesize();?>000></th>
</form>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<FORM method="POST" ENCTYPE="multipart/form-data">
<th>Restore from backup</th>
<th ><INPUT type=file name="restore_conf" ></th>
<th><INPUT type=submit value="Load" class="btn" ><INPUT type=hidden name=MAX_FILE_SIZE VALUE= <?php wrs_php_filesize();?>000></th>
</form>
</tr>
</table>
<br><br><br><br>
<center>
<FORM align="center" method="POST" ENCTYPE="multipart/form-data">
<th>Backup Configuration files to your computer </th>
<input type="hidden" name="cmd" value="Backup">
<th><INPUT type=submit value="Backup" class="btn" ></th>
</form>
</center>
<?php
wrs_change_wrfs("rw");
wrs_management();
//wrs_check_writeable();
wrs_change_wrfs("ro");
?>
......
......@@ -10,8 +10,8 @@ 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>
<input type="text" name="login" value="" placeholder="Username" size="15">
<input type="password" name="password" value="" placeholder="Password" size="15">
<!--<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
......@@ -24,22 +24,25 @@ echo '<div class="login">
}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="network.php"> Network Setup </a></li>';
echo '<li><a href="ptp.php"> PPSi Setup </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="vlan.php"> VLAN Setup </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 '<li><a href="advance.php"> Advanced Mode </a></li>';
if(!empty($_SESSION['advance'])){
echo '<ul class="advance">';
echo '<li><a href="sfpcalibration.php">SFP Calibration</a></li>';
echo '<li><a href="endpoint.php">Endpoint Tool </a></li>';
echo '<li><a href="endpointcalibration.php">Endpoint Calibration</a></li>';
echo '<li><a href="load.php">LM32 & FPGA</a></li>';
echo '<li><a href="terminal.php">Virtual Console</a></li>';
echo '<li><a href="firmware.php">Firmware</a></li>';
echo '</ul>';
}
echo '</ul><br><hr>';
echo '<b>User: <font color="blue">'.$_SESSION["myusername"].' </font></b>';
echo '<b>User: <font color="blue"><a href="change_passwd.php">'.$_SESSION["myusername"].'</a> </font></b>';
echo '<a href="./logout.php">(logout)</a>';
}
?>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="modifymode">
<div class="main">
<div class="page">
<div class="header" >
......@@ -29,6 +29,9 @@
wrs_modify_endpoint_mode($endpoint, $mode);
wrs_change_wrfs("ro");
header('Location: endpointmode.php');
exit;
?>
<hr>
<FORM align="right" action="endpointmode.php" method="post">
......
<?php include 'functions.php'; include 'head.php'; ?>
<body id="ptp">
<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">Network Management <a href='help.php?help_id=network' 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 id="daemon" border="0" align="center">
<tr>
<th align=left>eth0 Setup: </th>
<th><input type="radio" name="networkgroup" value="DHCP" <?php if(!strcmp(wrs_interface_setup(), "dhcp")) echo "checked" ?> > DHCP <br>
<input type="radio" name="networkgroup" value="Static" <?php if(!strcmp(wrs_interface_setup(), "static")) echo "checked" ?> > Static <br>
<th><INPUT type="submit" value="Change" class="btn"></th>
</tr>
</table>
</FORM>
<?php
wrs_change_wrfs("rw");
if((empty($_POST["networkgroup"]))){
echo '
<table border="0" class="altrowstable" id="alternatecolor" align="center">
<tr>
<th><font color="blue">Current eth0</font></th>
</tr><tr></tr><tr></tr>
<tr>
<th align=left>IP Address: </th>
<th ><INPUT type="text" STYLE="text-align:center;" align="center" value="'.shell_exec("ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").'" readonly name="ip" ></th>
</tr>
<tr>
<th align=left>Netmask: </th>
<th><INPUT type="text" STYLE="text-align:center;" align="center" value="'.shell_exec("ifconfig eth0 | grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'").'" readonly name="netmask" ></th>
</tr>
<tr>
<th align=left>Broadcast: </th>
<th><INPUT type="text" STYLE="text-align:center;" align="center" value="'.shell_exec("ifconfig eth0 | grep 'inet addr:' | cut -d: -f3 | awk '{ print $1}'").'" readonly name="broadcast" ></th>
</tr>
</table>';
}
if ((!empty($_POST["networkgroup"])) && (!strcmp(htmlspecialchars($_POST["networkgroup"]),"DHCP"))){
$interface_file = $GLOBALS['interfacesfile'];
$tmpfile="/tmp/interfaces";
shell_exec('rm '.$interface_file);
$output="# Configure Loopback\nauto lo\niface lo inet loopback\n\n#Force eth0 to be configured by DHCP\nauto eth0\niface eth0 inet dhcp\n\n# Uncomment this example for static configuration\n";
$output.="#iface eth0 inet static\n";
$output.="#\taddress 192.168.1.10";
$output.="\n#\tnetmask 255.255.255.0";
$output.="\n#\tnetwork 192.168.1.0";
$output.="\n#\tbroadcast 192.168.1.255";
$output.="\n#\tgateway 192.168.1.1\n";
$file = fopen($tmpfile,"w+");
fwrite($file,$output);
fclose($file);
//We move the file to /usr/etc/network
copy($tmpfile, $interface_file);
echo '<center>DHCP is now set for eth0<br>Rebooting switch</center>';
//Let's reboot
shell_exec('reboot');
}
if ((!empty($_POST["networkgroup"])) && (!strcmp(htmlspecialchars($_POST["networkgroup"]),"Static"))){
echo '<FORM method="POST">
<table border="0" align="center" class="altrowstable" id="alternatecolor">
<tr>
<th align=left>IP Address: </th>
<th><INPUT STYLE="text-align:center;" type="text" value="192.168.1.10" name="ip" ></th>
</tr>
<tr>
<th align=left>Netmask: </th>
<th><INPUT STYLE="text-align:center;" type="text" value="255.255.255.0" name="netmask" ></th>
</tr>
<tr>
<th align=left>Network: </th>
<th><INPUT STYLE="text-align:center;" type="text" value="192.168.1.0" name="network" ></th>
</tr>
<tr>
<th align=left>Broadcast: </th>
<th><INPUT STYLE="text-align:center;" type="text" value="192.168.1.255" name="broadcast" ></th>
</tr>
<tr>
<th align=left>Gateway: </th>
<th><INPUT STYLE="text-align:center;" type="text" value="192.168.1.1" name="gateway" ></th>
</tr>
</table>
<INPUT type="submit" value="Save New Configuration" class="btn last">
</FORM>';
}
if ((!empty($_POST["ip"])) && (!empty($_POST["netmask"])) && (!empty($_POST["network"])) && (!empty($_POST["broadcast"])) && (!empty($_POST["gateway"]))){
$interface_file = $GLOBALS['interfacesfile'];
$tmpfile="/tmp/interfaces";
shell_exec('rm '.$interface_file);
$output="# Configure Loopback\nauto lo\niface lo inet loopback\n\n#Force eth0 to be configured by DHCP\n#auto eth0\n#iface eth0 inet dhcp\n\n# Uncomment this example for static configuration\n";
$output.="iface eth0 inet static\n";
$output.="\taddress ".$_POST["ip"];
$output.="\n\tnetmask ".$_POST["netmask"];
$output.="\n\tnetwork ".$_POST["network"];
$output.="\n\tbroadcast ".$_POST["broadcast"];
$output.="\n\tgateway ".$_POST["gateway"]."\n";
$file = fopen($tmpfile,"w+");
fwrite($file,$output);
fclose($file);
//We move the file to /usr/etc/network
copy($tmpfile, $interface_file);
echo '<center>New static configuration saved for eth0<br>Changes will take place after reboot.</center>';
//Let's reboot
shell_exec('reboot');
}
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 id="management">
<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 Management <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
$vlan_cmd = "/wr/bin/wrsw_vlans ";
if(!empty($_POST['vid'])){ $vlan_cmd .= " --rvid ".$_POST['vid'];}
if(!empty($_POST['fid'])){$vlan_cmd .= " --rfid ".$_POST['fid'];}
if(!empty($_POST['mask'])){$vlan_cmd .= " --rmask ".$_POST['mask'];}
if(!empty($_POST['drop'])){$vlan_cmd .= " --rdrop ".$_POST['drop'];}
if(!empty($_POST['prio'])){$vlan_cmd .= " --rprio ".$_POST['prio'];}
shell_exec($vlan_cmd);
header('Location: vlan.php');
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php include 'functions.php'; include 'head.php'; ?>
<body id="vlan">
<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">Port-VLAN Assigment <a href='help.php?help_id=vlanassignment' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<?php
// Get VLANS
echo '<center><strong>Port-VLAN List</strong></center><hr>';
$tmp_vlan_file="/tmp/vlans.conf";
$vlans = shell_exec("/wr/bin/wrsw_vlans --list >".$tmp_vlan_file);
$vlans = shell_exec("cat ".$tmp_vlan_file." | sed -n '/ /s/ \+/ /gp'");
$vlans = explode("\n", $vlans);
$name_vlans="";
$counter = 0;
foreach($vlans as $line){
$counter++;
if($counter>=3 && !empty($line)){
$line = explode(" ", $line);
$name_vlans .= $line[1]." ";
}
}
$name_vlans = explode(" ", $name_vlans);
// Get Previous assignment
$tmp_assign_file="/tmp/port2vlan.conf";
$vlans_assignment = shell_exec("/wr/bin/wrsw_vlans --elist >".$tmp_assign_file);
$vlans_assignment = shell_exec("cat ".$tmp_assign_file." | sed -n '/ /s/ \+/ /gp'");
$vlans_assignment = explode("\n", $vlans_assignment);
echo '<table align=center border="1" class="altrowstable" id="alternatecolor">';
echo '<tr align=center><th><font color="blue">Endpoint</font></th><th><font color="blue">VLAN ID</font></th><th><font color="blue">Mode</font></th><th><font color="blue">Priority</font></th><th><font color="blue">Mask</font></th></tr>';
echo '<form method=POST>';
for($i = 0; $i < 18; $i++){
$single_line = explode(" ",$vlans_assignment[$i+1]); //info per endpoint line
echo '<tr>';
echo '<th><center><b>wr'.($i+1).'</b></center></th>';
//Show the Vlan option button
echo '<th>';
//echo '<select name=vlan'.($i).'>';
/*foreach($name_vlans as $vlan){
if(!empty($vlan[0])){
echo '<option class="btn" value="'.$vlan[0].$vlan[1].'"><center>ID'.$vlan[0].$vlan[1].'</center></option>';
}
}*/
echo '<input STYLE="background-color:'.$vlancolor[$single_line[6]].';text-align:center;" size="5" type="text" value="'.$single_line[6].'" name="vlan'.($i).'">';
//echo '<option class="btn" selected="selected" value="disabled"><center>Disabled</center></option>';
//echo '</select>'; // end Vlan ID assignation
echo '</th>';
echo '<th>'; // Mode selection
echo '<select name=mode'.($i).'>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"0")) ? 'selected="selected"' : ''; echo ' value="0"><center>Access</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"1")) ? 'selected="selected"' : ''; echo ' value="1"><center>Trunk</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"2")) ? 'selected="selected"' : ''; echo ' value="2"><center>VLAN Disabled</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"3")) ? 'selected="selected"' : ''; echo ' value="3"><center>Unqualified port</center></option>';
echo '</select>'; // end mode
echo '</th>';
echo '<th>'; // Priority selection
echo '<select name=prio'.($i).'>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"0")) ? 'selected="selected"' : ''; echo 'value="0"><center>0</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"1")) ? 'selected="selected"' : ''; echo 'value="1"><center>1</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"2")) ? 'selected="selected"' : ''; echo 'value="2"><center>2</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"3")) ? 'selected="selected"' : ''; echo 'value="3"><center>3</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"4")) ? 'selected="selected"' : ''; echo 'value="4"><center>4</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"5")) ? 'selected="selected"' : ''; echo 'value="5"><center>5</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"6")) ? 'selected="selected"' : ''; echo 'value="6"><center>6</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"7")) ? 'selected="selected"' : ''; echo 'value="7"><center>7</center></option>';
echo '</select>'; // end Priority
echo '</th>';
echo '<th align=center><INPUT type="text" size="8" name="mask'.$i.'" ></th>';
echo '</tr>';
}
echo '<tr><th></th><th></th><th></th><th></th><th align=center><input type="submit" value="Update" class="btn" name="updatevlan" ></th></tr>
</form>';
echo '</table>';
echo '<br>'.$_POST['mode0'];
//Parse input and run the command
if (!empty($_POST['updatevlan'])){
$vlan_cmd= "/wr/bin/wrsw_vlans ";
for($i = 0; $i < 18; $i++){
//if(strcmp($_POST['vlan'.$i],"disabled")){ //VLAN selected
$vlan_cmd .= " --ep ".$i;
$vlan_cmd .= " --emode ".$_POST['mode'.$i];
$vlan_cmd .= " --eprio ".$_POST['prio'.$i];
if(!empty($_POST['vlan'.$i])){$vlan_cmd .= " --evid ".$_POST['vlan'.$i];}
if(!empty($_POST['mask'.$i])){$vlan_cmd .= " --eumask ".$_POST['mask'.$i];}
$output = shell_exec($vlan_cmd);
echo $vlan_cmd;
echo '<br><p><center>Port WR'.($i+1).' added to VLAN'.$_POST['vlan'.$i].'</center></p>';
//}else{
if(!strcmp($_POST['mode'.$i],"2")){ //Disable VLAN for endpoint
$vlan_cmd .= " --ep ".$i;
$vlan_cmd .= " --emode ".$_POST['mode'.$i];
$output = shell_exec($vlan_cmd);
echo '<br><p><center>VLAN removed for port WR'.($i+1).'</center></p>';
}
//}
$vlan_cmd= "/wr/bin/wrsw_vlans ";
}
header('Location: vlan.php');
}
?>
<br><br><FORM align="right" method="POST" action="vlan.php" ENCTYPE="multipart/form-data">
<INPUT type=submit value="Go 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>
<body id="ptp">
<div class="main">
<div class="page">
<div class="header" >
......@@ -16,25 +16,34 @@
</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>
<h1 class="title">PPSi 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">
<table id="daemon" 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>
<th align=center>PPSi Daemon: </th>
<input type="hidden" name="cmd" value="ppsiupdate">
<th><INPUT type="submit" value="<?php echo (wrs_check_ptp_status()) ? 'Disable PPSi' : 'Enable PPSi'; ?>" class="btn"></th>
</tr>
</table>
</FORM>
<FORM method="POST">
<table border="0" align="center">
<tr>
<th align=left>Clock Class: </th>
<th><INPUT type="text" STYLE="text-align:center;" size="10" name="clkclass" value="<?php echo shell_exec("cat ".$GLOBALS['etcdir'].$GLOBALS['ppsiconf']." | grep class | awk '{print $2}'");?>" ></th>
</tr>
<tr>
<th align=left>Clock Accuracy: </th>
<th><INPUT type="text" STYLE="text-align:center;" size="10" name="clkacc" value="<?php echo shell_exec("cat ".$GLOBALS['etcdir'].$GLOBALS['ppsiconf']." | grep accuracy | awk '{print $2}'");?>"></th>
</tr>
<!--
<tr>
<th align=left>Network Interface Binding: </th>
<th><INPUT type="text" name="b" ></th>
......@@ -66,15 +75,24 @@
<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>
<INPUT align="right" type="submit" value="Update & Relaunch" class="btn last">
</FORM>
<?php
<br><br><br><br><br><br><br><br><br><br><br><br>
<hr>
<p align="right">Click <A HREF="endpointmode.php">here</A> to modify endpoint mode configuration</p>
<?php
wrs_change_wrfs("rw");
wrs_ptp_configuration();
wrs_change_wrfs("ro");
?>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="sfpcalib">
<div class="main">
<div class="page">
<div class="header" >
......@@ -119,7 +119,7 @@
fclose($file);
//We move the file to /wr/etc/
copy('/tmp/sfp_database.conf', '/wr/etc/sfp_database.conf');
copy('/tmp/sfp_database.conf',$GLOBALS['etcdir'].'sfp_database.conf');
echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>';
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="terminal">
<div class="main">
<div class="page">
<div class="header" >
......@@ -18,15 +18,26 @@
<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() ?>
<?php session_is_started();
$hostname = $_SESSION['hostname'];
$ip = $_SESSION['ip'];
if(empty($hostname) || empty($ip)){
$_SESSION['hostname'] = trim(shell_exec("hostname"));
$_SESSION['ip'] = trim(shell_exec("ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"));
$hostname = $_SESSION['hostname'];
$ip = $_SESSION['ip'];
}
<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>
echo '<FORM action="terminal.php" method="POST" accept-charset="UTF-8">
'.$hostname.'@'.$_SESSION["ip"].'$: <input type="text" name="cmd" autofocus="autofocus" autocomplete="off">
<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){
......@@ -35,6 +46,7 @@
echo "PATH=".$path;
}*/
// If pwd is empty, we go to the root directory
if(empty($_SESSION["pwd"])){$_SESSION["pwd"]="/";}
shell_exec("cd ".$_SESSION["pwd"]);
......@@ -46,7 +58,7 @@
$cmd_aux = $cmd;
if(substr_count($cmd_aux , "cd")>0){
$cmd = " ls ";
//$cmd = " ls ";
// moving backwards
if(substr_count($cmd_aux , "cd ..")>0){
......@@ -100,11 +112,16 @@
$output = shell_exec( $path." ; cd ".$_SESSION["pwd"]." ; ".$cmd);
}
//Format output
$output=str_replace("\n","<br>",$output);
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>';
<p>'.$hostname.'@'.$ip.':'.$_SESSION["pwd"].'$ '.$cmd.'<br>'.$output.'</p> </div></div>';
......
......@@ -11,10 +11,11 @@ echo '<ul>
echo '<ul>
<li><a href="index.php"> Dashboard </a></li>
<li><a href="ptp.php"> PTP Configuration </a></li>
<li><a href="ptp.php"> PPSi Setup </a></li>
<li><a href="vlan.php"> VLAN Setup </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>
<li><a href="contact.php"> About </a></li>
</ul>';
......
<?php include 'functions.php'; include 'head.php'; ?>
<body>
<body id="vlan">
<div class="main">
<div class="page">
<div class="header" >
......@@ -22,45 +22,100 @@
<?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>';
echo '<center><strong>Existing VLANs</strong></center><hr>';
$tmp_vlan_file="/tmp/vlans.conf";
$vlans = shell_exec("/wr/bin/wrsw_vlans --list >".$tmp_vlan_file);
$vlans = shell_exec("cat ".$tmp_vlan_file." | sed -n '/ /s/ \+/ /gp'");
$vlans = explode("\n", $vlans);
echo '<table align=center border="1" class="altrowstable" id="alternatecolor" width="100%">';
echo '<tr align=center><th><font color="blue">Vlan ID</font></th><th><font color="blue">FID</font></th><th><font color="blue">Ports</font></th><th><font color="blue">Drop?</font></th><th><font color="blue">Priority</font></th><th><font color="blue">Action</font></th></tr>';
$counter = 0;
foreach($vlans as $line){
$counter++;
//Show the Vlan option button
echo '<td>';
echo '<form method=POST><div>
<select name='.($i).'>';
if($counter>=2 && !empty($line)){
$line = explode(" ", $line);
if(strcmp($line[3],"0x")){
for($op = 0; $op < 18; $op++){
echo '<option class="btn" value="'.($op+1).'"><center>Vlan'.($op+1).'</center></option>';
echo '<tr align=center><th bgcolor="'.$vlancolor[$line[1]].'">VLAN '.$line[1].'</th><th>'.$line[2].'</th><th>'.parse_mask2ports($line[3]).'</th><th>'.$line[4].'</th><th>'.$line[5].'</th><th><A HREF="delvlan.php?vlan='.$line[1].'.">Delete</A></th></tr>';
}else{
echo '<tr align=center><th>'.$line[1].'</th><th>'.$line[2].'</th><th>'.parse_mask2ports($line[3].$line[4]).'</th><th>'.$line[5].'</th><th>'.$line[6].'</th><th><A HREF="delvlan.php?vlan='.$line[1].'.">Delete</A></th></tr>';
}
}
echo '</select>';
}
//Form for a new one:
echo '<tr align=center>
<FORM method="POST" action="newvlan.php" "ENCTYPE="multipart/form-data">
<th align=center><INPUT type="text" size="3" name="vid" ></th>
<th align=center><INPUT type="text" size="3"name="fid" ></th>
<th align=center><INPUT type="text" size="5" name="mask" ></th>
<th align=center>
<select name="drop">
<option value="1">YES</option>
<option selected="selected" value="0">NO</option>
</select>
</th>
<th align=center>
<select name="prio">
<option selected="selected"value=""></option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
</th>
<th align=center><INPUT type=submit value="Add VLAN" class="btn"></th>
</form>
</tr>';
echo '</table>';
?>
<br><p align="right"><A HREF="delvlan.php?vlan=all" onclick="return confirm('You are deleting all VLANs, are you sure?')">Delete All VLANs</A></p>
<?php
//Display Port2Vlan assignment
echo '<br><br>';
echo '<center><strong>Port2Vlan assignments</strong></center><hr>';
echo '<table align=center border="1" class="altrowstable" id="alternatecolor1" width="100%">';
echo '<tr align=center><th><font color="blue">Port</font></strong></th><th><font color="blue">QMode</font></th><th><font color="blue">Priority</font></th><th><font color="blue">VLAN ID</font></th><th><font color="blue">MAC Address</font></th></tr>';
$tmp_vlan_file="/tmp/port2vlan.conf";
$vlans = shell_exec("/wr/bin/wrsw_vlans --elist >".$tmp_vlan_file);
$vlans = shell_exec("cat ".$tmp_vlan_file." | sed -n '/ /s/ \+/ /gp'");
$vlans = explode("\n", $vlans);
$counter = 0;
foreach($vlans as $line){
$counter++;
if($counter>=2 && !empty($line)){
$line = explode(" ", $line);
echo '</td>';
echo '<tr align=center><th>WR'.($line[1]+1).'</th><th>'.$line[2]." (".$line[3].')</th><th>'.($line[5]).'</th><th bgcolor="'.$vlancolor[$line[6]].'">VLAN '.$line[6].'</th><th>'.$line[7].'</th></th></tr>';
}
}
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 '<tr><th></th><th></th><th></th><th></th><th align=center><FORM method="POST" action="port2vlan.php"><INPUT type=submit align=center value="Edit Table" class="btn"></form></th></tr>';
echo '</table>';
?>
//Parse input and run the command
if (!empty($_POST['cmd'])){
$input = $_POST;
wrs_vlan_configuration($input);
}
wrs_vlan_display();
?>
<br><br><br><br><hr><p align="right"><A HREF="port2vlan.php">Assign Ports to VLANs</A></p>
</div>
......
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