ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_pong.c
Revision: 2820
Committed: Wed Jan 15 23:10:26 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3608 byte(s)
Log Message:
- Clean up all files in modules/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years
- Made module handlers int type for later use

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

Properties

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