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 1633 by michael, Sun Nov 4 15:51:30 2012 UTC vs.
Revision 1654 by michael, Fri Nov 16 19:39:37 2012 UTC

# Line 21 | Line 21
21  
22   /*! \file
23   * \brief Configuration managment for class{} blocks
24 < * \version $Id: conf_class.c,v 1.54 2007/10/21 21:57:05 devil Exp $
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28   #include "list.h"
29   #include "ircd_defs.h"
30 #include "balloc.h"
30   #include "conf.h"
31   #include "s_serv.h"
32   #include "resv.h"
# Line 72 | Line 71 | class_make(void)
71   {
72    struct ClassItem *class = MyMalloc(sizeof(*class));
73  
74 +  class->active    = 1;
75 +  class->con_freq  = DEFAULT_CONNECTFREQUENCY;
76 +  class->ping_freq = DEFAULT_PINGFREQUENCY;
77 +  class->max_total = MAXIMUM_LINKS_DEFAULT;
78 +  class->max_sendq = DEFAULT_SENDQ;
79 +  class->max_recvq = DEFAULT_RECVQ;
80 +
81    dlinkAdd(class, &class->node, &class_list);
82  
83    return class;
# Line 92 | Line 98 | class_free(struct ClassItem *class)
98   void
99   class_init(void)
100   {
101 <  class_default = class_make();
96 <
97 <  class_default->active = 1;
98 <  DupString(class_default->name, "default");
99 <  class_default->con_freq  = DEFAULT_CONNECTFREQUENCY;
100 <  class_default->ping_freq = DEFAULT_PINGFREQUENCY;
101 <  class_default->max_total = MAXIMUM_LINKS_DEFAULT;
102 <  class_default->max_sendq = DEFAULT_SENDQ;
103 <  class_default->max_recvq = DEFAULT_RECVQ;
104 <
105 <  client_check_cb = register_callback("check_client", check_client);
101 >  (class_default = class_make())->name = xstrdup("default");
102   }
103  
104   const char *
# Line 114 | Line 110 | get_client_class(const dlink_list *const
110      const struct MaskItem *conf = ptr->data;
111  
112      assert(conf->class);
113 <    assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
113 >    assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
114  
115      return conf->class->name;
116    }
# Line 123 | Line 119 | get_client_class(const dlink_list *const
119   }
120  
121   unsigned int
122 < get_client_ping(const dlink_list *const list, int *pingwarn)
122 > get_client_ping(const dlink_list *const list)
123   {
124    const dlink_node *ptr = NULL;
129  int ping = 0;
125  
126    if ((ptr = list->head)) {
127      const struct MaskItem *conf = ptr->data;
128  
129 <    assert(aconf->class);
130 <    assert(aconf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
129 >    assert(conf->class);
130 >    assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
131  
132 <    ping = get_conf_ping(conf, pingwarn);
138 <    if (ping > 0)
139 <      return ping;
132 >    return conf->class->ping_freq;
133    }
134  
135    return class_default->ping_freq;
# Line 151 | Line 144 | get_sendq(const dlink_list *const list)
144      const struct MaskItem *conf = ptr->data;
145  
146      assert(conf->class);
147 <    assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
147 >    assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
148  
149      return conf->class->max_sendq;
150    }
# Line 168 | Line 161 | get_recvq(const dlink_list *const list)
161      const struct MaskItem *conf = ptr->data;
162  
163      assert(conf->class);
164 <    assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
164 >    assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
165  
166      return conf->class->max_recvq;
167    }
# Line 205 | Line 198 | class_mark_for_deletion(void)
198   {
199    dlink_node *ptr = NULL;
200  
201 <  DLINK_FOREACH(ptr, class_list.head)
202 <  {
210 <    struct ClassItem *class = ptr->data;
211 <
212 <    if (class != class_default)
213 <      class->active = 0;
214 <  }
201 >  DLINK_FOREACH_PREV(ptr, class_list.tail->prev)
202 >    ((struct ClassItem *)ptr->data)->active = 0;
203   }
204  
205   void
# Line 247 | Line 235 | cidr_limit_reached(int over_rule,
235    dlink_node *ptr = NULL;
236    struct CidrItem *cidr = NULL;
237  
238 <  if (class->number_per_cidr <= 0)
238 >  if (class->number_per_cidr == 0)
239      return 0;
240  
241    if (ip->ss.ss_family == AF_INET)
242    {
243 <    if (class->cidr_bitlen_ipv4 <= 0)
243 >    if (class->cidr_bitlen_ipv4 == 0)
244        return 0;
245  
246      DLINK_FOREACH(ptr, class->list_ipv4.head)
# Line 316 | Line 304 | remove_from_cidr_check(struct irc_ssaddr
304  
305    if (ip->ss.ss_family == AF_INET)
306    {
307 <    if (aclass->cidr_bitlen_ipv4 <= 0)
307 >    if (aclass->cidr_bitlen_ipv4 == 0)
308        return;
309  
310      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
# Line 355 | Line 343 | remove_from_cidr_check(struct irc_ssaddr
343   #endif
344   }
345  
346 < static void
347 < rebuild_cidr_list(int aftype, struct ClassItem *oldcl, struct ClassItem *newcl,
360 <                  dlink_list *old_list, dlink_list *new_list, int changed)
346 > void
347 > rebuild_cidr_list(struct ClassItem *class)
348   {
349    dlink_node *ptr;
363  struct Client *client_p;
364  struct MaskItem *conf;
350  
351 <  if (!changed)
367 <  {
368 <    *new_list = *old_list;
369 <    old_list->head = old_list->tail = NULL;
370 <    old_list->length = 0;
371 <    return;
372 <  }
351 >  destroy_cidr_class(class);
352  
353    DLINK_FOREACH(ptr, local_client_list.head)
354    {
355 <    client_p = ptr->data;
356 <    if (client_p->localClient->aftype != aftype)
378 <      continue;
379 <    if (dlink_list_length(&client_p->localClient->confs) == 0)
380 <      continue;
381 <
382 <    conf = client_p->localClient->confs.tail->data;
383 <    if (conf->type == CONF_CLIENT)
384 <      if (conf->class == oldcl)
385 <        cidr_limit_reached(1, &client_p->localClient->ip, newcl);
386 <  }
387 < }
388 <
389 < /*
390 < * rebuild_cidr_class
391 < *
392 < * inputs       - pointer to old conf
393 < *              - pointer to new_class
394 < * output       - none
395 < * side effects - rebuilds the class link list of cidr blocks
396 < */
397 < void
398 < rebuild_cidr_class(struct ClassItem *old_class, struct ClassItem *new_class)
399 < {
400 <  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
401 <  {
402 <    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
403 <      rebuild_cidr_list(AF_INET, old_class, new_class,
404 <                        &old_class->list_ipv4, &new_class->list_ipv4,
405 <                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
355 >    struct Client *client_p = ptr->data;
356 >    struct MaskItem *conf = client_p->localClient->confs.tail->data;
357  
358 < #ifdef IPV6
359 <    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
360 <      rebuild_cidr_list(AF_INET6, old_class, new_class,
410 <                        &old_class->list_ipv6, &new_class->list_ipv6,
411 <                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
412 < #endif
358 >    if (conf && (conf->type == CONF_CLIENT))
359 >      if (conf->class == class)
360 >        cidr_limit_reached(1, &client_p->localClient->ip, class);
361    }
414
415  destroy_cidr_class(old_class);
362   }
363  
364   /*

Comparing ircd-hybrid/trunk/src/conf_class.c (property svn:keywords):
Revision 1633 by michael, Sun Nov 4 15:51:30 2012 UTC vs.
Revision 1654 by michael, Fri Nov 16 19:39:37 2012 UTC

# Line 0 | Line 1
1 + Id

Diff Legend

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