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

www: Adding VLAN Support to front-end

	- adding vlans
	- setting ports to vlan
	- remove vlans

Adding neccesary functions for vlan support
parent 9895f40d
<?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=firmware' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
<?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');
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
......@@ -125,7 +125,7 @@ function wrs_main_info(){
echo '<tr><th> <b>White-Rabbit Date:</b></th><th><center>'; $str = shell_exec("TZ=".$_SESSION['utc']." /wr/bin/wr_date get"); echo $str; echo '</center></th></tr>';
echo '<tr><th> <b>PPSi:</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> <b>Net-SNMP:</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 '</center></th></tr>';
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> <b>NTP Server:</b> </th><th><center> <A HREF="management.php">'; $str = check_ntp_server(); echo $str; echo $_SESSION['utc']; echo '</A></center></th></tr>';
echo '<tr><th> <b>Max. Filesize Upload: </b></th><th><center>'; echo shell_exec("cat /etc/php.ini | grep upload_max_filesize | awk '{print $3}'"); echo '</center></th></tr>';
echo '</table>';
......@@ -279,9 +279,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")){
......@@ -952,8 +952,7 @@ 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 /tmp 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>
- <b>PHP Filesize</b>: It changes the max. size of the files that can be uploaded to the switch (40 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>
......@@ -974,15 +973,15 @@ 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>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")){
......@@ -1003,7 +1002,52 @@ 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>PHP Filesize</b>: It changes the max. size of the files that can be uploaded to the switch (40 MegaBytes by default)<br>
- <b>Flash firmware</b>: It moves a binary file into the /tmp folder<br>
- <b>Backup firmware</b>: It downloads a copy of the entire WRS to your PC<br>
</p>";
}
......
<?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 ";
$vlan_cmd .= " --rvid ".$_POST['vid'];
$vlan_cmd .= " --rfid ".$_POST['fid'];
$vlan_cmd .= " --rmask ".$_POST['mask'];
$vlan_cmd .= " --rdrop ".$_POST['drop'];
$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);
echo '<table align=center border="1" class="altrowstable" id="alternatecolor">';
echo '<tr align=center><th>Endpoint</th><th>VLANs ID</th><th>Mode</th><th>Priority</th><th>Mask</th></tr>';
echo '<form method=POST>';
for($i = 0; $i < 18; $i++){
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 '<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" selected="selected" value="0"><center>Access</center></option>';
echo '<option class="btn" value="1"><center>Trunk</center></option>';
echo '<option class="btn" value="2"><center>VLAN Disabled</center></option>';
echo '<option class="btn" 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" selected="selected" value="0"><center>0</center></option>';
echo '<option class="btn" value="1"><center>1</center></option>';
echo '<option class="btn" value="2"><center>2</center></option>';
echo '<option class="btn" value="3"><center>3</center></option>';
echo '<option class="btn" value="4"><center>4</center></option>';
echo '</select>'; // end Priority
echo '</th>';
echo '<th align=center><INPUT type="text" size="3" name="mask'.$i.'" ></th>';
echo '</tr>';
}
echo '<tr><th></th><th></th><th></th><th></th><th><input type="submit" value="Add VLANs" class="btn" name="updatevlan" ></th></tr>
</form>';
echo '</table>';
//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];
$vlan_cmd .= " --evid ".$_POST['vlan'.$i];
if(!empty($_POST['mask'.$i]))$vlan_cmd .= " --eumask ".$_POST['mask'.$i];
$output = shell_exec($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 ";
}
}
?>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
......@@ -22,45 +22,64 @@
<?php $_SESSION['advance']=""; ?>
<?php
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">';
echo '<tr><th>Endpoint</th><th>VLANs</th></tr>';
for($i = 0; $i < 18; $i++){
echo '<tr>';
echo '<td><center><b>wr'.($i+1).'</b></center></td>';
//Show the Vlan option button
echo '<td>';
echo '<form method=POST><div>
<select name='.($i).'>';
for($op = 0; $op < 18; $op++){
echo '<tr align=center><th>VID</th><th>FID</th><th>MASK</th><th>DROP</th><th>PRIO</th><th>PRIO_OVERRIDE</th></tr>';
$counter = 0;
foreach($vlans as $line){
$counter++;
echo '<option class="btn" value="'.($op+1).'"><center>Vlan'.($op+1).'</center></option>';
if($counter>=2 && !empty($line)){
$line = explode(" ", $line);
if(strcmp($line[3],"0x")){
echo '<tr align=center><th>'.$line[1].'</th><th>'.$line[2].'</th><th>'.$line[3].'</th><th>'.$line[4].'</th><th>'.$line[5].'</th><th>'.$line[6].'</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>'.$line[3].$line[4].'</th><th>'.$line[5].'</th><th>'.$line[6].'</th><th>'.$line[7].'</th><th><A HREF="delvlan.php?vlan='.$line[1].'.">Delete</A></th></tr>';
}
}
echo '</select>';
echo '</td>';
}
echo '<input type="hidden" value=cmd name=cmd>';
echo '<p align="right"><input type="submit" value="Add VLANs" class="btn" ></p>
</form>';
echo '</tr>';
//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>
</select>
</th>
<th></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>
//Parse input and run the command
if (!empty($_POST['cmd'])){
$input = $_POST;
wrs_vlan_configuration($input);
}
<br><br><br><br><hr><p align="right"><A HREF="port2vlan.php">Assign Ports to VLANs</A></p>
wrs_vlan_display();
?>
</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