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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Tue Jun 6 03:41:37 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU
CVS Tags: arelease
Changes since 1.1: +0 -0 lines
Content type: text/x-chdr
no message

1 sysadm 1.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     struct {
145     t_tag archtag;
146     t_tag gamelang;
147     t_clienttag clienttag;
148     char const * clientver;
149     unsigned long versionid; /* AKA bnversion */
150     unsigned long gameversion;
151     unsigned long checksum;
152     char const * country;
153     int tzbias;
154     char const * host;
155     char const * user;
156     char const * clientexe;
157     char const * owner;
158     char const * cdkey;
159     t_versioncheck * versioncheck; /* equation and MPQ file used to validate game checksum */
160     } client; /* client program specific data */
161     struct {
162     t_queue * outqueue; /* packets waiting to be sent */
163     unsigned int outsize; /* amount sent from the current output packet */
164     unsigned int outsizep;
165     t_packet * inqueue; /* packet waiting to be processed */
166     unsigned int insize; /* amount received into the current input packet */
167     } queues; /* network queues and related data */
168     struct {
169     t_channel * channel;
170     char const * tmpOP_channel;
171     char const * tmpVOICE_channel;
172     char const * away;
173     char const * dnd;
174     t_account * * ignore_list;
175     unsigned int ignore_count;
176     t_quota quota;
177     time_t last_message;
178     char const * lastsender; /* last person to whisper to this connection */
179     struct {
180     char const * ircline; /* line cache for IRC connections */
181     unsigned int ircping; /* value of last ping */
182     char const * ircpass; /* hashed password for PASS authentication */
183     } irc; /* irc chat specific data */
184     } chat; /* chat and messages specific data */
185     t_game * game;
186     const char * loggeduser; /* username as logged in or given (not taken from account) */
187     struct connection * bound; /* matching Diablo II auth connection */
188     t_elist timers; /* cached list of timers for cleaning */
189     /* FIXME: this d2/w3 specific data could be unified into an union */
190     struct {
191     t_realm * realm;
192     t_rcm_regref realm_regref;
193     t_character * character;
194     char const * realminfo;
195     char const * charname;
196     } d2;
197     struct {
198     char const * w3_playerinfo; /* ADDED BY UNDYING SOULZZ 4/7/02 */
199     time_t anongame_search_starttime;
200     /* [zap-zero] 20020527 - matching w3route connection for game connection /
201     matching game connection for w3route connection */
202     /* FIXME: this "optimization" is so confusing leading to many possible bugs */
203     struct connection * routeconn;
204     t_anongame * anongame;
205     } w3;
206     // [quetzal] 20020828 - creation time, can be used for killing idling init connections
207     int cr_time;
208     /* Pass fail count for bruteforce protection */
209     unsigned int passfail_count;
210     /* connection flag substituting some other values */
211     t_conn_flags cflags;
212     } protocol;
213     }
214     #endif
215     t_connection;
216     #endif
217    
218    
219     /*****/
220     #ifndef JUST_NEED_TYPES
221     #ifndef INCLUDED_CONNECTION_PROTOS
222     #define INCLUDED_CONNECTION_PROTOS
223    
224     #define JUST_NEED_TYPES
225     #include "common/packet.h"
226     #include "common/queue.h"
227     #include "channel.h"
228     #include "game.h"
229     #include "account.h"
230     #include "common/list.h"
231     #include "character.h"
232     #include "versioncheck.h"
233     #include "timer.h"
234     #include "anongame.h"
235     # include "realm.h"
236     #include "message.h"
237     #include "common/tag.h"
238     #include "common/fdwatch.h"
239     #undef JUST_NEED_TYPES
240    
241     #define DESTROY_FROM_CONNLIST 0
242     #define DESTROY_FROM_DEADLIST 1
243    
244     extern t_anongame * conn_create_anongame(t_connection * c);
245     extern void conn_destroy_anongame(t_connection * c);
246    
247     extern t_anongame * conn_get_anongame(t_connection *c);
248    
249    
250     extern void conn_shutdown(t_connection * c, time_t now, t_timer_data foo);
251     extern void conn_test_latency(t_connection * c, time_t now, t_timer_data delta);
252     extern char const * conn_class_get_str(t_conn_class class) ;
253     extern char const * conn_state_get_str(t_conn_state state) ;
254    
255     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) ;
256     extern void conn_destroy(t_connection * c, t_elem ** elem, int conn_or_dead_list);
257     extern int conn_match(t_connection const * c, char const * user);
258     extern t_conn_class conn_get_class(t_connection const * c) ;
259     extern void conn_set_class(t_connection * c, t_conn_class class);
260     extern t_conn_state conn_get_state(t_connection const * c) ;
261     extern void conn_set_state(t_connection * c, t_conn_state state);
262     extern unsigned int conn_get_sessionkey(t_connection const * c) ;
263     extern unsigned int conn_get_sessionnum(t_connection const * c) ;
264     extern unsigned int conn_get_secret(t_connection const * c) ;
265     extern unsigned int conn_get_addr(t_connection const * c) ;
266     extern unsigned short conn_get_port(t_connection const * c) ;
267     extern unsigned int conn_get_local_addr(t_connection const * c);
268     extern unsigned short conn_get_local_port(t_connection const * c) ;
269     extern unsigned int conn_get_real_local_addr(t_connection const * c) ;
270     extern unsigned short conn_get_real_local_port(t_connection const * c) ;
271     extern unsigned int conn_get_game_addr(t_connection const * c) ;
272     extern int conn_set_game_addr(t_connection * c, unsigned int game_addr);
273     extern unsigned short conn_get_game_port(t_connection const * c) ;
274     extern int conn_set_game_port(t_connection * c, unsigned short game_port);
275     extern void conn_set_host(t_connection * c, char const * host);
276     extern void conn_set_user(t_connection * c, char const * user);
277     extern const char * conn_get_user(t_connection const * c);
278     extern void conn_set_owner(t_connection * c, char const * owner);
279     extern const char * conn_get_owner(t_connection const * c);
280     extern void conn_set_cdkey(t_connection * c, char const * cdkey);
281     extern char const * conn_get_clientexe(t_connection const * c) ;
282     extern void conn_set_clientexe(t_connection * c, char const * clientexe);
283     extern t_tag conn_get_archtag(t_connection const * c) ;
284     extern void conn_set_archtag(t_connection * c, t_tag archtag);
285     extern t_tag conn_get_gamelang(t_connection const * c) ;
286     extern void conn_set_gamelang(t_connection * c, t_tag gamelang);
287     extern t_clienttag conn_get_clienttag(t_connection const * c) ;
288     extern t_clienttag conn_get_fake_clienttag(t_connection const * c) ;
289     extern void conn_set_clienttag(t_connection * c, t_clienttag clienttag);
290     extern unsigned long conn_get_versionid(t_connection const * c) ;
291     extern int conn_set_versionid(t_connection * c, unsigned long versionid);
292     extern unsigned long conn_get_gameversion(t_connection const * c) ;
293     extern int conn_set_gameversion(t_connection * c, unsigned long gameversion);
294     extern unsigned long conn_get_checksum(t_connection const * c) ;
295     extern int conn_set_checksum(t_connection * c, unsigned long checksum);
296     extern char const * conn_get_clientver(t_connection const * c) ;
297     extern void conn_set_clientver(t_connection * c, char const * clientver);
298     extern int conn_get_tzbias(t_connection const * c) ;
299     extern void conn_set_tzbias(t_connection * c, int tzbias);
300     extern int conn_set_loggeduser(t_connection * c, char const * username);
301     extern char const * conn_get_loggeduser(t_connection const * c);
302     extern unsigned int conn_get_flags(t_connection const * c) ;
303     extern int conn_set_flags(t_connection * c, unsigned int flags);
304     extern void conn_add_flags(t_connection * c, unsigned int flags);
305     extern void conn_del_flags(t_connection * c, unsigned int flags);
306     extern unsigned int conn_get_latency(t_connection const * c) ;
307     extern void conn_set_latency(t_connection * c, unsigned int ms);
308     extern char const * conn_get_awaystr(t_connection const * c) ;
309     extern int conn_set_awaystr(t_connection * c, char const * away);
310     extern char const * conn_get_dndstr(t_connection const * c) ;
311     extern int conn_set_dndstr(t_connection * c, char const * dnd);
312     extern int conn_add_ignore(t_connection * c, t_account * account);
313     extern int conn_del_ignore(t_connection * c, t_account const * account);
314     extern int conn_add_watch(t_connection * c, t_account * account, t_clienttag clienttag);
315     extern int conn_del_watch(t_connection * c, t_account * account, t_clienttag clienttag);
316     extern t_channel * conn_get_channel(t_connection const * c) ;
317     extern int conn_set_channel_var(t_connection * c, t_channel * channel);
318     extern int conn_set_channel(t_connection * c, char const * channelname);
319     extern t_game * conn_get_game(t_connection const * c) ;
320     extern int conn_set_game(t_connection * c, char const * gamename, char const * gamepass, char const * gameinfo, t_game_type type, int version);
321     extern unsigned int conn_get_tcpaddr(t_connection * c) ;
322     extern t_packet * conn_get_in_queue(t_connection * c) ;
323     extern void conn_put_in_queue(t_connection * c, t_packet *packet) ;
324     extern unsigned int conn_get_in_size(t_connection const * c) ;
325     extern void conn_set_in_size(t_connection * c, unsigned int size);
326     extern unsigned int conn_get_out_size(t_connection const * c) ;
327     extern void conn_set_out_size(t_connection * c, unsigned int size);
328     extern int conn_push_outqueue(t_connection * c, t_packet * packet);
329     extern t_packet * conn_peek_outqueue(t_connection * c);
330     extern t_packet * conn_pull_outqueue(t_connection * c);
331     extern int conn_check_ignoring(t_connection const * c, char const * me) ;
332     extern t_account * conn_get_account(t_connection const * c) ;
333     extern void conn_login(t_connection * c, t_account * account, const char *loggeduser);
334     extern int conn_get_socket(t_connection const * c) ;
335     extern int conn_get_game_socket(t_connection const * c) ;
336     extern int conn_set_game_socket(t_connection * c, int usock);
337     extern char const * conn_get_username_real(t_connection const * c, char const * fn, unsigned int ln);
338     #define conn_get_username(C) conn_get_username_real(C,__FILE__,__LINE__)
339     extern char const * conn_get_chatname(t_connection const * c);
340     extern int conn_unget_chatname(t_connection const * c, char const * name);
341     extern char const * conn_get_chatcharname(t_connection const * c, t_connection const * dst);
342     extern int conn_unget_chatcharname(t_connection const * c, char const * name);
343     extern t_message_class conn_get_message_class(t_connection const * c, t_connection const * dst);
344     extern unsigned int conn_get_userid(t_connection const * c);
345     extern char const * conn_get_playerinfo(t_connection const * c);
346     extern int conn_set_playerinfo(t_connection const * c, char const * playerinfo);
347     extern char const * conn_get_realminfo(t_connection const * c);
348     extern int conn_set_realminfo(t_connection * c, char const * realminfo);
349     extern char const * conn_get_charname(t_connection const * c);
350     extern int conn_set_charname(t_connection * c, char const * charname);
351     extern int conn_set_idletime(t_connection * c);
352     extern unsigned int conn_get_idletime(t_connection const * c) ;
353     extern t_realm * conn_get_realm(t_connection const * c);
354     extern int conn_set_realm(t_connection * c, t_realm * realm);
355     extern int conn_set_character(t_connection * c, t_character * ch);
356     extern int conn_bind(t_connection * c1, t_connection * c2);
357     extern void conn_set_country(t_connection * c, char const * country);
358     extern char const * conn_get_country(t_connection const * c);
359     extern int conn_quota_exceeded(t_connection * c, char const * message);
360     extern int conn_set_lastsender(t_connection * c, char const * sender);
361     extern char const * conn_get_lastsender(t_connection const * c);
362     extern t_versioncheck * conn_get_versioncheck(t_connection * c) ;
363     extern int conn_set_versioncheck(t_connection * c, t_versioncheck * versioncheck);
364     extern int conn_get_echoback(t_connection * c) ;
365     extern void conn_set_echoback(t_connection * c, int echoback);
366     extern int conn_set_ircline(t_connection * c, char const * line);
367     extern char const * conn_get_ircline(t_connection const * c);
368     extern int conn_set_ircpass(t_connection * c, char const * pass);
369     extern char const * conn_get_ircpass(t_connection const * c);
370     extern int conn_set_ircping(t_connection * c, unsigned int ping);
371     extern unsigned int conn_get_ircping(t_connection const * c);
372     extern int conn_set_udpok(t_connection * c);
373     extern int conn_get_welcomed(t_connection const * c) ;
374     extern void conn_set_welcomed(t_connection * c, int welcomed);
375    
376     /* ADDED BY UNDYING SOULZZ 4/7/02 */
377     extern int conn_set_w3_playerinfo( t_connection * c, char const * w3_playerinfo );
378     extern const char * conn_get_w3_playerinfo( t_connection * c );
379    
380     // [quetzal] 20020822
381     extern int conn_get_crtime(t_connection *c);
382    
383     // [zap-zero] 20020522
384     extern int conn_set_w3_loginreq(t_connection * c, char const * loginreq);
385     extern char const * conn_get_w3_loginreq(t_connection * c);
386    
387     // [zap-zero] 20020527
388     extern int conn_set_routeconn(t_connection * c, t_connection * rc);
389     extern t_connection * conn_get_routeconn(t_connection const * c);
390     extern int connlist_create(void);
391     extern void connlist_reap(void);
392     extern int connlist_destroy(void);
393     extern t_list * connlist(void) ;
394     extern t_connection * connlist_find_connection_by_sessionkey(unsigned int sessionkey);
395     extern t_connection * connlist_find_connection_by_socket(int socket);
396     extern t_connection * connlist_find_connection_by_sessionnum(unsigned int sessionnum);
397     extern t_connection * connlist_find_connection_by_name(char const * name, t_realm * realm); /* any chat name format */
398     extern t_connection * connlist_find_connection_by_accountname(char const * username);
399     extern t_connection * connlist_find_connection_by_charname(char const * charname, char const * realmname);
400     extern t_connection * connlist_find_connection_by_account(t_account * account);
401     extern t_connection * connlist_find_connection_by_uid(unsigned int uid);
402     extern int connlist_get_length(void) ;
403     extern unsigned int connlist_login_get_length(void) ;
404     extern int connlist_total_logins(void) ;
405     extern int conn_set_joingamewhisper_ack(t_connection * c, unsigned int value);
406     extern int conn_get_joingamewhisper_ack(t_connection * c);
407     extern int conn_set_leavegamewhisper_ack(t_connection * c, unsigned int value);
408     extern int conn_get_leavegamewhisper_ack(t_connection * c);
409     extern int conn_set_anongame_search_starttime(t_connection * c, time_t t);
410     extern time_t conn_get_anongame_search_starttime(t_connection * c);
411    
412     extern int conn_get_user_count_by_clienttag(t_clienttag ct);
413    
414     extern unsigned int connlist_count_connections(unsigned int addr);
415    
416     extern int conn_update_w3_playerinfo(t_connection * c);
417    
418     extern int conn_get_passfail_count(t_connection * c);
419     extern int conn_set_passfail_count(t_connection * c, unsigned int failcount);
420     extern int conn_increment_passfail_count (t_connection * c);
421    
422     extern int conn_set_tmpOP_channel(t_connection * c, char const * tmpOP_channel);
423     extern char const * conn_get_tmpOP_channel(t_connection * c);
424     extern int conn_set_tmpVOICE_channel(t_connection * c, char const * tmpVOICE_channel);
425     extern char const * conn_get_tmpVOICE_channel(t_connection * c);
426     extern t_elist *conn_get_timer(t_connection * c);
427     extern int conn_add_fdwatch(t_connection *c, fdwatch_handler handle);
428    
429     #endif
430     #endif

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