From: <kr...@us...> - 2007-01-24 18:21:12
|
Revision: 522 http://svn.sourceforge.net/astlinux/?rev=522&view=rev Author: krisk84 Date: 2007-01-24 10:21:04 -0800 (Wed, 24 Jan 2007) Log Message: ----------- add nistnet to the web interface Modified Paths: -------------- trunk/package/minihttpd/www.tar.gz trunk/package/nistnet/nistnet.mk Added Paths: ----------- trunk/package/nistnet/nistnet.php Modified: trunk/package/minihttpd/www.tar.gz =================================================================== (Binary files differ) Modified: trunk/package/nistnet/nistnet.mk =================================================================== --- trunk/package/nistnet/nistnet.mk 2007-01-24 17:45:35 UTC (rev 521) +++ trunk/package/nistnet/nistnet.mk 2007-01-24 18:21:04 UTC (rev 522) @@ -38,6 +38,9 @@ $(INSTALL) -D -m 0644 $(NISTNET_DIR)/$(NISTNET_BINARY) $(TARGET_DIR)/$(NISTNET_TARGET_BINARY) $(INSTALL) -D -m 0755 package/nistnet/nistnet.init $(TARGET_DIR)/etc/init.d/nistnet # -$(STRIP) $(TARGET_DIR)/$(NISTNET_TARGET_BINARY) +ifeq ($(strip $(BR2_PACKAGE_MINIHTTPD)),y) + $(INSTALL) -D -m 0755 package/nistnet/nistnet.php $(TARGET_DIR)/stat/var/www/admin/nistnet.php +endif /sbin/depmod -ae -F $(BUILD_DIR)/linux/System.map -b $(BUILD_DIR)/root -r $(LINUX_VER) touch -c $(TARGET_DIR)/$(NISTNET_TARGET_BINARY) @@ -53,6 +56,9 @@ -rm $(TARGET_DIR)/$(NISTNET_TARGET_BINARY) -rm $(TARGET_DIR)/etc/init.d/nistnet /sbin/depmod -ae -F $(BUILD_DIR)/linux/System.map -b $(BUILD_DIR)/root -r $(LINUX_VER) +ifeq ($(strip $(BR2_PACKAGE_MINIHTTPD)),y) + -rm $(TARGET_DIR)/stat/var/www/admin/nistnet.php +endif -$(MAKE) -C $(NISTNET_DIR) clean nistnet-dirclean: Added: trunk/package/nistnet/nistnet.php =================================================================== --- trunk/package/nistnet/nistnet.php (rev 0) +++ trunk/package/nistnet/nistnet.php 2007-01-24 18:21:04 UTC (rev 522) @@ -0,0 +1,167 @@ +<? +include "header.php"; + + + +//we've set a hidden variable to see if we've been submitted -- +if(isset($_POST['submitted'])) { + + switch($_POST['submit']) { + case "Status": + + $src = (isset($_POST['src'])) ? $_POST['src'] : "0.0.0.0"; + $dst = (isset($_POST['dst'])) ? $_POST['dst'] : "0.0.0.0"; + + $src = preg_replace('/[^0-9.]/', '', $src); + $dst = preg_replace('/[^0-9.]/', '', $dst); + + echo "<p class=\"alert\">Current Status:</p>"; + // system("/usr/sbin/cnistnet -s $src $dst"); + system("/usr/sbin/cnistnet -R"); + echo "<BR><BR>"; + break; + case "Clear": + + $src = (isset($_POST['src'])) ? $_POST['src'] : "0.0.0.0"; + $dst = (isset($_POST['dst'])) ? $_POST['dst'] : "0.0.0.0"; + + $src = preg_replace('/[^0-9.]/', '', $src); + $dst = preg_replace('/[^0-9.]/', '', $dst); + + exec("/usr/sbin/cnistnet -r $src $dst"); + + echo "<p class=\"alert\">Existing rules removed</p>"; + + break; + + case "Enable": + + system("/usr/sbin/cnistnet -u"); + + echo "<p class=\"alert\">Simulator enabled</p>"; + break; + + case "Disable": + + system("/usr/sbin/cnistnet -d"); + + echo "<p class=\"alert\">Simulator disabled</p>"; + break; + + case "Set": + //initialize our three vars (either via post, or set to 0) + $bandwidth = (isset($_POST['bandwidth'])) ? $_POST['bandwidth'] : "0"; + $latency = (isset($_POST['latency'])) ? $_POST['latency'] : "0"; + $packetloss = (isset($_POST['packetloss'])) ? $_POST['packetloss'] : "0"; + + //get our source and dest IP + $src = (isset($_POST['src'])) ? $_POST['src'] : "0.0.0.0"; + $dst = (isset($_POST['dst'])) ? $_POST['dst'] : "0.0.0.0"; + + //clean the source and IP (numeric, plus a ".") + $src = preg_replace('/[^0-9.]/', '', $src); + $dst = preg_replace('/[^0-9.]/', '', $dst); + + + //each of the three can take an "other" as a value. If that's set, check the corresponding text input for the value we should use + //for bandwidth, we need to divide by 8 (bps -> Bps) + + if($bandwidth == "other") { + $bandwidth = (isset($_POST['bandwidth_other'])) ? $_POST['bandwidth_other'] : "0"; + $bandwidth = round($bandwidth / 8); + } + + //finally, strip all non-numeric stuff from the variable + + $bandwidth = preg_replace('/[^0-9]/', '', $bandwidth); + + //and repeat for latency and packetloss + + if($latency == "other") { + $latency = (isset($_POST['latency_other'])) ? $_POST['latency_other'] : "0"; + } + $latency = preg_replace('/[^0-9]/', '', $latency); + + if($packetloss == "other") { + $packetloss = (isset($_POST['packetloss_other'])) ? $_POST['packetloss_other'] : "0"; + } + $packetloss = preg_replace('/[^0-9]/', '', $packetloss); + + //exec whatever our command is -- + + exec("/usr/sbin/cnistnet -a $src $dst --delay $latency --bandwidth $bandwidth --drop $packetloss --drd 79 80 0"); + + echo "<p class=\"alert\">Traffic shaper set to:<br> bandwidth: $bandwidth Bps<br> latency: $latency ms<br> packetloss: $packetloss %</p>"; + break; + } + +} +?> + + +<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST"> + +<table> + <tr style="vertical-align: top;"> + <td> + <h2>Bandwidth</h2> + <p> + <input type="radio" name="bandwidth" value="1875000" checked> 15mb<br> + <input type="radio" name="bandwidth" value="1250000"> 10mb<br> + <input type="radio" name="bandwidth" value="625000"> 5mb<br> + <input type="radio" name="bandwidth" value="250000"> 2mb<br> + <input type="radio" name="bandwidth" value="125000"> 1mb<br> + <input type="radio" name="bandwidth" value="64000"> 512kb<br> + <input type="radio" name="bandwidth" value="other"> Other: <input type="text" name="bandwidth_other" size="10">bps<br> + </p> + </td> + <td> + <h2>Latency</h2> + <p> + <input type="radio" name="latency" value="10" checked> 10ms<br> + <input type="radio" name="latency" value="20"> 20ms<br> + <input type="radio" name="latency" value="40"> 40ms<br> + <input type="radio" name="latency" value="60"> 60ms<br> + <input type="radio" name="latency" value="80"> 80ms<br> + <input type="radio" name="latency" value="100"> 100ms<br> + <input type="radio" name="latency" value="120"> 120ms<br> + <input type="radio" name="latency" value="140"> 140ms<br> + <input type="radio" name="latency" value="160"> 160ms<br> + <input type="radio" name="latency" value="180"> 180ms<br> + <input type="radio" name="latency" value="200"> 200ms<br> + <input type="radio" name="latency" value="other"> Other: <input type="text" name="latency_other" size="3">ms<br> + </p> + </td> + </tr> + <tr> + <td> + <h2>Packet Loss</h2> + <p> + <input type="radio" name="packetloss" value="0" checked> 0%<br> + <input type="radio" name="packetloss" value="5"> 5%<br> + <input type="radio" name="packetloss" value="10"> 10%<br> + <input type="radio" name="packetloss" value="15"> 15%<br> + <input type="radio" name="packetloss" value="20"> 20%<br> + <input type="radio" name="packetloss" value="other"> Other: <input type="text" name="packetloss_other" size="3">%<br> + </p> + </td> + + <td> + <p><b>Source IP:</b> <input type="text" name="src" value="0.0.0.0" size="12"></p> + <p><b>Destination IP:</b> <input type="text" name="dst" value="0.0.0.0" size="12"></p> + <input type="hidden" name="submitted" value="true"> + <input type="submit" name="submit" value="Set"> + <input type="submit" name="submit" value="Clear"> + <input type="submit" name="submit" value="Status"><br> + <input type="submit" name="submit" value="Enable"> + <input type="submit" name="submit" value="Disable"> + </td> + </tr> +</table> + +</form> + +<?php +include "footer.php"; +?> + Property changes on: trunk/package/nistnet/nistnet.php ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |