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
;
18 /* function implemented in prometheus.c */
21 /* == This function strips extra characters after IPv4 address and stores it = */
22 void parse_ip(char *str
)
24 char *ptr
, *ipaddr
= NULL
, *ipname
= NULL
, *lmsid
= NULL
;
26 ptr
= strchr(str
, '{');
30 while(*ptr
and *ptr
!= '}')
38 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
46 while(*ptr
and (*ptr
==' ' or *ptr
==9))
51 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
57 if_exists(ip
, ips
, eq(ip
->addr
,ipaddr
));
66 ip
->lmsid
= atoi(lmsid
);
71 /* == This function parses hosts style main configuration file == */
72 void parse_hosts(char *hosts
)
74 int groupidx
= FIRSTGROUPID
;
82 if(*str
< '0' or *str
> '9')
84 /* any line starting with non-number is comment ...*/
88 /* Does this IP share QoS class with some other ? */
89 substring
= strstr(str
, "sharing-");
92 substring
+= 8; /* "sharing-" */
95 ip
->sharing
= substring
;
96 ip
->keyword
= defaultkeyword
; /* settings for default keyword */
97 while(*substring
and *substring
!= '\n')
105 /*Do we have to create new QoS class for this IP ? */
107 if_exists(keyword
,keywords
,(substring
=strstr(str
,keyword
->key
)))
111 ip
->keyword
= keyword
;
113 ip
->prio
= keyword
->default_prio
;
114 substring
+= strlen(keyword
->key
)+1;
116 while(*ptr
and *ptr
!= '-')
123 ip
->max
= ip
->desired
= atoi(ptr
+1);
125 ip
->min
= atoi(substring
);
128 printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kb/s\n",
132 if(ip
->max
<= ip
->min
)
134 ip
->fixedprio
= TRUE
;
135 ip
->max
= ip
->min
+ ip
->keyword
->reserve_min
;
139 ip
->max
-= ip
->keyword
->reserve_max
;
145 ip
->mark
= FIRSTIPCLASS
+1+class_count
++;
147 if_exists(group
,groups
,(group
->min
== ip
->min
))
150 group
->desired
+= ip
->min
;
151 ip
->group
= group
->id
;
156 group
->min
= ip
->min
;
157 group
->id
= groupidx
++;
158 ip
->group
= group
->id
;
160 if(group
->min
< 8) group
->min
= 8;
161 /* Warning - this is maybe because of primitive tc namespace, can be fixed */
162 /* it is because class IDs are derived from min. bandwidth. - xCh */
163 //if(group->min>MAX_GUARANTED_KBPS) group->min=MAX_GUARANTED_KBPS;
166 group
->desired
= ip
->min
;
167 insert(group
, groups
, desc_order_by
,min
);
177 done
; /* ugly macro end */
This page took 0.367346 seconds and 5 git commands to generate.