ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_pong.c
Revision: 4712
Committed: Tue Oct 7 10:55:48 2014 UTC (10 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 4503 byte(s)
Log Message:
- m_ping.c, m_pong.c: added proper TS6 support

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_pong.c
23     * \brief Includes required functions for processing the PONG command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "ircd.h"
29 michael 3347 #include "user.h"
30 adx 30 #include "client.h"
31 michael 2820 #include "hash.h"
32 adx 30 #include "numeric.h"
33 michael 1309 #include "conf.h"
34 adx 30 #include "send.h"
35     #include "irc_string.h"
36     #include "parse.h"
37     #include "modules.h"
38 michael 4712 #include "server.h"
39 adx 30
40    
41 michael 3346 /*! \brief PONG command handler
42     *
43     * \param source_p Pointer to allocated Client struct from which the message
44     * originally comes from. This can be a local or remote client.
45     * \param parc Integer holding the number of supplied arguments.
46     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
47     * pointers.
48     * \note Valid arguments for this command are:
49     * - parv[0] = command
50     * - parv[1] = origin
51     * - parv[2] = destination
52     */
53 michael 2820 static int
54 michael 3156 ms_pong(struct Client *source_p, int parc, char *parv[])
55 adx 30 {
56 michael 4712 struct Client *target_p = NULL;
57     const char *destination = NULL;
58 adx 30
59 michael 1121 if (parc < 2 || EmptyString(parv[1]))
60 adx 30 {
61 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
62 michael 2820 return 0;
63 adx 30 }
64    
65     destination = parv[2];
66    
67     /* Now attempt to route the PONG, comstud pointed out routable PING
68     * is used for SPING. routable PING should also probably be left in
69     * -Dianora
70     * That being the case, we will route, but only for registered clients (a
71     * case can be made to allow them only from servers). -Shadowfax
72     */
73 michael 1652 if (!EmptyString(destination) && match(destination, me.name) &&
74 adx 30 irccmp(destination, me.id))
75     {
76 michael 1169 if ((target_p = hash_find_client(destination)) ||
77     (target_p = hash_find_server(destination)))
78     sendto_one(target_p, ":%s PONG %s %s",
79 michael 4712 ID_or_name(source_p, target_p), parv[1],
80     ID_or_name(target_p, target_p));
81     else if (!IsDigit(*destination))
82 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
83 adx 30 }
84 michael 2820
85     return 0;
86 adx 30 }
87    
88 michael 3346 /*! \brief PONG command handler
89     *
90     * \param source_p Pointer to allocated Client struct from which the message
91     * originally comes from. This can be a local or remote client.
92     * \param parc Integer holding the number of supplied arguments.
93     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
94     * pointers.
95     * \note Valid arguments for this command are:
96     * - parv[0] = command
97     * - parv[1] = origin/ping cookie
98     */
99 michael 2820 static int
100 michael 3156 mr_pong(struct Client *source_p, int parc, char *parv[])
101 adx 30 {
102 michael 3156 assert(MyConnect(source_p));
103 michael 503
104 michael 3331 if (parc == 2 && !EmptyString(parv[1]))
105 adx 30 {
106 michael 4588 if (ConfigGeneral.ping_cookie && !source_p->connection->registration)
107 adx 30 {
108 michael 982 unsigned int incoming_ping = strtoul(parv[1], NULL, 10);
109 michael 503
110     if (incoming_ping)
111     {
112 michael 4588 if (source_p->connection->random_ping == incoming_ping)
113 michael 503 {
114     SetPingCookie(source_p);
115 michael 1080 register_local_user(source_p);
116 michael 503 }
117     else
118 michael 3109 sendto_one_numeric(source_p, &me, ERR_WRONGPONG,
119 michael 4588 source_p->connection->random_ping);
120 adx 30 }
121     }
122 michael 503 }
123 adx 30 else
124 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
125    
126 michael 2820 return 0;
127 adx 30 }
128 michael 1230
129 michael 2820 static struct Message pong_msgtab =
130     {
131 michael 4545 "PONG", NULL, 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
132 michael 2820 { mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore }
133 michael 1230 };
134    
135     static void
136     module_init(void)
137     {
138     mod_add_cmd(&pong_msgtab);
139     }
140    
141     static void
142     module_exit(void)
143     {
144     mod_del_cmd(&pong_msgtab);
145     }
146    
147 michael 2820 struct module module_entry =
148     {
149 michael 1230 .node = { NULL, NULL, NULL },
150     .name = NULL,
151     .version = "$Revision$",
152     .handle = NULL,
153     .modinit = module_init,
154     .modexit = module_exit,
155     .flags = 0
156     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision