/[LeafOK_CVS]/pvpgn-1.7.4/src/bnetd/connection.h
ViewVC logotype

Contents of /pvpgn-1.7.4/src/bnetd/connection.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Sat Jun 10 16:20:06 2006 UTC (19 years, 9 months ago) by sysadm
Branch: MAIN
CVS Tags: pvpgn_1-7-4-0_MIL, HEAD
Changes since 1.1: +7 -0 lines
Content type: text/x-chdr
Error occurred while calculating annotation data.
Antibot

1 /*
2 * Copyright (C) 1998,1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu)
3 * Copyright (C) 2000,2001 Marco Ziech (mmz@gmx.net)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 #ifndef INCLUDED_CONNECTION_TYPES
20 #define INCLUDED_CONNECTION_TYPES
21
22 #ifdef CONNECTION_INTERNAL_ACCESS
23
24 #ifdef JUST_NEED_TYPES
25 # ifdef TIME_WITH_SYS_TIME
26 # include <sys/time.h>
27 # include <time.h>
28 # else
29 # if HAVE_SYS_TIME_H
30 # include <sys/time.h>
31 # else
32 # include <time.h>
33 # endif
34 # endif
35 # include "game.h"
36 # include "common/queue.h"
37 # include "channel.h"
38 # include "account.h"
39 # include "quota.h"
40 # include "character.h"
41 # include "versioncheck.h"
42 # include "anongame.h"
43 # include "realm.h"
44 # include "common/tag.h"
45 # include "common/elist.h"
46 # include "common/packet.h"
47 # include "common/rcm.h"
48 #else
49 # define JUST_NEED_TYPES
50 # ifdef TIME_WITH_SYS_TIME
51 # include <sys/time.h>
52 # include <time.h>
53 # else
54 # if HAVE_SYS_TIME_H
55 # include <sys/time.h>
56 # else
57 # include <time.h>
58 # endif
59 # endif
60 # include "game.h"
61 # include "common/queue.h"
62 # include "channel.h"
63 # include "account.h"
64 # include "quota.h"
65 # include "character.h"
66 # include "versioncheck.h"
67 # include "anongame.h"
68 # include "realm.h"
69 # include "common/tag.h"
70 # include "common/elist.h"
71 # include "common/packet.h"
72 # include "common/rcm.h"
73 # undef JUST_NEED_TYPES
74 #endif
75
76 #endif
77
78
79
80 typedef enum
81 {
82 conn_class_init,
83 conn_class_bnet,
84 conn_class_file,
85 conn_class_bot,
86 conn_class_telnet,
87 conn_class_irc, /* Internet Relay Chat */
88 conn_class_d2cs_bnetd,
89 conn_class_w3route,
90 conn_class_none
91 } t_conn_class;
92
93 typedef enum
94 {
95 conn_state_empty,
96 conn_state_initial,
97 conn_state_connected,
98 conn_state_loggedin,
99 conn_state_destroy,
100 conn_state_bot_username,
101 conn_state_bot_password,
102 conn_state_untrusted,
103 conn_state_pending_raw
104 } t_conn_state;
105
106 #ifdef CONNECTION_INTERNAL_ACCESS
107 typedef enum
108 {
109 conn_flags_welcomed = 0x01,
110 conn_flags_udpok = 0x02,
111 conn_flags_joingamewhisper = 0x04,
112 conn_flags_leavegamewhisper = 0x08,
113 conn_flags_echoback = 0x10
114
115 } t_conn_flags;
116
117 #endif
118
119 typedef struct connection
120 #ifdef CONNECTION_INTERNAL_ACCESS
121 {
122 struct {
123 int tcp_sock;
124 unsigned int tcp_addr;
125 unsigned short tcp_port;
126 int udp_sock;
127 unsigned int udp_addr;
128 unsigned short udp_port;
129 unsigned int local_addr;
130 unsigned short local_port;
131 unsigned int real_local_addr;
132 unsigned short real_local_port;
133 int fdw_idx;
134 } socket; /* IP and socket specific data */
135 struct {
136 t_conn_class class;
137 t_conn_state state;
138 unsigned int sessionkey;
139 unsigned int sessionnum;
140 unsigned int secret; /* random number... never sent over net unencrypted */
141 unsigned int flags;
142 unsigned int latency;
143 t_account * account;
144
145 /* by sowater, 20050331 */
146 char checknum;
147
148 struct {
149 t_tag archtag;
150 t_tag gamelang;
151 t_clienttag clienttag;
152 char const * clientver;
153 unsigned long versionid; /* AKA bnversion */
154 unsigned long gameversion;
155 unsigned long checksum;
156 char const * country;
157 int tzbias;
158 char const * host;
159 char const * user;
160 char const * clientexe;
161 char const * owner;
162 char const * cdkey;
163 t_versioncheck * versioncheck; /* equation and MPQ file used to validate game checksum */
164 } client; /* client program specific data */
165 struct {
166 t_queue * outqueue; /* packets waiting to be sent */
167 unsigned int outsize; /* amount sent from the current output packet */
168 unsigned int outsizep;
169 t_packet * inqueue; /* packet waiting to be processed */
170 unsigned int insize; /* amount received into the current input packet */
171 } queues; /* network queues and related data */
172 struct {
173 t_channel * channel;
174 char const * tmpOP_channel;
175 char const * tmpVOICE_channel;
176 char const * away;
177 char const * dnd;
178 t_account * * ignore_list;
179 unsigned int ignore_count;
180 t_quota quota;
181 time_t last_message;
182 char const * lastsender; /* last person to whisper to this connection */
183 struct {
184 char const * ircline; /* line cache for IRC connections */
185 unsigned int ircping; /* value of last ping */
186 char const * ircpass; /* hashed password for PASS authentication */
187 } irc; /* irc chat specific data */
188 } chat; /* chat and messages specific data */
189 t_game * game;
190 const char * loggeduser; /* username as logged in or given (not taken from account) */
191 struct connection * bound; /* matching Diablo II auth connection */
192 t_elist timers; /* cached list of timers for cleaning */
193 /* FIXME: this d2/w3 specific data could be unified into an union */
194 struct {
195 t_realm * realm;
196 t_rcm_regref realm_regref;
197 t_character * character;
198 char const * realminfo;
199 char const * charname;
200 } d2;
201 struct {
202 char const * w3_playerinfo; /* ADDED BY UNDYING SOULZZ 4/7/02 */
203 time_t anongame_search_starttime;
204 /* [zap-zero] 20020527 - matching w3route connection for game connection /
205 matching game connection for w3route connection */
206 /* FIXME: this "optimization" is so confusing leading to many possible bugs */
207 struct connection * routeconn;
208 t_anongame * anongame;
209 } w3;
210 // [quetzal] 20020828 - creation time, can be used for killing idling init connections
211 int cr_time;
212 /* Pass fail count for bruteforce protection */
213 unsigned int passfail_count;
214 /* connection flag substituting some other values */
215 t_conn_flags cflags;
216 } protocol;
217 }
218 #endif
219 t_connection;
220 #endif
221
222
223 /*****/
224 #ifndef JUST_NEED_TYPES
225 #ifndef INCLUDED_CONNECTION_PROTOS
226 #define INCLUDED_CONNECTION_PROTOS
227
228 #define JUST_NEED_TYPES
229 #include "common/packet.h"
230 #include "common/queue.h"
231 #include "channel.h"
232 #include "game.h"
233 #include "account.h"
234 #include "common/list.h"
235 #include "character.h"
236 #include "versioncheck.h"
237 #include "timer.h"
238 #include "anongame.h"
239 # include "realm.h"
240 #include "message.h"
241 #include "common/tag.h"
242 #include "common/fdwatch.h"
243 #undef JUST_NEED_TYPES
244
245 #define DESTROY_FROM_CONNLIST 0
246 #define DESTROY_FROM_DEADLIST 1
247
248 extern t_anongame * conn_create_anongame(t_connection * c);
249 extern void conn_destroy_anongame(t_connection * c);
250
251 extern t_anongame * conn_get_anongame(t_connection *c);
252
253
254 extern void conn_shutdown(t_connection * c, time_t now, t_timer_data foo);
255 extern void conn_test_latency(t_connection * c, time_t now, t_timer_data delta);
256 extern char const * conn_class_get_str(t_conn_class class) ;
257 extern char const * conn_state_get_str(t_conn_state state) ;
258
259 extern t_connection * conn_create(int tsock, int usock, unsigned int real_local_addr, unsigned short real_local_port, unsigned int local_addr, unsigned short local_port, unsigned int addr, unsigned short port) ;
260 extern void conn_destroy(t_connection * c, t_elem ** elem, int conn_or_dead_list);
261 extern int conn_match(t_connection const * c, char const * user);
262 extern t_conn_class conn_get_class(t_connection const * c) ;
263 extern void conn_set_class(t_connection * c, t_conn_class class);
264 extern t_conn_state conn_get_state(t_connection const * c) ;
265 extern void conn_set_state(t_connection * c, t_conn_state state);
266 extern unsigned int conn_get_sessionkey(t_connection const * c) ;
267 extern unsigned int conn_get_sessionnum(t_connection const * c) ;
268 extern unsigned int conn_get_secret(t_connection const * c) ;
269 extern unsigned int conn_get_addr(t_connection const * c) ;
270 extern unsigned short conn_get_port(t_connection const * c) ;
271 extern unsigned int conn_get_local_addr(t_connection const * c);
272 extern unsigned short conn_get_local_port(t_connection const * c) ;
273 extern unsigned int conn_get_real_local_addr(t_connection const * c) ;
274 extern unsigned short conn_get_real_local_port(t_connection const * c) ;
275 extern unsigned int conn_get_game_addr(t_connection const * c) ;
276 extern int conn_set_game_addr(t_connection * c, unsigned int game_addr);
277 extern unsigned short conn_get_game_port(t_connection const * c) ;
278 extern int conn_set_game_port(t_connection * c, unsigned short game_port);
279 extern void conn_set_host(t_connection * c, char const * host);
280 extern void conn_set_user(t_connection * c, char const * user);
281 extern const char * conn_get_user(t_connection const * c);
282 extern void conn_set_owner(t_connection * c, char const * owner);
283 extern const char * conn_get_owner(t_connection const * c);
284 extern void conn_set_cdkey(t_connection * c, char const * cdkey);
285 extern char const * conn_get_clientexe(t_connection const * c) ;
286 extern void conn_set_clientexe(t_connection * c, char const * clientexe);
287 extern t_tag conn_get_archtag(t_connection const * c) ;
288 extern void conn_set_archtag(t_connection * c, t_tag archtag);
289 extern t_tag conn_get_gamelang(t_connection const * c) ;
290 extern void conn_set_gamelang(t_connection * c, t_tag gamelang);
291 extern t_clienttag conn_get_clienttag(t_connection const * c) ;
292 extern t_clienttag conn_get_fake_clienttag(t_connection const * c) ;
293 extern void conn_set_clienttag(t_connection * c, t_clienttag clienttag);
294 extern unsigned long conn_get_versionid(t_connection const * c) ;
295 extern int conn_set_versionid(t_connection * c, unsigned long versionid);
296 extern unsigned long conn_get_gameversion(t_connection const * c) ;
297 extern int conn_set_gameversion(t_connection * c, unsigned long gameversion);
298 extern unsigned long conn_get_checksum(t_connection const * c) ;
299 extern int conn_set_checksum(t_connection * c, unsigned long checksum);
300 extern char const * conn_get_clientver(t_connection const * c) ;
301 extern void conn_set_clientver(t_connection * c, char const * clientver);
302 extern int conn_get_tzbias(t_connection const * c) ;
303 extern void conn_set_tzbias(t_connection * c, int tzbias);
304 extern int conn_set_loggeduser(t_connection * c, char const * username);
305 extern char const * conn_get_loggeduser(t_connection const * c);
306 extern unsigned int conn_get_flags(t_connection const * c) ;
307 extern int conn_set_flags(t_connection * c, unsigned int flags);
308 extern void conn_add_flags(t_connection * c, unsigned int flags);
309 extern void conn_del_flags(t_connection * c, unsigned int flags);
310 extern unsigned int conn_get_latency(t_connection const * c) ;
311 extern void conn_set_latency(t_connection * c, unsigned int ms);
312 extern char const * conn_get_awaystr(t_connection const * c) ;
313 extern int conn_set_awaystr(t_connection * c, char const * away);
314 extern char const * conn_get_dndstr(t_connection const * c) ;
315 extern int conn_set_dndstr(t_connection * c, char const * dnd);
316 extern int conn_add_ignore(t_connection * c, t_account * account);
317 extern int conn_del_ignore(t_connection * c, t_account const * account);
318 extern int conn_add_watch(t_connection * c, t_account * account, t_clienttag clienttag);
319 extern int conn_del_watch(t_connection * c, t_account * account, t_clienttag clienttag);
320 extern t_channel * conn_get_channel(t_connection const * c) ;
321 extern int conn_set_channel_var(t_connection * c, t_channel * channel);
322 extern int conn_set_channel(t_connection * c, char const * channelname);
323 extern t_game * conn_get_game(t_connection const * c) ;
324 extern int conn_set_game(t_connection * c, char const * gamename, char const * gamepass, char const * gameinfo, t_game_type type, int version);
325 extern unsigned int conn_get_tcpaddr(t_connection * c) ;
326 extern t_packet * conn_get_in_queue(t_connection * c) ;
327 extern void conn_put_in_queue(t_connection * c, t_packet *packet) ;
328 extern unsigned int conn_get_in_size(t_connection const * c) ;
329 extern void conn_set_in_size(t_connection * c, unsigned int size);
330 extern unsigned int conn_get_out_size(t_connection const * c) ;
331 extern void conn_set_out_size(t_connection * c, unsigned int size);
332 extern int conn_push_outqueue(t_connection * c, t_packet * packet);
333 extern t_packet * conn_peek_outqueue(t_connection * c);
334 extern t_packet * conn_pull_outqueue(t_connection * c);
335 extern int conn_check_ignoring(t_connection const * c, char const * me) ;
336 extern t_account * conn_get_account(t_connection const * c) ;
337 extern void conn_login(t_connection * c, t_account * account, const char *loggeduser);
338 extern int conn_get_socket(t_connection const * c) ;
339 extern int conn_get_game_socket(t_connection const * c) ;
340 extern int conn_set_game_socket(t_connection * c, int usock);
341 extern char const * conn_get_username_real(t_connection const * c, char const * fn, unsigned int ln);
342 #define conn_get_username(C) conn_get_username_real(C,__FILE__,__LINE__)
343 extern char const * conn_get_chatname(t_connection const * c);
344 extern int conn_unget_chatname(t_connection const * c, char const * name);
345 extern char const * conn_get_chatcharname(t_connection const * c, t_connection const * dst);
346 extern int conn_unget_chatcharname(t_connection const * c, char const * name);
347 extern t_message_class conn_get_message_class(t_connection const * c, t_connection const * dst);
348 extern unsigned int conn_get_userid(t_connection const * c);
349 extern char const * conn_get_playerinfo(t_connection const * c);
350 extern int conn_set_playerinfo(t_connection const * c, char const * playerinfo);
351 extern char const * conn_get_realminfo(t_connection const * c);
352 extern int conn_set_realminfo(t_connection * c, char const * realminfo);
353 extern char const * conn_get_charname(t_connection const * c);
354 extern int conn_set_charname(t_connection * c, char const * charname);
355 extern int conn_set_idletime(t_connection * c);
356 extern unsigned int conn_get_idletime(t_connection const * c) ;
357 extern t_realm * conn_get_realm(t_connection const * c);
358 extern int conn_set_realm(t_connection * c, t_realm * realm);
359 extern int conn_set_character(t_connection * c, t_character * ch);
360 extern int conn_bind(t_connection * c1, t_connection * c2);
361 extern void conn_set_country(t_connection * c, char const * country);
362 extern char const * conn_get_country(t_connection const * c);
363 extern int conn_quota_exceeded(t_connection * c, char const * message);
364 extern int conn_set_lastsender(t_connection * c, char const * sender);
365 extern char const * conn_get_lastsender(t_connection const * c);
366 extern t_versioncheck * conn_get_versioncheck(t_connection * c) ;
367 extern int conn_set_versioncheck(t_connection * c, t_versioncheck * versioncheck);
368 extern int conn_get_echoback(t_connection * c) ;
369 extern void conn_set_echoback(t_connection * c, int echoback);
370 extern int conn_set_ircline(t_connection * c, char const * line);
371 extern char const * conn_get_ircline(t_connection const * c);
372 extern int conn_set_ircpass(t_connection * c, char const * pass);
373 extern char const * conn_get_ircpass(t_connection const * c);
374 extern int conn_set_ircping(t_connection * c, unsigned int ping);
375 extern unsigned int conn_get_ircping(t_connection const * c);
376 extern int conn_set_udpok(t_connection * c);
377 extern int conn_get_welcomed(t_connection const * c) ;
378 extern void conn_set_welcomed(t_connection * c, int welcomed);
379
380 /* ADDED BY UNDYING SOULZZ 4/7/02 */
381 extern int conn_set_w3_playerinfo( t_connection * c, char const * w3_playerinfo );
382 extern const char * conn_get_w3_playerinfo( t_connection * c );
383
384 // [quetzal] 20020822
385 extern int conn_get_crtime(t_connection *c);
386
387 // [zap-zero] 20020522
388 extern int conn_set_w3_loginreq(t_connection * c, char const * loginreq);
389 extern char const * conn_get_w3_loginreq(t_connection * c);
390
391 // [zap-zero] 20020527
392 extern int conn_set_routeconn(t_connection * c, t_connection * rc);
393 extern t_connection * conn_get_routeconn(t_connection const * c);
394 extern int connlist_create(void);
395 extern void connlist_reap(void);
396 extern int connlist_destroy(void);
397 extern t_list * connlist(void) ;
398 extern t_connection * connlist_find_connection_by_sessionkey(unsigned int sessionkey);
399 extern t_connection * connlist_find_connection_by_socket(int socket);
400 extern t_connection * connlist_find_connection_by_sessionnum(unsigned int sessionnum);
401 extern t_connection * connlist_find_connection_by_name(char const * name, t_realm * realm); /* any chat name format */
402 extern t_connection * connlist_find_connection_by_accountname(char const * username);
403 extern t_connection * connlist_find_connection_by_charname(char const * charname, char const * realmname);
404 extern t_connection * connlist_find_connection_by_account(t_account * account);
405 extern t_connection * connlist_find_connection_by_uid(unsigned int uid);
406 extern int connlist_get_length(void) ;
407 extern unsigned int connlist_login_get_length(void) ;
408 extern int connlist_total_logins(void) ;
409 extern int conn_set_joingamewhisper_ack(t_connection * c, unsigned int value);
410 extern int conn_get_joingamewhisper_ack(t_connection * c);
411 extern int conn_set_leavegamewhisper_ack(t_connection * c, unsigned int value);
412 extern int conn_get_leavegamewhisper_ack(t_connection * c);
413 extern int conn_set_anongame_search_starttime(t_connection * c, time_t t);
414 extern time_t conn_get_anongame_search_starttime(t_connection * c);
415
416 extern int conn_get_user_count_by_clienttag(t_clienttag ct);
417
418 extern unsigned int connlist_count_connections(unsigned int addr);
419
420 extern int conn_update_w3_playerinfo(t_connection * c);
421
422 extern int conn_get_passfail_count(t_connection * c);
423 extern int conn_set_passfail_count(t_connection * c, unsigned int failcount);
424 extern int conn_increment_passfail_count (t_connection * c);
425
426 extern int conn_set_tmpOP_channel(t_connection * c, char const * tmpOP_channel);
427 extern char const * conn_get_tmpOP_channel(t_connection * c);
428 extern int conn_set_tmpVOICE_channel(t_connection * c, char const * tmpVOICE_channel);
429 extern char const * conn_get_tmpVOICE_channel(t_connection * c);
430 extern t_elist *conn_get_timer(t_connection * c);
431 extern int conn_add_fdwatch(t_connection *c, fdwatch_handler handle);
432
433 /* by sowater, 20050331 */
434 extern char conn_get_checknum(t_connection const *c);
435 extern int conn_set_checknum(t_connection *c, char checknum);
436 #endif
437 #endif

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1