Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2004-10-04 01:02:06 UTC
Modified files:
include/class.h ircd/class.c
Log message:
Doxyfy class.h and class.c.
---------------------- diff included ----------------------
Index: ircu2.10/include/class.h
diff -u ircu2.10/include/class.h:1.18 ircu2.10/include/class.h:1.19
--- ircu2.10/include/class.h:1.18 Sat Sep 18 07:42:40 2004
+++ ircu2.10/include/class.h Sun Oct 3 18:01:44 2004
@@ -16,8 +16,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: class.h,v 1.18 2004/09/18 14:42:40 entrope Exp $
+ */
+/** @file
+ * @brief Declarations and interfaces for handling connection classes.
+ * @version $Id: class.h,v 1.19 2004/10/04 01:01:44 entrope Exp $
*/
#ifndef INCLUDED_class_h
#define INCLUDED_class_h
@@ -34,37 +36,55 @@
/*
* Structures
*/
+/** Represents a connection class. */
struct ConnectionClass {
- struct ConnectionClass* next;
- char *cc_name;
- char *default_umode;
- struct Privs privs;
- struct Privs privs_dirty;
- unsigned int max_sendq;
- unsigned int max_links;
- unsigned int ref_count;
- unsigned short ping_freq;
- unsigned short conn_freq;
- unsigned char valid;
+ struct ConnectionClass* next; /**< Link to next connection class. */
+ char *cc_name; /**< Name of connection class. */
+ char *default_umode; /**< Default usermode for users
+ in this class. */
+ struct Privs privs; /**< Privilege bits that are set on
+ or off. */
+ struct Privs privs_dirty; /**< Indication of which bits in
+ ConnectionClass::privs are valid. */
+ unsigned int max_sendq; /**< Maximum client SendQ in bytes. */
+ unsigned int max_links; /**< Maximum connections allowed. */
+ unsigned int ref_count; /**< Number of references to class. */
+ unsigned short ping_freq; /**< Ping frequency for clients. */
+ unsigned short conn_freq; /**< Auto-connect frequency. */
+ unsigned char valid; /**< Valid flag (cleared after this
+ class is removed from the config).*/
};
/*
* Macro's
*/
+/** Get class name for \a x. */
#define ConClass(x) ((x)->cc_name)
+/** Get ping frequency for \a x. */
#define PingFreq(x) ((x)->ping_freq)
+/** Get connection frequency for \a x. */
#define ConFreq(x) ((x)->conn_freq)
+/** Get maximum links allowed for \a x. */
#define MaxLinks(x) ((x)->max_links)
+/** Get maximum SendQ size for \a x. */
#define MaxSendq(x) ((x)->max_sendq)
+/** Get number of references to \a x. */
#define Links(x) ((x)->ref_count)
+/** Get class name for ConfItem \a x. */
#define ConfClass(x) ((x)->conn_class->cc_name)
+/** Get ping frequency for ConfItem \a x. */
#define ConfPingFreq(x) ((x)->conn_class->ping_freq)
+/** Get connection frequency for ConfItem \a x. */
#define ConfConFreq(x) ((x)->conn_class->conn_freq)
+/** Get maximum links allowed for ConfItem \a x. */
#define ConfMaxLinks(x) ((x)->conn_class->max_links)
+/** Get maximum SendQ size for ConfItem \a x. */
#define ConfSendq(x) ((x)->conn_class->max_sendq)
+/** Get number of references to class in ConfItem \a x. */
#define ConfLinks(x) ((x)->conn_class->ref_count)
+/** Get default usermode for ConfItem \a x. */
#define ConfUmode(x) ((x)->conn_class->default_umode)
/*
@@ -87,7 +107,6 @@
extern void add_class(char *name, unsigned int ping,
unsigned int confreq, unsigned int maxli,
unsigned int sendq);
-extern void check_class(void);
extern void report_classes(struct Client *sptr, const struct StatDesc *sd,
char *param);
extern unsigned int get_sendq(struct Client* cptr);
Index: ircu2.10/ircd/class.c
diff -u ircu2.10/ircd/class.c:1.26 ircu2.10/ircd/class.c:1.27
--- ircu2.10/ircd/class.c:1.26 Sat Sep 11 20:53:44 2004
+++ ircu2.10/ircd/class.c Sun Oct 3 18:01:46 2004
@@ -15,8 +15,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: class.c,v 1.26 2004/09/12 03:53:44 entrope Exp $
+ */
+/** @file
+ * @brief Implementation of connection class handling functions.
+ * @version $Id: class.c,v 1.27 2004/10/04 01:01:46 entrope Exp $
*/
#include "config.h"
@@ -35,18 +37,20 @@
#include <assert.h>
-#define BAD_CONF_CLASS ((unsigned int)-1)
-#define BAD_PING ((unsigned int)-2)
-#define BAD_CLIENT_CLASS ((unsigned int)-3)
-
+/** List of all connection classes. */
static struct ConnectionClass* connClassList = 0;
+/** Number of allocated connection classes. */
static unsigned int connClassAllocCount;
+/** Get start of connection class linked list. */
const struct ConnectionClass* get_class_list(void)
{
return connClassList;
}
+/** Allocate a new connection class.
+ * @return Newly allocated connection class structure.
+ */
struct ConnectionClass* make_class(void)
{
struct ConnectionClass *tmp;
@@ -58,6 +62,9 @@
return tmp;
}
+/** Dereference a connection class.
+ * @param[in] p Connection class to dereference.
+ */
void free_class(struct ConnectionClass* p)
{
if (p)
@@ -70,8 +77,10 @@
}
}
-/*
- * init_class - initialize the class list
+/** Initialize the connection class list.
+ * A connection class named "default" is created, with ping frequency,
+ * connection frequency, maximum links and max SendQ values from the
+ * corresponding configuration features.
*/
void init_class(void)
{
@@ -89,11 +98,7 @@
connClassList->next = 0;
}
-/*
- * class_mark_delete - mark classes for delete
- * We don't delete the class table, rather mark all entries
- * for deletion. The table is cleaned up by class_delete_marked(). - avalon
- * XXX - This destroys data
+/** Mark current connection classes as invalid.
*/
void class_mark_delete(void)
{
@@ -104,11 +109,10 @@
p->valid = 0;
}
-/*
- * class_delete_marked
- * delete classes marked for deletion
- * XXX - memory leak, no one deletes classes that become unused
- * later
+/** Unlink (and dereference) invalid connection classes.
+ * This is used in combination with class_mark_delete() during rehash
+ * to get rid of connection classes that are no longer in the
+ * configuration.
*/
void class_delete_marked(void)
{
@@ -135,6 +139,10 @@
}
}
+/** Get connection class name for a configuration item.
+ * @param[in] aconf Configuration item to check.
+ * @return Name of connection class associated with \a aconf.
+ */
char*
get_conf_class(const struct ConfItem* aconf)
{
@@ -146,6 +154,10 @@
return NULL;
}
+/** Get ping time for a configuration item.
+ * @param[in] aconf Configuration item to check.
+ * @return Ping time for connection class associated with \a aconf.
+ */
int get_conf_ping(const struct ConfItem* aconf)
{
assert(0 != aconf);
@@ -157,6 +169,10 @@
return -1;
}
+/** Get connection class name for a particular client.
+ * @param[in] acptr Client to check.
+ * @return Name of connection class to which \a acptr belongs.
+ */
char*
get_client_class(struct Client *acptr)
{
@@ -173,6 +189,11 @@
return "(null-class)";
}
+/** Get connection interval for a connection class.
+ * @param[in] clptr Connection class to check (or NULL).
+ * @return If \a clptr != NULL, its connection frequency; else default
+ * connection frequency.
+ */
unsigned int get_con_freq(struct ConnectionClass * clptr)
{
if (clptr)
@@ -181,12 +202,15 @@
return feature_int(FEAT_CONNECTFREQUENCY);
}
-/*
- * When adding a class, check to see if it is already present first.
- * if so, then update the information for that class, rather than create
- * a new entry for it and later delete the old entry.
- * if no present entry is found, then create a new one and add it in
- * immeadiately after the first one (class 0).
+/** Make sure we have a connection class named \a name.
+ * If one does not exist, create it. Then set its ping frequency,
+ * connection frequency, maximum link count, and max SendQ according
+ * to the parameters.
+ * @param[in] name Connection class name.
+ * @param[in] ping Ping frequency for clients in this class.
+ * @param[in] confreq Connection frequency for clients.
+ * @param[in] maxli Maximum link count for class.
+ * @param[in] sendq Max SendQ for clients.
*/
void add_class(char *name, unsigned int ping, unsigned int confreq,
unsigned int maxli, unsigned int sendq)
@@ -220,6 +244,10 @@
Links(p) = 0;
}
+/** Find a connection class by name.
+ * @param[in] name Name of connection class to search for.
+ * @return Pointer to connection class structure (or NULL if none match).
+ */
struct ConnectionClass* find_class(const char *name)
{
struct ConnectionClass *cltmp;
@@ -231,6 +259,11 @@
return connClassList;
}
+/** Report connection classes to a client.
+ * @param[in] sptr Client requesting statistics.
+ * @param[in] sd Stats descriptor for request (ignored).
+ * @param[in] param Extra parameter from user (ignored).
+ */
void
report_classes(struct Client *sptr, const struct StatDesc *sd,
char *param)
@@ -243,6 +276,10 @@
Links(cltmp));
}
+/** Return maximum SendQ length for a client.
+ * @param[in] cptr Local client to check.
+ * @return Number of bytes allowed in SendQ for \a cptr.
+ */
unsigned int
get_sendq(struct Client *cptr)
{
@@ -268,6 +305,10 @@
return feature_int(FEAT_DEFAULTMAXSENDQLENGTH);
}
+/** Report connection class memory statistics to a client.
+ * Send number of classes and number of bytes allocated for them.
+ * @param[in] cptr Client requesting statistics.
+ */
void class_send_meminfo(struct Client* cptr)
{
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Classes: inuse: %d(%d)",
----------------------- End of diff -----------------------