4 Copyright (C) 2006-2008 Jonathan Zarate
5 rate limit & connection limit by conanxu
8 TOASTMAN - client monitor
10 Files used with the clientmon function:
12 httpd/bwm.c // write to the correct in/out stats display
21 bwm-common.js // gives names to the imq interfaces
31 #include <arpa/inet.h>
33 //#include <sys/stat.h>
35 static char old_ip_address
[16]="none";
41 char *s
= "/tmp/start_cmon.sh";
48 // This nvram variable should be either 0 (off) or 1 (on)
50 if (!nvram_get_int("cmon_enable")) return;
52 //read ip address to monitor from nvram
53 p
= nvram_safe_get("cmon_ipaddr");
55 if ((f
= fopen(s
, "w")) == NULL
) return;
62 if (strcmp(old_ip_address
, "none"))
65 "iptables -t mangle -D PREROUTING -s %s -j IMQ --todev 3\n"
66 "iptables -t mangle -D POSTROUTING -d %s -j IMQ --todev 4\n",
67 old_ip_address
, old_ip_address
72 "ip link set imq3 up txqueuelen 100\n"
73 "ip link set imq4 up txqueuelen 100\n"
74 "iptables -t mangle -A PREROUTING -s %s -j IMQ --todev 3\n"
75 "iptables -t mangle -A POSTROUTING -d %s -j IMQ --todev 4\n"
86 if (_eval(argv
, NULL
, 0, &pid
) != 0) {
91 strcpy(old_ip_address
, p
);
100 This is working! All above is OK - Test the stop now...
109 char *s
= "/tmp/stop_cmon.sh";
113 if (nvram_get_int("cmon_enable")) return;
115 if ((f
= fopen(s
, "w")) == NULL
) return;
120 if (strcmp(old_ip_address
, "none"))
123 "iptables -t mangle -D PREROUTING -s %s -j IMQ --todev 3\n"
124 "iptables -t mangle -D POSTROUTING -d %s -j IMQ --todev 4\n",
125 old_ip_address
, old_ip_address
);
128 "ip link set imq3 down\n"
129 "ip link set imq4 down\n"
140 if (_eval(argv
, NULL
, 0, &pid
) != 0) {
145 strcpy(old_ip_address
, "none");