1 /* Modified by: xChaos, 20121007 */
3 #include "cll1-0.6.2.h"
6 #define FIRSTGROUPID 1024
7 #define FIRSTIPCLASS 2048
9 /* globals declared in prometheus.c */
10 extern struct IP
*ips
, *ip
, *sharedip
;
11 extern struct Group
*groups
, *group
;
12 extern struct Keyword
*keyword
, *defaultkeyword
, *keywords
;
13 extern int class_count
;
15 extern int found_lmsid
;
17 extern const int highest_priority
;
19 /* This must be object oriented! This looks almost like constructor ;-) */
20 void TheIP(char *ipaddr
)
26 ip
->prio
= highest_priority
+1;
40 ip
->keyword
= keywords
;
44 /* == This function strips extra characters after IPv4 address and stores it = */
45 void parse_ip(char *str
)
47 char *ptr
, *ipaddr
= NULL
, *ipname
= NULL
, *lmsid
= NULL
;
49 ptr
= strchr(str
, '{');
53 while(*ptr
and *ptr
!= '}')
61 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
69 while(*ptr
and (*ptr
==' ' or *ptr
==9))
74 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
80 if_exists(ip
, ips
, eq(ip
->addr
,ipaddr
));
88 ip
->lmsid
= atoi(lmsid
);
93 /* == This function parses hosts style main configuration file == */
94 void parse_hosts(char *hosts
)
96 int groupidx
= FIRSTGROUPID
;
104 if(*str
< '0' or *str
> '9')
106 /* any line starting with non-number is comment ...*/
110 /* Does this IP share QoS class with some other ? */
111 substring
= strstr(str
, "sharing-");
114 substring
+= 8; /* "sharing-" */
117 ip
->sharing
= substring
;
118 ip
->keyword
= defaultkeyword
; /* settings for default keyword */
119 while(*substring
and *substring
!= '\n')
127 /*Do we have to create new QoS class for this IP ? */
129 if_exists(keyword
,keywords
,(substring
=strstr(str
,keyword
->key
)))
133 ip
->keyword
= keyword
;
135 ip
->prio
= keyword
->default_prio
;
136 substring
+= strlen(keyword
->key
)+1;
138 while(*ptr
and *ptr
!= '-')
145 ip
->max
= ip
->desired
= atoi(ptr
+1);
147 ip
->min
= atoi(substring
);
150 printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kb/s\n",
154 if(ip
->max
<= ip
->min
)
156 ip
->fixedprio
= TRUE
;
157 ip
->max
= ip
->min
+ ip
->keyword
->reserve_min
;
161 ip
->max
-= ip
->keyword
->reserve_max
;
167 ip
->mark
= FIRSTIPCLASS
+1+class_count
++;
169 if_exists(group
,groups
,(group
->min
== ip
->min
))
172 group
->desired
+= ip
->min
;
173 ip
->group
= group
->id
;
178 group
->min
= ip
->min
;
179 group
->id
= groupidx
++;
180 ip
->group
= group
->id
;
182 if(group
->min
< 8) group
->min
= 8;
183 /* Warning - this is maybe because of primitive tc namespace, can be fixed */
184 /* it is because class IDs are derived from min. bandwidth. - xCh */
185 //if(group->min>MAX_GUARANTED_KBPS) group->min=MAX_GUARANTED_KBPS;
188 group
->desired
= ip
->min
;
189 insert(group
, groups
, desc_order_by
,min
);
199 done
; /* ugly macro end */
This page took 0.336879 seconds and 4 git commands to generate.