--- etc/inc/shaper.inc	Sun May 16 07:09:58 2004
+++ etc/inc/shaper.inc	Sun May 23 15:18:53 2004
@@ -50,6 +50,9 @@
 		   a rule has matched */
 		mwexec("/sbin/sysctl net.inet.ip.fw.one_pass=1");
 		
+		/* change packet size to 1000 */
+		mwexec("/sbin/sysctl net.inet.ip.dummynet.red_avg_pkt_size=1000");
+
 		/* load shaper rules */
 		mwexec("/sbin/ipfw -f delete set 4");
 		mwexec("/sbin/ipfw -f pipe flush");
@@ -291,6 +294,9 @@
 				}
 			}
 			
+			if ($rule['iptos']) 
+				$line .= "iptos {$rule['iptos']} ";
+
 			if ($rule['iplen'])
 				$line .= "iplen {$rule['iplen']} ";
 			
--- usr/local/www/firewall_shaper.php	Sun May 16 07:09:58 2004
+++ usr/local/www/firewall_shaper.php	Sun May 23 15:15:58 2004
@@ -113,6 +113,7 @@
     <td nowrap class="tabact">Rules</td>
     <td nowrap class="tabinact"><a href="firewall_shaper_pipes.php" class="tblnk">Pipes</a></td>
     <td nowrap class="tabinact"><a href="firewall_shaper_queues.php" class="tblnk">Queues</a></td>
+    <td nowrap class="tabinact"><a href="firewall_shaper_magic.php" class="tblnk">Magic</a></td>
     <td width="100%">&nbsp;</td>
   </tr>
   <tr> 
--- usr/local/www/firewall_shaper_edit.php	Sun May 16 07:09:58 2004
+++ usr/local/www/firewall_shaper_edit.php	Sun May 23 15:15:58 2004
@@ -134,6 +134,7 @@
 	}
 	
 	$pconfig['direction'] = $a_shaper[$id]['direction'];
+	$pconfig['iptos'] = $a_shaper[$id]['iptos'];
 	$pconfig['iplen'] = $a_shaper[$id]['iplen'];
 	$pconfig['tcpflags'] = $a_shaper[$id]['tcpflags'];
 	$pconfig['descr'] = $a_shaper[$id]['descr'];
@@ -209,6 +210,15 @@
 		$_POST['dstmask'] = 32;
 	}
 	
+	$intos = array();
+	foreach ($iptos as $tos) {
+		if ($_POST['iptos_' . $tos] == "on")
+			$intos[] = $tos;
+		else if ($_POST['iptos_' . $tos] == "off")
+			$intos[] = "!" . $tos;
+	}
+	$_POST['iptos'] = join(",", $intos);
+
 	$intcpflags = array();
 	foreach ($tcpflags as $tcpflag) {
 		if ($_POST['tcpflags_' . $tcpflag] == "on")
@@ -311,6 +321,7 @@
 		
 		$shaperent['direction'] = $_POST['direction'];
 		$shaperent['iplen'] = $_POST['iplen'];
+		$shaperent['iptos'] = $_POST['iptos'];
 		$shaperent['tcpflags'] = $_POST['tcpflags'];
 		$shaperent['descr'] = $_POST['descr'];
 		
@@ -674,6 +685,28 @@
                     perspective). </td>
                 </tr>
                 <tr> 
+                  <td width="22%" valign="top" class="vncell">IP Type of Service (TOS)</td>
+                  <td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
+                      <?php 
+				  $iniptos = explode(",", $pconfig['iptos']);
+				  foreach ($iptos as $tos): $dontcare = true; ?>
+                      <tr> 
+                        <td width="40" nowrap><strong> 
+			  <?echo $tos;?>
+                          </strong></td>
+                        <td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="on" <?php if (array_search($tos, $iniptos) !== false) { echo "checked"; $dontcare = false; }?>>
+                          set&nbsp;&nbsp;&nbsp;</td>
+                        <td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="off" <?php if (array_search("!" . $tos, $iniptos) !== false) { echo "checked"; $dontcare = false; }?>>
+                          cleared&nbsp;&nbsp;&nbsp;</td>
+                        <td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="" <?php if ($dontcare) echo "checked";?>>
+                          don't care</td>
+                      </tr>
+                      <?php endforeach; ?>
+                    </table>
+                    <span class="vexpl">Use this to choose IP TOS fields that must 
+                    be set or cleared for this rule to match.</span></td>
+                </tr>
+                 <tr> 
                   <td width="22%" valign="top" class="vncell">IP packet length</td>
                   <td width="78%" class="vtable"><input name="iplen" type="text" id="iplen" size="10" value="<?=htmlspecialchars($pconfig['iplen']);?>"> 
                     <br>
--- usr/local/www/firewall_shaper_pipes.php	Sun May 16 07:09:58 2004
+++ usr/local/www/firewall_shaper_pipes.php	Sun May 23 15:15:58 2004
@@ -111,6 +111,7 @@
     <td nowrap class="tabinact"><a href="firewall_shaper.php" class="tblnk">Rules</a></td>
     <td nowrap class="tabact">Pipes</a></td>
     <td nowrap class="tabinact"><a href="firewall_shaper_queues.php" class="tblnk">Queues</a></td>
+    <td nowrap class="tabinact"><a href="firewall_shaper_magic.php" class="tblnk">Magic</a></td>
     <td width="100%">&nbsp;</td>
   </tr>
   <tr> 
--- usr/local/www/firewall_shaper_queues.php	Sun May 16 07:09:58 2004
+++ usr/local/www/firewall_shaper_queues.php	Sun May 23 15:15:58 2004
@@ -94,6 +94,7 @@
     <td nowrap class="tabinact"><a href="firewall_shaper.php" class="tblnk">Rules</a></td>
     <td nowrap class="tabinact"><a href="firewall_shaper_pipes.php" class="tblnk">Pipes</a></a></td>
     <td nowrap class="tabact">Queues</td>
+    <td nowrap class="tabinact"><a href="firewall_shaper_magic.php" class="tblnk">Magic</a></a></td>
     <td width="100%">&nbsp;</td>
   </tr>
   <tr> 
--- usr/local/www/guiconfig.inc	Sun May 16 07:09:58 2004
+++ usr/local/www/guiconfig.inc	Sun May 23 11:08:17 2004
@@ -71,6 +71,7 @@
 				 110 => "POP3", 143 => "IMAP", 443 => "HTTPS");
 
 /* TCP flags */
+$iptos = array("lowdelay", "throughput", "reliability", "mincost", "congestion");
 $tcpflags = array("fin", "syn", "rst", "psh", "ack", "urg");
 
 $specialnets = array("lan" => "LAN net", "pptp" => "PPTP clients");
