Squash errors from doxygen (fix typos and unescaped command characters).
[ircu2.10.12-pk.git] / include / s_conf.h
1 /*
2  * s_conf.h
3  *
4  * $Id$ 
5  */
6 #ifndef INCLUDED_s_conf_h
7 #define INCLUDED_s_conf_h
8 #ifndef INCLUDED_time_h
9 #include <time.h>              /* struct tm */
10 #define INCLUDED_time_h
11 #endif
12 #ifndef INCLUDED_sys_types_h
13 #include <sys/types.h>
14 #define INCLUDED_sys_types_h
15 #endif
16 #include "client.h"
17
18 struct Client;
19 struct SLink;
20 struct Message;
21
22 /*
23  * General defines
24  */
25
26 /*-----------------------------------------------------------------------------
27  * Macros
28  */
29
30 #define CONF_ILLEGAL            0x80000000 /**< Delete the ConfItem when no remaining clients. */
31 #define CONF_CLIENT             0x0002     /**< ConfItem describes a Client block */
32 #define CONF_SERVER             0x0004     /**< ConfItem describes a Connect block */
33 #define CONF_OPERATOR           0x0020     /**< ConfItem describes an Operator block */
34 #define CONF_LEAF               0x1000     /**< ConfItem describes a Server leaf */
35 #define CONF_HUB                0x4000     /**< ConfItem describes a Server hub */
36 #define CONF_UWORLD             0x8000     /**< ConfItem describes a Uworld server */
37
38 /** Indicates ConfItem types that count associated clients. */
39 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER)
40
41 /** Checks whether the CONF_ILLEGAL bit is set on \a x. */
42 #define IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
43
44 /*
45  * Structures
46  */
47
48 /** Configuration item to limit peer or client access. */
49 struct ConfItem
50 {
51   struct ConfItem *next;    /**< Next ConfItem in #GlobalConfList */
52   unsigned int status;      /**< Set of CONF_* bits. */
53   unsigned int clients;     /**< Number of *LOCAL* clients using this */
54   struct ConnectionClass *conn_class;  /**< Class of connection */
55   struct irc_sockaddr origin;  /**< local address for outbound connections */
56   struct irc_sockaddr address; /**< ip and port */
57   char *host; /**< peer hostname */
58   char *origin_name; /**< text form of origin address */
59   char *passwd; /**< password field */
60   char *name; /**< name of peer */
61   time_t hold; /**< Earliest time to attempt an outbound connect on this ConfItem. */
62   int dns_pending; /**< a dns request is pending */
63   unsigned char bits; /**< Number of bits for ipkills. */
64   struct Privs privs; /**< Priviledges for opers. */
65   /** Used to detect if a privilege has been set by this ConfItem. */
66   struct Privs privs_dirty;
67 };
68
69 /** Channel quarantine structure. */
70 struct qline
71 {
72   struct qline *next; /**< Next qline in #GlobalQuarantineList. */
73   char *chname;       /**< Quarantined channel name. */
74   char *reason;       /**< Reason for quarantine. */
75 };
76
77 /** Local K-line structure. */
78 struct DenyConf {
79   struct DenyConf*    next;     /**< Next DenyConf in #denyConfList. */
80   char*               hostmask; /**< Mask for realname, IP or hostname. */
81   char*               message;  /**< Message to send to denied users. */
82   char*               usermask; /**< Mask for client's username. */
83   struct irc_in_addr  address;  /**< Address for IP-based denies. */
84   unsigned int        flags;    /**< Interpretation flags for the above.  */
85   unsigned char       bits;     /**< Number of bits for ipkills */
86 };
87
88 #define DENY_FLAGS_FILE     0x0001 /**< Comment is a filename */
89 #define DENY_FLAGS_IP       0x0002 /**< K-line by IP address */
90 #define DENY_FLAGS_REALNAME 0x0004 /**< K-line by real name */
91
92 /** Local server configuration. */
93 struct LocalConf {
94   char*          name;        /**< Name of server. */
95   char*          description; /**< Description of server. */
96   unsigned int   numeric;     /**< Globally assigned server numnick. */
97   char*          location1;   /**< First line of location information. */
98   char*          location2;   /**< Second line of location information. */
99   char*          contact;     /**< Admin contact information. */
100 };
101
102 enum {
103   CRULE_AUTO = 1, /**< CRule applies to automatic connections. */
104   CRULE_ALL  = 2, /**< CRule applies to oper-requested connections. */
105   CRULE_MASK = 3
106 };
107
108 /** Connection rule configuration. */
109 struct CRuleConf {
110   struct CRuleConf* next;     /**< Next CRule in cruleConfList. */
111   char*             hostmask; /**< Mask of affected server names. */
112   char*             rule;     /**< Text version of the rule. */
113   int               type;     /**< One of CRULE_AUTO or CRULE_ALL. */
114   struct CRuleNode* node;     /**< Parsed form of the rule. */
115 };
116
117 /** Authorization check result. */
118 enum AuthorizationCheckResult {
119   ACR_OK,                 /**< User accepted. */
120   ACR_NO_AUTHORIZATION,   /**< No matching ConfItem for the user. */
121   ACR_TOO_MANY_IN_CLASS,  /**< Connection class was already full. */
122   ACR_TOO_MANY_FROM_IP,   /**< User's IP already has max connections. */
123   ACR_ALREADY_AUTHORIZED, /**< User already had an attached ConfItem. */
124   ACR_BAD_SOCKET          /**< Client has bad file descriptor. */
125 };
126
127 /** Target description for service commands. */
128 struct nick_host {
129   struct nick_host *next; /**< Next nick_host struct in struct s_map. */
130   int nicklen;            /**< offset of @ part of server string */
131   char nick[1];           /**< start of nick\@server string */
132 };
133
134 /** Target set for a service pseudo-command. */
135 struct s_map {
136   struct s_map *next;         /**< Next element in #GlobalServiceMapList. */
137   struct Message *msg;        /**< Message element formed for this mapping. */
138   char *name;                 /**< Text name of the mapping. */
139   char *command;              /**< Command name to use. */
140   char *prepend;              /**< Extra text to prepend to user's text. */
141   struct nick_host *services; /**< Linked list of possible targets. */
142 };
143
144
145 /*
146  * GLOBALS
147  */
148 extern struct ConfItem* GlobalConfList;
149 extern int              GlobalConfCount;
150 extern struct s_map*    GlobalServiceMapList;
151 extern struct qline*    GlobalQuarantineList;
152
153 /*
154  * Proto types
155  */
156
157 extern int init_conf(void);
158
159 extern const struct LocalConf* conf_get_local(void);
160 extern const struct CRuleConf* conf_get_crule_list(void);
161 extern const struct DenyConf*  conf_get_deny_list(void);
162
163 extern const char* conf_eval_crule(const char* name, int mask);
164
165 extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
166 extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
167 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
168 extern struct ConfItem* conf_find_server(const char* name);
169
170 extern void det_confs_butmask(struct Client *cptr, int mask);
171 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
172 extern struct ConfItem* find_conf_exact(const char* name, const char* user,
173                                         const char* host, int statmask);
174 extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
175 extern int  conf_check_server(struct Client *cptr);
176 extern struct ConfItem* find_conf_name(const char* name, int statmask);
177 extern int rehash(struct Client *cptr, int sig);
178 extern void read_tlines(void);
179 extern int find_kill(struct Client *cptr);
180 extern int find_restrict(struct Client *cptr);
181 extern const char *find_quarantine(const char* chname);
182 extern void lookup_confhost(struct ConfItem *aconf);
183
184 extern void yyerror(const char *msg);
185
186 #endif /* INCLUDED_s_conf_h */