X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=prometheus.c;h=013f7f20d63a01c4b3efef2a6babca4aa49a0584;hp=8a567a173671e6be1758b5f88d11a43facf48b52;hb=43cde5c3b21d9575669722e90143f93166c14140;hpb=5a8f2e77c57c7c7f2fcf1ef5933a0a771dd57777
diff --git a/prometheus.c b/prometheus.c
index 8a567a1..013f7f2 100644
--- a/prometheus.c
+++ b/prometheus.c
@@ -7,7 +7,7 @@
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* Modified: xChaos, 20080422
+/* Modified: xChaos, 20080504
ludva, 20080415
Prometheus QoS is free software; you can redistribute it and/or
@@ -33,32 +33,34 @@
#include "cll1-0.6.h"
-const char *version="0.7.9-c";
+const char *version = "0.7.9-c";
-/* Version numbers: 0.7.9 will be last development ("beta"), 0.8.0 first stable */
+/* Version numbers: 0.7.9 is development releases ("beta"), 0.8.0 will be "stable" */
/* Debian(RPM) package versions/patchlevels: 0.7.9-2, 0.8.0-1, 0.8.0-2, etc. */
/* C source code development versions ("beta"): 0.7.9-a, 0.8.1-b, etc. */
/* C source code release versions: 0.8.0, 0.8.2, 0.8.4, etc. */
+const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2008 Michael Polak, Arachne Labs\n";
+
/* ======= All path names are defined here (for RPM patch) ======= */
-char *tc = "/sbin/tc"; /* requires tc with HTB support */
-char *iptables = "/sbin/iptables"; /* requires iptables utility */
-char *iptablessave = "/sbin/iptables-save"; /* not yet required */
+char *tc = "/sbin/tc"; /* requires tc with HTB support */
+char *iptables = "/sbin/iptables"; /* requires iptables utility */
+char *iptablessave = "/sbin/iptables-save"; /* not yet required */
char *iptablesrestore = "/sbin/iptables-restore"; /* requires iptables-restore */
-char *ls = "/bin/ls"; /* this is not user configurable :-) */
+char *ls = "/bin/ls"; /* this is not user configurable :-) */
-char *config = "/etc/prometheus/prometheus.conf"; /* main configuration file */
-char *hosts = "/etc/prometheus/hosts"; /* per-IP bandwidth definition file */
+char *config = "/etc/prometheus/prometheus.conf"; /* main configuration file */
+char *hosts = "/etc/prometheus/hosts"; /* per-IP bandwidth definition file */
-char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/
-char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */
-char *html = "/var/www/traffic.html"; /* hall of fame filename */
-char *preview = "/var/www/preview.html"; /* hall of fame preview */
-char *cmdlog = "/var/log/prometheuslog"; /* command log filename */
-char *log_dir = "/var/www/logs/"; /* log directory pathname, ended with slash */
-char *log_url = "logs/"; /* log directory relative URI prefix (partial URL) */
-char *html_log_dir = "/var/www/logs/html/";
+char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/
+char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */
+char *html = "/var/www/traffic.html"; /* hall of fame filename */
+char *preview = "/var/www/preview.html"; /* hall of fame preview */
+char *cmdlog = "/var/log/prometheuslog"; /* command log filename */
+char *log_dir = "/var/www/logs/"; /* log directory pathname, ended with slash */
+char *log_url = "logs/"; /* log directory relative URI prefix (partial URL) */
+char *html_log_dir = "/var/www/logs/html/";
/* ======= Help screen is hopefuly self-documenting part of code :-) ======= */
@@ -83,51 +85,48 @@ void help(void)
-r just reload configuration (...and keep data transfer statistics)\n\
*/
}
-
/* === Configuraration file values defaults - stored in global variables ==== */
-int filter_type=1; /*1 mark, 2 classify*/
-char *mark="MARK";
-char *mark_iptables="MARK --set-mark ";
-int dry_run=0; /* preview - use puts() instead of system() */
-char *iptablespreamble="*mangle\n:PREROUTING ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]";
-FILE *iptables_file=NULL;
-int enable_credit=1; /* enable credit file */
-int use_credit=0; /* use credit file (if enabled)*/
-char *title="Hall of Fame - Greatest Suckers"; /* hall of fame title */
-int hall_of_fame=1; /* enable hall of fame */
-char *lan="eth0"; /* LAN interface */
-char *lan_medium="100Mbit"; /* 10Mbit/100Mbit ethernet */
-char *wan="eth1"; /* WAN/ISP interface */
-char *wan_medium="100Mbit"; /* 10Mbit/100Mbit ethernet */
-char *qos_leaf="sfq perturb 5"; /* leaf discipline */
-char *qos_free_zone=NULL; /* QoS free zone */
-int qos_proxy=1; /* include proxy port to QoS */
-int include_upload=1; /* upload+download=total traffic */
-char *proxy_ip="192.168.1.1/32"; /* our IP with proxy port */
-int proxy_port=3128; /* proxy port number */
-long long int line=1024; /* WAN/ISP download in kbps */
-long long int up=1024; /* WAN/ISP upload in kbps */
-int free_min=32; /* minimum guaranted bandwidth for all undefined hosts */
-int free_max=64; /* maximum allowed bandwidth for all undefined hosts */
-int qos_free_delay=0; /* seconds to sleep before applying new QoS rules */
-int digital_divide=2; /* controls digital divide weirdness ratio, 1...3 */
-int max_nesting=3; /* maximum nesting of HTB clases, built-in maximum seems to be 4 */
-int htb_r2q=1;
-int burst=8; /* HTB burst (in kbits) */
-int burst_main=64;
-int burst_group=32;
-int magic_priorities=8; /* number of priority levels (soft shaping) */
-int magic_treshold=8; /* reduce ceil by X*magic_treshhold kbps (hard shaping) */
-int keywordcount=0;
-
+int filter_type = 1; /*1 mark, 2 classify*/
+char *mark = "MARK";
+char *mark_iptables = "MARK --set-mark ";
+int dry_run = 0; /* preview - use puts() instead of system() */
+char *iptablespreamble = "*mangle\n:PREROUTING ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]";
+FILE *iptables_file = NULL;
+int enable_credit = 1; /* enable credit file */
+int use_credit = 0; /* use credit file (if enabled)*/
+char *title = "Hall of Fame - Greatest Suckers"; /* hall of fame title */
+int hall_of_fame = 1; /* enable hall of fame */
+char *lan = "eth0"; /* LAN interface */
+char *lan_medium = "100Mbit"; /* 10Mbit/100Mbit ethernet */
+char *wan = "eth1"; /* WAN/ISP interface */
+char *wan_medium = "100Mbit"; /* 10Mbit/100Mbit ethernet */
+char *qos_leaf = "sfq perturb 5"; /* leaf discipline */
+char *qos_free_zone = NULL; /* QoS free zone */
+int qos_proxy = 1; /* include proxy port to QoS */
+int include_upload = 1; /* upload+download=total traffic */
+char *proxy_ip = "192.168.1.1/32"; /* our IP with proxy port */
+int proxy_port = 3128; /* proxy port number */
+long long int line = 1024; /* WAN/ISP download in kbps */
+long long int up = 1024; /* WAN/ISP upload in kbps */
+int free_min = 32; /* minimum guaranted bandwidth for all undefined hosts */
+int free_max = 64; /* maximum allowed bandwidth for all undefined hosts */
+int qos_free_delay = 0; /* seconds to sleep before applying new QoS rules */
+int digital_divide = 2; /* controls digital divide weirdness ratio, 1...3 */
+int max_nesting = 3; /* maximum nesting of HTB clases, built-in maximum seems to be 4 */
+int htb_r2q = 1;
+int burst = 8; /* HTB burst (in kbits) */
+int burst_main = 64;
+int burst_group = 32;
+int magic_priorities = 8; /* number of priority levels (soft shaping) */
+int magic_treshold = 8; /* reduce ceil by X*magic_treshhold kbps (hard shaping) */
+int keywordcount = 0;
/* not yet implemented:
- int fixed_packets=0; maximum number of pps per IP address (not class!)
- int packet_limit=5; maximum number of pps to htn CEIL, not rate !!!
+int fixed_packets = 0; maximum number of pps per IP address (not class!)
+int packet_limit = 5; maximum number of pps to htn CEIL, not rate !!!
*/
-FILE *log_file=NULL;
-
-char *kwd="via-prometheus"; /* /etc/hosts comment, eg. #qos-64-128 */
+FILE *log_file = NULL;
+char *kwd = "via-prometheus"; /* /etc/hosts comment, eg. #qos-64-128 */
const int idxtable_treshold1=24; /* this is no longer configurable */
const int idxtable_treshold2=12; /* this is no longer configurable */
@@ -707,7 +706,7 @@ void parse_ip_log(int argc, char **argv)
case 7:
case 8:
case 9:
- case 10: if (isalnum(*ptr)) /* alphanumeric string = date, just one*/
+ case 10: if (isalpha(*ptr)) /* character, not numeric string = date, just one*/
{
valid_columns(ptr2,ptr,' ',col2) switch(col2)
{
@@ -755,7 +754,8 @@ void parse_ip_log(int argc, char **argv)
total+=iplog->traffic>>10;
}
fprintf(f,"