84 |
|
{ |
85 |
|
const dlink_node *ptr = NULL; |
86 |
|
|
87 |
< |
if ((ptr = list->head)) { |
87 |
> |
if ((ptr = list->head)) |
88 |
> |
{ |
89 |
|
const struct MaskItem *conf = ptr->data; |
90 |
|
|
91 |
|
assert(conf->class); |
102 |
|
{ |
103 |
|
const dlink_node *ptr = NULL; |
104 |
|
|
105 |
< |
if ((ptr = list->head)) { |
105 |
> |
if ((ptr = list->head)) |
106 |
> |
{ |
107 |
|
const struct MaskItem *conf = ptr->data; |
108 |
|
|
109 |
|
assert(conf->class); |
120 |
|
{ |
121 |
|
const dlink_node *ptr = NULL; |
122 |
|
|
123 |
< |
if ((ptr = list->head)) { |
123 |
> |
if ((ptr = list->head)) |
124 |
> |
{ |
125 |
|
const struct MaskItem *conf = ptr->data; |
126 |
|
|
127 |
|
assert(conf->class); |
138 |
|
{ |
139 |
|
const dlink_node *ptr = NULL; |
140 |
|
|
141 |
< |
if ((ptr = list->head)) { |
141 |
> |
if ((ptr = list->head)) |
142 |
> |
{ |
143 |
|
const struct MaskItem *conf = ptr->data; |
144 |
|
|
145 |
|
assert(conf->class); |
156 |
|
{ |
157 |
|
const dlink_node *ptr = NULL; |
158 |
|
|
159 |
< |
if ((ptr = list->head)) { |
159 |
> |
if ((ptr = list->head)) |
160 |
> |
{ |
161 |
|
const struct MaskItem *conf = ptr->data; |
162 |
|
|
163 |
|
assert(conf->class); |
179 |
|
{ |
180 |
|
dlink_node *ptr = NULL; |
181 |
|
|
182 |
< |
DLINK_FOREACH(ptr, class_list.head) { |
182 |
> |
DLINK_FOREACH(ptr, class_list.head) |
183 |
> |
{ |
184 |
|
struct ClassItem *class = ptr->data; |
185 |
|
|
186 |
|
if (!irccmp(class->name, name)) |
208 |
|
{ |
209 |
|
dlink_node *ptr = NULL, *ptr_next = NULL; |
210 |
|
|
211 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, class_list.head) { |
211 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, class_list.head) |
212 |
> |
{ |
213 |
|
struct ClassItem *class = ptr->data; |
214 |
|
|
215 |
|
if (!class->active && !class->ref_count) |
231 |
|
* side effects - |
232 |
|
*/ |
233 |
|
int |
234 |
< |
cidr_limit_reached(int over_rule, |
228 |
< |
struct irc_ssaddr *ip, struct ClassItem *class) |
234 |
> |
cidr_limit_reached(int over_rule, struct irc_ssaddr *ip, struct ClassItem *class) |
235 |
|
{ |
236 |
|
dlink_node *ptr = NULL; |
237 |
|
struct CidrItem *cidr = NULL; |
247 |
|
DLINK_FOREACH(ptr, class->list_ipv4.head) |
248 |
|
{ |
249 |
|
cidr = ptr->data; |
250 |
+ |
|
251 |
|
if (match_ipv4(ip, &cidr->mask, class->cidr_bitlen_ipv4)) |
252 |
|
{ |
253 |
|
if (!over_rule && (cidr->number_on_this_cidr >= class->number_per_cidr)) |
254 |
|
return -1; |
255 |
+ |
|
256 |
|
cidr->number_on_this_cidr++; |
257 |
|
return 0; |
258 |
|
} |
259 |
|
} |
260 |
+ |
|
261 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
262 |
|
cidr->number_on_this_cidr = 1; |
263 |
|
cidr->mask = *ip; |
270 |
|
DLINK_FOREACH(ptr, class->list_ipv6.head) |
271 |
|
{ |
272 |
|
cidr = ptr->data; |
273 |
+ |
|
274 |
|
if (match_ipv6(ip, &cidr->mask, class->cidr_bitlen_ipv6)) |
275 |
|
{ |
276 |
|
if (!over_rule && (cidr->number_on_this_cidr >= class->number_per_cidr)) |
277 |
|
return -1; |
278 |
+ |
|
279 |
|
cidr->number_on_this_cidr++; |
280 |
|
return 0; |
281 |
|
} |
282 |
|
} |
283 |
+ |
|
284 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
285 |
|
cidr->number_on_this_cidr = 1; |
286 |
|
cidr->mask = *ip; |
317 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
318 |
|
{ |
319 |
|
cidr = ptr->data; |
320 |
+ |
|
321 |
|
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
322 |
|
{ |
323 |
< |
cidr->number_on_this_cidr--; |
324 |
< |
if (cidr->number_on_this_cidr == 0) |
325 |
< |
{ |
326 |
< |
dlinkDelete(ptr, &aclass->list_ipv4); |
327 |
< |
MyFree(cidr); |
328 |
< |
return; |
329 |
< |
} |
323 |
> |
cidr->number_on_this_cidr--; |
324 |
> |
|
325 |
> |
if (cidr->number_on_this_cidr == 0) |
326 |
> |
{ |
327 |
> |
dlinkDelete(ptr, &aclass->list_ipv4); |
328 |
> |
MyFree(cidr); |
329 |
> |
return; |
330 |
> |
} |
331 |
|
} |
332 |
|
} |
333 |
|
} |
337 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head) |
338 |
|
{ |
339 |
|
cidr = ptr->data; |
340 |
+ |
|
341 |
|
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
342 |
|
{ |
343 |
< |
cidr->number_on_this_cidr--; |
344 |
< |
if (cidr->number_on_this_cidr == 0) |
345 |
< |
{ |
346 |
< |
dlinkDelete(ptr, &aclass->list_ipv6); |
347 |
< |
MyFree(cidr); |
348 |
< |
return; |
349 |
< |
} |
343 |
> |
cidr->number_on_this_cidr--; |
344 |
> |
|
345 |
> |
if (cidr->number_on_this_cidr == 0) |
346 |
> |
{ |
347 |
> |
dlinkDelete(ptr, &aclass->list_ipv6); |
348 |
> |
MyFree(cidr); |
349 |
> |
return; |
350 |
> |
} |
351 |
|
} |
352 |
|
} |
353 |
|
} |