350 |
|
#endif |
351 |
|
} |
352 |
|
|
353 |
< |
static void |
354 |
< |
rebuild_cidr_list(int aftype, struct ClassItem *oldcl, struct ClassItem *newcl, |
355 |
< |
dlink_list *old_list, dlink_list *new_list, int changed) |
353 |
> |
void |
354 |
> |
rebuild_cidr_list(struct ClassItem *class) |
355 |
|
{ |
356 |
|
dlink_node *ptr; |
358 |
– |
struct Client *client_p; |
359 |
– |
struct MaskItem *conf; |
357 |
|
|
358 |
< |
if (!changed) |
362 |
< |
{ |
363 |
< |
*new_list = *old_list; |
364 |
< |
old_list->head = old_list->tail = NULL; |
365 |
< |
old_list->length = 0; |
366 |
< |
return; |
367 |
< |
} |
358 |
> |
destroy_cidr_class(class); |
359 |
|
|
360 |
|
DLINK_FOREACH(ptr, local_client_list.head) |
361 |
|
{ |
362 |
< |
client_p = ptr->data; |
363 |
< |
if (client_p->localClient->aftype != aftype) |
373 |
< |
continue; |
374 |
< |
if (dlink_list_length(&client_p->localClient->confs) == 0) |
375 |
< |
continue; |
362 |
> |
struct Client *client_p = ptr->data; |
363 |
> |
struct MaskItem *conf = client_p->localClient->confs.tail->data; |
364 |
|
|
365 |
< |
conf = client_p->localClient->confs.tail->data; |
366 |
< |
if (conf->type == CONF_CLIENT) |
367 |
< |
if (conf->class == oldcl) |
380 |
< |
cidr_limit_reached(1, &client_p->localClient->ip, newcl); |
365 |
> |
if (conf && (conf->type == CONF_CLIENT)) |
366 |
> |
if (conf->class == class) |
367 |
> |
cidr_limit_reached(1, &client_p->localClient->ip, class); |
368 |
|
} |
369 |
|
} |
370 |
|
|
371 |
|
/* |
385 |
– |
* rebuild_cidr_class |
386 |
– |
* |
387 |
– |
* inputs - pointer to old conf |
388 |
– |
* - pointer to new_class |
389 |
– |
* output - none |
390 |
– |
* side effects - rebuilds the class link list of cidr blocks |
391 |
– |
*/ |
392 |
– |
void |
393 |
– |
rebuild_cidr_class(struct ClassItem *old_class, struct ClassItem *new_class) |
394 |
– |
{ |
395 |
– |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
396 |
– |
{ |
397 |
– |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
398 |
– |
rebuild_cidr_list(AF_INET, old_class, new_class, |
399 |
– |
&old_class->list_ipv4, &new_class->list_ipv4, |
400 |
– |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
401 |
– |
|
402 |
– |
#ifdef IPV6 |
403 |
– |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
404 |
– |
rebuild_cidr_list(AF_INET6, old_class, new_class, |
405 |
– |
&old_class->list_ipv6, &new_class->list_ipv6, |
406 |
– |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
407 |
– |
#endif |
408 |
– |
} |
409 |
– |
|
410 |
– |
destroy_cidr_class(old_class); |
411 |
– |
} |
412 |
– |
|
413 |
– |
/* |
372 |
|
* destroy_cidr_list |
373 |
|
* |
374 |
|
* inputs - pointer to class dlink list of cidr blocks |