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
);
46 /* == This function strips extra characters after IPv4 address and stores it = */
47 void parse_ip(char *str
)
49 char *ptr
, *ipaddr
, *ip6range
= NULL
, *ipname
= NULL
, *lmsid
= NULL
;
51 if(ip6prefix
) /* Try this only if IPv6 subsystem is active...*/
53 ptr
= strstr(str
, "::");
54 if(ptr
&& ptr
-str
> 4)
57 duplicate(ptr
,ip6range
);
58 ptr
= strstr(ip6range
, "::");
66 ptr
= strchr(str
, '{');
70 while(*ptr
and *ptr
!= '}')
78 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
86 while(*ptr
and (*ptr
==' ' or *ptr
==9))
91 while(*ptr
and *ptr
!=' ' and *ptr
!=9)
99 concatenate(ip6prefix
,ip6range
,ptr
);
101 if_exists(ip
, ips
, eq(ip
->addr
,ip6range
));
107 ip
->sharing
= ipname
;
110 ip
->lmsid
= atoi(lmsid
);
114 if_exists(ip
, ips
, eq(ip
->addr
,ipaddr
));
122 ip
->lmsid
= atoi(lmsid
);
127 /* == This function parses hosts style main configuration file == */
128 void parse_hosts(char *hosts
)
130 int groupidx
= FIRSTGROUPID
;
138 if(*str
< '0' or *str
> '9')
140 /* any line starting with non-number is comment ...*/
144 /* Does this IP share QoS class with some other ? */
145 substring
= strstr(str
, "sharing-");
148 substring
+= 8; /* "sharing-" */
151 ip
->sharing
= substring
;
152 ip
->keyword
= defaultkeyword
; /* settings for default keyword */
153 while(*substring
and *substring
!= '\n')
161 /*Do we have to create new QoS class for this IP ? */
163 if_exists(keyword
,keywords
,(substring
=strstr(str
,keyword
->key
)))
167 ip
->keyword
= keyword
;
169 ip
->prio
= keyword
->default_prio
;
170 substring
+= strlen(keyword
->key
)+1;
172 while(*ptr
and *ptr
!= '-')
179 ip
->max
= ip
->desired
= atoi(ptr
+1);
181 ip
->min
= atoi(substring
);
184 printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kb/s\n",
188 if(ip
->max
<= ip
->min
)
190 ip
->fixedprio
= TRUE
;
191 ip
->max
= ip
->min
+ ip
->keyword
->reserve_min
;
195 ip
->max
-= ip
->keyword
->reserve_max
;
201 ip
->mark
= FIRSTIPCLASS
+1+class_count
++;
203 if_exists(group
,groups
,(group
->min
== ip
->min
))
206 group
->desired
+= ip
->min
;
207 ip
->group
= group
->id
;
212 group
->min
= ip
->min
;
213 group
->id
= groupidx
++;
214 ip
->group
= group
->id
;
216 if(group
->min
< 8) group
->min
= 8;
217 /* Warning - this is maybe because of primitive tc namespace, can be fixed */
218 /* it is because class IDs are derived from min. bandwidth. - xCh */
219 //if(group->min>MAX_GUARANTED_KBPS) group->min=MAX_GUARANTED_KBPS;
222 group
->desired
= ip
->min
;
223 insert(group
, groups
, desc_order_by
,min
);
233 done
; /* ugly macro end */
This page took 0.559688 seconds and 4 git commands to generate.