ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_class.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/conf_class.c (file contents):
Revision 1636 by michael, Sun Nov 4 17:09:47 2012 UTC vs.
Revision 1650 by michael, Sat Nov 10 20:57:51 2012 UTC

# Line 72 | Line 72 | class_make(void)
72   {
73    struct ClassItem *class = MyMalloc(sizeof(*class));
74  
75 +  class->active    = 1;
76 +  class->con_freq  = DEFAULT_CONNECTFREQUENCY;
77 +  class->ping_freq = DEFAULT_PINGFREQUENCY;
78 +  class->max_total = MAXIMUM_LINKS_DEFAULT;
79 +  class->max_sendq = DEFAULT_SENDQ;
80 +  class->max_recvq = DEFAULT_RECVQ;
81 +
82    dlinkAdd(class, &class->node, &class_list);
83  
84    return class;
# Line 92 | Line 99 | class_free(struct ClassItem *class)
99   void
100   class_init(void)
101   {
102 <  class_default = class_make();
96 <
97 <  DupString(class_default->name, "default");
98 <
99 <  class_default->active    = 1;
100 <  class_default->con_freq  = DEFAULT_CONNECTFREQUENCY;
101 <  class_default->ping_freq = DEFAULT_PINGFREQUENCY;
102 <  class_default->max_total = MAXIMUM_LINKS_DEFAULT;
103 <  class_default->max_sendq = DEFAULT_SENDQ;
104 <  class_default->max_recvq = DEFAULT_RECVQ;
105 <
106 <  client_check_cb = register_callback("check_client", check_client);
102 >  (class_default = class_make())->name = xstrdup("default");
103   }
104  
105   const char *
# Line 124 | Line 120 | get_client_class(const dlink_list *const
120   }
121  
122   unsigned int
123 < get_client_ping(const dlink_list *const list, int *pingwarn)
123 > get_client_ping(const dlink_list *const list)
124   {
125    const dlink_node *ptr = NULL;
130  int ping = 0;
126  
127    if ((ptr = list->head)) {
128      const struct MaskItem *conf = ptr->data;
# Line 135 | Line 130 | get_client_ping(const dlink_list *const
130      assert(aconf->class);
131      assert(aconf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
132  
133 <    ping = get_conf_ping(conf, pingwarn);
139 <    if (ping > 0)
140 <      return ping;
133 >    return conf->class->ping_freq;
134    }
135  
136    return class_default->ping_freq;
# Line 206 | Line 199 | class_mark_for_deletion(void)
199   {
200    dlink_node *ptr = NULL;
201  
202 <  DLINK_FOREACH(ptr, class_list.head)
203 <  {
211 <    struct ClassItem *class = ptr->data;
212 <
213 <    if (class != class_default)
214 <      class->active = 0;
215 <  }
202 >  DLINK_FOREACH_PREV(ptr, class_list.tail->prev)
203 >    ((struct ClassItem *)ptr->data)->active = 0;
204   }
205  
206   void
# Line 248 | Line 236 | cidr_limit_reached(int over_rule,
236    dlink_node *ptr = NULL;
237    struct CidrItem *cidr = NULL;
238  
239 <  if (class->number_per_cidr <= 0)
239 >  if (class->number_per_cidr == 0)
240      return 0;
241  
242    if (ip->ss.ss_family == AF_INET)
243    {
244 <    if (class->cidr_bitlen_ipv4 <= 0)
244 >    if (class->cidr_bitlen_ipv4 == 0)
245        return 0;
246  
247      DLINK_FOREACH(ptr, class->list_ipv4.head)
# Line 317 | Line 305 | remove_from_cidr_check(struct irc_ssaddr
305  
306    if (ip->ss.ss_family == AF_INET)
307    {
308 <    if (aclass->cidr_bitlen_ipv4 <= 0)
308 >    if (aclass->cidr_bitlen_ipv4 == 0)
309        return;
310  
311      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
# Line 356 | Line 344 | remove_from_cidr_check(struct irc_ssaddr
344   #endif
345   }
346  
347 < static void
348 < rebuild_cidr_list(int aftype, struct ClassItem *oldcl, struct ClassItem *newcl,
361 <                  dlink_list *old_list, dlink_list *new_list, int changed)
347 > void
348 > rebuild_cidr_list(struct ClassItem *class)
349   {
350    dlink_node *ptr;
364  struct Client *client_p;
365  struct MaskItem *conf;
351  
352 <  if (!changed)
368 <  {
369 <    *new_list = *old_list;
370 <    old_list->head = old_list->tail = NULL;
371 <    old_list->length = 0;
372 <    return;
373 <  }
352 >  destroy_cidr_class(class);
353  
354    DLINK_FOREACH(ptr, local_client_list.head)
355    {
356 <    client_p = ptr->data;
357 <    if (client_p->localClient->aftype != aftype)
379 <      continue;
380 <    if (dlink_list_length(&client_p->localClient->confs) == 0)
381 <      continue;
382 <
383 <    conf = client_p->localClient->confs.tail->data;
384 <    if (conf->type == CONF_CLIENT)
385 <      if (conf->class == oldcl)
386 <        cidr_limit_reached(1, &client_p->localClient->ip, newcl);
387 <  }
388 < }
389 <
390 < /*
391 < * rebuild_cidr_class
392 < *
393 < * inputs       - pointer to old conf
394 < *              - pointer to new_class
395 < * output       - none
396 < * side effects - rebuilds the class link list of cidr blocks
397 < */
398 < void
399 < rebuild_cidr_class(struct ClassItem *old_class, struct ClassItem *new_class)
400 < {
401 <  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
402 <  {
403 <    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
404 <      rebuild_cidr_list(AF_INET, old_class, new_class,
405 <                        &old_class->list_ipv4, &new_class->list_ipv4,
406 <                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
356 >    struct Client *client_p = ptr->data;
357 >    struct MaskItem *conf = client_p->localClient->confs.tail->data;
358  
359 < #ifdef IPV6
360 <    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
361 <      rebuild_cidr_list(AF_INET6, old_class, new_class,
411 <                        &old_class->list_ipv6, &new_class->list_ipv6,
412 <                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
413 < #endif
359 >    if (conf && (conf->type == CONF_CLIENT))
360 >      if (conf->class == class)
361 >        cidr_limit_reached(1, &client_p->localClient->ip, class);
362    }
415
416  destroy_cidr_class(old_class);
363   }
364  
365   /*

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)