jeste drobny bugfix a hotovo
[svn/Prometheus-QoS/.git] / prometheus.c
index 3abaa34ecb78b77d2ed83100e20b42b3d05f13f2..c7887a0e5b099f1326f2229f802a48222b879fb1 100644 (file)
@@ -1,13 +1,13 @@
-\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, 20080201\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.7-1"; /*0.7.9 will be last development, 0.8.0 first stable */\r
+const char *version="0.7.8"; /*0.7.9 will be last development, 0.8.0 first stable */\r
 \r
 /* ======= Help screen is hopefuly self-documenting part of code :-) ======= */\r
 \r
@@ -74,7 +74,7 @@ char *cmdlog="/var/log/prometheus";    /* command log filename */
 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_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
@@ -88,8 +88,8 @@ int qos_proxy=1;               /* include proxy port to QoS */
 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
@@ -111,10 +111,10 @@ FILE *log_file=NULL;
 \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
@@ -563,6 +563,10 @@ void run_restore(void)
 {\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
@@ -641,7 +645,7 @@ program
 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
@@ -748,7 +752,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version);
      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
@@ -1075,7 +1079,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version);
      }\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
@@ -1459,6 +1463,10 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version);
 \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
@@ -1481,7 +1489,7 @@ Credits: CZFree.Net, Martin Devera, Netdave, Aquarius\n\n",version);
 \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
This page took 0.130651 seconds and 4 git commands to generate.