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
;
18 extern char *ip6prefix
;
20 /* This must be object oriented! This looks almost like constructor ;-) */
21 void TheIP(char *ipaddr
)
27 ip
->prio
= highest_priority
+1;
41 ip
->keyword
= keywords
;
42 ip
->v6
= (strchr(ip
->addr
,':')!=NULL
);
49 /* == This function strips extra characters after IPv4 address and stores it = */
52 char *ptr
, *ipaddr
, *ip6range
= NULL
, *ipname
= NULL
, *lmsid
= NULL
;
54 if(ip6prefix
) /* Try this only if IPv6 subsystem is active... */
56 ptr
= strstr(str
, "::");
57 if(ptr
&& ptr
-str
> 4)
60 duplicate(ptr
, ip6range
);
61 ptr
= strstr(ip6range
, "::");
69 ptr
= strchr(str
, '{');
73 while(*ptr
and *ptr
!= '}')
81 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
89 while(*ptr
and (*ptr
==' ' or *ptr
==9))
94 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
102 concatenate(ip6prefix
,ip6range
,ptr
);
104 if_exists(ip
, ips
, eq(ip
->addr
,ip6range
));
110 ip
->keyword
= defaultkeyword
; /* settings for default keyword */
113 ip
->lmsid
= atoi(lmsid
);
122 if_exists(ip
, ips
, eq(ip
->addr
,ipaddr
));
130 ip
->lmsid
= atoi(lmsid
);
135 /* == This function parses hosts style main configuration file == */
136 void parse_hosts(char *hosts
)
138 int groupidx
= FIRSTGROUPID
;
146 if(*str
< '0' or *str
> '9')
148 /* any line starting with non-number is comment ...*/
152 /* Does this IP share QoS class with some other ? */
153 substring
= strstr(str
, "sharing-");
156 substring
+= 8; /* "sharing-" */
158 ip
->sharing
= substring
;
159 ip
->keyword
= defaultkeyword
; /* settings for default keyword */
162 lastIP6
->sharing
= substring
;
165 while(*substring
and *substring
!= '\n')
173 /*Do we have to create new QoS class for this IP ? */
175 if_exists(keyword
,keywords
,(substring
=strstr(str
,keyword
->key
)))
180 lastIP6
->sharing
= ip
->name
;
183 ip
->keyword
= keyword
;
185 ip
->prio
= keyword
->default_prio
;
186 substring
+= strlen(keyword
->key
)+1;
188 while(*ptr
and *ptr
!= '-')
195 ip
->max
= ip
->desired
= atoi(ptr
+1);
197 ip
->min
= atoi(substring
);
200 printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kb/s\n",
204 if(ip
->max
<= ip
->min
)
206 ip
->fixedprio
= TRUE
;
207 ip
->max
= ip
->min
+ ip
->keyword
->reserve_min
;
211 ip
->max
-= ip
->keyword
->reserve_max
;
217 ip
->mark
= FIRSTIPCLASS
+1+class_count
++;
219 if_exists(group
,groups
,(group
->min
== ip
->min
))
222 group
->desired
+= ip
->min
;
223 ip
->group
= group
->id
;
228 group
->min
= ip
->min
;
229 group
->id
= groupidx
++;
230 ip
->group
= group
->id
;
232 if(group
->min
< 8) group
->min
= 8;
233 /* Warning - this is maybe because of primitive tc namespace, can be fixed */
234 /* it is because class IDs are derived from min. bandwidth. - xCh */
235 //if(group->min>MAX_GUARANTED_KBPS) group->min=MAX_GUARANTED_KBPS;
238 group
->desired
= ip
->min
;
239 insert(group
, groups
, desc_order_by
,min
);
249 done
; /* ugly macro end */
This page took 0.825676 seconds and 4 git commands to generate.