Debian Codegraph @

include/phandler.h

raw
1 /*
2 * Copyright (c) 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Protocol handlers, both generic and the actual declarations themselves.
6 *
7 */
8
9 #ifndef PHANDLER_H
10 #define PHANDLER_H
11
12 struct ircd_ {
13 const char *ircdname;
14 const char *tldprefix;
15 bool uses_uid;
16 bool uses_rcommand;
17 bool uses_owner;
18 bool uses_protect;
19 bool uses_halfops;
20 bool uses_p10; /* Parser hackhack. */
21 bool uses_vhost; /* Do we use vHosts? */
22 unsigned int oper_only_modes;
23 unsigned int owner_mode;
24 unsigned int protect_mode;
25 unsigned int halfops_mode;
26 const char *owner_mchar;
27 const char *protect_mchar;
28 const char *halfops_mchar;
29 unsigned int type;
30 unsigned int perm_mode; /* Modes to not disappear when empty */
31 unsigned int oimmune_mode; /* Mode to disallow kicking ircops */
32 const char *ban_like_modes; /* e.g. "beI" */
33 char except_mchar;
34 char invex_mchar;
35 int flags;
36 };
37
38 typedef struct ircd_ ircd_t;
39
40 /* values for type */
41 /* -- what the HELL are these used for? A grep reveals nothing.. --w00t
42 * -- they are used to provide a hint to third-party module coders about what
43 * ircd they are working with. --nenolod
44 */
45 #define PROTOCOL_ASUKA 1
46 #define PROTOCOL_BAHAMUT 2
47 #define PROTOCOL_CHARYBDIS 3
48 #define PROTOCOL_DREAMFORGE 4
49 #define PROTOCOL_HYPERION 5 /* obsolete */
50 #define PROTOCOL_INSPIRCD 6
51 #define PROTOCOL_IRCNET 7
52 #define PROTOCOL_MONKEY 8 /* obsolete */
53 #define PROTOCOL_PLEXUS 9
54 #define PROTOCOL_PTLINK 10
55 #define PROTOCOL_RATBOX 11
56 #define PROTOCOL_SCYLLA 12
57 #define PROTOCOL_ELEMENTAL_IRCD 13
58 #define PROTOCOL_SORCERY 14 /* obsolete */
59 #define PROTOCOL_ULTIMATE3 15
60 #define PROTOCOL_UNREAL 17
61 #define PROTOCOL_SOLIDIRCD 18
62 #define PROTOCOL_NEFARIOUS 19
63 #define PROTOCOL_OFFICEIRC 20
64 #define PROTOCOL_SPORKSIRCD 21
65 #define PROTOCOL_NGIRCD 22
66
67 #define PROTOCOL_OTHER 255
68
69 /* values for flags */
70 #define IRCD_CIDR_BANS 1
71 #define IRCD_HOLDNICK 2 /* supports holdnick_sts() */
72 #define IRCD_TOPIC_NOCOLOUR 4
73 #define IRCD_SASL_USE_PUID 8
74
75 /* forced nick change types */
76 #define FNC_REGAIN 0 /* give a registered user their nick back */
77 #define FNC_FORCE 1 /* force a user off their nick (kill if unsupported) */
78
79 /* server login, usually sends PASS, CAPAB, SERVER and SVINFO
80 * you can still change ircd->uses_uid at this point
81 * set me.bursting = true
82 * return 1 if sts() failed (by returning 1), otherwise 0 */
83 E unsigned int (*server_login)(void);
84 /* introduce a client on the services server */
85 E void (*introduce_nick)(user_t *u);
86 /* send an invite for a given user to a channel
87 * the source may not be on the channel */
88 E void (*invite_sts)(user_t *source, user_t *target, channel_t *channel);
89 /* quit a client on the services server with the given message */
90 E void (*quit_sts)(user_t *u, const char *reason);
91 /* send wallops
92 * use something that only opers can see if easily possible */
93 E void (*wallops_sts)(const char *text);
94 /* join a channel with a client on the services server
95 * the client should be introduced opped
96 * isnew indicates the channel modes (and bans XXX) should be bursted
97 * note that the channelts can still be old in this case (e.g. kills)
98 * modes is a convenience argument giving the simple modes with parameters
99 * do not rely upon chanuser_find(c,u) */
100 E void (*join_sts)(channel_t *c, user_t *u, bool isnew, char *modes);
101 /* lower the TS of a channel, joining it with the given client on the
102 * services server (opped), replacing the current simple modes with the
103 * ones stored in the channel_t and clearing all other statuses
104 * if bans are timestamped on this ircd, call chanban_clear()
105 * if the topic is timestamped on this ircd, clear it */
106 E void (*chan_lowerts)(channel_t *c, user_t *u);
107 /* kick a user from a channel
108 * source is a client on the services server which may or may not be
109 * on the channel */
110 E void (*kick)(user_t *source, channel_t *c, user_t *u, const char *reason);
111 /* send a privmsg
112 * here it's ok to assume the source is able to send */
113 E void (*msg)(const char *from, const char *target, const char *fmt, ...) PRINTFLIKE(3, 4);
114 /* send a global privmsg to all users on servers matching the mask
115 * from is a client on the services server
116 * mask is either "*" or it has a non-wildcard TLD */
117 E void (*msg_global_sts)(user_t *from, const char *mask, const char *text);
118 /* send a notice to a user
119 * from can be a client on the services server or the services server
120 * itself (NULL) */
121 E void (*notice_user_sts)(user_t *from, user_t *target, const char *text);
122 /* send a global notice to all users on servers matching the mask
123 * from is a client on the services server
124 * mask is either "*" or it has a non-wildcard TLD */
125 E void (*notice_global_sts)(user_t *from, const char *mask, const char *text);
126 /* send a notice to a channel
127 * from can be a client on the services server or the services server
128 * itself (NULL)
129 * if the source cannot send because it is not on the channel, send the
130 * notice from the server or join for a moment */
131 E void (*notice_channel_sts)(user_t *from, channel_t *target, const char *text);
132 /* send a notice to ops in a channel
133 * source may or may not be on channel
134 * generic_wallchops() sends an individual notice to each channel operator */
135 E void (*wallchops)(user_t *source, channel_t *target, const char *message);
136 /* send a numeric from must currently be me.me */
137 E void (*numeric_sts)(server_t *from, int numeric, user_t *target, const char *fmt, ...) PRINTFLIKE(4, 5);
138 /* kill a user
139 * killer can be a client on the services server or NULL for the
140 * services server itself
141 * unlike other functions, the target is specified by a UID or nick;
142 * do not call user_find(), user_find_named() or similar on it */
143 E void (*kill_id_sts)(user_t *killer, const char *id, const char *reason);
144 /* part a channel with a client on the services server */
145 E void (*part_sts)(channel_t *c, user_t *u);
146 /* add a kline on the servers matching the given mask
147 * duration is in seconds, 0 for a permanent kline
148 * if the ircd requires klines to be sent from users, use opersvs */
149 E void (*kline_sts)(const char *server, const char *user, const char *host, long duration, const char *reason);
150 /* remove a kline on the servers matching the given mask
151 * if the ircd requires unklines to be sent from users, use opersvs */
152 E void (*unkline_sts)(const char *server, const char *user, const char *host);
153 /* add a xline on the servers matching the given mask
154 * duration is in seconds, 0 for a permanent xline
155 * if the ircd requires xlines to be sent from users, use opersvs */
156 E void (*xline_sts)(const char *server, const char *realname, long duration, const char *reason);
157 /* remove a xline on the servers matching the given mask
158 * if the ircd requires unxlines to be sent from users, use opersvs */
159 E void (*unxline_sts)(const char *server, const char *realname);
160 /* add a qline on the servers matching the given mask
161 * duration is in seconds, 0 for a permanent qline
162 * if the ircd requires qlines to be sent from users, use opersvs */
163 E void (*qline_sts)(const char *server, const char *mask, long duration, const char *reason);
164 /* remove a qline on the servers matching the given mask
165 * if the ircd requires unqlines to be sent from users, use opersvs */
166 E void (*unqline_sts)(const char *server, const char *mask);
167 /* add a dline (sometimes called zline) on the servers matching mask
168 * if the ircd requires dlines to be sent from users, use opersvs */
169 E void (*dline_sts)(const char *server, const char *host, long duration, const char *reason);
170 /* remove a dline (sometimes called zline) on the servers matching the given mask
171 * if the ircd requires undlines to be sent from users, use opersvs */
172 E void (*undline_sts)(const char *server, const char *host);
173 /* make the given service set a topic on a channel
174 * setter and ts should be used if the ircd supports topics to be set
175 * with a given topicsetter and topicts; ts is not a channelts
176 * prevts is the topicts of the old topic or 0 if there was no topic,
177 * useful in optimizing which form of topic change to use
178 * if the given topicts was not set and topicts is used on the ircd,
179 * set c->topicts to the value used */
180 E void (*topic_sts)(channel_t *c, user_t *source, const char *setter, time_t ts, time_t prevts, const char *topic);
181 /* set modes on a channel by the given sender; sender must be a client
182 * on the services server; sender may or may not be on channel */
183 E void (*mode_sts)(char *sender, channel_t *target, char *modes);
184 /* ping the uplink
185 * first check if me.connected is true and bail if not */
186 E void (*ping_sts)(void);
187 /* mark user 'u' as logged in as 'account'
188 * wantedhost is currently not used
189 * first check if me.connected is true and bail if not */
190 E void (*ircd_on_login)(user_t *u, myuser_t *account, const char *wantedhost);
191 /* mark user 'u' as logged out
192 * first check if me.connected is true and bail if not
193 * return false if successful or logins are not supported
194 * return true if the user was killed to force logout (P10) */
195 E bool (*ircd_on_logout)(user_t *u, const char *account);
196 /* introduce a fake server
197 * it is ok to use opersvs to squit the old server
198 * if SQUIT uses kill semantics (e.g. charybdis), server_delete() the server
199 * and continue
200 * if SQUIT uses unconnect semantics (e.g. bahamut), set SF_JUPE_PENDING on
201 * the server and return; you will be called again when the server is really
202 * deleted */
203 E void (*jupe)(const char *server, const char *reason);
204 /* set a dynamic spoof on a user
205 * if the ircd does not notify the user of this, do
206 * notice(source->nick, target->nick, "Setting your host to \2%s\2.", host); */
207 E void (*sethost_sts)(user_t *source, user_t *target, const char *host);
208 /* force a nickchange for a user
209 * possible values for type:
210 * FNC_REGAIN: give a registered user their nick back
211 * FNC_FORCE: force a user off their nick (kill if unsupported)
212 */
213 E void (*fnc_sts)(user_t *source, user_t *u, const char *newnick, int type);
214 /* temporarily make a nick unavailable to users
215 * source is the responsible service
216 * duration is in seconds, 0 to remove the effect of a previous call
217 * account is an account that may still use the nick, or NULL */
218 E void (*holdnick_sts)(user_t *source, int duration, const char *nick, myuser_t *account);
219 /* change nick, user, host and/or services login name for a user
220 * target may also be a not yet fully introduced UID (for SASL) */
221 E void (*svslogin_sts)(char *target, char *nick, char *user, char *host, myuser_t *account);
222 /* send sasl message */
223 E void (*sasl_sts) (char *target, char mode, char *data);
224 /* send sasl mech list */
225 E void (*sasl_mechlist_sts)(const char *mechlist);
226 /* find next channel ban (or other ban-like mode) matching user */
227 E mowgli_node_t *(*next_matching_ban)(channel_t *c, user_t *u, int type, mowgli_node_t *first);
228 /* find next host channel access matching user */
229 E mowgli_node_t *(*next_matching_host_chanacs)(mychan_t *mc, user_t *u, mowgli_node_t *first);
230 /* check a nickname for validity; normally you don't need to override this */
231 E bool (*is_valid_nick)(const char *nick);
232 /* check a username for validity; normally you don't need to override this */
233 E bool (*is_valid_username)(const char *username);
234 /* check a vhost for validity; the core will already have checked for
235 * @!?*, space, empty, : at start, length and cidr masks */
236 E bool (*is_valid_host)(const char *host);
237 /* burst a channel mlock. */
238 E void (*mlock_sts)(channel_t *c);
239 /* burst a channel topiclock */
240 E void (*topiclock_sts)(channel_t *c);
241 /* attempt to quarantine a user.
242 * in Unreal-esque terms, this means SHUN.
243 * in Hybrid, this means CAPTURE.
244 * pretty much the same thing either way.
245 */
246 E void (*quarantine_sts)(user_t *source, user_t *victim, long duration, const char *reason);
247 /* Ask the proto module if this is valid as an extban */
248 E bool (*is_extban)(const char *mask);
249
250 E unsigned int generic_server_login(void);
251 E void generic_introduce_nick(user_t *u);
252 E void generic_invite_sts(user_t *source, user_t *target, channel_t *channel);
253 E void generic_quit_sts(user_t *u, const char *reason);
254 E void generic_wallops_sts(const char *text);
255 E void generic_join_sts(channel_t *c, user_t *u, bool isnew, char *modes);
256 E void generic_chan_lowerts(channel_t *c, user_t *u);
257 E void generic_kick(user_t *source, channel_t *c, user_t *u, const char *reason);
258 E void generic_msg(const char *from, const char *target, const char *fmt, ...);
259 E void generic_msg_global_sts(user_t *from, const char *mask, const char *text);
260 E void generic_notice_user_sts(user_t *from, user_t *target, const char *text);
261 E void generic_notice_global_sts(user_t *from, const char *mask, const char *text);
262 E void generic_notice_channel_sts(user_t *from, channel_t *target, const char *text);
263 E void generic_wallchops(user_t *source, channel_t *target, const char *message);
264 E void generic_numeric_sts(server_t *from, int numeric, user_t *target, const char *fmt, ...);
265 E void generic_kill_id_sts(user_t *killer, const char *id, const char *reason);
266 E void generic_part_sts(channel_t *c, user_t *u);
267 E void generic_kline_sts(const char *server, const char *user, const char *host, long duration, const char *reason);
268 E void generic_unkline_sts(const char *server, const char *user, const char *host);
269 E void generic_xline_sts(const char *server, const char *realname, long duration, const char *reason);
270 E void generic_unxline_sts(const char *server, const char *realname);
271 E void generic_qline_sts(const char *server, const char *mask, long duration, const char *reason);
272 E void generic_unqline_sts(const char *server, const char *mask);
273 E void generic_topic_sts(channel_t *c, user_t *source, const char *setter, time_t ts, time_t prevts, const char *topic);
274 E void generic_mode_sts(char *sender, channel_t *target, char *modes);
275 E void generic_ping_sts(void);
276 E void generic_on_login(user_t *u, myuser_t *account, const char *wantedhost);
277 E bool generic_on_logout(user_t *u, const char *account);
278 E void generic_jupe(const char *server, const char *reason);
279 E void generic_sethost_sts(user_t *source, user_t *target, const char *host);
280 E void generic_fnc_sts(user_t *source, user_t *u, const char *newnick, int type);
281 E void generic_holdnick_sts(user_t *source, int duration, const char *nick, myuser_t *account);
282 E void generic_svslogin_sts(char *target, char *nick, char *user, char *host, myuser_t *account);
283 E void generic_sasl_sts(char *target, char mode, char *data);
284 E void generic_sasl_mechlist_sts(const char *mechlist);
285 E mowgli_node_t *generic_next_matching_ban(channel_t *c, user_t *u, int type, mowgli_node_t *first);
286 E mowgli_node_t *generic_next_matching_host_chanacs(mychan_t *mc, user_t *u, mowgli_node_t *first);
287 E bool generic_is_valid_host(const char *host);
288 E bool generic_is_valid_nick(const char *nick);
289 E bool generic_is_valid_username(const char *username);
290 E void generic_mlock_sts(channel_t *c);
291 E void generic_topiclock_sts(channel_t *c);
292 E void generic_quarantine_sts(user_t *source, user_t *victim, long duration, const char *reason);
293 E bool generic_is_extban(const char *mask);
294 E void generic_dline_sts(const char *server, const char *host, long duration, const char *reason);
295 E void generic_undline_sts(const char *server, const char *host);
296
297 E struct cmode_ *mode_list;
298 E struct extmode *ignore_mode_list;
299 E size_t ignore_mode_list_size;
300 E struct cmode_ *status_mode_list;
301 E struct cmode_ *prefix_mode_list;
302 E struct cmode_ *user_mode_list;
303
304 E ircd_t *ircd;
305
306 #endif
307
308 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
309 * vim:ts=8
310 * vim:sw=8
311 * vim:noexpandtab
312 */