/[LeafOK_CVS]/pvpgn-1.7.4/src/bnetd/handle_init.c
ViewVC logotype

Annotation of /pvpgn-1.7.4/src/bnetd/handle_init.c

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, MAIN
CVS Tags: pvpgn_1-7-4-0_MIL, arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-csrc
no message

1 sysadm 1.1 /*
2     * Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu)
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     #include "common/setup_before.h"
19     #ifdef HAVE_STDDEF_H
20     # include <stddef.h>
21     #else
22     # ifndef NULL
23     # define NULL ((void *)0)
24     # endif
25     #endif
26     #include "common/packet.h"
27     #include "common/init_protocol.h"
28     #include "common/eventlog.h"
29     #include "common/queue.h"
30     #include "common/bn_type.h"
31     #include "connection.h"
32     #include "realm.h"
33     #include "prefs.h"
34     #include "common/addr.h"
35     #include "handle_init.h"
36     #include "handle_d2cs.h"
37     #include "common/setup_after.h"
38    
39    
40     extern int handle_init_packet(t_connection * c, t_packet const * const packet)
41     {
42     if (!c)
43     {
44     eventlog(eventlog_level_error,__FUNCTION__,"[%d] got NULL connection",conn_get_socket(c));
45     return -1;
46     }
47     if (!packet)
48     {
49     eventlog(eventlog_level_error,__FUNCTION__,"[%d] got NULL packet",conn_get_socket(c));
50     return -1;
51     }
52     if (packet_get_class(packet)!=packet_class_init)
53     {
54     eventlog(eventlog_level_error,__FUNCTION__,"[%d] got bad packet (class %d)",conn_get_socket(c),(int)packet_get_class(packet));
55     return -1;
56     }
57    
58     switch (packet_get_type(packet))
59     {
60     case CLIENT_INITCONN:
61     switch (bn_byte_get(packet->u.client_initconn.class))
62     {
63     case CLIENT_INITCONN_CLASS_BNET:
64     eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated bnet connection",conn_get_socket(c));
65     conn_set_state(c,conn_state_connected);
66     conn_set_class(c,conn_class_bnet);
67    
68     break;
69    
70     case CLIENT_INITCONN_CLASS_FILE:
71     eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated file download connection",conn_get_socket(c));
72     conn_set_state(c,conn_state_connected);
73     conn_set_class(c,conn_class_file);
74    
75     break;
76    
77     case CLIENT_INITCONN_CLASS_BOT:
78     eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated chat bot connection",conn_get_socket(c));
79     conn_set_state(c,conn_state_connected);
80     conn_set_class(c,conn_class_bot);
81    
82     break;
83    
84     case CLIENT_INITCONN_CLASS_TELNET:
85     eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated telnet connection",conn_get_socket(c));
86     conn_set_state(c,conn_state_connected);
87     conn_set_class(c,conn_class_telnet);
88    
89     break;
90    
91     case CLIENT_INITCONN_CLASS_D2CS_BNETD:
92     {
93     eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated d2cs_bnetd connection",conn_get_socket(c));
94    
95     if (!(realmlist_find_realm_by_ip(conn_get_addr(c))))
96     {
97     eventlog(eventlog_level_info,__FUNCTION__, "[%d] d2cs connection from unknown ip address %s",conn_get_socket(c),addr_num_to_addr_str(conn_get_addr(c),conn_get_port(c)));
98     return -1;
99     }
100    
101     conn_set_state(c,conn_state_connected);
102     conn_set_class(c,conn_class_d2cs_bnetd);
103     if (handle_d2cs_init(c)<0)
104     {
105     eventlog(eventlog_level_info,__FUNCTION__,"faild to init d2cs connection");
106     return -1;
107     }
108     }
109     break;
110    
111     case CLIENT_INITCONN_CLASS_ENC:
112     eventlog(eventlog_level_info,__FUNCTION__,"[%d] client initiated encrypted connection (not supported)",conn_get_socket(c));
113     return -1;
114    
115     default:
116     eventlog(eventlog_level_error,__FUNCTION__,"[%d] client requested unknown class 0x%02x (length %d) (closing connection)",conn_get_socket(c),(unsigned int)bn_byte_get(packet->u.client_initconn.class),packet_get_size(packet));
117     return -1;
118     }
119     break;
120     default:
121     eventlog(eventlog_level_error,__FUNCTION__,"[%d] unknown init packet type 0x%04x, len %u",conn_get_socket(c),packet_get_type(packet),packet_get_size(packet));
122     return -1;
123     }
124    
125     return 0;
126     }
127    
128    

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