LCOV - code coverage report
Current view: top level - src/lib/srv/mod-udpd - mod-udpd-message.c (source / functions) Hit Total Coverage
Test: liquidwar6.info Lines: 21 21 100.0 %
Date: 2014-03-26 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :   Liquid War 6 is a unique multiplayer wargame.
       3             :   Copyright (C)  2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014  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        9934 : _mod_udpd_send (_mod_udpd_context_t * udpd_context,
      32             :                 lw6cnx_connection_t * connection,
      33             :                 int64_t now,
      34             :                 u_int32_t physical_ticket_sig, u_int32_t logical_ticket_sig,
      35             :                 u_int64_t logical_from_id, u_int64_t logical_to_id,
      36             :                 const char *message)
      37             : {
      38        9934 :   int ret = 0;
      39        9934 :   _mod_udpd_specific_data_t *specific_data =
      40             :     (_mod_udpd_specific_data_t *) connection->backend_specific_data;
      41             :   char *line;
      42             : 
      43        9934 :   lw6sys_log (LW6SYS_LOG_DEBUG, _x_ ("mod_udpd send \"%s\""), message);
      44       19868 :   line = lw6msg_envelope_generate (LW6MSG_ENVELOPE_MODE_TELNET,
      45        9934 :                                    lw6sys_build_get_version (),
      46        9934 :                                    connection->password_send_checksum,
      47             :                                    physical_ticket_sig,
      48             :                                    logical_ticket_sig,
      49             :                                    connection->local_id_int,
      50             :                                    connection->remote_id_int,
      51             :                                    logical_from_id, logical_to_id, message);
      52        9934 :   if (line)
      53             :     {
      54        9934 :       if (lw6cnx_connection_lock_send (connection))
      55             :         {
      56        9934 :           if (lw6net_send_line_udp
      57        9934 :               (specific_data->sock, line, connection->remote_ip,
      58             :                specific_data->remote_port))
      59             :             {
      60        9934 :               lw6sys_log (LW6SYS_LOG_DEBUG, _x_ ("mod_udpd sent \"%s\""),
      61             :                           line);
      62        9934 :               ret = 1;
      63             :             }
      64        9934 :           lw6cnx_connection_unlock_send (connection);
      65             :         }
      66        9934 :       LW6SYS_FREE (line);
      67             :     }
      68             : 
      69        9934 :   return ret;
      70             : }
      71             : 
      72             : int
      73      523290 : _mod_udpd_can_send (_mod_udpd_context_t * udpd_context,
      74             :                     lw6cnx_connection_t * connection)
      75             : {
      76      523290 :   return 1;
      77             : }
      78             : 
      79             : void
      80     3572604 : _mod_udpd_poll (_mod_udpd_context_t * udpd_context,
      81             :                 lw6cnx_connection_t * connection)
      82             : {
      83     3572604 :   lw6sys_log (LW6SYS_LOG_DEBUG, _x_ ("mod_udpd poll"));
      84             :   /*
      85             :    * No real polling here, polling is done in the main loop,
      86             :    * at the listener level.
      87             :    */
      88     3572604 : }

Generated by: LCOV version 1.10