ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_pong.c
Revision: 1569
Committed: Tue Oct 16 18:46:53 2012 UTC (12 years, 10 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_pong.c
File size: 3621 byte(s)
Log Message:
- Removed remnants of MFLG_UNREG which is no longer needed with the
  current implementation of message handlers

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_pong.c: The reply to a ping message.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "ircd.h"
27     #include "s_user.h"
28     #include "client.h"
29     #include "hash.h" /* for find_client() */
30     #include "numeric.h"
31 michael 1309 #include "conf.h"
32 adx 30 #include "send.h"
33     #include "irc_string.h"
34     #include "parse.h"
35     #include "modules.h"
36    
37    
38     static void
39     ms_pong(struct Client *client_p, struct Client *source_p,
40     int parc, char *parv[])
41     {
42     struct Client *target_p;
43     const char *origin, *destination;
44    
45 michael 1121 if (parc < 2 || EmptyString(parv[1]))
46 adx 30 {
47     sendto_one(source_p, form_str(ERR_NOORIGIN),
48 michael 1230 me.name, source_p->name);
49 adx 30 return;
50     }
51    
52     origin = parv[1];
53     destination = parv[2];
54    
55     /* Now attempt to route the PONG, comstud pointed out routable PING
56     * is used for SPING. routable PING should also probably be left in
57     * -Dianora
58     * That being the case, we will route, but only for registered clients (a
59     * case can be made to allow them only from servers). -Shadowfax
60     */
61     if (!EmptyString(destination) && !match(destination, me.name) &&
62     irccmp(destination, me.id))
63     {
64 michael 1169 if ((target_p = hash_find_client(destination)) ||
65     (target_p = hash_find_server(destination)))
66     sendto_one(target_p, ":%s PONG %s %s",
67 michael 1230 source_p->name, origin, destination);
68 michael 1169 else
69     {
70     sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
71 michael 1230 me.name, source_p->name, destination);
72 michael 1169 return;
73     }
74 adx 30 }
75     }
76    
77     static void
78     mr_pong(struct Client *client_p, struct Client *source_p,
79     int parc, char *parv[])
80     {
81 michael 503 assert(source_p == client_p);
82    
83 adx 30 if (parc == 2 && *parv[1] != '\0')
84     {
85 michael 503 if (ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
86 adx 30 {
87 michael 982 unsigned int incoming_ping = strtoul(parv[1], NULL, 10);
88 michael 503
89     if (incoming_ping)
90     {
91     if (source_p->localClient->random_ping == incoming_ping)
92     {
93     SetPingCookie(source_p);
94 michael 1080 register_local_user(source_p);
95 michael 503 }
96     else
97     {
98     sendto_one(source_p, form_str(ERR_WRONGPONG), me.name,
99     source_p->name, source_p->localClient->random_ping);
100     return;
101     }
102 adx 30 }
103     }
104 michael 503 }
105 adx 30 else
106 michael 1230 sendto_one(source_p, form_str(ERR_NOORIGIN),
107     me.name, source_p->name);
108 adx 30 }
109 michael 1230
110     static struct Message pong_msgtab = {
111 michael 1569 "PONG", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
112 michael 1230 {mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore}
113     };
114    
115     static void
116     module_init(void)
117     {
118     mod_add_cmd(&pong_msgtab);
119     }
120    
121     static void
122     module_exit(void)
123     {
124     mod_del_cmd(&pong_msgtab);
125     }
126    
127     struct module module_entry = {
128     .node = { NULL, NULL, NULL },
129     .name = NULL,
130     .version = "$Revision$",
131     .handle = NULL,
132     .modinit = module_init,
133     .modexit = module_exit,
134     .flags = 0
135     };

Properties

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