extern int qos_proxy;\r
extern char *title;\r
extern char *log_url;\r
-extern int found_lmsid;\r
+extern int found_code;\r
extern char *lms_url;\r
extern char *log_dir;\r
extern char *ip6prefix;\r
f = fopen(str, "a");\r
if(f > 0)\r
{\r
- fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",\r
+ fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%s\t%s",\r
time(NULL), self->name, self->traffic, self->direct, self->proxy,\r
- self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/\r
+ self->upload, self->min, self->max, self->desired, self->code, d); /* d = date*/\r
fclose(f);\r
}\r
else\r
i=0;\r
if(f > 0)\r
{\r
- unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum = 0;\r
+ unsigned long long total_traffic = 1 /* prevent divide by zero */ , total_direct=0, total_proxy=0, total_upload=0, tmp_sum = 0;\r
unsigned long long total_pktup = 0, total_pktdown = 0;\r
int active_classes = 0;\r
// int colspan = 14;\r
int agreg_count = 0, limit_count = 0, prio_count = 0;\r
int popup_button = 0;\r
/* IPv6 vs. IPv4 stats */\r
- unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0;\r
+ unsigned long long pkts4 = 1, pkts6 = 1 /*prevent divide by zero */, bytes4 = 0, bytes6 = 0;\r
int count4 = 0, count6 = 0;\r
int mpkts;\r
double perc6;\r
fputs("</td>\n",f);\r
/* ----------------------------------------------- */\r
\r
- if(found_lmsid)\r
+ if(found_code)\r
{\r
fputs("<td style=\"text-align: right\">",f);\r
- if(ip->lmsid > 0)\r
+ if(ip->code[0])\r
{\r
- fprintf(f, "<a class=\"blue\" target=\"_blank\" href=\"%s%d\">%04d</a>\n",\r
- lms_url, ip->lmsid, ip->lmsid);\r
+ fprintf(f, "<a class=\"blue\" target=\"_blank\" href=\"%s%s\">%s</a>\n",\r
+ lms_url, ip->code, ip->code);\r
}\r
- else if(ip->lmsid == 0)\r
+ else if(ip->code[0] == 0)\r
{\r
fputs("------",f);\r
}\r
int aggregated;\r
int fixedprio;\r
int group;\r
- int lmsid;\r
+ char *code;\r
int pps_limit;\r
unsigned long long direct;\r
unsigned long long proxy;\r
\r
for_each(ip, ips)\r
{\r
- if( ip->lmsid > 0 \r
+ if( ip->code[0] > 0 \r
and (ip->traffic or ip->direct or ip->proxy or ip->upload))\r
{\r
if(jsoncount)\r
fprintf(f, ",\n");\r
}\r
fprintf(f, \r
- " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \\r
+ " \"%s\":{ \"code\": %s, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \\r
\"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d, \\r
\"pktsup\":%Lu, \"pktsdown\":%Lu, \"realquota\":%Lu, \"credit\":%Lu, \"dailyquota\":%ld }",\r
- ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, \r
+ ip->name, ip->code, ip->addr, ip->traffic, ip->direct, ip->proxy, \r
ip->upload, ip->min, ip->desired, ip->max, ip->pktsup, ip->pktsdown,\r
ip->realquota, ip->credit, (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)));\r
jsoncount++;\r
extern struct Macro *macro, *macros;\r
extern int class_count;\r
extern int ip_count;\r
-extern int found_lmsid;\r
+extern int found_code;\r
extern int free_min;\r
extern const int highest_priority;\r
extern char *ip6prefix;\r
ip->addr = ipaddr;\r
ip->sharing = NULL;\r
ip->prio = highest_priority+1;\r
- ip->lmsid = -1;\r
+ ip->code = "-----";\r
ip->fixedprio = \\r
ip->aggregated = \\r
ip->mark = \\r
void parse_and_append_ip(char *str, struct IP *listhead)\r
{\r
char *ptr, *ipaddr, *nextip6, *ip6buf; \r
- char *ip6uplink = NULL, *ip6range = NULL, *ipname = NULL, *lmsid = NULL;\r
+ char *ip6uplink = NULL, *ip6range = NULL, *ipname = NULL, *code = NULL;\r
\r
if(ip6prefix) /* Try this only if IPv6 subsystem is active... */\r
{\r
ptr = strchr(str, '{');\r
if(ptr)\r
{\r
- lmsid = ++ptr;\r
+ code = ++ptr;\r
while(*ptr and *ptr != '}')\r
{\r
ptr++;\r
}\r
ip->name = ip6range;\r
ip->keyword = defaultkeyword; /* settings for default keyword */\r
- if(lmsid)\r
+ if(code)\r
{\r
- ip->lmsid = atoi(lmsid);\r
+ ip->code = code;\r
}\r
lastIP6range = ip;\r
}\r
TheIP(ip6uplink, FALSE); /* always new IP - more IPs in single uplink network */\r
ip->name = ip6uplink;\r
ip->keyword = defaultkeyword; /* settings for default keyword */\r
- if(lmsid)\r
+ if(code)\r
{\r
- ip->lmsid = atoi(lmsid);\r
+ ip->code = code;\r
}\r
lastIP6uplink = ip;\r
}\r
TheIP(ipaddr, (listhead==networks));\r
}\r
ip->name = ipname;\r
- if(lmsid)\r
+ if(code)\r
{\r
- ip->lmsid = atoi(lmsid);\r
- found_lmsid = TRUE;\r
+ ip->code = code;\r
+ found_code = TRUE;\r
}\r
}\r
\r
}\r
}\r
\r
- /* avg MTU bytes * 8 >> 10 = in bits, max is in kb/s */\r
- pktratio = (ip->keyword->allowed_avgmtu*8) >> 10;\r
- if(pktratio > 0)\r
+ if(ip->keyword->allowed_avgmtu)\r
{\r
- ip->pps_limit = ip->max/pktratio;\r
- if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */\r
+ /* avg MTU bytes * 8 >> 10 = in bits, max is in kb/s */\r
+ pktratio = (ip->keyword->allowed_avgmtu*8) >> 10;\r
+ if(pktratio > 0)\r
{\r
- ip->pps_limit = 0; /* do not apply packet limits */\r
+ ip->pps_limit = ip->max/pktratio;\r
+ if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */\r
+ {\r
+ ip->pps_limit = 0; /* do not apply packet limits */\r
+ }\r
}\r
}\r
\r
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20220327\r
+/* Modified by: xChaos, 20220607\r
ludva, 20080415\r
\r
Prometheus QoS is free software; you can redistribute it and/or\r
#include "cll1-0.6.2.h"\r
#include "ipstruct.h"\r
\r
-const char *version = "1.0.0-b";\r
+const char *version = "1.0.0-d";\r
\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
/* Versions: 0.9.0 is development release, 1.0 will be "stable" */\r
char *qos_free_dst_ipset = NULL; /* QoS free zone - dst match ipset name, must be prepared outside prometheus */\r
char *qos_free_src_ipset = NULL; /* QoS free zone - src match ipset name, must be prepared outside prometheus */\r
/* int qos_proxy = TRUE; include proxy port to QoS */\r
-int found_lmsid = FALSE; /* show links to users in LMS information system */\r
+int found_code = FALSE; /* show links to users in LMS information system */\r
int include_upload = TRUE; /* 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
{\r
for_each(ip, ips) if(eq(technology->filename, ip->technology_str))\r
{\r
- fprintf(f,"%d,%s,%d\n", ip->lmsid, ip->ruian_id_str, ip->max);\r
+ fprintf(f,"%s,%s,%d\n", ip->code, ip->ruian_id_str, ip->max);\r
}\r
fclose(f);\r
}\r
sharedip->traffic_up += ip->upload;\r
ip->traffic = 0;\r
ip->mark = sharedip->mark; \r
- ip->lmsid = sharedip->lmsid;\r
+ ip->code = sharedip->code;\r
ip->pps_limit = sharedip->pps_limit; /* no other way to do this */\r
\r
/* Ugly hack: append IPv4 addresses of sharedip to IPv6 uplinks */\r
iptables_save_line(ip6preamble, IPv6);\r
}\r
\r
+ /* this doesn't seem to be way to go... about 2/3 of all packets have ACK flag set\r
+ maybe with --length 40:100 it would make some sense, but not enought \r
+ for_each(interface, interfaces)\r
+ {\r
+ sprintf(str,"-A %s -m tcp -p tcp --tcp-flags ACK ACK -o %s -j ACCEPT", interface->chain, interface->name);\r
+ iptables_save_line(str, IPv4);\r
+ }\r
+ */\r
+\r
if(qos_free_zone && *qos_free_zone != '0') /* this is currently supported only for IPv4 */\r
{\r
for_each(interface, interfaces)\r
}\r
\r
/*-----------------------------------------------------------------*/\r
- printf(" + generating iptables and tc classes ... ");\r
+ printf(" + generating iptables and tc classes ... \n");\r
/*-----------------------------------------------------------------*/\r
\r
for_each(ip, ips) if(ip->mark > 0)\r
{\r
fprintf(f, "%s %d\n", ip->addr, ip->mark);\r
}\r
+ printf(".");\r
}\r
if(f > 0)\r
{\r
- puts("done.");\r
+ puts(" done.");\r
fclose(f);\r
}\r
\r
sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d", tc, interface->name, FREE_CLASS, FREE_CLASS);\r
safe_run(str);\r
}\r
- /*-----------------------------------------------------------------*/\r
- puts("Generating bandwith class for overlimit packets...");\r
- /*-----------------------------------------------------------------*/\r
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",\r
- tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority, htb_quantum);\r
- safe_run(str);\r
+ if(*limit_pkts) /* non-empty string?*/\r
+ {\r
+ /*-----------------------------------------------------------------*/\r
+ puts("Generating bandwith class for overlimit packets...");\r
+ /*-----------------------------------------------------------------*/\r
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d", \r
+ tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority, htb_quantum);\r
+ safe_run(str);\r
+ }\r
} \r
printf("Total IP count: %d\n", i);\r
run_iptables_restore();\r