-/* Modified by: xChaos, 20131029 */\r
+/* Modified by: xChaos, 20131220 */\r
\r
#include "cll1-0.6.2.h"\r
#include "ipstruct.h"\r
extern struct IP *ips, *ip, *sharedip, *networks;\r
extern struct Group *groups, *group;\r
extern struct Keyword *keyword, *defaultkeyword, *keywords;\r
+extern struct Macro *macro, *macros;\r
extern int class_count;\r
extern int ip_count;\r
extern int found_lmsid;\r
char *str, *ptr;\r
char *substring;\r
struct IP *network;\r
+ int pktratio;\r
\r
parse(hosts)\r
{\r
- str=_;\r
+ str = _;\r
\r
if(*str < '0' or *str > '9')\r
{\r
/* any line starting with non-number is comment ...*/\r
continue;\r
}\r
- \r
+\r
+ ptr = strchr(str,'\r'); /* fore unix-style end of line */\r
+ if(ptr)\r
+ {\r
+ *ptr = 0;\r
+ }\r
+ \r
+ /* first, expand (rewrite) any predefined macros, if found*/\r
+ for_each(macro, macros)\r
+ {\r
+ substring = strstr(str, macro->rewrite_from);\r
+ if(substring)\r
+ {\r
+ int l1, l3;\r
+ *substring = 0;\r
+ substring += strlen(macro->rewrite_from);\r
+ l1 = strlen(str);\r
+ l3 = strlen(substring);\r
+ string(ptr, l1 + strlen(macro->rewrite_to) + l3 + 1);\r
+ strcpy(ptr, str);\r
+ strcat(ptr, macro->rewrite_to);\r
+ strcat(ptr, substring);\r
+ str = ptr;\r
+ /* printf("REWRITE: %s -> %s\n",_,str); */\r
+ }\r
+ }\r
+\r
/* Does this IP share QoS class with some other ? */\r
substring = strstr(str, "sharing-");\r
if(substring)\r
ip->max = ip->min;\r
}\r
}\r
- \r
- /* MTU is 1450 bytes = 11600 bits ~= 12 kbit, max is in kb/s */\r
- ip->pps_limit = ip->max/12;\r
- ip->mark = FIRSTIPCLASS+1+class_count++;\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
+ {\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
+ ip->mark = FIRSTIPCLASS+1+class_count++; \r
update_network(ip->addr, ip);\r
\r
if_exists(group,groups,(group->min == ip->min)) \r
// TheIP("0.0.0.0", TRUE);\r
// ip->name = "TOTAL";\r
// ip->mask = 0;\r
-}
\ No newline at end of file
+}\r