/[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.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:38 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 /*
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 } t_connection;
77
78 typedef int ( * packet_handle_func) (t_connection * c, t_packet * packet);
79 typedef struct
80 {
81 unsigned int size;
82 t_conn_state state;
83 packet_handle_func handler;
84 } t_packet_handle_table;
85
86 #define SOCKET_FLAG_READ 0x1
87 #define SOCKET_FLAG_WRITE 0x2
88
89 extern t_hashtable * d2cs_connlist(void);
90 extern int d2cs_connlist_destroy(void);
91 extern int d2cs_connlist_reap(void);
92 extern int d2cs_connlist_create(void);
93 extern int conn_check_multilogin(t_connection const * c,char const * charname);
94 extern t_connection * d2cs_connlist_find_connection_by_sessionnum(unsigned int sessionnum);
95 extern t_connection * d2cs_connlist_find_connection_by_charname(char const * charname);
96 extern int conn_handle_socket(t_connection * c);
97 extern t_connection * d2cs_conn_create(int sock, unsigned int local_addr, unsigned short local_port,
98 unsigned int addr, unsigned short port);
99 extern int d2cs_conn_destroy(t_connection * c, t_elem ** elem);
100 extern int d2cs_conn_get_socket(t_connection const * c);
101 extern unsigned int d2cs_conn_get_sessionnum(t_connection const * c);
102 extern t_conn_class d2cs_conn_get_class(t_connection const * c);
103 extern int d2cs_conn_set_class(t_connection * c, t_conn_class class);
104 extern t_conn_state d2cs_conn_get_state(t_connection const * c);
105 extern int d2cs_conn_set_state(t_connection * c, t_conn_state state);
106 extern t_queue * * d2cs_conn_get_out_queue(t_connection const * c);
107 extern t_packet * d2cs_conn_get_in_queue(t_connection const * c);
108 extern void d2cs_conn_set_in_queue(t_connection * c, t_packet * packet);
109 extern unsigned int d2cs_conn_get_in_size(t_connection const * c);
110 extern unsigned int d2cs_conn_get_out_size(t_connection const * c);
111 extern int conn_push_outqueue(t_connection * c, t_packet * packet);
112 extern t_packet * conn_peek_outqueue(t_connection * c);
113 extern t_packet * conn_pull_outqueue(t_connection * c);
114 extern int conn_add_socket_flag(t_connection * c, unsigned int flag);
115 extern int conn_process_packet(t_connection * c, t_packet * packet, t_packet_handle_table * table,
116 unsigned int table_size);
117 extern int d2cs_conn_set_account(t_connection * c, char const * account);
118 extern int d2cs_conn_set_charname(t_connection * c, char const * charname);
119 extern char const * d2cs_conn_get_account(t_connection const * c);
120 extern char const * d2cs_conn_get_charname(t_connection const * c);
121 extern int conn_set_charinfo(t_connection * c, t_d2charinfo_summary const * charinfo);
122 extern unsigned int conn_get_charinfo_ladder(t_connection const * c);
123 extern unsigned int conn_get_charinfo_expansion(t_connection const * c);
124 extern unsigned int conn_get_charinfo_hardcore(t_connection const * c);
125 extern unsigned int conn_get_charinfo_dead(t_connection const * c);
126 extern unsigned int conn_get_charinfo_difficulty(t_connection const * c);
127 extern unsigned int conn_get_charinfo_level(t_connection const * c);
128 extern unsigned int conn_get_charinfo_class(t_connection const * c);
129 extern unsigned int conn_get_d2gs_id(t_connection const * c);
130 extern int conn_set_d2gs_id(t_connection * c, unsigned int d2gs_id);
131 extern unsigned int d2cs_conn_get_addr(t_connection const * c);
132 extern unsigned short d2cs_conn_get_port(t_connection const * c);
133 extern t_gq * conn_get_gamequeue(t_connection const * c);
134 extern int conn_set_gamequeue(t_connection * c, t_gq * gq);
135 extern int conn_set_bnetd_sessionnum(t_connection * c, unsigned int sessionnum);
136 extern unsigned int conn_get_bnetd_sessionnum(t_connection const * c);
137 extern int conn_add_fd(t_connection * c, t_fdwatch_type rw, fdwatch_handler handler);
138 extern int connlist_check_timeout(void);
139
140 #endif

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