ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_pong.c
Revision: 3109
Committed: Thu Mar 6 19:25:12 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 3482 byte(s)
Log Message:
- Applied Adam's sendto_one_numeric() changes

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     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * 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     #include "s_user.h"
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    
39    
40 michael 2820 static int
41 adx 30 ms_pong(struct Client *client_p, struct Client *source_p,
42     int parc, char *parv[])
43     {
44     struct Client *target_p;
45     const char *origin, *destination;
46    
47 michael 1121 if (parc < 2 || EmptyString(parv[1]))
48 adx 30 {
49 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
50 michael 2820 return 0;
51 adx 30 }
52    
53     origin = parv[1];
54     destination = parv[2];
55    
56     /* Now attempt to route the PONG, comstud pointed out routable PING
57     * is used for SPING. routable PING should also probably be left in
58     * -Dianora
59     * That being the case, we will route, but only for registered clients (a
60     * case can be made to allow them only from servers). -Shadowfax
61     */
62 michael 1652 if (!EmptyString(destination) && match(destination, me.name) &&
63 adx 30 irccmp(destination, me.id))
64     {
65 michael 1169 if ((target_p = hash_find_client(destination)) ||
66     (target_p = hash_find_server(destination)))
67     sendto_one(target_p, ":%s PONG %s %s",
68 michael 1230 source_p->name, origin, destination);
69 michael 1169 else
70 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
71 adx 30 }
72 michael 2820
73     return 0;
74 adx 30 }
75    
76 michael 2820 static int
77 adx 30 mr_pong(struct Client *client_p, struct Client *source_p,
78     int parc, char *parv[])
79     {
80 michael 503 assert(source_p == client_p);
81    
82 adx 30 if (parc == 2 && *parv[1] != '\0')
83     {
84 michael 503 if (ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
85 adx 30 {
86 michael 982 unsigned int incoming_ping = strtoul(parv[1], NULL, 10);
87 michael 503
88     if (incoming_ping)
89     {
90     if (source_p->localClient->random_ping == incoming_ping)
91     {
92     SetPingCookie(source_p);
93 michael 1080 register_local_user(source_p);
94 michael 503 }
95     else
96 michael 3109 sendto_one_numeric(source_p, &me, ERR_WRONGPONG,
97     source_p->localClient->random_ping);
98 adx 30 }
99     }
100 michael 503 }
101 adx 30 else
102 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
103    
104 michael 2820 return 0;
105 adx 30 }
106 michael 1230
107 michael 2820 static struct Message pong_msgtab =
108     {
109 michael 1569 "PONG", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
110 michael 2820 { mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore }
111 michael 1230 };
112    
113     static void
114     module_init(void)
115     {
116     mod_add_cmd(&pong_msgtab);
117     }
118    
119     static void
120     module_exit(void)
121     {
122     mod_del_cmd(&pong_msgtab);
123     }
124    
125 michael 2820 struct module module_entry =
126     {
127 michael 1230 .node = { NULL, NULL, NULL },
128     .name = NULL,
129     .version = "$Revision$",
130     .handle = NULL,
131     .modinit = module_init,
132     .modexit = module_exit,
133     .flags = 0
134     };

Properties

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