diff -Nuar lms-org/daemon/modules/tc/tc.c lms/daemon/modules/tc/tc.c
--- lms-org/daemon/modules/tc/tc.c	2006-02-25 21:06:34.000000000 +0100
+++ lms/daemon/modules/tc/tc.c	2006-04-06 18:35:42.000000000 +0200
@@ -231,26 +231,50 @@
 								}
 							}
 							
-							if(h_climit)
+							if(!tc->limit_per_host)
 							{
-								g->str_replace(&cl, "%climit", itoa(h_climit));
-								g->str_replace(&cl, "%n", name);
-    								g->str_replace(&cl, "%i", ipaddr);
-								g->str_replace(&cl, "%m", mac);
-								g->str_replace(&cl, "%x", itoa(x));
-								fprintf(fh, "%s", cl);
-							}
+							    if(h_climit)
+							    {
+								    g->str_replace(&cl, "%climit", itoa(h_climit));
+								    g->str_replace(&cl, "%n", name);
+    								    g->str_replace(&cl, "%i", ipaddr);
+								    g->str_replace(&cl, "%m", mac);
+								    g->str_replace(&cl, "%x", itoa(x));
+								    fprintf(fh, "%s", cl);
+							    }
 							
-							if(h_plimit)
+							    if(h_plimit)
+							    {
+								    g->str_replace(&pl, "%plimit", itoa(h_plimit));
+								    g->str_replace(&pl, "%n", name);
+								    g->str_replace(&pl, "%i", ipaddr);
+								    g->str_replace(&pl, "%m", mac);
+								    g->str_replace(&pl, "%x", itoa(x));
+								    fprintf(fh, "%s", pl);
+							    }	
+							} else
 							{
-								g->str_replace(&pl, "%plimit", itoa(h_plimit));
-								g->str_replace(&pl, "%n", name);
-								g->str_replace(&pl, "%i", ipaddr);
-								g->str_replace(&pl, "%m", mac);
-								g->str_replace(&pl, "%x", itoa(x));
-								fprintf(fh, "%s", pl);
-							}	
-					
+							    if(n_climit)
+							    {
+								    g->str_replace(&cl, "%climit", itoa(n_climit));
+								    g->str_replace(&cl, "%n", name);
+    								    g->str_replace(&cl, "%i", ipaddr);
+								    g->str_replace(&cl, "%m", mac);
+								    g->str_replace(&cl, "%x", itoa(x));
+								    fprintf(fh, "%s", cl);
+							    }
+							
+							    if(n_plimit)
+							    {
+								    g->str_replace(&pl, "%plimit", itoa(n_plimit));
+								    g->str_replace(&pl, "%n", name);
+								    g->str_replace(&pl, "%i", ipaddr);
+								    g->str_replace(&pl, "%m", mac);
+								    g->str_replace(&pl, "%x", itoa(x));
+								    fprintf(fh, "%s", pl);
+							    }
+							}
+							
 							if(tc->one_class_per_host) x++;
 						}
 						
@@ -258,18 +282,18 @@
 						{
 							g->str_replace(&htb_up, "%n", name);
 							g->str_replace(&htb_up, "%x", itoa(x));
-							g->str_replace(&htb_up, "%uprate", uprate);
+							g->str_replace(&htb_up, "%uprate", itoa(n_uprate));
 							if(!n_upceil)
-								g->str_replace(&htb_up, "%upceil", uprate);
+								g->str_replace(&htb_up, "%upceil", itoa(n_uprate));
 							else
-								g->str_replace(&htb_up, "%upceil", upceil);
+								g->str_replace(&htb_up, "%upceil", itoa(n_upceil));
 							g->str_replace(&htb_down, "%n", name);
 							g->str_replace(&htb_down, "%x", itoa(x));
-							g->str_replace(&htb_down, "%downrate", downrate);
+							g->str_replace(&htb_down, "%downrate", itoa(n_downrate));
 							if(!n_downceil)
-								g->str_replace(&htb_down, "%downceil", downrate);
+								g->str_replace(&htb_down, "%downceil", itoa(n_downrate));
 							else						
-								g->str_replace(&htb_down, "%downceil", downceil);
+								g->str_replace(&htb_down, "%downceil", itoa(n_downceil));
 						
 							// write to file
 							fprintf(fh, "%s", htb_up);
@@ -454,6 +478,7 @@
 	tc->networks = strdup(g->config_getstring(tc->base.ini, tc->base.instance, "networks", ""));
 	tc->customergroups = strdup(g->config_getstring(tc->base.ini, tc->base.instance, "customergroups", ""));
 	tc->one_class_per_host = g->config_getbool(tc->base.ini, tc->base.instance, "one_class_per_host", 0);
+	tc->limit_per_host = g->config_getbool(tc->base.ini, tc->base.instance, "limit_per_host", 0);
 #ifdef DEBUG1
 	syslog(LOG_INFO, "DEBUG: [%s/tc] initialized", tc->base.instance);
 #endif
diff -Nuar lms-org/daemon/modules/tc/tc.h lms/daemon/modules/tc/tc.h
--- lms-org/daemon/modules/tc/tc.h	2005-05-26 12:33:02.000000000 +0200
+++ lms/daemon/modules/tc/tc.h	2006-04-06 16:48:40.000000000 +0200
@@ -30,4 +30,5 @@
 	unsigned char *networks;
 	unsigned char *customergroups;
 	int one_class_per_host;
+	int limit_per_host;
 };
diff -Nuar lms-org/daemon/modules/traffic/traffic.c lms/daemon/modules/traffic/traffic.c
--- lms-org/daemon/modules/traffic/traffic.c	2006-02-25 21:06:34.000000000 +0100
+++ lms/daemon/modules/traffic/traffic.c	2006-04-06 16:37:29.000000000 +0200
@@ -60,6 +60,9 @@
 
 	if( g->db_nrows(res) )
 	{
+                if (traffic->before)
+                           system(traffic->command);
+                           
 		for(i=0; i<g->db_nrows(res); i++)
 		{
 			hosts = (HOSTS *) realloc(hosts, sizeof(HOSTS) * (j + 1));
@@ -109,9 +112,13 @@
 	else 
 		syslog(LOG_ERR, "[%s/traffic] Unable to read table 'nodes'", traffic->base.instance);
 
+        if (!traffic->before)
+                   system(traffic->command);
+
 	g->db_free(&res);
 	free(hosts);
 	free(traffic->file);
+	free(traffic->command);
 }
 
 struct traffic_module * init(GLOBAL *g, MODULE *m)
@@ -128,7 +135,8 @@
 	traffic->base.reload = (void (*)(GLOBAL *, MODULE *)) &reload;
 
 	traffic->file = strdup(g->config_getstring(traffic->base.ini, traffic->base.instance, "file", "/var/log/traffic.log"));
-	
+	traffic->command = strdup(g->config_getstring(traffic->base.ini, traffic->base.instance, "command", ""));
+	traffic->before = g->config_getbool(traffic->base.ini, traffic->base.instance, "before", 1);
 #ifdef DEBUG1
 	syslog(LOG_INFO,"DEBUG: [%s/traffic] initialized", traffic->base.instance);
 #endif	
diff -Nuar lms-org/daemon/modules/traffic/traffic.h lms/daemon/modules/traffic/traffic.h
--- lms-org/daemon/modules/traffic/traffic.h	2004-04-21 10:20:15.000000000 +0200
+++ lms/daemon/modules/traffic/traffic.h	2006-04-06 16:08:57.000000000 +0200
@@ -3,6 +3,8 @@
 {
 	MODULE base;
 	unsigned char *file;
+	unsigned char *command;
+	int before;
 };
 
 typedef struct
