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 ;-) */
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
));
89 ip
->lmsid
= atoi(lmsid
);
94 /* == This function parses hosts style main configuration file == */
95 void parse_hosts(char *hosts
)
97 int groupidx
= FIRSTGROUPID
;
105 if(*str
< '0' or *str
> '9')
107 /* any line starting with non-number is comment ...*/
111 /* Does this IP share QoS class with some other ? */
112 substring
= strstr(str
, "sharing-");
115 substring
+= 8; /* "sharing-" */
118 ip
->sharing
= substring
;
119 ip
->keyword
= defaultkeyword
; /* settings for default keyword */
120 while(*substring
and *substring
!= '\n')
128 /*Do we have to create new QoS class for this IP ? */
130 if_exists(keyword
,keywords
,(substring
=strstr(str
,keyword
->key
)))
134 ip
->keyword
= keyword
;
136 ip
->prio
= keyword
->default_prio
;
137 substring
+= strlen(keyword
->key
)+1;
139 while(*ptr
and *ptr
!= '-')
146 ip
->max
= ip
->desired
= atoi(ptr
+1);
148 ip
->min
= atoi(substring
);
151 printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kb/s\n",
155 if(ip
->max
<= ip
->min
)
157 ip
->fixedprio
= TRUE
;
158 ip
->max
= ip
->min
+ ip
->keyword
->reserve_min
;
162 ip
->max
-= ip
->keyword
->reserve_max
;
168 ip
->mark
= FIRSTIPCLASS
+1+class_count
++;
170 if_exists(group
,groups
,(group
->min
== ip
->min
))
173 group
->desired
+= ip
->min
;
174 ip
->group
= group
->id
;
179 group
->min
= ip
->min
;
180 group
->id
= groupidx
++;
181 ip
->group
= group
->id
;
183 if(group
->min
< 8) group
->min
= 8;
184 /* Warning - this is maybe because of primitive tc namespace, can be fixed */
185 /* it is because class IDs are derived from min. bandwidth. - xCh */
186 //if(group->min>MAX_GUARANTED_KBPS) group->min=MAX_GUARANTED_KBPS;
189 group
->desired
= ip
->min
;
190 insert(group
, groups
, desc_order_by
,min
);
200 done
; /* ugly macro end */
This page took 0.371797 seconds and 5 git commands to generate.