Branch data Line data Source code
1 : : /*
2 : : Liquid War 6 is a unique multiplayer wargame.
3 : : Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Christian Mauduit <ufoot@ufoot.org>
4 : :
5 : : This program is free software; you can redistribute it and/or modify
6 : : it under the terms of the GNU General Public License as published by
7 : : the Free Software Foundation, either version 3 of the License, or
8 : : (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, see <http://www.gnu.org/licenses/>.
17 : :
18 : :
19 : : Liquid War 6 homepage : http://www.gnu.org/software/liquidwar6/
20 : : Contact author : ufoot@ufoot.org
21 : : */
22 : :
23 : : #ifdef HAVE_CONFIG_H
24 : : #include "config.h"
25 : : #endif
26 : :
27 : : #include "../srv.h"
28 : : #include "mod-udpd-internal.h"
29 : :
30 : : int
31 : 73 : _mod_udpd_send (_udpd_context_t * udpd_context,
32 : : lw6cnx_connection_t * connection,
33 : : u_int32_t physical_ticket_sig, u_int32_t logical_ticket_sig,
34 : : u_int64_t logical_from_id, u_int64_t logical_to_id,
35 : : char *message)
36 : : {
37 : 73 : int ret = 0;
38 : 73 : _udpd_specific_data_t *specific_data =
39 : : (_udpd_specific_data_t *) connection->backend_specific_data;
40 : : char *line;
41 : :
42 : 73 : lw6sys_log (LW6SYS_LOG_DEBUG, _x_ ("mod_udpd send \"%s\""), message);
43 : 73 : line = lw6msg_envelope_generate (LW6MSG_ENVELOPE_MODE_TELNET,
44 : : lw6sys_build_get_version (),
45 : : connection->password_send_checksum,
46 : : physical_ticket_sig,
47 : : logical_ticket_sig,
48 : 73 : connection->local_id_int,
49 : 73 : connection->remote_id_int,
50 : : logical_from_id, logical_to_id, message);
51 [ + - ]: 73 : if (line)
52 : : {
53 [ + - ]: 73 : if (lw6cnx_connection_lock_send (connection))
54 : : {
55 [ + - ]: 73 : if (lw6net_send_line_udp
56 : 73 : (specific_data->sock, line, connection->remote_ip,
57 : : specific_data->remote_port))
58 : : {
59 : 73 : lw6sys_log (LW6SYS_LOG_DEBUG, _x_ ("mod_udpd sent \"%s\""),
60 : : line);
61 : 73 : ret = 1;
62 : : }
63 : 73 : lw6cnx_connection_unlock_send (connection);
64 : : }
65 : 73 : LW6SYS_FREE (line);
66 : : }
67 : :
68 : 73 : return ret;
69 : : }
70 : :
71 : : void
72 : 236 : _mod_udpd_poll (_udpd_context_t * udpd_context,
73 : : lw6cnx_connection_t * connection)
74 : : {
75 : 236 : lw6sys_log (LW6SYS_LOG_DEBUG, _x_ ("mod_udpd poll"));
76 : : /*
77 : : * No real polling here, polling is done in the main loop,
78 : : * at the listener level.
79 : : */
80 : 236 : }
|