-\r
-/* ============================================================= */\r
-/* === Prometheus QoS - you can "steal fire" from your ISP === */\r
-/* === "fair-per-IP" quality of service (QoS) utility === */\r
-/* === requires Linux 2.4.x or 2.6.x with HTB support === */\r
-/* === Copyright(C) 2005-2008 Michael Polak (xChaos) === */\r
-/* === Credits: CZFree.Net, Martin Devera, Netdave, Aquarius === */\r
-/* ============================================================= */\r
-\r
-/* Modified: xChaos, 20080119\r
+/* =============================================================== */\r
+/* == Prometheus QoS - you can "steal fire" from your ISP == */\r
+/* == "fair-per-IP" quality of service (QoS) utility == */\r
+/* == requires Linux 2.4.x or 2.6.x with HTB support == */\r
+/* == Copyright(C) 2005-2008 Michael Polak (xChaos) == */\r
+/* == iptables-restore support Copyright(C) 2007-2008 ludva == */\r
+/* == Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf == */\r
+/* =============================================================== */\r
+\r
+/* Modified: xChaos, 20080202\r
ludva, 20071227\r
\r
Prometheus QoS is free software; you can redistribute it and/or\r
\r
#define STRLEN 256\r
#define FIRSTGROUPID 1024\r
-#define MAX_GUARANTED_KBPS 2048\r
+#define FIRSTIPCLASS 2048\r
#undef DEBUG\r
\r
-#include "cll1.h"\r
+#include "cll1-0.6.h"\r
+\r
+const char *version="0.7.8"; /*0.7.9 will be last development, 0.8.0 first stable */\r
+\r
+/* ======= All path names are defined hear (for RPM patch) ======= */\r
+\r
+char *tc = "/sbin/tc"; /* requires tc with HTB support */\r
+char *iptables = "/sbin/iptables"; /* requires iptables utility */\r
+char *iptablessave = "/sbin/iptables-save"; /* not yet required */\r
+char *iptablesrestore = "/sbin/iptables-restore"; /* requires iptables-restore */\r
\r
-const char *version="0.7.7-1"; /*0.7.9 will be last development, 0.8.0 first stable */\r
+char *config = "/etc/prometheus/prometheus.conf"; /* main configuration file */\r
+char *hosts = "/etc/prometheus/hosts"; /* per-IP bandwidth definition file */\r
+\r
+char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/\r
+char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */\r
+char *html = "/var/www/traffic.html"; /* hall of fame filename */\r
+char *preview = "/var/www/preview.html"; /* hall of fame preview */\r
+char *cmdlog = "/var/log/prometheuslog"; /* command log filename */\r
+char *log_dir = "/var/www/logs/"; /* log directory pathname, ended with slash */\r
+char *log_url = "logs/"; /* log directory relative URI prefix (partial URL) */\r
\r
/* ======= Help screen is hopefuly self-documenting part of code :-) ======= */\r
\r
char *mark="MARK";\r
char *mark_iptables="MARK --set-mark ";\r
int dry_run=0; /* preview - use puts() instead of system() */\r
-char *config="/etc/prometheus/prometheus.conf"; /* main configuration file */\r
-char *hosts="/etc/prometheus/hosts"; /* line bandwidth definition file */\r
-char *tc="/sbin/tc"; /* requires tc with HTB support */\r
-char *iptables="/sbin/iptables"; /* requires iptables utility */\r
-char *iptablessave="/sbin/iptables-save"; /* new */\r
-char *iptablesrestore="/sbin/iptables-restore"; /* new */\r
-char *iptablesfile="/var/spool/prometheus.iptables"; /* new; file for iptables-restore*/\r
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]";\r
FILE *iptables_file=NULL;\r
-char *html="/var/www/traffic.html"; /* hall of fame filename */\r
-char *preview="/var/www/preview.html"; /* hall of fame preview */\r
-char *cmdlog="/var/log/prometheus"; /* command log filename */\r
-char *credit="/var/run/prometheus.credit"; /* credit log file */\r
int enable_credit=1; /* enable credit file */\r
int use_credit=0; /* use credit file (if enabled)*/\r
-char *log_dir="/var/www/logs/"; /* log directory pathname */\r
-char *log_url="logs/"; /* log directory URL prefix */\r
char *title="Hall of Fame - Greatest Suckers"; /* hall of fame title */\r
int hall_of_fame=1; /* enable hall of fame */\r
char *lan="eth0"; /* LAN interface */\r
int include_upload=1; /* upload+download=total traffic */\r
char *proxy_ip="192.168.1.1/32"; /* our IP with proxy port */\r
int proxy_port=3128; /* proxy port number */\r
-long long int line=1024; /* WAN/ISP download in kbps */\r
-long long int up=1024; /* WAN/ISP upload in kbps */\r
+long long int line=1024; /* WAN/ISP download in kbps */\r
+long long int up=1024; /* WAN/ISP upload in kbps */\r
int free_min=32; /* minimum guaranted bandwidth for all undefined hosts */\r
int free_max=64; /* maximum allowed bandwidth for all undefined hosts */\r
int qos_free_delay=0; /* seconds to sleep before applying new QoS rules */\r
\r
char *kwd="via-prometheus"; /* /etc/hosts comment, eg. #qos-64-128 */\r
\r
-const int idxtable_treshold1=24; /* this is no longer configurable */\r
-const int idxtable_treshold2=12; /* this is no longer configurable */\r
-const int idxtable_bitmask1=3; /* this is no longer configurable */\r
-const int idxtable_bitmask2=3; /* this is no longer configurable */\r
+const int idxtable_treshold1=24; /* this is no longer configurable */\r
+const int idxtable_treshold2=12; /* this is no longer configurable */\r
+const int idxtable_bitmask1=3; /* this is no longer configurable */\r
+const int idxtable_bitmask2=3; /* this is no longer configurable */\r
\r
\r
/* not yet implemented:\r
{\r
char *restor, *str;\r
string(restor,STRLEN);\r
+\r
+ /*-----------------------------------------------------------------*/\r
+ printf("Running %s <%s ...\n",iptablesrestore,iptablesfile);\r
+ /*-----------------------------------------------------------------*/\r
\r
save_line("COMMIT");\r
fclose(iptables_file);\r
- if(dry_run) {\r
+ if(dry_run) \r
+ {\r
parse(iptablesfile)\r
{\r
str=_;\r
printf("%s\n", str);\r
}done;\r
- }else{\r
- //sprintf(restor,"cat %s",iptablesfile); else \r
- sprintf(restor,"%s <%s",iptablesrestore, iptablesfile);\r
- system(restor);\r
- };\r
+ }\r
+\r
+ sprintf(restor,"%s <%s",iptablesrestore, iptablesfile);\r
+ safe_run(restor);\r
\r
free(restor);\r
}\r
Prometheus QoS - \"fair-per-IP\" Quality of Service setup utility.\n\\r
Version %s - Copyright (C)2005-2008 Michael Polak (xChaos)\n\\r
iptables-restore & burst tunning & classify modification 0.7d by Ludva\n\\r
-Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version);\r
+Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);\r
\r
/*----- Boring... we have to check command line options first: ----*/\r
\r
if(ip->max<ip->min)\r
ip->max=ip->min;\r
}\r
- ip->mark=MAX_GUARANTED_KBPS+1+class_count++;\r
+ ip->mark=FIRSTIPCLASS+1+class_count++;\r
\r
find(group,groups,group->min==ip->min) \r
{ \r
}\r
else\r
{\r
- if( keyword->data_prio && !ip->fixedprio &&\r
+ if( ip->keyword->data_prio && !ip->fixedprio &&\r
ip->traffic>ip->credit+\r
(ip->min*ip->keyword->data_prio+(ip->keyword->fixed_prio<<20)) )\r
{\r
\r
printf("Total IP count: %d\n", i);\r
\r
+ /*-----------------------------------------------------------------*/\r
+ puts("Generating free bandwith classes ...");\r
+ /*-----------------------------------------------------------------*/\r
+\r
/* ---------------------------------------- tc - free bandwith shared class */\r
sprintf(str,"%s class add dev %s parent 1:%d classid 1:3 htb rate %dkbit ceil %dkbit burst %dk prio 2",tc,lan,parent,free_min,free_max,burst);\r
safe_run(str);\r
\r
sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle 3 fw flowid 1:3",tc,wan);\r
safe_run(str);\r
- \r
+\r
run_restore();\r
\r
if (log_file) fclose(log_file);\r