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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue Jun 13 12:19:11 2006 UTC (19 years, 9 months ago) by sysadm
Branch: MAIN
CVS Tags: pvpgn_1-7-4-0_MIL, HEAD
Changes since 1.3: +1 -2 lines
Content type: text/x-chdr
Antibot (for non-password protected game)

1 /*
2 * Copyright (C) 2000,2001 Onlyer (onlyer@263.net)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #ifndef INCLUDED_CONNECTION_H
19 #define INCLUDED_CONNECTION_H
20
21 #include "common/queue.h"
22 #include "common/hashtable.h"
23 #include "common/packet.h"
24 #include "common/fdwatch.h"
25 #include "d2charfile.h"
26 #include "gamequeue.h"
27
28 typedef enum
29 {
30 conn_state_none = 0x00,
31 conn_state_init = 0x01,
32 conn_state_connecting = 0x02,
33 conn_state_connected = 0x04,
34 conn_state_authed = 0x08,
35 conn_state_char_authed = 0x10,
36 conn_state_destroy = 0x20,
37 conn_state_destroying = 0x40,
38 conn_state_any = 0xff
39 } t_conn_state;
40
41 typedef enum
42 {
43 conn_class_none,
44 conn_class_init,
45 conn_class_d2cs,
46 conn_class_d2gs,
47 conn_class_bnetd
48 } t_conn_class;
49
50 typedef struct
51 {
52 char const * charname;
53 char const * account;
54 int sock;
55 int fdw_idx;
56 unsigned int socket_flag;
57 unsigned int addr;
58 unsigned int local_addr;
59 unsigned short port;
60 unsigned short local_port;
61 unsigned int last_active;
62 t_conn_class class;
63 t_conn_state state;
64 unsigned int sessionnum;
65 t_queue * outqueue;
66 unsigned int outsize;
67 unsigned int outsizep;
68 t_packet * inqueue;
69 unsigned int insize;
70 t_d2charinfo_summary const * charinfo;
71 unsigned int d2gs_id;
72 t_gq * gamequeue;
73 unsigned int bnetd_sessionnum;
74 unsigned int sessionnum_hash;
75 unsigned int charname_hash;
76
77 /* by sowater, 200503031 */
78 char checknum;
79
80 /* by Leaflet, 20050613 */
81 int checknum_error_count;
82
83 } t_connection;
84
85 typedef int ( * packet_handle_func) (t_connection * c, t_packet * packet);
86 typedef struct
87 {
88 unsigned int size;
89 t_conn_state state;
90 packet_handle_func handler;
91 } t_packet_handle_table;
92
93 #define SOCKET_FLAG_READ 0x1
94 #define SOCKET_FLAG_WRITE 0x2
95
96 extern t_hashtable * d2cs_connlist(void);
97 extern int d2cs_connlist_destroy(void);
98 extern int d2cs_connlist_reap(void);
99 extern int d2cs_connlist_create(void);
100 extern int conn_check_multilogin(t_connection const * c,char const * charname);
101 extern t_connection * d2cs_connlist_find_connection_by_sessionnum(unsigned int sessionnum);
102 extern t_connection * d2cs_connlist_find_connection_by_charname(char const * charname);
103 extern int conn_handle_socket(t_connection * c);
104 extern t_connection * d2cs_conn_create(int sock, unsigned int local_addr, unsigned short local_port,
105 unsigned int addr, unsigned short port);
106 extern int d2cs_conn_destroy(t_connection * c, t_elem ** elem);
107 extern int d2cs_conn_get_socket(t_connection const * c);
108 extern unsigned int d2cs_conn_get_sessionnum(t_connection const * c);
109 extern t_conn_class d2cs_conn_get_class(t_connection const * c);
110 extern int d2cs_conn_set_class(t_connection * c, t_conn_class class);
111 extern t_conn_state d2cs_conn_get_state(t_connection const * c);
112 extern int d2cs_conn_set_state(t_connection * c, t_conn_state state);
113 extern t_queue * * d2cs_conn_get_out_queue(t_connection const * c);
114 extern t_packet * d2cs_conn_get_in_queue(t_connection const * c);
115 extern void d2cs_conn_set_in_queue(t_connection * c, t_packet * packet);
116 extern unsigned int d2cs_conn_get_in_size(t_connection const * c);
117 extern unsigned int d2cs_conn_get_out_size(t_connection const * c);
118 extern int conn_push_outqueue(t_connection * c, t_packet * packet);
119 extern t_packet * conn_peek_outqueue(t_connection * c);
120 extern t_packet * conn_pull_outqueue(t_connection * c);
121 extern int conn_add_socket_flag(t_connection * c, unsigned int flag);
122 extern int conn_process_packet(t_connection * c, t_packet * packet, t_packet_handle_table * table,
123 unsigned int table_size);
124 extern int d2cs_conn_set_account(t_connection * c, char const * account);
125 extern int d2cs_conn_set_charname(t_connection * c, char const * charname);
126 extern char const * d2cs_conn_get_account(t_connection const * c);
127 extern char const * d2cs_conn_get_charname(t_connection const * c);
128 extern int conn_set_charinfo(t_connection * c, t_d2charinfo_summary const * charinfo);
129 extern unsigned int conn_get_charinfo_ladder(t_connection const * c);
130 extern unsigned int conn_get_charinfo_expansion(t_connection const * c);
131 extern unsigned int conn_get_charinfo_hardcore(t_connection const * c);
132 extern unsigned int conn_get_charinfo_dead(t_connection const * c);
133 extern unsigned int conn_get_charinfo_difficulty(t_connection const * c);
134 extern unsigned int conn_get_charinfo_level(t_connection const * c);
135 extern unsigned int conn_get_charinfo_class(t_connection const * c);
136 extern unsigned int conn_get_d2gs_id(t_connection const * c);
137 extern int conn_set_d2gs_id(t_connection * c, unsigned int d2gs_id);
138 extern unsigned int d2cs_conn_get_addr(t_connection const * c);
139 extern unsigned short d2cs_conn_get_port(t_connection const * c);
140 extern t_gq * conn_get_gamequeue(t_connection const * c);
141 extern int conn_set_gamequeue(t_connection * c, t_gq * gq);
142 extern int conn_set_bnetd_sessionnum(t_connection * c, unsigned int sessionnum);
143 extern unsigned int conn_get_bnetd_sessionnum(t_connection const * c);
144 extern int conn_add_fd(t_connection * c, t_fdwatch_type rw, fdwatch_handler handler);
145 extern int connlist_check_timeout(void);
146
147 /* by sowater, 20050331 */
148 extern int d2cs_conn_set_checknum(t_connection * c, char checknum);
149 extern char d2cs_conn_get_checknum(t_connection * c);
150 /* by Leaflet, 20060613 */
151 extern int d2cs_conn_verify_checknum(t_connection *c, char checksum);
152
153 #endif

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